mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-72321 Java Formatter: Respect 'space before method call parentheses' for anonymous class constructor
This commit is contained in:
@@ -241,7 +241,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
}
|
||||
else if (aClass instanceof PsiAnonymousClass && ElementType.JAVA_PLAIN_COMMENT_BIT_SET.contains(myChild1.getElementType())) {
|
||||
ASTNode prev = myChild1.getTreePrev();
|
||||
if (prev.getElementType() == JavaTokenType.WHITE_SPACE && !StringUtil.containsLineBreak(prev.getChars())) {
|
||||
if (prev.getElementType() == TokenType.WHITE_SPACE && !StringUtil.containsLineBreak(prev.getChars())) {
|
||||
prev = prev.getTreePrev();
|
||||
}
|
||||
if (prev.getElementType() == JavaTokenType.LBRACE) {
|
||||
@@ -252,7 +252,12 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
processClassBody();
|
||||
}
|
||||
}
|
||||
else processClassBody();
|
||||
else if (aClass instanceof PsiAnonymousClass && myRole2 == ChildRole.ARGUMENT_LIST) {
|
||||
createSpaceInCode(mySettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES);
|
||||
}
|
||||
else {
|
||||
processClassBody();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isTheOnlyClassMember(final ASTNode node) {
|
||||
|
||||
@@ -366,4 +366,20 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
|
||||
"foo(1,2,3);"
|
||||
);
|
||||
}
|
||||
|
||||
public void testBeforeAnonymousClassConstructor() throws Exception {
|
||||
// Inspired by IDEA-72321.
|
||||
getSettings().SPACE_BEFORE_METHOD_CALL_PARENTHESES = true;
|
||||
|
||||
doMethodTest(
|
||||
"actions.add(new Action(this) {\n" +
|
||||
" public void run() {\n" +
|
||||
" }\n" +
|
||||
"});",
|
||||
"actions.add (new Action (this) {\n" +
|
||||
" public void run() {\n" +
|
||||
" }\n" +
|
||||
"});"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user