Search in sources :

Example 1 with GoApplicationRunningState

use of com.goide.runconfig.application.GoApplicationRunningState in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoBuildingRunner method prepare.

@NotNull
@Override
protected Promise<RunProfileStarter> prepare(@NotNull ExecutionEnvironment environment, @NotNull RunProfileState state) throws ExecutionException {
    File outputFile = getOutputFile(environment, (GoApplicationRunningState) state);
    FileDocumentManager.getInstance().saveAllDocuments();
    AsyncPromise<RunProfileStarter> buildingPromise = new AsyncPromise<>();
    GoHistoryProcessListener historyProcessListener = new GoHistoryProcessListener();
    ((GoApplicationRunningState) state).createCommonExecutor().withParameters("build").withParameterString(((GoApplicationRunningState) state).getGoBuildParams()).withParameters("-o", outputFile.getAbsolutePath()).withParameters(((GoApplicationRunningState) state).isDebug() ? new String[] { "-gcflags", "-N -l" } : ArrayUtil.EMPTY_STRING_ARRAY).withParameters(((GoApplicationRunningState) state).getTarget()).disablePty().withPresentableName("go build").withProcessListener(historyProcessListener).withProcessListener(new ProcessAdapter() {

        @Override
        public void processTerminated(ProcessEvent event) {
            super.processTerminated(event);
            boolean compilationFailed = event.getExitCode() != 0;
            if (((GoApplicationRunningState) state).isDebug()) {
                buildingPromise.setResult(new MyDebugStarter(outputFile.getAbsolutePath(), historyProcessListener, compilationFailed));
            } else {
                buildingPromise.setResult(new MyRunStarter(outputFile.getAbsolutePath(), historyProcessListener, compilationFailed));
            }
        }
    }).executeWithProgress(false);
    return buildingPromise;
}
Also used : RunProfileStarter(com.intellij.execution.RunProfileStarter) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) GoApplicationRunningState(com.goide.runconfig.application.GoApplicationRunningState) GoHistoryProcessListener(com.goide.util.GoHistoryProcessListener) AsyncPromise(org.jetbrains.concurrency.AsyncPromise) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

GoApplicationRunningState (com.goide.runconfig.application.GoApplicationRunningState)1 GoHistoryProcessListener (com.goide.util.GoHistoryProcessListener)1 RunProfileStarter (com.intellij.execution.RunProfileStarter)1 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1 File (java.io.File)1 NotNull (org.jetbrains.annotations.NotNull)1 AsyncPromise (org.jetbrains.concurrency.AsyncPromise)1