Lines 6050-6056
Link Here
|
6050 |
* @test Ensure that the formatter does not take care of formatting tags by default |
6050 |
* @test Ensure that the formatter does not take care of formatting tags by default |
6051 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=311582" |
6051 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=311582" |
6052 |
*/ |
6052 |
*/ |
6053 |
public void testBug0311582a() throws JavaModelException { |
6053 |
public void testBug311582a() throws JavaModelException { |
6054 |
this.formatterPrefs.disabling_tag = "disable-formatter".toCharArray(); |
6054 |
this.formatterPrefs.disabling_tag = "disable-formatter".toCharArray(); |
6055 |
this.formatterPrefs.enabling_tag = "enable-formatter".toCharArray(); |
6055 |
this.formatterPrefs.enabling_tag = "enable-formatter".toCharArray(); |
6056 |
String source = |
6056 |
String source = |
Lines 6080-6086
Link Here
|
6080 |
"}\n" |
6080 |
"}\n" |
6081 |
); |
6081 |
); |
6082 |
} |
6082 |
} |
6083 |
public void testBug0311582b() { |
6083 |
public void testBug311582b() { |
6084 |
this.formatterPrefs = null; |
6084 |
this.formatterPrefs = null; |
6085 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_DISABLING_TAG, "off"); |
6085 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_DISABLING_TAG, "off"); |
6086 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_ENABLING_TAG, ""); |
6086 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_ENABLING_TAG, ""); |
Lines 6106-6112
Link Here
|
6106 |
* @test Ensure that the formatter does not take care of formatting tags by default |
6106 |
* @test Ensure that the formatter does not take care of formatting tags by default |
6107 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=311617" |
6107 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=311617" |
6108 |
*/ |
6108 |
*/ |
6109 |
public void testBug0311617() throws JavaModelException { |
6109 |
public void testBug311617() throws JavaModelException { |
6110 |
this.formatterPrefs.use_tags = true; |
6110 |
this.formatterPrefs.use_tags = true; |
6111 |
String source = |
6111 |
String source = |
6112 |
"public class X01 {\n" + |
6112 |
"public class X01 {\n" + |
Lines 6134-6140
Link Here
|
6134 |
"}\n" |
6134 |
"}\n" |
6135 |
); |
6135 |
); |
6136 |
} |
6136 |
} |
6137 |
public void testBug0311617b() { |
6137 |
public void testBug311617b() { |
6138 |
this.formatterPrefs = null; |
6138 |
this.formatterPrefs = null; |
6139 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_USE_ON_OFF_TAGS, DefaultCodeFormatterConstants.TRUE); |
6139 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_USE_ON_OFF_TAGS, DefaultCodeFormatterConstants.TRUE); |
6140 |
String source = |
6140 |
String source = |
Lines 6147-6150
Link Here
|
6147 |
formatSource(source); |
6147 |
formatSource(source); |
6148 |
} |
6148 |
} |
6149 |
|
6149 |
|
|
|
6150 |
/** |
6151 |
* @bug 313524: [formatter] Add preference for improved lines wrapping in nested method calls |
6152 |
* @test Ensure that the formatter keep previous eclipse versions behavior when |
6153 |
* the "Try to keep nested expressions on one line" preference is set. |
6154 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=313524" |
6155 |
*/ |
6156 |
public void testBug313524_01() throws JavaModelException { |
6157 |
this.formatterPrefs.page_width = 40; |
6158 |
this.formatterPrefs.keep_nested_expression_on_one_line = true; |
6159 |
String source = |
6160 |
"public class X01 {\n" + |
6161 |
" void test() {\n" + |
6162 |
" foo(bar(1, 2, 3, 4), bar(5, 6, 7, 8));\n" + |
6163 |
" }\n" + |
6164 |
"}\n"; |
6165 |
formatSource(source, |
6166 |
"public class X01 {\n" + |
6167 |
" void test() {\n" + |
6168 |
" foo(bar(1, 2, 3, 4), bar(5, 6,\n" + |
6169 |
" 7, 8));\n" + |
6170 |
" }\n" + |
6171 |
"}\n" |
6172 |
); |
6173 |
} |
6174 |
public void testBug313524_01b() throws JavaModelException { |
6175 |
this.formatterPrefs = null; |
6176 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "40"); |
6177 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_NESTED_EXPRESSIONS_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); |
6178 |
this.formatterOptions.put( |
6179 |
DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, |
6180 |
DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); |
6181 |
String source = |
6182 |
"public class X01 {\n" + |
6183 |
" void test() {\n" + |
6184 |
" foo(bar(1, 2, 3, 4), bar(5, 6, 7, 8));\n" + |
6185 |
" }\n" + |
6186 |
"}\n"; |
6187 |
formatSource(source, |
6188 |
"public class X01 {\n" + |
6189 |
" void test() {\n" + |
6190 |
" foo(bar(1, 2, 3, 4), bar( 5,\n" + |
6191 |
" 6,\n" + |
6192 |
" 7,\n" + |
6193 |
" 8));\n" + |
6194 |
" }\n" + |
6195 |
"}\n" |
6196 |
); |
6197 |
} |
6198 |
public void testBug313524_02() throws JavaModelException { |
6199 |
this.formatterPrefs.page_width = 40; |
6200 |
this.formatterPrefs.keep_nested_expression_on_one_line = true; |
6201 |
String source = |
6202 |
"public class X02 {\n" + |
6203 |
" void test() {\n" + |
6204 |
" foo(bar(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), bar(11, 12, 13, 14, 15, 16, 17, 18, 19, 20));\n" + |
6205 |
" }\n" + |
6206 |
"}\n"; |
6207 |
formatSource(source, |
6208 |
"public class X02 {\n" + |
6209 |
" void test() {\n" + |
6210 |
" foo(bar(1, 2, 3, 4, 5, 6, 7, 8,\n" + |
6211 |
" 9, 10), bar(11, 12, 13,\n" + |
6212 |
" 14, 15, 16, 17, 18, 19,\n" + |
6213 |
" 20));\n" + |
6214 |
" }\n" + |
6215 |
"}\n" |
6216 |
); |
6217 |
} |
6218 |
public void testBug313524_02b() throws JavaModelException { |
6219 |
this.formatterPrefs = null; |
6220 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "40"); |
6221 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_NESTED_EXPRESSIONS_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); |
6222 |
this.formatterOptions.put( |
6223 |
DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, |
6224 |
DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); |
6225 |
String source = |
6226 |
"public class X02 {\n" + |
6227 |
" void test() {\n" + |
6228 |
" foo(bar(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), bar(11, 12, 13, 14, 15, 16, 17, 18, 19, 20));\n" + |
6229 |
" }\n" + |
6230 |
"}\n"; |
6231 |
formatSource(source, |
6232 |
"public class X02 {\n" + |
6233 |
" void test() {\n" + |
6234 |
" foo(bar(1, 2, 3, 4, 5, 6, 7, 8,\n" + |
6235 |
" 9, 10), bar(11, 12, 13,\n" + |
6236 |
" 14, 15, 16,\n" + |
6237 |
" 17, 18, 19,\n" + |
6238 |
" 20));\n" + |
6239 |
" }\n" + |
6240 |
"}\n" |
6241 |
); |
6242 |
} |
6243 |
public void testBug313524_03() throws JavaModelException { |
6244 |
this.formatterPrefs.page_width = 40; |
6245 |
this.formatterPrefs.keep_nested_expression_on_one_line = true; |
6246 |
String source = |
6247 |
"public class X03 {\n" + |
6248 |
" void test() {\n" + |
6249 |
" foo(bar(1, 2, 3, 4), bar(5, 6, 7, 8), bar(9, 10, 11, 12));\n" + |
6250 |
" }\n" + |
6251 |
"}\n"; |
6252 |
formatSource(source, |
6253 |
"public class X03 {\n" + |
6254 |
" void test() {\n" + |
6255 |
" foo(bar(1, 2, 3, 4), bar(5, 6,\n" + |
6256 |
" 7, 8), bar(9, 10, 11,\n" + |
6257 |
" 12));\n" + |
6258 |
" }\n" + |
6259 |
"}\n" |
6260 |
); |
6261 |
} |
6262 |
public void testBug313524_03b() throws JavaModelException { |
6263 |
this.formatterPrefs = null; |
6264 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "40"); |
6265 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_NESTED_EXPRESSIONS_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); |
6266 |
this.formatterOptions.put( |
6267 |
DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, |
6268 |
DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); |
6269 |
String source = |
6270 |
"public class X03 {\n" + |
6271 |
" void test() {\n" + |
6272 |
" foo(bar(1, 2, 3, 4), bar(5, 6, 7, 8), bar(9, 10, 11, 12));\n" + |
6273 |
" }\n" + |
6274 |
"}\n"; |
6275 |
formatSource(source, |
6276 |
"public class X03 {\n" + |
6277 |
" void test() {\n" + |
6278 |
" foo(bar(1, 2, 3, 4), bar( 5,\n" + |
6279 |
" 6,\n" + |
6280 |
" 7,\n" + |
6281 |
" 8),\n" + |
6282 |
" bar(9, 10, 11, 12));\n" + |
6283 |
" }\n" + |
6284 |
"}\n" |
6285 |
); |
6286 |
} |
6287 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=146175 |
6288 |
public void testBug313524_146175() throws JavaModelException { |
6289 |
this.formatterPrefs.keep_nested_expression_on_one_line = true; |
6290 |
String source = |
6291 |
"public class FormatterDemo {\n" + |
6292 |
"\n" + |
6293 |
" public void fooBar() {\n" + |
6294 |
" SomeOtherClass instanceOfOtherClass = new SomeOtherClass();\n" + |
6295 |
"\n" + |
6296 |
" /* The following statement demonstrates the formatter issue */\n" + |
6297 |
" SomeOtherClass.someMethodInInnerClass(\n" + |
6298 |
" instanceOfOtherClass.anotherMethod(\"Value of paramter 1\"),\n" + |
6299 |
" instanceOfOtherClass.anotherMethod(\"Value of paramter 2\"));\n" + |
6300 |
"\n" + |
6301 |
" }\n" + |
6302 |
"\n" + |
6303 |
" private static class SomeOtherClass {\n" + |
6304 |
" public static void someMethodInInnerClass(\n" + |
6305 |
" String param1,\n" + |
6306 |
" String param2) {\n" + |
6307 |
" }\n" + |
6308 |
" public String anotherMethod(String par) {\n" + |
6309 |
" return par;\n" + |
6310 |
" }\n" + |
6311 |
" }\n" + |
6312 |
"}\n"; |
6313 |
formatSource(source, |
6314 |
"public class FormatterDemo {\n" + |
6315 |
"\n" + |
6316 |
" public void fooBar() {\n" + |
6317 |
" SomeOtherClass instanceOfOtherClass = new SomeOtherClass();\n" + |
6318 |
"\n" + |
6319 |
" /* The following statement demonstrates the formatter issue */\n" + |
6320 |
" SomeOtherClass.someMethodInInnerClass(instanceOfOtherClass\n" + |
6321 |
" .anotherMethod(\"Value of paramter 1\"), instanceOfOtherClass\n" + |
6322 |
" .anotherMethod(\"Value of paramter 2\"));\n" + |
6323 |
"\n" + |
6324 |
" }\n" + |
6325 |
"\n" + |
6326 |
" private static class SomeOtherClass {\n" + |
6327 |
" public static void someMethodInInnerClass(String param1, String param2) {\n" + |
6328 |
" }\n" + |
6329 |
"\n" + |
6330 |
" public String anotherMethod(String par) {\n" + |
6331 |
" return par;\n" + |
6332 |
" }\n" + |
6333 |
" }\n" + |
6334 |
"}\n" |
6335 |
); |
6336 |
} |
6337 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=164093 |
6338 |
public void testBug313524_164093_01() throws JavaModelException { |
6339 |
this.formatterPrefs = null; |
6340 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "30"); |
6341 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_NESTED_EXPRESSIONS_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); |
6342 |
this.formatterOptions.put( |
6343 |
DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, |
6344 |
DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); |
6345 |
String source = |
6346 |
"public class Test {\n" + |
6347 |
" int someLongMethodName(int foo, boolean bar, String yetAnotherArg) {\n" + |
6348 |
" return 0;\n" + |
6349 |
" }\n" + |
6350 |
"}\n"; |
6351 |
formatSource(source, |
6352 |
"public class Test {\n" + |
6353 |
" int someLongMethodName( int foo,\n" + |
6354 |
" boolean bar,\n" + |
6355 |
" String yetAnotherArg) {\n" + |
6356 |
" return 0;\n" + |
6357 |
" }\n" + |
6358 |
"}\n" |
6359 |
); |
6360 |
} |
6361 |
public void testBug313524_164093_02() throws JavaModelException { |
6362 |
this.formatterPrefs = null; |
6363 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "55"); |
6364 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); |
6365 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_NESTED_EXPRESSIONS_ON_ONE_LINE, DefaultCodeFormatterConstants.TRUE); |
6366 |
this.formatterOptions.put( |
6367 |
DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION, |
6368 |
DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); |
6369 |
String source = |
6370 |
"public class X01 {\n" + |
6371 |
" void foo() {\n" + |
6372 |
" someIdentifier(someArg).someMethodName().someMethodName(foo, bar).otherMethod(arg0, arg1);\n" + |
6373 |
" }\n" + |
6374 |
"}\n"; |
6375 |
formatSource(source, |
6376 |
"public class X01 {\n" + |
6377 |
" void foo() {\n" + |
6378 |
" someIdentifier(someArg).someMethodName()\n" + |
6379 |
" .someMethodName(foo,\n" + |
6380 |
" bar)\n" + |
6381 |
" .otherMethod(arg0, arg1);\n" + |
6382 |
" }\n" + |
6383 |
"}\n" |
6384 |
); |
6385 |
} |
6386 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=203588 |
6387 |
public void testBug313524_203588() throws JavaModelException { |
6388 |
this.formatterPrefs.keep_nested_expression_on_one_line = true; |
6389 |
String source = |
6390 |
"public class Test {\n" + |
6391 |
"public void a()\n" + |
6392 |
"{\n" + |
6393 |
" if(true)\n" + |
6394 |
" {\n" + |
6395 |
" allocation.add(idx_ta + 1, Double.valueOf(allocation.get(idx_ta).doubleValue() + q));\n" + |
6396 |
" }\n" + |
6397 |
"}\n" + |
6398 |
"}\n"; |
6399 |
formatSource(source, |
6400 |
"public class Test {\n" + |
6401 |
" public void a() {\n" + |
6402 |
" if (true) {\n" + |
6403 |
" allocation.add(idx_ta + 1, Double.valueOf(allocation.get(idx_ta)\n" + |
6404 |
" .doubleValue()\n" + |
6405 |
" + q));\n" + |
6406 |
" }\n" + |
6407 |
" }\n" + |
6408 |
"}\n" |
6409 |
); |
6410 |
} |
6411 |
// wksp1 |
6412 |
public void testBug313524_wksp1_01() throws JavaModelException { |
6413 |
this.formatterPrefs.keep_nested_expression_on_one_line = true; |
6414 |
String source = |
6415 |
"public class X01 {\n" + |
6416 |
" private void reportError(String name) throws ParseError {\n" + |
6417 |
" throw new ParseError(MessageFormat.format(AntDTDSchemaMessages.getString(\"NfmParser.Ambiguous\"), new String[]{name})); //$NON-NLS-1$\n" + |
6418 |
" }\n" + |
6419 |
"}\n"; |
6420 |
formatSource(source, |
6421 |
"public class X01 {\n" + |
6422 |
" private void reportError(String name) throws ParseError {\n" + |
6423 |
" throw new ParseError(MessageFormat.format(AntDTDSchemaMessages\n" + |
6424 |
" .getString(\"NfmParser.Ambiguous\"), new String[] { name })); //$NON-NLS-1$\n" + |
6425 |
" }\n" + |
6426 |
"}\n" |
6427 |
); |
6428 |
} |
6429 |
public void testBug313524_wksp1_02() throws JavaModelException { |
6430 |
this.formatterPrefs.keep_nested_expression_on_one_line = true; |
6431 |
String source = |
6432 |
"public class X02 {\n" + |
6433 |
" private void parseBuildFile(Project project) {\n" + |
6434 |
" if (!buildFile.exists()) {\n" + |
6435 |
" throw new BuildException(MessageFormat.format(InternalAntMessages.getString(\"InternalAntRunner.Buildfile__{0}_does_not_exist_!_1\"), //$NON-NLS-1$\n" + |
6436 |
" new String[]{buildFile.getAbsolutePath()}));\n" + |
6437 |
" }\n" + |
6438 |
" if (!buildFile.isFile()) {\n" + |
6439 |
" throw new BuildException(MessageFormat.format(InternalAntMessages.getString(\"InternalAntRunner.Buildfile__{0}_is_not_a_file_1\"), //$NON-NLS-1$\n" + |
6440 |
" new String[]{buildFile.getAbsolutePath()}));\n" + |
6441 |
" }\n" + |
6442 |
" }\n" + |
6443 |
"}\n"; |
6444 |
formatSource(source, |
6445 |
"public class X02 {\n" + |
6446 |
" private void parseBuildFile(Project project) {\n" + |
6447 |
" if (!buildFile.exists()) {\n" + |
6448 |
" throw new BuildException(\n" + |
6449 |
" MessageFormat\n" + |
6450 |
" .format(InternalAntMessages\n" + |
6451 |
" .getString(\"InternalAntRunner.Buildfile__{0}_does_not_exist_!_1\"), //$NON-NLS-1$\n" + |
6452 |
" new String[] { buildFile.getAbsolutePath() }));\n" + |
6453 |
" }\n" + |
6454 |
" if (!buildFile.isFile()) {\n" + |
6455 |
" throw new BuildException(\n" + |
6456 |
" MessageFormat\n" + |
6457 |
" .format(InternalAntMessages\n" + |
6458 |
" .getString(\"InternalAntRunner.Buildfile__{0}_is_not_a_file_1\"), //$NON-NLS-1$\n" + |
6459 |
" new String[] { buildFile.getAbsolutePath() }));\n" + |
6460 |
" }\n" + |
6461 |
" }\n" + |
6462 |
"}\n" |
6463 |
); |
6464 |
} |
6465 |
public void testBug313524_wksp1_03() throws JavaModelException { |
6466 |
this.formatterPrefs.keep_nested_expression_on_one_line = true; |
6467 |
String source = |
6468 |
"public class X03 {\n" + |
6469 |
"\n" + |
6470 |
" protected void foo() {\n" + |
6471 |
" printTargets(project, subNames, null, InternalAntMessages.getString(\"InternalAntRunner.Subtargets__5\"), 0); //$NON-NLS-1$\n" + |
6472 |
" }\n" + |
6473 |
"}\n"; |
6474 |
formatSource(source, |
6475 |
"public class X03 {\n" + |
6476 |
"\n" + |
6477 |
" protected void foo() {\n" + |
6478 |
" printTargets(project, subNames, null, InternalAntMessages\n" + |
6479 |
" .getString(\"InternalAntRunner.Subtargets__5\"), 0); //$NON-NLS-1$\n" + |
6480 |
" }\n" + |
6481 |
"}\n" |
6482 |
); |
6483 |
} |
6484 |
public void testBug313524_wksp1_04() throws JavaModelException { |
6485 |
this.formatterPrefs.keep_nested_expression_on_one_line = true; |
6486 |
String source = |
6487 |
"public class X04 {\n" + |
6488 |
" void foo() {\n" + |
6489 |
" if (AntUIPlugin.getDefault().getPreferenceStore().getBoolean(IAntUIPreferenceConstants.OUTLINE_LINK_WITH_EDITOR)) {\n" + |
6490 |
" synchronizeOutlinePage(node, true);\n" + |
6491 |
" }\n" + |
6492 |
" }\n" + |
6493 |
"}\n"; |
6494 |
formatSource(source, |
6495 |
"public class X04 {\n" + |
6496 |
" void foo() {\n" + |
6497 |
" if (AntUIPlugin.getDefault().getPreferenceStore().getBoolean(\n" + |
6498 |
" IAntUIPreferenceConstants.OUTLINE_LINK_WITH_EDITOR)) {\n" + |
6499 |
" synchronizeOutlinePage(node, true);\n" + |
6500 |
" }\n" + |
6501 |
" }\n" + |
6502 |
"}\n" |
6503 |
); |
6504 |
} |
6505 |
public void testBug313524_wksp1_05() throws JavaModelException { |
6506 |
this.formatterPrefs.keep_nested_expression_on_one_line = true; |
6507 |
String source = |
6508 |
"public class X05 {\n" + |
6509 |
"void foo() {\n" + |
6510 |
" if (false && AntUIPlugin.getDefault().getPreferenceStore().getBoolean(AntEditorPreferenceConstants.TEMPLATES_USE_CODEFORMATTER)) {\n" + |
6511 |
" }\n" + |
6512 |
"}\n" + |
6513 |
"}\n"; |
6514 |
formatSource(source, |
6515 |
"public class X05 {\n" + |
6516 |
" void foo() {\n" + |
6517 |
" if (false && AntUIPlugin.getDefault().getPreferenceStore().getBoolean(\n" + |
6518 |
" AntEditorPreferenceConstants.TEMPLATES_USE_CODEFORMATTER)) {\n" + |
6519 |
" }\n" + |
6520 |
" }\n" + |
6521 |
"}\n" |
6522 |
); |
6523 |
} |
6524 |
// TODO Improve this formatting as it let the message send argument in one line over the max width |
6525 |
public void testBug313524_wksp1_06() throws JavaModelException { |
6526 |
this.formatterPrefs.keep_nested_expression_on_one_line = true; |
6527 |
String source = |
6528 |
"public class X06 {\n" + |
6529 |
" public void launch() {\n" + |
6530 |
" try {\n" + |
6531 |
" if ((javaProject == null) || !javaProject.exists()) {\n" + |
6532 |
" abort(PDEPlugin________.getResourceString(\"JUnitLaunchConfig_____\"), null, IJavaLaunchConfigurationConstants.ERR_NOT_A_JAVA_PROJECT);\n" + |
6533 |
" }\n" + |
6534 |
" } catch (CoreException e) {\n" + |
6535 |
" }\n" + |
6536 |
" }\n" + |
6537 |
"}\n"; |
6538 |
formatSource(source, |
6539 |
"public class X06 {\n" + |
6540 |
" public void launch() {\n" + |
6541 |
" try {\n" + |
6542 |
" if ((javaProject == null) || !javaProject.exists()) {\n" + |
6543 |
" abort(PDEPlugin________\n" + |
6544 |
" .getResourceString(\"JUnitLaunchConfig_____\"),\n" + |
6545 |
" null,\n" + |
6546 |
" IJavaLaunchConfigurationConstants.ERR_NOT_A_JAVA_PROJECT);\n" + |
6547 |
" }\n" + |
6548 |
" } catch (CoreException e) {\n" + |
6549 |
" }\n" + |
6550 |
" }\n" + |
6551 |
"}\n" |
6552 |
); |
6553 |
} |
6554 |
public void testBug313524_wksp1_07() throws JavaModelException { |
6555 |
this.formatterPrefs.keep_nested_expression_on_one_line = true; |
6556 |
String source = |
6557 |
"public class X07 {\n" + |
6558 |
" void foo() {\n" + |
6559 |
" if (true) {\n" + |
6560 |
" configureAntObject(result, element, task, task.getTaskName(), InternalCoreAntMessages.getString(\"AntCorePreferences.No_library_for_task\")); //$NON-NLS-1$\n" + |
6561 |
" }\n" + |
6562 |
" }\n" + |
6563 |
"}\n"; |
6564 |
formatSource(source, |
6565 |
"public class X07 {\n" + |
6566 |
" void foo() {\n" + |
6567 |
" if (true) {\n" + |
6568 |
" configureAntObject(\n" + |
6569 |
" result,\n" + |
6570 |
" element,\n" + |
6571 |
" task,\n" + |
6572 |
" task.getTaskName(),\n" + |
6573 |
" InternalCoreAntMessages\n" + |
6574 |
" .getString(\"AntCorePreferences.No_library_for_task\")); //$NON-NLS-1$\n" + |
6575 |
" }\n" + |
6576 |
" }\n" + |
6577 |
"}\n" |
6578 |
); |
6579 |
} |
6580 |
public void testBug313524_wksp1_08() throws JavaModelException { |
6581 |
this.formatterPrefs.keep_nested_expression_on_one_line = true; |
6582 |
String source = |
6583 |
"public class X08 {\n" + |
6584 |
" public void foo() {\n" + |
6585 |
" if (true) {\n" + |
6586 |
" IStatus status= new Status(IStatus.ERROR, AntCorePlugin.PI_ANTCORE, AntCorePlugin.ERROR_RUNNING_BUILD, MessageFormat.format(InternalCoreAntMessages.getString(\"AntRunner.Already_in_progess\"), new String[]{buildFileLocation}), null); //$NON-NLS-1$\n" + |
6587 |
" }\n" + |
6588 |
" }\n" + |
6589 |
"}\n"; |
6590 |
formatSource(source, |
6591 |
"public class X08 {\n" + |
6592 |
" public void foo() {\n" + |
6593 |
" if (true) {\n" + |
6594 |
" IStatus status = new Status(\n" + |
6595 |
" IStatus.ERROR,\n" + |
6596 |
" AntCorePlugin.PI_ANTCORE,\n" + |
6597 |
" AntCorePlugin.ERROR_RUNNING_BUILD,\n" + |
6598 |
" MessageFormat\n" + |
6599 |
" .format(InternalCoreAntMessages\n" + |
6600 |
" .getString(\"AntRunner.Already_in_progess\"), new String[] { buildFileLocation }), null); //$NON-NLS-1$\n" + |
6601 |
" }\n" + |
6602 |
" }\n" + |
6603 |
"}\n" |
6604 |
); |
6605 |
} |
6606 |
public void testBug313524_wksp1_09() throws JavaModelException { |
6607 |
this.formatterPrefs.keep_nested_expression_on_one_line = true; |
6608 |
String source = |
6609 |
"public class X09 {\n" + |
6610 |
" void foo() {\n" + |
6611 |
" if (true) {\n" + |
6612 |
" String secondFileName = secondDirectoryAbsolutePath + File.separator + currentFile.substring(firstDirectoryAbsolutePath.length() + 1);\n" + |
6613 |
" }\n" + |
6614 |
" }\n" + |
6615 |
"}\n"; |
6616 |
formatSource(source, |
6617 |
"public class X09 {\n" + |
6618 |
" void foo() {\n" + |
6619 |
" if (true) {\n" + |
6620 |
" String secondFileName = secondDirectoryAbsolutePath\n" + |
6621 |
" + File.separator\n" + |
6622 |
" + currentFile\n" + |
6623 |
" .substring(firstDirectoryAbsolutePath.length() + 1);\n" + |
6624 |
" }\n" + |
6625 |
" }\n" + |
6626 |
"}\n" |
6627 |
); |
6628 |
} |
6629 |
public void testBug313524_wksp1_10() throws JavaModelException { |
6630 |
this.formatterPrefs.keep_nested_expression_on_one_line = true; |
6631 |
String source = |
6632 |
"public class X10 {\n" + |
6633 |
" void foo() {\n" + |
6634 |
" if (true) {\n" + |
6635 |
" if (true) {\n" + |
6636 |
" throw new BuildException(InternalAntMessages.getString(\"InternalAntRunner.Could_not_load_the_version_information._10\")); //$NON-NLS-1$\n" + |
6637 |
" }\n" + |
6638 |
" }\n" + |
6639 |
" }\n" + |
6640 |
"}\n"; |
6641 |
formatSource(source, |
6642 |
"public class X10 {\n" + |
6643 |
" void foo() {\n" + |
6644 |
" if (true) {\n" + |
6645 |
" if (true) {\n" + |
6646 |
" throw new BuildException(\n" + |
6647 |
" InternalAntMessages\n" + |
6648 |
" .getString(\"InternalAntRunner.Could_not_load_the_version_information._10\")); //$NON-NLS-1$\n" + |
6649 |
" }\n" + |
6650 |
" }\n" + |
6651 |
" }\n" + |
6652 |
"}\n" |
6653 |
); |
6654 |
} |
6655 |
public void testBug313524_wksp1_11() throws JavaModelException { |
6656 |
this.formatterPrefs.keep_nested_expression_on_one_line = true; |
6657 |
String source = |
6658 |
"public class X11 {\n" + |
6659 |
" private void antFileNotFound() {\n" + |
6660 |
" reportError(AntLaunchConfigurationMessages.getString(\"AntLaunchShortcut.Unable\"), null); //$NON-NLS-1$ \n" + |
6661 |
" }\n" + |
6662 |
"}\n"; |
6663 |
formatSource(source, |
6664 |
"public class X11 {\n" + |
6665 |
" private void antFileNotFound() {\n" + |
6666 |
" reportError(AntLaunchConfigurationMessages\n" + |
6667 |
" .getString(\"AntLaunchShortcut.Unable\"), null); //$NON-NLS-1$ \n" + |
6668 |
" }\n" + |
6669 |
"}\n" |
6670 |
); |
6671 |
} |
6672 |
public void testBug313524_wksp1_12() throws JavaModelException { |
6673 |
this.formatterPrefs.keep_nested_expression_on_one_line = true; |
6674 |
String source = |
6675 |
"public class X12 {\n" + |
6676 |
" void foo() {\n" + |
6677 |
" if (this.fTests.size() == 0) {\n" + |
6678 |
" this.addTest(TestSuite\n" + |
6679 |
" .warning(\"No tests found in \" + theClass.getName())); //$NON-NLS-1$\n" + |
6680 |
" }\n" + |
6681 |
" }\n" + |
6682 |
"}\n"; |
6683 |
formatSource(source, |
6684 |
"public class X12 {\n" + |
6685 |
" void foo() {\n" + |
6686 |
" if (this.fTests.size() == 0) {\n" + |
6687 |
" this.addTest(TestSuite\n" + |
6688 |
" .warning(\"No tests found in \" + theClass.getName())); //$NON-NLS-1$\n" + |
6689 |
" }\n" + |
6690 |
" }\n" + |
6691 |
"}\n" |
6692 |
); |
6693 |
} |
6694 |
|
6150 |
} |
6695 |
} |