Search in sources :

Example 1 with DefaultExecutionResult

use of com.intellij.execution.DefaultExecutionResult in project buck by facebook.

the class TestExecutionState method execute.

@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
    final ProcessHandler processHandler = runBuildCommand(executor);
    final TestConsoleProperties properties = new BuckTestConsoleProperties(processHandler, mProject, mConfiguration, "Buck test", executor);
    final ConsoleView console = SMTestRunnerConnectionUtil.createAndAttachConsole("buck test", processHandler, properties);
    return new DefaultExecutionResult(console, processHandler, AnAction.EMPTY_ARRAY);
}
Also used : DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) ConsoleView(com.intellij.execution.ui.ConsoleView) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) TestConsoleProperties(com.intellij.execution.testframework.TestConsoleProperties) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with DefaultExecutionResult

use of com.intellij.execution.DefaultExecutionResult in project azure-tools-for-java by Microsoft.

the class SparkBatchJobSubmissionState method execute.

@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner programRunner) throws ExecutionException {
    if (programRunner instanceof SparkBatchJobDebuggerRunner) {
        ConsoleViewImpl consoleView = new ConsoleViewImpl(myProject, false);
        RemoteDebugProcessHandler process = new RemoteDebugProcessHandler(myProject);
        consoleView.attachToProcess(process);
        return new DefaultExecutionResult(consoleView, process);
    } else if (programRunner instanceof SparkBatchJobRunner) {
        SparkBatchJobRunner jobRunner = (SparkBatchJobRunner) programRunner;
        jobRunner.submitJob(getSubmitModel());
    }
    return null;
}
Also used : DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) RemoteDebugProcessHandler(com.intellij.debugger.engine.RemoteDebugProcessHandler) ConsoleViewImpl(com.intellij.execution.impl.ConsoleViewImpl) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with DefaultExecutionResult

use of com.intellij.execution.DefaultExecutionResult in project intellij-community by JetBrains.

the class PythonTestCommandLineStateBase method execute.

@Override
public ExecutionResult execute(Executor executor, PythonProcessStarter processStarter, CommandLinePatcher... patchers) throws ExecutionException {
    final ProcessHandler processHandler = startProcess(processStarter, patchers);
    final ConsoleView console = createAndAttachConsole(myConfiguration.getProject(), processHandler, executor);
    DefaultExecutionResult executionResult = new DefaultExecutionResult(console, processHandler, createActions(console, processHandler));
    PyRerunFailedTestsAction rerunFailedTestsAction = new PyRerunFailedTestsAction(console);
    if (console instanceof SMTRunnerConsoleView) {
        rerunFailedTestsAction.init(((BaseTestsOutputConsoleView) console).getProperties());
        rerunFailedTestsAction.setModelProvider(() -> ((SMTRunnerConsoleView) console).getResultsViewer());
    }
    executionResult.setRestartActions(rerunFailedTestsAction, new ToggleAutoTestAction());
    return executionResult;
}
Also used : SMTRunnerConsoleView(com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView) DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) SMTRunnerConsoleView(com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView) BaseTestsOutputConsoleView(com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView) ConsoleView(com.intellij.execution.ui.ConsoleView) PythonDebugLanguageConsoleView(com.jetbrains.python.console.PythonDebugLanguageConsoleView) ProcessHandler(com.intellij.execution.process.ProcessHandler) ToggleAutoTestAction(com.intellij.execution.testframework.autotest.ToggleAutoTestAction)

Example 4 with DefaultExecutionResult

use of com.intellij.execution.DefaultExecutionResult in project intellij-community by JetBrains.

the class PythonCommandLineState method execute.

public ExecutionResult execute(Executor executor, PythonProcessStarter processStarter, CommandLinePatcher... patchers) throws ExecutionException {
    final ProcessHandler processHandler = startProcess(processStarter, patchers);
    final ConsoleView console = createAndAttachConsole(myConfig.getProject(), processHandler, executor);
    return new DefaultExecutionResult(console, processHandler, createActions(console, processHandler));
}
Also used : DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) ConsoleView(com.intellij.execution.ui.ConsoleView) ProcessHandler(com.intellij.execution.process.ProcessHandler)

