Search in sources :

Example 1 with DartCommandLineRunConfiguration

use of com.jetbrains.lang.dart.ide.runner.server.DartCommandLineRunConfiguration in project intellij-plugins by JetBrains.

the class DartCoverageProgramRunner method startCollectingCoverage.

private static void startCollectingCoverage(@NotNull final ExecutionEnvironment env, @NotNull final ProcessHandler dartAppProcessHandler, @NotNull final String observatoryUrl) {
    final DartCommandLineRunConfiguration dartRC = (DartCommandLineRunConfiguration) env.getRunProfile();
    final DartCoverageEnabledConfiguration coverageConfiguration = (DartCoverageEnabledConfiguration) CoverageEnabledConfiguration.getOrCreate(dartRC);
    final String coverageFilePath = coverageConfiguration.getCoverageFilePath();
    final DartSdk sdk = DartSdk.getDartSdk(env.getProject());
    LOG.assertTrue(sdk != null);
    final GeneralCommandLine cmdline = new GeneralCommandLine().withExePath(DartSdkUtil.getPubPath(sdk)).withParameters("global", "run", "coverage:collect_coverage", "--uri", observatoryUrl, "--out", coverageFilePath, "--resume-isolates", "--wait-paused");
    try {
        final ProcessHandler coverageProcess = new OSProcessHandler(cmdline);
        coverageProcess.addProcessListener(new ProcessAdapter() {

            @Override
            public void onTextAvailable(@NotNull final ProcessEvent event, @NotNull final Key outputType) {
                LOG.debug(event.getText());
            }
        });
        coverageProcess.startNotify();
        coverageConfiguration.setCoverageProcess(coverageProcess);
        CoverageHelper.attachToProcess(dartRC, dartAppProcessHandler, env.getRunnerSettings());
    } catch (ExecutionException e) {
        LOG.error(e);
    }
}
Also used : DartSdk(com.jetbrains.lang.dart.sdk.DartSdk) DartCommandLineRunConfiguration(com.jetbrains.lang.dart.ide.runner.server.DartCommandLineRunConfiguration) ExecutionException(com.intellij.execution.ExecutionException) Key(com.intellij.openapi.util.Key)

Example 2 with DartCommandLineRunConfiguration

use of com.jetbrains.lang.dart.ide.runner.server.DartCommandLineRunConfiguration in project intellij-plugins by JetBrains.

the class DartProjectTemplate method createCmdLineRunConfiguration.

static void createCmdLineRunConfiguration(@NotNull final Module module, @NotNull final VirtualFile mainDartFile) {
    DartModuleBuilder.runWhenNonModalIfModuleNotDisposed(() -> {
        final RunManager runManager = RunManager.getInstance(module.getProject());
        final RunnerAndConfigurationSettings settings = runManager.createRunConfiguration("", DartCommandLineRunConfigurationType.getInstance().getConfigurationFactories()[0]);
        final DartCommandLineRunConfiguration runConfiguration = (DartCommandLineRunConfiguration) settings.getConfiguration();
        runConfiguration.getRunnerParameters().setFilePath(mainDartFile.getPath());
        runConfiguration.getRunnerParameters().setWorkingDirectory(DartCommandLineRunnerParameters.suggestDartWorkingDir(module.getProject(), mainDartFile));
        settings.setName(runConfiguration.suggestedName());
        runManager.addConfiguration(settings, false);
        runManager.setSelectedConfiguration(settings);
    }, module);
}
Also used : DartCommandLineRunConfiguration(com.jetbrains.lang.dart.ide.runner.server.DartCommandLineRunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) RunManager(com.intellij.execution.RunManager)

Example 3 with DartCommandLineRunConfiguration

use of com.jetbrains.lang.dart.ide.runner.server.DartCommandLineRunConfiguration in project intellij-plugins by JetBrains.

the class DartCoverageProgramRunner method doExecute.

@Nullable
@Override
protected RunContentDescriptor doExecute(@NotNull final RunProfileState state, @NotNull final ExecutionEnvironment env) throws ExecutionException {
    FileDocumentManager.getInstance().saveAllDocuments();
    final DartCommandLineRunConfiguration runConfiguration = (DartCommandLineRunConfiguration) env.getRunProfile();
    final DartSdk sdk = DartSdk.getDartSdk(runConfiguration.getProject());
    if (sdk == null) {
        throw new ExecutionException(DartBundle.message("dart.sdk.is.not.configured"));
    }
    final String dartPubPath = DartSdkUtil.getPubPath(sdk);
    final RunContentDescriptor result = DefaultProgramRunnerKt.executeState(state, env, this);
    if (result == null) {
        return null;
    }
    if (!myCoveragePackageActivated && !activateCoverage(runConfiguration.getProject(), dartPubPath)) {
        throw new ExecutionException("Cannot activate pub package 'coverage'.");
    }
    final ProcessHandler dartAppProcessHandler = result.getProcessHandler();
    if (dartAppProcessHandler != null) {
        ((DartCommandLineRunningState) state).addObservatoryUrlConsumer(observatoryUrl -> startCollectingCoverage(env, dartAppProcessHandler, observatoryUrl));
    }
    return result;
}
Also used : DartCommandLineRunningState(com.jetbrains.lang.dart.ide.runner.server.DartCommandLineRunningState) DartSdk(com.jetbrains.lang.dart.sdk.DartSdk) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) DartCommandLineRunConfiguration(com.jetbrains.lang.dart.ide.runner.server.DartCommandLineRunConfiguration) ExecutionException(com.intellij.execution.ExecutionException) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

DartCommandLineRunConfiguration (com.jetbrains.lang.dart.ide.runner.server.DartCommandLineRunConfiguration)3 ExecutionException (com.intellij.execution.ExecutionException)2 DartSdk (com.jetbrains.lang.dart.sdk.DartSdk)2 RunManager (com.intellij.execution.RunManager)1 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)1 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)1 Key (com.intellij.openapi.util.Key)1 DartCommandLineRunningState (com.jetbrains.lang.dart.ide.runner.server.DartCommandLineRunningState)1 Nullable (org.jetbrains.annotations.Nullable)1