Skip to content

Commit 7739a88

Browse files
author
Andy Hanson
committed
getReferencesInContainer: Take sourceFile as parameter
1 parent 5bcb8fa commit 7739a88

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/services/findAllReferences.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ namespace ts.FindAllReferences.Core {
339339
// otherwise we'll need to search globally (i.e. include each file).
340340
const scope = getSymbolScope(symbol);
341341
if (scope) {
342-
getReferencesInContainer(scope, search, state);
342+
getReferencesInContainer(scope, scope.getSourceFile(), search, state);
343343
}
344344
else {
345345
// Global search
@@ -516,7 +516,7 @@ namespace ts.FindAllReferences.Core {
516516
// For each import, find all references to that import in its source file.
517517
for (const [importLocation, importSymbol] of importSearches) {
518518
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);
520520
}
521521

522522
if (indirectUsers.length) {
@@ -543,14 +543,14 @@ namespace ts.FindAllReferences.Core {
543543
// Go to the symbol we imported from and find references for it.
544544
function searchForImportedSymbol(symbol: Symbol, state: State): void {
545545
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);
547547
}
548548
}
549549

550550
/** Search for all occurences of an identifier in a source file (and filter out the ones that match). */
551551
function searchForName(sourceFile: SourceFile, search: Search, state: State): void {
552552
if (sourceFileHasName(sourceFile, search.escapedText)) {
553-
getReferencesInContainer(sourceFile, search, state);
553+
getReferencesInSourceFile(sourceFile, search, state);
554554
}
555555
}
556556

@@ -748,13 +748,16 @@ namespace ts.FindAllReferences.Core {
748748
}
749749
}
750750

751+
function getReferencesInSourceFile(sourceFile: ts.SourceFile, search: Search, state: State): void {
752+
return getReferencesInContainer(sourceFile, sourceFile, search, state);
753+
}
754+
751755
/**
752756
* Search within node "container" for references for a search value, where the search value is defined as a
753757
* tuple of(searchSymbol, searchText, searchLocation, and searchMeaning).
754758
* searchLocation: a node where the search value
755759
*/
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 {
758761
if (!state.markSearchedSymbol(sourceFile, search.symbol)) {
759762
return;
760763
}

0 commit comments

Comments
 (0)