mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-19061 Integrate the Rearranger-plugin into core-IDEA
Arrangement is blank lines aware now
This commit is contained in:
@@ -133,7 +133,7 @@ public class JavaRearranger implements Rearranger<JavaElementArrangementEntry>,
|
||||
@NotNull JavaElementArrangementEntry target)
|
||||
{
|
||||
if (previous == null) {
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
CommonCodeStyleSettings commonSettings = settings.getCommonSettings(JavaLanguage.INSTANCE);
|
||||
@@ -152,7 +152,7 @@ public class JavaRearranger implements Rearranger<JavaElementArrangementEntry>,
|
||||
else {
|
||||
return commonSettings.BLANK_LINES_AROUND_METHOD;
|
||||
}
|
||||
default: return 0;
|
||||
default: return commonSettings.BLANK_LINES_AROUND_CLASS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-3
@@ -25,6 +25,7 @@ import static com.intellij.psi.codeStyle.arrangement.match.ArrangementModifier.S
|
||||
public class JavaRearrangerBlankLinesTest extends AbstractJavaRearrangerTest {
|
||||
|
||||
void testPreserveRelativeBlankLines() {
|
||||
commonSettings.BLANK_LINES_AROUND_CLASS = 2
|
||||
commonSettings.BLANK_LINES_AROUND_FIELD = 1
|
||||
commonSettings.BLANK_LINES_AROUND_METHOD = 2
|
||||
commonSettings.BLANK_LINES_AROUND_FIELD_IN_INTERFACE = 2
|
||||
@@ -33,11 +34,11 @@ public class JavaRearrangerBlankLinesTest extends AbstractJavaRearrangerTest {
|
||||
'''\
|
||||
class Test {
|
||||
private void method1() {}
|
||||
|
||||
|
||||
public void method2() {}
|
||||
|
||||
private int i;
|
||||
|
||||
|
||||
public int j;
|
||||
public static int k;
|
||||
}
|
||||
@@ -62,13 +63,19 @@ interface MyInterface {
|
||||
|
||||
void test2();
|
||||
}
|
||||
|
||||
|
||||
class Test {
|
||||
public static int k;
|
||||
|
||||
public int j;
|
||||
|
||||
private int i;
|
||||
|
||||
|
||||
|
||||
public void method2() {}
|
||||
|
||||
|
||||
private void method1() {}
|
||||
}''',
|
||||
[rule(INTERFACE),
|
||||
|
||||
+3
@@ -24,6 +24,9 @@ import static com.intellij.psi.codeStyle.arrangement.match.ArrangementModifier.*
|
||||
class JavaRearrangerByTypeAndModifierTest extends AbstractJavaRearrangerTest {
|
||||
|
||||
void testComplex() {
|
||||
commonSettings.BLANK_LINES_AROUND_METHOD = 0
|
||||
commonSettings.BLANK_LINES_AROUND_CLASS = 0
|
||||
|
||||
doTest(
|
||||
'''\
|
||||
class Test {
|
||||
|
||||
+9
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.psi.codeStyle.arrangement
|
||||
|
||||
import org.junit.Before
|
||||
|
||||
import static com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryType.*
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
@@ -22,6 +24,13 @@ import static com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryType.
|
||||
*/
|
||||
class JavaRearrangerByTypeTest extends AbstractJavaRearrangerTest {
|
||||
|
||||
@Before
|
||||
void setUp() {
|
||||
super.setUp()
|
||||
commonSettings.BLANK_LINES_AROUND_METHOD = 0
|
||||
commonSettings.BLANK_LINES_AROUND_CLASS = 0
|
||||
}
|
||||
|
||||
void testFieldsBeforeMethods() {
|
||||
doTest(
|
||||
'''\
|
||||
|
||||
Reference in New Issue
Block a user