COMPLETE migrating grammar checking; No more errors

This commit is contained in:
Yui T
2014-12-16 19:30:08 -08:00
parent fdfd8d4863
commit d7f607234a
21 changed files with 216 additions and 111 deletions
+14 -21
View File
@@ -7021,14 +7021,7 @@ module ts {
function checkNumericLiteral(node: LiteralExpression): Type {
// Grammar checking
if (node.flags & NodeFlags.OctalLiteral) {
if (node.parserContextFlags & ParserContextFlags.StrictMode) {
grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode);
}
else if (compilerOptions.target >= ScriptTarget.ES5) {
grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher);
}
}
checkGrammarNumbericLiteral(node);
return numberType;
}
@@ -10362,8 +10355,7 @@ module ts {
// Grammar checking for computedPropertName and shorthandPropertyAssignment
checkGrammarForInvalidQuestionMark(prop,(<PropertyAssignment>prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional);
if (name.kind === SyntaxKind.NumericLiteral) {
}
else if (name.kind === SyntaxKind.StringLiteral) {
checkGrammarNumbericLiteral(<Identifier>name);
}
currentKind = Property;
}
@@ -10455,7 +10447,6 @@ module ts {
function checkGrammarMethod(node: MethodDeclaration) {
if (checkGrammarFunctionLikeDeclaration(node) ||
checkGrammarForBodyInAmbientContext(node.body, /*isConstructor:*/ false) ||
checkGrammarForGenerator(node)) {
return true;
}
@@ -10734,16 +10725,6 @@ module ts {
}
}
function checkGrammarForBodyInAmbientContext(body: Block | Expression, isConstructor: boolean): boolean {
if (isInAmbientContext(body) && body && body.kind === SyntaxKind.Block) {
var diagnostic = isConstructor
? Diagnostics.A_constructor_implementation_cannot_be_declared_in_an_ambient_context
: Diagnostics.A_function_implementation_cannot_be_declared_in_an_ambient_context;
return getNodeLinks(body).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(body, diagnostic);
}
}
function checkGrammarProperty(node: PropertyDeclaration) {
if (node.parent.kind === SyntaxKind.ClassDeclaration) {
if (checkGrammarForInvalidQuestionMark(node, node.questionToken, Diagnostics.A_class_member_cannot_be_declared_optional) ||
@@ -10839,6 +10820,18 @@ module ts {
}
}
function checkGrammarNumbericLiteral(node: Identifier): boolean {
// Grammar checking
if (node.flags & NodeFlags.OctalLiteral) {
if (node.parserContextFlags & ParserContextFlags.StrictMode) {
return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode);
}
else if (compilerOptions.target >= ScriptTarget.ES5) {
return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher);
}
}
}
function grammarErrorAfterFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
var sourceFile = getSourceFileOfNode(node);
if (!hasParseDiagnostics(sourceFile)) {
@@ -50,7 +50,7 @@ module ts {
An_export_assignment_cannot_be_used_in_an_internal_module: { code: 1063, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in an internal module.", isEarly: true },
Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers.", isEarly: true },
Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." },
A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." },
A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration.", isEarly: true },
Invalid_reference_directive_syntax: { code: 1084, category: DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." },
Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher.", isEarly: true },
An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context.", isEarly: true },
+2 -1
View File
@@ -228,7 +228,8 @@
},
"A 'declare' modifier cannot be used with an import declaration.": {
"category": "Error",
"code": 1079
"code": 1079,
"isEarly": true
},
"Invalid 'reference' directive syntax.": {
"category": "Error",