mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't mark local cleanups as global command (IDEA-185968)
This commit is contained in:
+10
-1
@@ -21,13 +21,22 @@ public interface CleanupInspectionUtil {
|
||||
@Nullable Class quickfixClass,
|
||||
boolean startInWriteAction);
|
||||
|
||||
default AbstractPerformFixesTask applyFixesNoSort(@NotNull Project project,
|
||||
@NotNull String presentationText,
|
||||
@NotNull List<ProblemDescriptor> descriptions,
|
||||
@Nullable Class quickfixClass,
|
||||
boolean startInWriteAction,
|
||||
boolean markGlobal) {
|
||||
return applyFixesNoSort(project, presentationText, descriptions, quickfixClass, startInWriteAction);
|
||||
}
|
||||
|
||||
default AbstractPerformFixesTask applyFixes(@NotNull Project project,
|
||||
@NotNull String presentationText,
|
||||
@NotNull List<ProblemDescriptor> descriptions,
|
||||
@Nullable Class quickfixClass,
|
||||
boolean startInWriteAction) {
|
||||
sortDescriptions(descriptions);
|
||||
return applyFixesNoSort(project, presentationText, descriptions, quickfixClass, startInWriteAction);
|
||||
return applyFixesNoSort(project, presentationText, descriptions, quickfixClass, startInWriteAction, true);
|
||||
}
|
||||
|
||||
default void sortDescriptions(@NotNull List<ProblemDescriptor> descriptions) {
|
||||
|
||||
+16
-3
@@ -21,14 +21,19 @@ import java.util.List;
|
||||
public class CleanupInspectionUtilImpl implements CleanupInspectionUtil {
|
||||
private final static Logger LOG = Logger.getInstance(CleanupInspectionUtilImpl.class);
|
||||
|
||||
@Override
|
||||
public AbstractPerformFixesTask applyFixesNoSort(@NotNull Project project, @NotNull String presentationText, @NotNull List<ProblemDescriptor> descriptions, @Nullable Class quickfixClass, boolean startInWriteAction) {
|
||||
@Override
|
||||
public AbstractPerformFixesTask applyFixesNoSort(@NotNull Project project,
|
||||
@NotNull String presentationText,
|
||||
@NotNull List<ProblemDescriptor> descriptions,
|
||||
@Nullable Class quickfixClass,
|
||||
boolean startInWriteAction,
|
||||
boolean markGlobal) {
|
||||
final boolean isBatch = quickfixClass != null && BatchQuickFix.class.isAssignableFrom(quickfixClass);
|
||||
final AbstractPerformFixesTask fixesTask = isBatch ?
|
||||
new PerformBatchFixesTask(project, descriptions.toArray(ProblemDescriptor.EMPTY_ARRAY), quickfixClass) :
|
||||
new PerformFixesTask(project, descriptions.toArray(ProblemDescriptor.EMPTY_ARRAY), quickfixClass);
|
||||
CommandProcessor.getInstance().executeCommand(project, () -> {
|
||||
CommandProcessor.getInstance().markCurrentCommandAsGlobal(project);
|
||||
if (markGlobal) CommandProcessor.getInstance().markCurrentCommandAsGlobal(project);
|
||||
if (quickfixClass != null && startInWriteAction) {
|
||||
((ApplicationImpl)ApplicationManager.getApplication())
|
||||
.runWriteActionWithCancellableProgressInDispatchThread(presentationText, project, null, fixesTask::doRun);
|
||||
@@ -44,6 +49,14 @@ public class CleanupInspectionUtilImpl implements CleanupInspectionUtil {
|
||||
return fixesTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractPerformFixesTask applyFixesNoSort(@NotNull Project project,
|
||||
@NotNull String presentationText,
|
||||
@NotNull List<ProblemDescriptor> descriptions,
|
||||
@Nullable Class quickfixClass,
|
||||
boolean startInWriteAction) {
|
||||
return applyFixesNoSort(project, presentationText, descriptions, quickfixClass, startInWriteAction, true);
|
||||
}
|
||||
|
||||
private static class PerformBatchFixesTask extends AbstractPerformFixesTask {
|
||||
private final List<ProblemDescriptor> myBatchModeDescriptors = new ArrayList<>();
|
||||
|
||||
+5
-2
@@ -49,6 +49,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.ToolWindowId;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.GlobalSearchScopesCore;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
@@ -921,7 +922,9 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
|
||||
setCurrentScope(scope);
|
||||
final int fileCount = scope.getFileCount();
|
||||
final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
|
||||
progressIndicator.setIndeterminate(false);
|
||||
if (progressIndicator != null) {
|
||||
progressIndicator.setIndeterminate(false);
|
||||
}
|
||||
|
||||
final SearchScope searchScope = ReadAction.compute(scope::toSearchScope);
|
||||
final TextRange range;
|
||||
@@ -1019,7 +1022,7 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
|
||||
|
||||
Runnable runnable = () -> {
|
||||
if (!FileModificationService.getInstance().preparePsiElementsForWrite(files)) return;
|
||||
CleanupInspectionUtil.getInstance().applyFixesNoSort(getProject(), "Code Cleanup", descriptors, null, false);
|
||||
CleanupInspectionUtil.getInstance().applyFixesNoSort(getProject(), "Code Cleanup", descriptors, null, false, searchScope instanceof GlobalSearchScope);
|
||||
if (postRunnable != null) {
|
||||
postRunnable.run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user