-
Notifications
You must be signed in to change notification settings - Fork 325
Code completing a named parameter doesn't show me the types that could go there #998
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
/cc @danrubel, re: adding type info in for named parameters (perhaps just passing Elements in for those completion items would do it?) |
Because Flutter loves to use named parameters in constructors, this would be a big win. Thank you! :) |
We could do some better filtering (false doesn't make sense for example) but really we want the user to type cc @lukechurch |
AI @pq: look at what proposals we get from |
why do I need to type new? Sometimes I might want const. Or, sometimes it's a static or enum that goes here. |
Well, @sethladd : in an ideal world what completions would you like to see? All extenders/implementers of @danrubel : thoughts? |
Yup! Even if they come from statics or enums available to me. |
From chatting with Dan, this could be improved with suggestions based on type matching. Infrastructure is in place and the issue can be solved generally. That said, will investigate with the decorations case as a driving force. |
@danrubel to investigate. |
Great, thanks! |
@pq is this an analyzer issue or an IJ issue? |
Analysis server. cc @danrubel |
Nice improvement! What happens if I try to complete without first typing "new" or "const" ? For example:
|
No changes here. |
[email protected], [email protected] Bug: flutter/flutter-intellij#998 Change-Id: I88eb345bfa7f0a65d135e5fdcb443d5dadd695c5 Reviewed-on: https://dart-review.googlesource.com/42882 Reviewed-by: Dan Rubel <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
As long as we don't do what the screenshot in #998 (comment) is doing, then I'm happy :) (Put another way, if I try to code complete immediately after a named parameter, show me ONLY what I can put there (both variables whose types match, as well as constructor calls that apply), don't show me variables whose types don't even match.) |
It always raises a question of "transitive applicability". class A {}
class B {
A a;
}
void foo({A a}) {}
main(B b) {
foo(a: ^);
} |
That's fair. I assume that we won't show "true" or "false" as options in your example? |
We will. Because we don't look at the type of the thing being proposed to ensure that there is a chain of invocations that will get you the type of thing you need. (Hence, we can't know that there isn't.) |
Oh, bummer. That was the original request. :) In a world with optional new/const, we can expect that developers won't first type 'new' or 'const' in order to trigger the useful code completions. Are there other completion models here that assume new and const won't be used, but also return the more likely/useful options? true/false/const/etc just aren't useful :( |
IMO it's all about the "relevance" of the suggestion. In this situation, types that match should have a higher relevance than suggestions that do not, and the IDE should display suggestions ranked by the relevance returned by the analysis server... more relevant suggestions first. |
Well, But that aside, there are two things I can think of that we could do. The first is what Dan said: to prioritize suggestions that already have the right type over those that don't, so that less useful ones show up lower in the list. I do think we should do that. The second is to special case |
So, we don't suggest EdgeInsetsGeometry for 'padding: ', even though it is the type of the parameters. But we still suggest its subclasses EdgeInsets and EdgeInsetsDirectional. [email protected], [email protected] Bug: flutter/flutter-intellij#998 Change-Id: If2d7ba550ec76e4f66cb81e1346466b5f1a30464 Reviewed-on: https://dart-review.googlesource.com/42888 Reviewed-by: Brian Wilkerson <[email protected]>
This sounds like a pretty elegant solution - we'll still show all correct suggestions (and allow users to compete through a few expressions to their end goal) but will show the most immediately useful suggestions first. |
+1 for sorting matching types higher! |
No prioritizing matching types yet, but this CL will include constructor invocations for implicit creation. So, you can complete |
Nice! I see this screenshot starts with "EdIn" ... Does the same result happen if you code complete immediately after the |
Yes, I actually activated completion right after |
Well then, double nice! :) Thank you! |
[email protected] Bug: flutter/flutter-intellij#998 Change-Id: I43270f47fb43402d1a9e0f7d9814494ffd83bb5e Reviewed-on: https://dart-review.googlesource.com/43080 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
OK, we can prioritize completion suggestions in Dart Analysis Server. Unfortunately IntelliJ has its own opinions about completions and their relevance. Here, nothing is typed yet, but the suggestions with compatible types are on the top, and sorted alphabetically. |
Wow! The top results look very relevant and useful. |
Exact type get the largest relevance boost, subtypes a smaller boost, and the rest has default relevance for its element kind. [email protected], [email protected] Bug: flutter/flutter-intellij#998 Change-Id: Ibb38caedc314e9cf476de2116aeb61bcec8c8a08 Reviewed-on: https://dart-review.googlesource.com/43263 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
Very nice! |
And one more fix, for completing imported enums. So, you can complete Don't pay attention to |
@scheglov yes yes yes yes yes you are on 🔥 |
So, you can complete `Column(crossAxisAlignment: ^)` and get all of the CrossAxisAlignment right away for selection. Or you can start typing `center` and by the time when you typed first letters, you get several completion suggestions. There are several enums with `center`, but because we give compatible types higher relevance, the correct one is always the first. [email protected], [email protected] Bug: flutter/flutter-intellij#998 Change-Id: I6c2082668c6b25bf23e070915b5df03081ff0d5c Reviewed-on: https://dart-review.googlesource.com/43485 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
I consider this issue fixed now, at least Analysis Server side of it. |
Thank you very much! |
This is awesome! Thank you. |
I wonder if we could show all the types of Decoration we have, when trying to code complete
decoration:
in a Container?Here's what we see now:
Those options aren't useful, unfortunately. However, since we know that
decoration:
takes aDecoration
, could we show the options for Decoration here? (e.g. BoxDecoration)I'm still learning the Flutter APIs, and bouncing back and forth between API docs and my IDE is less than efficient. I want to code complete my way to success! :)
Thanks!
The text was updated successfully, but these errors were encountered: