Search in sources :

Example 51 with ExecutionEnvironment

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

the class PyEduDebugRunner method getScriptName.

@Nullable
private static String getScriptName(PythonCommandLineState pyState) {
    ExecutionEnvironment environment = pyState.getEnvironment();
    if (environment == null) {
        return null;
    }
    RunProfile runProfile = environment.getRunProfile();
    if (runProfile instanceof PythonRunConfiguration) {
        String name = FileUtil.toSystemIndependentName(((PythonRunConfiguration) runProfile).getScriptName());
        return SystemInfo.isWindows ? name.toLowerCase() : name;
    }
    return null;
}
Also used : ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) PythonRunConfiguration(com.jetbrains.python.run.PythonRunConfiguration) RunProfile(com.intellij.execution.configurations.RunProfile) Nullable(org.jetbrains.annotations.Nullable)

Example 52 with ExecutionEnvironment

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

the class KarmaCoverageProgramRunner method listenForCoverageFile.

private static void listenForCoverageFile(@NotNull ExecutionEnvironment env, @NotNull KarmaServer server) throws ExecutionException {
    KarmaRunConfiguration runConfiguration = (KarmaRunConfiguration) env.getRunProfile();
    CoverageEnabledConfiguration coverageEnabledConfiguration = CoverageEnabledConfiguration.getOrCreate(runConfiguration);
    CoverageHelper.resetCoverageSuit(runConfiguration);
    String coverageFilePath = coverageEnabledConfiguration.getCoverageFilePath();
    if (coverageFilePath != null) {
        KarmaCoveragePeer coveragePeer = server.getCoveragePeer();
        Objects.requireNonNull(coveragePeer);
        coveragePeer.startCoverageSession(new KarmaCoverageSession() {

            @Override
            public void onCoverageSessionFinished(@Nullable File lcovFile) {
                LOG.info("Processing karma coverage file: " + lcovFile);
                UIUtil.invokeLaterIfNeeded(() -> {
                    Project project = env.getProject();
                    if (project.isDisposed())
                        return;
                    if (lcovFile != null) {
                        processLcovInfoFile(lcovFile, coverageFilePath, env, server, runConfiguration);
                    } else {
                        int response = Messages.showYesNoDialog(project, "Cannot find karma test coverage report - lcov.info", "Missing Karma Coverage Report", "Select lcov.info", "Cancel", Messages.getWarningIcon());
                        if (response == Messages.YES) {
                            FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFileDescriptor(), project, null, null, file -> {
                                File selected = file != null ? VfsUtilCore.virtualToIoFile(file) : null;
                                if (selected != null) {
                                    processLcovInfoFile(selected, coverageFilePath, env, server, runConfiguration);
                                }
                            });
                        }
                    }
                });
            }
        });
    }
}
Also used : KarmaRunConfiguration(com.intellij.javascript.karma.execution.KarmaRunConfiguration) KarmaUtil(com.intellij.javascript.karma.util.KarmaUtil) KarmaRunConfiguration(com.intellij.javascript.karma.execution.KarmaRunConfiguration) UIUtil(com.intellij.util.ui.UIUtil) FileChooserDescriptorFactory(com.intellij.openapi.fileChooser.FileChooserDescriptorFactory) ExecutionException(com.intellij.execution.ExecutionException) CoverageHelper(com.intellij.coverage.CoverageHelper) RunProfileState(com.intellij.execution.configurations.RunProfileState) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) Project(com.intellij.openapi.project.Project) ExecutionResult(com.intellij.execution.ExecutionResult) Messages(com.intellij.openapi.ui.Messages) FileUtil(com.intellij.openapi.util.io.FileUtil) Logger(com.intellij.openapi.diagnostic.Logger) CoverageEnabledConfiguration(com.intellij.execution.configurations.coverage.CoverageEnabledConfiguration) CoverageRunnerData(com.intellij.coverage.CoverageRunnerData) ConfigurationInfoProvider(com.intellij.execution.configurations.ConfigurationInfoProvider) GenericProgramRunner(com.intellij.execution.runners.GenericProgramRunner) VfsUtilCore(com.intellij.openapi.vfs.VfsUtilCore) KarmaServer(com.intellij.javascript.karma.server.KarmaServer) CoverageDataManager(com.intellij.coverage.CoverageDataManager) RunProfile(com.intellij.execution.configurations.RunProfile) FileDocumentManager(com.intellij.openapi.fileEditor.FileDocumentManager) IOException(java.io.IOException) RunnerSettings(com.intellij.execution.configurations.RunnerSettings) File(java.io.File) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) CoverageExecutor(com.intellij.coverage.CoverageExecutor) ExecutionUtil(com.intellij.execution.runners.ExecutionUtil) KarmaConsoleView(com.intellij.javascript.karma.execution.KarmaConsoleView) NotNull(org.jetbrains.annotations.NotNull) FileChooser(com.intellij.openapi.fileChooser.FileChooser) Project(com.intellij.openapi.project.Project) CoverageEnabledConfiguration(com.intellij.execution.configurations.coverage.CoverageEnabledConfiguration) File(java.io.File)

Example 53 with ExecutionEnvironment

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

the class DartVmServiceDebugProcessZ method onConnectSucceeded.

