-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Improve IDE IntelliSense/autocomplete for types with static/constants #35587
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
Interesting.
![]() |
It has been considered, and I'd love to have it. I just don't know any way to determine "can lead to a value of the right type" in a performant way. If you know of one I'd love to hear about it. Also, your categorical statement isn't true. You can get to them if there's an extension method that allows it.
True, but it's valid in lots of places, including here.
That's an aspect that I wanted to explore taking into account in the relevance tables. IIRC, the code that currently builds the relevance tables only looks at the first token in most cases (I think there's an exception for enum constants). I wanted to see whether we'd get better results if the table builder looked past the first token to identify static field and static method references. I haven't had time, but I still think it would be interesting to explore.
This is an interestingly hard question. Most users do want to reference a field from We've talked several times about whether there should be a limit; something along the line of "we'll add static fields if there are less than N of them". We've also talked about whether the relevance of class names should always be higher than the relevance of static members of the class. We haven't so far had time to compare the variations to find the right answer. |
We made a decision, a long time ago, that we were going to suggest anything that could be valid no matter how unlikely it is to be what the user wants, and let the relevance take care of moving it to the bottom. Maybe that was the wrong choice, but that's a different conversation.
Yes. I obviously wasn't being clear. We currently add all fields. I think there's a case to be made that it might be better for users if we didn't include any of the fields of And be less surprising when some of the fields are displayed and others not.
Not necessarily. If there were some top-level variable, like |
Dart VM version:
2.1.0-dev.9.4.flutter-f9ebf21297 (Thu Nov 8 23:00:07 2018 +0100) on "linux_x64"
When using an IDE, when an argument of a certain type is required, classes with static getters or constants of that type could be suggested, for example:
Here,
B.staticMember
should be an autocomplete suggestion.See this Flutter example:
The IDE suggests
MaterialColor(
, but what the user probably needs isColors.
, so this should be the first suggestion. (primarySwatch
is of typeMaterialColor
and theColors
class includes many static constants of typeMaterialColor
).Originally filed in Dart-Code/Dart-Code#1375
The text was updated successfully, but these errors were encountered: