Merge pull request #3860 from DickvdBrink/fix-occurrences-in-classexpression

Fix occurrences in classexpressions
This commit is contained in:
Daniel Rosenwasser 2015-07-14 15:59:39 -07:00
commit c27b379b17
5 changed files with 111 additions and 3 deletions

View File

@ -4682,12 +4682,13 @@ namespace ts {
// Make sure we only highlight the keyword when it makes sense to do so.
if (isAccessibilityModifier(modifier)) {
if (!(container.kind === SyntaxKind.ClassDeclaration ||
container.kind === SyntaxKind.ClassExpression ||
(declaration.kind === SyntaxKind.Parameter && hasKind(container, SyntaxKind.Constructor)))) {
return undefined;
}
}
else if (modifier === SyntaxKind.StaticKeyword) {
if (container.kind !== SyntaxKind.ClassDeclaration) {
if (!(container.kind === SyntaxKind.ClassDeclaration || container.kind === SyntaxKind.ClassExpression)) {
return undefined;
}
}
@ -4726,12 +4727,13 @@ namespace ts {
(<ClassDeclaration>container.parent).members);
break;
case SyntaxKind.ClassDeclaration:
nodes = (<ClassDeclaration>container).members;
case SyntaxKind.ClassExpression:
nodes = (<ClassLikeDeclaration>container).members;
// If we're an accessibility modifier, we're in an instance member and should search
// the constructor's parameter list for instance members as well.
if (modifierFlag & NodeFlags.AccessibilityModifier) {
let constructor = forEach((<ClassDeclaration>container).members, member => {
let constructor = forEach((<ClassLikeDeclaration>container).members, member => {
return member.kind === SyntaxKind.Constructor && <ConstructorDeclaration>member;
});

View File

@ -0,0 +1,23 @@
/// <reference path='fourslash.ts' />
////let A = class Foo {
//// [|constructor|]();
//// [|constructor|](x: number);
//// [|constructor|](y: string);
//// [|constructor|](a?: any) {
//// }
////}
////
////let B = class D {
//// constructor(x: number) {
//// }
////}
const ranges = test.ranges();
for (let r of ranges) {
goTo.position(r.start);
for (let range of ranges) {
verify.occurrencesAtPositionContains(range, false);
}
}

View File

@ -0,0 +1,27 @@
/// <reference path='fourslash.ts' />
////let A = class Foo {
//// [|private|] foo;
//// [|private|] private;
//// constructor([|private|] y: string, public x: string) {
//// }
//// [|private|] method() { }
//// public method2() { }
//// [|private|] static static() { }
////}
////
////let B = class D {
//// constructor(private x: number) {
//// }
//// private test() {}
//// public test2() {}
////}
const ranges = test.ranges();
for (let r of ranges) {
goTo.position(r.start);
for (let range of ranges) {
verify.occurrencesAtPositionContains(range, false);
}
}

View File

@ -0,0 +1,27 @@
/// <reference path='fourslash.ts' />
////let A = class Foo {
//// [|public|] foo;
//// [|public|] public;
//// constructor([|public|] y: string, private x: string) {
//// }
//// [|public|] method() { }
//// private method2() {}
//// [|public|] static static() { }
////}
////
////let B = class D {
//// constructor(private x: number) {
//// }
//// private test() {}
//// public test2() {}
////}
const ranges = test.ranges();
for (let r of ranges) {
goTo.position(r.start);
for (let range of ranges) {
verify.occurrencesAtPositionContains(range, false);
}
}

View File

@ -0,0 +1,29 @@
/// <reference path='fourslash.ts' />
////let A = class Foo {
//// public static foo;
//// [|static|] a;
//// constructor(public y: string, private x: string) {
//// }
//// public method() { }
//// private method2() {}
//// public [|static|] static() { }
//// private [|static|] static2() { }
////}
////
////let B = class D {
//// static a;
//// constructor(private x: number) {
//// }
//// private static test() {}
//// public static test2() {}
////}
const ranges = test.ranges();
for (let r of ranges) {
goTo.position(r.start);
for (let range of ranges) {
verify.occurrencesAtPositionContains(range, false);
}
}