Skip to content

Commit 1e8772c

Browse files
Merge branch 'getOccurrences' into getOccurrencesLoopBreakContinue
Conflicts: src/services/services.ts
2 parents efed1f9 + 9c530fd commit 1e8772c

File tree

3 files changed

+84
-1
lines changed

3 files changed

+84
-1
lines changed

src/services/services.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2219,6 +2219,11 @@ module ts {
22192219
return getLoopBreakContinueOccurrences(<IterationStatement>node.parent);
22202220
}
22212221
break;
2222+
case SyntaxKind.ConstructorKeyword:
2223+
if (hasKind(node.parent, SyntaxKind.Constructor)) {
2224+
return getConstructorOccurrences(<ConstructorDeclaration>node.parent);
2225+
}
2226+
break;
22222227
}
22232228

22242229
return undefined;
@@ -2283,7 +2288,7 @@ module ts {
22832288
return result;
22842289
}
22852290

2286-
function getReturnOccurrences(returnStatement: ReturnStatement): ReferenceEntry[]{
2291+
function getReturnOccurrences(returnStatement: ReturnStatement): ReferenceEntry[] {
22872292
var func = <FunctionDeclaration>getContainingFunction(returnStatement);
22882293

22892294
// If we didn't find a containing function with a block body, bail out.
@@ -2435,6 +2440,20 @@ module ts {
24352440
return undefined;
24362441
}
24372442

2443+
function getConstructorOccurrences(constructorDeclaration: ConstructorDeclaration): ReferenceEntry[] {
2444+
var declarations = constructorDeclaration.symbol.getDeclarations()
2445+
2446+
var keywords: Node[] = [];
2447+
2448+
forEach(declarations, declaration => {
2449+
forEach(declaration.getChildren(), token => {
2450+
return pushKeywordIf(keywords, token, SyntaxKind.ConstructorKeyword);
2451+
});
2452+
});
2453+
2454+
return map(keywords, getReferenceEntryFromNode);
2455+
}
2456+
24382457
// returns true if 'node' is defined and has a matching 'kind'.
24392458
function hasKind(node: Node, kind: SyntaxKind) {
24402459
return node !== undefined && node.kind === kind;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////class C {
4+
//// [|const/**/ructor|]();
5+
//// [|constructor|](x: number);
6+
//// [|constructor|](y: string, x: number);
7+
//// [|constructor|](a?: any, ...r: any[]) {
8+
//// if (a === undefined && r.length === 0) {
9+
//// return;
10+
//// }
11+
////
12+
//// return;
13+
//// }
14+
////}
15+
////
16+
////class D {
17+
//// constructor(public x: number, public y: number) {
18+
//// }
19+
////}
20+
21+
test.ranges().forEach(r => {
22+
goTo.position(r.start);
23+
24+
test.ranges().forEach(range => {
25+
verify.occurrencesAtPositionContains(range, false);
26+
});
27+
});
28+
29+
goTo.marker();
30+
test.ranges().forEach(range => {
31+
verify.occurrencesAtPositionContains(range, false);
32+
});
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////class C {
4+
//// constructor();
5+
//// constructor(x: number);
6+
//// constructor(y: string, x: number);
7+
//// constructor(a?: any, ...r: any[]) {
8+
//// if (a === undefined && r.length === 0) {
9+
//// return;
10+
//// }
11+
////
12+
//// return;
13+
//// }
14+
////}
15+
////
16+
////class D {
17+
//// [|con/**/structor|](public x: number, public y: number) {
18+
//// }
19+
////}
20+
21+
test.ranges().forEach(r => {
22+
goTo.position(r.start);
23+
24+
test.ranges().forEach(range => {
25+
verify.occurrencesAtPositionContains(range, false);
26+
});
27+
});
28+
29+
goTo.marker();
30+
test.ranges().forEach(range => {
31+
verify.occurrencesAtPositionContains(range, false);
32+
});

0 commit comments

Comments
 (0)