mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-79529 Groovy: Change Signature Refactoring doesn't work when renaming a method which implements Java interface
This commit is contained in:
@@ -15,8 +15,11 @@
|
||||
*/
|
||||
package com.intellij.refactoring.changeSignature;
|
||||
|
||||
import com.intellij.lang.LanguageRefactoringSupport;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.impl.source.tree.Factory;
|
||||
import com.intellij.psi.impl.source.tree.SharedImplUtil;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
@@ -97,6 +100,12 @@ public class ChangeSignatureUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void invokeChangeSignatureOn(PsiMethod method, Project project) {
|
||||
final ChangeSignatureHandler handler =
|
||||
LanguageRefactoringSupport.INSTANCE.forLanguage(method.getLanguage()).getChangeSignatureHandler();
|
||||
handler.invoke(project, new PsiElement[]{method}, null);
|
||||
}
|
||||
|
||||
public interface ChildrenGenerator<Parent extends PsiElement, Child extends PsiElement> {
|
||||
List<Child> getChildren(Parent parent);
|
||||
}
|
||||
|
||||
+3
-3
@@ -63,9 +63,9 @@ public class JavaChangeSignatureHandler implements ChangeSignatureHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public void invoke(@NotNull final Project project, @NotNull final PsiElement[] elements, final DataContext dataContext) {
|
||||
public void invoke(@NotNull final Project project, @NotNull final PsiElement[] elements, @Nullable final DataContext dataContext) {
|
||||
if (elements.length != 1) return;
|
||||
Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
|
||||
Editor editor = dataContext != null ? PlatformDataKeys.EDITOR.getData(dataContext) : null;
|
||||
invokeOnElement(project, editor, elements[0]);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class JavaChangeSignatureHandler implements ChangeSignatureHandler {
|
||||
if (newMethod == null) return;
|
||||
|
||||
if (!newMethod.equals(method)) {
|
||||
invoke(newMethod, project, editor);
|
||||
ChangeSignatureUtil.invokeChangeSignatureOn(newMethod, project);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -15,11 +15,14 @@
|
||||
*/
|
||||
package com.intellij.refactoring.changeSignature;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -33,4 +36,6 @@ public interface ChangeSignatureHandler extends RefactoringActionHandler {
|
||||
|
||||
@Nullable
|
||||
PsiElement findTargetMember(PsiElement element);
|
||||
|
||||
void invoke(@NotNull Project project, @NotNull PsiElement[] elements, @Nullable DataContext dataContext);
|
||||
}
|
||||
|
||||
+3
-2
@@ -30,6 +30,7 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.HelpID;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.changeSignature.ChangeSignatureHandler;
|
||||
import com.intellij.refactoring.changeSignature.ChangeSignatureUtil;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -66,7 +67,7 @@ public class GrChangeSignatureHandler implements ChangeSignatureHandler {
|
||||
|
||||
public void invoke(@NotNull final Project project, @NotNull final PsiElement[] elements, final DataContext dataContext) {
|
||||
if (elements.length != 1) return;
|
||||
Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
|
||||
Editor editor = dataContext == null ? null : PlatformDataKeys.EDITOR.getData(dataContext);
|
||||
invokeOnElement(project, editor, elements[0]);
|
||||
}
|
||||
|
||||
@@ -78,7 +79,7 @@ public class GrChangeSignatureHandler implements ChangeSignatureHandler {
|
||||
if (newMethod == null) return;
|
||||
|
||||
if (!newMethod.equals(method)) {
|
||||
invoke(newMethod, project);
|
||||
ChangeSignatureUtil.invokeChangeSignatureOn(method, project);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user