summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolay Metchev2013-08-28 03:58:56 (EDT)
committer Noopur Gupta2013-08-28 03:58:56 (EDT)
commit7acac94cbbccefac8bdf219e4587fd5562de555d (patch)
treed412536e020b44defb48c72b56b4a291cf22fa4e
parent0fbe2b6237757f39482f8d7ec96033c73d088d99 (diff)
downloadeclipse.jdt.ui-7acac94cbbccefac8bdf219e4587fd5562de555d.zip
eclipse.jdt.ui-7acac94cbbccefac8bdf219e4587fd5562de555d.tar.gz
eclipse.jdt.ui-7acac94cbbccefac8bdf219e4587fd5562de555d.tar.bz2
Fixed bug 217753: [move method] Move method with static imported methodI20130901-2000I20130831-1500I20130830-2000I20130829-2000I20130828-1800I20130828-1000
calls introduces compiler error Signed-off-by: Nikolay Metchev <nikolaymetchev@gmail.com>
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test58/in/A.java11
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test58/in/B.java5
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test58/out/A.java4
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test58/out/B.java13
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test59/in/A.java13
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test59/in/B.java4
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test59/out/A.java8
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test59/out/B.java11
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test60/in/A.java17
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test60/out/A.java18
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test61/in/A.java15
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test61/out/A.java16
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test62/in/A.java16
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test62/in/B.java6
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test62/out/A.java9
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test62/out/B.java15
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test63/in/A.java10
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test63/out/A.java11
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInstanceMethodTests.java31
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInstanceMethodProcessor.java12
20 files changed, 243 insertions, 2 deletions
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test58/in/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test58/in/A.java
new file mode 100644
index 0000000..543ff33
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test58/in/A.java
@@ -0,0 +1,11 @@
+package p;
+
+import static java.util.Arrays.asList;
+
+import java.util.List;
+
+public class A {
+ public List<String> abc(B b) {
+ return asList("a", b.toString());
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test58/in/B.java b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test58/in/B.java
new file mode 100644
index 0000000..ec3e38a
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test58/in/B.java
@@ -0,0 +1,5 @@
+package p;
+
+public class B {
+
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test58/out/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test58/out/A.java
new file mode 100644
index 0000000..d0fba05
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test58/out/A.java
@@ -0,0 +1,4 @@
+package p;
+
+
+public class A { } \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test58/out/B.java b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test58/out/B.java
new file mode 100644
index 0000000..7976393
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test58/out/B.java
@@ -0,0 +1,13 @@
+package p;
+
+import static java.util.Arrays.asList;
+
+import java.util.List;
+
+public class B {
+
+ public List<String> abc() {
+ return asList("a", toString());
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test59/in/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test59/in/A.java
new file mode 100644
index 0000000..ddeb48f
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test59/in/A.java
@@ -0,0 +1,13 @@
+package p;
+import static java.util.Arrays.asList;
+public class A {
+ class X {
+ void m(B b) {
+ asList(b.toString());
+ n();
+ }
+ }
+
+ public static void n() {
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test59/in/B.java b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test59/in/B.java
new file mode 100644
index 0000000..ae61754
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test59/in/B.java
@@ -0,0 +1,4 @@
+package p;
+
+public class B {
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test59/out/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test59/out/A.java
new file mode 100644
index 0000000..a083789
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test59/out/A.java
@@ -0,0 +1,8 @@
+package p;
+public class A {
+ class X {
+ }
+
+ public static void n() {
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test59/out/B.java b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test59/out/B.java
new file mode 100644
index 0000000..d1abcff
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test59/out/B.java
@@ -0,0 +1,11 @@
+package p;
+
+import static java.util.Arrays.asList;
+
+public class B {
+
+ void m() {
+ asList(toString());
+ A.n();
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test60/in/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test60/in/A.java
new file mode 100644
index 0000000..a1c7a08
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test60/in/A.java
@@ -0,0 +1,17 @@
+package p;
+import static java.util.Arrays.asList;
+public class A {
+ class X {
+ void m(B b) {
+ asList(b.toString());
+ n();
+ }
+ }
+
+ public static void n() {
+ }
+}
+
+class B {
+
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test60/out/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test60/out/A.java
new file mode 100644
index 0000000..c37260d
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test60/out/A.java
@@ -0,0 +1,18 @@
+package p;
+import static java.util.Arrays.asList;
+public class A {
+ class X {
+ }
+
+ public static void n() {
+ }
+}
+
+class B {
+
+ void m() {
+ asList(toString());
+ A.n();
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test61/in/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test61/in/A.java
new file mode 100644
index 0000000..c23f0ee
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test61/in/A.java
@@ -0,0 +1,15 @@
+package p;
+
+public class A {
+ public static class X {
+ void m(B b) {
+ n();
+ }
+ public static void n() {
+ }
+ }
+}
+
+class B {
+
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test61/out/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test61/out/A.java
new file mode 100644
index 0000000..14ba522
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test61/out/A.java
@@ -0,0 +1,16 @@
+package p;
+
+public class A {
+ public static class X {
+ public static void n() {
+ }
+ }
+}
+
+class B {
+
+ void m() {
+ A.X.n();
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test62/in/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test62/in/A.java
new file mode 100644
index 0000000..9d44bb9
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test62/in/A.java
@@ -0,0 +1,16 @@
+package p;
+
+import static java.util.Arrays.asList;
+import q.B;
+
+public class A {
+ public static class X {
+ void m(B.C c) {
+ n();
+ A.m();
+ asList("a","b");
+ }
+ public static void n() {}
+ }
+ public static void m() {}
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test62/in/B.java b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test62/in/B.java
new file mode 100644
index 0000000..ad80049
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test62/in/B.java
@@ -0,0 +1,6 @@
+package q;
+
+public class B {
+ public class C {
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test62/out/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test62/out/A.java
new file mode 100644
index 0000000..2bfaa6d
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test62/out/A.java
@@ -0,0 +1,9 @@
+package p;
+
+
+public class A {
+ public static class X {
+ public static void n() {}
+ }
+ public static void m() {}
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test62/out/B.java b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test62/out/B.java
new file mode 100644
index 0000000..d04a1df
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test62/out/B.java
@@ -0,0 +1,15 @@
+package q;
+
+import static java.util.Arrays.asList;
+import p.A;
+
+public class B {
+ public class C {
+
+ public void m() {
+ A.X.n();
+ A.m();
+ asList("a","b");
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test63/in/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test63/in/A.java
new file mode 100644
index 0000000..ba858f2
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test63/in/A.java
@@ -0,0 +1,10 @@
+public class A {
+ void m(B b) {
+ n();
+ }
+ public static void n() {};
+}
+
+class B {
+
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test63/out/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test63/out/A.java
new file mode 100644
index 0000000..2337a2d
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/MoveInstanceMethod/canMove/test63/out/A.java
@@ -0,0 +1,11 @@
+public class A {
+ public static void n() {};
+}
+
+class B {
+
+ void m() {
+ A.n();
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInstanceMethodTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInstanceMethodTests.java
index e5fee78..e37a2bf 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInstanceMethodTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInstanceMethodTests.java
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Nikolay Metchev <nikolaymetchev@gmail.com> - [move method] super method invocation does not compile after refactoring - https://bugs.eclipse.org/356687
+ * Nikolay Metchev <nikolaymetchev@gmail.com> - [move method] Move method with static imported method calls introduces compiler error - https://bugs.eclipse.org/217753
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
@@ -521,6 +522,36 @@ public class MoveInstanceMethodTests extends RefactoringTest {
helper1(new String[] { "p.A" }, "p.A", 5, 17, 5, 18, PARAMETER, "b", true, true);
}
+ //bug 217753
+ public void test58() throws Exception {
+ helper1(new String[] { "p.A", "p.B" }, "p.A", 8, 25, 8, 28, PARAMETER, "b", true, true);
+ }
+
+ // bug 217753
+ public void test59() throws Exception {
+ helper1(new String[] { "p.A", "p.B" }, "p.A", 5, 14, 5, 15, PARAMETER, "b", true, true);
+ }
+
+ // bug 217753
+ public void test60() throws Exception {
+ helper1(new String[] { "p.A" }, "p.A", 5, 14, 5, 15, PARAMETER, "b", true, true);
+ }
+
+ // bug 217753
+ public void test61() throws Exception {
+ helper1(new String[] { "p.A" }, "p.A", 5, 14, 5, 15, PARAMETER, "b", true, true);
+ }
+
+ // bug 217753
+ public void test62() throws Exception {
+ helper1(new String[] { "p.A", "q.B" }, "p.A", 8, 14, 8, 15, PARAMETER, "c", true, true);
+ }
+
+ // bug 217753
+ public void test63() throws Exception {
+ helper1(new String[] { "A" }, "A", 2, 10, 2, 11, PARAMETER, "b", true, true);
+ }
+
// Move mA1 to field fB, do not inline delegator
public void test3() throws Exception {
helper1(new String[] { "p1.A", "p2.B", "p3.C"}, "p1.A", 9, 17, 9, 20, FIELD, "fB", false, false);
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInstanceMethodProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInstanceMethodProcessor.java
index cac5f1a..60d6c5b 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInstanceMethodProcessor.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInstanceMethodProcessor.java
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Nikolay Metchev <nikolaymetchev@gmail.com> - [move method] super method invocation does not compile after refactoring - https://bugs.eclipse.org/356687
+ * Nikolay Metchev <nikolaymetchev@gmail.com> - [move method] Move method with static imported method calls introduces compiler error - https://bugs.eclipse.org/217753
*******************************************************************************/
package org.eclipse.jdt.internal.corext.refactoring.structure;
@@ -585,8 +586,15 @@ public final class MoveInstanceMethodProcessor extends MoveProcessor implements
final AST ast= node.getAST();
if (!JdtFlags.isStatic(method))
rewrite.set(node, MethodInvocation.EXPRESSION_PROPERTY, ast.newSimpleName(fTargetName), null);
- else
- rewrite.set(node, MethodInvocation.EXPRESSION_PROPERTY, ast.newSimpleType(ast.newSimpleName(fMethod.getDeclaringType().getElementName())), null);
+ else if (!fStaticImports.contains(method)) {
+ ITypeBinding declaring= method.getDeclaringClass();
+ if (declaring != null) {
+ IType type= (IType) declaring.getJavaElement();
+ if (type != null) {
+ rewrite.set(node, MethodInvocation.EXPRESSION_PROPERTY, ast.newName(type.getTypeQualifiedName('.')), null);
+ }
+ }
+ }
return true;
} else {
if (expression instanceof FieldAccess) {