Merge pull request #5086 from Microsoft/abstract-semicolon-insertion

Automatic semicolon insertion for class modifiers
This commit is contained in:
Nathan Shively-Sanders
2015-10-05 10:35:42 -07:00
12 changed files with 309 additions and 35 deletions

View File

@@ -856,7 +856,7 @@ namespace ts {
let saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
// Note: it is not actually necessary to save/restore the context flags here. That's
// because the saving/restorating of these flags happens naturally through the recursive
// because the saving/restoring of these flags happens naturally through the recursive
// descent nature of our parser. However, we still store this here just so we can
// assert that that invariant holds.
let saveContextFlags = contextFlags;
@@ -1124,7 +1124,15 @@ namespace ts {
if (token === SyntaxKind.DefaultKeyword) {
return nextTokenIsClassOrFunction();
}
if (token === SyntaxKind.StaticKeyword) {
nextToken();
return canFollowModifier();
}
nextToken();
if (scanner.hasPrecedingLineBreak()) {
return false;
}
return canFollowModifier();
}
@@ -4157,8 +4165,12 @@ namespace ts {
case SyntaxKind.ModuleKeyword:
case SyntaxKind.NamespaceKeyword:
return nextTokenIsIdentifierOrStringLiteralOnSameLine();
case SyntaxKind.AbstractKeyword:
case SyntaxKind.AsyncKeyword:
case SyntaxKind.DeclareKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.PublicKeyword:
nextToken();
// ASI takes effect for this modifier.
if (scanner.hasPrecedingLineBreak()) {
@@ -4178,11 +4190,7 @@ namespace ts {
}
continue;
case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.StaticKeyword:
case SyntaxKind.AbstractKeyword:
nextToken();
continue;
default:

View File

@@ -3683,14 +3683,20 @@ namespace ts {
// Previous token may have been a keyword that was converted to an identifier.
switch (contextToken.getText()) {
case "abstract":
case "async":
case "class":
case "interface":
case "const":
case "declare":
case "enum":
case "function":
case "var":
case "static":
case "interface":
case "let":
case "const":
case "private":
case "protected":
case "public":
case "static":
case "var":
case "yield":
return true;
}