diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/RenameVirtualMethodInClass/test41/in/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameVirtualMethodInClass/test41/in/A.java new file mode 100644 index 0000000..fffb733 --- /dev/null +++ b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameVirtualMethodInClass/test41/in/A.java @@ -0,0 +1,8 @@ +package p; + +public class A { + public String getName() // rename to getSomething() + { + return null; + } +} diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/RenameVirtualMethodInClass/test41/out/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameVirtualMethodInClass/test41/out/A.java new file mode 100644 index 0000000..2df5941 --- /dev/null +++ b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameVirtualMethodInClass/test41/out/A.java @@ -0,0 +1,8 @@ +package p; + +public class A { + public String getSomething() // rename to getSomething() + { + return null; + } +} diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameVirtualMethodInClassTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameVirtualMethodInClassTests.java index d79bd26..bffb296 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameVirtualMethodInClassTests.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameVirtualMethodInClassTests.java @@ -1,14 +1,15 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation + * Nikolay Metchev - - [rename] Renaming a "getName" method takes ages to complete "checking preconditions" phase... - https://bugs.eclipse.org/351410 *******************************************************************************/ package org.eclipse.jdt.ui.tests.refactoring; import junit.framework.Test; import junit.framework.TestSuite; @@ -517,10 +518,27 @@ assertEquals("was supposed to pass", null, performRefactoring(refactoring)); assertEqualLines("invalid renaming A", getFileContents(getOutputTestFileName("A")), cu.getSource()); } + public void test41() throws Exception { // test for bug 351410 + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IMethod method= cu.getType("A").getMethod("getName", new String[0]); + + final RenameJavaElementDescriptor descriptor= RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_METHOD); + descriptor.setJavaElement(method); + descriptor.setNewName("getSomething"); + descriptor.setUpdateReferences(true); + final RefactoringStatus status= new RefactoringStatus(); + final Refactoring refactoring= descriptor.createRefactoring(status); + assertNotNull("Refactoring should not be null", refactoring); + assertTrue("status should be ok", status.isOK()); + + assertEquals("was supposed to pass", null, performRefactoring(refactoring)); + assertEqualLines("invalid renaming A", getFileContents(getOutputTestFileName("A")), cu.getSource()); + } + //anonymous inner class public void testAnon0() throws Exception{ helper2(); } diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameMethodProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameMethodProcessor.java index 46cf543..f7ce659 100644 --- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameMethodProcessor.java +++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameMethodProcessor.java @@ -1,14 +1,15 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation + * Nikolay Metchev - - [rename] Renaming a "getName" method takes ages to complete "checking preconditions" phase... - https://bugs.eclipse.org/351410 *******************************************************************************/ package org.eclipse.jdt.internal.corext.refactoring.rename; import java.util.ArrayList; import java.util.Arrays; @@ -454,11 +455,11 @@ protected final IJavaSearchScope createRefactoringScope() throws CoreException { return createRefactoringScope(fMethod); } //TODO: shouldn't scope take all ripple methods into account? protected static final IJavaSearchScope createRefactoringScope(IMethod method) throws CoreException { - return RefactoringScopeFactory.create(method, true, false); + return RefactoringScopeFactory.create(method, true, true); } private SearchPattern createOccurrenceSearchPattern() { HashSet methods= new HashSet(fMethodsToRename); methods.add(fMethod); diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RippleMethodFinder2.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RippleMethodFinder2.java index 0657e8c..9dc1fb1 100644 --- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RippleMethodFinder2.java +++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RippleMethodFinder2.java @@ -1,14 +1,15 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation + * Nikolay Metchev - - [rename] Renaming a "getName" method takes ages to complete "checking preconditions" phase... - https://bugs.eclipse.org/351410 *******************************************************************************/ package org.eclipse.jdt.internal.corext.refactoring.rename; import java.util.ArrayList; import java.util.Arrays; @@ -347,11 +348,11 @@ int limitTo = IJavaSearchConstants.DECLARATIONS | IJavaSearchConstants.IGNORE_DECLARING_TYPE | IJavaSearchConstants.IGNORE_RETURN_TYPE; int matchRule= SearchPattern.R_ERASURE_MATCH | SearchPattern.R_CASE_SENSITIVE; SearchPattern pattern= SearchPattern.createPattern(fMethod, limitTo, matchRule); SearchParticipant[] participants= SearchUtils.getDefaultSearchParticipants(); - IJavaSearchScope scope= RefactoringScopeFactory.createRelatedProjectsScope(fMethod.getJavaProject(), IJavaSearchScope.SOURCES | IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SYSTEM_LIBRARIES); + IJavaSearchScope scope= RefactoringScopeFactory.createRelatedProjectsScope(fMethod.getJavaProject(), IJavaSearchScope.SOURCES | IJavaSearchScope.APPLICATION_LIBRARIES); MethodRequestor requestor= new MethodRequestor(); SearchEngine searchEngine= owner != null ? new SearchEngine(owner) : new SearchEngine(); searchEngine.search(pattern, participants, scope, requestor, monitor); }