Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve auto-complete for override #59930

Open
FMorschel opened this issue Jan 17, 2025 · 7 comments
Open

Improve auto-complete for override #59930

FMorschel opened this issue Jan 17, 2025 · 7 comments
Labels
analyzer-completion Issues with the analysis server's code completion feature analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on

Comments

@FMorschel
Copy link
Contributor

FMorschel commented Jan 17, 2025

If you type @override and ask for auto-completion, this is the output sample:

Image

When you continue writing value, VS Code filters it client-side:

Image

But if you close that auto-complete and come back, these are the outputs:

  • Asking for auto-complete after override and before value:

Image

  • Asking for auto-complete after it all:

Image

I'd like to request that the two last examples work the same as the second image.

CC @DanTup

@FMorschel FMorschel added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Jan 17, 2025
@scheglov
Copy link
Contributor

Good idea.

If possible, please also take into account what IntelliJ would do, and if any changes are required there too.

@scheglov scheglov added analyzer-completion Issues with the analysis server's code completion feature analyzer-server P2 A bug or feature request we're likely to work on labels Jan 17, 2025
@bwilkerson
Copy link
Member

The "problem" here is that our code completion is based on the semantics of the code rather than the lexical qualities of the code, but the filtering, as you noted, is based on the lexical qualities.

When you complete after @override the identifier has been resolved to an existing element, so our code completion engine knows that you're completing an override annotation and guesses that you might want help inserting an override of some inherited member. VS Code does filtering based on text, so the lack of a space is ignored in that process.

But when you complete after @overridevalue, it sees that you're trying to complete a name that starts with overridevalue, and can't find any names matching that pattern. It doesn't try inserting a space into the name to see whether it can find a known name that you might have meant. The same is true when completing in the middle of overridevalue, it just changes the prefix used by the completion engine to filter the results such that a few suggestions show up.

We could, potentially, special case override by checking whether the identifier starts with override, but I'm not sure how much value that adds across our users.

As a work around, I'll note that if you start typing the name of the inherited member (without the @override) it will also provide suggestions for overriding the inherited member, and that form has (or should have, I haven't tested it) the ability to correctly resume the operation if the cursor is moved during the process.

@FMorschel
Copy link
Contributor Author

FMorschel commented Jan 17, 2025

or should have, I haven't tested it

It doesn't apparently, only if you continue writing (removing/adding characters - second recording):

20250117_155132.mp4
20250117_155641.mp4

About IntelliJ, it does have the same behaviour I mentioned above as vscode. But I can't seem to enable the same auto-complete for overriding when writing down the member name:

20250117_155549.mp4

So it seems that at least right now, for IntelliJ users this @override special-casing would be helpful.

@scheglov
Copy link
Contributor

I think special casing (in DAS, VS Code, and IntelliJ) @overrideXYZ is totally reasonable. This will provide a useful feature for our user, and chances of false positives don't look too bad. Currently @over, without complete @override and without anything after full @override, is already special cased in DAS.

@bwilkerson
Copy link
Member

It doesn't apparently, only if you continue writing ...

That sounds like a bug.

But I can't seem to enable the same auto-complete for overriding when writing down the member name:

That also sounds like a bug.

Currently @over, without complete @override and without anything after full @override, is already special cased in DAS.

What's special cased, iirc, is the override element from dart:core, not the text.

Personally, I'd much rather see us support @override va^ as a way to get these suggestions than to support @overrideva. I think it would be much more discoverable and hence more useful.

@FMorschel
Copy link
Contributor Author

FMorschel commented Jan 17, 2025

Personally, I'd much rather see us support @override va^ as a way to get these suggestions than to support @overrideva. I think it would be much more discoverable and hence more useful.

If that is at all possible I agree it'd be better.

Should I file other issues for the above or can we use this to track that work too?

@bwilkerson
Copy link
Member

I think we can use this issue for all of the 'override' related bugs. If it gets too confusing we can try out the new sub-issue feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-completion Issues with the analysis server's code completion feature analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

3 participants