Search in sources :

Example 31 with DebuggerSession

use of com.intellij.debugger.impl.DebuggerSession in project intellij-community by JetBrains.

the class JavaWithRuntimeCastSurrounder method surroundExpression.

public TextRange surroundExpression(Project project, Editor editor, PsiExpression expr) throws IncorrectOperationException {
    DebuggerContextImpl debuggerContext = (DebuggerManagerEx.getInstanceEx(project)).getContext();
    DebuggerSession debuggerSession = debuggerContext.getDebuggerSession();
    if (debuggerSession != null) {
        final ProgressWindowWithNotification progressWindow = new ProgressWindowWithNotification(true, expr.getProject());
        SurroundWithCastWorker worker = new SurroundWithCastWorker(editor, expr, debuggerContext, progressWindow);
        progressWindow.setTitle(DebuggerBundle.message("title.evaluating"));
        debuggerContext.getDebugProcess().getManagerThread().startProgress(worker, progressWindow);
    }
    return null;
}
Also used : DebuggerSession(com.intellij.debugger.impl.DebuggerSession) ProgressWindowWithNotification(com.intellij.openapi.progress.util.ProgressWindowWithNotification) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl)

Example 32 with DebuggerSession

use of com.intellij.debugger.impl.DebuggerSession in project intellij-community by JetBrains.

the class JavaStackFrame method customizePresentation.

@Override
public void customizePresentation(@NotNull ColoredTextContainer component) {
    StackFrameDescriptorImpl selectedDescriptor = null;
    DebuggerSession session = myDebugProcess.getSession();
    if (session != null) {
        XDebugSession xSession = session.getXDebugSession();
        if (xSession != null) {
            XStackFrame frame = xSession.getCurrentStackFrame();
            if (frame instanceof JavaStackFrame) {
                selectedDescriptor = ((JavaStackFrame) frame).getDescriptor();
            }
        }
    }
    FRAME_RENDERER.customizePresentation(myDescriptor, component, selectedDescriptor);
    if (myInsertCapturePoint != null) {
        component.setIcon(XDebuggerUIConstants.INFORMATION_MESSAGE_ICON);
    }
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) DebuggerSession(com.intellij.debugger.impl.DebuggerSession)

Example 33 with DebuggerSession

use of com.intellij.debugger.impl.DebuggerSession in project intellij-community by JetBrains.

the class DebuggerTree method buildWhenPaused.

protected final void buildWhenPaused(DebuggerContextImpl context, RefreshDebuggerTreeCommand command) {
    DebuggerSession session = context.getDebuggerSession();
    if (ApplicationManager.getApplication().isUnitTestMode() || (session != null && session.getState() == DebuggerSession.State.PAUSED)) {
        showMessage(MessageDescriptor.EVALUATING);
        context.getDebugProcess().getManagerThread().schedule(command);
    } else {
        showMessage(session != null ? session.getStateDescription() : DebuggerBundle.message("status.debug.stopped"));
        if (session == null || session.isStopped()) {
            // save memory by clearing references on JDI objects
            getNodeFactory().clearHistory();
        }
    }
}
Also used : DebuggerSession(com.intellij.debugger.impl.DebuggerSession)

Example 34 with DebuggerSession

use of com.intellij.debugger.impl.DebuggerSession in project intellij-community by JetBrains.

the class HotSwapUIImpl method hotSwapSessions.

