Search in sources :

Example 1 with DartCoverageProgramRunner

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());
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) IOException(java.io.IOException) ExecutionException(com.intellij.execution.ExecutionException) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) DartCoverageProgramRunner(com.jetbrains.lang.dart.coverage.DartCoverageProgramRunner) CommandLineTokenizer(com.intellij.execution.configurations.CommandLineTokenizer)

Aggregations

ExecutionException (com.intellij.execution.ExecutionException)1 CommandLineTokenizer (com.intellij.execution.configurations.CommandLineTokenizer)1 RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 DartCoverageProgramRunner (com.jetbrains.lang.dart.coverage.DartCoverageProgramRunner)1 IOException (java.io.IOException)1