mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
replace unused parameter fix with safe delete in onTheFly mode: deep parameter delete is enabled this way
This commit is contained in:
@@ -23,8 +23,10 @@ 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.psi.PsiParameter;
|
||||
import com.intellij.psi.PsiSubstitutor;
|
||||
import com.intellij.refactoring.safeDelete.SafeDeleteHandler;
|
||||
import com.intellij.refactoring.safeDelete.SafeDeleteProcessor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -53,7 +55,12 @@ public class SafeDeleteFix extends LocalQuickFixAndIntentionActionOnPsiElement {
|
||||
@NotNull PsiElement startElement,
|
||||
@NotNull PsiElement endElement) {
|
||||
if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
|
||||
SafeDeleteHandler.invoke(project, new PsiElement[]{startElement}, false);
|
||||
final PsiElement[] elements = {startElement};
|
||||
if (startElement instanceof PsiParameter) {
|
||||
SafeDeleteProcessor.createInstance(project, null, elements, false, false, true).run();
|
||||
} else {
|
||||
SafeDeleteHandler.invoke(project, elements, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -665,7 +665,7 @@ public class QuickFixFactoryImpl extends QuickFixFactory {
|
||||
Collections.addAll(options, SuppressIntentionActionFromFix.convertBatchToSuppressIntentionActions(batchSuppressActions));
|
||||
}
|
||||
//need suppress from Unused Parameters but settings from Unused Symbol
|
||||
QuickFixAction.registerQuickFixAction((HighlightInfo)highlightInfo, new RemoveUnusedParameterFix(parameter),
|
||||
QuickFixAction.registerQuickFixAction((HighlightInfo)highlightInfo, new SafeDeleteFix(parameter),
|
||||
options, HighlightDisplayKey.getDisplayNameByKey(myUnusedSymbolKey));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Remove Parameter 'i'" "true"
|
||||
// "Safe delete 'i'" "true"
|
||||
import java.io.*;
|
||||
|
||||
class a {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Remove Parameter 'i'" "true"
|
||||
// "Safe delete 'i'" "true"
|
||||
import java.io.*;
|
||||
|
||||
class a {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Remove Parameter 'i'" "true"
|
||||
// "Safe delete 'i'" "true"
|
||||
import java.io.*;
|
||||
|
||||
class a {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Remove Parameter 'i'" "true"
|
||||
// "Safe delete 'i'" "true"
|
||||
import java.io.*;
|
||||
|
||||
class a {
|
||||
|
||||
Reference in New Issue
Block a user