[cleanup] minor refactoring in ExternalSystemRunnableState

GitOrigin-RevId: a6b79f972db2bdaf172519283242ee0e9c208ee8
This commit is contained in:
Alexander.Glukhov
2024-05-16 18:05:10 +02:00
committed by intellij-monorepo-bot
parent 0abd106eec
commit a66efbffe5

View File

@@ -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<ExternalSystemTaskNotificationListener> 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<ExecutionConsole, ProcessHandler>
@@ -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,