Search in sources :

Example 1 with DartRunConfiguration

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

the class DartCommandLineRunningState method doStartProcess.

protected ProcessHandler doStartProcess(@Nullable final String overriddenMainFilePath) throws ExecutionException {
    final GeneralCommandLine commandLine = createCommandLine(overriddenMainFilePath);
    // Workaround for "Observatory listening on ..." message that is concatenated (without line break) with the message following it
    final OSProcessHandler processHandler = new ColoredProcessHandler(commandLine) {

        @Override
        public void coloredTextAvailable(@NotNull String text, @NotNull Key attributes) {
            if (text.startsWith(DartConsoleFilter.OBSERVATORY_LISTENING_ON)) {
                text += "\n";
            }
            super.coloredTextAvailable(text, attributes);
        }
    };
    processHandler.addProcessListener(new ProcessAdapter() {

        @Override
        public void onTextAvailable(final ProcessEvent event, final Key outputType) {
            final String prefix = DartConsoleFilter.OBSERVATORY_LISTENING_ON + "http://";
            final String text = event.getText().trim();
            if (text.startsWith(prefix)) {
                processHandler.removeProcessListener(this);
                final String url = "http://" + text.substring(prefix.length());
                for (Consumer<String> consumer : myObservatoryUrlConsumers) {
                    consumer.consume(url);
                }
            }
        }
    });
    // Check for and display any analysis errors when we launch a Dart app.
    final Project project = getEnvironment().getProject();
    try {
        final DartRunConfiguration dartRunConfiguration = (DartRunConfiguration) getEnvironment().getRunProfile();
        final VirtualFile launchFile = dartRunConfiguration.getRunnerParameters().getDartFileOrDirectory();
        String launchTitle = "Analysis issues with " + dartRunConfiguration.getName();
        DartExecutionHelper.displayIssues(project, launchFile, launchTitle, dartRunConfiguration.getIcon());
    } catch (RuntimeConfigurationError error) {
        DartExecutionHelper.clearIssueNotifications(project);
    }
    ProcessTerminatedListener.attach(processHandler, getEnvironment().getProject());
    return processHandler;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) NotNull(org.jetbrains.annotations.NotNull) Project(com.intellij.openapi.project.Project) DartRunConfiguration(com.jetbrains.lang.dart.ide.runner.base.DartRunConfiguration) Consumer(com.intellij.util.Consumer) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) Key(com.intellij.openapi.util.Key)

Example 2 with DartRunConfiguration

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

the class DartTestRunningState method createConsole.

private static ConsoleView createConsole(@NotNull ExecutionEnvironment env) {
    final Project project = env.getProject();
    final DartRunConfiguration runConfiguration = (DartRunConfiguration) env.getRunProfile();
    final DartTestRunnerParameters runnerParameters = (DartTestRunnerParameters) runConfiguration.getRunnerParameters();
    final TestConsoleProperties testConsoleProperties = new DartConsoleProperties(runConfiguration, env);
    final ConsoleView consoleView = SMTestRunnerConnectionUtil.createConsole(DART_FRAMEWORK_NAME, testConsoleProperties);
    try {
        final VirtualFile dartFile = runnerParameters.getDartFileOrDirectory();
        consoleView.addMessageFilter(new DartConsoleFilter(project, dartFile));
        consoleView.addMessageFilter(new DartRelativePathsConsoleFilter(project, runnerParameters.computeProcessWorkingDirectory(project)));
        consoleView.addMessageFilter(new UrlFilter());
    } catch (RuntimeConfigurationError ignore) {
    /* can't happen because already checked */
    }
    Disposer.register(project, consoleView);
    return consoleView;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DartRelativePathsConsoleFilter(com.jetbrains.lang.dart.ide.runner.DartRelativePathsConsoleFilter) Project(com.intellij.openapi.project.Project) DartRunConfiguration(com.jetbrains.lang.dart.ide.runner.base.DartRunConfiguration) SMTRunnerConsoleView(com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView) ConsoleView(com.intellij.execution.ui.ConsoleView) DartConsoleFilter(com.jetbrains.lang.dart.ide.runner.DartConsoleFilter) UrlFilter(com.intellij.execution.filters.UrlFilter) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) TestConsoleProperties(com.intellij.execution.testframework.TestConsoleProperties)

Aggregations

RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)2 Project (com.intellij.openapi.project.Project)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 DartRunConfiguration (com.jetbrains.lang.dart.ide.runner.base.DartRunConfiguration)2 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)1 UrlFilter (com.intellij.execution.filters.UrlFilter)1 TestConsoleProperties (com.intellij.execution.testframework.TestConsoleProperties)1 SMTRunnerConsoleView (com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView)1 ConsoleView (com.intellij.execution.ui.ConsoleView)1 Key (com.intellij.openapi.util.Key)1 Consumer (com.intellij.util.Consumer)1 DartConsoleFilter (com.jetbrains.lang.dart.ide.runner.DartConsoleFilter)1 DartRelativePathsConsoleFilter (com.jetbrains.lang.dart.ide.runner.DartRelativePathsConsoleFilter)1 NotNull (org.jetbrains.annotations.NotNull)1