@@ -424,7 +424,8 @@ namespace ts.FindAllReferences.Core {
424
424
readonly text : string ;
425
425
readonly escapedText : __String ;
426
426
/** Only set if `options.implementations` is true. These are the symbols checked to get the implementations of a property access. */
427
- readonly parents : Symbol [ ] | undefined ;
427
+ readonly parents : ReadonlyArray < Symbol > | undefined ;
428
+ readonly allSearchSymbols : ReadonlyArray < Symbol > ;
428
429
429
430
/**
430
431
* Whether a symbol is in the search set.
@@ -500,14 +501,11 @@ namespace ts.FindAllReferences.Core {
500
501
// here appears to be intentional).
501
502
const {
502
503
text = stripQuotes ( unescapeLeadingUnderscores ( ( getLocalSymbolForExportDefault ( symbol ) || symbol ) . escapedName ) ) ,
503
- allSearchSymbols,
504
+ allSearchSymbols = [ symbol ] ,
504
505
} = searchOptions ;
505
506
const escapedText = escapeLeadingUnderscores ( text ) ;
506
507
const parents = this . options . implementations && getParentSymbolsOfPropertyAccess ( location , symbol , this . checker ) ;
507
- return {
508
- symbol, comingFrom, text, escapedText, parents,
509
- includes : referenceSymbol => allSearchSymbols ? contains ( allSearchSymbols , referenceSymbol ) : referenceSymbol === symbol ,
510
- } ;
508
+ return { symbol, comingFrom, text, escapedText, parents, allSearchSymbols, includes : sym => contains ( allSearchSymbols , sym ) } ;
511
509
}
512
510
513
511
private readonly symbolIdToReferences : Entry [ ] [ ] = [ ] ;
@@ -534,13 +532,17 @@ namespace ts.FindAllReferences.Core {
534
532
}
535
533
536
534
// Source file ID → symbol ID → Whether the symbol has been searched for in the source file.
537
- private readonly sourceFileToSeenSymbols : true [ ] [ ] = [ ] ;
535
+ private readonly sourceFileToSeenSymbols : Map < true > [ ] = [ ] ;
538
536
/** Returns `true` the first time we search for a symbol in a file and `false` afterwards. */
539
- markSearchedSymbol ( sourceFile : SourceFile , symbol : Symbol ) : boolean {
537
+ markSearchedSymbols ( sourceFile : SourceFile , symbols : ReadonlyArray < Symbol > ) : boolean {
540
538
const sourceId = getNodeId ( sourceFile ) ;
541
- const symbolId = getSymbolId ( symbol ) ;
542
- const seenSymbols = this . sourceFileToSeenSymbols [ sourceId ] || ( this . sourceFileToSeenSymbols [ sourceId ] = [ ] ) ;
543
- return ! seenSymbols [ symbolId ] && ( seenSymbols [ symbolId ] = true ) ;
539
+ const seenSymbols = this . sourceFileToSeenSymbols [ sourceId ] || ( this . sourceFileToSeenSymbols [ sourceId ] = createMap < true > ( ) ) ;
540
+
541
+ let anyNewSymbols = false ;
542
+ for ( const sym of symbols ) {
543
+ anyNewSymbols = addToSeen ( seenSymbols , getSymbolId ( sym ) ) || anyNewSymbols ;
544
+ }
545
+ return anyNewSymbols ;
544
546
}
545
547
}
546
548
@@ -804,7 +806,7 @@ namespace ts.FindAllReferences.Core {
804
806
* searchLocation: a node where the search value
805
807
*/
806
808
function getReferencesInContainer ( container : Node , sourceFile : SourceFile , search : Search , state : State , addReferencesHere : boolean ) : void {
807
- if ( ! state . markSearchedSymbol ( sourceFile , search . symbol ) ) {
809
+ if ( ! state . markSearchedSymbols ( sourceFile , search . allSearchSymbols ) ) {
808
810
return ;
809
811
}
810
812
0 commit comments