mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Do not indent control structures parentheses
Fixes: IDEA-98552 for() statement: Place ')' on new line → "incorrect" alignment IDEA-175560 Right parenthesis (rparen) on new line is not indented properly
This commit is contained in:
@@ -182,6 +182,9 @@ public class BlockContainingJavaBlock extends AbstractJavaBlock{
|
||||
|| child.getElementType() == JavaElementType.TYPE_PARAMETER_LIST)) {
|
||||
return Indent.getNoneIndent();
|
||||
}
|
||||
else if (child.getElementType() == JavaTokenType.LPARENTH || child.getElementType() == JavaTokenType.RPARENTH) {
|
||||
return Indent.getNoneIndent();
|
||||
}
|
||||
else {
|
||||
return Indent.getContinuationIndent(myIndentSettings.USE_RELATIVE_INDENTS);
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.List;
|
||||
class Test {
|
||||
void test(List<String> list, String key) {
|
||||
if(key !=/*nullcheck*/ null && !key./*check*/isEmpty() /*and*/ /*key*/ //line comment
|
||||
) {
|
||||
) {
|
||||
list.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public class Foo {
|
||||
int thisShouldBeWrapped = 0;
|
||||
thisShouldBeWrapped < 10;
|
||||
thisShouldBeWrapped++
|
||||
) {
|
||||
) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ public class Foo {
|
||||
for (int thisShouldBeWrapped = 0;
|
||||
thisShouldBeWrapped < 10;
|
||||
thisShouldBeWrapped++
|
||||
) {
|
||||
) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3442,4 +3442,67 @@ class JavaFormatterTest : AbstractJavaFormatterTest() {
|
||||
"}"
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* See IDEA-98552, IDEA-175560
|
||||
*/
|
||||
fun testParenthesesIndentation() {
|
||||
doTextTest(
|
||||
"""
|
||||
package com.company;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
class Test {
|
||||
|
||||
void foo(boolean bool1, boolean bool2) {
|
||||
List<String> list = Arrays.asList(
|
||||
"a", "b", "c"
|
||||
);
|
||||
// IDEA-98552
|
||||
for (
|
||||
String s : list
|
||||
) {
|
||||
System.out.println(s);
|
||||
}
|
||||
// IDEA-175560
|
||||
if (bool1
|
||||
&& bool2
|
||||
) { // Indented at continuation indent level
|
||||
// do stuff
|
||||
}
|
||||
}
|
||||
}
|
||||
""",
|
||||
|
||||
"""
|
||||
package com.company;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
class Test {
|
||||
|
||||
void foo(boolean bool1, boolean bool2) {
|
||||
List<String> list = Arrays.asList(
|
||||
"a", "b", "c"
|
||||
);
|
||||
// IDEA-98552
|
||||
for (
|
||||
String s : list
|
||||
) {
|
||||
System.out.println(s);
|
||||
}
|
||||
// IDEA-175560
|
||||
if (bool1
|
||||
&& bool2
|
||||
) { // Indented at continuation indent level
|
||||
// do stuff
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user