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;
}
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);
}
}
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();
}
}
}
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);
});
}
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();
}
}
});
}
}
Aggregations