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);
}
}
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);
}
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;
}
Aggregations