@@ -1030,10 +1030,6 @@ namespace ts.FindAllReferences.Core {
1030
1030
}
1031
1031
}
1032
1032
1033
- function getPropertyAccessExpressionFromRightHandSide ( node : Node ) : PropertyAccessExpression {
1034
- return isRightSideOfPropertyAccess ( node ) && < PropertyAccessExpression > node . parent ;
1035
- }
1036
-
1037
1033
/**
1038
1034
* `classSymbol` is the class where the constructor was defined.
1039
1035
* Reference the constructor and all calls to `new this()`.
@@ -1130,18 +1126,6 @@ namespace ts.FindAllReferences.Core {
1130
1126
}
1131
1127
}
1132
1128
1133
- function getSymbolsForClassAndInterfaceComponents ( type : UnionOrIntersectionType , result : Symbol [ ] = [ ] ) : Symbol [ ] {
1134
- for ( const componentType of type . types ) {
1135
- if ( componentType . symbol && componentType . symbol . getFlags ( ) & ( SymbolFlags . Class | SymbolFlags . Interface ) ) {
1136
- result . push ( componentType . symbol ) ;
1137
- }
1138
- if ( componentType . isUnionOrIntersection ( ) ) {
1139
- getSymbolsForClassAndInterfaceComponents ( componentType , result ) ;
1140
- }
1141
- }
1142
- return result ;
1143
- }
1144
-
1145
1129
function getContainingTypeReference ( node : Node ) : Node {
1146
1130
let topLevelTypeReference : Node ;
1147
1131
@@ -1462,7 +1446,7 @@ namespace ts.FindAllReferences.Core {
1462
1446
? rootSymbol && ! ( getCheckFlags ( sym ) & CheckFlags . Synthetic ) ? rootSymbol : sym
1463
1447
: undefined ,
1464
1448
/*allowBaseTypes*/ rootSymbol =>
1465
- ! ( search . parents && ! some ( search . parents , parent => explicitlyInheritsFrom ( rootSymbol . parent , parent , state . inheritsFromCache , checker ) ) ) ) ;
1449
+ ! ( search . parents && ! search . parents . some ( parent => explicitlyInheritsFrom ( rootSymbol . parent , parent , state . inheritsFromCache , checker ) ) ) ) ;
1466
1450
}
1467
1451
1468
1452
/** Gets all symbols for one property. Does not get symbols for every property. */
@@ -1549,13 +1533,11 @@ namespace ts.FindAllReferences.Core {
1549
1533
* symbol may have a different parent symbol if the local type's symbol does not declare the property
1550
1534
* being accessed (i.e. it is declared in some parent class or interface)
1551
1535
*/
1552
- function getParentSymbolsOfPropertyAccess ( location : Node , symbol : Symbol , checker : TypeChecker ) : Symbol [ ] | undefined {
1553
- const propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide ( location ) ;
1554
- const localParentType = propertyAccessExpression && checker . getTypeAtLocation ( propertyAccessExpression . expression ) ;
1555
- return localParentType && localParentType . symbol && localParentType . symbol . flags & ( SymbolFlags . Class | SymbolFlags . Interface ) && localParentType . symbol !== symbol . parent
1556
- ? [ localParentType . symbol ]
1557
- : localParentType && localParentType . isUnionOrIntersection ( )
1558
- ? getSymbolsForClassAndInterfaceComponents ( localParentType )
1559
- : undefined ;
1536
+ function getParentSymbolsOfPropertyAccess ( location : Node , symbol : Symbol , checker : TypeChecker ) : ReadonlyArray < Symbol > | undefined {
1537
+ const propertyAccessExpression = isRightSideOfPropertyAccess ( location ) ? < PropertyAccessExpression > location . parent : undefined ;
1538
+ const lhsType = propertyAccessExpression && checker . getTypeAtLocation ( propertyAccessExpression . expression ) ;
1539
+ const res = mapDefined ( lhsType && ( lhsType . isUnionOrIntersection ( ) ? lhsType . types : lhsType . symbol === symbol . parent ? undefined : [ lhsType ] ) , t =>
1540
+ t . symbol && t . symbol . flags & ( SymbolFlags . Class | SymbolFlags . Interface ) ? t . symbol : undefined ) ;
1541
+ return res . length === 0 ? undefined : res ;
1560
1542
}
1561
1543
}
0 commit comments