Skip to content

Commit

Permalink
Added message to deprecate support for parenthesis in parameter and a…
Browse files Browse the repository at this point in the history
…rgument lists.
  • Loading branch information
rbuckton committed Oct 5, 2015
1 parent 17862ce commit b4f729d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/lib/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,31 @@ export class Checker {
}

private checkParameterList(node: ParameterList): void {
this.checkGrammarParameterList(node);

for (let element of node.elements) {
this.checkParameter(element);
}
}

private checkGrammarParameterList(node: ParameterList): boolean {
if (!node.openParenToken) {
return this.reportGrammarError(node.pos, Diagnostics._0_expected, tokenToString(SyntaxKind.OpenBracketToken));
}

if (node.openParenToken.kind === SyntaxKind.OpenParenToken) {
return this.reportGrammarErrorForNode(node.openParenToken, Diagnostics.Obsolete_0_, `Support for using parenthesis to enclose production parameter lists is deprecated and may be removed in a future update. Please switch to bracket's ('[', ']') when enclosing production parameter lists.`)
}

if (!node.elements) {
return this.reportGrammarError(node.pos, Diagnostics._0_expected, tokenToString(SyntaxKind.Identifier));
}

if (!node.closeParenToken) {
return this.reportGrammarError(node.pos, Diagnostics._0_expected, tokenToString(SyntaxKind.CloseBracketToken));
}
}

private checkParameter(node: Parameter): void {
this.checkIdentifier(node.name);
}
Expand Down Expand Up @@ -781,15 +801,19 @@ export class Checker {

private checkGrammarArgumentList(node: ArgumentList): boolean {
if (!node.openParenToken) {
return this.reportGrammarError(node.pos, Diagnostics._0_expected, tokenToString(SyntaxKind.OpenParenToken));
return this.reportGrammarError(node.pos, Diagnostics._0_expected, tokenToString(SyntaxKind.OpenBracketToken));
}

if (node.openParenToken.kind === SyntaxKind.OpenParenToken) {
return this.reportGrammarErrorForNode(node.openParenToken, Diagnostics.Obsolete_0_, `Support for using parenthesis to enclose an argument list is deprecated and may be removed in a future update. Please switch to bracket's ('[', ']') when enclosing argument lists.`)
}

if (!node.elements) {
return this.reportGrammarError(node.pos, Diagnostics._0_expected, tokenToString(SyntaxKind.Identifier));
}

if (!node.closeParenToken) {
return this.reportGrammarError(node.pos, Diagnostics._0_expected, tokenToString(SyntaxKind.CloseParenToken));
return this.reportGrammarError(node.pos, Diagnostics._0_expected, tokenToString(SyntaxKind.CloseBracketToken));
}

return false;
Expand Down
1 change: 1 addition & 0 deletions src/lib/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const Diagnostics = {
Digit_expected: <Diagnostic>{ code: 1006, message: "Digit expected." },
Production_expected: <Diagnostic>{ code: 1007, message: "Production expected." },
Unterminated_identifier_literal: <Diagnostic>{ code: 1008, message: "Unterminated identifier literal." },
Obsolete_0_: <Diagnostic>{ code: 1009, message: "Obsolete: {0}", warning: true },
Cannot_find_name_0_: <Diagnostic>{ code: 2000, message: "Cannot find name: '{0}'." },
Duplicate_identifier_0_: <Diagnostic>{ code: 2001, message: "Duplicate identifier: '{0}'." },
Duplicate_terminal_0_: <Diagnostic>{ code: 2002, message: "Duplicate terminal: `{0}`." },
Expand Down

0 comments on commit b4f729d

Please sign in to comment.