Merge branch 'getOccurrences' into getOccurrencesLoopBreakContinue

Conflicts:
	src/services/services.ts
This commit is contained in:
Daniel Rosenwasser 2014-09-10 19:19:53 -07:00
commit 1e8772c7a5
3 changed files with 84 additions and 1 deletions

View file

@ -2219,6 +2219,11 @@ module ts {
return getLoopBreakContinueOccurrences(<IterationStatement>node.parent);
}
break;
case SyntaxKind.ConstructorKeyword:
if (hasKind(node.parent, SyntaxKind.Constructor)) {
return getConstructorOccurrences(<ConstructorDeclaration>node.parent);
}
break;
}
return undefined;
@ -2283,7 +2288,7 @@ module ts {
return result;
}
function getReturnOccurrences(returnStatement: ReturnStatement): ReferenceEntry[]{
function getReturnOccurrences(returnStatement: ReturnStatement): ReferenceEntry[] {
var func = <FunctionDeclaration>getContainingFunction(returnStatement);
// If we didn't find a containing function with a block body, bail out.
@ -2435,6 +2440,20 @@ module ts {
return undefined;
}
function getConstructorOccurrences(constructorDeclaration: ConstructorDeclaration): ReferenceEntry[] {
var declarations = constructorDeclaration.symbol.getDeclarations()
var keywords: Node[] = [];
forEach(declarations, declaration => {
forEach(declaration.getChildren(), token => {
return pushKeywordIf(keywords, token, SyntaxKind.ConstructorKeyword);
});
});
return map(keywords, getReferenceEntryFromNode);
}
// returns true if 'node' is defined and has a matching 'kind'.
function hasKind(node: Node, kind: SyntaxKind) {
return node !== undefined && node.kind === kind;

View file

@ -0,0 +1,32 @@
/// <reference path='fourslash.ts' />
////class C {
//// [|const/**/ructor|]();
//// [|constructor|](x: number);
//// [|constructor|](y: string, x: number);
//// [|constructor|](a?: any, ...r: any[]) {
//// if (a === undefined && r.length === 0) {
//// return;
//// }
////
//// return;
//// }
////}
////
////class D {
//// constructor(public x: number, public y: number) {
//// }
////}
test.ranges().forEach(r => {
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker();
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});

View file

@ -0,0 +1,32 @@
/// <reference path='fourslash.ts' />
////class C {
//// constructor();
//// constructor(x: number);
//// constructor(y: string, x: number);
//// constructor(a?: any, ...r: any[]) {
//// if (a === undefined && r.length === 0) {
//// return;
//// }
////
//// return;
//// }
////}
////
////class D {
//// [|con/**/structor|](public x: number, public y: number) {
//// }
////}
test.ranges().forEach(r => {
goTo.position(r.start);
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
});
goTo.marker();
test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});