Skip to content

Commit 84e385d

Browse files
Made a getThisContainer function.
1 parent a6a6d77 commit 84e385d

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/compiler/parser.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,14 @@ module ts {
430430
}
431431
}
432432

433+
export function getThisContainer(node: Node): Node {
434+
do {
435+
node = getThisContainerOrArrowFunction(node);
436+
} while (node.kind === SyntaxKind.ArrowFunction);
437+
438+
return node;
439+
}
440+
433441
export function hasRestParameters(s: SignatureDeclaration): boolean {
434442
return s.parameters.length > 0 && (s.parameters[s.parameters.length - 1].flags & NodeFlags.Rest) !== 0;
435443
}

src/services/services.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2629,10 +2629,7 @@ module ts {
26292629

26302630
function getReferencesForThisKeyword(thisKeyword: Node, sourceFiles: SourceFile[]) {
26312631
// Get the owner" of the 'this' keyword.
2632-
var thisContainer = thisKeyword;
2633-
do {
2634-
thisContainer = getThisContainerOrArrowFunction(thisContainer);
2635-
} while (thisContainer.kind === SyntaxKind.ArrowFunction);
2632+
var thisContainer = getThisContainer(thisKeyword);
26362633

26372634
var searchSpaceNode: Node;
26382635

@@ -2683,10 +2680,7 @@ module ts {
26832680
}
26842681

26852682
// Get the owner" of the 'this' keyword.
2686-
var container = node;
2687-
do {
2688-
container = getThisContainerOrArrowFunction(container);
2689-
} while (container.kind === SyntaxKind.ArrowFunction);
2683+
var container = getThisContainer(node);
26902684

26912685
switch (container.kind) {
26922686
case SyntaxKind.Property:

0 commit comments

Comments
 (0)