Skip to content

Commit 457b67f

Browse files
committed
PR Feedback
1 parent 111e509 commit 457b67f

3 files changed

Lines changed: 20 additions & 9 deletions

File tree

src/compiler/utilities.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,11 +1669,6 @@ namespace ts {
16691669
return false;
16701670
}
16711671

1672-
export function isFunctionDeclarationIdentifierName(node: Identifier): boolean {
1673-
return node.parent.kind === SyntaxKind.FunctionDeclaration &&
1674-
(<FunctionDeclaration>node.parent).name === node;
1675-
}
1676-
16771672
// An alias symbol is created by one of the following declarations:
16781673
// import <symbol> = ...
16791674
// import <symbol> from ...

src/server/session.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,9 @@ namespace ts.server {
366366
}
367367

368368
const compilerService = project.compilerService;
369-
const position = compilerService.host.lineOffsetToPosition(file, line, offset);
369+
const implementations = compilerService.languageService.getImplementationAtPosition(file,
370+
compilerService.host.lineOffsetToPosition(file, line, offset));
370371

371-
const implementations = compilerService.languageService.getImplementationAtPosition(file, position);
372372
if (!implementations) {
373373
return undefined;
374374
}

src/services/services.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5302,13 +5302,19 @@ namespace ts {
53025302
const node = getTouchingPropertyName(getValidSourceFile(fileName), position);
53035303
const typeChecker = program.getTypeChecker();
53045304

5305+
// If invoked directly on a shorthand property assignment, then return
5306+
// the declaration of the symbol being assigned (not the symbol being assigned to).
53055307
if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) {
53065308
const entry = getReferenceEntryForShorthandPropertyAssignment(node, typeChecker);
53075309
entries.push({
53085310
textSpan: entry.textSpan,
53095311
fileName: entry.fileName
53105312
});
53115313
}
5314+
5315+
// For most symbols, the definition is the same as the implementation so we can just
5316+
// call "Go to Definition". This case should handle anything that is not a type
5317+
// reference to or member of an interface, class, or union/intersection type.
53125318
else if (definitionIsImplementation(node, typeChecker)) {
53135319
const definitions = getDefinitionAtPosition(fileName, position);
53145320
forEach(definitions, (definition: DefinitionInfo) => {
@@ -5318,8 +5324,12 @@ namespace ts {
53185324
});
53195325
});
53205326
}
5327+
5328+
// Interfaces, classes, and unions/intersection types separate the implementation and
5329+
// definition so "Go to Definition" is not sufficient. This case handles invocations
5330+
// on type references and members of those types.
53215331
else {
5322-
// Do a search for all references and filter them down to implementations only
5332+
// Perform "Find all References" and filter them down to implementations only
53235333
const result = getReferencedSymbolsForNode(node, program.getSourceFiles(), /*findInStrings*/false, /*findInComments*/false, /*implementations*/true);
53245334

53255335
forEach(result, referencedSymbol => {
@@ -5362,7 +5372,8 @@ namespace ts {
53625372
return false;
53635373
}
53645374

5365-
// Also check the right hand side to see if this is a type being accessed on a namespace/module
5375+
// Also check the right hand side to see if this is a type being accessed on a namespace/module.
5376+
// For example, SomeModule.SomeType
53665377
const rightHandType = typeChecker.getTypeAtLocation(node);
53675378
return rightHandType && !(rightHandType.getFlags() & (TypeFlags.Class | TypeFlags.Interface | TypeFlags.UnionOrIntersection));
53685379
}
@@ -5424,6 +5435,11 @@ namespace ts {
54245435
return isIdentifierOfClass(node) || isIdentifierOfEnumDeclaration(node);
54255436
}
54265437

5438+
function isFunctionDeclarationIdentifierName(node: Identifier): boolean {
5439+
return node.parent.kind === SyntaxKind.FunctionDeclaration &&
5440+
(<FunctionDeclaration>node.parent).name === node;
5441+
}
5442+
54275443
function isIdentifierOfClass(node: Identifier) {
54285444
return (node.parent.kind === SyntaxKind.ClassDeclaration || node.parent.kind === SyntaxKind.ClassExpression) &&
54295445
(<ClassLikeDeclaration>node.parent).name === node;

0 commit comments

Comments
 (0)