mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
cs: detect delete group; tests
This commit is contained in:
+37
-22
@@ -139,6 +139,12 @@ public class JavaChangeSignatureDetector implements LanguageChangeSignatureDetec
|
||||
if (changeInfo instanceof MyJavaChangeInfo) {
|
||||
final MyJavaChangeInfo info = (MyJavaChangeInfo)changeInfo;
|
||||
final PsiMethod method = info.getSuperMethod();
|
||||
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
temporallyRevertChanges(method, oldText);
|
||||
createChangeSignatureProcessor(info, method).run();
|
||||
return true;
|
||||
}
|
||||
final JavaChangeSignatureDialog dialog =
|
||||
new JavaChangeSignatureDialog(method.getProject(), new JavaMethodDescriptor(info.getMethod()) {
|
||||
@Override
|
||||
@@ -147,16 +153,7 @@ public class JavaChangeSignatureDetector implements LanguageChangeSignatureDetec
|
||||
}
|
||||
}, true, method) {
|
||||
protected BaseRefactoringProcessor createRefactoringProcessor() {
|
||||
return new ChangeSignatureProcessor(myProject, new MyJavaChangeInfo(info.getNewVisibility(), info.getSuperMethod(),
|
||||
info.getNewReturnType(),
|
||||
(ParameterInfoImpl[])info.getNewParameters(),
|
||||
info.getNewExceptions(), info.getOldName()) {
|
||||
@Override
|
||||
protected void fillOldParams(PsiMethod method) {
|
||||
oldParameterNames = info.getOldParameterNames();
|
||||
oldParameterTypes = info.getOldParameterTypes();
|
||||
}
|
||||
});
|
||||
return createChangeSignatureProcessor(info, method);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -164,18 +161,7 @@ public class JavaChangeSignatureDetector implements LanguageChangeSignatureDetec
|
||||
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final PsiFile file = method.getContainingFile();
|
||||
final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject());
|
||||
final Document document = documentManager.getDocument(file);
|
||||
if (document != null) {
|
||||
document.setText(oldText);
|
||||
documentManager.commitDocument(document);
|
||||
}
|
||||
}
|
||||
});
|
||||
temporallyRevertChanges(method, oldText);
|
||||
doRefactor(processor);
|
||||
}
|
||||
}, RefactoringBundle.message("changing.signature.of.0", UsageViewUtil.getDescriptiveName(info.getMethod())), null);
|
||||
@@ -192,6 +178,35 @@ public class JavaChangeSignatureDetector implements LanguageChangeSignatureDetec
|
||||
|
||||
}
|
||||
|
||||
private static void temporallyRevertChanges(final PsiMethod method, final String oldText) {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final PsiFile file = method.getContainingFile();
|
||||
final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(method.getProject());
|
||||
final Document document = documentManager.getDocument(file);
|
||||
if (document != null) {
|
||||
document.setText(oldText);
|
||||
documentManager.commitDocument(document);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static ChangeSignatureProcessor createChangeSignatureProcessor(final MyJavaChangeInfo info,
|
||||
final PsiMethod method) {
|
||||
return new ChangeSignatureProcessor(method.getProject(), new MyJavaChangeInfo(info.getNewVisibility(), info.getSuperMethod(),
|
||||
info.getNewReturnType(),
|
||||
(ParameterInfoImpl[])info.getNewParameters(),
|
||||
info.getNewExceptions(), info.getOldName()) {
|
||||
@Override
|
||||
protected void fillOldParams(PsiMethod method) {
|
||||
oldParameterNames = info.getOldParameterNames();
|
||||
oldParameterTypes = info.getOldParameterTypes();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChangeSignatureAvailable(PsiElement element, ChangeInfo currentInfo) {
|
||||
if (currentInfo instanceof JavaChangeInfo) {
|
||||
|
||||
Reference in New Issue
Block a user