From a66efbffe5b4a7f8d3aa1bd98fa100a9897aa1c4 Mon Sep 17 00:00:00 2001 From: "Alexander.Glukhov" Date: Thu, 16 May 2024 18:05:10 +0200 Subject: [PATCH] [cleanup] minor refactoring in ExternalSystemRunnableState GitOrigin-RevId: a6b79f972db2bdaf172519283242ee0e9c208ee8 --- .../ExternalSystemRunnableState.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemRunnableState.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemRunnableState.java index 03bee81f8e73..f341ec4a24ba 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemRunnableState.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemRunnableState.java @@ -42,6 +42,7 @@ import com.intellij.openapi.progress.util.AbstractProgressIndicatorExBase; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Key; +import com.intellij.openapi.util.NlsSafe; import com.intellij.openapi.util.UserDataHolderBase; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; @@ -81,6 +82,9 @@ public class ExternalSystemRunnableState extends UserDataHolderBase implements R public static final @NotNull Key TASK_NOTIFICATION_LISTENER_KEY = Key.create("TASK_NOTIFICATION_LISTENER"); + private static final @NotNull String DEFAULT_TASK_PREFIX = ": "; + private static final @NotNull String DEFAULT_TASK_POSTFIX = ""; + @NotNull private final ExternalSystemTaskExecutionSettings mySettings; @NotNull private final Project myProject; @NotNull private final ExternalSystemRunConfiguration myConfiguration; @@ -196,12 +200,7 @@ public class ExternalSystemRunnableState extends UserDataHolderBase implements R ExternalSystemProgressNotificationManager.getInstance().addNotificationListener(task.getId(), listener); } - final String executionName = StringUtil.isNotEmpty(mySettings.getExecutionName()) - ? mySettings.getExecutionName() - : StringUtil.isNotEmpty(myConfiguration.getName()) - ? myConfiguration.getName() : AbstractExternalSystemTaskConfigurationType.generateName( - myProject, externalSystemId, mySettings.getExternalProjectPath(), - mySettings.getTaskNames(), mySettings.getExecutionName(), ": ", ""); + final String executionName = getExecutionName(externalSystemId); final ExternalSystemProcessHandler processHandler = new ExternalSystemProcessHandler(task, executionName); final ExternalSystemExecutionConsoleManager @@ -262,6 +261,19 @@ public class ExternalSystemRunnableState extends UserDataHolderBase implements R return executionResult; } + private @NotNull String getExecutionName(@NotNull ProjectSystemId externalSystemId) { + if (StringUtil.isNotEmpty(mySettings.getExecutionName())) { + return mySettings.getExecutionName(); + } + if (StringUtil.isNotEmpty(myConfiguration.getName())) { + return myConfiguration.getName(); + } + return AbstractExternalSystemTaskConfigurationType.generateName(myProject, externalSystemId, mySettings.getExternalProjectPath(), + mySettings.getTaskNames(), mySettings.getExecutionName(), + DEFAULT_TASK_PREFIX, DEFAULT_TASK_POSTFIX + ); + } + private void executeTask(@NotNull ExternalSystemExecuteTaskTask task, @Nls String executionName, @NotNull ProgressIndicator indicator,