mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-10 13:17:09 +07:00
Supported "initializer block" arrangement entry (IDEA-95115)
Previous behaviour was to treat initializer block as field and stick it with previous field, now it's eliminated with matching and rearranging according to matching rules. See comments also in [CR-IC-6618]
This commit is contained in:
+4
-2
@@ -83,9 +83,10 @@ class Test {
|
||||
expected: '''\
|
||||
class Test {
|
||||
public int j;
|
||||
{ j = 1; }
|
||||
protected int k;
|
||||
private int i;
|
||||
|
||||
{ j = 1; }
|
||||
}''',
|
||||
rules: [rule(FIELD, PUBLIC), rule(FIELD, PROTECTED), rule(FIELD, PRIVATE)])
|
||||
}
|
||||
@@ -101,10 +102,11 @@ class Test {
|
||||
}''',
|
||||
expected: '''\
|
||||
class Test {
|
||||
{ j = 1; }
|
||||
public int j;
|
||||
protected int k;
|
||||
private int i;
|
||||
|
||||
{ j = 1; }
|
||||
}''',
|
||||
rules: [rule(FIELD, PUBLIC), rule(FIELD, PROTECTED), rule(FIELD, PRIVATE)])
|
||||
}
|
||||
|
||||
+81
@@ -569,4 +569,85 @@ class B extends A {
|
||||
rules: [rule(PUBLIC, METHOD), rule(PRIVATE, METHOD)]
|
||||
)
|
||||
}
|
||||
|
||||
void "test initializer block after fields"() {
|
||||
doTest(
|
||||
initial: '''\
|
||||
public class NewOneClass {
|
||||
|
||||
{
|
||||
a = 1;
|
||||
}
|
||||
|
||||
int a;
|
||||
|
||||
{
|
||||
b = 5;
|
||||
}
|
||||
|
||||
int b;
|
||||
|
||||
}
|
||||
''',
|
||||
expected: '''\
|
||||
public class NewOneClass {
|
||||
|
||||
int a;
|
||||
int b;
|
||||
|
||||
{
|
||||
a = 1;
|
||||
}
|
||||
|
||||
{
|
||||
b = 5;
|
||||
}
|
||||
|
||||
}
|
||||
''',
|
||||
rules: [rule(FIELD), rule(INIT_BLOCK)]
|
||||
)
|
||||
}
|
||||
|
||||
void "test static initializer block"() {
|
||||
doTest(
|
||||
initial: '''\
|
||||
public class NewOneClass {
|
||||
|
||||
static {
|
||||
a = 1;
|
||||
}
|
||||
|
||||
static int a;
|
||||
|
||||
{
|
||||
b = 5;
|
||||
}
|
||||
|
||||
int b;
|
||||
|
||||
}
|
||||
''',
|
||||
expected: '''\
|
||||
public class NewOneClass {
|
||||
|
||||
static int a;
|
||||
|
||||
static {
|
||||
a = 1;
|
||||
}
|
||||
|
||||
int b;
|
||||
|
||||
{
|
||||
b = 5;
|
||||
}
|
||||
|
||||
}
|
||||
''',
|
||||
rules: [rule(STATIC, FIELD), rule(STATIC, INIT_BLOCK), rule(FIELD), rule(INIT_BLOCK)]
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ public class JavaFormatterBlankLinesTest extends AbstractJavaFormatterTest {
|
||||
|
||||
public void testBlankLinesAroundClassInitializationBlock() throws Exception {
|
||||
getSettings().BLANK_LINES_AROUND_METHOD = 3;
|
||||
getJavaSettings().BLANK_LINES_AROUND_INITIALIZER = 3;
|
||||
doTextTest(
|
||||
"class T {\n" +
|
||||
" private final DecimalFormat fmt = new DecimalFormat();\n" +
|
||||
|
||||
Reference in New Issue
Block a user