Example 5 with DefaultExecutionResult

use of com.intellij.execution.DefaultExecutionResult in project intellij-community by JetBrains.

the class MavenServerManager method createRunProfileState.

private RunProfileState createRunProfileState() {
    return new CommandLineState(null) {

        private SimpleJavaParameters createJavaParameters() {
            final SimpleJavaParameters params = new SimpleJavaParameters();
            final Sdk jdk = getJdk();
            params.setJdk(jdk);
            params.setWorkingDirectory(PathManager.getBinPath());
            params.setMainClass(MAIN_CLASS);
            Map<String, String> defs = new THashMap<>();
            defs.putAll(MavenUtil.getPropertiesFromMavenOpts());
            // pass ssl-related options
            for (Map.Entry<Object, Object> each : System.getProperties().entrySet()) {
                Object key = each.getKey();
                Object value = each.getValue();
                if (key instanceof String && value instanceof String && ((String) key).startsWith("javax.net.ssl")) {
                    defs.put((String) key, (String) value);
                }
            }
            if (SystemInfo.isMac) {
                String arch = System.getProperty("sun.arch.data.model");
                if (arch != null) {
                    params.getVMParametersList().addParametersString("-d" + arch);
                }
            }
            defs.put("java.awt.headless", "true");
            for (Map.Entry<String, String> each : defs.entrySet()) {
                params.getVMParametersList().defineProperty(each.getKey(), each.getValue());
            }
            params.getVMParametersList().addProperty("idea.version=", MavenUtil.getIdeaVersionToPassToMavenProcess());
            boolean xmxSet = false;
            boolean forceMaven2 = false;
            if (myState.vmOptions != null) {
                ParametersList mavenOptsList = new ParametersList();
                mavenOptsList.addParametersString(myState.vmOptions);
                for (String param : mavenOptsList.getParameters()) {
                    if (param.startsWith("-Xmx")) {
                        xmxSet = true;
                    }
                    if (param.equals(FORCE_MAVEN2_OPTION)) {
                        forceMaven2 = true;
                    }
                    params.getVMParametersList().add(param);
                }
            }
            final File mavenHome;
            final String mavenVersion;
            final File currentMavenHomeFile = forceMaven2 ? BundledMavenPathHolder.myBundledMaven2Home : getCurrentMavenHomeFile();
            if (currentMavenHomeFile == null) {
                mavenHome = BundledMavenPathHolder.myBundledMaven3Home;
                mavenVersion = getMavenVersion(mavenHome);
                Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
                final Project project = openProjects.length == 1 ? openProjects[0] : null;
                if (project != null) {
                    new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "", RunnerBundle.message("external.maven.home.invalid.substitution.warning.with.fix", myState.mavenHome, mavenVersion), NotificationType.WARNING, new NotificationListener() {

                        @Override
                        public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
                            ShowSettingsUtil.getInstance().showSettingsDialog(project, MavenSettings.DISPLAY_NAME);
                        }
                    }).notify(null);
                } else {
                    new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "", RunnerBundle.message("external.maven.home.invalid.substitution.warning", myState.mavenHome, mavenVersion), NotificationType.WARNING).notify(null);
                }
            } else {
                mavenHome = currentMavenHomeFile;
                mavenVersion = getMavenVersion(mavenHome);
            }
            assert mavenVersion != null;
            params.getVMParametersList().addProperty(MavenServerEmbedder.MAVEN_EMBEDDER_VERSION, mavenVersion);
            String sdkConfigLocation = "Settings | Build, Execution, Deployment | Build Tools | Maven | Importing | JDK for Importer";
            verifyMavenSdkRequirements(jdk, mavenVersion, sdkConfigLocation);
            final List<String> classPath = new ArrayList<>();
            classPath.add(PathUtil.getJarPathForClass(org.apache.log4j.Logger.class));
            if (StringUtil.compareVersionNumbers(mavenVersion, "3.1") < 0) {
                classPath.add(PathUtil.getJarPathForClass(Logger.class));
                classPath.add(PathUtil.getJarPathForClass(Log4jLoggerFactory.class));
            }
            classPath.addAll(PathManager.getUtilClassPath());
            ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(Query.class));
            params.getClassPath().add(PathManager.getResourceRoot(getClass(), "/messages/CommonBundle.properties"));
            params.getClassPath().addAll(classPath);
            params.getClassPath().addAllFiles(collectClassPathAndLibsFolder(mavenVersion, mavenHome));
            String embedderXmx = System.getProperty("idea.maven.embedder.xmx");
            if (embedderXmx != null) {
                params.getVMParametersList().add("-Xmx" + embedderXmx);
            } else {
                if (!xmxSet) {
                    params.getVMParametersList().add("-Xmx768m");
                }
            }
            String mavenEmbedderDebugPort = System.getProperty("idea.maven.embedder.debug.port");
            if (mavenEmbedderDebugPort != null) {
                params.getVMParametersList().addParametersString("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=" + mavenEmbedderDebugPort);
            }
            String mavenEmbedderParameters = System.getProperty("idea.maven.embedder.parameters");
            if (mavenEmbedderParameters != null) {
                params.getProgramParametersList().addParametersString(mavenEmbedderParameters);
            }
            String mavenEmbedderCliOptions = System.getProperty(MavenServerEmbedder.MAVEN_EMBEDDER_CLI_ADDITIONAL_ARGS);
            if (mavenEmbedderCliOptions != null) {
                params.getVMParametersList().addProperty(MavenServerEmbedder.MAVEN_EMBEDDER_CLI_ADDITIONAL_ARGS, mavenEmbedderCliOptions);
            }
            return params;
        }

        @NotNull
        @Override
        public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
            ProcessHandler processHandler = startProcess();
            return new DefaultExecutionResult(processHandler);
        }

        @Override
        @NotNull
        protected OSProcessHandler startProcess() throws ExecutionException {
            SimpleJavaParameters params = createJavaParameters();
            GeneralCommandLine commandLine = params.toCommandLine();
            OSProcessHandler processHandler = new OSProcessHandler(commandLine);
            processHandler.setShouldDestroyProcessRecursively(false);
            return processHandler;
        }
    };
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) Query(org.apache.lucene.search.Query) Logger(org.slf4j.Logger) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification) Executor(com.intellij.execution.Executor) THashMap(gnu.trove.THashMap) Log4jLoggerFactory(org.slf4j.impl.Log4jLoggerFactory) JavaSdk(com.intellij.openapi.projectRoots.JavaSdk) Sdk(com.intellij.openapi.projectRoots.Sdk) ProgramRunner(com.intellij.execution.runners.ProgramRunner) Project(com.intellij.openapi.project.Project) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) UnicastRemoteObject(java.rmi.server.UnicastRemoteObject) THashMap(gnu.trove.THashMap) File(java.io.File) NotificationListener(com.intellij.notification.NotificationListener)

