-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Completion list for a class extending another class should contain me…
…mbers from base class Handles #7158
- Loading branch information
1 parent
1db4f96
commit 945f675
Showing
9 changed files
with
313 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
tests/cases/fourslash/completionEntryForClassMembers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
///<reference path="fourslash.ts" /> | ||
|
||
////abstract class B { | ||
//// abstract getValue(): number; | ||
//// /*abstractClass*/ | ||
////} | ||
////class C extends B { | ||
//// /*classThatIsEmptyAndExtendingAnotherClass*/ | ||
////} | ||
////class D extends B { | ||
//// /*classThatHasAlreadyImplementedAnotherClassMethod*/ | ||
//// getValue() { | ||
//// return 10; | ||
//// } | ||
//// /*classThatHasAlreadyImplementedAnotherClassMethodAfterMethod*/ | ||
////} | ||
////class E { | ||
//// /*classThatDoesNotExtendAnotherClass*/ | ||
////} | ||
////class F extends B { | ||
//// public /*classThatHasWrittenPublicKeyword*/ | ||
////} | ||
////class G extends B { | ||
//// static /*classElementContainingStatic*/ | ||
////} | ||
////class H extends B { | ||
//// prop/*classThatStartedWritingIdentifier*/ | ||
////} | ||
////class I extends B { | ||
//// prop0: number | ||
//// /*propDeclarationWithoutSemicolon*/ | ||
//// prop: number; | ||
//// /*propDeclarationWithSemicolon*/ | ||
//// prop1 = 10; | ||
//// /*propAssignmentWithSemicolon*/ | ||
//// prop2 = 10 | ||
//// /*propAssignmentWithoutSemicolon*/ | ||
//// method(): number | ||
//// /*methodSignatureWithoutSemicolon*/ | ||
//// method2(): number; | ||
//// /*methodSignatureWithSemicolon*/ | ||
//// method3() { | ||
//// /*InsideMethod*/ | ||
//// } | ||
//// /*methodImplementation*/ | ||
//// get c() | ||
//// /*accessorSignatureWithoutSemicolon*/ | ||
//// set c() | ||
//// { | ||
//// } | ||
//// /*accessorSignatureImplementation*/ | ||
////} | ||
////class J extends B { | ||
//// get /*classThatHasWrittenGetKeyword*/ | ||
////} | ||
////class K extends B { | ||
//// set /*classThatHasWrittenSetKeyword*/ | ||
////} | ||
////class J extends B { | ||
//// get identi/*classThatStartedWritingIdentifierOfGetAccessor*/ | ||
////} | ||
////class K extends B { | ||
//// set identi/*classThatStartedWritingIdentifierOfSetAccessor*/ | ||
////} | ||
////class L extends B { | ||
//// public identi/*classThatStartedWritingIdentifierAfterModifier*/ | ||
////} | ||
////class L extends B { | ||
//// static identi/*classThatStartedWritingIdentifierAfterStaticModifier*/ | ||
////} | ||
|
||
const allowedKeywords = [ | ||
"public", | ||
"private", | ||
"protected", | ||
"static", | ||
"abstract", | ||
"readonly", | ||
"get", | ||
"set", | ||
"constructor" | ||
]; | ||
|
||
const allowedKeywordCount = allowedKeywords.length; | ||
function verifyAllowedKeyWords() { | ||
for (const keyword of allowedKeywords) { | ||
verify.completionListContains(keyword, keyword, /*documentation*/ undefined, "keyword"); | ||
} | ||
} | ||
|
||
const nonClassElementMarkers = [ | ||
"InsideMethod" | ||
]; | ||
for (const marker of nonClassElementMarkers) { | ||
goTo.marker(marker); | ||
verify.not.completionListContains("getValue"); | ||
verify.not.completionListIsEmpty(); | ||
} | ||
|
||
// Only keywords allowed at this position since they dont extend the class | ||
const onlyClassElementKeywordLocations = [ | ||
"abstractClass", | ||
"classThatDoesNotExtendAnotherClass" | ||
]; | ||
for (const marker of onlyClassElementKeywordLocations) { | ||
goTo.marker(marker); | ||
verifyAllowedKeyWords(); | ||
verify.completionListCount(allowedKeywordCount); | ||
} | ||
|
||
// Base members and class member keywords allowed | ||
const classElementCompletionLocations = [ | ||
"classThatIsEmptyAndExtendingAnotherClass", | ||
"classThatHasAlreadyImplementedAnotherClassMethod", | ||
"classThatHasAlreadyImplementedAnotherClassMethodAfterMethod", | ||
// TODO should we give completion for these keywords | ||
//"classThatHasWrittenPublicKeyword", | ||
//"classElementContainingStatic", | ||
"classThatStartedWritingIdentifier", | ||
"propDeclarationWithoutSemicolon", | ||
"propDeclarationWithSemicolon", | ||
"propAssignmentWithSemicolon", | ||
"propAssignmentWithoutSemicolon", | ||
"methodSignatureWithoutSemicolon", | ||
"methodSignatureWithSemicolon", | ||
"methodImplementation", | ||
"accessorSignatureWithoutSemicolon", | ||
"accessorSignatureImplementation", | ||
// TODO should we give completion for these keywords | ||
//"classThatHasWrittenGetKeyword", | ||
//"classThatHasWrittenSetKeyword", | ||
//"classThatStartedWritingIdentifierOfGetAccessor", | ||
//"classThatStartedWritingIdentifierOfSetAccessor", | ||
//"classThatStartedWritingIdentifierAfterModifier", | ||
//"classThatStartedWritingIdentifierAfterStaticModifier" | ||
]; | ||
for (const marker of classElementCompletionLocations) { | ||
goTo.marker(marker); | ||
verify.completionListContains("getValue", "(method) B.getValue(): number", /*documentation*/ undefined, "method"); | ||
verifyAllowedKeyWords(); | ||
verify.completionListCount(allowedKeywordCount + 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.