mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-27 22:39:59 -05:00
Address slew of review comments
This commit is contained in:
@@ -11381,12 +11381,13 @@ module ts {
|
||||
}
|
||||
|
||||
function checkGrammarArrowFunction(node: FunctionLikeDeclaration): boolean {
|
||||
if (node.kind === SyntaxKind.ArrowFunction && (<ArrowFunction>node).arrow) {
|
||||
if (node.kind === SyntaxKind.ArrowFunction) {
|
||||
var arrowFunction = <ArrowFunction>node;
|
||||
var sourceFile = getSourceFileOfNode(node);
|
||||
if (getLineAndCharacterOfPosition(sourceFile, getTokenPosOfNode(arrowFunction.arrow, sourceFile)).line !==
|
||||
getLineAndCharacterOfPosition(sourceFile, arrowFunction.parameters.end).line) {
|
||||
return grammarErrorOnNode(arrowFunction.arrow, Diagnostics.Line_terminator_not_permitted_before_arrow);
|
||||
var equalsGreaterThanLine = getLineAndCharacterOfPosition(sourceFile, getTokenPosOfNode(arrowFunction.equalsGreaterThanToken, sourceFile)).line;
|
||||
var parametersLine = getLineAndCharacterOfPosition(sourceFile, arrowFunction.parameters.end).line;
|
||||
if (equalsGreaterThanLine !== parametersLine) {
|
||||
return grammarErrorOnNode(arrowFunction.equalsGreaterThanToken, Diagnostics.Line_terminator_not_permitted_before_arrow);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -95,7 +95,7 @@ module ts {
|
||||
visitNodes(cbNodes, (<FunctionLikeDeclaration>node).typeParameters) ||
|
||||
visitNodes(cbNodes, (<FunctionLikeDeclaration>node).parameters) ||
|
||||
visitNode(cbNode, (<FunctionLikeDeclaration>node).type) ||
|
||||
visitNode(cbNode, (<ArrowFunction>node).arrow) ||
|
||||
visitNode(cbNode, (<ArrowFunction>node).equalsGreaterThanToken) ||
|
||||
visitNode(cbNode, (<FunctionLikeDeclaration>node).body);
|
||||
case SyntaxKind.TypeReference:
|
||||
return visitNode(cbNode, (<TypeReferenceNode>node).typeName) ||
|
||||
@@ -3017,9 +3017,7 @@ module ts {
|
||||
node.parameters.pos = parameter.pos;
|
||||
node.parameters.end = parameter.end;
|
||||
|
||||
if ((node.arrow = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, false, Diagnostics._0_expected, "=>"))) {
|
||||
node.arrow.parent = node;
|
||||
}
|
||||
node.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, false, Diagnostics._0_expected, "=>");
|
||||
node.body = parseArrowFunctionExpressionBody();
|
||||
|
||||
return finishNode(node);
|
||||
@@ -3048,8 +3046,7 @@ module ts {
|
||||
|
||||
// If we have an arrow, then try to parse the body. Even if not, try to parse if we
|
||||
// have an opening brace, just in case we're in an error state.
|
||||
if ((arrowFunction.arrow = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, false, Diagnostics._0_expected, "=>")) || token === SyntaxKind.OpenBraceToken) {
|
||||
arrowFunction.arrow.parent = arrowFunction;
|
||||
if ((arrowFunction.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, false, Diagnostics._0_expected, "=>")) || token === SyntaxKind.OpenBraceToken) {
|
||||
arrowFunction.body = parseArrowFunctionExpressionBody();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -654,7 +654,7 @@ module ts {
|
||||
}
|
||||
|
||||
export interface ArrowFunction extends Expression, FunctionLikeDeclaration {
|
||||
arrow: Node;
|
||||
equalsGreaterThanToken: Node;
|
||||
}
|
||||
|
||||
// The text property of a LiteralExpression stores the interpreted value of the literal in text form. For a StringLiteral,
|
||||
|
||||
@@ -554,7 +554,7 @@ declare module "typescript" {
|
||||
body: Block | Expression;
|
||||
}
|
||||
interface ArrowFunction extends Expression, FunctionLikeDeclaration {
|
||||
arrow: Node;
|
||||
equalsGreaterThanToken: Node;
|
||||
}
|
||||
interface LiteralExpression extends PrimaryExpression {
|
||||
text: string;
|
||||
|
||||
@@ -1674,8 +1674,8 @@ declare module "typescript" {
|
||||
>questionToken : Node
|
||||
>Node : Node
|
||||
|
||||
initializer: Expression;
|
||||
|
||||
initializer: Expression;
|
||||
|
||||
>initializer : Expression
|
||||
>Expression : Expression
|
||||
}
|
||||
|
||||
@@ -585,7 +585,7 @@ declare module "typescript" {
|
||||
body: Block | Expression;
|
||||
}
|
||||
interface ArrowFunction extends Expression, FunctionLikeDeclaration {
|
||||
arrow: Node;
|
||||
equalsGreaterThanToken: Node;
|
||||
}
|
||||
interface LiteralExpression extends PrimaryExpression {
|
||||
text: string;
|
||||
|
||||
@@ -1820,8 +1820,8 @@ declare module "typescript" {
|
||||
>questionToken : Node
|
||||
>Node : Node
|
||||
|
||||
initializer: Expression;
|
||||
|
||||
initializer: Expression;
|
||||
|
||||
>initializer : Expression
|
||||
>Expression : Expression
|
||||
}
|
||||
|
||||
@@ -586,7 +586,7 @@ declare module "typescript" {
|
||||
body: Block | Expression;
|
||||
}
|
||||
interface ArrowFunction extends Expression, FunctionLikeDeclaration {
|
||||
arrow: Node;
|
||||
equalsGreaterThanToken: Node;
|
||||
}
|
||||
interface LiteralExpression extends PrimaryExpression {
|
||||
text: string;
|
||||
|
||||
@@ -1770,8 +1770,8 @@ declare module "typescript" {
|
||||
>questionToken : Node
|
||||
>Node : Node
|
||||
|
||||
initializer: Expression;
|
||||
|
||||
initializer: Expression;
|
||||
|
||||
>initializer : Expression
|
||||
>Expression : Expression
|
||||
}
|
||||
|
||||
@@ -623,7 +623,7 @@ declare module "typescript" {
|
||||
body: Block | Expression;
|
||||
}
|
||||
interface ArrowFunction extends Expression, FunctionLikeDeclaration {
|
||||
arrow: Node;
|
||||
equalsGreaterThanToken: Node;
|
||||
}
|
||||
interface LiteralExpression extends PrimaryExpression {
|
||||
text: string;
|
||||
|
||||
@@ -1943,8 +1943,8 @@ declare module "typescript" {
|
||||
>questionToken : Node
|
||||
>Node : Node
|
||||
|
||||
initializer: Expression;
|
||||
|
||||
initializer: Expression;
|
||||
|
||||
>initializer : Expression
|
||||
>Expression : Expression
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user