Search in sources :

Example 21 with ExecutionEnvironment

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

the class XDebuggerTree method isUnderRemoteDebug.

public boolean isUnderRemoteDebug() {
    DataContext context = DataManager.getInstance().getDataContext(this);
    ExecutionEnvironment env = LangDataKeys.EXECUTION_ENVIRONMENT.getData(context);
    if (env != null && env.getRunProfile() instanceof RemoteRunProfile) {
        return true;
    }
    return false;
}
Also used : ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) RemoteRunProfile(com.intellij.execution.configurations.RemoteRunProfile)

Example 22 with ExecutionEnvironment

use of com.intellij.execution.runners.ExecutionEnvironment in project android by JetBrains.

the class HotswapAction method doPerform.

@Override
protected void doPerform(@NotNull AnActionEvent e, @NotNull Project project) {
    RunnerAndConfigurationSettings settings = RunManager.getInstance(project).getSelectedConfiguration();
    if (settings == null) {
        InstantRunManager.LOG.warn("Hotswap Action could not locate current run config settings");
        return;
    }
    AndroidSessionInfo session = getAndroidSessionInfo(project, settings);
    if (session == null) {
        InstantRunManager.LOG.warn("Hotswap Action could not locate an existing session for selected run config.");
        return;
    }
    Executor executor = getExecutor(session.getExecutorId());
    if (executor == null) {
        InstantRunManager.LOG.warn("Hotswap Action could not identify executor");
        return;
    }
    ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder.createOrNull(executor, settings);
    if (builder == null) {
        InstantRunManager.LOG.warn("Hotswap Action could not construct an env");
        return;
    }
    ExecutionEnvironment env = builder.activeTarget().dataContext(e.getDataContext()).build();
    InstantRunUtils.setInvokedViaHotswapAction(env, true);
    InstantRunManager.LOG.info("Invoking hotswap launch");
    ProgramRunnerUtil.executeConfiguration(env, false, true);
}
Also used : ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) Executor(com.intellij.execution.Executor) AndroidSessionInfo(com.android.tools.idea.run.AndroidSessionInfo) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ExecutionEnvironmentBuilder(com.intellij.execution.runners.ExecutionEnvironmentBuilder)

Example 23 with ExecutionEnvironment

use of com.intellij.execution.runners.ExecutionEnvironment in project intellij-plugins by JetBrains.

the class DartTestEventsConverterTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    myNodes = new HashMap<>();
    final ExecutionEnvironment environment = new ExecutionEnvironment();
    myMockResettablePrinter = new MockPrinter(true);
    TestConsoleProperties consoleProperties = createConsoleProperties();
    myConsole = new MyConsoleView(consoleProperties, environment);
    myConsole.initUI();
    myResultsViewer = myConsole.getResultsViewer();
    myEventsConverter = new DartTestEventsConverter(DartTestRunningState.DART_FRAMEWORK_NAME, consoleProperties, DartUrlResolver.getInstance(getProject(), getSourceRoot()));
    myEventsProcessor = new DartTestEventsProcessor(consoleProperties.getProject(), DartTestRunningState.DART_FRAMEWORK_NAME);
    myEventsProcessor.addEventsListener(myResultsViewer);
    myEventsConverter.setProcessor(myEventsProcessor);
    myTreeModel = myResultsViewer.getTreeView() == null ? null : (DefaultTreeModel) myResultsViewer.getTreeView().getModel();
    assertNotNull(myTreeModel);
    myParentNode = (DefaultMutableTreeNode) myTreeModel.getRoot();
    myEventsProcessor.onStartTesting();
}
Also used : ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) MockPrinter(com.intellij.execution.testframework.sm.runner.ui.MockPrinter) TestConsoleProperties(com.intellij.execution.testframework.TestConsoleProperties)

Example 24 with ExecutionEnvironment

use of com.intellij.execution.runners.ExecutionEnvironment in project intellij-plugins by JetBrains.

the class AdlUtil method runDebugger.

// http://kb2.adobe.com/cps/407/kb407625.html
public static void runDebugger(final Module module, final Runnable postTask) throws ExecutionException {
    final Project project = module.getProject();
    final RunnerAndConfigurationSettings settings = RunManager.getInstance(project).createConfiguration("FlashUIDesigner", RemoteFlashRunConfigurationType.getFactory());
    final RemoteFlashRunConfiguration configuration = (RemoteFlashRunConfiguration) settings.getConfiguration();
    RunManagerEx.disableTasks(project, settings.getConfiguration(), CompileStepBeforeRun.ID, CompileStepBeforeRunNoErrorCheck.ID);
    final Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();
    ProgramRunner.Callback callback = new ProgramRunner.Callback() {

        @Override
        public void processStarted(final RunContentDescriptor descriptor) {
            final ProcessHandler processHandler = descriptor.getProcessHandler();
            assert processHandler != null;
            DesignerApplication application = DesignerApplicationManager.getApplication();
            if (application != null) {
                Disposer.register(application, new Disposable() {

                    @Override
                    public void dispose() {
                        if (!project.isDisposed()) {
                            ApplicationManager.getApplication().invokeLater(() -> ExecutionManager.getInstance(project).getContentManager().removeRunContent(executor, descriptor));
                        }
                        processHandler.destroyProcess();
                    }
                });
                postTask.run();
            }
        }
    };
    FlexBuildConfiguration buildConfiguration = FlexBuildConfigurationManager.getInstance(module).getActiveConfiguration();
    configuration.getRunnerParameters().setModuleName(module.getName());
    configuration.getRunnerParameters().setBCName(buildConfiguration.getName());
    final FlexRunner runner = new FlexRunner(callback, buildConfiguration);
    runner.execute(new ExecutionEnvironment(executor, runner, settings, project));
}
Also used : Disposable(com.intellij.openapi.Disposable) FlexRunner(com.intellij.flex.uiDesigner.debug.FlexRunner) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Project(com.intellij.openapi.project.Project) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) RemoteFlashRunConfiguration(com.intellij.lang.javascript.flex.run.RemoteFlashRunConfiguration) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) ProgramRunner(com.intellij.execution.runners.ProgramRunner)

Example 25 with ExecutionEnvironment

use of com.intellij.execution.runners.ExecutionEnvironment 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) {
    }
}
Also used : ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) ProcessHandler(com.intellij.execution.process.ProcessHandler) ProgramRunner(com.intellij.execution.runners.ProgramRunner)

Aggregations

ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)49 ProcessHandler (com.intellij.execution.process.ProcessHandler)13 ProcessEvent (com.intellij.execution.process.ProcessEvent)12 NotNull (org.jetbrains.annotations.NotNull)12 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)11 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)11 Project (com.intellij.openapi.project.Project)11 Nullable (org.jetbrains.annotations.Nullable)11 ProgramRunner (com.intellij.execution.runners.ProgramRunner)10 ExecutionException (com.intellij.execution.ExecutionException)9 Executor (com.intellij.execution.Executor)8 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)8 ExecutionEnvironmentBuilder (com.intellij.execution.runners.ExecutionEnvironmentBuilder)8 Key (com.intellij.openapi.util.Key)8 RunProfile (com.intellij.execution.configurations.RunProfile)7 Ref (com.intellij.openapi.util.Ref)7 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)6 Module (com.intellij.openapi.module.Module)6 IOException (java.io.IOException)5 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)4