mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] allow new line before elvis operand (IDEA-195296)
This commit is contained in:
+12
-1
@@ -7291,11 +7291,22 @@ public class GroovyGeneratedParser implements PsiParser, LightPsiParser {
|
||||
return r;
|
||||
}
|
||||
|
||||
// '?:' mb_nl
|
||||
// mb_nl ('?:' mb_nl)
|
||||
private static boolean elvis_expression_0(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "elvis_expression_0")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = mb_nl(b, l + 1);
|
||||
r = r && elvis_expression_0_1(b, l + 1);
|
||||
exit_section_(b, m, null, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
// '?:' mb_nl
|
||||
private static boolean elvis_expression_0_1(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "elvis_expression_0_1")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = consumeTokenSmart(b, T_ELVIS);
|
||||
r = r && mb_nl(b, l + 1);
|
||||
exit_section_(b, m, null, r);
|
||||
|
||||
@@ -1076,7 +1076,7 @@ private conditionals ::= ternary_expression | elvis_expression
|
||||
ternary_expression ::= expression (ternary_tail_pin | ternary_tail)
|
||||
private ternary_tail_pin ::= '?' mb_nl !'[' expression mb_nl ':' mb_nl conditionals { pin = 3 consumeTokenMethod = 'consumeTokenFast' }
|
||||
private ternary_tail ::= '?' mb_nl expression mb_nl ':' mb_nl conditionals { pin = 5 consumeTokenMethod = 'consumeTokenFast' }
|
||||
elvis_expression ::= expression '?:' mb_nl expression
|
||||
elvis_expression ::= expression mb_nl ('?:' mb_nl) expression
|
||||
{
|
||||
rightAssociative = true
|
||||
}
|
||||
|
||||
+2
@@ -81,6 +81,8 @@ class ExpressionsParsingTest extends GroovyParsingTestCase {
|
||||
|
||||
void testconditional$elvis2() throws Throwable { doTest() }
|
||||
|
||||
void testconditional$elvisNlBeforeOperator() { doTest() }
|
||||
|
||||
void testconditional$ternaryQuestionOnly() { doTest() }
|
||||
|
||||
void testconditional$ternaryWithoutElse() { doTest() }
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
a
|
||||
?: b
|
||||
-----
|
||||
Groovy script
|
||||
Elvis expression
|
||||
Reference expression
|
||||
PsiElement(identifier)('a')
|
||||
PsiElement(new line)('\n')
|
||||
PsiElement(?:)('?:')
|
||||
PsiWhiteSpace(' ')
|
||||
Reference expression
|
||||
PsiElement(identifier)('b')
|
||||
Reference in New Issue
Block a user