Skip to content

Commit 54f33f5

Browse files
committed
chore: don't use internal startRunProfile
Signed-off-by: azerr <[email protected]>
1 parent fe28668 commit 54f33f5

File tree

1 file changed

+3
-63
lines changed

1 file changed

+3
-63
lines changed
Lines changed: 3 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
11
// Copyright 2000-2020 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.
22
package com.redhat.devtools.intellij.quarkus.buildtool.gradle;
33

4-
import com.intellij.build.BuildView;
54
import com.intellij.execution.ExecutionException;
6-
import com.intellij.execution.ExecutionManager;
7-
import com.intellij.execution.ExecutionResult;
85
import com.intellij.execution.configurations.RunProfile;
9-
import com.intellij.execution.configurations.RunProfileState;
106
import com.intellij.execution.configurations.RunnerSettings;
117
import com.intellij.execution.runners.ExecutionEnvironment;
128
import com.intellij.execution.runners.ProgramRunner;
13-
import com.intellij.execution.runners.RunContentBuilder;
14-
import com.intellij.execution.testframework.HistoryTestRunnableState;
15-
import com.intellij.execution.ui.RunContentDescriptor;
16-
import com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunnableState;
9+
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
1710
import com.redhat.devtools.intellij.quarkus.buildtool.BuildToolDelegate;
1811
import com.redhat.devtools.intellij.quarkus.buildtool.maven.MavenToolDelegate;
1912
import com.redhat.devtools.intellij.quarkus.run.QuarkusRunConfiguration;
20-
import org.jetbrains.concurrency.Promises;
2113

2214
/**
2315
* Program runner to run/debug a Gradle configuration.
@@ -54,59 +46,7 @@ public boolean canRun(String executorId, RunProfile profile) {
5446

5547
@Override
5648
public void execute(ExecutionEnvironment environment) throws ExecutionException {
57-
RunProfileState state = environment.getState();
58-
if (state == null) {
59-
return;
60-
}
61-
ExecutionManager.getInstance(environment.getProject()).startRunProfile(environment, () -> {
62-
try {
63-
return Promises.resolvedPromise(doExecute(state, environment));
64-
} catch (ExecutionException e) {
65-
throw new RuntimeException(e);
66-
}
67-
});
68-
}
69-
70-
private RunContentDescriptor doExecute(RunProfileState state, ExecutionEnvironment environment) throws ExecutionException {
71-
if (!(state instanceof ExternalSystemRunnableState) && !(state instanceof HistoryTestRunnableState)) {
72-
return null;
73-
}
74-
75-
RunContentDescriptor runContentDescriptor;
76-
ExecutionResult executionResult = state.execute(environment.getExecutor(), this);
77-
if (executionResult == null) {
78-
return null;
79-
}
80-
runContentDescriptor = new RunContentBuilder(executionResult, environment).showRunContent(environment.getContentToReuse());
81-
if (runContentDescriptor == null) {
82-
return null;
83-
}
84-
85-
if (state instanceof HistoryTestRunnableState) {
86-
return runContentDescriptor;
87-
}
88-
89-
((ExternalSystemRunnableState) state).setContentDescriptor(runContentDescriptor);
90-
91-
if (executionResult.getExecutionConsole() instanceof BuildView) {
92-
return runContentDescriptor;
93-
}
94-
95-
RunContentDescriptor descriptor = new RunContentDescriptor(
96-
runContentDescriptor.getExecutionConsole(),
97-
runContentDescriptor.getProcessHandler(),
98-
runContentDescriptor.getComponent(),
99-
runContentDescriptor.getDisplayName(),
100-
runContentDescriptor.getIcon(),
101-
null,
102-
runContentDescriptor.getRestartActions()
103-
) {
104-
@Override
105-
public boolean isHiddenContent() {
106-
return true;
107-
}
108-
};
109-
descriptor.setRunnerLayoutUi(runContentDescriptor.getRunnerLayoutUi());
110-
return descriptor;
49+
// Execute environment with the 'ExternalSystemTaskRunner.RUNNER_ID'
50+
ProgramRunner.findRunnerById(ExternalSystemConstants.RUNNER_ID).execute(environment);
11151
}
11252
}

0 commit comments

Comments
 (0)