Skip to content

Commit

Permalink
Make the tests pass
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Stryker <[email protected]>
  • Loading branch information
robstryker committed Dec 7, 2023
1 parent cd6de32 commit bafffd2
Showing 1 changed file with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*******************************************************************************/
package org.eclipse.jdt.ls.core.internal.corext.refactoring.rename;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
Expand All @@ -26,6 +27,8 @@
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeParameter;
import org.eclipse.jdt.core.refactoring.descriptors.RenameJavaElementDescriptor;
import org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationRefactoringChange;
import org.eclipse.jdt.internal.corext.refactoring.changes.RenameCompilationUnitChange;
import org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor;
import org.eclipse.jdt.internal.corext.refactoring.rename.MethodChecks;
import org.eclipse.jdt.internal.corext.refactoring.rename.RenameCompilationUnitProcessor;
Expand All @@ -40,6 +43,8 @@
import org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating;
import org.eclipse.jdt.internal.corext.refactoring.tagging.IReferenceUpdating;
import org.eclipse.jdt.internal.corext.refactoring.tagging.ITextUpdating;
import org.eclipse.jdt.internal.corext.refactoring.util.TextChangeManager;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.corext.util.JdtFlags;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
Expand Down Expand Up @@ -286,7 +291,17 @@ public static RenameSupport create(ICompilationUnit unit, String newName, int fl
* the {@link RenameSupport}.
*/
public static RenameSupport create(IType type, String newName, int flags) throws CoreException {
JavaRenameProcessor processor = new RenameTypeProcessor(type);
JavaRenameProcessor processor = new RenameTypeProcessor(type) {
@Override
protected void createChangeForRenamedCUStandardResource(IType type, TextChangeManager changeManager, IResource resource, DynamicValidationRefactoringChange result) throws CoreException {
addTypeDeclarationUpdate(changeManager);
addConstructorRenames(changeManager);
result.addAll(changeManager.getAllChanges());
String renamedCUName = JavaModelUtil.getRenamedCUName(type.getCompilationUnit(), getNewElementName());
result.add(new RenameCompilationUnitChange(type.getCompilationUnit(), renamedCUName));
}

};
return new RenameSupport(processor, newName, flags);
}

Expand All @@ -305,7 +320,14 @@ public static RenameSupport create(IType type, String newName, int flags) throws
public static RenameSupport create(IMethod method, String newName, int flags) throws CoreException {
JavaRenameProcessor processor;
if (MethodChecks.isVirtual(method)) {
processor= new RenameVirtualMethodProcessor(method);
processor = new RenameVirtualMethodProcessor(method) {
@Override
protected void initializeWithTopMostImplementation(IMethod topmost) {
String newName = getNewElementName();
initialize(topmost);
setNewElementName(newName);
}
};
} else {
processor= new RenameNonVirtualMethodProcessor(method);
}
Expand Down

0 comments on commit bafffd2

Please sign in to comment.