mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-75064 keep control statements in one line
This commit is contained in:
+4
-2
@@ -302,8 +302,7 @@ public class GroovySpacingProcessor extends GroovyElementVisitor {
|
||||
public void visitOpenBlock(GrOpenBlock block) {
|
||||
|
||||
final PsiElement parent = block.getParent();
|
||||
boolean keepInOneLine = parent instanceof GrMethod ?
|
||||
mySettings.KEEP_SIMPLE_METHODS_IN_ONE_LINE :
|
||||
boolean keepInOneLine = parent instanceof GrMethod ? mySettings.KEEP_SIMPLE_METHODS_IN_ONE_LINE :
|
||||
mySettings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE;
|
||||
|
||||
if (myType1 == mLCURLY && myType2 == mRCURLY) {
|
||||
@@ -717,6 +716,9 @@ public class GroovySpacingProcessor extends GroovyElementVisitor {
|
||||
myResult = Spacing.createSpacing(0, 0, 1, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
|
||||
}
|
||||
}
|
||||
else if (myType1 == mRPAREN) {
|
||||
createSpacingBeforeElementInsideControlStatement();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isOpenBlock(IElementType type) {
|
||||
|
||||
@@ -306,6 +306,46 @@ if (abc) {return 2}
|
||||
if (abc) {
|
||||
return 2
|
||||
}
|
||||
''')
|
||||
}
|
||||
|
||||
void testControlStatementsInOneLine() {
|
||||
groovySettings.KEEP_CONTROL_STATEMENT_IN_ONE_LINE = true
|
||||
checkFormatting('''\
|
||||
if (abc) return 2
|
||||
''', '''\
|
||||
if (abc) return 2
|
||||
''')
|
||||
checkFormatting('''\
|
||||
while (abc) return 2
|
||||
''', '''\
|
||||
while (abc) return 2
|
||||
''')
|
||||
checkFormatting('''\
|
||||
for (abc) return 2
|
||||
''', '''\
|
||||
for (abc) return 2
|
||||
''')
|
||||
|
||||
groovySettings.KEEP_CONTROL_STATEMENT_IN_ONE_LINE = false
|
||||
checkFormatting('''\
|
||||
if (abc) return 2
|
||||
''', '''\
|
||||
if (abc)
|
||||
return 2
|
||||
''')
|
||||
checkFormatting('''\
|
||||
while (abc) return 2
|
||||
''', '''\
|
||||
while (abc)
|
||||
return 2
|
||||
''')
|
||||
|
||||
checkFormatting('''\
|
||||
for (;abc;) return 2
|
||||
''', '''\
|
||||
for (; abc;)
|
||||
return 2
|
||||
''')
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user