From d4e4bd17536158cfc0b666d719ebcf8ffb3b9844 Mon Sep 17 00:00:00 2001 From: Rob Stryker Date: Mon, 4 Dec 2023 12:13:37 -0500 Subject: [PATCH] Make the tests pass Signed-off-by: Rob Stryker --- .../refactoring/rename/RenameSupport.java | 26 +++++++++++++++++-- .../org.eclipse.jdt.ls.tp.target | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/corext/refactoring/rename/RenameSupport.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/corext/refactoring/rename/RenameSupport.java index 1a87c1f49d..e6e54c14ca 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/corext/refactoring/rename/RenameSupport.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/corext/refactoring/rename/RenameSupport.java @@ -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; @@ -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; @@ -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; @@ -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); } @@ -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); } diff --git a/org.eclipse.jdt.ls.target/org.eclipse.jdt.ls.tp.target b/org.eclipse.jdt.ls.target/org.eclipse.jdt.ls.tp.target index 9dc2d50cb5..44709cda97 100644 --- a/org.eclipse.jdt.ls.target/org.eclipse.jdt.ls.tp.target +++ b/org.eclipse.jdt.ls.target/org.eclipse.jdt.ls.tp.target @@ -25,7 +25,7 @@ - +