Skip to content

Commit efc7e9d

Browse files
author
Andy Hanson
committed
Climb past multiple property accesses if necessary
1 parent 5977473 commit efc7e9d

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/services/services.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2792,6 +2792,10 @@ namespace ts {
27922792
return isRightSideOfPropertyAccess(node) ? node.parent : node;
27932793
}
27942794

2795+
function climbPastManyPropertyAccesses(node: Node): Node {
2796+
return isRightSideOfPropertyAccess(node) ? climbPastManyPropertyAccesses(node.parent) : node;
2797+
}
2798+
27952799
function isCallExpressionTarget(node: Node): boolean {
27962800
node = climbPastPropertyAccess(node);
27972801
return node && node.parent && node.parent.kind === SyntaxKind.CallExpression && (<CallExpression>node.parent).expression === node;
@@ -2804,7 +2808,7 @@ namespace ts {
28042808

28052809
/** Returns a CallLikeExpression where `node` is the target being invoked. */
28062810
function getAncestorCallLikeExpression(node: Node): CallLikeExpression | undefined {
2807-
const target = climbPastPropertyAccess(node);
2811+
const target = climbPastManyPropertyAccesses(node);
28082812
const callLike = target.parent;
28092813
return isCallLikeExpression(callLike) && getInvokedExpression(callLike) === target && callLike;
28102814
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// Test that we can climb past more than one property access to reach a call expression.
4+
5+
////namespace A {
6+
//// export namespace B {
7+
//// export function f(value: number): void;
8+
//// /*1*/export function f(value: string): void;
9+
//// export function f(value: number | string) {}
10+
//// }
11+
////}
12+
////A.B./*2*/f("");
13+
14+
goTo.marker("2");
15+
goTo.definition();
16+
verify.caretAtMarker("1");

0 commit comments

Comments
 (0)