Handle completions in interface / type literal similar to class#22701
Conversation
5b2a5f6 to
60a9c87
Compare
60a9c87 to
7bac82f
Compare
| // class c { method() { } b| } | ||
| return isFromObjectTypeDeclaration(location) && (location.parent as ClassElement | TypeElement).name === location | ||
| ? location.parent.parent as ObjectTypeDeclaration | ||
| : tryCast(location, isClassLike); |
There was a problem hiding this comment.
why is this not isObjectTypeDeclaration ?
| return tryCast(contextToken.parent, isObjectTypeDeclaration); | ||
| default: | ||
| return isFromObjectTypeDeclaration(contextToken) && | ||
| (isClassMemberCompletionKeyword(contextToken.kind) || isIdentifier(contextToken) && isClassMemberCompletionKeywordText(contextToken.text)) |
There was a problem hiding this comment.
hmm dont you need it to be classMemberCompletion if its call location and "readonly" in type literals and interfaces
| ////} | ||
| ////class O extends B { | ||
| //// constructor(public a) { | ||
| //// }, |
|
|
||
| ////interface a { /*interfaceValue1*/ | ||
|
|
||
| goTo.eachMarker(() => verify.completionListIsEmpty()); |
There was a problem hiding this comment.
can you instead of deleting this have test case that verifies "aa" is not present in the completion
There was a problem hiding this comment.
completionsInterfaceElement does basically the same thing -- verify.completionsAt will fail if there were completions we didn't list.
|
|
||
| ////interface a { f/*interfaceValue2*/ | ||
|
|
||
| goTo.eachMarker(() => verify.completionListIsEmpty()); |
There was a problem hiding this comment.
can you instead of deleting this have test case that verifies "aa" is not present in the completion
There was a problem hiding this comment.
There is a test in completionsInterfaceElement just like this.
| //// m(): void; | ||
| //// fo/*i*/ | ||
| ////} | ||
| ////type T = { fo/*t*/ }; |
There was a problem hiding this comment.
Also need test case when interface I { /marker/ } and similar type literal
| ////} | ||
| ////type T = { fo/*t*/ }; | ||
|
|
||
| //verify.completionsAt("i", ["readonly"]); |
There was a problem hiding this comment.
why is this commented out?
| function tryGetClassLikeCompletionSymbols(): GlobalsSearch { | ||
| const classLikeDeclaration = tryGetClassLikeCompletionContainer(contextToken); | ||
| if (!classLikeDeclaration) return GlobalsSearch.Continue; | ||
| const decl = contextToken && tryGetObjectTypeDeclarationCompletionContainer(contextToken, location); |
There was a problem hiding this comment.
this seems like change from previous behaviour where event if contextToken was not present we would use location to decide on class location. Why is this changed ?
Fixes #22672
Previously we provided global completions inside of interfaces / type literals. Now we will only provide the
readonlykeyword.