-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Analyzer suggests auto-complete items that are not useful #35863
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
Comments
The source code appears to contradict the second statement, so I'm not sure I understand what the problem is. But if the issue is that server isn't suggesting names from libraries that are not imported but could be, then we're already working on fixing the issue.
I agree that it would be useful for server to prioritize suggestions that match the target type when such a type is known. I would love to see us add support for that.
The filtering is actually being done by the client, not by the server. @jwren @alexander-doroshko for feedback on the filtering. It would be interesting to know where |
Yes, is there a bug tracking this particular issue?
Is it worth filing a separate issue specifically for this?
In this case it was actually VSCode, not IntelliJ (/cc @DanTup), fwiw. |
Yes, the issue is #25820.
Given that using type information to prioritize suggestions is (I think) the only analyzer issue left that isn't being worked on elsewhere, I think it's fine if we use this issue to track it. |
Speaking of IntelliJ, it has 2 shortcuts for code completion: standard (Ctrl+Space) and Smart Completion (Ctrl+Shift+Space). Standard completion suggests everything available at the caret position. Smart Completion suggests only those items that match expected type. It even includes chained calls that result in expected type. Unfortunately, Smart Completion is not yet supported in Dart but you may try it in Java and in some other languages to get the idea. If you like the idea we may think about implementing the feature on the Analysis Server end and integrating it in IDEs. |
And speaking of middle-matching and sorting, IntelliJ shows items with exact matches higher than items with fractional matches, so 'DefenseDice' would be close to top if it were in the list. Middle-matching, case-sensivity and other completion options are configurable in IntelliJ. |
This was raised in Dart Code previously too, but I think filtering out unrelated types may be bad because there could be static members on those types that you want. For example in MaterialDemoDocumentationButton(SnackBarDemo.routeName) That constructor takes a
The filtering is done client-side so this is VS Code behaviour. It seems like you might not be able to disable it though there is |
The available declarations support addressed at least one of the issues raised here. We're also now paying attention to the context type, so that ought to address at least one of the issues. I'm going to close this but please let me know if we've missed something important that isn't yet resolved. |
My file looks approximately like this:
I wanted a suggestion of
package:swlegion/holodeck.dart
, which includes aDefenseDice
class.I hit
CTRL-SPACE
, and got:A few comments/requests:
I was assigning to
DefensePool.dice
, which reads:... so I think it would be ideal to only suggest types that are valid assignments to
DefenseDice
.I typed
dice
, assuming that it would auto-complete toDefenseDice
but instead got:... etc. Maybe this makes sense up to say, 2 characters, but clearly by typing
dice
I did not intend to writeUri.directory
. In fact,DefenseDice
does not show up at all in the list no matter what I type and try to complete, because it is not imported. But that's unfortunate, because it is one of my dependencies.The text was updated successfully, but these errors were encountered: