1 /******************************************************************************* 2 * Copyright (c) 2000, 2020 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.jdt.ui.tests.refactoring; 15 16 import static org.junit.Assert.assertEquals; 17 import static org.junit.Assert.assertFalse; 18 import static org.junit.Assert.assertNotEquals; 19 import static org.junit.Assert.assertNotNull; 20 import static org.junit.Assert.assertNull; 21 import static org.junit.Assert.assertTrue; 22 23 import java.io.ByteArrayInputStream; 24 import java.io.IOException; 25 import java.io.InputStreamReader; 26 import java.util.ArrayList; 27 import java.util.List; 28 29 import org.junit.Rule; 30 import org.junit.Test; 31 32 import org.eclipse.core.runtime.CoreException; 33 import org.eclipse.core.runtime.IAdaptable; 34 import org.eclipse.core.runtime.NullProgressMonitor; 35 import org.eclipse.core.runtime.Platform; 36 37 import org.eclipse.core.resources.IFile; 38 import org.eclipse.core.resources.IProject; 39 40 import org.eclipse.ltk.core.refactoring.Refactoring; 41 import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; 42 import org.eclipse.ltk.core.refactoring.RefactoringStatus; 43 import org.eclipse.ltk.core.refactoring.participants.RenameArguments; 44 import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; 45 46 import org.eclipse.jdt.core.ICompilationUnit; 47 import org.eclipse.jdt.core.IField; 48 import org.eclipse.jdt.core.IJavaElement; 49 import org.eclipse.jdt.core.IJavaProject; 50 import org.eclipse.jdt.core.ILocalVariable; 51 import org.eclipse.jdt.core.IMember; 52 import org.eclipse.jdt.core.IMethod; 53 import org.eclipse.jdt.core.IPackageFragment; 54 import org.eclipse.jdt.core.IType; 55 import org.eclipse.jdt.core.JavaCore; 56 import org.eclipse.jdt.core.JavaModelException; 57 import org.eclipse.jdt.core.refactoring.IJavaElementMapper; 58 import org.eclipse.jdt.core.refactoring.IJavaRefactorings; 59 import org.eclipse.jdt.core.refactoring.descriptors.RenameJavaElementDescriptor; 60 61 import org.eclipse.jdt.internal.core.refactoring.descriptors.RefactoringSignatureDescriptorFactory; 62 import org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeProcessor; 63 import org.eclipse.jdt.internal.corext.refactoring.rename.RenamingNameSuggestor; 64 import org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating; 65 66 import org.eclipse.jdt.ui.tests.refactoring.infra.DebugUtils; 67 import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup; 68 69 public class RenameTypeTests extends GenericRefactoringTest { 70 71 private static final boolean BUG_54948= false; 72 private static final String REFACTORING_PATH= "RenameType/"; 73 74 @Rule 75 public RefactoringTestSetup fts= new RefactoringTestSetup(); 76 77 @Override getRefactoringPath()78 protected String getRefactoringPath() { 79 return REFACTORING_PATH; 80 } 81 getClassFromTestFile(IPackageFragment pack, String className)82 private IType getClassFromTestFile(IPackageFragment pack, String className) throws Exception{ 83 return getType(createCUfromTestFile(pack, className), className); 84 } 85 createRefactoringDescriptor(IType type, String newName)86 private RenameJavaElementDescriptor createRefactoringDescriptor(IType type, String newName) { 87 RenameJavaElementDescriptor descriptor= RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_TYPE); 88 descriptor.setJavaElement(type); 89 descriptor.setNewName(newName); 90 descriptor.setUpdateReferences(true); 91 return descriptor; 92 } 93 helper1_0(String className, String newName)94 private void helper1_0(String className, String newName) throws Exception { 95 IType classA= getClassFromTestFile(getPackageP(), className); 96 RefactoringStatus result= performRefactoring(createRefactoringDescriptor(classA, newName)); 97 assertNotNull("precondition was supposed to fail", result); 98 if (fIsVerbose) 99 DebugUtils.dump("result: " + result); 100 } 101 helper1()102 private void helper1() throws Exception{ 103 helper1_0("A", "B"); 104 } 105 helperWithTextual(String oldCuName, String oldName, String newName, String newCUName, boolean updateReferences, boolean updateTextualMatches)106 private String[] helperWithTextual(String oldCuName, String oldName, String newName, String newCUName, boolean updateReferences, boolean updateTextualMatches) throws Exception{ 107 ICompilationUnit cu= createCUfromTestFile(getPackageP(), oldCuName); 108 IType classA= getType(cu, oldName); 109 IJavaElement[] classAMembers= classA.getChildren(); 110 111 IPackageFragment pack= (IPackageFragment)cu.getParent(); 112 String[] renameHandles= null; 113 if (classA.getDeclaringType() == null && cu.getElementName().startsWith(classA.getElementName())) { 114 renameHandles= ParticipantTesting.createHandles(classA, cu, cu.getResource()); 115 } else { 116 renameHandles= ParticipantTesting.createHandles(classA); 117 } 118 RenameJavaElementDescriptor descriptor= createRefactoringDescriptor(classA, newName); 119 descriptor.setUpdateReferences(updateReferences); 120 descriptor.setUpdateTextualOccurrences(updateTextualMatches); 121 Refactoring refactoring= createRefactoring(descriptor); 122 assertNull("was supposed to pass", performRefactoring(refactoring)); 123 ICompilationUnit newcu= pack.getCompilationUnit(newCUName + ".java"); 124 assertTrue("cu " + newcu.getElementName()+ " does not exist", newcu.exists()); 125 assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName(newCUName)), newcu.getSource()); 126 127 INameUpdating nameUpdating= refactoring.getAdapter(INameUpdating.class); 128 IType newElement = (IType) nameUpdating.getNewElement(); 129 assertTrue("new element does not exist:\n" + newElement.toString(), newElement.exists()); 130 131 checkMappers(refactoring, classA, newCUName + ".java", classAMembers); 132 133 return renameHandles; 134 } 135 helper2_0(String oldName, String newName, String newCUName, boolean updateReferences)136 private String[] helper2_0(String oldName, String newName, String newCUName, boolean updateReferences) throws Exception{ 137 return helperWithTextual(oldName, oldName, newName, newCUName, updateReferences, false); 138 } 139 helper2(String oldName, String newName, boolean updateReferences)140 private void helper2(String oldName, String newName, boolean updateReferences) throws Exception{ 141 helper2_0(oldName, newName, newName, updateReferences); 142 } 143 helper2(String oldName, String newName)144 private String[] helper2(String oldName, String newName) throws Exception{ 145 return helper2_0(oldName, newName, newName, true); 146 } 147 148 // <--------------------- Similarly named elements ----------------------------> 149 150 @Override genericbefore()151 public void genericbefore() throws Exception { 152 super.genericbefore(); 153 setSomeFieldOptions(getPackageP().getJavaProject(), "f", "Suf1", false); 154 setSomeFieldOptions(getPackageP().getJavaProject(), "fs", "_suffix", true); 155 setSomeLocalOptions(getPackageP().getJavaProject(), "lv", "_lv"); 156 setSomeArgumentOptions(getPackageP().getJavaProject(), "pm", "_pm"); 157 fIsPreDeltaTest= true; 158 } 159 helper3(String oldName, String newName, boolean updateRef, boolean updateTextual, boolean updateSimilar)160 private void helper3(String oldName, String newName, boolean updateRef, boolean updateTextual, boolean updateSimilar) throws JavaModelException, CoreException, IOException, Exception { 161 helper3(oldName, newName, updateRef, updateTextual, updateSimilar, null); 162 } 163 helper3(String oldName, String newName, boolean updateRef, boolean updateTextual, boolean updateSimilar, String nonJavaFiles)164 private void helper3(String oldName, String newName, boolean updateRef, boolean updateTextual, boolean updateSimilar, String nonJavaFiles) throws JavaModelException, CoreException, IOException, Exception { 165 RefactoringDescriptor descriptor= initWithAllOptions(oldName, oldName, newName, updateRef, updateTextual, updateSimilar, nonJavaFiles, RenamingNameSuggestor.STRATEGY_EMBEDDED); 166 Refactoring ref= createRefactoring(descriptor); 167 RefactoringStatus status= performRefactoring(ref); 168 assertNull("was supposed to pass", status); 169 checkResultInClass(newName); 170 checkMappedSimilarElementsExist(ref); 171 } 172 helper3_inner(String oldName, String oldInnerName, String newName, String innerNewName, boolean updateRef, boolean updateTextual, boolean updateSimilar, String nonJavaFiles)173 private void helper3_inner(String oldName, String oldInnerName, String newName, String innerNewName, boolean updateRef, boolean updateTextual, boolean updateSimilar, String nonJavaFiles) throws JavaModelException, CoreException, IOException, Exception { 174 RefactoringDescriptor descriptor= initWithAllOptions(oldName, oldInnerName, innerNewName, updateRef, updateTextual, updateSimilar, nonJavaFiles, RenamingNameSuggestor.STRATEGY_EMBEDDED); 175 Refactoring ref= createRefactoring(descriptor); 176 assertNull("was supposed to pass", performRefactoring(ref)); 177 checkResultInClass(newName); 178 checkMappedSimilarElementsExist(ref); 179 } 180 checkMappedSimilarElementsExist(Refactoring ref)181 private void checkMappedSimilarElementsExist(Refactoring ref) { 182 RenameTypeProcessor rtp= (RenameTypeProcessor) ((RenameRefactoring) ref).getProcessor(); 183 IJavaElementMapper mapper= rtp.getAdapter(IJavaElementMapper.class); 184 IJavaElement[] similarElements= rtp.getSimilarElements(); 185 if (similarElements == null) 186 return; 187 for (IJavaElement element : similarElements) { 188 if (! (element instanceof ILocalVariable)) { 189 IJavaElement newElement= mapper.getRefactoredJavaElement(element); 190 assertTrue(newElement.exists()); 191 assertFalse(element.exists()); 192 } 193 } 194 195 } 196 helper3_fail(String oldName, String newName, boolean updateSimilar, boolean updateTextual, boolean updateRef, int matchStrategy)197 private void helper3_fail(String oldName, String newName, boolean updateSimilar, boolean updateTextual, boolean updateRef, int matchStrategy) throws JavaModelException, CoreException, IOException, Exception { 198 RefactoringDescriptor descriptor= initWithAllOptions(oldName, oldName, newName, updateRef, updateTextual, updateSimilar, null, matchStrategy); 199 assertNotNull("was supposed to fail", performRefactoring(descriptor)); 200 } 201 helper3_fail(String oldName, String newName, boolean updateSimilar, boolean updateTextual, boolean updateRef)202 private void helper3_fail(String oldName, String newName, boolean updateSimilar, boolean updateTextual, boolean updateRef) throws JavaModelException, CoreException, IOException, Exception { 203 RefactoringDescriptor descriptor= initWithAllOptions(oldName, oldName, newName, updateRef, updateTextual, updateSimilar, null, RenamingNameSuggestor.STRATEGY_SUFFIX); 204 assertNotNull("was supposed to fail", performRefactoring(descriptor)); 205 } 206 initWithAllOptions(String oldName, String innerOldName, String innerNewName, boolean updateReferences, boolean updateTextualMatches, boolean updateSimilar, String nonJavaFiles, int matchStrategy)207 private RefactoringDescriptor initWithAllOptions(String oldName, String innerOldName, String innerNewName, boolean updateReferences, boolean updateTextualMatches, boolean updateSimilar, String nonJavaFiles, int matchStrategy) throws Exception, JavaModelException, CoreException { 208 ICompilationUnit cu= createCUfromTestFile(getPackageP(), oldName); 209 IType classA= getType(cu, innerOldName); 210 RenameJavaElementDescriptor descriptor= createRefactoringDescriptor(classA, innerNewName); 211 setTheOptions(descriptor, updateReferences, updateTextualMatches, updateSimilar, nonJavaFiles, matchStrategy); 212 return descriptor; 213 } 214 setTheOptions(RenameJavaElementDescriptor descriptor, boolean updateReferences, boolean updateTextualMatches, boolean updateSimilar, String nonJavaFiles, int matchStrategy)215 private void setTheOptions(RenameJavaElementDescriptor descriptor, boolean updateReferences, boolean updateTextualMatches, boolean updateSimilar, String nonJavaFiles, int matchStrategy) { 216 descriptor.setUpdateReferences(updateReferences); 217 descriptor.setUpdateTextualOccurrences(updateTextualMatches); 218 if (nonJavaFiles!=null) { 219 descriptor.setUpdateQualifiedNames(true); 220 descriptor.setFileNamePatterns(nonJavaFiles); 221 } 222 descriptor.setUpdateSimilarDeclarations(updateSimilar); 223 descriptor.setMatchStrategy(matchStrategy); 224 } 225 checkResultInClass(String typeName)226 private void checkResultInClass(String typeName) throws JavaModelException, IOException { 227 ICompilationUnit newcu= getPackageP().getCompilationUnit(typeName + ".java"); 228 assertTrue("cu " + newcu.getElementName()+ " does not exist", newcu.exists()); 229 assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName(typeName)), newcu.getSource()); 230 } 231 setSomeFieldOptions(IJavaProject project, String prefixes, String suffixes, boolean forStatic)232 private void setSomeFieldOptions(IJavaProject project, String prefixes, String suffixes, boolean forStatic) { 233 if (forStatic) { 234 project.setOption(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, prefixes); 235 project.setOption(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, suffixes); 236 } 237 else { 238 project.setOption(JavaCore.CODEASSIST_FIELD_PREFIXES, prefixes); 239 project.setOption(JavaCore.CODEASSIST_FIELD_SUFFIXES, suffixes); 240 } 241 } 242 setSomeLocalOptions(IJavaProject project, String prefixes, String suffixes)243 private void setSomeLocalOptions(IJavaProject project, String prefixes, String suffixes) { 244 project.setOption(JavaCore.CODEASSIST_LOCAL_PREFIXES, prefixes); 245 project.setOption(JavaCore.CODEASSIST_LOCAL_SUFFIXES, suffixes); 246 } 247 setSomeArgumentOptions(IJavaProject project, String prefixes, String suffixes)248 private void setSomeArgumentOptions(IJavaProject project, String prefixes, String suffixes) { 249 project.setOption(JavaCore.CODEASSIST_ARGUMENT_PREFIXES, prefixes); 250 project.setOption(JavaCore.CODEASSIST_ARGUMENT_SUFFIXES, suffixes); 251 } 252 253 // </------------------------------------ Similarly named elements ---------------------------------> 254 255 @Test testIllegalInnerClass()256 public void testIllegalInnerClass() throws Exception { 257 helper1(); 258 } 259 260 @Test testIllegalTypeName1()261 public void testIllegalTypeName1() throws Exception { 262 helper1_0("A", "X "); 263 } 264 265 @Test testIllegalTypeName2()266 public void testIllegalTypeName2() throws Exception { 267 helper1_0("A", " X"); 268 } 269 270 @Test testIllegalTypeName3()271 public void testIllegalTypeName3() throws Exception { 272 helper1_0("A", "34"); 273 } 274 275 @Test testIllegalTypeName4()276 public void testIllegalTypeName4() throws Exception { 277 helper1_0("A", "this"); 278 } 279 280 @Test testIllegalTypeName5()281 public void testIllegalTypeName5() throws Exception { 282 helper1_0("A", "fred"); 283 } 284 285 @Test testIllegalTypeName6()286 public void testIllegalTypeName6() throws Exception { 287 helper1_0("A", "class"); 288 } 289 290 @Test testIllegalTypeName7()291 public void testIllegalTypeName7() throws Exception { 292 helper1_0("A", "A.B"); 293 } 294 295 @Test testIllegalTypeName8()296 public void testIllegalTypeName8() throws Exception { 297 helper1_0("A", "A$B"); 298 } 299 300 @Test testIllegalTypeName9()301 public void testIllegalTypeName9() throws Exception { 302 if (Platform.getOS().equals(Platform.OS_WIN32)) 303 helper1_0("A", "aux"); 304 } 305 306 @Test testNoOp()307 public void testNoOp() throws Exception { 308 helper1_0("A", "A"); 309 } 310 311 @Test testWrongArg1()312 public void testWrongArg1() throws Exception { 313 IllegalArgumentException result= null; 314 try { 315 helper1_0("A", ""); 316 } catch (IllegalArgumentException exception) { 317 result= exception; 318 } 319 assertNotNull("empty name was supposed to trigger IAE", result); 320 } 321 322 @Test testFail0()323 public void testFail0() throws Exception { 324 helper1(); 325 } 326 327 @Test testFail1()328 public void testFail1() throws Exception { 329 helper1(); 330 } 331 332 @Test testFail2()333 public void testFail2() throws Exception { 334 helper1(); 335 } 336 337 @Test testFail3()338 public void testFail3() throws Exception { 339 helper1(); 340 } 341 342 @Test testFail4()343 public void testFail4() throws Exception { 344 IType classA= getClassFromTestFile(getPackageP(), "A"); 345 getClassFromTestFile(getPackageP(), "B"); 346 RefactoringStatus result= performRefactoring(createRefactoringDescriptor(classA, "B")); 347 assertNotNull("precondition was supposed to fail", result); 348 } 349 350 @Test testFail5()351 public void testFail5() throws Exception { 352 IType classA= getClassFromTestFile(getPackageP(), "A"); 353 getClassFromTestFile(getPackageP(), "B"); 354 getClassFromTestFile(getPackageP(), "C"); 355 356 RefactoringStatus result= performRefactoring(createRefactoringDescriptor(classA, "B")); 357 assertNotNull("precondition was supposed to fail", result); 358 } 359 360 @Test testFail6()361 public void testFail6() throws Exception { 362 IType classA= getClassFromTestFile(getPackageP(), "A"); 363 getClassFromTestFile(getPackageP(), "B"); 364 getClassFromTestFile(getPackageP(), "C"); 365 366 RefactoringStatus result= performRefactoring(createRefactoringDescriptor(classA, "B")); 367 assertNotNull("precondition was supposed to fail", result); 368 } 369 370 @Test testFail7()371 public void testFail7() throws Exception { 372 helper1(); 373 } 374 375 @Test testFail8()376 public void testFail8() throws Exception { 377 IType classA= getClassFromTestFile(getPackageP(), "A"); 378 getClassFromTestFile(getPackageP(), "B"); 379 380 RefactoringStatus result= performRefactoring(createRefactoringDescriptor(classA, "B")); 381 assertNotNull("precondition was supposed to fail", result); 382 } 383 384 @Test testFail9()385 public void testFail9() throws Exception { 386 helper1(); 387 } 388 389 @Test testFail10()390 public void testFail10() throws Exception { 391 helper1(); 392 } 393 394 @Test testFail11()395 public void testFail11() throws Exception { 396 helper1(); 397 } 398 399 @Test testFail12()400 public void testFail12() throws Exception { 401 helper1(); 402 } 403 404 @Test testFail16()405 public void testFail16() throws Exception { 406 helper1(); 407 } 408 409 @Test testFail17()410 public void testFail17() throws Exception { 411 helper1(); 412 } 413 414 @Test testFail18()415 public void testFail18() throws Exception { 416 helper1(); 417 } 418 419 @Test testFail19()420 public void testFail19() throws Exception { 421 helper1(); 422 } 423 424 @Test testFail20()425 public void testFail20() throws Exception { 426 IPackageFragment packageP1= getRoot().createPackageFragment("p1", true, null); 427 IPackageFragment packageP2= getRoot().createPackageFragment("p2", true, null); 428 429 IType classA= getClassFromTestFile(packageP1, "A"); 430 getClassFromTestFile(packageP2, "AA"); 431 432 RefactoringStatus result= performRefactoring(createRefactoringDescriptor(classA, "B")); 433 assertNotNull("precondition was supposed to fail", result); 434 } 435 436 @Test testFail22()437 public void testFail22() throws Exception { 438 IType classA= getClassFromTestFile(getPackageP(), "A"); 439 getClassFromTestFile(getPackageP(), "B"); 440 441 RefactoringStatus result= performRefactoring(createRefactoringDescriptor(classA, "B")); 442 assertNotNull("precondition was supposed to fail", result); 443 } 444 445 @Test testFail23()446 public void testFail23() throws Exception { 447 IPackageFragment packageP1= getRoot().createPackageFragment("p1", true, null); 448 IPackageFragment packageP2= getRoot().createPackageFragment("p2", true, null); 449 IPackageFragment packageP3= getRoot().createPackageFragment("p3", true, null); 450 451 IType classA= getClassFromTestFile(packageP1, "A"); 452 getClassFromTestFile(packageP3, "B"); 453 getClassFromTestFile(packageP2, "Bogus"); 454 455 RefactoringStatus result= performRefactoring(createRefactoringDescriptor(classA, "B")); 456 assertNotNull("precondition was supposed to fail", result); 457 } 458 459 @Test testFail24()460 public void testFail24() throws Exception { 461 IPackageFragment packageP1= getRoot().createPackageFragment("p1", true, null); 462 IPackageFragment packageP2= getRoot().createPackageFragment("p2", true, null); 463 464 IType classA= getClassFromTestFile(packageP1, "A"); 465 getClassFromTestFile(packageP2, "B"); 466 467 RefactoringStatus result= performRefactoring(createRefactoringDescriptor(classA, "B")); 468 assertNotNull("precondition was supposed to fail", result); 469 } 470 471 @Test testFail25()472 public void testFail25() throws Exception { 473 IPackageFragment packageP1= getRoot().createPackageFragment("p1", true, null); 474 IPackageFragment packageP2= getRoot().createPackageFragment("p2", true, null); 475 476 IType classA= getClassFromTestFile(packageP1, "A"); 477 getClassFromTestFile(packageP2, "B"); 478 479 RefactoringStatus result= performRefactoring(createRefactoringDescriptor(classA, "B")); 480 assertNotNull("precondition was supposed to fail", result); 481 } 482 483 @Test testFail26()484 public void testFail26() throws Exception { 485 IPackageFragment packageP1= getRoot().createPackageFragment("p1", true, null); 486 IPackageFragment packageP2= getRoot().createPackageFragment("p2", true, null); 487 488 IType classA= getClassFromTestFile(packageP1, "A"); 489 getClassFromTestFile(packageP2, "B"); 490 491 RefactoringStatus result= performRefactoring(createRefactoringDescriptor(classA, "B")); 492 assertNotNull("precondition was supposed to fail", result); 493 } 494 495 @Test testFail27()496 public void testFail27() throws Exception { 497 IPackageFragment packageP1= getRoot().createPackageFragment("p1", true, null); 498 IPackageFragment packageP2= getRoot().createPackageFragment("p2", true, null); 499 500 IType classA= getClassFromTestFile(packageP1, "A"); 501 getClassFromTestFile(packageP2, "B"); 502 503 RefactoringStatus result= performRefactoring(createRefactoringDescriptor(classA, "B")); 504 assertNotNull("precondition was supposed to fail", result); 505 } 506 507 @Test testFail28()508 public void testFail28() throws Exception { 509 printTestDisabledMessage("obscuring"); 510 // helper1(); 511 } 512 513 @Test testFail29()514 public void testFail29() throws Exception { 515 printTestDisabledMessage("obscuring"); 516 // helper1(); 517 } 518 519 @Test testFail30()520 public void testFail30() throws Exception { 521 printTestDisabledMessage("obscuring"); 522 // helper1(); 523 } 524 525 @Test testFail31()526 public void testFail31() throws Exception { 527 IPackageFragment packageP1= getRoot().createPackageFragment("p1", true, null); 528 IPackageFragment packageP2= getRoot().createPackageFragment("p2", true, null); 529 IPackageFragment packageP3= getRoot().createPackageFragment("p3", true, null); 530 531 IType classA= getClassFromTestFile(packageP1, "A"); 532 getClassFromTestFile(packageP2, "B"); 533 getClassFromTestFile(packageP3, "C"); 534 535 RefactoringStatus result= performRefactoring(createRefactoringDescriptor(classA, "B")); 536 assertNotNull("precondition was supposed to fail", result); 537 } 538 539 @Test testFail32()540 public void testFail32() throws Exception { 541 IType classA= getClassFromTestFile(getPackageP(), "A"); 542 IPackageFragment packageP1= getRoot().createPackageFragment("p1", true, null); 543 getClassFromTestFile(packageP1, "B"); 544 545 RefactoringStatus result= performRefactoring(createRefactoringDescriptor(classA, "B")); 546 assertNotNull("precondition was supposed to fail", result); 547 } 548 549 @Test testFail33()550 public void testFail33() throws Exception { 551 helper1(); 552 } 553 554 @Test testFail34()555 public void testFail34() throws Exception { 556 printTestDisabledMessage("obscuring"); 557 // helper1(); 558 } 559 560 @Test testFail35()561 public void testFail35() throws Exception { 562 printTestDisabledMessage("obscuring"); 563 // helper1(); 564 } 565 566 @Test testFail36()567 public void testFail36() throws Exception { 568 printTestDisabledMessage("obscuring"); 569 // helper1(); 570 } 571 572 @Test testFail37()573 public void testFail37() throws Exception { 574 IType classA= getClassFromTestFile(getPackageP(), "A"); 575 getClassFromTestFile(getPackageP(), "B"); 576 577 RefactoringStatus result= performRefactoring(createRefactoringDescriptor(classA, "B")); 578 assertNotNull("precondition was supposed to fail", result); 579 } 580 581 @Test testFail38()582 public void testFail38() throws Exception { 583 helper1(); 584 } 585 586 @Test testFail39()587 public void testFail39() throws Exception { 588 helper1(); 589 } 590 591 @Test testFail40()592 public void testFail40() throws Exception { 593 helper1(); 594 } 595 596 @Test testFail41()597 public void testFail41() throws Exception { 598 printTestDisabledMessage("obscuring"); 599 // helper1(); 600 } 601 602 @Test testFail42()603 public void testFail42() throws Exception { 604 printTestDisabledMessage("obscuring"); 605 // helper1(); 606 } 607 608 @Test testFail43()609 public void testFail43() throws Exception { 610 printTestDisabledMessage("obscuring"); 611 // helper1(); 612 } 613 614 @Test testFail44()615 public void testFail44() throws Exception { 616 printTestDisabledMessage("obscuring"); 617 // helper1(); 618 } 619 620 @Test testFail45()621 public void testFail45() throws Exception { 622 printTestDisabledMessage("obscuring"); 623 // helper1(); 624 } 625 626 @Test testFail46()627 public void testFail46() throws Exception { 628 printTestDisabledMessage("obscuring"); 629 // helper1(); 630 } 631 632 @Test testFail47()633 public void testFail47() throws Exception { 634 printTestDisabledMessage("obscuring"); 635 // helper1(); 636 } 637 638 @Test testFail48()639 public void testFail48() throws Exception { 640 helper1(); 641 } 642 643 @Test testFail49()644 public void testFail49() throws Exception { 645 helper1(); 646 } 647 648 @Test testFail50()649 public void testFail50() throws Exception { 650 helper1(); 651 } 652 653 @Test testFail51()654 public void testFail51() throws Exception { 655 helper1(); 656 } 657 658 @Test testFail52()659 public void testFail52() throws Exception { 660 helper1(); 661 } 662 663 @Test testFail53()664 public void testFail53() throws Exception { 665 helper1(); 666 } 667 668 @Test testFail54()669 public void testFail54() throws Exception { 670 helper1(); 671 } 672 673 @Test testFail55()674 public void testFail55() throws Exception { 675 helper1(); 676 } 677 678 @Test testFail56()679 public void testFail56() throws Exception { 680 helper1(); 681 } 682 683 @Test testFail57()684 public void testFail57() throws Exception { 685 helper1(); 686 } 687 688 @Test testFail58()689 public void testFail58() throws Exception { 690 helper1(); 691 } 692 693 @Test testFail59()694 public void testFail59() throws Exception { 695 helper1(); 696 } 697 698 @Test testFail60()699 public void testFail60() throws Exception { 700 helper1(); 701 } 702 703 @Test testFail61()704 public void testFail61() throws Exception { 705 helper1(); 706 } 707 708 @Test testFail62()709 public void testFail62() throws Exception { 710 helper1(); 711 } 712 713 @Test testFail63()714 public void testFail63() throws Exception { 715 helper1(); 716 } 717 718 @Test testFail64()719 public void testFail64() throws Exception { 720 helper1(); 721 } 722 723 @Test testFail65()724 public void testFail65() throws Exception { 725 helper1(); 726 } 727 728 @Test testFail66()729 public void testFail66() throws Exception { 730 helper1(); 731 } 732 733 @Test testFail67()734 public void testFail67() throws Exception { 735 helper1(); 736 } 737 738 @Test testFail68()739 public void testFail68() throws Exception { 740 helper1(); 741 } 742 743 @Test testFail69()744 public void testFail69() throws Exception { 745 helper1(); 746 } 747 748 @Test testFail70()749 public void testFail70() throws Exception { 750 helper1(); 751 } 752 753 @Test testFail71()754 public void testFail71() throws Exception { 755 helper1(); 756 } 757 758 @Test testFail72()759 public void testFail72() throws Exception { 760 helper1(); 761 } 762 763 @Test testFail73()764 public void testFail73() throws Exception { 765 helper1(); 766 } 767 768 @Test testFail74()769 public void testFail74() throws Exception { 770 helper1(); 771 } 772 773 @Test testFail75()774 public void testFail75() throws Exception { 775 helper1(); 776 } 777 778 @Test testFail76()779 public void testFail76() throws Exception { 780 helper1(); 781 } 782 783 @Test testFail77()784 public void testFail77() throws Exception { 785 helper1(); 786 } 787 788 @Test testFail78()789 public void testFail78() throws Exception { 790 helper1(); 791 } 792 793 @Test testFail79()794 public void testFail79() throws Exception { 795 helper1(); 796 } 797 798 @Test testFail80()799 public void testFail80() throws Exception { 800 helper1(); 801 } 802 803 @Test testFail81()804 public void testFail81() throws Exception { 805 helper1(); 806 } 807 808 @Test testFail82()809 public void testFail82() throws Exception { 810 helper1(); 811 } 812 813 @Test testFail83()814 public void testFail83() throws Exception { 815 helper1_0("A", "Cloneable"); 816 } 817 818 @Test testFail84()819 public void testFail84() throws Exception { 820 helper1_0("A", "List"); 821 } 822 823 @Test testFail85()824 public void testFail85() throws Exception { 825 helper1(); 826 } 827 828 @Test testFail86()829 public void testFail86() throws Exception { 830 printTestDisabledMessage("native method with A as parameter (same CU)"); 831 // helper1(); 832 } 833 834 @Test testFail87()835 public void testFail87() throws Exception { 836 printTestDisabledMessage("native method with A as parameter (same CU)"); 837 // helper1(); 838 } 839 840 @Test testFail88()841 public void testFail88() throws Exception { 842 helper1(); 843 } 844 845 @Test testFail89()846 public void testFail89() throws Exception { 847 helper1(); 848 } 849 850 @Test testFail90()851 public void testFail90() throws Exception { 852 helper1(); 853 } 854 855 @Test testFail91()856 public void testFail91() throws Exception { 857 helper1(); 858 } 859 860 @Test testFail92()861 public void testFail92() throws Exception { 862 // printTestDisabledMessage("needs fixing - double nested local type named B"); 863 helper1(); 864 } 865 866 @Test testFail93()867 public void testFail93() throws Exception { 868 // printTestDisabledMessage("needs fixing - double nested local type named B"); 869 helper1(); 870 } 871 872 @Test testFail94()873 public void testFail94() throws Exception { 874 helper1(); 875 } 876 877 @Test testFail95()878 public void testFail95() throws Exception { 879 helper1(); 880 } 881 882 @Test testFail96()883 public void testFail96() throws Exception { 884 // https://bugs.eclipse.org/356677 885 IPackageFragment packageP1= getRoot().createPackageFragment("p1", true, null); 886 IPackageFragment packageP2= getRoot().createPackageFragment("p2", true, null); 887 888 IType classA= getClassFromTestFile(packageP1, "A"); 889 getClassFromTestFile(packageP1, "B"); 890 getClassFromTestFile(packageP2, "C"); 891 892 RefactoringStatus result= performRefactoring(createRefactoringDescriptor(classA, "C")); 893 assertNotNull("precondition was supposed to fail", result); 894 } 895 896 @Test testFail00()897 public void testFail00() throws Exception { 898 helper1(); 899 } 900 901 @Test testFail01()902 public void testFail01() throws Exception { 903 helper1_0("A", "B"); 904 } 905 906 @Test testFail02()907 public void testFail02() throws Exception { 908 helper1(); 909 } 910 911 @Test testFail03()912 public void testFail03() throws Exception { 913 helper1_0("A", "C"); 914 } 915 916 @Test testFail04()917 public void testFail04() throws Exception { 918 helper1_0("A", "A"); 919 } 920 921 @Test testFailRegression1GCRKMQ()922 public void testFailRegression1GCRKMQ() throws Exception { 923 IPackageFragment myPackage= getRoot().createPackageFragment("", true, new NullProgressMonitor()); 924 IType myClass= getClassFromTestFile(myPackage, "Blinky"); 925 926 RefactoringStatus result= performRefactoring(createRefactoringDescriptor(myClass, "B")); 927 assertNotNull("precondition was supposed to fail", result); 928 } 929 930 @Test test0()931 public void test0() throws Exception { 932 ParticipantTesting.reset(); 933 String newName= "B"; 934 String[] renameHandles= helper2("A", newName); 935 ParticipantTesting.testRename( 936 renameHandles, 937 new RenameArguments[] { 938 new RenameArguments(newName, true), 939 new RenameArguments(newName + ".java", true), 940 new RenameArguments(newName + ".java", true)}); 941 } 942 943 @Test test1()944 public void test1() throws Exception { 945 helper2("A", "B"); 946 } 947 948 @Test test10()949 public void test10() throws Exception { 950 helper2("A", "B"); 951 } 952 953 @Test test12()954 public void test12() throws Exception { 955 helper2("A", "B"); 956 } 957 958 @Test test13()959 public void test13() throws Exception { 960 helper2("A", "B"); 961 } 962 963 @Test test14()964 public void test14() throws Exception { 965 helper2("A", "B"); 966 } 967 968 @Test test15()969 public void test15() throws Exception { 970 helper2("A", "B"); 971 } 972 973 @Test test16()974 public void test16() throws Exception { 975 helper2("A", "B"); 976 } 977 978 @Test test17()979 public void test17() throws Exception { 980 helper2("A", "B"); 981 } 982 983 @Test test18()984 public void test18() throws Exception { 985 helper2("A", "B"); 986 } 987 988 @Test test19()989 public void test19() throws Exception { 990 helper2("A", "B"); 991 } 992 993 @Test test2()994 public void test2() throws Exception { 995 helper2("A", "B"); 996 } 997 998 @Test test20()999 public void test20() throws Exception { 1000 //printTestDisabledMessage("failb because of bug#9479"); 1001 //if (true) 1002 // return; 1003 IPackageFragment packageA= getRoot().createPackageFragment("A", true, null); 1004 1005 ICompilationUnit cu= createCUfromTestFile(packageA, "A"); 1006 IType classA= getType(cu, "A"); 1007 1008 assertNull("was supposed to pass", performRefactoring(createRefactoringDescriptor(classA, "B"))); 1009 1010 ICompilationUnit newcu= packageA.getCompilationUnit("B.java"); 1011 assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("B")), newcu.getSource()); 1012 } 1013 1014 @Test test21()1015 public void test21() throws Exception { 1016 helper2("A", "B"); 1017 } 1018 1019 @Test test22()1020 public void test22() throws Exception { 1021 helper2("A", "B"); 1022 } 1023 1024 @Test test23()1025 public void test23() throws Exception { 1026 helper2("A", "B"); 1027 } 1028 1029 @Test test24()1030 public void test24() throws Exception { 1031 helper2("A", "B"); 1032 } 1033 1034 @Test test25()1035 public void test25() throws Exception { 1036 helper2("A", "B"); 1037 } 1038 1039 @Test test26()1040 public void test26() throws Exception { 1041 helper2("A", "B"); 1042 } 1043 1044 @Test test27()1045 public void test27() throws Exception { 1046 helper2("A", "B"); 1047 } 1048 1049 @Test test28()1050 public void test28() throws Exception { 1051 helper2("A", "B"); 1052 } 1053 1054 @Test test29()1055 public void test29() throws Exception { 1056 IPackageFragment packageP1= getRoot().createPackageFragment("p1", true, null); 1057 createCUfromTestFile(packageP1, "C"); 1058 1059 ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); 1060 IType classA= getType(cu, "A"); 1061 1062 assertNull("was supposed to pass", performRefactoring(createRefactoringDescriptor(classA, "B"))); 1063 1064 ICompilationUnit newcu= getPackageP().getCompilationUnit("B.java"); 1065 ICompilationUnit newcuC= packageP1.getCompilationUnit("C.java"); 1066 assertEqualLines("invalid renaming A", getFileContents(getOutputTestFileName("B")), newcu.getSource()); 1067 assertEqualLines("invalid renaming C", getFileContents(getOutputTestFileName("C")), newcuC.getSource()); 1068 1069 } 1070 1071 @Test test3()1072 public void test3() throws Exception { 1073 helper2("A", "B"); 1074 } 1075 1076 @Test test30()1077 public void test30() throws Exception { 1078 createCUfromTestFile(getPackageP(), "AA"); 1079 1080 ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); 1081 IType classA= getType(cu, "A"); 1082 1083 assertNull("was supposed to pass", performRefactoring(createRefactoringDescriptor(classA, "B"))); 1084 1085 ICompilationUnit newcu= getPackageP().getCompilationUnit("B.java"); 1086 ICompilationUnit newcuAA= getPackageP().getCompilationUnit("AA.java"); 1087 assertEqualLines("invalid renaming A", getFileContents(getOutputTestFileName("B")), newcu.getSource()); 1088 assertEqualLines("invalid renaming AA", getFileContents(getOutputTestFileName("AA")), newcuAA.getSource()); 1089 } 1090 @Test test31()1091 public void test31() throws Exception { 1092 createCUfromTestFile(getPackageP(), "AA"); 1093 1094 ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); 1095 IType classA= getType(cu, "A"); 1096 1097 assertNull("was supposed to pass", performRefactoring(createRefactoringDescriptor(classA, "B"))); 1098 1099 ICompilationUnit newcu= getPackageP().getCompilationUnit("B.java"); 1100 ICompilationUnit newcuAA= getPackageP().getCompilationUnit("AA.java"); 1101 assertEqualLines("invalid renaming A", getFileContents(getOutputTestFileName("B")), newcu.getSource()); 1102 assertEqualLines("invalid renaming AA", getFileContents(getOutputTestFileName("AA")), newcuAA.getSource()); 1103 } 1104 @Test test32()1105 public void test32() throws Exception { 1106 helper2("A", "B"); 1107 } 1108 1109 @Test test33()1110 public void test33() throws Exception { 1111 helper2("A", "B"); 1112 } 1113 1114 @Test test34()1115 public void test34() throws Exception { 1116 helper2("A", "B"); 1117 } 1118 1119 @Test test35()1120 public void test35() throws Exception { 1121 helper2("A", "B"); 1122 } 1123 1124 @Test test36()1125 public void test36() throws Exception { 1126 helper2("A", "B"); 1127 } 1128 1129 @Test test37()1130 public void test37() throws Exception { 1131 helper2("A", "B"); 1132 } 1133 1134 @Test test38()1135 public void test38() throws Exception { 1136 helper2("A", "B"); 1137 } 1138 1139 @Test test39()1140 public void test39() throws Exception { 1141 helper2("A", "B"); 1142 } 1143 1144 @Test test4()1145 public void test4() throws Exception { 1146 helper2("A", "B"); 1147 } 1148 1149 @Test test40()1150 public void test40() throws Exception { 1151 //printTestDisabledMessage("search engine bug"); 1152 helper2("A", "B"); 1153 } 1154 1155 @Test test41()1156 public void test41() throws Exception { 1157 helper2("A", "B"); 1158 } 1159 1160 @Test test42()1161 public void test42() throws Exception { 1162 helper2("A", "B"); 1163 } 1164 1165 @Test test43()1166 public void test43() throws Exception { 1167 helper2("A", "B"); 1168 } 1169 1170 @Test test44()1171 public void test44() throws Exception { 1172 helper2("A", "B"); 1173 } 1174 1175 @Test test45()1176 public void test45() throws Exception { 1177 helper2("A", "B"); 1178 } 1179 1180 @Test test46()1181 public void test46() throws Exception { 1182 IPackageFragment packageP1= getRoot().createPackageFragment("p1", true, null); 1183 createCUfromTestFile(packageP1, "C"); 1184 1185 ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); 1186 IType classA= getType(cu, "A"); 1187 1188 assertNull("was supposed to pass", performRefactoring(createRefactoringDescriptor(classA, "B"))); 1189 1190 ICompilationUnit newcu= getPackageP().getCompilationUnit("B.java"); 1191 ICompilationUnit newcuC= packageP1.getCompilationUnit("C.java"); 1192 assertEqualLines("invalid renaming A", getFileContents(getOutputTestFileName("B")), newcu.getSource()); 1193 assertEqualLines("invalid renaming C", getFileContents(getOutputTestFileName("C")), newcuC.getSource()); 1194 } 1195 1196 @Test test47()1197 public void test47() throws Exception { 1198 helper2("A", "B"); 1199 } 1200 1201 @Test test48()1202 public void test48() throws Exception { 1203 helper2("A", "B"); 1204 } 1205 1206 @Test test49()1207 public void test49() throws Exception { 1208 helper2("A", "B"); 1209 } 1210 1211 @Test test50()1212 public void test50() throws Exception { 1213 printTestDisabledMessage("https://bugs.eclipse.org/bugs/show_bug.cgi?id=54948"); 1214 if (BUG_54948) 1215 helper2("A", "B"); 1216 } 1217 1218 @Test test51()1219 public void test51() throws Exception { 1220 IPackageFragment packageP1= getRoot().createPackageFragment("p1", true, null); 1221 createCUfromTestFile(packageP1, "C"); 1222 1223 ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); 1224 IType classA= getType(cu, "A"); 1225 1226 assertNull("was supposed to pass", performRefactoring(createRefactoringDescriptor(classA, "B"))); 1227 1228 ICompilationUnit newcu= getPackageP().getCompilationUnit("B.java"); 1229 ICompilationUnit newcuC= packageP1.getCompilationUnit("C.java"); 1230 assertEqualLines("invalid renaming A", getFileContents(getOutputTestFileName("B")), newcu.getSource()); 1231 assertEqualLines("invalid renaming C", getFileContents(getOutputTestFileName("C")), newcuC.getSource()); 1232 } 1233 1234 @Test test52()1235 public void test52() throws Exception { 1236 //printTestDisabledMessage("1GJY2XN: ITPJUI:WIN2000 - rename type: error when with reference"); 1237 helper2("A", "B"); 1238 } 1239 1240 @Test test53()1241 public void test53() throws Exception { 1242 helper2("A", "B", false); 1243 } 1244 1245 @Test test54()1246 public void test54() throws Exception { 1247 //printTestDisabledMessage("waiting for: 1GKAQJS: ITPJCORE:WIN2000 - search: incorrect results for nested types"); 1248 helperWithTextual("A", "X", "XYZ", "A", true, false); 1249 } 1250 1251 @Test test55()1252 public void test55() throws Exception { 1253 //printTestDisabledMessage("waiting for: 1GKAQJS: ITPJCORE:WIN2000 - search: incorrect results for nested types"); 1254 helperWithTextual("A", "X", "XYZ", "A", false, false); 1255 } 1256 1257 @Test test57()1258 public void test57() throws Exception { 1259 helperWithTextual("A", "A", "B", "B", true, true); 1260 } 1261 1262 @Test test58()1263 public void test58() throws Exception { 1264 //printTestDisabledMessage("bug#16751"); 1265 helper2("A", "B"); 1266 } 1267 1268 @Test test59()1269 public void test59() throws Exception { 1270 // printTestDisabledMessage("bug#22938"); 1271 helper2("A", "B"); 1272 } 1273 1274 @Test test60()1275 public void test60() throws Exception { 1276 // printTestDisabledMessage("test for bug 24740"); 1277 helperWithTextual("A", "A", "B", "B", true, true); 1278 } 1279 1280 @Test test61()1281 public void test61() throws Exception { 1282 ParticipantTesting.reset(); 1283 String[] renameHandles= helperWithTextual("A" , "Inner", "InnerB", "A", true, false); 1284 ParticipantTesting.testRename(renameHandles, 1285 new RenameArguments[] { 1286 new RenameArguments("InnerB", true), 1287 }); 1288 } 1289 1290 @Test test62()1291 public void test62() throws Exception { 1292 // printTestDisabledMessage("test for bug 66250"); 1293 helperWithTextual("A", "A", "B", "B", false, true); 1294 } 1295 1296 @Test test63()1297 public void test63() throws Exception { 1298 // printTestDisabledMessage("test for bug 79131"); 1299 IPackageFragment anotherP= getRoot().createPackageFragment("another.p", true, null); 1300 String folder= "anotherp/"; 1301 String type= "A"; 1302 ICompilationUnit cu= createCUfromTestFile(anotherP, type, folder); 1303 1304 helperWithTextual(type, type, "B", "B", true, true); 1305 1306 assertEqualLines("invalid renaming in another.p.A", getFileContents(getOutputTestFileName(type, folder)), cu.getSource()); 1307 } 1308 1309 @Test test64()1310 public void test64() throws Exception { 1311 // printTestDisabledMessage("test for bug 79131"); 1312 IPackageFragment p2= getRoot().createPackageFragment("p2", true, null); 1313 String folder= "p2/"; 1314 String type= "A"; 1315 ICompilationUnit cu= createCUfromTestFile(p2, type, folder); 1316 1317 helperWithTextual(type, type, "B", "B", true, true); 1318 1319 assertEqualLines("invalid renaming in p2.A", getFileContents(getOutputTestFileName(type, folder)), cu.getSource()); 1320 } 1321 1322 @Test test65()1323 public void test65() throws Exception { 1324 // https://bugs.eclipse.org/356677 1325 IPackageFragment packageP1= getRoot().createPackageFragment("p1", true, null); 1326 IPackageFragment packageP2= getRoot().createPackageFragment("p2", true, null); 1327 1328 IType classA= getClassFromTestFile(packageP1, "A"); 1329 IType classB= getClassFromTestFile(packageP1, "B"); 1330 IType classC= getClassFromTestFile(packageP2, "C"); 1331 1332 RefactoringStatus result= performRefactoring(createRefactoringDescriptor(classA, "C")); 1333 assertNull("was supposed to pass", result); 1334 1335 assertEqualLines("invalid renaming A", getFileContents(getOutputTestFileName("NewC")), packageP1.getCompilationUnit("C.java").getSource()); 1336 assertEqualLines("invalid renaming in B", getFileContents(getOutputTestFileName("B")), classB.getCompilationUnit().getSource()); 1337 assertEqualLines("invalid renaming in C", getFileContents(getOutputTestFileName("C")), classC.getCompilationUnit().getSource()); 1338 } 1339 1340 @Test test66()1341 public void test66() throws Exception { 1342 //https://bugs.eclipse.org/bugs/show_bug.cgi?id=365380 1343 helperWithTextual("B", "A", "B", "B", true, true); 1344 } 1345 1346 @Test test5()1347 public void test5() throws Exception { 1348 helper2("A", "B"); 1349 } 1350 1351 @Test test6()1352 public void test6() throws Exception { 1353 helper2("A", "B"); 1354 } 1355 1356 @Test test7()1357 public void test7() throws Exception { 1358 helper2("A", "B"); 1359 } 1360 1361 @Test test8()1362 public void test8() throws Exception { 1363 helper2("A", "B"); 1364 } 1365 1366 @Test test9()1367 public void test9() throws Exception { 1368 helper2("A", "B"); 1369 } 1370 1371 @Test testUnicode01()1372 public void testUnicode01() throws Exception { 1373 helper2("B", "C"); 1374 //TODO: test undo! 1375 } 1376 1377 @Test testQualifiedName1()1378 public void testQualifiedName1() throws Exception { 1379 helperQualifiedName("A", "B", "build.xml", "*.xml"); 1380 } 1381 1382 @Test testQualifiedName2()1383 public void testQualifiedName2() throws Exception { 1384 helperQualifiedName("Transient", "TransientEquipment", "mapping.hbm.xml", "*.xml"); 1385 } 1386 helperQualifiedName(String oldName, String newName, String textFileName, String filePatterns)1387 private void helperQualifiedName(String oldName, String newName, String textFileName, String filePatterns) throws Exception { 1388 ICompilationUnit cu= createCUfromTestFile(getPackageP(), oldName); 1389 IType classA= getType(cu, oldName); 1390 1391 String content= getFileContents(getTestPath() + getName() + TEST_INPUT_INFIX + textFileName); 1392 IProject project= classA.getJavaProject().getProject(); 1393 IFile file= project.getFile(textFileName); 1394 file.create(new ByteArrayInputStream(content.getBytes()), true, null); 1395 1396 RenameJavaElementDescriptor descriptor= createRefactoringDescriptor(classA, newName); 1397 descriptor.setUpdateQualifiedNames(true); 1398 descriptor.setFileNamePatterns(filePatterns); 1399 1400 assertNull("was supposed to pass", performRefactoring(descriptor)); 1401 1402 ICompilationUnit newcu= getPackageP().getCompilationUnit(newName + ".java"); 1403 assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName(newName)), newcu.getSource()); 1404 InputStreamReader reader= new InputStreamReader(file.getContents(true)); 1405 StringBuilder newContent= new StringBuilder(); 1406 try { 1407 int ch; 1408 while((ch= reader.read()) != -1) 1409 newContent.append((char)ch); 1410 } finally { 1411 reader.close(); 1412 } 1413 String definedContent= getFileContents(getTestPath() + getName() + TEST_OUTPUT_INFIX + textFileName); 1414 assertEqualLines("invalid updating", definedContent, newContent.toString()); 1415 } 1416 1417 @Test testGenerics1()1418 public void testGenerics1() throws Exception { 1419 helper2("A", "B"); 1420 } 1421 1422 @Test testGenerics2()1423 public void testGenerics2() throws Exception { 1424 helper2("A", "B"); 1425 } 1426 1427 @Test testGenerics3()1428 public void testGenerics3() throws Exception { 1429 helper2("A", "B"); 1430 } 1431 1432 @Test testGenerics4()1433 public void testGenerics4() throws Exception { 1434 helper2("A", "B"); 1435 } 1436 1437 @Test testEnum1()1438 public void testEnum1() throws Exception { 1439 IPackageFragment p2= getRoot().createPackageFragment("p2", true, null); 1440 String folder= "p2/"; 1441 String type= "A"; 1442 ICompilationUnit cu= createCUfromTestFile(p2, type, folder); 1443 1444 helper2("A", "B"); 1445 1446 assertEqualLines("invalid renaming in p2.A", getFileContents(getOutputTestFileName(type, folder)), cu.getSource()); 1447 } 1448 1449 @Test testEnum2()1450 public void testEnum2() throws Exception { 1451 helper2("A", "B"); 1452 } 1453 1454 @Test testEnum3()1455 public void testEnum3() throws Exception { 1456 ICompilationUnit enumbered= createCUfromTestFile(getPackageP(), "Enumbered"); 1457 helper2("A", "B"); 1458 assertEqualLines("invalid renaming in Enumbered", getFileContents(getOutputTestFileName("Enumbered")), enumbered.getSource()); 1459 } 1460 1461 @Test testEnum4()1462 public void testEnum4() throws Exception { 1463 helperWithTextual("A" , "A", "B", "A", true, false); 1464 } 1465 1466 @Test testEnum5()1467 public void testEnum5() throws Exception { 1468 helper2("A", "B"); 1469 } 1470 1471 @Test testAnnotation1()1472 public void testAnnotation1() throws Exception { 1473 helper2("A", "B"); 1474 } 1475 1476 @Test testAnnotation2()1477 public void testAnnotation2() throws Exception { 1478 helper2("A", "B"); 1479 } 1480 1481 @Test testAnnotation3()1482 public void testAnnotation3() throws Exception { 1483 helperWithTextual("A" , "A", "B", "A", true, true); 1484 } 1485 1486 // --------------- Similarly named elements ----------------- 1487 1488 @Test testSimilarElements00()1489 public void testSimilarElements00() throws Exception { 1490 // Very basic test, one field, two methods 1491 helper3("SomeClass", "SomeClass2", true, false, true); 1492 } 1493 1494 @Test testSimilarElements01()1495 public void testSimilarElements01() throws Exception { 1496 // Already existing field with new name, shadow-error from field refac 1497 helper3_fail("SomeClass", "SomeClass2", true, false, true); 1498 } 1499 1500 @Test testSimilarElements02()1501 public void testSimilarElements02() throws Exception { 1502 // Already existing method 1503 helper3_fail("SomeClass", "SomeDifferentClass", true, false, true); 1504 } 1505 1506 @Test testSimilarElements03()1507 public void testSimilarElements03() throws Exception { 1508 // more methods 1509 helper3("SomeClass", "SomeClass2", true, false, true); 1510 } 1511 @Test testSimilarElements04()1512 public void testSimilarElements04() throws Exception { 1513 //Additional field with exactly the same name and getters and setters in another class 1514 getClassFromTestFile(getPackageP(), "SomeOtherClass"); 1515 helper3("SomeClass", "SomeClass2", true, false, true); 1516 checkResultInClass("SomeOtherClass"); 1517 } 1518 1519 @Test testSimilarElements05()1520 public void testSimilarElements05() throws Exception { 1521 //qualified name updating 1522 //includes textual updating 1523 String content= getFileContents(getTestPath() + "testSimilarElements05/in/test.html"); 1524 IProject project= getPackageP().getJavaProject().getProject(); 1525 IFile file= project.getFile("test.html"); 1526 file.create(new ByteArrayInputStream(content.getBytes()), true, null); 1527 1528 helper3("SomeClass", "SomeDifferentClass", true, true, true, "test.html"); 1529 1530 InputStreamReader reader= new InputStreamReader(file.getContents(true)); 1531 StringBuilder newContent= new StringBuilder(); 1532 try { 1533 int ch; 1534 while((ch= reader.read()) != -1) 1535 newContent.append((char)ch); 1536 } finally { 1537 reader.close(); 1538 } 1539 String definedContent= getFileContents(getTestPath() + "testSimilarElements05/out/test.html"); 1540 assertEqualLines("invalid updating test.html", newContent.toString(), definedContent); 1541 1542 } 1543 1544 @Test testSimilarElements06()1545 public void testSimilarElements06() throws Exception { 1546 //Additional field with exactly the same name and getters and setters in another class 1547 //includes textual updating 1548 // printTestDisabledMessage("potential matches in comments issue (bug 111891)"); 1549 getClassFromTestFile(getPackageP(), "SomeNearlyIdenticalClass"); 1550 helper3("SomeClass", "SomeOtherClass", true, true, true); 1551 checkResultInClass("SomeNearlyIdenticalClass"); 1552 } 1553 1554 @Test testSimilarElements07()1555 public void testSimilarElements07() throws Exception { 1556 //Test 4 fields in one file, different suffixes/prefixes, incl. 2x setters/getters 1557 //includes textual updating 1558 helper3("SomeClass", "SomeDiffClass", true, true, true); 1559 } 1560 1561 @Test testSimilarElements08()1562 public void testSimilarElements08() throws Exception { 1563 //Interface renaming fun, this time without textual 1564 helper3("ISomeIf", "ISomeIf2", true, false, true); 1565 } 1566 1567 @Test testSimilarElements09()1568 public void testSimilarElements09() throws Exception { 1569 //Some inner types 1570 //includes textual updating 1571 getClassFromTestFile(getPackageP(), "SomeOtherClass"); 1572 helper3_inner("SomeClass", "SomeInnerClass", "SomeClass", "SomeNewInnerClass", true, true, true, null); 1573 checkResultInClass("SomeOtherClass"); 1574 } 1575 1576 @Test testSimilarElements10()1577 public void testSimilarElements10() throws Exception { 1578 //Two static fields 1579 getClassFromTestFile(getPackageP(), "SomeOtherClass"); 1580 helper3("SomeClass", "SomeClass2", true, false, true, null); 1581 checkResultInClass("SomeOtherClass"); 1582 } 1583 1584 @Test testSimilarElements11()1585 public void testSimilarElements11() throws Exception { 1586 //Assure participants get notified of normal stuff (type rename 1587 //and resource changes) AND similarly named elements. 1588 ParticipantTesting.reset(); 1589 ICompilationUnit cu= createCUfromTestFile(getPackageP(), "SomeClass"); 1590 IType someClass= getType(cu, "SomeClass"); 1591 IType other= getClassFromTestFile(getPackageP(), "SomeOtherClass"); 1592 1593 List<IAdaptable> handleList= new ArrayList<>(); 1594 List<RenameArguments> argumentList= new ArrayList<>(); 1595 1596 List<String> similarOldHandleList= new ArrayList<>(); 1597 List<String> similarNewNameList= new ArrayList<>(); 1598 List<String> similarNewHandleList= new ArrayList<>(); 1599 1600 final String newName= "SomeNewClass"; 1601 1602 // f-Field + getters/setters 1603 IField f3= other.getField("fSomeClass"); 1604 similarOldHandleList.add(f3.getHandleIdentifier()); 1605 similarNewHandleList.add("Lp/SomeOtherClass;.fSomeNewClass"); 1606 similarNewNameList.add("fSomeNewClass"); 1607 1608 IMethod m3= other.getMethod("getSomeClass", new String[0]); 1609 similarOldHandleList.add(m3.getHandleIdentifier()); 1610 similarNewNameList.add("getSomeNewClass"); 1611 similarNewHandleList.add("Lp/SomeOtherClass;.getSomeNewClass()V"); 1612 IMethod m4= other.getMethod("setSomeClass", new String[] {"QSomeClass;"}); 1613 similarOldHandleList.add(m4.getHandleIdentifier()); 1614 similarNewNameList.add("setSomeNewClass"); 1615 similarNewHandleList.add("Lp/SomeOtherClass;.setSomeNewClass(QSomeNewClass;)V"); 1616 1617 // non-f-field + getter/setters 1618 IField f1= someClass.getField("someClass"); 1619 similarOldHandleList.add(f1.getHandleIdentifier()); 1620 similarNewNameList.add("someNewClass"); 1621 similarNewHandleList.add("Lp/SomeNewClass;.someNewClass"); 1622 IMethod m1= someClass.getMethod("getSomeClass", new String[0]); 1623 similarOldHandleList.add(m1.getHandleIdentifier()); 1624 similarNewNameList.add("getSomeNewClass"); 1625 similarNewHandleList.add("Lp/SomeNewClass;.getSomeNewClass()V"); 1626 IMethod m2= someClass.getMethod("setSomeClass", new String[] {"QSomeClass;"}); 1627 similarOldHandleList.add(m2.getHandleIdentifier()); 1628 similarNewNameList.add("setSomeNewClass"); 1629 similarNewHandleList.add("Lp/SomeNewClass;.setSomeNewClass(QSomeNewClass;)V"); 1630 1631 // fs-field 1632 IField f2= someClass.getField("fsSomeClass"); 1633 similarOldHandleList.add(f2.getHandleIdentifier()); 1634 similarNewNameList.add("fsSomeNewClass"); 1635 similarNewHandleList.add("Lp/SomeNewClass;.fsSomeNewClass"); 1636 1637 // Type Stuff 1638 handleList.add(someClass); 1639 argumentList.add(new RenameArguments(newName, true)); 1640 handleList.add(cu); 1641 argumentList.add(new RenameArguments(newName + ".java", true)); 1642 handleList.add(cu.getResource()); 1643 argumentList.add(new RenameArguments(newName + ".java", true)); 1644 1645 String[] handles= ParticipantTesting.createHandles(handleList.toArray()); 1646 RenameArguments[] arguments= argumentList.toArray(new RenameArguments[0]); 1647 1648 RenameJavaElementDescriptor descriptor= createRefactoringDescriptor(someClass, newName); 1649 setTheOptions(descriptor, true, false, true, null, RenamingNameSuggestor.STRATEGY_EMBEDDED); 1650 RefactoringStatus status= performRefactoring(descriptor); 1651 assertNull("was supposed to pass", status); 1652 1653 checkResultInClass(newName); 1654 checkResultInClass("SomeOtherClass"); 1655 1656 ParticipantTesting.testRename(handles, arguments); 1657 ParticipantTesting.testSimilarElements(similarOldHandleList, similarNewNameList, similarNewHandleList); 1658 } 1659 1660 @Test testSimilarElements12()1661 public void testSimilarElements12() throws Exception { 1662 // Test updating of references 1663 helper3("SomeFieldClass", "SomeOtherFieldClass", true, false, true); 1664 } 1665 1666 @Test testSimilarElements13()1667 public void testSimilarElements13() throws Exception { 1668 // Test various locals and parameters with and without prefixes. 1669 // tests not renaming parameters with local prefixes and locals with parameter prefixes 1670 helper3("SomeClass", "SomeOtherClass", true, false, true); 1671 } 1672 1673 @Test testSimilarElements14()1674 public void testSimilarElements14() throws Exception { 1675 // Test for loop variables 1676 helper3("SomeClass2", "SomeOtherClass2", true, false, true); 1677 } 1678 1679 @Test testSimilarElements15()1680 public void testSimilarElements15() throws Exception { 1681 // Test catch block variables (exceptions) 1682 helper3("SomeClass3", "SomeOtherClass3", true, false, true); 1683 } 1684 1685 @Test testSimilarElements16()1686 public void testSimilarElements16() throws Exception { 1687 // Test updating of references 1688 helper3("SomeClass4", "SomeOtherClass4", true, false, true); 1689 } 1690 1691 @Test testSimilarElements17()1692 public void testSimilarElements17() throws Exception { 1693 // Local with this name already exists - do not pass. 1694 helper3_fail("SomeClass6", "SomeOtherClass6", true, false, true); 1695 } 1696 1697 @Test testSimilarElements18()1698 public void testSimilarElements18() throws Exception { 1699 // factory method 1700 helper3("SomeClass", "SomeOtherClass", true, false, true); 1701 } 1702 1703 @Test testSimilarElements19()1704 public void testSimilarElements19() throws Exception { 1705 // Test detection of same target 1706 helper3_fail("ThreeHunkClass", "TwoHunk", true, false, true, RenamingNameSuggestor.STRATEGY_SUFFIX); 1707 } 1708 1709 @Test testSimilarElements20()1710 public void testSimilarElements20() throws Exception { 1711 // Overridden method, check both are renamed 1712 getClassFromTestFile(getPackageP(), "OtherClass"); 1713 helper3("OverriddenMethodClass", "ThirdClass", true, false, true); 1714 checkResultInClass("OtherClass"); 1715 } 1716 1717 @Test testSimilarElements21()1718 public void testSimilarElements21() throws Exception { 1719 // Constructors may not be renamed 1720 getClassFromTestFile(getPackageP(), "SomeClassSecond"); 1721 helper3("SomeClass", "SomeNewClass", true, false, true); 1722 checkResultInClass("SomeClassSecond"); 1723 } 1724 1725 @Test testSimilarElements22()1726 public void testSimilarElements22() throws Exception { 1727 // Test transplanter for fields in types inside of initializers 1728 1729 ParticipantTesting.reset(); 1730 ICompilationUnit cu= createCUfromTestFile(getPackageP(), "SomeClass"); 1731 IType someClass= getType(cu, "SomeClass"); 1732 1733 List<IAdaptable> handleList= new ArrayList<>(); 1734 List<RenameArguments> argumentList= new ArrayList<>(); 1735 1736 List<String> similarOldHandleList= new ArrayList<>(); 1737 List<String> similarNewNameList= new ArrayList<>(); 1738 List<String> similarNewHandleList= new ArrayList<>(); 1739 1740 final String newName= "SomeNewClass"; 1741 1742 // field in class in initializer 1743 IField inInitializer= someClass.getInitializer(1).getType("InInitializer", 1).getField("someClassInInitializer"); 1744 similarOldHandleList.add(inInitializer.getHandleIdentifier()); 1745 similarNewNameList.add("someNewClassInInitializer"); 1746 similarNewHandleList.add("Lp/SomeNewClass$InInitializer;.someNewClassInInitializer"); 1747 1748 // Type Stuff 1749 handleList.add(someClass); 1750 argumentList.add(new RenameArguments(newName, true)); 1751 handleList.add(cu); 1752 argumentList.add(new RenameArguments(newName + ".java", true)); 1753 handleList.add(cu.getResource()); 1754 argumentList.add(new RenameArguments(newName + ".java", true)); 1755 1756 String[] handles= ParticipantTesting.createHandles(handleList.toArray()); 1757 RenameArguments[] arguments= argumentList.toArray(new RenameArguments[0]); 1758 1759 RenameJavaElementDescriptor descriptor= createRefactoringDescriptor(someClass, newName); 1760 setTheOptions(descriptor, true, false, true, null, RenamingNameSuggestor.STRATEGY_EMBEDDED); 1761 RefactoringStatus status= performRefactoring(descriptor); 1762 assertNull("was supposed to pass", status); 1763 1764 checkResultInClass(newName); 1765 1766 ParticipantTesting.testRename(handles, arguments); 1767 ParticipantTesting.testSimilarElements(similarOldHandleList, similarNewNameList, similarNewHandleList); 1768 1769 } 1770 1771 @Test testSimilarElements23()1772 public void testSimilarElements23() throws Exception { 1773 // Test transplanter for elements inside types inside fields 1774 1775 ParticipantTesting.reset(); 1776 ICompilationUnit cu= createCUfromTestFile(getPackageP(), "SomeClass"); 1777 IType someClass= getType(cu, "SomeClass"); 1778 1779 List<IAdaptable> handleList= new ArrayList<>(); 1780 List<RenameArguments> argumentList= new ArrayList<>(); 1781 1782 List<String> similarOldHandleList= new ArrayList<>(); 1783 List<String> similarNewNameList= new ArrayList<>(); 1784 List<String> similarNewHandleList= new ArrayList<>(); 1785 1786 final String newName= "SomeNewClass"; 1787 1788 // some field 1789 IField anotherSomeClass= someClass.getField("anotherSomeClass"); 1790 similarOldHandleList.add(anotherSomeClass.getHandleIdentifier()); 1791 similarNewNameList.add("anotherSomeNewClass"); 1792 similarNewHandleList.add("Lp/SomeNewClass;.anotherSomeNewClass"); 1793 1794 // field in class in method in field declaration ;) 1795 IField inInner= anotherSomeClass.getType("", 1).getMethod("foo", new String[0]).getType("X", 1).getField("someClassInInner"); 1796 similarOldHandleList.add(inInner.getHandleIdentifier()); 1797 similarNewNameList.add("someNewClassInInner"); 1798 similarNewHandleList.add("Lp/SomeNewClass$1$X;.someNewClassInInner"); 1799 1800 // Type Stuff 1801 handleList.add(someClass); 1802 argumentList.add(new RenameArguments(newName, true)); 1803 handleList.add(cu); 1804 argumentList.add(new RenameArguments(newName + ".java", true)); 1805 handleList.add(cu.getResource()); 1806 argumentList.add(new RenameArguments(newName + ".java", true)); 1807 1808 String[] handles= ParticipantTesting.createHandles(handleList.toArray()); 1809 RenameArguments[] arguments= argumentList.toArray(new RenameArguments[0]); 1810 1811 RenameJavaElementDescriptor descriptor= createRefactoringDescriptor(someClass, newName); 1812 setTheOptions(descriptor, true, false, true, null, RenamingNameSuggestor.STRATEGY_EMBEDDED); 1813 RefactoringStatus status= performRefactoring(descriptor); 1814 assertNull("was supposed to pass", status); 1815 1816 checkResultInClass(newName); 1817 1818 ParticipantTesting.testRename(handles, arguments); 1819 ParticipantTesting.testSimilarElements(similarOldHandleList, similarNewNameList, similarNewHandleList); 1820 } 1821 1822 @Test testSimilarElements24()1823 public void testSimilarElements24() throws Exception { 1824 // Test transplanter for ICompilationUnit and IFile 1825 1826 ParticipantTesting.reset(); 1827 ICompilationUnit cu= createCUfromTestFile(getPackageP(), "SomeClass"); 1828 IType someClass= getType(cu, "SomeClass"); 1829 IJavaElement[] someClassMembers= someClass.getChildren(); 1830 1831 RenameJavaElementDescriptor descriptor= createRefactoringDescriptor(someClass, "SomeNewClass"); 1832 setTheOptions(descriptor, true, false, true, null, RenamingNameSuggestor.STRATEGY_EMBEDDED); 1833 Refactoring ref= createRefactoring(descriptor); 1834 RefactoringStatus status= performRefactoring(ref); 1835 assertNull("was supposed to pass", status); 1836 1837 checkResultInClass("SomeNewClass"); 1838 1839 checkMappers(ref, someClass, "SomeNewClass.java", someClassMembers); 1840 } 1841 checkMappers(Refactoring refactoring, IType type, String newCUName, IJavaElement[] someClassMembers)1842 private void checkMappers(Refactoring refactoring, IType type, String newCUName, IJavaElement[] someClassMembers) { 1843 RenameTypeProcessor rtp= (RenameTypeProcessor)((RenameRefactoring) refactoring).getProcessor(); 1844 1845 ICompilationUnit newUnit= (ICompilationUnit)rtp.getRefactoredJavaElement(type.getCompilationUnit()); 1846 assertTrue(newUnit.exists()); 1847 assertEquals(newUnit.getElementName(), newCUName); 1848 1849 IFile newFile= (IFile)rtp.getRefactoredResource(type.getResource()); 1850 assertTrue(newFile.exists()); 1851 assertEquals(newFile.getName(), newCUName); 1852 1853 if ((type.getParent().getElementType() == IJavaElement.COMPILATION_UNIT) 1854 && type.getCompilationUnit().getElementName().equals(type.getElementName() + ".java")) { 1855 assertFalse(type.getCompilationUnit().exists()); 1856 assertFalse(type.getResource().exists()); 1857 } 1858 1859 IPackageFragment oldPackage= (IPackageFragment)type.getCompilationUnit().getParent(); 1860 IPackageFragment newPackage= (IPackageFragment)rtp.getRefactoredJavaElement(oldPackage); 1861 assertEquals(oldPackage, newPackage); 1862 1863 for (IJavaElement someClassMember : someClassMembers) { 1864 IMember member= (IMember) someClassMember; 1865 IJavaElement refactoredMember= rtp.getRefactoredJavaElement(member); 1866 if (member instanceof IMethod && member.getElementName().equals(type.getElementName())) 1867 continue; // constructor 1868 assertTrue(refactoredMember.exists()); 1869 assertEquals(member.getElementName(), refactoredMember.getElementName()); 1870 assertNotEquals(refactoredMember, member); 1871 } 1872 } 1873 1874 @Test testSimilarElements25()1875 public void testSimilarElements25() throws Exception { 1876 // Test renaming of several-in-one field declarations 1877 helper3("ScrewUp", "ScrewDown", true, false, true); 1878 } 1879 1880 @Test testSimilarElements26()1881 public void testSimilarElements26() throws Exception { 1882 // Test renaming of several-in-one local variable declarations 1883 helper3("ScrewUp", "ScrewDown", true, false, true); 1884 } 1885 1886 @Test testSimilarElements27()1887 public void testSimilarElements27() throws Exception { 1888 // Test methods are not renamed if the match is 1889 // not either a parameter or a return type 1890 helper3("ScrewUp", "ScrewDown", true, false, true); 1891 } 1892 1893 @Test testSimilarElements28()1894 public void testSimilarElements28() throws Exception { 1895 // Test local variables are not renamed if the match is 1896 // not the type of the local variable itself 1897 helper3("ScrewUp", "ScrewDown", true, false, true); 1898 } 1899 1900 @Test testSimilarElements29()1901 public void testSimilarElements29() throws Exception { 1902 // Test fields are not renamed if the match is 1903 // not the type of the field itself 1904 helper3("ScrewUp", "ScrewDown", true, false, true); 1905 } 1906 1907 @Test testSimilarElements30()1908 public void testSimilarElements30() throws Exception { 1909 // Test local variables in initializers 1910 helper3("SomeClass", "SomeNewClass", true, false, true); 1911 } 1912 1913 @Test testSimilarElements31()1914 public void testSimilarElements31() throws Exception { 1915 // Test references and textual references to local elements 1916 helper3("SomeClass", "SomeDiffClass", true, true, true); 1917 } 1918 1919 @Test testSimilarElements32()1920 public void testSimilarElements32() throws Exception { 1921 // Test whether local variable problem reporting still works 1922 helper3_fail("SomeClass", "SomeDifferentClass", true, false, true); 1923 } 1924 1925 @Test testSimilarElements33()1926 public void testSimilarElements33() throws Exception { 1927 // Test two local variables inside anonymous types do not generate warnings 1928 helper3("Why", "WhyNot", true, false, true); 1929 } 1930 1931 @Test testSimilarElements34()1932 public void testSimilarElements34() throws Exception { 1933 // Test references in annotations and type parameters 1934 helper3("Try", "Bla", true, false, true); 1935 } 1936 } 1937