mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-19061 Integrate the Rearranger-plugin into core-IDE
1. Making arrangement blank lines aware; 2. Refactoring;
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.psi.codeStyle.arrangement
|
||||
|
||||
import com.intellij.ide.highlighter.JavaFileType
|
||||
import com.intellij.lang.java.JavaLanguage
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
* @since 8/30/12 12:15 PM
|
||||
*/
|
||||
abstract class AbstractJavaRearrangerTest extends AbstractRearrangerTest {
|
||||
|
||||
AbstractJavaRearrangerTest() {
|
||||
fileType = JavaFileType.INSTANCE
|
||||
language = JavaLanguage.INSTANCE
|
||||
}
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.psi.codeStyle.arrangement
|
||||
|
||||
import static com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryType.*
|
||||
import static com.intellij.psi.codeStyle.arrangement.match.ArrangementModifier.PUBLIC
|
||||
import static com.intellij.psi.codeStyle.arrangement.match.ArrangementModifier.STATIC
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
* @since 8/30/12 12:14 PM
|
||||
*/
|
||||
public class JavaRearrangerBlankLinesTest extends AbstractJavaRearrangerTest {
|
||||
|
||||
void testPreserveRelativeBlankLines() {
|
||||
commonSettings.BLANK_LINES_AROUND_FIELD = 1
|
||||
commonSettings.BLANK_LINES_AROUND_METHOD = 2
|
||||
commonSettings.BLANK_LINES_AROUND_FIELD_IN_INTERFACE = 2
|
||||
commonSettings.BLANK_LINES_AROUND_METHOD_IN_INTERFACE = 3
|
||||
doTest(
|
||||
'''\
|
||||
class Test {
|
||||
private void method1() {}
|
||||
|
||||
public void method2() {}
|
||||
|
||||
private int i;
|
||||
|
||||
public int j;
|
||||
public static int k;
|
||||
}
|
||||
interface MyInterface {
|
||||
void test1();
|
||||
void test2();
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
}''',
|
||||
'''\
|
||||
interface MyInterface {
|
||||
int i = 0;
|
||||
|
||||
|
||||
int j = 0;
|
||||
|
||||
|
||||
|
||||
void test1();
|
||||
|
||||
|
||||
|
||||
void test2();
|
||||
}
|
||||
class Test {
|
||||
public static int k;
|
||||
public int j;
|
||||
private int i;
|
||||
|
||||
public void method2() {}
|
||||
|
||||
private void method1() {}
|
||||
}''',
|
||||
[rule(INTERFACE),
|
||||
rule(CLASS),
|
||||
rule(FIELD, STATIC),
|
||||
rule(FIELD, PUBLIC),
|
||||
rule(FIELD),
|
||||
rule(METHOD, PUBLIC),
|
||||
rule(METHOD)]
|
||||
)
|
||||
}
|
||||
}
|
||||
+12
-21
@@ -15,22 +15,13 @@
|
||||
*/
|
||||
package com.intellij.psi.codeStyle.arrangement
|
||||
|
||||
import com.intellij.ide.highlighter.JavaFileType
|
||||
import com.intellij.lang.java.JavaLanguage
|
||||
|
||||
import static com.intellij.psi.codeStyle.arrangement.ArrangementUtil.and
|
||||
import static com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryType.*
|
||||
import static com.intellij.psi.codeStyle.arrangement.match.ArrangementModifier.*
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
* @since 8/28/12 6:42 PM
|
||||
*/
|
||||
class JavaRearrangerByTypeAndModifierTest extends AbstractRearrangerTest {
|
||||
|
||||
JavaRearrangerByTypeAndModifierTest() {
|
||||
fileType = JavaFileType.INSTANCE
|
||||
language = JavaLanguage.INSTANCE
|
||||
}
|
||||
class JavaRearrangerByTypeAndModifierTest extends AbstractJavaRearrangerTest {
|
||||
|
||||
void testComplex() {
|
||||
doTest(
|
||||
@@ -62,17 +53,17 @@ class Test {
|
||||
public class PublicInner {}
|
||||
protected static class ProtectedStaticInner {}
|
||||
}''',
|
||||
[rule(and(atom(FIELD), atom(PUBLIC), atom(STATIC))),
|
||||
rule(and(atom(FIELD), atom(PUBLIC))),
|
||||
rule(and(atom(FIELD), atom(VOLATILE))),
|
||||
rule(and(atom(FIELD), atom(PRIVATE))),
|
||||
rule(and(atom(METHOD), atom(ABSTRACT))),
|
||||
rule(and(atom(METHOD), atom(PUBLIC))),
|
||||
rule(atom(METHOD)),
|
||||
rule(atom(INTERFACE)),
|
||||
rule(atom(ENUM)),
|
||||
rule(and(atom(CLASS), atom(PUBLIC))),
|
||||
rule(atom(CLASS))]
|
||||
[rule(FIELD, PUBLIC, STATIC),
|
||||
rule(FIELD, PUBLIC),
|
||||
rule(FIELD, VOLATILE),
|
||||
rule(FIELD, PRIVATE),
|
||||
rule(METHOD, ABSTRACT),
|
||||
rule(METHOD, PUBLIC),
|
||||
rule(METHOD),
|
||||
rule(INTERFACE),
|
||||
rule(ENUM),
|
||||
rule(CLASS, PUBLIC),
|
||||
rule(CLASS)]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+9
-16
@@ -15,19 +15,12 @@
|
||||
*/
|
||||
package com.intellij.psi.codeStyle.arrangement
|
||||
|
||||
import com.intellij.ide.highlighter.JavaFileType
|
||||
import com.intellij.lang.java.JavaLanguage
|
||||
import com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryType
|
||||
import static com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryType.*
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
* @since 7/20/12 2:45 PM
|
||||
*/
|
||||
class JavaRearrangerByTypeTest extends AbstractRearrangerTest {
|
||||
|
||||
JavaRearrangerByTypeTest() {
|
||||
fileType = JavaFileType.INSTANCE
|
||||
language = JavaLanguage.INSTANCE
|
||||
}
|
||||
class JavaRearrangerByTypeTest extends AbstractJavaRearrangerTest {
|
||||
|
||||
void testFieldsBeforeMethods() {
|
||||
doTest(
|
||||
@@ -53,7 +46,7 @@ class Test2 {
|
||||
public void test() {
|
||||
}
|
||||
}''',
|
||||
[rule(atom(ArrangementEntryType.FIELD))]
|
||||
[rule(FIELD)]
|
||||
)
|
||||
}
|
||||
|
||||
@@ -97,7 +90,7 @@ class Test {
|
||||
return null;
|
||||
}
|
||||
}''',
|
||||
[rule(atom(ArrangementEntryType.FIELD))]
|
||||
[rule(FIELD)]
|
||||
)
|
||||
}
|
||||
|
||||
@@ -135,7 +128,7 @@ class Test {
|
||||
});
|
||||
}
|
||||
}''',
|
||||
[rule(atom(ArrangementEntryType.FIELD))]
|
||||
[rule(FIELD)]
|
||||
)
|
||||
}
|
||||
|
||||
@@ -153,9 +146,9 @@ class Test {
|
||||
enum E { ONE, TWO }
|
||||
class Inner {}
|
||||
}''',
|
||||
[rule(atom(ArrangementEntryType.INTERFACE)),
|
||||
rule(atom(ArrangementEntryType.ENUM)),
|
||||
rule(atom(ArrangementEntryType.CLASS))]
|
||||
[rule(INTERFACE),
|
||||
rule(ENUM),
|
||||
rule(CLASS)]
|
||||
)
|
||||
}
|
||||
|
||||
@@ -193,7 +186,7 @@ class Test {
|
||||
});
|
||||
}
|
||||
}''',
|
||||
[rule(atom(ArrangementEntryType.FIELD))]
|
||||
[rule(FIELD)]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user