From d996d9601d3fe13c1da3701015d549cbff792fc8 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Mon, 21 May 2018 18:18:27 +0300 Subject: [PATCH] [groovy] parser: update error reporting in closure parameter list - don't report expected ','; - update test data to match new GeneratedParserUtilBase behaviour. --- .../groovy/lang/parser/GroovyBnfParser.java | 15 +++++++++++++-- .../plugins/groovy/lang/parser/groovy.bnf | 3 ++- .../groovy/expressions/noArrowClosure.test | 2 +- .../groovy/expressions/noArrowClosure2.test | 5 ++--- .../parsing/groovy/expressions/regex/regex10.test | 2 +- plugins/groovy/testdata/reparse/SwitchRParen.txt | 4 ++-- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/plugins/groovy/groovy-psi/gen/org/jetbrains/plugins/groovy/lang/parser/GroovyBnfParser.java b/plugins/groovy/groovy-psi/gen/org/jetbrains/plugins/groovy/lang/parser/GroovyBnfParser.java index 4edf801614cf..b662ecc11fcd 100644 --- a/plugins/groovy/groovy-psi/gen/org/jetbrains/plugins/groovy/lang/parser/GroovyBnfParser.java +++ b/plugins/groovy/groovy-psi/gen/org/jetbrains/plugins/groovy/lang/parser/GroovyBnfParser.java @@ -2279,9 +2279,9 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser { } /* ********************************************************** */ - // <> ','>> + // <> fast_comma>> static boolean comma_list(PsiBuilder b, int l, Parser _item) { - return a_b_a(b, l + 1, _item, T_COMMA_parser_); + return a_b_a(b, l + 1, _item, fast_comma_parser_); } /* ********************************************************** */ @@ -3176,6 +3176,12 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser { return r; } + /* ********************************************************** */ + // ',' + static boolean fast_comma(PsiBuilder b, int l) { + return consumeTokenFast(b, T_COMMA); + } + /* ********************************************************** */ // DOLLAR_SLASHY_CONTENT static boolean fast_dollar_slashy_content(PsiBuilder b, int l) { @@ -7241,6 +7247,11 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser { return extends_recovery(b, l + 1); } }; + final static Parser fast_comma_parser_ = new Parser() { + public boolean parse(PsiBuilder b, int l) { + return fast_comma(b, l + 1); + } + }; final static Parser fast_dollar_slashy_content_parser_ = new Parser() { public boolean parse(PsiBuilder b, int l) { return fast_dollar_slashy_content(b, l + 1); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/groovy.bnf b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/groovy.bnf index 872526e784f4..f5d7c0f3cf3a 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/groovy.bnf +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/groovy.bnf @@ -1253,7 +1253,8 @@ private empty_pars ::= '(' ')' { consumeTokenMethod = 'consumeTokenFast' } // region Lists private meta comma_list_p ::= <> ','>> private meta a_b_a_p ::= <> (<> <>)* { pin('.*') = 1 } -private meta comma_list ::= <> ','>> +private meta comma_list ::= <> fast_comma>> +private fast_comma ::= ',' private meta a_b_a ::= <> (<> <>)* { pin = 1 } private meta paren_list ::= '('')' | '(' <>>> ')' { pin('paren_list_1') = 1 } diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/noArrowClosure.test b/plugins/groovy/testdata/parsing/groovy/expressions/noArrowClosure.test index 246834f7c6f5..89493081d2c2 100644 --- a/plugins/groovy/testdata/parsing/groovy/expressions/noArrowClosure.test +++ b/plugins/groovy/testdata/parsing/groovy/expressions/noArrowClosure.test @@ -16,7 +16,7 @@ Groovy script Variable PsiElement(identifier)('key') PsiElement(,)(',') - PsiErrorElement:',', '->' or identifier expected, got '}' + PsiErrorElement:'->' or identifier expected, got '}' PsiWhiteSpace(' ') PsiElement(})('}') \ No newline at end of file diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/noArrowClosure2.test b/plugins/groovy/testdata/parsing/groovy/expressions/noArrowClosure2.test index 406fe752ec8f..081ef2c8c9fb 100644 --- a/plugins/groovy/testdata/parsing/groovy/expressions/noArrowClosure2.test +++ b/plugins/groovy/testdata/parsing/groovy/expressions/noArrowClosure2.test @@ -10,9 +10,8 @@ Groovy script Reference expression PsiElement(identifier)('a') - PsiElement(,)(',') - PsiErrorElement:identifier expected, got 'b' - + PsiErrorElement: expected, got ',' + PsiElement(,)(',') PsiWhiteSpace(' ') Reference expression PsiElement(identifier)('b') diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex10.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex10.test index a4a8bcafc7c4..f7e187b1eaad 100644 --- a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex10.test +++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex10.test @@ -17,7 +17,7 @@ Groovy script PsiElement({)('{') Parameter list - PsiErrorElement:',', '->', ';', , identifier or new line expected, got 'do' + PsiErrorElement:'->', ';', , identifier or new line expected, got 'do' PsiElement(do)('do') PsiWhiteSpace(' ') Compound Gstring diff --git a/plugins/groovy/testdata/reparse/SwitchRParen.txt b/plugins/groovy/testdata/reparse/SwitchRParen.txt index 8703095a5d1e..d6fc40e23a43 100644 --- a/plugins/groovy/testdata/reparse/SwitchRParen.txt +++ b/plugins/groovy/testdata/reparse/SwitchRParen.txt @@ -39,7 +39,7 @@ Groovy script PsiWhiteSpace('\n ') Parameter list - PsiErrorElement:',', '->', ';', , identifier or new line expected, got 'case' + PsiErrorElement:'->', ';', , identifier or new line expected, got 'case' PsiElement(case)('case') PsiWhiteSpace(' ') Literal @@ -109,7 +109,7 @@ Groovy script PsiWhiteSpace('\n ') Parameter list - PsiErrorElement:',', '->', ';', , identifier or new line expected, got 'case' + PsiErrorElement:'->', ';', , identifier or new line expected, got 'case' PsiElement(case)('case') PsiWhiteSpace(' ') Literal