use of com.jetbrains.lang.dart.coverage.DartCoverageProgramRunner in project intellij-plugins by JetBrains.
the class DartCommandLineRunningState method setupParameters.
private void setupParameters(@NotNull final GeneralCommandLine commandLine, @Nullable final String overriddenMainFilePath) throws ExecutionException {
int customObservatoryPort = -1;
final String vmOptions = myRunnerParameters.getVMOptions();
if (vmOptions != null) {
final StringTokenizer vmOptionsTokenizer = new CommandLineTokenizer(vmOptions);
while (vmOptionsTokenizer.hasMoreTokens()) {
final String vmOption = vmOptionsTokenizer.nextToken();
commandLine.addParameter(vmOption);
try {
if (vmOption.equals("--enable-vm-service") || vmOption.equals("--observe")) {
// default port, see https://www.dartlang.org/tools/dart-vm/
customObservatoryPort = 8181;
} else if (vmOption.startsWith("--enable-vm-service:")) {
customObservatoryPort = parseIntBeforeSlash(vmOption.substring("--enable-vm-service:".length()));
} else if (vmOption.startsWith("--observe:")) {
customObservatoryPort = parseIntBeforeSlash(vmOption.substring("--observe:".length()));
}
} catch (NumberFormatException ignore) {
/**/
}
}
}
if (myRunnerParameters.isCheckedMode()) {
commandLine.addParameter(DartiumUtil.CHECKED_MODE_OPTION);
}
final VirtualFile dartFile;
try {
dartFile = myRunnerParameters.getDartFileOrDirectory();
} catch (RuntimeConfigurationError e) {
throw new ExecutionException(e);
}
if (DefaultDebugExecutor.EXECUTOR_ID.equals(getEnvironment().getExecutor().getId())) {
commandLine.addParameter("--pause_isolates_on_start");
}
if (customObservatoryPort > 0) {
myObservatoryPort = customObservatoryPort;
} else {
try {
myObservatoryPort = NetUtils.findAvailableSocketPort();
} catch (IOException e) {
throw new ExecutionException(e);
}
commandLine.addParameter("--enable-vm-service:" + myObservatoryPort);
if (getEnvironment().getRunner() instanceof DartCoverageProgramRunner) {
commandLine.addParameter("--pause-isolates-on-exit");
}
}
commandLine.addParameter(FileUtil.toSystemDependentName(overriddenMainFilePath == null ? dartFile.getPath() : overriddenMainFilePath));
final String arguments = myRunnerParameters.getArguments();
if (arguments != null) {
StringTokenizer argumentsTokenizer = new CommandLineTokenizer(arguments);
while (argumentsTokenizer.hasMoreTokens()) {
commandLine.addParameter(argumentsTokenizer.nextToken());
}
}
}
Aggregations