private void hotSwapSessions(final List<DebuggerSession> sessions, @Nullable final Map<String, List<String>> generatedPaths) {
    final boolean shouldAskBeforeHotswap = myAskBeforeHotswap;
    myAskBeforeHotswap = true;
    final DebuggerSettings settings = DebuggerSettings.getInstance();
    final String runHotswap = settings.RUN_HOTSWAP_AFTER_COMPILE;
    final boolean shouldDisplayHangWarning = shouldDisplayHangWarning(settings, sessions);
    if (shouldAskBeforeHotswap && DebuggerSettings.RUN_HOTSWAP_NEVER.equals(runHotswap)) {
        return;
    }
    final boolean shouldPerformScan = generatedPaths == null;
    final HotSwapProgressImpl findClassesProgress;
    if (shouldPerformScan) {
        findClassesProgress = new HotSwapProgressImpl(myProject);
    } else {
        boolean createProgress = false;
        for (DebuggerSession session : sessions) {
            if (session.isModifiedClassesScanRequired()) {
                createProgress = true;
                break;
            }
        }
        findClassesProgress = createProgress ? new HotSwapProgressImpl(myProject) : null;
    }
    ApplicationManager.getApplication().executeOnPooledThread(() -> {
        final Map<DebuggerSession, Map<String, HotSwapFile>> modifiedClasses;
        if (shouldPerformScan) {
            modifiedClasses = scanForModifiedClassesWithProgress(sessions, findClassesProgress);
        } else {
            final List<DebuggerSession> toScan = new ArrayList<>();
            final List<DebuggerSession> toUseGenerated = new ArrayList<>();
            for (DebuggerSession session : sessions) {
                (session.isModifiedClassesScanRequired() ? toScan : toUseGenerated).add(session);
                session.setModifiedClassesScanRequired(false);
            }
            modifiedClasses = new HashMap<>();
            if (!toUseGenerated.isEmpty()) {
                modifiedClasses.putAll(HotSwapManager.findModifiedClasses(toUseGenerated, generatedPaths));
            }
            if (!toScan.isEmpty()) {
                modifiedClasses.putAll(scanForModifiedClassesWithProgress(toScan, findClassesProgress));
            }
        }
        final Application application = ApplicationManager.getApplication();
        if (modifiedClasses.isEmpty()) {
            final String message = DebuggerBundle.message("status.hotswap.uptodate");
            HotSwapProgressImpl.NOTIFICATION_GROUP.createNotification(message, NotificationType.INFORMATION).notify(myProject);
            return;
        }
        application.invokeLater(() -> {
            if (shouldAskBeforeHotswap && !DebuggerSettings.RUN_HOTSWAP_ALWAYS.equals(runHotswap)) {
                final RunHotswapDialog dialog = new RunHotswapDialog(myProject, sessions, shouldDisplayHangWarning);
                if (!dialog.showAndGet()) {
                    for (DebuggerSession session : modifiedClasses.keySet()) {
                        session.setModifiedClassesScanRequired(true);
                    }
                    return;
                }
                final Set<DebuggerSession> toReload = new HashSet<>(dialog.getSessionsToReload());
                for (DebuggerSession session : modifiedClasses.keySet()) {
                    if (!toReload.contains(session)) {
                        session.setModifiedClassesScanRequired(true);
                    }
                }
                modifiedClasses.keySet().retainAll(toReload);
            } else {
                if (shouldDisplayHangWarning) {
                    final int answer = Messages.showCheckboxMessageDialog(DebuggerBundle.message("hotswap.dialog.hang.warning"), DebuggerBundle.message("hotswap.dialog.title"), new String[] { "Perform &Reload Classes", "&Skip Reload Classes" }, CommonBundle.message("dialog.options.do.not.show"), false, 1, 1, Messages.getWarningIcon(), (exitCode, cb) -> {
                        settings.HOTSWAP_HANG_WARNING_ENABLED = !cb.isSelected();
                        return exitCode == DialogWrapper.OK_EXIT_CODE ? exitCode : DialogWrapper.CANCEL_EXIT_CODE;
                    });
                    if (answer == DialogWrapper.CANCEL_EXIT_CODE) {
                        for (DebuggerSession session : modifiedClasses.keySet()) {
                            session.setModifiedClassesScanRequired(true);
                        }
                        return;
                    }
                }
            }
            if (!modifiedClasses.isEmpty()) {
                final HotSwapProgressImpl progress = new HotSwapProgressImpl(myProject);
                if (modifiedClasses.keySet().size() == 1) {
                    //noinspection ConstantConditions
                    progress.setSessionForActions(ContainerUtil.getFirstItem(modifiedClasses.keySet()));
                }
                application.executeOnPooledThread(() -> reloadModifiedClasses(modifiedClasses, progress));
            }
        }, ModalityState.NON_MODAL);
    });
}
Also used : DebuggerSettings(com.intellij.debugger.settings.DebuggerSettings) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) Application(com.intellij.openapi.application.Application) THashSet(gnu.trove.THashSet)

Example 35 with DebuggerSession

use of com.intellij.debugger.impl.DebuggerSession in project intellij-community by JetBrains.

the class ThreadDumpAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    final Project project = e.getProject();
    if (project == null) {
        return;
    }
    DebuggerContextImpl context = (DebuggerManagerEx.getInstanceEx(project)).getContext();
    final DebuggerSession session = context.getDebuggerSession();
    if (session != null && session.isAttached()) {
        final DebugProcessImpl process = context.getDebugProcess();
        process.getManagerThread().invoke(new DebuggerCommandImpl() {

            protected void action() throws Exception {
                final VirtualMachineProxyImpl vm = process.getVirtualMachineProxy();
                vm.suspend();
                try {
                    final List<ThreadState> threads = buildThreadStates(vm);
                    ApplicationManager.getApplication().invokeLater(() -> {
                        XDebugSession xSession = session.getXDebugSession();
                        if (xSession != null) {
                            DebuggerUtilsEx.addThreadDump(project, threads, xSession.getUI(), session);
                        }
                    }, ModalityState.NON_MODAL);
                } finally {
                    vm.resume();
                }
            }
        });
    }
}
Also used : Project(com.intellij.openapi.project.Project) XDebugSession(com.intellij.xdebugger.XDebugSession) VirtualMachineProxyImpl(com.intellij.debugger.jdi.VirtualMachineProxyImpl) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) ArrayList(java.util.ArrayList) List(java.util.List) SmartList(com.intellij.util.SmartList) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl)

Aggregations

DebuggerSession (com.intellij.debugger.impl.DebuggerSession)51 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)19 Project (com.intellij.openapi.project.Project)17 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)13 XDebugSession (com.intellij.xdebugger.XDebugSession)13 DebuggerManagerEx (com.intellij.debugger.DebuggerManagerEx)9 Nullable (org.jetbrains.annotations.Nullable)8 DebugEnvironment (com.intellij.debugger.DebugEnvironment)7 XDebugProcessStarter (com.intellij.xdebugger.XDebugProcessStarter)7 SourcePosition (com.intellij.debugger.SourcePosition)5 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)5 XDebugProcess (com.intellij.xdebugger.XDebugProcess)5 NotNull (org.jetbrains.annotations.NotNull)5 DefaultDebugEnvironment (com.intellij.debugger.DefaultDebugEnvironment)4 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)4 DebuggerTree (com.intellij.debugger.ui.impl.watch.DebuggerTree)4 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)4 NodeDescriptorImpl (com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)4 DefaultExecutionResult (com.intellij.execution.DefaultExecutionResult)4 ExecutionResult (com.intellij.execution.ExecutionResult)4