Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2012-12-04 17:29:30 +0000
committerStephan Herrmann2012-12-04 17:29:30 +0000
commit9dc8e8860b9fa7710f42a7c1f6addb11bf2f4922 (patch)
treeeb4b17d9610b105ecb7abd03694fa8ecde03d8c5 /testplugins
parent18286b07fd11ed3b510816a22c1c6941aebef5c0 (diff)
downloadorg.eclipse.objectteams-9dc8e8860b9fa7710f42a7c1f6addb11bf2f4922.tar.gz
org.eclipse.objectteams-9dc8e8860b9fa7710f42a7c1f6addb11bf2f4922.tar.xz
org.eclipse.objectteams-9dc8e8860b9fa7710f42a7c1f6addb11bf2f4922.zip
Bug 394037 - [refactoring] renaming an argument with declared lifting
fails to rename occurrences
Diffstat (limited to 'testplugins')
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/misc/ChangeSignatureTests.java41
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ChangeSignature/canModify/A_testRename01_in.java12
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ChangeSignature/canModify/A_testRename01_out.java12
3 files changed, 65 insertions, 0 deletions
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/misc/ChangeSignatureTests.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/misc/ChangeSignatureTests.java
index b4c82f84e..eda6ba77b 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/misc/ChangeSignatureTests.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/misc/ChangeSignatureTests.java
@@ -195,6 +195,41 @@ public class ChangeSignatureTests extends RefactoringTest {
// assertParticipant(classA);
}
+ void helperRename(ICompilationUnit cu, IType declaringClass, String[] signature, int idx, String oldName, String newName, String expectedInfo)
+ throws JavaModelException, CoreException, Exception, IOException
+ {
+ IMethod method = declaringClass.getMethod("m", signature);
+ assertTrue("method does not exist", method.exists());
+ assertTrue("refactoring not available", RefactoringAvailabilityTester.isChangeSignatureAvailable(method));
+
+ ChangeSignatureProcessor processor= new ChangeSignatureProcessor(method);
+ Refactoring ref= new ProcessorBasedRefactoring(processor);
+
+ processor.setDelegateUpdating(false);
+ markAsRenamed(processor.getParameterInfos().get(idx), oldName, newName);
+ RefactoringStatus initialConditions= ref.checkInitialConditions(new NullProgressMonitor());
+ assertTrue("precondition was supposed to pass:"+initialConditions.getEntryWithHighestSeverity(), initialConditions.isOK());
+ RefactoringStatus result= performRefactoring(ref, true);
+ if (expectedInfo != null) {
+ assertTrue("precondition was supposed to create an info:"+result.getEntryWithHighestSeverity(), result.hasInfo());
+ assertEquals("wrong info", expectedInfo, result.getEntryMatchingSeverity(RefactoringStatus.INFO).getMessage());
+ } else {
+ assertEquals("precondition was supposed to pass", null, result);
+ }
+
+ IPackageFragment pack= (IPackageFragment)cu.getParent();
+ String newCuName= getSimpleTestFileName(true, true);
+ ICompilationUnit newcu= pack.getCompilationUnit(newCuName);
+ assertTrue(newCuName + " does not exist", newcu.exists());
+ String expectedFileContents= getFileContents(getTestFileName(true, false));
+ assertEqualLines("invalid content", expectedFileContents, newcu.getSource());
+ }
+
+ private void markAsRenamed(ParameterInfo parameterInfo, String oldName, String newName) {
+ assertEquals(parameterInfo.getOldName(), oldName);
+ parameterInfo.setNewName(newName);
+ }
+
private void helperPermute(String[] newOrder, String[] signature, boolean createDelegate) throws Exception{
ICompilationUnit cu= createCUfromTestFile(getPackageP(), true, true);
IType classA= getType(cu, "A");
@@ -328,4 +363,10 @@ public class ChangeSignatureTests extends RefactoringTest {
public void testReorder01() throws Exception {
helperPermute(new String[]{"ignore", "b", "a"}, new String[]{"I", "Z", "QString;"}, false);
}
+
+ public void testRename01() throws Exception {
+ ICompilationUnit cu= createCUfromTestFile(getPackageP(), true, true);
+ IType teamType = cu.getType("MyTeam");
+ helperRename(cu, teamType, new String[]{"QA;"}, 0, "arg", "renamed", null);
+ }
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ChangeSignature/canModify/A_testRename01_in.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ChangeSignature/canModify/A_testRename01_in.java
new file mode 100644
index 000000000..f1f38db15
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ChangeSignature/canModify/A_testRename01_in.java
@@ -0,0 +1,12 @@
+package p;
+
+class A {}
+
+team class MyTeam {
+ protected class R playedBy A {}
+
+ public Object m(A as R arg) {
+ System.out.println(arg);
+ return arg;
+ }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ChangeSignature/canModify/A_testRename01_out.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ChangeSignature/canModify/A_testRename01_out.java
new file mode 100644
index 000000000..b541af164
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ChangeSignature/canModify/A_testRename01_out.java
@@ -0,0 +1,12 @@
+package p;
+
+class A {}
+
+team class MyTeam {
+ protected class R playedBy A {}
+
+ public Object m(A as R renamed) {
+ System.out.println(renamed);
+ return renamed;
+ }
+} \ No newline at end of file

Back to the top