@@ -339,7 +339,7 @@ namespace ts.FindAllReferences.Core {
339
339
// otherwise we'll need to search globally (i.e. include each file).
340
340
const scope = getSymbolScope ( symbol ) ;
341
341
if ( scope ) {
342
- getReferencesInContainer ( scope , search , state ) ;
342
+ getReferencesInContainer ( scope , scope . getSourceFile ( ) , search , state ) ;
343
343
}
344
344
else {
345
345
// Global search
@@ -516,7 +516,7 @@ namespace ts.FindAllReferences.Core {
516
516
// For each import, find all references to that import in its source file.
517
517
for ( const [ importLocation , importSymbol ] of importSearches ) {
518
518
state . cancellationToken . throwIfCancellationRequested ( ) ;
519
- getReferencesInContainer ( importLocation . getSourceFile ( ) , state . createSearch ( importLocation , importSymbol , ImportExport . Export ) , state ) ;
519
+ getReferencesInSourceFile ( importLocation . getSourceFile ( ) , state . createSearch ( importLocation , importSymbol , ImportExport . Export ) , state ) ;
520
520
}
521
521
522
522
if ( indirectUsers . length ) {
@@ -543,14 +543,14 @@ namespace ts.FindAllReferences.Core {
543
543
// Go to the symbol we imported from and find references for it.
544
544
function searchForImportedSymbol ( symbol : Symbol , state : State ) : void {
545
545
for ( const declaration of symbol . declarations ) {
546
- getReferencesInContainer ( declaration . getSourceFile ( ) , state . createSearch ( declaration , symbol , ImportExport . Import ) , state ) ;
546
+ getReferencesInSourceFile ( declaration . getSourceFile ( ) , state . createSearch ( declaration , symbol , ImportExport . Import ) , state ) ;
547
547
}
548
548
}
549
549
550
550
/** Search for all occurences of an identifier in a source file (and filter out the ones that match). */
551
551
function searchForName ( sourceFile : SourceFile , search : Search , state : State ) : void {
552
552
if ( sourceFileHasName ( sourceFile , search . escapedText ) ) {
553
- getReferencesInContainer ( sourceFile , search , state ) ;
553
+ getReferencesInSourceFile ( sourceFile , search , state ) ;
554
554
}
555
555
}
556
556
@@ -748,13 +748,16 @@ namespace ts.FindAllReferences.Core {
748
748
}
749
749
}
750
750
751
+ function getReferencesInSourceFile ( sourceFile : ts . SourceFile , search : Search , state : State ) : void {
752
+ return getReferencesInContainer ( sourceFile , sourceFile , search , state ) ;
753
+ }
754
+
751
755
/**
752
756
* Search within node "container" for references for a search value, where the search value is defined as a
753
757
* tuple of(searchSymbol, searchText, searchLocation, and searchMeaning).
754
758
* searchLocation: a node where the search value
755
759
*/
756
- function getReferencesInContainer ( container : Node , search : Search , state : State ) : void {
757
- const sourceFile = container . getSourceFile ( ) ;
760
+ function getReferencesInContainer ( container : Node , sourceFile : ts . SourceFile , search : Search , state : State ) : void {
758
761
if ( ! state . markSearchedSymbol ( sourceFile , search . symbol ) ) {
759
762
return ;
760
763
}
0 commit comments