Search in sources :

Example 1 with JavaScriptDebugEngine

use of com.intellij.javascript.debugger.JavaScriptDebugEngine in project intellij-plugins by JetBrains.

the class KarmaDebugProgramRunner method createDescriptor.

@NotNull
private static RunContentDescriptor createDescriptor(@NotNull ExecutionEnvironment environment, @NotNull ExecutionResult executionResult, @NotNull KarmaConsoleView consoleView, @NotNull KarmaServer karmaServer, @NotNull DebuggableWebBrowser debuggableWebBrowser) throws ExecutionException {
    Url url = Urls.newFromEncoded(karmaServer.formatUrl("/"));
    DebuggableFileFinder fileFinder = getDebuggableFileFinder(karmaServer);
    XDebugSession session = XDebuggerManager.getInstance(environment.getProject()).startSession(environment, new XDebugProcessStarter() {

        @Override
        @NotNull
        public XDebugProcess start(@NotNull XDebugSession session) {
            JavaScriptDebugEngine debugEngine = debuggableWebBrowser.getDebugEngine();
            WebBrowser browser = debuggableWebBrowser.getWebBrowser();
            JavaScriptDebugProcess<? extends VmConnection> debugProcess = debugEngine.createDebugProcess(session, browser, fileFinder, url, executionResult, true);
            debugProcess.addFirstLineBreakpointPattern("\\.browserify$");
            debugProcess.setElementsInspectorEnabled(false);
            debugProcess.setConsoleMessagesSupportEnabled(false);
            debugProcess.setLayouter(consoleView.createDebugLayouter(debugProcess));
            Alarm alarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, consoleView);
            alarm.addRequest(() -> {
                resumeTestRunning(executionResult.getProcessHandler());
                Disposer.dispose(alarm);
            }, 2000);
            return debugProcess;
        }
    });
    return session.getRunContentDescriptor();
}
Also used : JavaScriptDebugProcess(com.intellij.javascript.debugger.JavaScriptDebugProcess) XDebugSession(com.intellij.xdebugger.XDebugSession) VmConnection(org.jetbrains.debugger.connection.VmConnection) XDebugProcess(com.intellij.xdebugger.XDebugProcess) WebBrowser(com.intellij.ide.browsers.WebBrowser) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter) Alarm(com.intellij.util.Alarm) NotNull(org.jetbrains.annotations.NotNull) Url(com.intellij.util.Url) DebuggableFileFinder(com.intellij.javascript.debugger.DebuggableFileFinder) JavaScriptDebugEngine(com.intellij.javascript.debugger.JavaScriptDebugEngine) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with JavaScriptDebugEngine

use of com.intellij.javascript.debugger.JavaScriptDebugEngine in project intellij-plugins by JetBrains.

the class JstdDebugBrowserInfo method build.

@Nullable
public static JstdDebugBrowserInfo build(@NotNull JstdServer server, @NotNull JstdRunSettings runSettings) {
    Collection<JstdBrowserInfo> capturedBrowsers = server.getCapturedBrowsers();
    List<JstdDebugBrowserInfo> debugBrowserInfos = new SmartList<>();
    for (JstdBrowserInfo browserInfo : capturedBrowsers) {
        Pair<JavaScriptDebugEngine, WebBrowser> engine = JavaScriptDebugEngine.Companion.findByBrowserIdOrName(browserInfo.getName());
        if (engine != null) {
            debugBrowserInfos.add(new JstdDebugBrowserInfo(engine, server.getSettings(), browserInfo));
        }
    }
    if (debugBrowserInfos.size() == 1) {
        return debugBrowserInfos.get(0);
    }
    if (debugBrowserInfos.size() > 1) {
        WebBrowser preferredBrowser = runSettings.getPreferredDebugBrowser();
        for (JstdDebugBrowserInfo info : debugBrowserInfos) {
            if (preferredBrowser.equals(info.getBrowser())) {
                return info;
            }
        }
    }
    return null;
}
Also used : WebBrowser(com.intellij.ide.browsers.WebBrowser) SmartList(com.intellij.util.SmartList) JstdBrowserInfo(com.google.jstestdriver.idea.server.JstdBrowserInfo) JavaScriptDebugEngine(com.intellij.javascript.debugger.JavaScriptDebugEngine) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

WebBrowser (com.intellij.ide.browsers.WebBrowser)2 JavaScriptDebugEngine (com.intellij.javascript.debugger.JavaScriptDebugEngine)2 JstdBrowserInfo (com.google.jstestdriver.idea.server.JstdBrowserInfo)1 DebuggableFileFinder (com.intellij.javascript.debugger.DebuggableFileFinder)1 JavaScriptDebugProcess (com.intellij.javascript.debugger.JavaScriptDebugProcess)1 Alarm (com.intellij.util.Alarm)1 SmartList (com.intellij.util.SmartList)1 Url (com.intellij.util.Url)1 XDebugProcess (com.intellij.xdebugger.XDebugProcess)1 XDebugProcessStarter (com.intellij.xdebugger.XDebugProcessStarter)1 XDebugSession (com.intellij.xdebugger.XDebugSession)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1 VmConnection (org.jetbrains.debugger.connection.VmConnection)1