private void onConnectSucceeded(VmService vmService, VmOpenSourceLocationListener vmOpenSourceLocationListener) {
    final DartVmServiceListener vmServiceListener = new DartVmServiceListener(this, (DartVmServiceBreakpointHandler) myBreakpointHandlers[0]);
    final DartVmServiceBreakpointHandler breakpointHandler = (DartVmServiceBreakpointHandler) myBreakpointHandlers[0];
    myVmOpenSourceLocationListener = vmOpenSourceLocationListener;
    myVmServiceWrapper = new VmServiceWrapper(this, vmService, vmServiceListener, myIsolatesInfo, breakpointHandler);
    final ScriptProvider provider = (isolateId, scriptId) -> myVmServiceWrapper.getScriptSync(isolateId, scriptId);
    mapper.onConnect(provider, myConnector.getRemoteBaseUrl());
    // We disable the remote debug flag so that handleDebuggerConnected() does not echo the stdout and
    // stderr streams (this would duplicate what we get over daemon logging).
    remoteDebug = false;
    final FlutterLaunchMode launchMode = FlutterLaunchMode.getMode(executionEnvironment);
    if (launchMode.supportsDebugConnection()) {
        myVmServiceWrapper.handleDebuggerConnected();
    }
    // We re-enable the remote debug flag so that the service wrapper will call our guessRemoteProjectRoot()
    // method with the list of loaded libraries for the isolate.
    remoteDebug = true;
    vmService.addVmServiceListener(vmServiceListener);
    myVmOpenSourceLocationListener.addListener(this::onOpenSourceLocationRequest);
    myVmConnected = true;
    getSession().rebuildViews();
    onVmConnected(vmService);
}
Also used : java.util(java.util) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ObservatoryConnector(com.jetbrains.lang.dart.ide.runner.ObservatoryConnector) DartVmServiceSuspendContext(com.jetbrains.lang.dart.ide.runner.server.vmService.frame.DartVmServiceSuspendContext) THashSet(gnu.trove.THashSet) FlutterLaunchMode(io.flutter.run.FlutterLaunchMode) org.dartlang.vm.service.element(org.dartlang.vm.service.element) XDebuggerEditorsProvider(com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider) GetObjectConsumer(org.dartlang.vm.service.consumer.GetObjectConsumer) XDebuggerBundle(com.intellij.xdebugger.XDebuggerBundle) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) XStackFrame(com.intellij.xdebugger.frame.XStackFrame) ConsoleViewContentType(com.intellij.execution.ui.ConsoleViewContentType) DartUrlResolver(com.jetbrains.lang.dart.util.DartUrlResolver) WindowListener(java.awt.event.WindowListener) ProjectUtil(com.intellij.ide.impl.ProjectUtil) Disposer(com.intellij.openapi.util.Disposer) Project(com.intellij.openapi.project.Project) ExecutionResult(com.intellij.execution.ExecutionResult) Logging(org.dartlang.vm.service.logging.Logging) OpenFileHyperlinkInfo(com.intellij.execution.filters.OpenFileHyperlinkInfo) Logger(com.intellij.openapi.diagnostic.Logger) XDebugSession(com.intellij.xdebugger.XDebugSession) XDebugSessionListener(com.intellij.xdebugger.XDebugSessionListener) XSuspendContext(com.intellij.xdebugger.frame.XSuspendContext) DartDebuggerEditorsProvider(com.jetbrains.lang.dart.ide.runner.base.DartDebuggerEditorsProvider) Frame(java.awt.Frame) WindowManager(com.intellij.openapi.wm.WindowManager) VmService(org.dartlang.vm.service.VmService) IOException(java.io.IOException) XBreakpointHandler(com.intellij.xdebugger.breakpoints.XBreakpointHandler) FlutterBundle(io.flutter.FlutterBundle) SystemInfo(com.intellij.openapi.util.SystemInfo) WindowEvent(java.awt.event.WindowEvent) StandardCharsets(java.nio.charset.StandardCharsets) java.awt(java.awt) Nullable(org.jetbrains.annotations.Nullable) XSourcePosition(com.intellij.xdebugger.XSourcePosition) TimeoutUtil(com.intellij.util.TimeoutUtil) DartVmServiceStackFrame(com.jetbrains.lang.dart.ide.runner.server.vmService.frame.DartVmServiceStackFrame) BitUtil(com.intellij.util.BitUtil) ApplicationManager(com.intellij.openapi.application.ApplicationManager) NotNull(org.jetbrains.annotations.NotNull) javax.swing(javax.swing) FlutterLaunchMode(io.flutter.run.FlutterLaunchMode)

Example 54 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)

Example 55 with ExecutionEnvironment

use of com.intellij.execution.runners.ExecutionEnvironment 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();
}
Also used : UIUtil(com.intellij.util.ui.UIUtil) GoRunConfigurationBase(com.goide.runconfig.GoRunConfigurationBase) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) DataContext(com.intellij.openapi.actionSystem.DataContext) GoIcons(com.goide.GoIcons) StringUtil(com.intellij.openapi.util.text.StringUtil) GoExecutor(com.goide.util.GoExecutor) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) Key(com.intellij.openapi.util.Key) VirtualFileManager(com.intellij.openapi.vfs.VirtualFileManager) GoSdkService(com.goide.sdk.GoSdkService) Nullable(org.jetbrains.annotations.Nullable) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) Semaphore(com.intellij.util.concurrency.Semaphore) BeforeRunTaskProvider(com.intellij.execution.BeforeRunTaskProvider) Project(com.intellij.openapi.project.Project) ProcessEvent(com.intellij.execution.process.ProcessEvent) Messages(com.intellij.openapi.ui.Messages) Module(com.intellij.openapi.module.Module) Ref(com.intellij.openapi.util.Ref) javax.swing(javax.swing) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) Semaphore(com.intellij.util.concurrency.Semaphore) GoSdkService(com.goide.sdk.GoSdkService) GoRunConfigurationBase(com.goide.runconfig.GoRunConfigurationBase) Project(com.intellij.openapi.project.Project) Module(com.intellij.openapi.module.Module)

Aggregations

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