Support completions for enums in switch cases#16864
Conversation
|
Is there prior art where we return an entire qualified name as a completion? I was expecting we'd return the valid enum type names as completions, you pick one, you type ".", then member completion takes over. |
|
99% of the time there will only be one valid enum. I think this is the first time we would have a place where we return a qualified name though; it's also the first place where we return something semantically meaningful that isn't a property name or the name of a local/global variable. |
|
We don't populate the completion list with all the members on |
rbuckton
left a comment
There was a problem hiding this comment.
This seems too restrictive, and I concur with @weswigham that we currently don't use qualified names anywhere else. C# does not do this in VS, are there any other languages/editors where this is a common practice?
| if (isRightOfDot) { | ||
| getTypeScriptMemberSymbols(); | ||
| } | ||
| else if (isRightOfCase) { |
There was a problem hiding this comment.
Wouldn't this restrict completions to only enum completions and prevent completions for locals? That is too restrictive.
| return links.switchTypes; | ||
| } | ||
|
|
||
| function getRemainingSwitchCaseTypes(node: SwitchStatement): Type[] | undefined { |
There was a problem hiding this comment.
i would move this to services, and use getTypeAtLocation for switch labels.
mhegazy
left a comment
There was a problem hiding this comment.
I do not think this is the right approach here..
A better approach is to mark completion list item as "suggested ", I think Roslyn refers to this as suggestedCompletion https://github.com/dotnet/roslyn/blob/878ffad23b8b06cb229c9ab31eada7634a473508/src/Features/Core/Portable/Completion/CompletionList.cs#L48
For instance in switch (node.kind) { case | you would get SyntaxKind highlighted as a suggested completion automatically..
We should also do the same for operators of ===/==/!=/!== and whenever there is a contextual type.
|
I do not think this is needed anylonger. |
|
Ref: #20020 |
Support getting completions to the right of the
casekeyword.Doesn't include already-covered cases.
Does not address #13711 as that scenario is if you just typed
E.. That will require a lot more refactoring (which should be done anyway).