diff --git a/plugins/groovy/groovy-psi/gen/org/jetbrains/plugins/groovy/lang/parser/GroovyGeneratedParser.java b/plugins/groovy/groovy-psi/gen/org/jetbrains/plugins/groovy/lang/parser/GroovyGeneratedParser.java index 9a2ac962a19d..23c44e0a7635 100644 --- a/plugins/groovy/groovy-psi/gen/org/jetbrains/plugins/groovy/lang/parser/GroovyGeneratedParser.java +++ b/plugins/groovy/groovy-psi/gen/org/jetbrains/plugins/groovy/lang/parser/GroovyGeneratedParser.java @@ -7764,7 +7764,7 @@ public class GroovyGeneratedParser implements PsiParser, LightPsiParser { r = true; exit_section_(b, l, m, PROPERTY_EXPRESSION, r, true, null); } - else if (g < 17 && method_call_expression_0(b, l + 1)) { + else if (g < 17 && callTail(b, l + 1, GroovyGeneratedParser::call_tail_with_nl_before_closure, GroovyGeneratedParser::call_tail)) { r = true; exit_section_(b, l, m, METHOD_CALL_EXPRESSION, r, true, null); } @@ -8429,28 +8429,6 @@ public class GroovyGeneratedParser implements PsiParser, LightPsiParser { return true; } - // <> call_tail_with_nl_before_closure | call_tail - private static boolean method_call_expression_0(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "method_call_expression_0")) return false; - boolean r; - Marker m = enter_section_(b); - r = method_call_expression_0_0(b, l + 1); - if (!r) r = call_tail(b, l + 1); - exit_section_(b, m, null, r); - return r; - } - - // <> call_tail_with_nl_before_closure - private static boolean method_call_expression_0_0(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "method_call_expression_0_0")) return false; - boolean r; - Marker m = enter_section_(b); - r = isParseNlBeforeClosure(b, l + 1); - r = r && call_tail_with_nl_before_closure(b, l + 1); - exit_section_(b, m, null, r); - return r; - } - // <> public static boolean lazy_closure(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "lazy_closure")) return false; 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 66b813037a88..3824b9c4c908 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 @@ -962,7 +962,7 @@ private optional_expression ::= non_empty_annotation_list? '[' expression? ']' { private priority1_2 ::= method_call_expression | lazy_closure | lambda_expression | single_parameter_lambda_expression | list_or_map constructor_call_expression ::= &('this' | 'super') unqualified_reference_expression call_tail -method_call_expression ::= expression (<> call_tail_with_nl_before_closure | call_tail) +method_call_expression ::= expression <> private call_tail ::= call_argument_list lazy_closure* | empty_argument_list lazy_closure+ private call_tail_with_nl_before_closure ::= call_argument_list (mb_nl lazy_closure)* | empty_argument_list (mb_nl lazy_closure)+ diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/parserUtils.kt b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/parserUtils.kt index 58a42c57a959..d268972fef9a 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/parserUtils.kt +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/parserUtils.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2019 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-2020 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. @file:JvmName("GroovyParserUtils") @file:Suppress("UNUSED_PARAMETER", "LiftReturnOrAssignment") @@ -207,8 +207,13 @@ fun disableNlBeforeClosure(builder: PsiBuilder, level: Int): Boolean { return true } -fun isParseNlBeforeClosure(builder: PsiBuilder, level: Int): Boolean { - return builder.latestDoneMarker?.tokenType == NEW_EXPRESSION || builder[parseNlBeforeClosureArgument] +fun callTail(builder: PsiBuilder, level: Int, withNl: Parser, withoutNl: Parser): Boolean { + if (builder.latestDoneMarker?.tokenType == NEW_EXPRESSION || builder[parseNlBeforeClosureArgument]) { + return withNl.parse(builder, level) + } + else { + return withoutNl.parse(builder, level) + } } fun parseArgument(builder: PsiBuilder, level: Int, argumentParser: Parser): Boolean {