diff options
author | Manju Mathew | 2014-01-16 03:03:11 +0000 |
---|---|---|
committer | Manju Mathew | 2014-01-16 03:03:11 +0000 |
commit | 26014289b11b5c95431963d1d38d625fccddb053 (patch) | |
tree | 4d777a8a65a580a3d789c42ae9452538f4433bef | |
parent | a7499577a79eae0daed3f86f5e041d46f701bba4 (diff) | |
download | eclipse.jdt.ui-26014289b11b5c95431963d1d38d625fccddb053.tar.gz eclipse.jdt.ui-26014289b11b5c95431963d1d38d625fccddb053.tar.xz eclipse.jdt.ui-26014289b11b5c95431963d1d38d625fccddb053.zip |
Fixed Bug 406786- [1.8][extract method] Extract Method refactoring in
interfaces not handled
4 files changed, 33 insertions, 3 deletions
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/defaultMethods18_in/A_test5.java b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/defaultMethods18_in/A_test5.java new file mode 100644 index 0000000000..741135a75b --- /dev/null +++ b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/defaultMethods18_in/A_test5.java @@ -0,0 +1,11 @@ +package defaultMethods_in; + +public interface A_test5 { + default int foo() { + /*[*/return 0;/*]*/ + } + + static int foo() { + return 0; + } +} diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/defaultMethods18_out/A_test5.java b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/defaultMethods18_out/A_test5.java new file mode 100644 index 0000000000..a88cbb8de3 --- /dev/null +++ b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/defaultMethods18_out/A_test5.java @@ -0,0 +1,15 @@ +package defaultMethods_out; + +public interface A_test5 { + default int foo() { + return extracted(); + } + + static int extracted() { + /*[*/return 0;/*]*/ + } + + static int foo() { + return extracted(); + } +} diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests18.java index 43eb52eb3c..e8d4fbc07a 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests18.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests18.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 IBM Corporation and others. + * Copyright (c) 2013, 2014 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 @@ -83,6 +83,10 @@ public class ExtractMethodTests18 extends ExtractMethodTests { defaultMethodsTest(1, Modifier.PUBLIC); } + public void test5() throws Exception { + defaultMethodsTest(0, Modifier.PUBLIC); + } + //==================================================================================== // Testing Static Methods //==================================================================================== diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodRefactoring.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodRefactoring.java index 6ed9c56a02..90fc02373b 100644 --- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodRefactoring.java +++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodRefactoring.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2014 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,7 +1009,7 @@ public class ExtractMethodRefactoring extends Refactoring { currentParent= currentParent.getParent(); } while (!shouldBeStatic && currentParent != null && currentParent != fDestination); - if (shouldBeStatic || fAnalyzer.getForceStatic()) { + if (shouldBeStatic || fAnalyzer.getForceStatic() || forceStatic()) { modifiers|= Modifier.STATIC; } else if (isDestinationInterface) { modifiers|= Modifier.DEFAULT; |