Skip to content

Commit 9925137

Browse files
committed
Fix findAllReferences for 'this' parameter declarations
1 parent aea2a12 commit 9925137

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/services/findAllReferences.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,10 @@ namespace ts.FindAllReferences.Core {
14281428
return [{ definition: { type: DefinitionKind.Symbol, symbol: searchSpaceNode.symbol }, references }];
14291429
}
14301430

1431+
function isParameterName(node: Node) {
1432+
return node.kind === SyntaxKind.Identifier && node.parent.kind === SyntaxKind.Parameter && (<ParameterDeclaration>node.parent).name === node;
1433+
}
1434+
14311435
function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: ReadonlyArray<SourceFile>, cancellationToken: CancellationToken): SymbolAndEntries[] | undefined {
14321436
let searchSpaceNode = getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false);
14331437

@@ -1450,7 +1454,7 @@ namespace ts.FindAllReferences.Core {
14501454
searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class
14511455
break;
14521456
case SyntaxKind.SourceFile:
1453-
if (isExternalModule(<SourceFile>searchSpaceNode)) {
1457+
if (isExternalModule(<SourceFile>searchSpaceNode) || isParameterName(thisOrSuperKeyword)) {
14541458
return undefined;
14551459
}
14561460
// falls through
@@ -1483,7 +1487,7 @@ namespace ts.FindAllReferences.Core {
14831487
// and has the appropriate static modifier from the original container.
14841488
return container.parent && searchSpaceNode.symbol === container.parent.symbol && (getModifierFlags(container) & ModifierFlags.Static) === staticFlag;
14851489
case SyntaxKind.SourceFile:
1486-
return container.kind === SyntaxKind.SourceFile && !isExternalModule(<SourceFile>container);
1490+
return container.kind === SyntaxKind.SourceFile && !isExternalModule(<SourceFile>container) && !isParameterName(node);
14871491
}
14881492
});
14891493
}).map(n => nodeEntry(n));

0 commit comments

Comments
 (0)