Fixed the contextual check for modifiers to check the original modifier instead of the flags of the node.

This commit is contained in:
Daniel Rosenwasser 2015-03-18 14:07:42 -07:00
parent 9a507fa5bf
commit 5cbf667d78
2 changed files with 15 additions and 15 deletions

View File

@ -4011,18 +4011,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;
}
@ -4063,7 +4063,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));
@ -5843,17 +5843,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)) {

View File

@ -320,6 +320,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") {