-
Notifications
You must be signed in to change notification settings - Fork 13k
Handle completions in interface / type literal similar to class #22701
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
5b2a5f6
to
60a9c87
Compare
60a9c87
to
7bac82f
Compare
src/services/completions.ts
Outdated
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this not isObjectTypeDeclaration
?
src/services/completions.ts
Outdated
return tryCast(contextToken.parent, isObjectTypeDeclaration); | ||
default: | ||
return isFromObjectTypeDeclaration(contextToken) && | ||
(isClassMemberCompletionKeyword(contextToken.kind) || isIdentifier(contextToken) && isClassMemberCompletionKeywordText(contextToken.text)) |
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.
hmm dont you need it to be classMemberCompletion if its call location and "readonly" in type literals and interfaces
@@ -114,7 +114,7 @@ | |||
////} | |||
////class O extends B { | |||
//// constructor(public a) { | |||
//// }, |
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.
why is this change?
|
||
////interface a { /*interfaceValue1*/ | ||
|
||
goTo.eachMarker(() => verify.completionListIsEmpty()); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a test in completionsInterfaceElement
just like this.
//// m(): void; | ||
//// fo/*i*/ | ||
////} | ||
////type T = { fo/*t*/ }; |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this commented out?
src/services/completions.ts
Outdated
@@ -1527,58 +1528,51 @@ namespace ts.Completions { | |||
* Relevant symbols are stored in the captured 'symbols' variable. | |||
*/ | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
readonly
keyword.