@@ -41,9 +41,6 @@ namespace ts.FindAllReferences {
41
41
if ( shorthandModuleSymbol ) {
42
42
searchSymbols . push ( shorthandModuleSymbol ) ;
43
43
}
44
- function isSearchedFor ( symbol : Symbol ) : boolean {
45
- return contains ( searchSymbols , symbol ) ;
46
- }
47
44
48
45
// Compute the meaning from the location and the symbol it references
49
46
const searchMeaning = getIntersectingMeaningFromDeclarations ( getMeaningFromLocation ( node ) , declarations ) ;
@@ -80,7 +77,7 @@ namespace ts.FindAllReferences {
80
77
81
78
function getRefs ( scope : ts . Node , searchName : string ) : void {
82
79
getReferencesInNode ( scope , symbol , searchName , node , searchMeaning , findInStrings , findInComments , result ,
83
- symbolToIndex , implementations , typeChecker , cancellationToken , isSearchedFor , inheritsFromCache ) ;
80
+ symbolToIndex , implementations , typeChecker , cancellationToken , searchSymbols , inheritsFromCache ) ;
84
81
}
85
82
}
86
83
@@ -456,7 +453,7 @@ namespace ts.FindAllReferences {
456
453
implementations : boolean ,
457
454
typeChecker : TypeChecker ,
458
455
cancellationToken : CancellationToken ,
459
- isSearchedFor : ( symbol : Symbol ) => boolean ,
456
+ searchSymbols : Symbol [ ] ,
460
457
inheritsFromCache : Map < boolean > ) : void {
461
458
462
459
const sourceFile = container . getSourceFile ( ) ;
@@ -502,7 +499,7 @@ namespace ts.FindAllReferences {
502
499
if ( referenceSymbol ) {
503
500
const referenceSymbolDeclaration = referenceSymbol . valueDeclaration ;
504
501
const shorthandValueSymbol = typeChecker . getShorthandAssignmentValueSymbol ( referenceSymbolDeclaration ) ;
505
- const relatedSymbol = getRelatedSymbol ( isSearchedFor , referenceSymbol , referenceLocation ,
502
+ const relatedSymbol = getRelatedSymbol ( searchSymbols , referenceSymbol , referenceLocation ,
506
503
/*searchLocationIsConstructor*/ searchLocation . kind === SyntaxKind . ConstructorKeyword , parents , inheritsFromCache , typeChecker ) ;
507
504
508
505
if ( relatedSymbol ) {
@@ -514,7 +511,7 @@ namespace ts.FindAllReferences {
514
511
* the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the
515
512
* position of property accessing, the referenceEntry of such position will be handled in the first case.
516
513
*/
517
- else if ( ! ( referenceSymbol . flags & SymbolFlags . Transient ) && isSearchedFor ( shorthandValueSymbol ) ) {
514
+ else if ( ! ( referenceSymbol . flags & SymbolFlags . Transient ) && contains ( searchSymbols , shorthandValueSymbol ) ) {
518
515
addReferenceToRelatedSymbol ( referenceSymbolDeclaration . name , shorthandValueSymbol ) ;
519
516
}
520
517
else if ( searchLocation . kind === SyntaxKind . ConstructorKeyword ) {
@@ -1178,8 +1175,8 @@ namespace ts.FindAllReferences {
1178
1175
}
1179
1176
}
1180
1177
1181
- function getRelatedSymbol ( isSearchedFor : ( symbol : Symbol ) => boolean , referenceSymbol : Symbol , referenceLocation : Node , searchLocationIsConstructor : boolean , parents : Symbol [ ] | undefined , cache : Map < boolean > , typeChecker : TypeChecker ) : Symbol | undefined {
1182
- if ( isSearchedFor ( referenceSymbol ) ) {
1178
+ function getRelatedSymbol ( searchSymbols : Symbol [ ] , referenceSymbol : Symbol , referenceLocation : Node , searchLocationIsConstructor : boolean , parents : Symbol [ ] | undefined , cache : Map < boolean > , typeChecker : TypeChecker ) : Symbol | undefined {
1179
+ if ( contains ( searchSymbols , referenceSymbol ) ) {
1183
1180
// If we are searching for constructor uses, they must be 'new' expressions.
1184
1181
return ( ! searchLocationIsConstructor || isNewExpressionTarget ( referenceLocation ) ) ? referenceSymbol : undefined ;
1185
1182
}
@@ -1188,7 +1185,7 @@ namespace ts.FindAllReferences {
1188
1185
// symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness.
1189
1186
const aliasSymbol = getAliasSymbolForPropertyNameSymbol ( referenceSymbol , referenceLocation , typeChecker ) ;
1190
1187
if ( aliasSymbol ) {
1191
- return getRelatedSymbol ( isSearchedFor , aliasSymbol , referenceLocation , searchLocationIsConstructor , parents , cache , typeChecker ) ;
1188
+ return getRelatedSymbol ( searchSymbols , aliasSymbol , referenceLocation , searchLocationIsConstructor , parents , cache , typeChecker ) ;
1192
1189
}
1193
1190
1194
1191
// If the reference location is in an object literal, try to get the contextual type for the
@@ -1197,7 +1194,7 @@ namespace ts.FindAllReferences {
1197
1194
const containingObjectLiteralElement = getContainingObjectLiteralElement ( referenceLocation ) ;
1198
1195
if ( containingObjectLiteralElement ) {
1199
1196
const contextualSymbol = forEach ( getPropertySymbolsFromContextualType ( containingObjectLiteralElement , typeChecker ) , contextualSymbol =>
1200
- find ( typeChecker . getRootSymbols ( contextualSymbol ) , isSearchedFor ) ) ;
1197
+ find ( typeChecker . getRootSymbols ( contextualSymbol ) , symbol => contains ( searchSymbols , symbol ) ) ) ;
1201
1198
1202
1199
if ( contextualSymbol ) {
1203
1200
return contextualSymbol ;
@@ -1208,7 +1205,7 @@ namespace ts.FindAllReferences {
1208
1205
// In below eg. get 'property' from type of elems iterating type
1209
1206
// for ( { property: p2 } of elems) { }
1210
1207
const propertySymbol = getPropertySymbolOfDestructuringAssignment ( referenceLocation , typeChecker ) ;
1211
- if ( propertySymbol && isSearchedFor ( propertySymbol ) ) {
1208
+ if ( propertySymbol && contains ( searchSymbols , propertySymbol ) ) {
1212
1209
return propertySymbol ;
1213
1210
}
1214
1211
}
@@ -1217,15 +1214,15 @@ namespace ts.FindAllReferences {
1217
1214
// then include the binding element in the related symbols
1218
1215
// let { a } : { a };
1219
1216
const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName ( referenceSymbol , typeChecker ) ;
1220
- if ( bindingElementPropertySymbol && isSearchedFor ( bindingElementPropertySymbol ) ) {
1217
+ if ( bindingElementPropertySymbol && contains ( searchSymbols , bindingElementPropertySymbol ) ) {
1221
1218
return bindingElementPropertySymbol ;
1222
1219
}
1223
1220
1224
1221
// Unwrap symbols to get to the root (e.g. transient symbols as a result of widening)
1225
1222
// Or a union property, use its underlying unioned symbols
1226
1223
return forEach ( typeChecker . getRootSymbols ( referenceSymbol ) , rootSymbol => {
1227
1224
// if it is in the list, then we are done
1228
- if ( isSearchedFor ( rootSymbol ) ) {
1225
+ if ( contains ( searchSymbols , rootSymbol ) ) {
1229
1226
return rootSymbol ;
1230
1227
}
1231
1228
@@ -1242,7 +1239,7 @@ namespace ts.FindAllReferences {
1242
1239
1243
1240
const result : Symbol [ ] = [ ] ;
1244
1241
getPropertySymbolsFromBaseTypes ( rootSymbol . parent , rootSymbol . getName ( ) , result , /*previousIterationSymbolsCache*/ createMap < Symbol > ( ) , typeChecker ) ;
1245
- return find ( result , isSearchedFor ) ;
1242
+ return find ( result , symbol => contains ( searchSymbols , symbol ) ) ;
1246
1243
}
1247
1244
1248
1245
return undefined ;
0 commit comments