@@ -1030,10 +1030,6 @@ namespace ts.FindAllReferences.Core {
10301030 }
10311031 }
10321032
1033- function getPropertyAccessExpressionFromRightHandSide ( node : Node ) : PropertyAccessExpression {
1034- return isRightSideOfPropertyAccess ( node ) && < PropertyAccessExpression > node . parent ;
1035- }
1036-
10371033 /**
10381034 * `classSymbol` is the class where the constructor was defined.
10391035 * Reference the constructor and all calls to `new this()`.
@@ -1130,18 +1126,6 @@ namespace ts.FindAllReferences.Core {
11301126 }
11311127 }
11321128
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-
11451129 function getContainingTypeReference ( node : Node ) : Node {
11461130 let topLevelTypeReference : Node ;
11471131
@@ -1462,7 +1446,7 @@ namespace ts.FindAllReferences.Core {
14621446 ? rootSymbol && ! ( getCheckFlags ( sym ) & CheckFlags . Synthetic ) ? rootSymbol : sym
14631447 : undefined ,
14641448 /*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 ) ) ) ) ;
14661450 }
14671451
14681452 /** Gets all symbols for one property. Does not get symbols for every property. */
@@ -1549,13 +1533,11 @@ namespace ts.FindAllReferences.Core {
15491533 * symbol may have a different parent symbol if the local type's symbol does not declare the property
15501534 * being accessed (i.e. it is declared in some parent class or interface)
15511535 */
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 ;
15601542 }
15611543}
0 commit comments