Search in sources :

Example 16 with DebuggerSession

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

the class HotSwapAction method update.

public void update(AnActionEvent e) {
    Project project = e.getProject();
    if (project == null) {
        e.getPresentation().setEnabled(false);
        return;
    }
    DebuggerManagerEx debuggerManager = DebuggerManagerEx.getInstanceEx(project);
    DebuggerSession session = debuggerManager.getContext().getDebuggerSession();
    e.getPresentation().setEnabled(session != null && HotSwapUIImpl.canHotSwap(session));
}
Also used : Project(com.intellij.openapi.project.Project) DebuggerManagerEx(com.intellij.debugger.DebuggerManagerEx) DebuggerSession(com.intellij.debugger.impl.DebuggerSession)

Example 17 with DebuggerSession

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

the class HotSwapAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    Project project = e.getProject();
    DebuggerManagerEx debuggerManager = DebuggerManagerEx.getInstanceEx(project);
    DebuggerSession session = debuggerManager.getContext().getDebuggerSession();
    if (session != null && session.isAttached()) {
        HotSwapUI.getInstance(project).reloadChangedClasses(session, DebuggerSettings.getInstance().COMPILE_BEFORE_HOTSWAP);
    }
}
Also used : Project(com.intellij.openapi.project.Project) DebuggerManagerEx(com.intellij.debugger.DebuggerManagerEx) DebuggerSession(com.intellij.debugger.impl.DebuggerSession)

Example 18 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 19 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 20 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)25 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)11 Project (com.intellij.openapi.project.Project)9 XDebugSession (com.intellij.xdebugger.XDebugSession)6 DebuggerManagerEx (com.intellij.debugger.DebuggerManagerEx)4 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)4 Nullable (org.jetbrains.annotations.Nullable)4 SourcePosition (com.intellij.debugger.SourcePosition)3 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)3 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)3 DebugEnvironment (com.intellij.debugger.DebugEnvironment)2 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)2 DebuggerTree (com.intellij.debugger.ui.impl.watch.DebuggerTree)2 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)2 NodeDescriptorImpl (com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)2 WatchItemDescriptor (com.intellij.debugger.ui.impl.watch.WatchItemDescriptor)2 Presentation (com.intellij.openapi.actionSystem.Presentation)2 Ref (com.intellij.openapi.util.Ref)2 XDebugProcess (com.intellij.xdebugger.XDebugProcess)2 XDebugProcessStarter (com.intellij.xdebugger.XDebugProcessStarter)2