use of com.intellij.execution.ExecutionResult in project intellij-plugins by JetBrains.
the class JstdCoverageProgramRunner method start.
@Nullable
private static RunContentDescriptor start(@Nullable JstdServer server, @NotNull ExecutionEnvironment environment) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
JstdRunConfiguration runConfiguration = (JstdRunConfiguration) environment.getRunProfile();
CoverageEnabledConfiguration coverageEnabledConfiguration = CoverageEnabledConfiguration.getOrCreate(runConfiguration);
String coverageFilePath = coverageEnabledConfiguration.getCoverageFilePath();
JstdRunProfileState jstdState = new JstdRunProfileState(environment, runConfiguration.getRunSettings(), coverageFilePath);
ExecutionResult executionResult = jstdState.executeWithServer(server);
RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, environment);
final RunContentDescriptor descriptor = contentBuilder.showRunContent(environment.getContentToReuse());
ProcessHandler processHandler = executionResult.getProcessHandler();
if (processHandler instanceof NopProcessHandler) {
if (server != null) {
server.addLifeCycleListener(new JstdServerLifeCycleAdapter() {
@Override
public void onBrowserCaptured(@NotNull JstdBrowserInfo info) {
ExecutionUtil.restartIfActive(descriptor);
server.removeLifeCycleListener(this);
}
}, contentBuilder);
}
} else {
CoverageHelper.attachToProcess(runConfiguration, processHandler, environment.getRunnerSettings());
}
return descriptor;
}
use of com.intellij.execution.ExecutionResult in project intellij-community by JetBrains.
the class ToolRunProfile method getState.
@Override
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) {
final Project project = env.getProject();
if (myCommandLine == null) {
// can return null if creation of cmd line has been cancelled
return null;
}
final CommandLineState commandLineState = new CommandLineState(env) {
GeneralCommandLine createCommandLine() {
return myCommandLine;
}
@Override
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
final GeneralCommandLine commandLine = createCommandLine();
final OSProcessHandler processHandler = new ColoredProcessHandler(commandLine);
ProcessTerminatedListener.attach(processHandler);
return processHandler;
}
@Override
@NotNull
public ExecutionResult execute(@NotNull final Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
final ExecutionResult result = super.execute(executor, runner);
final ProcessHandler processHandler = result.getProcessHandler();
if (processHandler != null) {
processHandler.addProcessListener(new ToolProcessAdapter(project, myTool.synchronizeAfterExecution(), getName()));
processHandler.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
if ((outputType == ProcessOutputTypes.STDOUT && myTool.isShowConsoleOnStdOut()) || (outputType == ProcessOutputTypes.STDERR && myTool.isShowConsoleOnStdErr())) {
ExecutionManager.getInstance(project).getContentManager().toFrontRunContent(executor, processHandler);
}
}
});
}
return result;
}
};
TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
final FilterInfo[] outputFilters = myTool.getOutputFilters();
for (FilterInfo outputFilter : outputFilters) {
builder.addFilter(new RegexpFilter(project, outputFilter.getRegExp()));
}
commandLineState.setConsoleBuilder(builder);
return commandLineState;
}
use of com.intellij.execution.ExecutionResult in project intellij-community by JetBrains.
the class DefaultJavaProgramRunner method doExecute.
@Override
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment env) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
ExecutionResult executionResult;
boolean shouldAddDefaultActions = true;
if (state instanceof JavaCommandLine) {
final JavaParameters parameters = ((JavaCommandLine) state).getJavaParameters();
patch(parameters, env.getRunnerSettings(), env.getRunProfile(), true);
ProcessProxy proxy = ProcessProxyFactory.getInstance().createCommandLineProxy((JavaCommandLine) state);
executionResult = state.execute(env.getExecutor(), this);
if (proxy != null) {
ProcessHandler handler = executionResult != null ? executionResult.getProcessHandler() : null;
if (handler != null) {
proxy.attach(handler);
handler.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
proxy.destroy();
}
});
} else {
proxy.destroy();
}
}
if (state instanceof JavaCommandLineState && !((JavaCommandLineState) state).shouldAddJavaProgramRunnerActions()) {
shouldAddDefaultActions = false;
}
} else {
executionResult = state.execute(env.getExecutor(), this);
}
if (executionResult == null) {
return null;
}
onProcessStarted(env.getRunnerSettings(), executionResult);
final RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, env);
if (shouldAddDefaultActions) {
addDefaultActions(contentBuilder, executionResult);
}
return contentBuilder.showRunContent(env.getContentToReuse());
}
use of com.intellij.execution.ExecutionResult in project intellij-plugins by JetBrains.
the class KarmaRunProgramRunner method doExecute.
@Nullable
@Override
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
ExecutionResult executionResult = state.execute(environment.getExecutor(), this);
if (executionResult == null) {
return null;
}
KarmaConsoleView consoleView = KarmaConsoleView.get(executionResult, state);
final RunContentDescriptor descriptor = KarmaUtil.createDefaultDescriptor(executionResult, environment);
if (consoleView == null) {
return descriptor;
}
KarmaServer server = consoleView.getKarmaExecutionSession().getKarmaServer();
if (!server.areBrowsersReady()) {
server.onBrowsersReady(() -> ExecutionUtil.restartIfActive(descriptor));
} else {
RerunTestsNotification.showRerunNotification(environment.getContentToReuse(), executionResult.getExecutionConsole());
}
RerunTestsAction.register(descriptor);
return descriptor;
}
use of com.intellij.execution.ExecutionResult in project intellij-plugins by JetBrains.
the class JstdRunProgramRunner method start.
public static RunContentDescriptor start(@Nullable JstdServer server, boolean fromDebug, @NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
JstdRunProfileState jstdState = JstdRunProfileState.cast(state);
ExecutionResult executionResult = jstdState.executeWithServer(server);
RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, environment);
final RunContentDescriptor descriptor = contentBuilder.showRunContent(environment.getContentToReuse());
if (server != null && executionResult.getProcessHandler() instanceof NopProcessHandler) {
server.addLifeCycleListener(new JstdServerLifeCycleAdapter() {
@Override
public void onBrowserCaptured(@NotNull JstdBrowserInfo info) {
if (fromDebug) {
final Alarm alarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, descriptor);
alarm.addRequest(() -> ExecutionUtil.restartIfActive(descriptor), 1000);
} else {
ExecutionUtil.restartIfActive(descriptor);
}
server.removeLifeCycleListener(this);
}
}, contentBuilder);
}
return descriptor;
}
Aggregations