Move grammar checking: labelStatement

This commit is contained in:
Yui T 2014-12-12 16:27:43 -08:00
parent 3903a65062
commit ee1f19efca
2 changed files with 16 additions and 1 deletions

View file

@ -8131,6 +8131,21 @@ module ts {
}
function checkLabeledStatement(node: LabeledStatement) {
// ensure that label is unique
// Grammar checking
var current = node.parent;
while (current) {
if (isAnyFunction(current)) {
break;
}
if (current.kind === SyntaxKind.LabeledStatement && (<LabeledStatement>current).label.text === node.label.text) {
var sourceFile = getSourceFileOfNode(node);
grammarErrorOnNode(node.label, Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceFile.text, node.label));
break;
}
current = current.parent;
}
checkSourceElement(node.statement);
}

View file

@ -4651,7 +4651,7 @@ module ts {
case SyntaxKind.GetAccessor: return checkGetAccessor(<MethodDeclaration>node);
//case SyntaxKind.HeritageClause: return checkHeritageClause(<HeritageClause>node);
//case SyntaxKind.InterfaceDeclaration: return checkInterfaceDeclaration(<InterfaceDeclaration>node);
case SyntaxKind.LabeledStatement: return checkLabeledStatement(<LabeledStatement>node);
//case SyntaxKind.LabeledStatement: return checkLabeledStatement(<LabeledStatement>node);
case SyntaxKind.PropertyAssignment: return checkPropertyAssignment(<PropertyAssignment>node);
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature: