1 19 package org.netbeans.api.java.source.gen; 20 21 import com.sun.source.tree.ClassTree; 22 import com.sun.source.tree.CompilationUnitTree; 23 import com.sun.source.tree.IdentifierTree; 24 import com.sun.source.tree.Tree; 25 import java.io.File ; 26 import java.io.IOException ; 27 import org.netbeans.api.java.source.CancellableTask; 28 import org.netbeans.api.java.source.JavaSource; 29 import static org.netbeans.api.java.source.JavaSource.*; 30 import org.netbeans.api.java.source.TestUtilities; 31 import org.netbeans.api.java.source.TreeMaker; 32 import org.netbeans.api.java.source.WorkingCopy; 33 import org.netbeans.junit.NbTestSuite; 34 35 40 public class ClassImplementsTest extends GeneratorTestMDRCompat { 41 42 43 public ClassImplementsTest(String testName) { 44 super(testName); 45 } 46 47 public static NbTestSuite suite() { 48 NbTestSuite suite = new NbTestSuite(); 49 suite.addTestSuite(ClassImplementsTest.class); 50 return suite; 66 } 67 68 public void testAddFirst() throws Exception { 69 testFile = new File (getWorkDir(), "Test.java"); 70 TestUtilities.copyStringToFile(testFile, 71 "package hierbas.del.litoral;\n\n" + 72 "import java.util.*;\n\n" + 73 "public class Test {\n" + 74 " public void taragui() {\n" + 75 " }\n" + 76 "}\n" 77 ); 78 String golden = 79 "package hierbas.del.litoral;\n\n" + 80 "import java.util.*;\n\n" + 81 "public class Test implements List {\n" + 82 " public void taragui() {\n" + 83 " }\n" + 84 "}\n"; 85 86 JavaSource src = getJavaSource(testFile); 87 CancellableTask task = new CancellableTask<WorkingCopy>() { 88 89 public void run(WorkingCopy workingCopy) throws IOException { 90 workingCopy.toPhase(Phase.RESOLVED); 91 CompilationUnitTree cut = workingCopy.getCompilationUnit(); 92 TreeMaker make = workingCopy.getTreeMaker(); 93 for (Tree typeDecl : cut.getTypeDecls()) { 94 ClassTree clazz = (ClassTree) typeDecl; 96 ClassTree copy = make.addClassImplementsClause( 97 clazz, make.Identifier("List") 98 ); 99 workingCopy.rewrite(clazz, copy); 100 } 101 } 102 103 public void cancel() { 104 throw new UnsupportedOperationException ("Not supported yet."); 105 } 106 }; 107 src.runModificationTask(task).commit(); 108 String res = TestUtilities.copyFileToString(testFile); 109 System.err.println(res); 110 assertEquals(golden, res); 111 } 112 113 public void testAddFirstTwo() throws Exception { 114 testFile = new File (getWorkDir(), "Test.java"); 115 TestUtilities.copyStringToFile(testFile, 116 "package hierbas.del.litoral;\n\n" + 117 "import java.io.*;\n\n" + 118 "public class Test extends Object {\n" + 119 " public void taragui() {\n" + 120 " }\n" + 121 "}\n" 122 ); 123 String golden = 124 "package hierbas.del.litoral;\n\n" + 125 "import java.io.*;\n\n" + 126 "public class Test extends Object implements Collection, List {\n" + 127 " public void taragui() {\n" + 128 " }\n" + 129 "}\n"; 130 131 JavaSource src = getJavaSource(testFile); 132 CancellableTask task = new CancellableTask<WorkingCopy>() { 133 134 public void run(WorkingCopy workingCopy) throws IOException { 135 workingCopy.toPhase(Phase.RESOLVED); 136 CompilationUnitTree cut = workingCopy.getCompilationUnit(); 137 TreeMaker make = workingCopy.getTreeMaker(); 138 for (Tree typeDecl : cut.getTypeDecls()) { 139 ClassTree clazz = (ClassTree) typeDecl; 141 ClassTree copy = make.addClassImplementsClause( 142 clazz, make.Identifier("Collection") 143 ); 144 copy = make.addClassImplementsClause( 145 copy, make.Identifier("List") 146 ); 147 workingCopy.rewrite(clazz, copy); 148 } 149 } 150 151 public void cancel() { 152 throw new UnsupportedOperationException ("Not supported yet."); 153 } 154 }; 155 src.runModificationTask(task).commit(); 156 String res = TestUtilities.copyFileToString(testFile); 157 System.err.println(res); 158 assertEquals(golden, res); 159 } 160 161 public void testRemoveAll() throws Exception { 162 testFile = new File (getWorkDir(), "Test.java"); 163 TestUtilities.copyStringToFile(testFile, 164 "package hierbas.del.litoral;\n\n" + 165 "import java.io.*;\n\n" + 166 "public class Test implements Serializable, List, Collection {\n" + 167 " public void taragui() {\n" + 168 " }\n" + 169 "}\n" 170 ); 171 String golden = 172 "package hierbas.del.litoral;\n\n" + 173 "import java.io.*;\n\n" + 174 "public class Test {\n" + 175 " public void taragui() {\n" + 176 " }\n" + 177 "}\n"; 178 179 JavaSource src = getJavaSource(testFile); 180 CancellableTask task = new CancellableTask<WorkingCopy>() { 181 182 public void run(WorkingCopy workingCopy) throws IOException { 183 workingCopy.toPhase(Phase.RESOLVED); 184 CompilationUnitTree cut = workingCopy.getCompilationUnit(); 185 TreeMaker make = workingCopy.getTreeMaker(); 186 for (Tree typeDecl : cut.getTypeDecls()) { 187 ClassTree clazz = (ClassTree) typeDecl; 189 ClassTree copy = make.removeClassImplementsClause(clazz, 0); 190 copy = make.removeClassImplementsClause(copy, 0); 191 copy = make.removeClassImplementsClause(copy, 0); 192 workingCopy.rewrite(clazz, copy); 193 } 194 } 195 196 public void cancel() { 197 throw new UnsupportedOperationException ("Not supported yet."); 198 } 199 }; 200 src.runModificationTask(task).commit(); 201 String res = TestUtilities.copyFileToString(testFile); 202 System.err.println(res); 203 assertEquals(golden, res); 204 } 205 206 public void testAddThirdToExisting() throws Exception { 207 testFile = new File (getWorkDir(), "Test.java"); 208 TestUtilities.copyStringToFile(testFile, 209 "package hierbas.del.litoral;\n\n" + 210 "import java.util.*;\n\n" + 211 "public class Test implements List, Serializable {\n" + 212 " public void taragui() {\n" + 213 " }\n" + 214 "}\n" 215 ); 216 String golden = 217 "package hierbas.del.litoral;\n\n" + 218 "import java.util.*;\n\n" + 219 "public class Test implements List, Serializable, Collection {\n" + 220 " public void taragui() {\n" + 221 " }\n" + 222 "}\n"; 223 224 JavaSource src = getJavaSource(testFile); 225 CancellableTask task = new CancellableTask<WorkingCopy>() { 226 227 public void run(WorkingCopy workingCopy) throws IOException { 228 workingCopy.toPhase(Phase.RESOLVED); 229 CompilationUnitTree cut = workingCopy.getCompilationUnit(); 230 TreeMaker make = workingCopy.getTreeMaker(); 231 for (Tree typeDecl : cut.getTypeDecls()) { 232 ClassTree clazz = (ClassTree) typeDecl; 234 ClassTree copy = make.addClassImplementsClause( 235 clazz, make.Identifier("Collection") 236 ); 237 workingCopy.rewrite(clazz, copy); 238 } 239 } 240 241 public void cancel() { 242 throw new UnsupportedOperationException ("Not supported yet."); 243 } 244 }; 245 src.runModificationTask(task).commit(); 246 String res = TestUtilities.copyFileToString(testFile); 247 System.err.println(res); 248 assertEquals(golden, res); 249 } 250 251 public void testAddFirstToExisting() throws Exception { 252 testFile = new File (getWorkDir(), "Test.java"); 253 TestUtilities.copyStringToFile(testFile, 254 "package hierbas.del.litoral;\n\n" + 255 "import java.util.*;\n\n" + 256 "public class Test implements List {\n" + 257 " public void taragui() {\n" + 258 " }\n" + 259 "}\n" 260 ); 261 String golden = 262 "package hierbas.del.litoral;\n\n" + 263 "import java.util.*;\n\n" + 264 "public class Test implements Serializable, List {\n" + 265 " public void taragui() {\n" + 266 " }\n" + 267 "}\n"; 268 269 JavaSource src = getJavaSource(testFile); 270 CancellableTask task = new CancellableTask<WorkingCopy>() { 271 272 public void run(WorkingCopy workingCopy) throws IOException { 273 workingCopy.toPhase(Phase.RESOLVED); 274 CompilationUnitTree cut = workingCopy.getCompilationUnit(); 275 TreeMaker make = workingCopy.getTreeMaker(); 276 for (Tree typeDecl : cut.getTypeDecls()) { 277 ClassTree clazz = (ClassTree) typeDecl; 279 ClassTree copy = make.insertClassImplementsClause( 280 clazz, 0, make.Identifier("Serializable") 281 ); 282 workingCopy.rewrite(clazz, copy); 283 } 284 } 285 286 public void cancel() { 287 throw new UnsupportedOperationException ("Not supported yet."); 288 } 289 }; 290 src.runModificationTask(task).commit(); 291 String res = TestUtilities.copyFileToString(testFile); 292 System.err.println(res); 293 assertEquals(golden, res); 294 } 295 296 public void testRemoveMid() throws Exception { 297 testFile = new File (getWorkDir(), "Test.java"); 298 TestUtilities.copyStringToFile(testFile, 299 "package hierbas.del.litoral;\n\n" + 300 "import java.util.*;\n\n" + 301 "public class Test implements List, Serializable, Collection {\n" + 302 " public void taragui() {\n" + 303 " }\n" + 304 "}\n" 305 ); 306 String golden = 307 "package hierbas.del.litoral;\n\n" + 308 "import java.util.*;\n\n" + 309 "public class Test implements List, Collection {\n" + 310 " public void taragui() {\n" + 311 " }\n" + 312 "}\n"; 313 314 JavaSource src = getJavaSource(testFile); 315 CancellableTask task = new CancellableTask<WorkingCopy>() { 316 317 public void run(WorkingCopy workingCopy) throws IOException { 318 workingCopy.toPhase(Phase.RESOLVED); 319 CompilationUnitTree cut = workingCopy.getCompilationUnit(); 320 TreeMaker make = workingCopy.getTreeMaker(); 321 for (Tree typeDecl : cut.getTypeDecls()) { 322 ClassTree clazz = (ClassTree) typeDecl; 324 ClassTree copy = make.removeClassImplementsClause(clazz, 1); 325 workingCopy.rewrite(clazz, copy); 326 } 327 } 328 329 public void cancel() { 330 throw new UnsupportedOperationException ("Not supported yet."); 331 } 332 }; 333 src.runModificationTask(task).commit(); 334 String res = TestUtilities.copyFileToString(testFile); 335 System.err.println(res); 336 assertEquals(golden, res); 337 } 338 339 public void testRemoveFirst() throws Exception { 340 testFile = new File (getWorkDir(), "Test.java"); 341 TestUtilities.copyStringToFile(testFile, 342 "package hierbas.del.litoral;\n\n" + 343 "import java.util.*;\n\n" + 344 "public class Test implements List {\n" + 345 " public void taragui() {\n" + 346 " }\n" + 347 "}\n" 348 ); 349 String golden = 350 "package hierbas.del.litoral;\n\n" + 351 "import java.util.*;\n\n" + 352 "public class Test {\n" + 353 " public void taragui() {\n" + 354 " }\n" + 355 "}\n"; 356 357 JavaSource src = getJavaSource(testFile); 358 CancellableTask task = new CancellableTask<WorkingCopy>() { 359 360 public void run(WorkingCopy workingCopy) throws IOException { 361 workingCopy.toPhase(Phase.RESOLVED); 362 CompilationUnitTree cut = workingCopy.getCompilationUnit(); 363 TreeMaker make = workingCopy.getTreeMaker(); 364 for (Tree typeDecl : cut.getTypeDecls()) { 365 ClassTree clazz = (ClassTree) typeDecl; 367 ClassTree copy = make.removeClassImplementsClause(clazz, 0); 368 workingCopy.rewrite(clazz, copy); 369 } 370 } 371 372 public void cancel() { 373 throw new UnsupportedOperationException ("Not supported yet."); 374 } 375 }; 376 src.runModificationTask(task).commit(); 377 String res = TestUtilities.copyFileToString(testFile); 378 System.err.println(res); 379 assertEquals(golden, res); 380 } 381 382 public void testRemoveLast() throws Exception { 383 testFile = new File (getWorkDir(), "Test.java"); 384 TestUtilities.copyStringToFile(testFile, 385 "package hierbas.del.litoral;\n\n" + 386 "import java.util.*;\n\n" + 387 "public class Test implements List, Collection, Serializable {\n" + 388 " public void taragui() {\n" + 389 " }\n" + 390 "}\n" 391 ); 392 String golden = 393 "package hierbas.del.litoral;\n\n" + 394 "import java.util.*;\n\n" + 395 "public class Test implements List, Collection {\n" + 396 " public void taragui() {\n" + 397 " }\n" + 398 "}\n"; 399 400 JavaSource src = getJavaSource(testFile); 401 CancellableTask task = new CancellableTask<WorkingCopy>() { 402 403 public void run(WorkingCopy workingCopy) throws IOException { 404 workingCopy.toPhase(Phase.RESOLVED); 405 CompilationUnitTree cut = workingCopy.getCompilationUnit(); 406 TreeMaker make = workingCopy.getTreeMaker(); 407 for (Tree typeDecl : cut.getTypeDecls()) { 408 ClassTree clazz = (ClassTree) typeDecl; 410 ClassTree copy = make.removeClassImplementsClause(clazz, 2); 411 workingCopy.rewrite(clazz, copy); 412 } 413 } 414 415 public void cancel() { 416 throw new UnsupportedOperationException ("Not supported yet."); 417 } 418 }; 419 src.runModificationTask(task).commit(); 420 String res = TestUtilities.copyFileToString(testFile); 421 System.err.println(res); 422 assertEquals(golden, res); 423 } 424 425 public void testRemoveJust() throws Exception { 426 testFile = new File (getWorkDir(), "Test.java"); 427 TestUtilities.copyStringToFile(testFile, 428 "package hierbas.del.litoral;\n\n" + 429 "import java.util.*;\n\n" + 430 "public class Test implements List, Collection {\n" + 431 " public void taragui() {\n" + 432 " }\n" + 433 "}\n" 434 ); 435 String golden = 436 "package hierbas.del.litoral;\n\n" + 437 "import java.util.*;\n\n" + 438 "public class Test {\n" + 439 " public void taragui() {\n" + 440 " }\n" + 441 "}\n"; 442 443 JavaSource src = getJavaSource(testFile); 444 CancellableTask task = new CancellableTask<WorkingCopy>() { 445 446 public void run(WorkingCopy workingCopy) throws IOException { 447 workingCopy.toPhase(Phase.RESOLVED); 448 CompilationUnitTree cut = workingCopy.getCompilationUnit(); 449 TreeMaker make = workingCopy.getTreeMaker(); 450 for (Tree typeDecl : cut.getTypeDecls()) { 451 ClassTree clazz = (ClassTree) typeDecl; 453 ClassTree copy = make.removeClassImplementsClause(clazz, 1); 454 copy = make.removeClassImplementsClause(copy, 0); 455 workingCopy.rewrite(clazz, copy); 456 } 457 } 458 459 public void cancel() { 460 throw new UnsupportedOperationException ("Not supported yet."); 461 } 462 }; 463 src.runModificationTask(task).commit(); 464 String res = TestUtilities.copyFileToString(testFile); 465 System.err.println(res); 466 assertEquals(golden, res); 467 } 468 469 public void testAddFirstTypeParam() throws Exception { 470 testFile = new File (getWorkDir(), "Test.java"); 471 TestUtilities.copyStringToFile(testFile, 472 "package hierbas.del.litoral;\n\n" + 473 "import java.util.*;\n\n" + 474 "public class Test<E> {\n" + 475 " public void taragui() {\n" + 476 " }\n" + 477 "}\n" 478 ); 479 String golden = 480 "package hierbas.del.litoral;\n\n" + 481 "import java.util.*;\n\n" + 482 "public class Test<E> implements List {\n" + 483 " public void taragui() {\n" + 484 " }\n" + 485 "}\n"; 486 487 JavaSource src = getJavaSource(testFile); 488 CancellableTask task = new CancellableTask<WorkingCopy>() { 489 490 public void run(WorkingCopy workingCopy) throws IOException { 491 workingCopy.toPhase(Phase.RESOLVED); 492 CompilationUnitTree cut = workingCopy.getCompilationUnit(); 493 TreeMaker make = workingCopy.getTreeMaker(); 494 for (Tree typeDecl : cut.getTypeDecls()) { 495 ClassTree clazz = (ClassTree) typeDecl; 497 ClassTree copy = make.addClassImplementsClause( 498 clazz, make.Identifier("List") 499 ); 500 workingCopy.rewrite(clazz, copy); 501 } 502 } 503 504 public void cancel() { 505 throw new UnsupportedOperationException ("Not supported yet."); 506 } 507 }; 508 src.runModificationTask(task).commit(); 509 String res = TestUtilities.copyFileToString(testFile); 510 System.err.println(res); 511 assertEquals(golden, res); 512 } 513 514 public void testRemoveAllImplTypeParam() throws Exception { 515 testFile = new File (getWorkDir(), "Test.java"); 516 TestUtilities.copyStringToFile(testFile, 517 "package hierbas.del.litoral;\n\n" + 518 "import java.util.*;\n\n" + 519 "public class Test<E> implements List {\n" + 520 " public void taragui() {\n" + 521 " }\n" + 522 "}\n" 523 ); 524 String golden = 525 "package hierbas.del.litoral;\n\n" + 526 "import java.util.*;\n\n" + 527 "public class Test<E> {\n" + 528 " public void taragui() {\n" + 529 " }\n" + 530 "}\n"; 531 532 JavaSource src = getJavaSource(testFile); 533 CancellableTask task = new CancellableTask<WorkingCopy>() { 534 535 public void run(WorkingCopy workingCopy) throws IOException { 536 workingCopy.toPhase(Phase.RESOLVED); 537 CompilationUnitTree cut = workingCopy.getCompilationUnit(); 538 TreeMaker make = workingCopy.getTreeMaker(); 539 for (Tree typeDecl : cut.getTypeDecls()) { 540 ClassTree clazz = (ClassTree) typeDecl; 542 ClassTree copy = make.removeClassImplementsClause( 543 clazz, 0 544 ); 545 workingCopy.rewrite(clazz, copy); 546 } 547 } 548 549 public void cancel() { 550 throw new UnsupportedOperationException ("Not supported yet."); 551 } 552 }; 553 src.runModificationTask(task).commit(); 554 String res = TestUtilities.copyFileToString(testFile); 555 System.err.println(res); 556 assertEquals(golden, res); 557 } 558 559 public void testAddFirstImplExtends() throws Exception { 560 testFile = new File (getWorkDir(), "Test.java"); 561 TestUtilities.copyStringToFile(testFile, 562 "package hierbas.del.litoral;\n\n" + 563 "import java.util.*;\n\n" + 564 "public class Test<E> extends Object {\n" + 565 " public void taragui() {\n" + 566 " }\n" + 567 "}\n" 568 ); 569 String golden = 570 "package hierbas.del.litoral;\n\n" + 571 "import java.util.*;\n\n" + 572 "public class Test<E> extends Object implements List {\n" + 573 " public void taragui() {\n" + 574 " }\n" + 575 "}\n"; 576 577 JavaSource src = getJavaSource(testFile); 578 CancellableTask task = new CancellableTask<WorkingCopy>() { 579 580 public void run(WorkingCopy workingCopy) throws IOException { 581 workingCopy.toPhase(Phase.RESOLVED); 582 CompilationUnitTree cut = workingCopy.getCompilationUnit(); 583 TreeMaker make = workingCopy.getTreeMaker(); 584 for (Tree typeDecl : cut.getTypeDecls()) { 585 ClassTree clazz = (ClassTree) typeDecl; 587 ClassTree copy = make.addClassImplementsClause( 588 clazz, make.Identifier("List") 589 ); 590 workingCopy.rewrite(clazz, copy); 591 } 592 } 593 594 public void cancel() { 595 throw new UnsupportedOperationException ("Not supported yet."); 596 } 597 }; 598 src.runModificationTask(task).commit(); 599 String res = TestUtilities.copyFileToString(testFile); 600 System.err.println(res); 601 assertEquals(golden, res); 602 } 603 604 public void testRemoveAllImplExtends() throws Exception { 605 testFile = new File (getWorkDir(), "Test.java"); 606 TestUtilities.copyStringToFile(testFile, 607 "package hierbas.del.litoral;\n\n" + 608 "import java.util.*;\n\n" + 609 "public class Test<E> extends Object implements List {\n" + 610 " public void taragui() {\n" + 611 " }\n" + 612 "}\n" 613 ); 614 String golden = 615 "package hierbas.del.litoral;\n\n" + 616 "import java.util.*;\n\n" + 617 "public class Test<E> extends Object {\n" + 618 " public void taragui() {\n" + 619 " }\n" + 620 "}\n"; 621 622 JavaSource src = getJavaSource(testFile); 623 CancellableTask task = new CancellableTask<WorkingCopy>() { 624 625 public void run(WorkingCopy workingCopy) throws IOException { 626 workingCopy.toPhase(Phase.RESOLVED); 627 CompilationUnitTree cut = workingCopy.getCompilationUnit(); 628 TreeMaker make = workingCopy.getTreeMaker(); 629 for (Tree typeDecl : cut.getTypeDecls()) { 630 ClassTree clazz = (ClassTree) typeDecl; 632 ClassTree copy = make.removeClassImplementsClause( 633 clazz, 0 634 ); 635 workingCopy.rewrite(clazz, copy); 636 } 637 } 638 639 public void cancel() { 640 throw new UnsupportedOperationException ("Not supported yet."); 641 } 642 }; 643 src.runModificationTask(task).commit(); 644 String res = TestUtilities.copyFileToString(testFile); 645 System.err.println(res); 646 assertEquals(golden, res); 647 } 648 649 public void testRenameInImpl() throws Exception { 650 testFile = new File (getWorkDir(), "Test.java"); 651 TestUtilities.copyStringToFile(testFile, 652 "package hierbas.del.litoral;\n\n" + 653 "import java.util.*;\n\n" + 654 "public class Test<E> extends Object implements List {\n" + 655 " public void taragui() {\n" + 656 " }\n" + 657 "}\n" 658 ); 659 String golden = 660 "package hierbas.del.litoral;\n\n" + 661 "import java.util.*;\n\n" + 662 "public class Test<E> extends Object implements Seznam {\n" + 663 " public void taragui() {\n" + 664 " }\n" + 665 "}\n"; 666 667 JavaSource src = getJavaSource(testFile); 668 CancellableTask task = new CancellableTask<WorkingCopy>() { 669 670 public void run(WorkingCopy workingCopy) throws IOException { 671 workingCopy.toPhase(Phase.RESOLVED); 672 CompilationUnitTree cut = workingCopy.getCompilationUnit(); 673 TreeMaker make = workingCopy.getTreeMaker(); 674 for (Tree typeDecl : cut.getTypeDecls()) { 675 ClassTree clazz = (ClassTree) typeDecl; 677 IdentifierTree ident = (IdentifierTree) clazz.getImplementsClause().get(0); 678 workingCopy.rewrite(ident, make.setLabel(ident, "Seznam")); 679 } 680 } 681 682 public void cancel() { 683 throw new UnsupportedOperationException ("Not supported yet."); 684 } 685 }; 686 src.runModificationTask(task).commit(); 687 String res = TestUtilities.copyFileToString(testFile); 688 System.err.println(res); 689 assertEquals(golden, res); 690 } 691 692 public void testRenameInImpl2() throws Exception { 693 testFile = new File (getWorkDir(), "Test.java"); 694 TestUtilities.copyStringToFile(testFile, 695 "package hierbas.del.litoral;\n\n" + 696 "import java.util.*;\n\n" + 697 "public class Test<E> extends Object implements PropertyChangeListener, List {\n" + 698 " public void taragui() {\n" + 699 " }\n" + 700 "}\n" 701 ); 702 String golden = 703 "package hierbas.del.litoral;\n\n" + 704 "import java.util.*;\n\n" + 705 "public class Test<E> extends Object implements PropertyChangeListener, Seznam {\n" + 706 " public void taragui() {\n" + 707 " }\n" + 708 "}\n"; 709 710 JavaSource src = getJavaSource(testFile); 711 CancellableTask task = new CancellableTask<WorkingCopy>() { 712 713 public void run(WorkingCopy workingCopy) throws IOException { 714 workingCopy.toPhase(Phase.RESOLVED); 715 CompilationUnitTree cut = workingCopy.getCompilationUnit(); 716 TreeMaker make = workingCopy.getTreeMaker(); 717 for (Tree typeDecl : cut.getTypeDecls()) { 718 ClassTree clazz = (ClassTree) typeDecl; 720 IdentifierTree ident = (IdentifierTree) clazz.getImplementsClause().get(1); 721 workingCopy.rewrite(ident, make.setLabel(ident, "Seznam")); 722 } 723 } 724 725 public void cancel() { 726 throw new UnsupportedOperationException ("Not supported yet."); 727 } 728 }; 729 src.runModificationTask(task).commit(); 730 String res = TestUtilities.copyFileToString(testFile); 731 System.err.println(res); 732 assertEquals(golden, res); 733 } 734 735 protected void setUp() throws Exception { 736 super.setUp(); 737 testFile = getFile(getSourceDir(), getSourcePckg() + "Test.java"); 738 } 739 740 String getGoldenPckg() { 741 return ""; 742 } 743 744 String getSourcePckg() { 745 return ""; 746 } 747 748 } 749 | Popular Tags |