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

Code Completion not optimized behaviour: Code Completion gives the class constructor as 2nd, or 7th suggestion, instead of first. #48600

Open
CMMT20 opened this issue Mar 17, 2022 · 1 comment
Assignees
Labels
analyzer-completion Issues with the analysis server's code completion feature 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 type-enhancement A request for a change that isn't a bug

Comments

@CMMT20
Copy link

CMMT20 commented Mar 17, 2022

*I have already read the related threads, so i will summarize and reference what is already said in those.

Context: I'm building a flutter mobile app, using Android Studio, last version. When you are writing code, and have in mind the functionalities you want to build. Stopping to write, to correct symbols, that stops your flow a lot, that is why this is relevant.

In the specific case of widgets, the Code Completion not desired behaviour is that gives more relevance to the widget name Scaffold than to the widget constructor Scaffold(). So the widget name appears first in Code Completion.
1 autocompletion

clarification for those not familiar with the subject
If you look at the image, the first suggestion, the one with the blue circle with a C in the left
It is the widget name, if you select it you get this Scaffold so you must type by yourself () to finish it

the 7th suggestion, the one with the orange circle in the left
It is the widget constructor, if you select it, you get this Scaffold() so you don't need type the rest
lots of () is lot of time

You can improve sorting by name the code completion, but still improvable:
4 autocompletion sort by name

The key question is:
How can you get from Code Completion the class constructor as first suggestion, not as 2nd, or 7th

After asking to the IDE team
1 The order in these code complete suggestions is not given by the IDE software (Android Studio), but it is given by the dart sdk software
Reference:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/4682230867346-Android-Studio-how-to-optimize-Code-Completion-behaviour-How-can-you-get-from-Code-Completion-the-class-constructor-as-first-suggestion-not-as-2nd

"Unfortunately it's not something that is controlled by the Dart plugin. Code completion, highlighting, quick fixes and other code insight features are powered by the Dart Analysis Server, a tool from the Dart SDK. IDE only shows what server asks it to show. For the reference, issues specific to the Dart Analysis Server are tracked in https://github.com/dart-lang/sdk/issues. Please feel free to submit a ticket there"

1.2 But sometimes the IDE can ignore this order and remake the order.
microsoft/vscode#79516 (comment)

After reading the related threads:
2 The order is given by the relevance, that comes from the relevance tables.
These tables was made from code repositories samples some years ago.

So the key question goes to:
1 If the dart team sees this correct, class constructor is more relevant than class name
to change the tables
2 If does not
how can you change, customize those tables in order to

  • change the relevance to fit your code usage
  • change the order in code completion suggestions
@scheglov
Copy link
Contributor

@bwilkerson

@scheglov scheglov added the P2 A bug or feature request we're likely to work on label Mar 23, 2022
@scheglov scheglov self-assigned this Mar 11, 2024
@srawlins srawlins added analyzer-completion Issues with the analysis server's code completion feature type-enhancement A request for a change that isn't a bug and removed analyzer-server labels Mar 14, 2024
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 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 type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants