use of com.intellij.execution.ExecutionException in project intellij-elixir by KronicDeth.
the class MixConfigurationForm method validateMixPath.
private boolean validateMixPath() {
String mixPath = myMixPathSelector.getText();
File mix = new File(mixPath);
if (!mix.exists()) {
return false;
}
if (!mix.canExecute()) {
String reason = mix.getPath() + "is not executable.";
LOGGER.warn("Can't detect Mix version: " + reason);
return false;
}
File exeFile = mix.getAbsoluteFile();
String exePath = exeFile.getPath();
String workDir = exeFile.getParent();
ProcessOutput output = null;
boolean valid = false;
for (String[] arguments : MIX_ARGUMENTS_ARRAY) {
try {
output = ElixirSystemUtil.getProcessOutput(3000, workDir, exePath, arguments);
} catch (ExecutionException executionException) {
LOGGER.warn(executionException);
}
if (output != null) {
String transformedStdout = transformStdoutLine(output, STDOUT_LINE_TRANSFORMER);
if (transformedStdout != null) {
myMixVersionText.setText(transformedStdout);
String versionString = transformedStdout.replaceAll("^[^0-9]*", "");
// Support for the --formatter option may be added in a 1.3.x release, but I'm being conservative for now
// and assuming it won't be released until 1.4
ElixirSdkRelease elixirSdkRelease = ElixirSdkRelease.fromString(versionString);
if (elixirSdkRelease != null) {
supportsFormatterOptionCheckBox.setSelected(elixirSdkRelease.compareTo(ElixirSdkRelease.V_1_4) >= 0);
}
valid = true;
break;
} else {
String stderr = output.getStderr();
StringBuilder text = new StringBuilder("N/A");
if (StringUtil.isNotEmpty(stderr)) {
text.append(": Error: ").append(stderr);
}
myMixVersionText.setText(text.toString());
}
}
}
return valid;
}
use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.
the class DebuggerTestCase method attachVM.
protected DebuggerSession attachVM(final RemoteConnection remoteConnection, final boolean pollConnection) throws InvocationTargetException, InterruptedException {
final RemoteState remoteState = new RemoteStateState(myProject, remoteConnection);
final DebuggerSession[] debuggerSession = new DebuggerSession[1];
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
try {
debuggerSession[0] = attachVirtualMachine(remoteState, new ExecutionEnvironmentBuilder(myProject, DefaultDebugExecutor.getDebugExecutorInstance()).runProfile(new MockConfiguration()).build(), remoteConnection, pollConnection);
} catch (ExecutionException e) {
fail(e.getMessage());
}
}
});
debuggerSession[0].getProcess().getProcessHandler().addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
print(event.getText(), outputType);
}
});
return debuggerSession[0];
}
use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.
the class DebuggerTestCase method createLocalProcess.
protected DebuggerSession createLocalProcess(int transport, final JavaParameters javaParameters) throws ExecutionException, InterruptedException, InvocationTargetException {
createBreakpoints(javaParameters.getMainClass());
final DebuggerSession[] debuggerSession = new DebuggerSession[] { null };
DebuggerSettings.getInstance().DEBUGGER_TRANSPORT = transport;
GenericDebuggerRunnerSettings debuggerRunnerSettings = new GenericDebuggerRunnerSettings();
debuggerRunnerSettings.LOCAL = true;
debuggerRunnerSettings.setDebugPort(String.valueOf(DEFAULT_ADDRESS));
ExecutionEnvironment environment = new ExecutionEnvironmentBuilder(myProject, DefaultDebugExecutor.getDebugExecutorInstance()).runnerSettings(debuggerRunnerSettings).runProfile(new MockConfiguration()).build();
final JavaCommandLineState javaCommandLineState = new JavaCommandLineState(environment) {
@Override
protected JavaParameters createJavaParameters() {
return javaParameters;
}
@Override
protected GeneralCommandLine createCommandLine() throws ExecutionException {
return getJavaParameters().toCommandLine();
}
};
final RemoteConnection debugParameters = DebuggerManagerImpl.createDebugParameters(javaCommandLineState.getJavaParameters(), debuggerRunnerSettings, true);
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
try {
debuggerSession[0] = attachVirtualMachine(javaCommandLineState, javaCommandLineState.getEnvironment(), debugParameters, false);
} catch (ExecutionException e) {
fail(e.getMessage());
}
}
});
final ProcessHandler processHandler = debuggerSession[0].getProcess().getProcessHandler();
debuggerSession[0].getProcess().addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
print(event.getText(), outputType);
}
});
DebugProcessImpl process = (DebugProcessImpl) DebuggerManagerEx.getInstanceEx(myProject).getDebugProcess(processHandler);
assertNotNull(process);
return debuggerSession[0];
}
use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.
the class ResetConfigurationModuleAdapter method hyperlinkActivated.
@Override
protected void hyperlinkActivated(HyperlinkEvent e) {
final Module moduleByName = ModuleManager.getInstance(myProject).findModuleByName(e.getDescription());
if (moduleByName != null) {
myConfiguration.getConfigurationModule().setModule(moduleByName);
try {
Executor executor = myIsDebug ? DefaultDebugExecutor.getDebugExecutorInstance() : DefaultRunExecutor.getRunExecutorInstance();
ExecutionEnvironmentBuilder.create(myProject, executor, myConfiguration).contentToReuse(null).buildAndExecute();
Balloon balloon = myToolWindowManager.getToolWindowBalloon(myTestRunDebugId);
if (balloon != null) {
balloon.hide();
}
} catch (ExecutionException e1) {
LOG.error(e1);
}
}
}
use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.
the class ProcessProxyFactoryImpl method createCommandLineProxy.
@Override
public ProcessProxy createCommandLineProxy(JavaCommandLine javaCmdLine) throws ExecutionException {
JavaParameters javaParameters = javaCmdLine.getJavaParameters();
String mainClass = javaParameters.getMainClass();
if (ourMayUseLauncher && mainClass != null) {
String rtJarPath = JavaSdkUtil.getIdeaRtJarPath();
boolean runtimeJarFile = new File(rtJarPath).isFile() && FileUtil.isAncestor(PathManager.getHomePath(), rtJarPath, true);
if (runtimeJarFile || javaParameters.getModuleName() == null) {
try {
ProcessProxyImpl proxy = new ProcessProxyImpl(StringUtil.getShortName(mainClass));
String port = String.valueOf(proxy.getPortNumber());
String binPath = PathManager.getBinPath();
if (runtimeJarFile && JavaSdkUtil.isJdkAtLeast(javaParameters.getJdk(), JavaSdkVersion.JDK_1_5)) {
javaParameters.getVMParametersList().add("-javaagent:" + rtJarPath + '=' + port + ':' + binPath);
} else {
JavaSdkUtil.addRtJar(javaParameters.getClassPath());
ParametersList vmParametersList = javaParameters.getVMParametersList();
vmParametersList.defineProperty(AppMainV2.LAUNCHER_PORT_NUMBER, port);
vmParametersList.defineProperty(AppMainV2.LAUNCHER_BIN_PATH, binPath);
javaParameters.getProgramParametersList().prepend(mainClass);
javaParameters.setMainClass(AppMainV2.class.getName());
}
return proxy;
} catch (Exception e) {
Logger.getInstance(ProcessProxy.class).warn(e);
}
}
}
return null;
}
Aggregations