use of com.intellij.execution.process.ProcessEvent in project clion-embedded-arm by elmot.
the class OpenOcdLauncher method createDebugProcess.
@NotNull
@Override
protected CidrDebugProcess createDebugProcess(@NotNull CommandLineState commandLineState, @NotNull XDebugSession xDebugSession) throws ExecutionException {
Project project = commandLineState.getEnvironment().getProject();
OpenOcdSettingsState ocdSettings = project.getComponent(OpenOcdSettingsState.class);
CidrRemoteDebugParameters remoteDebugParameters = new CidrRemoteDebugParameters();
remoteDebugParameters.setSymbolFile(findRunFile(commandLineState).getAbsolutePath());
remoteDebugParameters.setRemoteCommand("tcp:localhost:" + ocdSettings.gdbPort);
CPPToolchains.Toolchain toolchain = CPPToolchains.getInstance().getDefaultToolchain();
if (toolchain == null) {
throw new ExecutionException("Project toolchain is not defined. Please define it in the project settings.");
}
String gdbPath;
toolchain = toolchain.copy();
if (ocdSettings.shippedGdb) {
gdbPath = PathManager.findBinFile("gdb/bin/gdb" + (OS.isWindows() ? ".exe" : "")).getAbsolutePath();
} else {
gdbPath = ocdSettings.gdbLocation;
}
CPPDebugger cppDebugger = CPPDebugger.create(CPPDebugger.Kind.CUSTOM_GDB, gdbPath);
toolchain.setDebugger(cppDebugger);
GDBDriverConfiguration gdbDriverConfiguration = new GDBDriverConfiguration(getProject(), toolchain);
xDebugSession.stop();
CidrRemoteGDBDebugProcess debugProcess = new CidrRemoteGDBDebugProcess(gdbDriverConfiguration, remoteDebugParameters, xDebugSession, commandLineState.getConsoleBuilder(), project1 -> new Filter[0]);
debugProcess.getProcessHandler().addProcessListener(new ProcessAdapter() {
@Override
public void processWillTerminate(@NotNull ProcessEvent event, boolean willBeDestroyed) {
super.processWillTerminate(event, willBeDestroyed);
findOpenOcdAction(project).stopOpenOcd();
}
});
debugProcess.getProcessHandler().putUserData(RESTART_KEY, new AnAction("Reset", "MCU Reset", IconLoader.findIcon("reset.png", OpenOcdLauncher.class)) {
@Override
public void actionPerformed(AnActionEvent e) {
XDebugSession session = debugProcess.getSession();
session.pause();
debugProcess.postCommand(drv -> {
try {
ProgressManager.getInstance().runProcess(() -> {
while (drv.getState() != DebuggerDriver.TargetState.SUSPENDED) {
Thread.yield();
}
}, null);
drv.executeConsoleCommand("monitor reset init");
session.resume();
} catch (DebuggerCommandException exception) {
Informational.showFailedDownloadNotification(e.getProject());
}
});
}
});
return debugProcess;
}
use of com.intellij.execution.process.ProcessEvent in project clion-embedded-arm by elmot.
the class OpenOcdLauncher method createProcess.
@Override
protected ProcessHandler createProcess(@NotNull CommandLineState commandLineState) throws ExecutionException {
File runFile = findRunFile(commandLineState);
findOpenOcdAction(commandLineState.getEnvironment().getProject()).stopOpenOcd();
try {
GeneralCommandLine commandLine = OpenOcdComponent.createOcdCommandLine(commandLineState.getEnvironment().getProject(), runFile, "reset", true);
OSProcessHandler osProcessHandler = new OSProcessHandler(commandLine);
osProcessHandler.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(@NotNull ProcessEvent event) {
super.processTerminated(event);
Project project = commandLineState.getEnvironment().getProject();
if (event.getExitCode() == 0) {
Informational.showSuccessfulDownloadNotification(project);
} else {
Informational.showFailedDownloadNotification(project);
}
}
});
return osProcessHandler;
} catch (ConfigurationException e) {
Messages.showErrorDialog(getProject(), e.getLocalizedMessage(), e.getTitle());
throw new ExecutionException(e);
}
}
use of com.intellij.execution.process.ProcessEvent in project intellij by bazelbuild.
the class BlazeAndroidTestLaunchTask method waitAndSetUpForKillingBlazeOnStop.
/**
* Hooks up the Blaze process to be killed if the user hits the 'Stop' button, then waits for the
* Blaze process to stop. In non-debug mode, we wait for test execution to finish before returning
* from launch() (this matches the behavior of the stock ddmlib runner).
*/
private void waitAndSetUpForKillingBlazeOnStop(@NotNull final ProcessHandler processHandler, @NotNull LaunchStatus launchStatus) {
processHandler.addProcessListener(new ProcessAdapter() {
@Override
public void processWillTerminate(ProcessEvent event, boolean willBeDestroyed) {
blazeResult.cancel(true);
launchStatus.terminateLaunch("Test run stopped.\n");
}
});
try {
blazeResult.get();
launchStatus.terminateLaunch("Tests ran to completion.\n");
} catch (CancellationException e) {
// The user has canceled the test.
launchStatus.terminateLaunch("Test run stopped.\n");
} catch (InterruptedException e) {
// We've been interrupted - cancel the underlying Blaze process.
blazeResult.cancel(true);
launchStatus.terminateLaunch("Test run stopped.\n");
} catch (ExecutionException e) {
LOG.error(e);
launchStatus.terminateLaunch("Test run stopped due to internal exception. Please file a bug report.\n");
}
}
use of com.intellij.execution.process.ProcessEvent in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoBeforeRunTaskProvider method executeTask.
@Override
public boolean executeTask(DataContext context, RunConfiguration configuration, ExecutionEnvironment env, GoCommandBeforeRunTask task) {
Semaphore done = new Semaphore();
Ref<Boolean> result = Ref.create(false);
GoRunConfigurationBase goRunConfiguration = (GoRunConfigurationBase) configuration;
Module module = goRunConfiguration.getConfigurationModule().getModule();
Project project = configuration.getProject();
String workingDirectory = goRunConfiguration.getWorkingDirectory();
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
if (StringUtil.isEmpty(task.getCommand()))
return;
if (project == null || project.isDisposed())
return;
GoSdkService sdkService = GoSdkService.getInstance(project);
if (!sdkService.isGoModule(module))
return;
done.down();
GoExecutor.in(module).withParameterString(task.getCommand()).withWorkDirectory(workingDirectory).showOutputOnError().showNotifications(false, true).withPresentableName("Executing `" + task + "`").withProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
done.up();
result.set(event.getExitCode() == 0);
}
}).executeWithProgress(false, result1 -> VirtualFileManager.getInstance().asyncRefresh(null));
}
});
done.waitFor();
return result.get();
}
use of com.intellij.execution.process.ProcessEvent in project intellij-leiningen-plugin by derkork.
the class LeiningenRunConfigurationType method runConfiguration.
public static void runConfiguration(Project project, LeiningenRunnerParameters params, DataContext context) {
RunnerAndConfigurationSettings configSettings = createRunnerAndConfigurationSettings(params, project);
ProgramRunner runner = RunnerRegistry.getInstance().findRunnerById(DefaultRunExecutor.EXECUTOR_ID);
Executor executor = DefaultRunExecutor.getRunExecutorInstance();
ExecutionEnvironment env = new ExecutionEnvironment(executor, runner, configSettings, project);
try {
runner.execute(env, new ProgramRunner.Callback() {
public void processStarted(RunContentDescriptor runContentDescriptor) {
final ProcessHandler runContentDescriptorProcessHandler = runContentDescriptor.getProcessHandler();
if (runContentDescriptorProcessHandler != null) {
runContentDescriptorProcessHandler.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
LocalFileSystem.getInstance().refreshWithoutFileWatcher(true);
}
});
}
}
});
} catch (ExecutionException e) {
}
}
Aggregations