Skip to content

Commit a8ad40f

Browse files
committed
Add async to the list of class element completion keyword and refactoring according to feedback
1 parent fcb0f46 commit a8ad40f

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/harness/fourslash.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3426,7 +3426,8 @@ namespace FourSlashInterface {
34263426
"readonly",
34273427
"get",
34283428
"set",
3429-
"constructor"
3429+
"constructor",
3430+
"async"
34303431
];
34313432

34323433
constructor(protected state: FourSlash.TestState, private negative = false) {

src/services/completions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,8 @@ namespace ts.Completions {
618618

619619
if (classLikeContainer = tryGetClassLikeCompletionContainer(contextToken)) {
620620
// cursor inside class declaration
621-
return tryGetClassLikeCompletionSymbols(classLikeContainer);
621+
getGetClassLikeCompletionSymbols(classLikeContainer);
622+
return true;
622623
}
623624

624625
if (jsxContainer = tryGetContainingJsxElement(contextToken)) {
@@ -929,7 +930,7 @@ namespace ts.Completions {
929930
*
930931
* @returns true if 'symbols' was successfully populated; false otherwise.
931932
*/
932-
function tryGetClassLikeCompletionSymbols(classLikeDeclaration: ClassLikeDeclaration): boolean {
933+
function getGetClassLikeCompletionSymbols(classLikeDeclaration: ClassLikeDeclaration) {
933934
// We're looking up possible property names from parent type.
934935
isMemberCompletion = true;
935936
// Declaring new property/method/accessor
@@ -965,8 +966,6 @@ namespace ts.Completions {
965966
baseProperty => baseProperty.getDeclarations() && !(getDeclarationModifierFlagsFromSymbol(baseProperty) & ModifierFlags.Private));
966967
}
967968
}
968-
969-
return true;
970969
}
971970

972971
/**
@@ -1431,6 +1430,7 @@ namespace ts.Completions {
14311430
case SyntaxKind.ReadonlyKeyword:
14321431
case SyntaxKind.GetKeyword:
14331432
case SyntaxKind.SetKeyword:
1433+
case SyntaxKind.AsyncKeyword:
14341434
return true;
14351435
}
14361436
}

tests/cases/fourslash/completionEntryForClassMembers.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@
8484
////class M extends B {
8585
//// private static identi/*classThatStartedWritingIdentifierAfterPrivateStaticModifier*/
8686
////}
87+
////class N extends B {
88+
//// async /*classThatHasWrittenAsyncKeyword*/
89+
////}
8790

8891
const allowedKeywordCount = verify.allowedClassElementKeywords.length;
8992
type CompletionInfo = [string, string];
@@ -171,6 +174,7 @@ const classInstanceElementLocations = [
171174
"classThatStartedWritingIdentifierOfGetAccessor",
172175
"classThatStartedWritingIdentifierOfSetAccessor",
173176
"classThatStartedWritingIdentifierAfterModifier",
177+
"classThatHasWrittenAsyncKeyword"
174178
];
175179
verifyClassElementLocations(instanceMemberInfo, classInstanceElementLocations);
176180

0 commit comments

Comments
 (0)