Search in sources :

Example 1 with KarmaConsoleView

use of com.intellij.javascript.karma.execution.KarmaConsoleView in project intellij-plugins by JetBrains.

the class KarmaDebugProgramRunner method execute.

@NotNull
@Override
protected Promise<RunContentDescriptor> execute(@NotNull ExecutionEnvironment environment, @NotNull RunProfileState state) throws ExecutionException {
    FileDocumentManager.getInstance().saveAllDocuments();
    ExecutionResult executionResult = state.execute(environment.getExecutor(), this);
    if (executionResult == null) {
        return Promise.resolve(null);
    }
    KarmaConsoleView consoleView = KarmaConsoleView.get(executionResult, state);
    if (consoleView == null) {
        return Promise.resolve(KarmaUtil.createDefaultDescriptor(executionResult, environment));
    }
    KarmaServer karmaServer = consoleView.getKarmaExecutionSession().getKarmaServer();
    if (karmaServer.areBrowsersReady()) {
        KarmaDebugBrowserSelector browserSelector = new KarmaDebugBrowserSelector(karmaServer.getCapturedBrowsers(), environment, consoleView);
        DebuggableWebBrowser debuggableWebBrowser = browserSelector.selectDebugEngine();
        if (debuggableWebBrowser == null) {
            return Promises.resolvedPromise(KarmaUtil.createDefaultDescriptor(executionResult, environment));
        }
        return KarmaKt.prepareKarmaDebugger(environment.getProject(), debuggableWebBrowser, () -> createDescriptor(environment, executionResult, consoleView, karmaServer, debuggableWebBrowser));
    } else {
        RunContentDescriptor descriptor = KarmaUtil.createDefaultDescriptor(executionResult, environment);
        karmaServer.onBrowsersReady(() -> ExecutionUtil.restartIfActive(descriptor));
        return Promises.resolvedPromise(descriptor);
    }
}
Also used : KarmaServer(com.intellij.javascript.karma.server.KarmaServer) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) KarmaConsoleView(com.intellij.javascript.karma.execution.KarmaConsoleView) ExecutionResult(com.intellij.execution.ExecutionResult) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with KarmaConsoleView

use of com.intellij.javascript.karma.execution.KarmaConsoleView in project intellij-plugins by JetBrains.

the class KarmaCoverageProgramRunner method doExecute.

@Override
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull final ExecutionEnvironment env) throws ExecutionException {
    FileDocumentManager.getInstance().saveAllDocuments();
    ExecutionResult executionResult = state.execute(env.getExecutor(), this);
    if (executionResult == null) {
        return null;
    }
    RunContentDescriptor descriptor = KarmaUtil.createDefaultDescriptor(executionResult, env);
    KarmaConsoleView consoleView = KarmaConsoleView.get(executionResult, state);
    if (consoleView == null) {
        return descriptor;
    }
    KarmaServer server = consoleView.getKarmaExecutionSession().getKarmaServer();
    if (server.areBrowsersReady()) {
        listenForCoverageFile(env, server);
    } else {
        server.onBrowsersReady(() -> ExecutionUtil.restartIfActive(descriptor));
    }
    return descriptor;
}
Also used : KarmaServer(com.intellij.javascript.karma.server.KarmaServer) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) KarmaConsoleView(com.intellij.javascript.karma.execution.KarmaConsoleView) ExecutionResult(com.intellij.execution.ExecutionResult)

Aggregations

ExecutionResult (com.intellij.execution.ExecutionResult)2 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)2 KarmaConsoleView (com.intellij.javascript.karma.execution.KarmaConsoleView)2 KarmaServer (com.intellij.javascript.karma.server.KarmaServer)2 NotNull (org.jetbrains.annotations.NotNull)1