mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-24 11:43:18 -05:00
Address code review
This commit is contained in:
@@ -11925,7 +11925,8 @@ module ts {
|
||||
// GRAMMAR CHECKING
|
||||
function isReservedwordInStrictMode(node: Identifier): boolean {
|
||||
// Check that originalKeywordKind is less than LastFurtureReservedWord to see if an Identifier is a strict-mode reserved word
|
||||
return (node.parserContextFlags & ParserContextFlags.StrictMode) && node.originalKeywordKind <= SyntaxKind.LastFutureReservedWord;
|
||||
return (node.parserContextFlags & ParserContextFlags.StrictMode) &&
|
||||
(node.originalKeywordKind >= SyntaxKind.FirstFutureReservedWord && node.originalKeywordKind <= SyntaxKind.LastFutureReservedWord);
|
||||
}
|
||||
|
||||
function reportStrictModeGrammarErrorInClassDeclaration(identifier: Identifier, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
|
||||
@@ -12015,16 +12016,8 @@ module ts {
|
||||
// Walk from right to left and report a possible error at each Identifier in QualifiedName
|
||||
// Example:
|
||||
// x1: public.private.package // error at public and private
|
||||
let qualifiedName = typeName;
|
||||
while (qualifiedName && qualifiedName.kind === SyntaxKind.QualifiedName) {
|
||||
checkGrammarTypeNameInStrictMode((<QualifiedName>qualifiedName).right);
|
||||
qualifiedName = (<QualifiedName>qualifiedName).left;
|
||||
}
|
||||
|
||||
// Report an error at the last Identifier in QualifiedName
|
||||
// Example:
|
||||
// x1: public.private.package // error at package
|
||||
checkGrammarTypeNameInStrictMode(<Identifier>qualifiedName);
|
||||
checkGrammarTypeNameInStrictMode((<QualifiedName>typeName).right);
|
||||
checkGrammarTypeReferenceInStrictMode((<QualifiedName>typeName).left);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12034,27 +12027,18 @@ module ts {
|
||||
// public // error at public
|
||||
// public.private.package // error at public
|
||||
// B.private.B // no error
|
||||
function checkGrammarHeritageClauseElementInStrictMode(expression: Expression) {
|
||||
function checkGrammarHeritageClauseElementInStrictMode(expression: PropertyAccessExpression) {
|
||||
// Example:
|
||||
// class C extends public // error at public
|
||||
if (expression && expression.kind === SyntaxKind.Identifier) {
|
||||
return checkGrammarIdentifierInStrictMode(expression);
|
||||
}
|
||||
else if (expression && expression.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
let propertyAccessExp = <PropertyAccessExpression>expression;
|
||||
|
||||
// Walk from left to right in PropertyAccessExpression until we are at the left most expression
|
||||
// in PropertyAccessExpression. According to grammar production of MemberExpression,
|
||||
// the left component expression is a PrimaryExpression (i.e. Identifier) while the other
|
||||
// component after dots can be IdentifierName.
|
||||
while (propertyAccessExp && propertyAccessExp.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
propertyAccessExp = <PropertyAccessExpression>propertyAccessExp.expression;
|
||||
}
|
||||
|
||||
// Report strict mode at the property of memberExpression
|
||||
// Example:
|
||||
// public.private.package // error at public as it is parsed as an Identifier in the PropertyAccessExpression
|
||||
checkGrammarIdentifierInStrictMode(propertyAccessExp);
|
||||
checkGrammarHeritageClauseElementInStrictMode(<PropertyAccessExpression>expression.expression);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user