[groovy] parser: update error reporting in closure parameter list

- don't report expected ',';
- update test data to match new GeneratedParserUtilBase behaviour.
This commit is contained in:
Daniil Ovchinnikov
2018-05-21 18:18:58 +03:00
parent 8b6bdb6715
commit d996d9601d
6 changed files with 21 additions and 10 deletions
@@ -2279,9 +2279,9 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
}
/* ********************************************************** */
// <<a_b_a <<item>> ','>>
// <<a_b_a <<item>> 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);
@@ -1253,7 +1253,8 @@ private empty_pars ::= '(' ')' { consumeTokenMethod = 'consumeTokenFast' }
// region Lists
private meta comma_list_p ::= <<a_b_a_p <<item>> ','>>
private meta a_b_a_p ::= <<a>> (<<b>> <<a>>)* { pin('.*') = 1 }
private meta comma_list ::= <<a_b_a <<item>> ','>>
private meta comma_list ::= <<a_b_a <<item>> fast_comma>>
private fast_comma ::= ','
private meta a_b_a ::= <<a>> (<<b>> <<a>>)* { pin = 1 }
private meta paren_list ::= '('')' | '(' <<paren_list_inner <<item>>>> ')' { pin('paren_list_1') = 1 }
@@ -16,7 +16,7 @@ Groovy script
Variable
PsiElement(identifier)('key')
PsiElement(,)(',')
PsiErrorElement:',', '->' or identifier expected, got '}'
PsiErrorElement:'->' or identifier expected, got '}'
<empty list>
PsiWhiteSpace(' ')
PsiElement(})('}')
@@ -10,9 +10,8 @@ Groovy script
<empty list>
Reference expression
PsiElement(identifier)('a')
PsiElement(,)(',')
PsiErrorElement:identifier expected, got 'b'
<empty list>
PsiErrorElement:<expression> expected, got ','
PsiElement(,)(',')
PsiWhiteSpace(' ')
Reference expression
PsiElement(identifier)('b')
@@ -17,7 +17,7 @@ Groovy script
PsiElement({)('{')
Parameter list
<empty list>
PsiErrorElement:',', '->', ';', <statement>, identifier or new line expected, got 'do'
PsiErrorElement:'->', ';', <statement>, identifier or new line expected, got 'do'
PsiElement(do)('do')
PsiWhiteSpace(' ')
Compound Gstring
+2 -2
View File
@@ -39,7 +39,7 @@ Groovy script
PsiWhiteSpace('\n ')
Parameter list
<empty list>
PsiErrorElement:',', '->', ';', <statement>, identifier or new line expected, got 'case'
PsiErrorElement:'->', ';', <statement>, identifier or new line expected, got 'case'
PsiElement(case)('case')
PsiWhiteSpace(' ')
Literal
@@ -109,7 +109,7 @@ Groovy script
PsiWhiteSpace('\n ')
Parameter list
<empty list>
PsiErrorElement:',', '->', ';', <statement>, identifier or new line expected, got 'case'
PsiErrorElement:'->', ';', <statement>, identifier or new line expected, got 'case'
PsiElement(case)('case')
PsiWhiteSpace(' ')
Literal