|
Lines 11-16
Link Here
|
| 11 |
* Robin Stocker - Bug 49619 - [formatting] comment formatter leaves whitespace in comments |
11 |
* Robin Stocker - Bug 49619 - [formatting] comment formatter leaves whitespace in comments |
| 12 |
* Mateusz Matela <mateusz.matela@gmail.com> - [formatter] Formatter does not format Java code correctly, especially when max line width is set - https://bugs.eclipse.org/303519 |
12 |
* Mateusz Matela <mateusz.matela@gmail.com> - [formatter] Formatter does not format Java code correctly, especially when max line width is set - https://bugs.eclipse.org/303519 |
| 13 |
* Mateusz Matela <mateusz.matela@gmail.com> - [formatter] IndexOutOfBoundsException in TokenManager - https://bugs.eclipse.org/462945 |
13 |
* Mateusz Matela <mateusz.matela@gmail.com> - [formatter] IndexOutOfBoundsException in TokenManager - https://bugs.eclipse.org/462945 |
|
|
14 |
* Mateusz Matela <mateusz.matela@gmail.com> - [formatter] follow up bug for comments - https://bugs.eclipse.org/458208 |
| 14 |
*******************************************************************************/ |
15 |
*******************************************************************************/ |
| 15 |
package org.eclipse.jdt.core.tests.formatter; |
16 |
package org.eclipse.jdt.core.tests.formatter; |
| 16 |
|
17 |
|
|
Lines 1372-1378
Link Here
|
| 1372 |
// see also bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=287462 |
1373 |
// see also bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=287462 |
| 1373 |
public void testBug198074_dup201022() throws JavaModelException { |
1374 |
public void testBug198074_dup201022() throws JavaModelException { |
| 1374 |
this.formatterPrefs.join_wrapped_lines = false; |
1375 |
this.formatterPrefs.join_wrapped_lines = false; |
| 1375 |
this.formatterPrefs.wrap_before_binary_operator = false; |
|
|
| 1376 |
String source = |
1376 |
String source = |
| 1377 |
"public class Test {\n" + |
1377 |
"public class Test {\n" + |
| 1378 |
"\n" + |
1378 |
"\n" + |
|
Lines 1399-1405
Link Here
|
| 1399 |
// duplicate bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=213700 |
1399 |
// duplicate bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=213700 |
| 1400 |
public void testBug198074_dup213700() throws JavaModelException { |
1400 |
public void testBug198074_dup213700() throws JavaModelException { |
| 1401 |
this.formatterPrefs.join_wrapped_lines = false; |
1401 |
this.formatterPrefs.join_wrapped_lines = false; |
| 1402 |
this.formatterPrefs.wrap_before_binary_operator = false; |
|
|
| 1403 |
String source = |
1402 |
String source = |
| 1404 |
"public class Test {\n" + |
1403 |
"public class Test {\n" + |
| 1405 |
"\n" + |
1404 |
"\n" + |
|
Lines 1906-1912
Link Here
|
| 1906 |
"@MessageDriven(mappedName = \"filiality/SchedulerMQService\",\n" + |
1905 |
"@MessageDriven(mappedName = \"filiality/SchedulerMQService\",\n" + |
| 1907 |
" activationConfig = {\n" + |
1906 |
" activationConfig = {\n" + |
| 1908 |
" @ActivationConfigProperty(propertyName = \"cronTrigger\",\n" + |
1907 |
" @ActivationConfigProperty(propertyName = \"cronTrigger\",\n" + |
| 1909 |
" propertyValue = \"0/10 * * * * ?\") })\n" + |
1908 |
" propertyValue = \"0/10 * * * * ?\")\n" + |
|
|
1909 |
" })\n" + |
| 1910 |
"@RunAs(\"admin\")\n" + |
1910 |
"@RunAs(\"admin\")\n" + |
| 1911 |
"@ResourceAdapter(\"quartz-ra.rar\")\n" + |
1911 |
"@ResourceAdapter(\"quartz-ra.rar\")\n" + |
| 1912 |
"@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)\n" + |
1912 |
"@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)\n" + |
|
Lines 8041-8049
Link Here
|
| 8041 |
"public class X07 {\n" + |
8041 |
"public class X07 {\n" + |
| 8042 |
"\n" + |
8042 |
"\n" + |
| 8043 |
" static final long[] jjtoToken = {\n" + |
8043 |
" static final long[] jjtoToken = {\n" + |
| 8044 |
" 0x7fbfecffL, };\n" + |
8044 |
" 0x7fbfecffL,\n" + |
|
|
8045 |
" };\n" + |
| 8045 |
" static final long[] jjtoSkip = {\n" + |
8046 |
" static final long[] jjtoSkip = {\n" + |
| 8046 |
" 0x400000L, };\n" + |
8047 |
" 0x400000L,\n" + |
|
|
8048 |
" };\n" + |
| 8047 |
"\n" + |
8049 |
"\n" + |
| 8048 |
"}\n" |
8050 |
"}\n" |
| 8049 |
); |
8051 |
); |
|
Lines 8072-8081
Link Here
|
| 8072 |
"\n" + |
8074 |
"\n" + |
| 8073 |
" static final long[] jjtoToken =\n" + |
8075 |
" static final long[] jjtoToken =\n" + |
| 8074 |
" {\n" + |
8076 |
" {\n" + |
| 8075 |
" 0x7fbfecffL, };\n" + |
8077 |
" 0x7fbfecffL,\n" + |
|
|
8078 |
" };\n" + |
| 8076 |
" static final long[] jjtoSkip =\n" + |
8079 |
" static final long[] jjtoSkip =\n" + |
| 8077 |
" {\n" + |
8080 |
" {\n" + |
| 8078 |
" 0x400000L, };\n" + |
8081 |
" 0x400000L,\n" + |
|
|
8082 |
" };\n" + |
| 8079 |
"\n" + |
8083 |
"\n" + |
| 8080 |
"}\n" |
8084 |
"}\n" |
| 8081 |
); |
8085 |
); |
|
Lines 8124-8130
Link Here
|
| 8124 |
"public class X09 {\n" + |
8128 |
"public class X09 {\n" + |
| 8125 |
" public Class[] getAdapterList() {\n" + |
8129 |
" public Class[] getAdapterList() {\n" + |
| 8126 |
" return new Class[] {\n" + |
8130 |
" return new Class[] {\n" + |
| 8127 |
" IWorkbenchAdapter.class };\n" + |
8131 |
" IWorkbenchAdapter.class\n" + |
|
|
8132 |
" };\n" + |
| 8128 |
" }\n" + |
8133 |
" }\n" + |
| 8129 |
"}\n" |
8134 |
"}\n" |
| 8130 |
); |
8135 |
); |
|
Lines 8796-8802
Link Here
|
| 8796 |
} |
8801 |
} |
| 8797 |
public void testBug330313_wksp1_25_njl() { |
8802 |
public void testBug330313_wksp1_25_njl() { |
| 8798 |
this.formatterPrefs.join_wrapped_lines = false; |
8803 |
this.formatterPrefs.join_wrapped_lines = false; |
| 8799 |
this.formatterPrefs.wrap_before_binary_operator = false; |
|
|
| 8800 |
String source = |
8804 |
String source = |
| 8801 |
"package wksp1;\n" + |
8805 |
"package wksp1;\n" + |
| 8802 |
"\n" + |
8806 |
"\n" + |
|
Lines 8811-8817
Link Here
|
| 8811 |
} |
8815 |
} |
| 8812 |
public void testBug330313_wksp1_26_njl() { |
8816 |
public void testBug330313_wksp1_26_njl() { |
| 8813 |
this.formatterPrefs.join_wrapped_lines = false; |
8817 |
this.formatterPrefs.join_wrapped_lines = false; |
| 8814 |
this.formatterPrefs.wrap_before_binary_operator = false; |
|
|
| 8815 |
String source = |
8818 |
String source = |
| 8816 |
"package wksp1;\n" + |
8819 |
"package wksp1;\n" + |
| 8817 |
"\n" + |
8820 |
"\n" + |
|
Lines 8962-8968
Link Here
|
| 8962 |
} |
8965 |
} |
| 8963 |
public void testBug330313_wksp1_30_njl() { |
8966 |
public void testBug330313_wksp1_30_njl() { |
| 8964 |
this.formatterPrefs.join_wrapped_lines = false; |
8967 |
this.formatterPrefs.join_wrapped_lines = false; |
| 8965 |
this.formatterPrefs.wrap_before_binary_operator = false; |
|
|
| 8966 |
setPageWidth80(); |
8968 |
setPageWidth80(); |
| 8967 |
String source = |
8969 |
String source = |
| 8968 |
"package wksp1;\n" + |
8970 |
"package wksp1;\n" + |
|
Lines 9083-9089
Link Here
|
| 9083 |
} |
9085 |
} |
| 9084 |
public void testBug330313_wksp1_33_njl() { |
9086 |
public void testBug330313_wksp1_33_njl() { |
| 9085 |
this.formatterPrefs.join_wrapped_lines = false; |
9087 |
this.formatterPrefs.join_wrapped_lines = false; |
| 9086 |
this.formatterPrefs.wrap_before_binary_operator = false; |
|
|
| 9087 |
String source = |
9088 |
String source = |
| 9088 |
"package wksp1;\n" + |
9089 |
"package wksp1;\n" + |
| 9089 |
"\n" + |
9090 |
"\n" + |
|
Lines 9106-9113
Link Here
|
| 9106 |
" void foo() {\n" + |
9107 |
" void foo() {\n" + |
| 9107 |
" if (inMetaTag &&\n" + |
9108 |
" if (inMetaTag &&\n" + |
| 9108 |
" (t1.image.equalsIgnoreCase(\"name\") ||\n" + |
9109 |
" (t1.image.equalsIgnoreCase(\"name\") ||\n" + |
| 9109 |
" t1.image.equalsIgnoreCase(\"HTTP-EQUIV\")) &&\n" + |
9110 |
" t1.image.equalsIgnoreCase(\"HTTP-EQUIV\"))\n" + |
| 9110 |
" t2 != null) {\n" + |
9111 |
" && t2 != null) {\n" + |
| 9111 |
" currentMetaTag = t2.image.toLowerCase();\n" + |
9112 |
" currentMetaTag = t2.image.toLowerCase();\n" + |
| 9112 |
" }\n" + |
9113 |
" }\n" + |
| 9113 |
" }\n" + |
9114 |
" }\n" + |
|
Lines 9305-9311
Link Here
|
| 9305 |
" * \"GeneralPage.DoubleClick\", resName, 1,\n" + |
9306 |
" * \"GeneralPage.DoubleClick\", resName, 1,\n" + |
| 9306 |
" * new String[][] {\n" + |
9307 |
" * new String[][] {\n" + |
| 9307 |
" * { \"Open Browser\", \"open\" },\n" + |
9308 |
" * { \"Open Browser\", \"open\" },\n" + |
| 9308 |
" * { \"Expand Tree\", \"expand\" } },\n" + |
9309 |
" * { \"Expand Tree\", \"expand\" }\n" + |
|
|
9310 |
" * },\n" + |
| 9309 |
" * parent);\n" + |
9311 |
" * parent);\n" + |
| 9310 |
" * </pre>\n" + |
9312 |
" * </pre>\n" + |
| 9311 |
" */\n" + |
9313 |
" */\n" + |
|
Lines 9337-9343
Link Here
|
| 9337 |
" /* INACTIVE */ { \"INACTIVE\", \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\" },\n" + |
9339 |
" /* INACTIVE */ { \"INACTIVE\", \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\" },\n" + |
| 9338 |
" /* PARTLY_ACTIVE */ { \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\",\n" + |
9340 |
" /* PARTLY_ACTIVE */ { \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\",\n" + |
| 9339 |
" \"PARTLY_ACTIVE\" },\n" + |
9341 |
" \"PARTLY_ACTIVE\" },\n" + |
| 9340 |
" /* ACTIVE */ { \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\", \"ACTIVE\" } };\n" + |
9342 |
" /* ACTIVE */ { \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\", \"ACTIVE\" }\n" + |
|
|
9343 |
" };\n" + |
| 9341 |
"}\n" |
9344 |
"}\n" |
| 9342 |
); |
9345 |
); |
| 9343 |
} |
9346 |
} |
|
Lines 9508-9514
Link Here
|
| 9508 |
" user,\n" + |
9511 |
" user,\n" + |
| 9509 |
" revision,\n" + |
9512 |
" revision,\n" + |
| 9510 |
" String.valueOf(delta),\n" + |
9513 |
" String.valueOf(delta),\n" + |
| 9511 |
" line });\n" + |
9514 |
" line\n" + |
|
|
9515 |
" });\n" + |
| 9512 |
" }\n" + |
9516 |
" }\n" + |
| 9513 |
"}\n" |
9517 |
"}\n" |
| 9514 |
); |
9518 |
); |
|
Lines 9611-9617
Link Here
|
| 9611 |
" IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR),\n" + |
9615 |
" IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR),\n" + |
| 9612 |
" new Color[] {\n" + |
9616 |
" new Color[] {\n" + |
| 9613 |
" colorRegistry.get(\n" + |
9617 |
" colorRegistry.get(\n" + |
| 9614 |
" IWorkbenchThemeConstants.INACTIVE_TAB_BG_START) },\n" + |
9618 |
" IWorkbenchThemeConstants.INACTIVE_TAB_BG_START)\n" + |
|
|
9619 |
" },\n" + |
| 9615 |
" new int[0],\n" + |
9620 |
" new int[0],\n" + |
| 9616 |
" true);\n" + |
9621 |
" true);\n" + |
| 9617 |
" }\n" + |
9622 |
" }\n" + |
|
Lines 9780-9786
Link Here
|
| 9780 |
" public char[][] getCompoundName() {\n" + |
9785 |
" public char[][] getCompoundName() {\n" + |
| 9781 |
" return EvaluationConstants.ROOT_COMPOUND_NAME;\n" + |
9786 |
" return EvaluationConstants.ROOT_COMPOUND_NAME;\n" + |
| 9782 |
" }\n" + |
9787 |
" }\n" + |
| 9783 |
" } },\n" + |
9788 |
" }\n" + |
|
|
9789 |
" },\n" + |
| 9784 |
" null);\n" + |
9790 |
" null);\n" + |
| 9785 |
" }\n" + |
9791 |
" }\n" + |
| 9786 |
" }\n" + |
9792 |
" }\n" + |
|
Lines 9985-9991
Link Here
|
| 9985 |
" return info.getLocal()\n" + |
9991 |
" return info.getLocal()\n" + |
| 9986 |
" .getType() == IResource.FILE;\n" + |
9992 |
" .getType() == IResource.FILE;\n" + |
| 9987 |
" }\n" + |
9993 |
" }\n" + |
| 9988 |
" } }),\n" + |
9994 |
" }\n" + |
|
|
9995 |
" }),\n" + |
| 9989 |
" // Conflicting changes of files will fail if the local is not\n" + |
9996 |
" // Conflicting changes of files will fail if the local is not\n" + |
| 9990 |
" // managed\n" + |
9997 |
" // managed\n" + |
| 9991 |
" // or is an addition\n" + |
9998 |
" // or is an addition\n" + |
|
Lines 10012-10018
Link Here
|
| 10012 |
" }\n" + |
10019 |
" }\n" + |
| 10013 |
" return false;\n" + |
10020 |
" return false;\n" + |
| 10014 |
" }\n" + |
10021 |
" }\n" + |
| 10015 |
" } }),\n" + |
10022 |
" }\n" + |
|
|
10023 |
" }),\n" + |
| 10016 |
" // Conflicting changes involving a deletion on one side will\n" + |
10024 |
" // Conflicting changes involving a deletion on one side will\n" + |
| 10017 |
" // aways fail\n" + |
10025 |
" // aways fail\n" + |
| 10018 |
" new AndSyncInfoFilter(new FastSyncInfoFilter[] {\n" + |
10026 |
" new AndSyncInfoFilter(new FastSyncInfoFilter[] {\n" + |
|
Lines 10031-10037
Link Here
|
| 10031 |
" && !base.equals(remote));\n" + |
10039 |
" && !base.equals(remote));\n" + |
| 10032 |
" }\n" + |
10040 |
" }\n" + |
| 10033 |
" }\n" + |
10041 |
" }\n" + |
| 10034 |
" } }),\n" + |
10042 |
" }\n" + |
|
|
10043 |
" }),\n" + |
| 10035 |
" // Conflicts where the file type is binary will work but are not\n" + |
10044 |
" // Conflicts where the file type is binary will work but are not\n" + |
| 10036 |
" // merged\n" + |
10045 |
" // merged\n" + |
| 10037 |
" // so they should be skipped\n" + |
10046 |
" // so they should be skipped\n" + |
|
Lines 10060-10068
Link Here
|
| 10060 |
" }\n" + |
10069 |
" }\n" + |
| 10061 |
" return false;\n" + |
10070 |
" return false;\n" + |
| 10062 |
" }\n" + |
10071 |
" }\n" + |
| 10063 |
" } }),\n" + |
10072 |
" }\n" + |
|
|
10073 |
" }),\n" + |
| 10064 |
" // Outgoing changes may not fail but they are skipped as well\n" + |
10074 |
" // Outgoing changes may not fail but they are skipped as well\n" + |
| 10065 |
" new SyncInfoDirectionFilter(SyncInfo.OUTGOING) });\n" + |
10075 |
" new SyncInfoDirectionFilter(SyncInfo.OUTGOING)\n" + |
|
|
10076 |
" });\n" + |
| 10066 |
" }\n" + |
10077 |
" }\n" + |
| 10067 |
"}\n" |
10078 |
"}\n" |
| 10068 |
); |
10079 |
); |
|
Lines 10113-10119
Link Here
|
| 10113 |
" { 104, 20 },\n" + |
10124 |
" { 104, 20 },\n" + |
| 10114 |
" { 108, 21 },\n" + |
10125 |
" { 108, 21 },\n" + |
| 10115 |
" { 12, 1856 },\n" + |
10126 |
" { 12, 1856 },\n" + |
| 10116 |
" { 13, 1920 } }, };\n" + |
10127 |
" { 13, 1920 } },\n" + |
|
|
10128 |
" };\n" + |
| 10117 |
"}\n" |
10129 |
"}\n" |
| 10118 |
); |
10130 |
); |
| 10119 |
} |
10131 |
} |
|
Lines 10254-10260
Link Here
|
| 10254 |
" UNKNOWN,\n" + |
10266 |
" UNKNOWN,\n" + |
| 10255 |
" UNKNOWN,\n" + |
10267 |
" UNKNOWN,\n" + |
| 10256 |
" UNKNOWN,\n" + |
10268 |
" UNKNOWN,\n" + |
| 10257 |
" UNKNOWN } };\n" + |
10269 |
" UNKNOWN }\n" + |
|
|
10270 |
" };\n" + |
| 10258 |
"\n" + |
10271 |
"\n" + |
| 10259 |
"}\n" |
10272 |
"}\n" |
| 10260 |
); |
10273 |
); |
|
Lines 10300-10306
Link Here
|
| 10300 |
" \"READ_POTENTIAL\",\n" + |
10313 |
" \"READ_POTENTIAL\",\n" + |
| 10301 |
" \"UNKNOWN\",\n" + |
10314 |
" \"UNKNOWN\",\n" + |
| 10302 |
" \"UNKNOWN\",\n" + |
10315 |
" \"UNKNOWN\",\n" + |
| 10303 |
" \"UNKNOWN\" }, };\n" + |
10316 |
" \"UNKNOWN\" },\n" + |
|
|
10317 |
" };\n" + |
| 10304 |
"\n" + |
10318 |
"\n" + |
| 10305 |
"}\n" |
10319 |
"}\n" |
| 10306 |
); |
10320 |
); |
|
Lines 10348-10354
Link Here
|
| 10348 |
" \"READ_POTENTIAL\",\n" + |
10362 |
" \"READ_POTENTIAL\",\n" + |
| 10349 |
" \"UNKNOWN\",\n" + |
10363 |
" \"UNKNOWN\",\n" + |
| 10350 |
" \"UNKNOWN\",\n" + |
10364 |
" \"UNKNOWN\",\n" + |
| 10351 |
" \"UNKNOWN\" }, };\n" + |
10365 |
" \"UNKNOWN\" },\n" + |
|
|
10366 |
" };\n" + |
| 10352 |
"\n" + |
10367 |
"\n" + |
| 10353 |
"}\n" |
10368 |
"}\n" |
| 10354 |
); |
10369 |
); |
|
Lines 10389-10395
Link Here
|
| 10389 |
" \"1234567890123456789012345678901234567890\" },\n" + |
10404 |
" \"1234567890123456789012345678901234567890\" },\n" + |
| 10390 |
" /* Comment 3 */ {\n" + |
10405 |
" /* Comment 3 */ {\n" + |
| 10391 |
" \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\",\n" + |
10406 |
" \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\",\n" + |
| 10392 |
" \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" }, };\n" + |
10407 |
" \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" + |
|
|
10408 |
" };\n" + |
| 10393 |
"\n" + |
10409 |
"\n" + |
| 10394 |
"}\n" |
10410 |
"}\n" |
| 10395 |
); |
10411 |
); |
|
Lines 10720-10724
Link Here
|
| 10720 |
String source = "/**/int f;"; |
10736 |
String source = "/**/int f;"; |
| 10721 |
formatSource(source, source, CodeFormatter.K_STATEMENTS); |
10737 |
formatSource(source, source, CodeFormatter.K_STATEMENTS); |
| 10722 |
} |
10738 |
} |
| 10723 |
|
10739 |
/** |
|
|
10740 |
* @bug 458208: [formatter] follow up bug for comments |
| 10741 |
* @test test a space is not added after a lambda expression in parenthesis |
| 10742 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=458208#c2" |
| 10743 |
*/ |
| 10744 |
public void testBug458208() throws Exception { |
| 10745 |
String source = |
| 10746 |
"package p;\n" + |
| 10747 |
"import java.util.function.IntConsumer;\n" + |
| 10748 |
"class TestInlineLambda1 {\n" + |
| 10749 |
" {\n" + |
| 10750 |
" IntConsumer op = (x -> {} );\n" + |
| 10751 |
" }\n" + |
| 10752 |
"}\n"; |
| 10753 |
formatSource(source, |
| 10754 |
"package p;\n" + |
| 10755 |
"\n" + |
| 10756 |
"import java.util.function.IntConsumer;\n" + |
| 10757 |
"\n" + |
| 10758 |
"class TestInlineLambda1 {\n" + |
| 10759 |
" {\n" + |
| 10760 |
" IntConsumer op = (x -> {\n" + |
| 10761 |
" });\n" + |
| 10762 |
" }\n" + |
| 10763 |
"}\n" |
| 10764 |
); |
| 10765 |
} |
| 10766 |
/** |
| 10767 |
* @bug 458208: [formatter] follow up bug for comments |
| 10768 |
* @test test that comments in switch statements are properly indented |
| 10769 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=458208#c21" |
| 10770 |
*/ |
| 10771 |
public void testBug458208b() throws Exception { |
| 10772 |
formatSource( |
| 10773 |
"package p;\n" + |
| 10774 |
"\n" + |
| 10775 |
"public class C1 {\n" + |
| 10776 |
" void foo(int x) {\n" + |
| 10777 |
" switch (x) {\n" + |
| 10778 |
" // case 1\n" + |
| 10779 |
" case 1:\n" + |
| 10780 |
" break;\n" + |
| 10781 |
" // case 2\n" + |
| 10782 |
" case 2:\n" + |
| 10783 |
" break;\n" + |
| 10784 |
" // no more cases\n" + |
| 10785 |
" }\n" + |
| 10786 |
" }\n" + |
| 10787 |
"\n" + |
| 10788 |
" int bar(int x) {\n" + |
| 10789 |
" while (true) {\n" + |
| 10790 |
" int y = 9;\n" + |
| 10791 |
" switch (x) {\n" + |
| 10792 |
" // case 1\n" + |
| 10793 |
" case 1:\n" + |
| 10794 |
" // should return\n" + |
| 10795 |
" return y;\n" + |
| 10796 |
" // case 2\n" + |
| 10797 |
" case 2:\n" + |
| 10798 |
" // should break\n" + |
| 10799 |
" break;\n" + |
| 10800 |
" case 3:\n" + |
| 10801 |
" // TODO\n" + |
| 10802 |
" }\n" + |
| 10803 |
" }\n" + |
| 10804 |
" }\n" + |
| 10805 |
"}\n" |
| 10806 |
); |
| 10807 |
} |
| 10808 |
/** |
| 10809 |
* @bug 458208: [formatter] follow up bug for comments |
| 10810 |
* @test test that elements separated with empty lines are properly indented |
| 10811 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=458208#c18" |
| 10812 |
*/ |
| 10813 |
public void testBug458208c() throws Exception { |
| 10814 |
final int wrapAllOnColumn = Alignment.M_NEXT_PER_LINE_SPLIT + Alignment.M_INDENT_ON_COLUMN + Alignment.M_FORCE; |
| 10815 |
this.formatterPrefs.alignment_for_enum_constants = wrapAllOnColumn; |
| 10816 |
this.formatterPrefs.alignment_for_arguments_in_enum_constant = wrapAllOnColumn; |
| 10817 |
this.formatterPrefs.alignment_for_expressions_in_array_initializer = wrapAllOnColumn; |
| 10818 |
String source = |
| 10819 |
"package p;\n" + |
| 10820 |
"\n" + |
| 10821 |
"public enum TestEnum {\n" + |
| 10822 |
" FIRST_ENUM(\"first type\",\n" + |
| 10823 |
" new SomeClass(),\n" + |
| 10824 |
" new OtherEnumType[] { OtherEnumType.FOO }),\n" + |
| 10825 |
"\n" + |
| 10826 |
" SECOND_ENUM(\"second type\",\n" + |
| 10827 |
" new SomeClassOtherClass(),\n" + |
| 10828 |
" new OtherEnumType[] { OtherEnumType.BAR }),\n" + |
| 10829 |
"\n" + |
| 10830 |
" THIRD_ENUM(\"third type\",\n" + |
| 10831 |
" new YetAnotherClass(),\n" + |
| 10832 |
" new OtherEnumType[] { OtherEnumType.FOOBAR,\n" + |
| 10833 |
" OtherEnumType.FOOBARBAZ,\n" + |
| 10834 |
"\n" + |
| 10835 |
" OtherEnumType.LONGERFOOBARBAZ,\n" + |
| 10836 |
" OtherEnumType.MORELETTERSINHERE });\n" + |
| 10837 |
"\n" + |
| 10838 |
" /* data members and methods go here */\n" + |
| 10839 |
" TestEnum(String s, Cls s1, OtherEnumType[] e) {\n" + |
| 10840 |
" }\n" + |
| 10841 |
"}"; |
| 10842 |
formatSource(source, |
| 10843 |
"package p;\n" + |
| 10844 |
"\n" + |
| 10845 |
"public enum TestEnum {\n" + |
| 10846 |
" FIRST_ENUM( \"first type\",\n" + |
| 10847 |
" new SomeClass(),\n" + |
| 10848 |
" new OtherEnumType[] { OtherEnumType.FOO }),\n" + |
| 10849 |
"\n" + |
| 10850 |
" SECOND_ENUM(\"second type\",\n" + |
| 10851 |
" new SomeClassOtherClass(),\n" + |
| 10852 |
" new OtherEnumType[] { OtherEnumType.BAR }),\n" + |
| 10853 |
"\n" + |
| 10854 |
" THIRD_ENUM( \"third type\",\n" + |
| 10855 |
" new YetAnotherClass(),\n" + |
| 10856 |
" new OtherEnumType[] { OtherEnumType.FOOBAR,\n" + |
| 10857 |
" OtherEnumType.FOOBARBAZ,\n" + |
| 10858 |
"\n" + |
| 10859 |
" OtherEnumType.LONGERFOOBARBAZ,\n" + |
| 10860 |
" OtherEnumType.MORELETTERSINHERE });\n" + |
| 10861 |
"\n" + |
| 10862 |
" /* data members and methods go here */\n" + |
| 10863 |
" TestEnum(String s, Cls s1, OtherEnumType[] e) {\n" + |
| 10864 |
" }\n" + |
| 10865 |
"}" |
| 10866 |
); |
| 10867 |
} |
| 10868 |
/** |
| 10869 |
* @bug 458208: [formatter] follow up bug for comments |
| 10870 |
* @test test that enum constants are not indented with spaces when "Use spaces to indent wrapped lines" is on |
| 10871 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=458208#c24" |
| 10872 |
*/ |
| 10873 |
public void testBug458208d() throws Exception { |
| 10874 |
this.formatterPrefs.alignment_for_enum_constants = Alignment.M_COMPACT_SPLIT; |
| 10875 |
this.formatterPrefs.use_tabs_only_for_leading_indentations = true; |
| 10876 |
setPageWidth80(); |
| 10877 |
String source = |
| 10878 |
"package p;\n" + |
| 10879 |
"\n" + |
| 10880 |
"public enum TestEnum {\n" + |
| 10881 |
" ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, ELEVEN, TWELWE, THIRTEEN, FOURTEEN, FIFTEEN;\n" + |
| 10882 |
"}"; |
| 10883 |
formatSource(source, |
| 10884 |
"package p;\n" + |
| 10885 |
"\n" + |
| 10886 |
"public enum TestEnum {\n" + |
| 10887 |
" ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, ELEVEN, TWELWE,\n" + |
| 10888 |
" THIRTEEN, FOURTEEN, FIFTEEN;\n" + |
| 10889 |
"}" |
| 10890 |
); |
| 10891 |
} |
| 10724 |
} |
10892 |
} |