diff options
author | Mateusz Matela | 2019-08-18 21:09:51 +0000 |
---|---|---|
committer | Mateusz Matela | 2019-08-18 21:18:38 +0000 |
commit | b7cb75ad308cdfd0a16f029d800d9cc0a3c5246e (patch) | |
tree | 1204b27b8ba2a798519beeab6d98a2f7d64aeedb /org.eclipse.jdt.core.tests.model | |
parent | 8ec6a672dc17ba336bebe0f69f57be0365408647 (diff) | |
download | eclipse.jdt.core-b7cb75ad308cdfd0a16f029d800d9cc0a3c5246e.tar.gz eclipse.jdt.core-b7cb75ad308cdfd0a16f029d800d9cc0a3c5246e.tar.xz eclipse.jdt.core-b7cb75ad308cdfd0a16f029d800d9cc0a3c5246e.zip |
Bug 413193 - [formatter] Blank lines before first declaration and
declarations of same kind not respected in enums
Change-Id: Ib6d8219b13a54165d073dc573ec684d9c0e53f3f
Signed-off-by: Mateusz Matela <mateusz.matela@gmail.com>
Diffstat (limited to 'org.eclipse.jdt.core.tests.model')
14 files changed, 93 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java index ff4c5f1915..305d9b3b01 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java @@ -11324,6 +11324,7 @@ public void testBug474918() { "\r\n" + " private enum E {\r\n" + " AAA, BBB;\r\n" + + "\r\n" + " int a = 55;\r\n" + " String sssss = \"ssssss\";\r\n" + " }\r\n" + @@ -11390,6 +11391,7 @@ public void testBug474918b() { "\r\n" + " private enum E {\r\n" + " AAA, BBB;\r\n" + + "\r\n" + " int a = 55;\r\n" + " String sssss = \"ssssss\";\r\n" + " }\r\n" + @@ -11456,6 +11458,7 @@ public void testBug474918c() { "\r\n" + " private enum E {\r\n" + " AAA, BBB;\r\n" + + "\r\n" + " int a = 55;\r\n" + " String sssss = \"ssssss\";\r\n" + " }\r\n" + @@ -12592,6 +12595,7 @@ public void testBug500096a() { String source = "public enum Test {\n" + "AAA, BBB;\n" + + "\n" + "Test() {\n" + "}\n" + "}"; @@ -12606,6 +12610,7 @@ public void testBug500096b() { String source = "public enum Test {\n" + " AAA, BBB;\n" + + "\n" + "Test() {\n" + "}\n" + "}"; @@ -12956,4 +12961,65 @@ public void testBug543780() { "}"; formatSource(source); } +/** + * https://bugs.eclipse.org/413193 - [formatter] Blank lines before the first declarations and declarations of same kind not respected in enums + */ +public void testBug413193a() { + this.formatterPrefs.blank_lines_before_first_class_body_declaration = 2; + this.formatterPrefs.blank_lines_after_last_class_body_declaration = 3; + this.formatterPrefs.blank_lines_before_new_chunk = 4; + formatSource( + "public enum TestEnum {\n" + + "\n" + + "\n" + + " ONE, TWO, THREE;\n" + + "\n" + + "\n" + + "\n" + + "\n" + + " public int foo() {\n" + + " return 0;\n" + + " }\n" + + "\n" + + "\n" + + "\n" + + "}"); +} +/** + * https://bugs.eclipse.org/413193 - [formatter] Blank lines before the first declarations and declarations of same kind not respected in enums + */ +public void testBug413193b() { + this.formatterPrefs.blank_lines_before_first_class_body_declaration = 2; + this.formatterPrefs.blank_lines_after_last_class_body_declaration = 3; + this.formatterPrefs.blank_lines_before_new_chunk = 4; + formatSource( + "public enum TestEnum {\n" + + " ONE, TWO, THREE;\n" + + "}"); +} +/** + * https://bugs.eclipse.org/413193 - [formatter] Blank lines before the first declarations and declarations of same kind not respected in enums + */ +public void testBug413193c() { + this.formatterPrefs.blank_lines_before_first_class_body_declaration = ~0; + this.formatterPrefs.blank_lines_after_last_class_body_declaration = ~0; + this.formatterPrefs.blank_lines_before_new_chunk = ~0; + String source = + "public enum TestEnum {\n" + + "\n" + + " ONE, TWO, THREE;\n" + + "\n" + + " public int foo() {\n" + + " return 0;\n" + + " }\n" + + "\n" + + "}"; + formatSource(source, + "public enum TestEnum {\n" + + " ONE, TWO, THREE;\n" + + " public int foo() {\n" + + " return 0;\n" + + " }\n" + + "}"); +} } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java index 266b0ee01f..71ad555547 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java @@ -10947,6 +10947,7 @@ public void test730() { "enum Fail1 {\n" + " A;\n" + " ;\n" + + "\n" + " {\n" + " }\n" + "}" @@ -10963,6 +10964,7 @@ public void test731() { "enum Fail2 {\n" + " A, B;\n" + " ;\n" + + "\n" + " {\n" + " }\n" + "}" @@ -10979,6 +10981,7 @@ public void test732() { "enum Fail3 {\n" + " A;\n" + " ;\n" + + "\n" + " public void foo() {\n" + " }\n" + "}" @@ -10995,6 +10998,7 @@ public void test733() { "enum Fail4 {\n" + " A;\n" + " ;\n" + + "\n" + " public int i = 0;\n" + "}" ); @@ -15086,6 +15090,7 @@ public void testBug522089a() throws JavaModelException { setComplianceLevel(CompilerOptions.VERSION_1_8); this.formatterPrefs.number_of_empty_lines_to_preserve = 3; this.formatterPrefs.blank_lines_at_end_of_method_body = 2; + this.formatterPrefs.blank_lines_before_new_chunk = 0; String input = getCompilationUnit("Formatter", "", "test522089", "in.java").getSource(); formatSource(input, getCompilationUnit("Formatter", "", "test522089", "A_out.java").getSource()); } @@ -15096,6 +15101,7 @@ public void testBug522089b() throws JavaModelException { setComplianceLevel(CompilerOptions.VERSION_1_8); this.formatterPrefs.number_of_empty_lines_to_preserve = 3; this.formatterPrefs.blank_lines_at_end_of_method_body = ~0; + this.formatterPrefs.blank_lines_before_new_chunk = 0; String input = getCompilationUnit("Formatter", "", "test522089", "in.java").getSource(); formatSource(input, getCompilationUnit("Formatter", "", "test522089", "B_out.java").getSource()); } diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test169131/B_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test169131/B_out.java index 9f2fe319ed..641d726a05 100644 --- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test169131/B_out.java +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test169131/B_out.java @@ -70,6 +70,8 @@ class C5b { enum Enum { A, B; + + } enum Enum2 { diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/A_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/A_out.java index 89aa366a81..dac90dcbdd 100644 --- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/A_out.java +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/A_out.java @@ -123,6 +123,7 @@ public enum TinyEnum { public enum SmallEnum { VALUE(0); + SmallEnum(int val) { }; } @@ -142,6 +143,7 @@ public enum EnumConstants { return 3; } }; + int getVal() { return 1; } diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/B_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/B_out.java index 4c112b86ab..0bd3177efd 100644 --- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/B_out.java +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/B_out.java @@ -114,6 +114,7 @@ public enum TinyEnum { public enum SmallEnum { VALUE(0); + SmallEnum(int val) { }; } @@ -128,6 +129,7 @@ public enum EnumConstants { int getVal() { return 3; } }; + int getVal() { return 1; } } diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/C_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/C_out.java index ec05534b58..dd146bf3d3 100644 --- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/C_out.java +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/C_out.java @@ -109,6 +109,7 @@ public enum TinyEnum { A; } public enum SmallEnum { VALUE(0); + SmallEnum(int val) {}; } @@ -127,6 +128,7 @@ public enum EnumConstants { return 3; } }; + int getVal() { return 1; } diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/D_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/D_out.java index a1e2cca718..3b4bfcb70a 100644 --- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/D_out.java +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/D_out.java @@ -111,6 +111,7 @@ public enum TinyEnum { public enum SmallEnum { VALUE(0); + SmallEnum(int val) { }; } @@ -129,6 +130,7 @@ public enum EnumConstants { return 3; } }; + int getVal() { return 1; } diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/E_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/E_out.java index 60cf56fc6a..70fabb789d 100644 --- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/E_out.java +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/E_out.java @@ -110,6 +110,7 @@ public enum TinyEnum { public enum SmallEnum { VALUE(0); + SmallEnum(int val) {}; } @@ -117,6 +118,7 @@ public enum EnumConstants { EMPTY {}, TINY { int getVal() { return 2; } }, SMALL { int val = 3; int getVal() { return 3; } }; + int getVal() { return 1; } } diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/F_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/F_out.java index 012f0e3bb1..6c0378f938 100644 --- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/F_out.java +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/F_out.java @@ -105,6 +105,7 @@ public enum TinyEnum { A; } public enum SmallEnum { VALUE(0); + SmallEnum(int val) { }; } @@ -123,6 +124,7 @@ public enum EnumConstants { return 3; } }; + int getVal() { return 1; } diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/G_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/G_out.java index fc1e78cfd5..be297bf3d3 100644 --- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/G_out.java +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/G_out.java @@ -91,6 +91,7 @@ public enum TinyEnum { A; } public enum SmallEnum { VALUE(0); + SmallEnum(int val) {}; } @@ -105,6 +106,7 @@ public enum EnumConstants { int getVal() { return 3; } }; + int getVal() { return 1; } } diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/H_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/H_out.java index 9eba7cd481..0243d335e7 100644 --- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/H_out.java +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/H_out.java @@ -97,6 +97,7 @@ public enum EnumConstants { }, TINY { int getVal() { return 2; } }, SMALL { int val = 3; int getVal() { return 3; } }; + int getVal() { return 1; } } diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/I_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/I_out.java index 82d5839371..f5ddfdcd5b 100644 --- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/I_out.java +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test205973/I_out.java @@ -100,6 +100,7 @@ public enum TinyEnum { A; } public enum SmallEnum { VALUE(0); + SmallEnum(int val) {}; } @@ -111,6 +112,7 @@ public enum EnumConstants { int getVal() { return 3; } }; + int getVal() { return 1; } } diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test530/A_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test530/A_out.java index 9448cebced..9f583dc50d 100644 --- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test530/A_out.java +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test530/A_out.java @@ -2,6 +2,7 @@ package test530; public enum A { TEST; + public String field; public void foo() { diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test626/A_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test626/A_out.java index 9dd9296e3c..9506e64265 100644 --- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test626/A_out.java +++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test626/A_out.java @@ -1,5 +1,6 @@ public enum Enum_16 { ONE, TWO, THREE; + String foo(String str) { return ""; } |