Lines 5275-5278
Link Here
|
5275 |
); |
5275 |
); |
5276 |
} |
5276 |
} |
5277 |
|
5277 |
|
|
|
5278 |
/** |
5279 |
* @bug 304529: [formatter] NPE when either the disabling or the enabling tag is not defined |
5280 |
* @test Verify that having an empty disabling or enabling is now accepted by the formatter |
5281 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=304529" |
5282 |
*/ |
5283 |
public void testBug304529() { |
5284 |
this.formatterPrefs.disabling_tag = "off".toCharArray(); |
5285 |
this.formatterPrefs.enabling_tag = null; |
5286 |
String source = |
5287 |
"/* off */\n" + |
5288 |
"public class X01 {\n" + |
5289 |
"void foo( ) { \n" + |
5290 |
" // unformatted area\n" + |
5291 |
"}\n" + |
5292 |
"}\n"; |
5293 |
formatSource(source); |
5294 |
} |
5295 |
public void testBug304529b() { |
5296 |
this.formatterPrefs.disabling_tag = null; |
5297 |
this.formatterPrefs.enabling_tag = "on".toCharArray(); |
5298 |
String source = |
5299 |
"/* on */\n" + |
5300 |
"public class X01 {\n" + |
5301 |
"void foo( ) { \n" + |
5302 |
" // formatted area\n" + |
5303 |
"}\n" + |
5304 |
"}\n"; |
5305 |
formatSource(source, |
5306 |
"/* on */\n" + |
5307 |
"public class X01 {\n" + |
5308 |
" void foo() {\n" + |
5309 |
" // formatted area\n" + |
5310 |
" }\n" + |
5311 |
"}\n" |
5312 |
); |
5313 |
} |
5314 |
public void testBug304529c() { |
5315 |
this.formatterPrefs = null; |
5316 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_DISABLING_TAG, "off"); |
5317 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_ENABLING_TAG, ""); |
5318 |
String source = |
5319 |
"/* off */\n" + |
5320 |
"public class X01 {\n" + |
5321 |
"void foo( ) { \n" + |
5322 |
" // unformatted area\n" + |
5323 |
"}\n" + |
5324 |
"}\n"; |
5325 |
formatSource(source); |
5326 |
} |
5327 |
public void testBug304529d() { |
5328 |
this.formatterPrefs = null; |
5329 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_DISABLING_TAG, ""); |
5330 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_ENABLING_TAG, "on"); |
5331 |
String source = |
5332 |
"/* on */\n" + |
5333 |
"public class X01 {\n" + |
5334 |
"void foo( ) { \n" + |
5335 |
" // formatted area\n" + |
5336 |
"}\n" + |
5337 |
"}\n"; |
5338 |
formatSource(source, |
5339 |
"/* on */\n" + |
5340 |
"public class X01 {\n" + |
5341 |
" void foo() {\n" + |
5342 |
" // formatted area\n" + |
5343 |
" }\n" + |
5344 |
"}\n" |
5345 |
); |
5346 |
} |
5347 |
public void testBug304529e() { |
5348 |
this.formatterPrefs = null; |
5349 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_DISABLING_TAG, "off"); |
5350 |
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_ENABLING_TAG, "on"); |
5351 |
String source = |
5352 |
"public class X01 {\n" + |
5353 |
"/* off */\n" + |
5354 |
"void foo( ) { \n" + |
5355 |
" // unformatted area\n" + |
5356 |
"}\n" + |
5357 |
"/* on */\n" + |
5358 |
"void bar( ) { \n" + |
5359 |
" // formatted area\n" + |
5360 |
"}\n" + |
5361 |
"}\n"; |
5362 |
formatSource(source, |
5363 |
"public class X01 {\n" + |
5364 |
"/* off */\n" + |
5365 |
"void foo( ) { \n" + |
5366 |
" // unformatted area\n" + |
5367 |
"}\n" + |
5368 |
"/* on */\n" + |
5369 |
" void bar() {\n" + |
5370 |
" // formatted area\n" + |
5371 |
" }\n" + |
5372 |
"}\n" |
5373 |
); |
5374 |
} |
5375 |
|
5278 |
} |
5376 |
} |