Fixed issue with the kinds we check.

This commit is contained in:
Daniel Rosenwasser 2015-01-20 12:42:03 -08:00
parent ea30c68128
commit 3429fab6fb

View file

@ -1143,8 +1143,8 @@ module ts {
InMultiLineCommentTrivia, InMultiLineCommentTrivia,
InSingleQuoteStringLiteral, InSingleQuoteStringLiteral,
InDoubleQuoteStringLiteral, InDoubleQuoteStringLiteral,
InTemplateHeadLiteral, // this could also be a NoSubstitutionTemplateLiteral InTemplateHeadOrNoSubstitutionTemplate,
InTemplateMiddleLiteral, //this could also be a TemplateTail InTemplateMiddleOrTail,
InTemplateSubstitutionPosition, InTemplateSubstitutionPosition,
} }
@ -5678,20 +5678,22 @@ module ts {
text = "/*\n" + text; text = "/*\n" + text;
offset = 3; offset = 3;
break; break;
case EndOfLineState.InTemplateHeadLiteral: case EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate:
if (syntacticClassifierAbsent) { if (syntacticClassifierAbsent) {
text = "`\n" + text; text = "`\n" + text;
offset = 2; offset = 2;
} }
break; break;
case EndOfLineState.InTemplateMiddleLiteral: case EndOfLineState.InTemplateMiddleOrTail:
if (syntacticClassifierAbsent) { if (syntacticClassifierAbsent) {
text = "${\n" + text; text = "}\n" + text;
offset = 3; offset = 2;
} }
// fallthrough // fallthrough
case EndOfLineState.InTemplateSubstitutionPosition: case EndOfLineState.InTemplateSubstitutionPosition:
templateStack = [SyntaxKind.TemplateHead]; if (syntacticClassifierAbsent) {
templateStack = [SyntaxKind.TemplateHead];
}
break; break;
} }
@ -5847,11 +5849,14 @@ module ts {
} }
else if (isTemplateLiteralKind(token) && syntacticClassifierAbsent) { else if (isTemplateLiteralKind(token) && syntacticClassifierAbsent) {
if (scanner.isUnterminated()) { if (scanner.isUnterminated()) {
if (token === SyntaxKind.TemplateMiddle) { if (token === SyntaxKind.TemplateTail) {
result.finalLexState = EndOfLineState.InTemplateMiddleLiteral; result.finalLexState = EndOfLineState.InTemplateMiddleOrTail;
}
else if (token === SyntaxKind.NoSubstitutionTemplateLiteral) {
result.finalLexState = EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate;
} }
else { else {
result.finalLexState = EndOfLineState.InTemplateHeadLiteral; Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token);
} }
} }
} }