diff --git a/src/services/services.ts b/src/services/services.ts index 067e4580991..e10f639920b 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4024,18 +4024,18 @@ module ts { let container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. - if (declaration.flags & NodeFlags.AccessibilityModifier) { + if (isAccessibilityModifier(modifier)) { if (!(container.kind === SyntaxKind.ClassDeclaration || (declaration.kind === SyntaxKind.Parameter && hasKind(container, SyntaxKind.Constructor)))) { return undefined; } } - else if (declaration.flags & NodeFlags.Static) { + else if (modifier === SyntaxKind.StaticKeyword) { if (container.kind !== SyntaxKind.ClassDeclaration) { return undefined; } } - else if (declaration.flags & (NodeFlags.Export | NodeFlags.Ambient)) { + else if (modifier === SyntaxKind.ExportKeyword || modifier === SyntaxKind.DeclareKeyword) { if (!(container.kind === SyntaxKind.ModuleBlock || container.kind === SyntaxKind.SourceFile)) { return undefined; } @@ -4076,7 +4076,7 @@ module ts { default: Debug.fail("Invalid container kind.") } - + forEach(nodes, node => { if (node.modifiers && node.flags & modifierFlag) { forEach(node.modifiers, child => pushKeywordIf(keywords, child, modifier)); @@ -5856,17 +5856,6 @@ module ts { // a string literal, and a template end consisting of '} } `'. let templateStack: SyntaxKind[] = []; - function isAccessibilityModifier(kind: SyntaxKind) { - switch (kind) { - case SyntaxKind.PublicKeyword: - case SyntaxKind.PrivateKeyword: - case SyntaxKind.ProtectedKeyword: - return true; - } - - return false; - } - /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ function canFollow(keyword1: SyntaxKind, keyword2: SyntaxKind) { if (isAccessibilityModifier(keyword1)) { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index cc9b8c94ab6..2a9af04409e 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -471,6 +471,17 @@ module ts { && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); } + export function isAccessibilityModifier(kind: SyntaxKind) { + switch (kind) { + case SyntaxKind.PublicKeyword: + case SyntaxKind.PrivateKeyword: + case SyntaxKind.ProtectedKeyword: + return true; + } + + return false; + } + export function compareDataObjects(dst: any, src: any): boolean { for (let e in dst) { if (typeof dst[e] === "object") { diff --git a/tests/cases/fourslash/getOccurrencesConst.ts b/tests/cases/fourslash/getOccurrencesConst01.ts similarity index 100% rename from tests/cases/fourslash/getOccurrencesConst.ts rename to tests/cases/fourslash/getOccurrencesConst01.ts diff --git a/tests/cases/fourslash/getOccurrencesConst02.ts b/tests/cases/fourslash/getOccurrencesConst02.ts new file mode 100644 index 00000000000..0dc96fcca6c --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesConst02.ts @@ -0,0 +1,16 @@ +/// + +////module m { +//// declare [|const|] x; +//// declare [|const|] enum E { +//// } +////} +//// +////declare [|const|] x; +////declare [|const|] enum E { +////} + +test.ranges().forEach(range => { + goTo.position(range.start); + verify.occurrencesAtPositionCount(0); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesConst03.ts b/tests/cases/fourslash/getOccurrencesConst03.ts new file mode 100644 index 00000000000..404ff655044 --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesConst03.ts @@ -0,0 +1,16 @@ +/// + +////module m { +//// export [|const|] x; +//// export [|const|] enum E { +//// } +////} +//// +////export [|const|] x; +////export [|const|] enum E { +////} + +test.ranges().forEach(range => { + goTo.position(range.start); + verify.occurrencesAtPositionCount(0); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesConst04.ts b/tests/cases/fourslash/getOccurrencesConst04.ts new file mode 100644 index 00000000000..c7f293450d3 --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesConst04.ts @@ -0,0 +1,12 @@ +/// + +////export const class C { +//// private static c/*1*/onst foo; +//// constructor(public con/*2*/st foo) { +//// } +////} + +goTo.marker("1"); +verify.occurrencesAtPositionCount(1); +goTo.marker("2"); +verify.occurrencesAtPositionCount(0); \ No newline at end of file