Search in sources :

Example 91 with ExecutionException

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;
}
Also used : ProcessOutput(com.intellij.execution.process.ProcessOutput) ElixirSdkRelease(org.elixir_lang.sdk.ElixirSdkRelease) ExecutionException(com.intellij.execution.ExecutionException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 92 with ExecutionException

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];
}
Also used : ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) ThrowableRunnable(com.intellij.util.ThrowableRunnable) RemoteStateState(com.intellij.debugger.engine.RemoteStateState) ExecutionEnvironmentBuilder(com.intellij.execution.runners.ExecutionEnvironmentBuilder) ExecutionException(com.intellij.execution.ExecutionException) Key(com.intellij.openapi.util.Key)

Example 93 with ExecutionException

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];
}
Also used : ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) ThrowableRunnable(com.intellij.util.ThrowableRunnable) ProcessHandler(com.intellij.execution.process.ProcessHandler) ExecutionEnvironmentBuilder(com.intellij.execution.runners.ExecutionEnvironmentBuilder) ExecutionException(com.intellij.execution.ExecutionException) Key(com.intellij.openapi.util.Key)

Example 94 with ExecutionException

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);
        }
    }
}
Also used : DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) Executor(com.intellij.execution.Executor) Balloon(com.intellij.openapi.ui.popup.Balloon) Module(com.intellij.openapi.module.Module) JavaRunConfigurationModule(com.intellij.execution.configurations.JavaRunConfigurationModule) ExecutionException(com.intellij.execution.ExecutionException)

Example 95 with ExecutionException

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;
}
Also used : ParametersList(com.intellij.execution.configurations.ParametersList) JavaParameters(com.intellij.execution.configurations.JavaParameters) File(java.io.File) AppMainV2(com.intellij.rt.execution.application.AppMainV2) ExecutionException(com.intellij.execution.ExecutionException)

Aggregations

ExecutionException (com.intellij.execution.ExecutionException)154 NotNull (org.jetbrains.annotations.NotNull)42 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)39 IOException (java.io.IOException)35 File (java.io.File)34 VirtualFile (com.intellij.openapi.vfs.VirtualFile)26 Sdk (com.intellij.openapi.projectRoots.Sdk)20 Nullable (org.jetbrains.annotations.Nullable)20 Project (com.intellij.openapi.project.Project)19 ProcessHandler (com.intellij.execution.process.ProcessHandler)17 ProcessOutput (com.intellij.execution.process.ProcessOutput)17 Module (com.intellij.openapi.module.Module)13 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)12 Key (com.intellij.openapi.util.Key)12 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)10 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)9 ProcessEvent (com.intellij.execution.process.ProcessEvent)8 JavaParameters (com.intellij.execution.configurations.JavaParameters)7 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)7 ArrayList (java.util.ArrayList)7