@NotNull @Override public ExecutionConsole createConsole() { ExecutionConsole console = myJavaSession.getProcess().getExecutionResult().getExecutionConsole(); if (console != null) return console; return super.createConsole(); }
private void saveNodeHistory(final StackFrameProxyImpl frameProxy) { myJavaSession .getProcess() .getManagerThread() .invoke( new DebuggerCommandImpl() { @Override protected void action() throws Exception { myNodeManager.setHistoryByContext(frameProxy); } @Override public Priority getPriority() { return Priority.NORMAL; } }); }
protected JavaDebugProcess( @NotNull final XDebugSession session, final DebuggerSession javaSession) { super(session); myJavaSession = javaSession; myEditorsProvider = new JavaDebuggerEditorsProvider(); final DebugProcessImpl process = javaSession.getProcess(); List<XBreakpointHandler> handlers = new ArrayList<XBreakpointHandler>(); handlers.add(new JavaBreakpointHandler.JavaLineBreakpointHandler(process)); handlers.add(new JavaBreakpointHandler.JavaExceptionBreakpointHandler(process)); handlers.add(new JavaBreakpointHandler.JavaFieldBreakpointHandler(process)); handlers.add(new JavaBreakpointHandler.JavaMethodBreakpointHandler(process)); handlers.add(new JavaBreakpointHandler.JavaWildcardBreakpointHandler(process)); for (JavaBreakpointHandlerFactory factory : Extensions.getExtensions(JavaBreakpointHandlerFactory.EP_NAME)) { handlers.add(factory.createHandler(process)); } myBreakpointHandlers = handlers.toArray(new XBreakpointHandler[handlers.size()]); myJavaSession .getContextManager() .addListener( new DebuggerContextListener() { @Override public void changeEvent( @NotNull final DebuggerContextImpl newContext, DebuggerSession.Event event) { if (event == DebuggerSession.Event.PAUSE || event == DebuggerSession.Event.CONTEXT || event == DebuggerSession.Event.REFRESH && myJavaSession.isPaused()) { final SuspendContextImpl newSuspendContext = newContext.getSuspendContext(); if (newSuspendContext != null && shouldApplyContext(newContext)) { process .getManagerThread() .schedule( new SuspendContextCommandImpl(newSuspendContext) { @Override public void contextAction() throws Exception { newSuspendContext.initExecutionStacks(newContext.getThreadProxy()); List<Pair<Breakpoint, Event>> descriptors = DebuggerUtilsEx.getEventDescriptors(newSuspendContext); if (!descriptors.isEmpty()) { Breakpoint breakpoint = descriptors.get(0).getFirst(); XBreakpoint xBreakpoint = breakpoint.getXBreakpoint(); if (xBreakpoint != null) { ((XDebugSessionImpl) getSession()) .breakpointReachedNoProcessing( xBreakpoint, newSuspendContext); unsetPausedIfNeeded(newContext); return; } } getSession().positionReached(newSuspendContext); unsetPausedIfNeeded(newContext); } }); } } else if (event == DebuggerSession.Event.ATTACHED) { getSession().rebuildViews(); // to refresh variables views message } } }); myNodeManager = new NodeManagerImpl(session.getProject(), null) { @Override public DebuggerTreeNodeImpl createNode( final NodeDescriptor descriptor, EvaluationContext evaluationContext) { return new DebuggerTreeNodeImpl(null, descriptor); } @Override public DebuggerTreeNodeImpl createMessageNode(MessageDescriptor descriptor) { return new DebuggerTreeNodeImpl(null, descriptor); } @Override public DebuggerTreeNodeImpl createMessageNode(String message) { return new DebuggerTreeNodeImpl(null, new MessageDescriptor(message)); } }; session.addSessionListener( new XDebugSessionAdapter() { @Override public void sessionPaused() { saveNodeHistory(); showAlternativeNotification(session.getCurrentStackFrame()); } @Override public void stackFrameChanged() { XStackFrame frame = session.getCurrentStackFrame(); if (frame instanceof JavaStackFrame) { showAlternativeNotification(frame); StackFrameProxyImpl frameProxy = ((JavaStackFrame) frame).getStackFrameProxy(); DebuggerContextUtil.setStackFrame(javaSession.getContextManager(), frameProxy); saveNodeHistory(frameProxy); } } private void showAlternativeNotification(@Nullable XStackFrame frame) { if (frame != null) { XSourcePosition position = frame.getSourcePosition(); if (position != null) { VirtualFile file = position.getFile(); if (!AlternativeSourceNotificationProvider.fileProcessed(file)) { EditorNotifications.getInstance(session.getProject()).updateNotifications(file); } } } } }); }
public static JavaDebugProcess create( @NotNull final XDebugSession session, final DebuggerSession javaSession) { JavaDebugProcess res = new JavaDebugProcess(session, javaSession); javaSession.getProcess().setXDebugProcess(res); return res; }
@Override public String getCurrentStateMessage() { String description = myJavaSession.getStateDescription(); return description != null ? description : super.getCurrentStateMessage(); }
@Nullable @Override protected ProcessHandler doGetProcessHandler() { return myJavaSession.getProcess().getProcessHandler(); }
@Override public void runToPosition(@NotNull XSourcePosition position) { myJavaSession.runToCursor(position, false); }
@Override public void resume() { myJavaSession.resume(); }
@Override public void startPausing() { myJavaSession.pause(); }
@Override public void stop() { myJavaSession.dispose(); myNodeManager.dispose(); }
@Override public void startStepOut() { myJavaSession.stepOut(); }
@Override public void startForceStepInto() { myJavaSession.stepInto(true, null); }
@Override public void startStepInto() { myJavaSession.stepInto(false, null); }
@Override public void startStepOver() { myJavaSession.stepOver(false); }
private DebuggerStateManager getDebuggerStateManager() { return myJavaSession.getContextManager(); }