mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] parser: argument list parsing & recovery (IDEA-191728)
This commit is contained in:
+199
-20
@@ -948,6 +948,111 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
return r;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// <<argument_list_item_head <<brace>>>> <<argument_list_item_end <<brace>>>>
|
||||
static boolean argument_list_item(PsiBuilder b, int l, Parser _brace) {
|
||||
if (!recursion_guard_(b, l, "argument_list_item")) return false;
|
||||
boolean r, p;
|
||||
Marker m = enter_section_(b, l, _NONE_);
|
||||
r = argument_list_item_head(b, l + 1, _brace);
|
||||
p = r; // pin = 1
|
||||
r = r && argument_list_item_end(b, l + 1, _brace);
|
||||
exit_section_(b, l, m, r, p, null);
|
||||
return r || p;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// ',' | &<<brace>>
|
||||
static boolean argument_list_item_end(PsiBuilder b, int l, Parser _brace) {
|
||||
if (!recursion_guard_(b, l, "argument_list_item_end")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = consumeToken(b, T_COMMA);
|
||||
if (!r) r = argument_list_item_end_1(b, l + 1, _brace);
|
||||
exit_section_(b, m, null, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
// &<<brace>>
|
||||
private static boolean argument_list_item_end_1(PsiBuilder b, int l, Parser _brace) {
|
||||
if (!recursion_guard_(b, l, "argument_list_item_end_1")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b, l, _AND_);
|
||||
r = _brace.parse(b, l);
|
||||
exit_section_(b, l, m, r, false, null);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// <<argument_list_item_head0 <<brace>> <<argument_list_item_recovery <<brace>>>>>>
|
||||
static boolean argument_list_item_head(PsiBuilder b, int l, Parser _brace) {
|
||||
return argument_list_item_head0(b, l + 1, _brace, new Parser() {
|
||||
public boolean parse(PsiBuilder b, int l) {
|
||||
return argument_list_item_recovery(b, l + 1, _brace);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// !(end_of_file | <<brace>>) parse_argument
|
||||
static boolean argument_list_item_head0(PsiBuilder b, int l, Parser _brace, Parser _recovery) {
|
||||
if (!recursion_guard_(b, l, "argument_list_item_head0")) return false;
|
||||
boolean r, p;
|
||||
Marker m = enter_section_(b, l, _NONE_);
|
||||
r = argument_list_item_head0_0(b, l + 1, _brace, _recovery);
|
||||
p = r; // pin = 1
|
||||
r = r && parse_argument(b, l + 1);
|
||||
exit_section_(b, l, m, r, p, _recovery);
|
||||
return r || p;
|
||||
}
|
||||
|
||||
// !(end_of_file | <<brace>>)
|
||||
private static boolean argument_list_item_head0_0(PsiBuilder b, int l, Parser _brace, Parser _recovery) {
|
||||
if (!recursion_guard_(b, l, "argument_list_item_head0_0")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b, l, _NOT_);
|
||||
r = !argument_list_item_head0_0_0(b, l + 1, _brace, _recovery);
|
||||
exit_section_(b, l, m, r, false, null);
|
||||
return r;
|
||||
}
|
||||
|
||||
// end_of_file | <<brace>>
|
||||
private static boolean argument_list_item_head0_0_0(PsiBuilder b, int l, Parser _brace, Parser _recovery) {
|
||||
if (!recursion_guard_(b, l, "argument_list_item_head0_0_0")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = eof(b, l + 1);
|
||||
if (!r) r = _brace.parse(b, l);
|
||||
exit_section_(b, m, null, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// !(<<brace>> | ',' | '}' | qualified_reference_expression_identifiers | expression_start | argument_label)
|
||||
static boolean argument_list_item_recovery(PsiBuilder b, int l, Parser _brace) {
|
||||
if (!recursion_guard_(b, l, "argument_list_item_recovery")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b, l, _NOT_);
|
||||
r = !argument_list_item_recovery_0(b, l + 1, _brace);
|
||||
exit_section_(b, l, m, r, false, null);
|
||||
return r;
|
||||
}
|
||||
|
||||
// <<brace>> | ',' | '}' | qualified_reference_expression_identifiers | expression_start | argument_label
|
||||
private static boolean argument_list_item_recovery_0(PsiBuilder b, int l, Parser _brace) {
|
||||
if (!recursion_guard_(b, l, "argument_list_item_recovery_0")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = _brace.parse(b, l);
|
||||
if (!r) r = consumeToken(b, T_COMMA);
|
||||
if (!r) r = consumeToken(b, T_RBRACE);
|
||||
if (!r) r = qualified_reference_expression_identifiers(b, l + 1);
|
||||
if (!r) r = expression_start(b, l + 1);
|
||||
if (!r) r = argument_label(b, l + 1);
|
||||
exit_section_(b, m, null, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// mandatory_expression optional_expression*
|
||||
public static boolean array_declarator(PsiBuilder b, int l) {
|
||||
@@ -1172,6 +1277,25 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
return r;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// bracket_argument_list_item*
|
||||
static boolean bracket_argument_list_inner(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "bracket_argument_list_inner")) return false;
|
||||
int c = current_position_(b);
|
||||
while (true) {
|
||||
if (!bracket_argument_list_item(b, l + 1)) break;
|
||||
if (!empty_element_parsed_guard_(b, "bracket_argument_list_inner", c)) break;
|
||||
c = current_position_(b);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// <<argument_list_item ']'>>
|
||||
static boolean bracket_argument_list_item(PsiBuilder b, int l) {
|
||||
return argument_list_item(b, l + 1, T_RBRACK_parser_);
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// 'break' IDENTIFIER?
|
||||
public static boolean break_statement(PsiBuilder b, int l) {
|
||||
@@ -1193,26 +1317,47 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// empty_pars | '(' parse_paren_argument_list ')'
|
||||
// '(' (')') | '(' paren_argument_list_inner ')'
|
||||
public static boolean call_argument_list(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "call_argument_list")) return false;
|
||||
if (!nextTokenIsFast(b, T_LPAREN)) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = empty_pars(b, l + 1);
|
||||
r = call_argument_list_0(b, l + 1);
|
||||
if (!r) r = call_argument_list_1(b, l + 1);
|
||||
exit_section_(b, m, ARGUMENT_LIST, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
// '(' parse_paren_argument_list ')'
|
||||
// '(' (')')
|
||||
private static boolean call_argument_list_0(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "call_argument_list_0")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = consumeTokenFast(b, T_LPAREN);
|
||||
r = r && call_argument_list_0_1(b, l + 1);
|
||||
exit_section_(b, m, null, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
// (')')
|
||||
private static boolean call_argument_list_0_1(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "call_argument_list_0_1")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = consumeTokenFast(b, T_RPAREN);
|
||||
exit_section_(b, m, null, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
// '(' paren_argument_list_inner ')'
|
||||
private static boolean call_argument_list_1(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "call_argument_list_1")) return false;
|
||||
boolean r, p;
|
||||
Marker m = enter_section_(b, l, _NONE_);
|
||||
r = consumeTokenFast(b, T_LPAREN);
|
||||
p = r; // pin = 1
|
||||
r = r && report_error_(b, parseArgumentList(b, l + 1, T_RPAREN, argument_parser_));
|
||||
r = r && report_error_(b, paren_argument_list_inner(b, l + 1));
|
||||
r = p && consumeToken(b, T_RPAREN) && r;
|
||||
exit_section_(b, l, m, r, p, null);
|
||||
return r || p;
|
||||
@@ -2813,18 +2958,6 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// '(' ')'
|
||||
static boolean empty_pars(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "empty_pars")) return false;
|
||||
if (!nextTokenIsFast(b, T_LPAREN)) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = consumeTokens(b, 0, T_LPAREN, T_RPAREN);
|
||||
exit_section_(b, m, null, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// empty
|
||||
public static boolean empty_throws_clause(PsiBuilder b, int l) {
|
||||
@@ -3587,7 +3720,7 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// !empty_map '[' parse_bracket_argument_list ']'
|
||||
// !empty_map '[' bracket_argument_list_inner ']'
|
||||
public static boolean index_expression_argument_list(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "index_expression_argument_list")) return false;
|
||||
boolean r, p;
|
||||
@@ -3595,7 +3728,7 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
r = index_expression_argument_list_0(b, l + 1);
|
||||
r = r && consumeTokenFast(b, T_LBRACK);
|
||||
p = r; // pin = 2
|
||||
r = r && report_error_(b, parseArgumentList(b, l + 1, T_RBRACK, argument_parser_));
|
||||
r = r && report_error_(b, bracket_argument_list_inner(b, l + 1));
|
||||
r = p && consumeToken(b, T_RBRACK) && r;
|
||||
exit_section_(b, l, m, r, p, null);
|
||||
return r || p;
|
||||
@@ -4232,14 +4365,14 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// '[' parse_bracket_argument_list ']'
|
||||
// '[' bracket_argument_list_inner ']'
|
||||
static boolean non_empty_list_or_map(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "non_empty_list_or_map")) return false;
|
||||
if (!nextTokenIs(b, T_LBRACK)) return false;
|
||||
boolean r, p;
|
||||
Marker m = enter_section_(b, l, _NONE_);
|
||||
r = consumeToken(b, T_LBRACK);
|
||||
r = r && parseArgumentList(b, l + 1, T_RBRACK, argument_parser_);
|
||||
r = r && bracket_argument_list_inner(b, l + 1);
|
||||
p = r; // pin = 2
|
||||
r = r && consumeToken(b, T_RBRACK);
|
||||
exit_section_(b, l, m, r, p, null);
|
||||
@@ -4498,6 +4631,36 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
return r;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// paren_argument_list_item* <<clearError>>
|
||||
static boolean paren_argument_list_inner(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "paren_argument_list_inner")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = paren_argument_list_inner_0(b, l + 1);
|
||||
r = r && clearError(b, l + 1);
|
||||
exit_section_(b, m, null, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
// paren_argument_list_item*
|
||||
private static boolean paren_argument_list_inner_0(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "paren_argument_list_inner_0")) return false;
|
||||
int c = current_position_(b);
|
||||
while (true) {
|
||||
if (!paren_argument_list_item(b, l + 1)) break;
|
||||
if (!empty_element_parsed_guard_(b, "paren_argument_list_inner_0", c)) break;
|
||||
c = current_position_(b);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// <<argument_list_item ')'>>
|
||||
static boolean paren_argument_list_item(PsiBuilder b, int l) {
|
||||
return argument_list_item(b, l + 1, T_RPAREN_parser_);
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// '('')' | '(' <<paren_list_inner <<item>>>> ')'
|
||||
static boolean paren_list(PsiBuilder b, int l, Parser _item) {
|
||||
@@ -4588,6 +4751,12 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
return r;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// <<parseArgument argument>>
|
||||
static boolean parse_argument(PsiBuilder b, int l) {
|
||||
return parseArgument(b, l + 1, argument_parser_);
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// <<parseTailLeftFlat declaration_start declaration_tail>>
|
||||
static boolean parse_block_declaration(PsiBuilder b, int l) {
|
||||
@@ -7052,6 +7221,16 @@ public class GroovyBnfParser implements PsiParser, LightPsiParser {
|
||||
return consumeTokenFast(b, T_LBRACE);
|
||||
}
|
||||
};
|
||||
final static Parser T_RBRACK_parser_ = new Parser() {
|
||||
public boolean parse(PsiBuilder b, int l) {
|
||||
return consumeToken(b, T_RBRACK);
|
||||
}
|
||||
};
|
||||
final static Parser T_RPAREN_parser_ = new Parser() {
|
||||
public boolean parse(PsiBuilder b, int l) {
|
||||
return consumeToken(b, T_RPAREN);
|
||||
}
|
||||
};
|
||||
final static Parser angle_list_item_recovery_parser_ = new Parser() {
|
||||
public boolean parse(PsiBuilder b, int l) {
|
||||
return commaAngleRecovery(b, l + 1);
|
||||
|
||||
@@ -935,7 +935,7 @@ list_or_map ::= empty_list | empty_map | non_empty_list_or_map
|
||||
|
||||
private empty_map ::= '[' mb_nl ':' mb_nl ']'
|
||||
private empty_list ::= '[' mb_nl ']'
|
||||
private non_empty_list_or_map ::= '[' parse_bracket_argument_list ']'
|
||||
private non_empty_list_or_map ::= '[' bracket_argument_list_inner ']'
|
||||
{
|
||||
pin = 2
|
||||
}
|
||||
@@ -981,7 +981,7 @@ private cast_expression_no_pin ::= '(' type_element ')' priority1_4
|
||||
|
||||
private priority1_5 ::= index_expression | postfix_unary_expression
|
||||
index_expression ::= expression index_expression_argument_list
|
||||
index_expression_argument_list ::= !empty_map '[' parse_bracket_argument_list ']'
|
||||
index_expression_argument_list ::= !empty_map '[' bracket_argument_list_inner ']'
|
||||
{
|
||||
pin = 2
|
||||
elementType = argument_list
|
||||
@@ -1089,19 +1089,29 @@ fake argument_list ::=
|
||||
empty_argument_list ::= { elementType = argument_list }
|
||||
|
||||
private call_argument_list_start ::= &'(' // adds a variant, to achieve "'(' expected" generated message
|
||||
call_argument_list ::= empty_pars | '(' parse_paren_argument_list ')'
|
||||
call_argument_list ::= '(' (')') | '(' paren_argument_list_inner ')'
|
||||
{
|
||||
elementType = argument_list
|
||||
pin('call_argument_list_1') = 1
|
||||
consumeTokenMethod = 'consumeTokenFast'
|
||||
}
|
||||
|
||||
private external parse_paren_argument_list ::= parseArgumentList 'T_RPAREN' argument
|
||||
private external parse_bracket_argument_list ::= parseArgumentList 'T_RBRACK' argument
|
||||
private paren_argument_list_inner ::= paren_argument_list_item* <<clearError>>
|
||||
private bracket_argument_list_inner ::= bracket_argument_list_item*
|
||||
|
||||
private paren_argument_list_item ::= <<argument_list_item ')'>>
|
||||
private bracket_argument_list_item ::= <<argument_list_item ']'>>
|
||||
|
||||
private meta argument_list_item ::= <<argument_list_item_head <<brace>>>> <<argument_list_item_end <<brace>>>> { pin = 1 }
|
||||
private meta argument_list_item_head ::= <<argument_list_item_head0 <<brace>> <<argument_list_item_recovery <<brace>>>>>>
|
||||
private meta argument_list_item_head0 ::= !(end_of_file | <<brace>>) parse_argument { pin = 1 recoverWhile = '<<recovery>>' }
|
||||
private meta argument_list_item_end ::= ',' | &<<brace>>
|
||||
private meta argument_list_item_recovery ::= !(<<brace>> | ',' | '}' | qualified_reference_expression_identifiers | expression_start | argument_label)
|
||||
|
||||
application_argument_list ::= <<applicationArguments application_arguments>>
|
||||
private application_arguments ::= argument (',' mb_nl argument)*
|
||||
|
||||
private parse_argument ::= <<parseArgument argument>>
|
||||
private argument ::= spread_list_argument | named_argument | <<parseExpressionOrMapArgument expression>>
|
||||
spread_list_argument ::= !<<isApplicationArguments>> '*' expression { consumeTokenMethod = 'consumeTokenFast' }
|
||||
named_argument ::= argument_label named_argument_tail
|
||||
@@ -1202,7 +1212,7 @@ private nl ::= NL { consumeTokenMethod = 'consumeTokenFast' }
|
||||
private meta mb_nl_group ::= <<something>> | nl <<something>> // allows error reporting in position before the new line
|
||||
private empty ::= ()
|
||||
private external fail ::= noMatch
|
||||
private empty_pars ::= '(' ')' { consumeTokenMethod = 'consumeTokenFast' }
|
||||
private external end_of_file ::= eof
|
||||
// endregion
|
||||
|
||||
|
||||
|
||||
+7
-3
@@ -13,7 +13,6 @@ import com.intellij.openapi.util.Key
|
||||
import com.intellij.psi.tree.IElementType
|
||||
import com.intellij.psi.tree.TokenSet
|
||||
import org.jetbrains.plugins.groovy.GroovyBundle
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.arguments.ArgumentList
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementTypes.*
|
||||
import org.jetbrains.plugins.groovy.util.get
|
||||
import org.jetbrains.plugins.groovy.util.getAndReset
|
||||
@@ -122,9 +121,9 @@ fun codeReferenceTypeArguments(builder: PsiBuilder, level: Int, typeArgumentsPar
|
||||
return true
|
||||
}
|
||||
|
||||
fun parseArgumentList(builder: PsiBuilder, level: Int, closingBrace: IElementType, argumentParser: Parser): Boolean {
|
||||
fun parseArgument(builder: PsiBuilder, level: Int, argumentParser: Parser): Boolean {
|
||||
return builder.withKey(parseArguments, true) {
|
||||
ArgumentList.parseArgumentList(builder, level, closingBrace, argumentParser)
|
||||
argumentParser.parse(builder, level)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,3 +313,8 @@ fun clearVariants(builder: PsiBuilder, level: Int): Boolean {
|
||||
fun replaceVariants(builder: PsiBuilder, level: Int, variant: String): Boolean {
|
||||
return clearVariants(builder, level) && addVariant(builder, level, variant)
|
||||
}
|
||||
|
||||
fun clearError(builder: PsiBuilder, level: Int): Boolean {
|
||||
ErrorState.get(builder).currentFrame.errorReportedAt = -1
|
||||
return true
|
||||
}
|
||||
|
||||
+22
-12
@@ -1,8 +1,22 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.arguments;
|
||||
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.lang.parser.GeneratedParserUtilBase.Parser;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
@@ -36,17 +50,14 @@ public class ArgumentList {
|
||||
GroovyTokenTypes.kTRY, GroovyTokenTypes.kVOLATILE,
|
||||
GroovyTokenTypes.kWHILE);
|
||||
|
||||
public static void parseArgumentList(PsiBuilder builder, IElementType closingBrace, GroovyParser parser) {
|
||||
parseArgumentList(builder, 0, closingBrace, (b, l) -> argumentParse(b, parser));
|
||||
}
|
||||
|
||||
public static boolean parseArgumentList(PsiBuilder builder, int level, IElementType closingBrace, Parser argumentParser) {
|
||||
boolean hasFirstArg = argumentParser.parse(builder, level + 1);
|
||||
public static void parseArgumentList(PsiBuilder builder, IElementType closingBrace, GroovyParser parser) {
|
||||
boolean hasFirstArg = argumentParse(builder, parser);
|
||||
if (!hasFirstArg) {
|
||||
if (!closingBrace.equals(builder.getTokenType())) {
|
||||
builder.error(GroovyBundle.message("expression.expected"));
|
||||
}
|
||||
if (GroovyTokenTypes.mRCURLY.equals(builder.getTokenType())) return true;
|
||||
if (GroovyTokenTypes.mRCURLY.equals(builder.getTokenType())) return;
|
||||
|
||||
if (!GroovyTokenTypes.mCOMMA.equals(builder.getTokenType()) &&
|
||||
!closingBrace.equals(builder.getTokenType())) {
|
||||
@@ -63,14 +74,14 @@ public class ArgumentList {
|
||||
}
|
||||
ParserUtils.getToken(builder, GroovyTokenTypes.mNLS);
|
||||
if (hasErrors && CONTROL_KEYWORDS.contains(builder.getTokenType())) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
if (!argumentParser.parse(builder, level + 1)) {
|
||||
if (!argumentParse(builder, parser)) {
|
||||
if (!closingBrace.equals(builder.getTokenType())) {
|
||||
builder.error(GroovyBundle.message("expression.expected"));
|
||||
hasErrors = true;
|
||||
}
|
||||
if (GroovyTokenTypes.mRCURLY.equals(builder.getTokenType())) return true;
|
||||
if (GroovyTokenTypes.mRCURLY.equals(builder.getTokenType())) return;
|
||||
|
||||
if (!GroovyTokenTypes.mCOMMA.equals(builder.getTokenType()) &&
|
||||
!closingBrace.equals(builder.getTokenType())) {
|
||||
@@ -81,7 +92,6 @@ public class ArgumentList {
|
||||
}
|
||||
|
||||
ParserUtils.getToken(builder, GroovyTokenTypes.mNLS);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
@@ -279,6 +279,8 @@ class ExpressionsParsingTest extends GroovyParsingTestCase {
|
||||
|
||||
void testpath$method$method9() throws Throwable { doTest() }
|
||||
|
||||
void testpath$method$method14() { doTest() }
|
||||
|
||||
void testpath$path1() throws Throwable { doTest() }
|
||||
|
||||
void testpath$path13() throws Throwable { doTest() }
|
||||
|
||||
Vendored
+4
-5
@@ -37,10 +37,9 @@ Groovy script
|
||||
PsiElement([)('[')
|
||||
Reference expression
|
||||
PsiElement(identifier)('param')
|
||||
PsiErrorElement:',' or ']' expected
|
||||
<empty list>
|
||||
PsiElement())(')')
|
||||
PsiErrorElement:',' or ']' expected
|
||||
PsiErrorElement:')' unexpected
|
||||
PsiElement())(')')
|
||||
PsiErrorElement:',', <expression> or ']' expected, got 'case'
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n ')
|
||||
Case section
|
||||
@@ -64,7 +63,7 @@ Groovy script
|
||||
Reference expression
|
||||
PsiElement(identifier)('param')
|
||||
PsiElement(])(']')
|
||||
PsiErrorElement:',' or ')' expected
|
||||
PsiErrorElement:')' or ',' expected, got 'case'
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n ')
|
||||
Case section
|
||||
|
||||
@@ -12,5 +12,5 @@ Groovy script
|
||||
PsiElement(identifier)('a')
|
||||
PsiElement(.)('.')
|
||||
PsiElement(identifier)('toString')
|
||||
PsiErrorElement:')' expected
|
||||
PsiErrorElement:')' or ',' expected
|
||||
<empty list>
|
||||
@@ -8,5 +8,5 @@ Groovy script
|
||||
PsiElement([)('[')
|
||||
Literal
|
||||
PsiElement(string)(''name'')
|
||||
PsiErrorElement:']' expected
|
||||
PsiErrorElement:',' or ']' expected
|
||||
<empty list>
|
||||
+4
-4
@@ -12,16 +12,16 @@ Groovy script
|
||||
Literal
|
||||
PsiElement(Integer)('1')
|
||||
PsiElement(,)(',')
|
||||
PsiErrorElement:Expression expected
|
||||
PsiErrorElement:<expression> expected, got ','
|
||||
<empty list>
|
||||
PsiElement(,)(',')
|
||||
PsiErrorElement:Expression expected
|
||||
PsiErrorElement:<expression> expected, got ','
|
||||
<empty list>
|
||||
PsiElement(,)(',')
|
||||
PsiErrorElement:Expression expected
|
||||
PsiErrorElement:<expression> expected, got ','
|
||||
<empty list>
|
||||
PsiElement(,)(',')
|
||||
PsiErrorElement:Expression expected
|
||||
PsiErrorElement:<expression> expected, got ','
|
||||
<empty list>
|
||||
PsiElement(,)(',')
|
||||
Literal
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
a(,
|
||||
-----
|
||||
Groovy script
|
||||
Method call
|
||||
Reference expression
|
||||
PsiElement(identifier)('a')
|
||||
Arguments
|
||||
PsiElement(()('(')
|
||||
PsiErrorElement:<expression> expected, got ','
|
||||
<empty list>
|
||||
PsiElement(,)(',')
|
||||
PsiErrorElement:')' expected
|
||||
<empty list>
|
||||
+2
-2
@@ -13,12 +13,12 @@ Groovy script
|
||||
PsiWhiteSpace(' ')
|
||||
Literal
|
||||
PsiElement(Integer)('3')
|
||||
PsiErrorElement:',' or ')' expected
|
||||
PsiErrorElement:')' or ',' expected, got '3'
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
Literal
|
||||
PsiElement(Integer)('3')
|
||||
PsiErrorElement:',' or ')' expected
|
||||
PsiErrorElement:')' or ',' expected, got '3'
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
Literal
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ Groovy script
|
||||
PsiWhiteSpace(' ')
|
||||
Reference expression
|
||||
PsiElement(identifier)('c')
|
||||
PsiErrorElement:',' or ')' expected
|
||||
PsiErrorElement:')' or ',' expected, got '3'
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n')
|
||||
Method call
|
||||
@@ -29,5 +29,5 @@ Groovy script
|
||||
Arguments
|
||||
PsiElement(()('(')
|
||||
PsiElement())(')')
|
||||
PsiErrorElement:')' expected
|
||||
PsiErrorElement:')' or ',' expected
|
||||
<empty list>
|
||||
+1
-1
@@ -8,7 +8,7 @@ Groovy script
|
||||
PsiElement(identifier)('foo')
|
||||
Arguments
|
||||
PsiElement(()('(')
|
||||
PsiErrorElement:Expression expected
|
||||
PsiErrorElement:<expression> expected, got ','
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(,)(',')
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ Groovy script
|
||||
Literal
|
||||
PsiElement(Integer)('3')
|
||||
PsiElement(,)(',')
|
||||
PsiErrorElement:Expression expected
|
||||
PsiErrorElement:<expression> expected, got ','
|
||||
<empty list>
|
||||
PsiElement(,)(',')
|
||||
Literal
|
||||
|
||||
+4
-12
@@ -9,14 +9,9 @@ Groovy script
|
||||
PsiElement(identifier)('foo')
|
||||
Arguments
|
||||
PsiElement(()('(')
|
||||
PsiErrorElement:Expression expected
|
||||
<empty list>
|
||||
PsiErrorElement:<expression> expected, got '#'
|
||||
PsiElement(wrong token)('#')
|
||||
PsiElement(wrong token)('#')
|
||||
PsiErrorElement:Expression expected
|
||||
<empty list>
|
||||
PsiElement(wrong token)('#')
|
||||
PsiErrorElement:Expression expected
|
||||
<empty list>
|
||||
PsiElement(wrong token)('#')
|
||||
PsiElement(,)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
@@ -27,12 +22,9 @@ Groovy script
|
||||
Literal
|
||||
PsiElement(Integer)('2')
|
||||
PsiElement(,)(',')
|
||||
PsiErrorElement:Expression expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(wrong token)('#')
|
||||
PsiErrorElement:Expression expected
|
||||
<empty list>
|
||||
PsiErrorElement:<expression> expected, got '#'
|
||||
PsiElement(wrong token)('#')
|
||||
PsiElement(wrong token)('#')
|
||||
PsiElement(,)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
|
||||
+1
-1
@@ -16,6 +16,6 @@ Groovy script
|
||||
Parameter list
|
||||
<empty list>
|
||||
PsiElement(})('}')
|
||||
PsiErrorElement:',' or ']' expected
|
||||
PsiErrorElement:',' or ']' expected, got '}'
|
||||
<empty list>
|
||||
PsiElement(})('}')
|
||||
@@ -6,7 +6,7 @@ Groovy script
|
||||
Literal
|
||||
PsiElement(Gstring)('"abc"')
|
||||
PsiElement(,)(',')
|
||||
PsiErrorElement:Expression expected
|
||||
PsiErrorElement:<expression> expected, got ','
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(,)(',')
|
||||
|
||||
@@ -10,15 +10,10 @@ Groovy script
|
||||
Literal
|
||||
PsiElement(Integer)('3')
|
||||
PsiElement(,)(',')
|
||||
PsiErrorElement:Expression expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(wrong token)('#')
|
||||
PsiErrorElement:',' or ']' expected
|
||||
<empty list>
|
||||
PsiErrorElement:<expression> expected, got '#'
|
||||
PsiElement(wrong token)('#')
|
||||
PsiElement(:)(':')
|
||||
PsiErrorElement:',' or ']' expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
Literal
|
||||
PsiElement(Integer)('2')
|
||||
|
||||
@@ -250,5 +250,5 @@ Groovy script
|
||||
PsiElement(,)(',')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(])(']')
|
||||
PsiErrorElement:']' expected
|
||||
PsiErrorElement:',' or ']' expected
|
||||
<empty list>
|
||||
@@ -13,12 +13,11 @@ Groovy script
|
||||
PsiElement(])(']')
|
||||
Arguments
|
||||
PsiElement([)('[')
|
||||
PsiErrorElement:Expression expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement())(')')
|
||||
PsiErrorElement:<expression> or ']' expected, got ')'
|
||||
PsiElement())(')')
|
||||
PsiWhiteSpace(' ')
|
||||
Literal
|
||||
PsiElement(Integer)('3')
|
||||
PsiErrorElement:']' expected
|
||||
PsiErrorElement:',' or ']' expected
|
||||
<empty list>
|
||||
+1
-1
@@ -12,7 +12,7 @@ Groovy script
|
||||
PsiElement(()('(')
|
||||
builtin type class expression
|
||||
PsiElement(int)('int')
|
||||
PsiErrorElement:',' or ')' expected
|
||||
PsiErrorElement:')' or ',' expected, got 'a'
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
Reference expression
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ Groovy script
|
||||
PsiElement(()('(')
|
||||
Reference expression
|
||||
PsiElement(identifier)('Map')
|
||||
PsiErrorElement:',' or ')' expected
|
||||
PsiErrorElement:')' or ',' expected, got 'm'
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
Reference expression
|
||||
|
||||
@@ -36,11 +36,11 @@ Groovy script
|
||||
PsiElement(()('(')
|
||||
Literal
|
||||
PsiElement(Gstring)('""')
|
||||
PsiErrorElement:',' or ')' expected
|
||||
PsiErrorElement:')' or ',' expected, got 'aaa'
|
||||
<empty list>
|
||||
Reference expression
|
||||
PsiElement(identifier)('aaa')
|
||||
PsiErrorElement:',' or ')' expected
|
||||
PsiErrorElement:')' or ',' expected, got '"'
|
||||
<empty list>
|
||||
Compound Gstring
|
||||
PsiElement(Gstring begin)('"')
|
||||
@@ -49,7 +49,7 @@ Groovy script
|
||||
PsiErrorElement:Gstring end expected
|
||||
<empty list>
|
||||
PsiElement(new line)('\n ')
|
||||
PsiErrorElement:',' or ')' expected
|
||||
PsiErrorElement:')', ',' or <expression> expected, got '}'
|
||||
<empty list>
|
||||
PsiElement(})('}')
|
||||
PsiElement(new line)('\n\n ')
|
||||
|
||||
Reference in New Issue
Block a user