|
1 | 1 | /* @internal */
|
2 | 2 | namespace ts.GoToImplementation {
|
3 |
| - export function getImplementationAtPosition(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], node: Node): ImplementationLocation[] { |
4 |
| - // If invoked directly on a shorthand property assignment, then return |
5 |
| - // the declaration of the symbol being assigned (not the symbol being assigned to). |
6 |
| - if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { |
7 |
| - const result: ReferenceEntry[] = []; |
8 |
| - FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); |
9 |
| - return result.length > 0 ? result : undefined; |
10 |
| - } |
11 |
| - else if (node.kind === SyntaxKind.SuperKeyword || isSuperProperty(node.parent)) { |
12 |
| - // References to and accesses on the super keyword only have one possible implementation, so no |
13 |
| - // need to "Find all References" |
14 |
| - const symbol = typeChecker.getSymbolAtLocation(node); |
15 |
| - return symbol.valueDeclaration && [FindAllReferences.getReferenceEntryFromNode(symbol.valueDeclaration)]; |
16 |
| - } |
17 |
| - else { |
18 |
| - // Perform "Find all References" and retrieve only those that are implementations |
19 |
| - const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, |
20 |
| - node, sourceFiles, /*findInStrings*/false, /*findInComments*/false, /*implementations*/true); |
21 |
| - const result = flatMap(referencedSymbols, symbol => |
22 |
| - map(symbol.references, ({ textSpan, fileName }) => ({ textSpan, fileName }))); |
| 3 | + export function getImplementationAtPosition(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], node: Node): ImplementationLocation[] { |
| 4 | + // If invoked directly on a shorthand property assignment, then return |
| 5 | + // the declaration of the symbol being assigned (not the symbol being assigned to). |
| 6 | + if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { |
| 7 | + const result: ReferenceEntry[] = []; |
| 8 | + FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); |
| 9 | + return result.length > 0 ? result : undefined; |
| 10 | + } |
| 11 | + else if (node.kind === SyntaxKind.SuperKeyword || isSuperProperty(node.parent)) { |
| 12 | + // References to and accesses on the super keyword only have one possible implementation, so no |
| 13 | + // need to "Find all References" |
| 14 | + const symbol = typeChecker.getSymbolAtLocation(node); |
| 15 | + return symbol.valueDeclaration && [FindAllReferences.getReferenceEntryFromNode(symbol.valueDeclaration)]; |
| 16 | + } |
| 17 | + else { |
| 18 | + // Perform "Find all References" and retrieve only those that are implementations |
| 19 | + const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, |
| 20 | + node, sourceFiles, /*findInStrings*/false, /*findInComments*/false, /*implementations*/true); |
| 21 | + const result = flatMap(referencedSymbols, symbol => |
| 22 | + map(symbol.references, ({ textSpan, fileName }) => ({ textSpan, fileName }))); |
23 | 23 |
|
24 |
| - return result && result.length > 0 ? result : undefined; |
25 |
| - } |
| 24 | + return result && result.length > 0 ? result : undefined; |
26 | 25 | }
|
| 26 | + } |
27 | 27 | }
|
0 commit comments