mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] parse new line before catch block (IDEA-196301)
This commit is contained in:
+13
-2
@@ -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) {
|
||||
|
||||
@@ -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 | <<newLine>>
|
||||
|
||||
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 ::= <<parseTailLeftFlat catch_parameter_start catch_parameter>>
|
||||
private catch_parameter_start ::= modifier_list catch_parameter_type_element?
|
||||
private catch_parameter_type_element ::= type_element_followed_by_identifier
|
||||
|
||||
+2
@@ -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() }
|
||||
|
||||
+24
@@ -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
|
||||
<empty list>
|
||||
PsiElement(identifier)('e')
|
||||
PsiElement())(')')
|
||||
PsiElement(new line)('\n')
|
||||
Open block
|
||||
PsiElement({)('{')
|
||||
PsiElement(})('}')
|
||||
Reference in New Issue
Block a user