Aggregations

DefaultExecutionResult (com.intellij.execution.DefaultExecutionResult)18 ProcessHandler (com.intellij.execution.process.ProcessHandler)14 ConsoleView (com.intellij.execution.ui.ConsoleView)9 NotNull (org.jetbrains.annotations.NotNull)8 Nullable (org.jetbrains.annotations.Nullable)6 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)4 ToggleAutoTestAction (com.intellij.execution.testframework.autotest.ToggleAutoTestAction)4 SMTRunnerConsoleView (com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView)4 Executor (com.intellij.execution.Executor)3 ProgramRunner (com.intellij.execution.runners.ProgramRunner)3 AbstractRerunFailedTestsAction (com.intellij.execution.testframework.actions.AbstractRerunFailedTestsAction)3 BaseTestsOutputConsoleView (com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView)3 ExecutionException (com.intellij.execution.ExecutionException)2 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)2 RunProfile (com.intellij.execution.configurations.RunProfile)2 ConsoleViewImpl (com.intellij.execution.impl.ConsoleViewImpl)2 TestConsoleProperties (com.intellij.execution.testframework.TestConsoleProperties)2 SMTRunnerConsoleProperties (com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties)2 File (java.io.File)2 InstantRunBuildInfo (com.android.tools.fd.client.InstantRunBuildInfo)1