Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolay Metchev2013-08-12 06:08:33 +0000
committerNoopur Gupta2013-08-12 06:08:33 +0000
commitbc01471bb9bd65a3c133006714462002a4c84c6c (patch)
tree9fed46ffad0a20d767aa8a1f8df683ba9048c603
parente3c65d210e25f12e59c0b9d2a00b78049b2a3715 (diff)
downloadeclipse.jdt.ui-bc01471bb9bd65a3c133006714462002a4c84c6c.tar.gz
eclipse.jdt.ui-bc01471bb9bd65a3c133006714462002a4c84c6c.tar.xz
eclipse.jdt.ui-bc01471bb9bd65a3c133006714462002a4c84c6c.zip
Fixed bug 124978: [refactoring][convert anonymous] gets confused with
generic methods Signed-off-by: Nikolay Metchev <nikolaymetchev@gmail.com>
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/ConvertAnonymousToNested/canConvert/A_test33_in.java14
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/ConvertAnonymousToNested/canConvert/A_test33_out.java16
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests.java10
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ConvertAnonymousToNestedRefactoring.java11
4 files changed, 47 insertions, 4 deletions
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/ConvertAnonymousToNested/canConvert/A_test33_in.java b/org.eclipse.jdt.ui.tests.refactoring/resources/ConvertAnonymousToNested/canConvert/A_test33_in.java
new file mode 100644
index 0000000000..edf8947783
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/ConvertAnonymousToNested/canConvert/A_test33_in.java
@@ -0,0 +1,14 @@
+package p;
+public interface A{
+ <T> void a();
+ <T> void b();
+}
+
+class Z{
+ void m(){
+ A a = new A(){
+ public <T> void b(){}
+ public <T> void a(){}
+ };
+ }
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/ConvertAnonymousToNested/canConvert/A_test33_out.java b/org.eclipse.jdt.ui.tests.refactoring/resources/ConvertAnonymousToNested/canConvert/A_test33_out.java
new file mode 100644
index 0000000000..c307f1e344
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/ConvertAnonymousToNested/canConvert/A_test33_out.java
@@ -0,0 +1,16 @@
+package p;
+public interface A{
+ <T> void a();
+ <T> void b();
+}
+
+class Z{
+ private static final class AImpl implements A {
+ public <T> void b(){}
+ public <T> void a(){}
+ }
+
+void m(){
+ A a = new AImpl();
+ }
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests.java
index f165b787bf..b8d144a2d6 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,9 +7,11 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * N.Metchev@teamphone.com - contributed fixes for
+ * NikolayMetchev@gmail.com - contributed fixes for
* - convert anonymous to nested should sometimes declare class as static [refactoring]
* (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=43360)
+ * - [refactoring][convert anonymous] gets confused with generic methods
+ * (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=124978)
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
@@ -379,4 +381,8 @@ public class ConvertAnonymousToNestedTests extends RefactoringTest {
public void test32() throws Exception{ // for bug 158028
helper1(10, 30, 10, 36, true, false, "Inner1Extension", Modifier.PRIVATE);
}
+
+ public void test33() throws Exception { // for bug 124978
+ helper1(9, 21, 12, 7, true, true, "AImpl", Modifier.PRIVATE);
+ }
}
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ConvertAnonymousToNestedRefactoring.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ConvertAnonymousToNestedRefactoring.java
index 525f3bfe1f..d7f7f816bd 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ConvertAnonymousToNestedRefactoring.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ConvertAnonymousToNestedRefactoring.java
@@ -7,11 +7,13 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * N.Metchev@teamphone.com - contributed fixes for
+ * NikolayMetchev@gmail.com - contributed fixes for
* - convert anonymous to nested should sometimes declare class as static [refactoring]
* (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=43360)
* - Convert anonymous to nested: should show error if field form outer anonymous type is references [refactoring]
* (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=48282)
+ * - [refactoring][convert anonymous] gets confused with generic methods
+ * (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=124978)
*******************************************************************************/
package org.eclipse.jdt.internal.corext.refactoring.code;
@@ -136,7 +138,12 @@ public class ConvertAnonymousToNestedRefactoring extends Refactoring {
}
return true;
}
-
+
+ @Override
+ public final boolean visit(TypeParameter parameter) {
+ return parameter.getParent().getNodeType() != ASTNode.METHOD_DECLARATION;
+ }
+
public final ITypeBinding[] getResult() {
final ITypeBinding[] result= new ITypeBinding[fFound.size()];
fFound.toArray(result);

Back to the top