@@ -14,18 +14,22 @@ namespace ts.codefix {
14
14
return changes . length === 0 ? undefined : [ { description : getLocaleSpecificMessage ( Diagnostics . Implement_inherited_abstract_class ) , changes, fixId } ] ;
15
15
} ,
16
16
fixIds : [ fixId ] ,
17
- getAllCodeActions : context => codeFixAll ( context , errorCodes , ( changes , diag ) => {
18
- addMissingMembers ( getClass ( diag . file ! , diag . start ! ) , context . sourceFile , context . program . getTypeChecker ( ) , changes ) ;
19
- } ) ,
17
+ getAllCodeActions : context => {
18
+ const seenClassDeclarations = createMap < true > ( ) ;
19
+ return codeFixAll ( context , errorCodes , ( changes , diag ) => {
20
+ const classDeclaration = getClass ( diag . file ! , diag . start ! ) ;
21
+ if ( addToSeen ( seenClassDeclarations , getNodeId ( classDeclaration ) ) ) {
22
+ addMissingMembers ( classDeclaration , context . sourceFile , context . program . getTypeChecker ( ) , changes ) ;
23
+ }
24
+ } ) ;
25
+ } ,
20
26
} ) ;
21
27
22
28
function getClass ( sourceFile : SourceFile , pos : number ) : ClassLikeDeclaration {
23
- // This is the identifier in the case of a class declaration
29
+ // Token is the identifier in the case of a class declaration
24
30
// or the class keyword token in the case of a class expression.
25
31
const token = getTokenAtPosition ( sourceFile , pos , /*includeJsDocComment*/ false ) ;
26
- const classDeclaration = token . parent ;
27
- Debug . assert ( isClassLike ( classDeclaration ) ) ;
28
- return classDeclaration as ClassLikeDeclaration ;
32
+ return cast ( token . parent , isClassLike ) ;
29
33
}
30
34
31
35
function addMissingMembers ( classDeclaration : ClassLikeDeclaration , sourceFile : SourceFile , checker : TypeChecker , changeTracker : textChanges . ChangeTracker ) : void {
0 commit comments