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 2ccc2fde400b..78844f58004b 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 @@ -1916,7 +1916,7 @@ public class GroovyGeneratedParser implements PsiParser, LightPsiParser { } /* ********************************************************** */ - // 'catch' '(' parse_catch_parameter ')' lazy_block + // 'catch' '(' parse_catch_parameter ')' (mb_nl lazy_block) public static boolean catch_clause(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "catch_clause")) return false; if (!nextTokenIs(b, KW_CATCH)) return false; @@ -1926,11 +1926,22 @@ public class GroovyGeneratedParser implements PsiParser, LightPsiParser { p = r; // pin = 1 r = r && report_error_(b, parse_catch_parameter(b, l + 1)); r = p && report_error_(b, consumeToken(b, T_RPAREN)) && r; - r = p && lazy_block(b, l + 1) && r; + r = p && catch_clause_4(b, l + 1) && r; exit_section_(b, l, m, r, p, null); return r || p; } + // mb_nl lazy_block + private static boolean catch_clause_4(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "catch_clause_4")) return false; + boolean r; + Marker m = enter_section_(b); + r = mb_nl(b, l + 1); + r = r && lazy_block(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + /* ********************************************************** */ // IDENTIFIER public static boolean catch_parameter(PsiBuilder b, int l) { 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 879a35bb1219..96c11d6baa5a 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 @@ -728,7 +728,7 @@ try_resource_list ::= '(' try_resource_list_item+ ')' { pin = 1 } private try_resource_list_item ::= local_variable_declaration try_resource_list_separator { pin = 1 } private try_resource_list_separator ::= &')' | separators | <> -catch_clause ::= 'catch' '(' parse_catch_parameter ')' lazy_block { pin = 1 } +catch_clause ::= 'catch' '(' parse_catch_parameter ')' (mb_nl lazy_block) { pin = 1 } private parse_catch_parameter ::= <> private catch_parameter_start ::= modifier_list catch_parameter_type_element? private catch_parameter_type_element ::= type_element_followed_by_identifier diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/StatementsParsingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/StatementsParsingTest.groovy index cf63bc075b1a..4c5f1be24985 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/StatementsParsingTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/StatementsParsingTest.groovy @@ -307,6 +307,8 @@ class StatementsParsingTest extends GroovyParsingTestCase { void testTry_catch$try7() throws Throwable { doTest() } + void testTry_catch$newLineBeforeCatchBlock() throws Throwable { doTest() } + void testTry_catch$tryResources() { doTest() } void testTry_catch$tryResourcesEmpty() { doTest() } diff --git a/plugins/groovy/testdata/parsing/groovy/statements/try_catch/newLineBeforeCatchBlock.test b/plugins/groovy/testdata/parsing/groovy/statements/try_catch/newLineBeforeCatchBlock.test new file mode 100644 index 000000000000..29d3c9aaffa4 --- /dev/null +++ b/plugins/groovy/testdata/parsing/groovy/statements/try_catch/newLineBeforeCatchBlock.test @@ -0,0 +1,24 @@ +try {} catch (e) +{} +----- +Groovy script + Try statement + PsiElement(try)('try') + PsiWhiteSpace(' ') + Open block + PsiElement({)('{') + PsiElement(})('}') + PsiWhiteSpace(' ') + Catch clause + PsiElement(catch)('catch') + PsiWhiteSpace(' ') + PsiElement(()('(') + Parameter + Modifiers + + PsiElement(identifier)('e') + PsiElement())(')') + PsiElement(new line)('\n') + Open block + PsiElement({)('{') + PsiElement(})('}') \ No newline at end of file