-
Notifications
You must be signed in to change notification settings - Fork 822
TypeApp, type parameter completions #12933
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
Conversation
// Unchecked.defaultof<str$> | ||
| SynExpr.TypeApp (typeArgsRange = range) when rangeContainsPos range pos -> | ||
Some CompletionContext.TypeApp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In light of points 3 and 4, I'd rather remove CompletionContext.TypeApp
and abuse CompletionContext.PatternType
. The reason is that we might like to have the TypeApp
case carry further information in the future, and we'd be making a breaking change then.
|> Seq.map (fun kvp -> Item.TypeVar (kvp.Key, kvp.Value)) | ||
|> Seq.toList | ||
|
||
unqualifiedItems @ activePatternItems @ moduleAndNamespaceItems @ tycons @ constructors @ typeVars |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure ResolvePartialLongIdentPrim
is the place to insert these type variables as it's outside of the FCS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure exactly what you mean by 'outside of FCS' here. This seems like a reasonable change, and sometimes lower level changes need to be made in order to surface better behaviors in the user-facing APIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's outside of the service folder, so I thought this file was part of the compiler proper.
Let me know how you want to proceed. If the PR is acceptable as it is, I'll just update the surface area. |
Is it possible to add some tests for type-parameters completions? Just couple of simple ones? Overall, I think, this is great, @KevinRansom @cartermp thoughs? |
Good idea, that slipped my mind. |
Two more points.
For |
Thanks! |
The first part of this PR deals with completions inside of a type application (
SynExpr.TypeApp
). Givenpressing Ctrl-space on
str
will now only show type-like completions. Currently the list also contains keywords and functions.Secondly, type variables (parameters) in scope are now included in the list of completions. Given
pressing Ctrl-space on
va
orty
will show type-like completions, includingvalueType
andtyp
, respectively.'
(or^
for SRTPs) is added automatically when the completion is used. (I have a vague memory this was thing in the past, and that you'd often end up with 2 apostrophes. Maybe in Power Tools pre-Roslyn?)Thirdly, type variables now have (currently not really useful) tooltips and are clickable (F12 navigation works already).
Thoughts/open issues (for future PRs?)
In C# tooltips for type parameters show where the latter is declared.

Typar
doesn't seem to directly contain such information. Is there a way I can quickly find out the record/union/type definition or method/function as the point of declaration?Because

denv.showConstraintTyparAnnotations
isfalse
, SRTP tooltips show up with an apostrophe instead of a caret, which looks a bit weird.I would like to see only type-like completions pop up in all of these cases
The parser detects an error and reports
SynExpr.App
, and the presence of a less than/inequality operator, so theTypeApp
completion context cannot be immediately established. Unfortunately, because of type inference, we cannot really rule out the possiblity that the user wants to make a comparison, however unlikely it would be in these 5 functions.When type variables are in scope, I feel they should have a high priority on the completion list, because are likely to be used. When
func<' >
is typed, they should certainly be the only items on the list.typeparam
XmlDoc does not appear to be collected on a function. We could at least show that in the tooltip.