mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
align conditional expression
This commit is contained in:
@@ -289,6 +289,18 @@ public class GroovyBlockGenerator implements GroovyElementTypes {
|
||||
}
|
||||
}
|
||||
|
||||
else if (blockPsi instanceof GrConditionalExpression) {
|
||||
if (mySettings.ALIGN_MULTILINE_TERNARY_OPERATION) {
|
||||
final GrConditionalExpression conditional = (GrConditionalExpression)blockPsi;
|
||||
|
||||
final AlignmentProvider.Aligner aligner = myAlignmentProvider.createAligner(false);
|
||||
aligner.append(conditional.getCondition());
|
||||
if (!(conditional instanceof GrElvisExpression)) {
|
||||
aligner.append(conditional.getThenBranch());
|
||||
}
|
||||
aligner.append(conditional.getElseBranch());
|
||||
}
|
||||
}
|
||||
|
||||
// For other cases
|
||||
final ArrayList<Block> subBlocks = new ArrayList<Block>();
|
||||
|
||||
@@ -694,6 +694,30 @@ for (int i = 3;
|
||||
}
|
||||
|
||||
|
||||
void testConditional0() {
|
||||
groovySettings.ALIGN_MULTILINE_TERNARY_OPERATION = true
|
||||
checkFormatting '''\
|
||||
print abc ?
|
||||
cde:
|
||||
xyz
|
||||
''', '''\
|
||||
print abc ?
|
||||
cde :
|
||||
xyz
|
||||
'''
|
||||
}
|
||||
|
||||
void testConditional1() {
|
||||
groovySettings.ALIGN_MULTILINE_TERNARY_OPERATION = true
|
||||
checkFormatting '''\
|
||||
print abc ?:
|
||||
xyz
|
||||
''', '''\
|
||||
print abc ?:
|
||||
xyz
|
||||
'''
|
||||
}
|
||||
|
||||
private void doGeeseTest() {
|
||||
GroovyCodeStyleSettings customSettings = myTempSettings.getCustomSettings(GroovyCodeStyleSettings.class);
|
||||
boolean oldvalue = customSettings.USE_FLYING_GEESE_BRACES;
|
||||
|
||||
Reference in New Issue
Block a user