mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-97826 Java arrangement: Don't insert unnecessary line feeds for anonymous classes
This commit is contained in:
+3
-1
@@ -87,7 +87,9 @@ public class JavaArrangementVisitor extends JavaElementVisitor {
|
||||
|
||||
@Override
|
||||
public void visitAnonymousClass(PsiAnonymousClass aClass) {
|
||||
JavaElementArrangementEntry entry = createNewEntry(aClass, aClass.getTextRange(), ArrangementEntryType.CLASS, aClass.getName(), false);
|
||||
JavaElementArrangementEntry entry = createNewEntry(
|
||||
aClass, aClass.getTextRange(), ArrangementEntryType.ANONYMOUS_CLASS, aClass.getName(), false
|
||||
);
|
||||
processEntry(entry, null, aClass);
|
||||
}
|
||||
|
||||
|
||||
@@ -317,8 +317,8 @@ public class JavaRearranger implements Rearranger<JavaElementArrangementEntry>,
|
||||
else {
|
||||
return commonSettings.BLANK_LINES_AROUND_METHOD;
|
||||
}
|
||||
default:
|
||||
return commonSettings.BLANK_LINES_AROUND_CLASS;
|
||||
case CLASS: return commonSettings.BLANK_LINES_AROUND_CLASS;
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
@@ -118,4 +118,16 @@ class Test {
|
||||
rules: [rule(FIELD, PACKAGE_PRIVATE), rule(METHOD)]
|
||||
)
|
||||
}
|
||||
|
||||
void "test blank lines settings are not applied to anonymous classes"() {
|
||||
commonSettings.BLANK_LINES_AROUND_CLASS = 1
|
||||
def text = '''\
|
||||
class Test {
|
||||
void test() {
|
||||
a(new Intf() {});
|
||||
a(new Intf() {});
|
||||
}
|
||||
}'''
|
||||
doTest(initial: text, expected: text, rules: [rule(CLASS)] )
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ import com.intellij.psi.codeStyle.arrangement.ArrangementEntry;
|
||||
*/
|
||||
public enum ArrangementEntryType {
|
||||
|
||||
CLASS, FIELD, CONSTRUCTOR, METHOD, ENUM, INTERFACE,
|
||||
CLASS, ANONYMOUS_CLASS, FIELD, CONSTRUCTOR, METHOD, ENUM, INTERFACE,
|
||||
|
||||
CONST, VAR, PROPERTY, EVENT_HANDLER, STATIC_INIT
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user