@@ -1362,51 +1362,16 @@ namespace ts {
1362
1362
/**
1363
1363
* Finds members of the resolved type that are missing in the class pointed to by class decl
1364
1364
* and generates source code for the missing members.
1365
- * @param possiblyMissingSymbols The collection of symbols to filter.
1365
+ * @param possiblyMissingSymbols The collection of symbols to filter and then get insertions for .
1366
1366
*/
1367
- export function getMissingMembersInsertion ( classDeclaration : ClassLikeDeclaration , possiblyMissingSymbols : Map < Symbol > , checker : TypeChecker , newlineChar : string ) : string {
1368
- const missingMembers = filterMissingMembers ( possiblyMissingSymbols , classDeclaration . symbol . members ) ;
1369
- return getInsertionsForMembers ( missingMembers , classDeclaration , checker , newlineChar ) ;
1370
- }
1371
-
1372
- /**
1373
- * Finds the symbols in source but not target, generating a new map with the differences.
1374
- */
1375
- function filterMissingMembers ( sourceSymbols : Map < Symbol > , targetSymbols : Map < Symbol > ) : Map < Symbol > {
1376
- const result : Map < Symbol > = createMap < Symbol > ( ) ;
1377
- for ( const sourceName in sourceSymbols ) {
1378
- if ( ! ( sourceName in targetSymbols ) ) {
1379
- result [ sourceName ] = sourceSymbols [ sourceName ] ;
1380
- }
1381
- }
1382
- return result ;
1383
- }
1384
-
1385
- function filterSymbolMapByDeclaration ( symbolMap : Map < Symbol > , pred : ( decl : Declaration ) => boolean ) : Map < Symbol > {
1386
- const result = createMap < Symbol > ( ) ;
1387
- for ( const key in symbolMap ) {
1388
- const declaration = symbolMap [ key ] . getDeclarations ( ) ;
1389
- Debug . assert ( ! ! ( declaration && declaration . length ) ) ;
1390
- if ( pred ( declaration [ 0 ] ) ) {
1391
- result [ key ] = symbolMap [ key ] ;
1392
- }
1393
- }
1394
- return result ;
1395
- }
1396
-
1397
- export function filterAbstractAndNonPrivate ( symbolMap : Map < Symbol > ) {
1398
- return filterSymbolMapByDeclaration ( symbolMap , decl => ! ( getModifierFlags ( decl ) & ModifierFlags . Private ) && ! ! ( getModifierFlags ( decl ) & ModifierFlags . Abstract ) ) ;
1399
- }
1400
-
1401
- export function filterNonPrivate ( symbolMap : Map < Symbol > ) {
1402
- return filterSymbolMapByDeclaration ( symbolMap , decl => ! ( getModifierFlags ( decl ) & ModifierFlags . Private ) ) ;
1403
- }
1367
+ export function getMissingMembersInsertion ( classDeclaration : ClassLikeDeclaration , possiblyMissingSymbols : Symbol [ ] , checker : TypeChecker , newlineChar : string ) : string {
1368
+ const classMembers = classDeclaration . symbol . members ;
1369
+ const missingMembers = possiblyMissingSymbols . filter ( symbol => ! ( symbol . getName ( ) in classMembers ) ) ;
1404
1370
1405
- function getInsertionsForMembers ( symbolMap : MapLike < Symbol > , enclosingDeclaration : ClassLikeDeclaration , checker : TypeChecker , newlineChar : string ) : string {
1406
1371
let insertion = "" ;
1407
1372
1408
- for ( const symbolName in symbolMap ) {
1409
- insertion = insertion . concat ( getInsertionForMemberSymbol ( symbolMap [ symbolName ] , enclosingDeclaration , checker , newlineChar ) ) ;
1373
+ for ( const symbol of missingMembers ) {
1374
+ insertion = insertion . concat ( getInsertionForMemberSymbol ( symbol , classDeclaration , checker , newlineChar ) ) ;
1410
1375
}
1411
1376
return insertion ;
1412
1377
}
0 commit comments