Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKalyan Prasad2015-08-17 06:57:42 +0000
committerNoopur Gupta2015-08-18 09:39:34 +0000
commit43269564691d3f443f31cf0d1eb9c1cbac8e9f8d (patch)
treedd245fa0f747c6327d518ec652de310905cd9d4f
parentbcce823521155b589c99c1f1a67c4417373db199 (diff)
downloadeclipse.jdt.ui-43269564691d3f443f31cf0d1eb9c1cbac8e9f8d.tar.gz
eclipse.jdt.ui-43269564691d3f443f31cf0d1eb9c1cbac8e9f8d.tar.xz
eclipse.jdt.ui-43269564691d3f443f31cf0d1eb9c1cbac8e9f8d.zip
Bug 444354 - [pull up] pull up refactoring doesn't add the requiredI20150818-0800
'public' modifier Made changes to the function addMethodStubForAbstractMethod. If the destination type is interface and a method stub is added, then the method tub should be having th epublic modifier Change-Id: I0ca1efad07f0e322137067339aea833086239349 Signed-off-by: Kalyan Prasad <ktatavar@in.ibm.com>
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/PullUp/test51/in/A.java10
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/PullUp/test51/in/B.java17
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/PullUp/test51/out/A.java10
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/PullUp/test51/out/B.java25
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests.java25
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PullUpRefactoringProcessor.java9
6 files changed, 93 insertions, 3 deletions
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/PullUp/test51/in/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/PullUp/test51/in/A.java
new file mode 100644
index 0000000000..aec8891869
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/PullUp/test51/in/A.java
@@ -0,0 +1,10 @@
+package pkg1;
+
+import java.util.List;
+
+public class A implements B.Foo {
+
+ public void b() {
+ List<Object> l = null;
+ }
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/PullUp/test51/in/B.java b/org.eclipse.jdt.ui.tests.refactoring/resources/PullUp/test51/in/B.java
new file mode 100644
index 0000000000..37fc6ff0c6
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/PullUp/test51/in/B.java
@@ -0,0 +1,17 @@
+package pkg1;
+
+import java.util.List;
+
+public class B {
+
+ interface Foo {
+
+ }
+
+ static class Bar implements Foo {
+
+ /** baz it! */
+ void baz(final String s) {
+ }
+ }
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/PullUp/test51/out/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/PullUp/test51/out/A.java
new file mode 100644
index 0000000000..aec8891869
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/PullUp/test51/out/A.java
@@ -0,0 +1,10 @@
+package pkg1;
+
+import java.util.List;
+
+public class A implements B.Foo {
+
+ public void b() {
+ List<Object> l = null;
+ }
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/PullUp/test51/out/B.java b/org.eclipse.jdt.ui.tests.refactoring/resources/PullUp/test51/out/B.java
new file mode 100644
index 0000000000..c91ed5727a
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/PullUp/test51/out/B.java
@@ -0,0 +1,25 @@
+package pkg1;
+
+import java.util.List;
+
+public class B {
+
+ interface Foo {
+
+ void b();
+
+ }
+
+ static class Bar implements Foo {
+
+ /** baz it! */
+ void baz(final String s) {
+ }
+
+ /* (non-Javadoc)
+ * @see p.B.Foo#b()
+ */
+ public void b() {
+ }
+ }
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests.java
index ca848be460..44b356c924 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -1009,6 +1009,29 @@ public class PullUpTests extends RefactoringTest {
}
+ public void test51() throws Exception {
+ ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
+ ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B");
+
+ String[] methodNames= new String[] { "b" };
+ String[][] signatures= new String[][] { new String[0] };
+
+ IType type= getType(cuA, "A");
+ IMethod[] methods= getMethods(type, methodNames, signatures);
+
+ PullUpRefactoringProcessor processor= createRefactoringProcessor(methods);
+ Refactoring ref= processor.getRefactoring();
+
+ assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK());
+ setSuperclassAsTargetClass(processor);
+
+ RefactoringStatus result= performRefactoring(ref);
+ assertTrue("precondition was supposed to pass", result == null || !result.hasError());
+
+ assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B")));
+ assertEqualLines("A", cuA.getSource(), getFileContents(getOutputTestFileName("A")));
+ }
+
public void testFail0() throws Exception{
// printTestDisabledMessage("6538: searchDeclarationsOf* incorrect");
helper2(new String[]{"m"}, new String[][]{new String[0]}, true, false, 0);
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PullUpRefactoringProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PullUpRefactoringProcessor.java
index 9cd55cb8d4..561bb0dde2 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PullUpRefactoringProcessor.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PullUpRefactoringProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2014 IBM Corporation and others.
+ * Copyright (c) 2006, 2015 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
@@ -505,7 +505,12 @@ public class PullUpRefactoringProcessor extends HierarchyProcessor {
newMethod.setBody(createMethodStub(methodToCreateStubFor, ast));
newMethod.setConstructor(false);
copyExtraDimensions(methodToCreateStubFor, newMethod);
- newMethod.modifiers().addAll(ASTNodeFactory.newModifiers(ast, getModifiersWithUpdatedVisibility(sourceMethod, JdtFlags.clearFlag(Modifier.NATIVE | Modifier.ABSTRACT, methodToCreateStubFor.getModifiers()), adjustments, new SubProgressMonitor(monitor, 1), false, status)));
+ int modifiers= getModifiersWithUpdatedVisibility(sourceMethod, JdtFlags.clearFlag(Modifier.NATIVE | Modifier.ABSTRACT, methodToCreateStubFor.getModifiers()), adjustments,
+ new SubProgressMonitor(monitor, 1), false, status);
+ if (getDestinationType().isInterface()) {
+ modifiers= modifiers | Modifier.PUBLIC;
+ }
+ newMethod.modifiers().addAll(ASTNodeFactory.newModifiers(ast, modifiers));
newMethod.setName(((SimpleName) ASTNode.copySubtree(ast, methodToCreateStubFor.getName())));
final TypeVariableMaplet[] mapping= TypeVariableUtil.composeMappings(TypeVariableUtil.subTypeToSuperType(getDeclaringType(), getDestinationType()), TypeVariableUtil.superTypeToInheritedType(getDestinationType(), ((IType) typeToCreateStubIn.resolveBinding().getJavaElement())));
copyReturnType(rewriter.getASTRewrite(), getDeclaringType().getCompilationUnit(), methodToCreateStubFor, newMethod, mapping);

Back to the top