From 4a7fd61c4eeb9297d53103875d27659bb39758c2 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Tue, 6 Apr 2021 18:28:49 +0200 Subject: [PATCH] reuse `PerformInBackgroundOption#DEAF` and `PerformInBackgroundOption#ALWAYS_BACKGROUND` GitOrigin-RevId: 46407bff6cb8a2d0aed3457be41ba2f7e1791fa2 --- .../ex/GlobalInspectionContextBase.java | 2 +- .../editor/actions/RemoveBomAction.java | 5 ++-- .../export/ExportTestResultsAction.java | 8 ++---- .../changes/BackgroundFromStartOption.java | 26 +++---------------- 4 files changed, 9 insertions(+), 32 deletions(-) diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextBase.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextBase.java index bbfefd36fd96..8fb362ff6e3a 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextBase.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextBase.java @@ -228,7 +228,7 @@ public class GlobalInspectionContextBase extends UserDataHolderBase implements G @NotNull protected PerformInBackgroundOption createOption() { - return () -> true; + return PerformInBackgroundOption.ALWAYS_BACKGROUND; } protected void notifyInspectionsFinished(@NotNull AnalysisScope scope) { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/RemoveBomAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/RemoveBomAction.java index 0924003b6cb7..d293ce77acef 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/RemoveBomAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/RemoveBomAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.editor.actions; import com.intellij.ide.IdeBundle; @@ -12,6 +12,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.progress.PerformInBackgroundOption; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Task; @@ -77,7 +78,7 @@ public class RemoveBomAction extends AnAction implements DumbAware { List filesToProcess = getFilesWithBom(files); if (filesToProcess.isEmpty()) return; List filesUnableToProcess = new ArrayList<>(); - new Task.Backgroundable(getEventProject(e), IdeBundle.message("removing.BOM"), true, () -> false) { + new Task.Backgroundable(getEventProject(e), IdeBundle.message("removing.BOM"), true, PerformInBackgroundOption.DEAF) { @Override public void run(@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(false); diff --git a/platform/testRunner/src/com/intellij/execution/testframework/export/ExportTestResultsAction.java b/platform/testRunner/src/com/intellij/execution/testframework/export/ExportTestResultsAction.java index 09b3efb36641..2afdac6d1894 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/export/ExportTestResultsAction.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/export/ExportTestResultsAction.java @@ -119,12 +119,8 @@ public final class ExportTestResultsAction extends DumbAwareAction { return; } ProgressManager.getInstance().run( - new Task.Backgroundable(project, ExecutionBundle.message("export.test.results.task.name"), false, new PerformInBackgroundOption() { - @Override - public boolean shouldStartInBackground() { - return true; - } - }) { + new Task.Backgroundable(project, ExecutionBundle.message("export.test.results.task.name"), false, + PerformInBackgroundOption.ALWAYS_BACKGROUND) { @Override public void run(@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(true); diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/BackgroundFromStartOption.java b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/BackgroundFromStartOption.java index 2a13cebee6c0..ddd6025f5a04 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/BackgroundFromStartOption.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/BackgroundFromStartOption.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.vcs.changes; import com.intellij.openapi.progress.PerformInBackgroundOption; @@ -23,15 +9,9 @@ import org.jetbrains.annotations.ApiStatus; */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "2021.3") -public class BackgroundFromStartOption implements PerformInBackgroundOption { - private final static BackgroundFromStartOption ourInstance = new BackgroundFromStartOption(); +public class BackgroundFromStartOption { public static PerformInBackgroundOption getInstance() { - return ourInstance; - } - - @Override - public boolean shouldStartInBackground() { - return true; + return PerformInBackgroundOption.ALWAYS_BACKGROUND; } }