Java Code Examples for com.intellij.xdebugger.XDebugSession#getCurrentStackFrame()

The following examples show how to use com.intellij.xdebugger.XDebugSession#getCurrentStackFrame() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlutterPopFrameAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Nullable
private static DartVmServiceStackFrame getStackFrame(@NotNull final AnActionEvent e) {
  final Project project = e.getProject();
  if (project == null) return null;

  XDebugSession session = e.getData(XDebugSession.DATA_KEY);

  if (session == null) {
    session = XDebuggerManager.getInstance(project).getCurrentSession();
  }

  if (session != null) {
    final XStackFrame frame = session.getCurrentStackFrame();
    if (frame instanceof DartVmServiceStackFrame) {
      return ((DartVmServiceStackFrame)frame);
    }
  }

  return null;
}
 
Example 2
Source File: FlutterPopFrameAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Nullable
private static DartVmServiceStackFrame getStackFrame(@NotNull final AnActionEvent e) {
  final Project project = e.getProject();
  if (project == null) return null;

  XDebugSession session = e.getData(XDebugSession.DATA_KEY);

  if (session == null) {
    session = XDebuggerManager.getInstance(project).getCurrentSession();
  }

  if (session != null) {
    final XStackFrame frame = session.getCurrentStackFrame();
    if (frame instanceof DartVmServiceStackFrame) {
      return ((DartVmServiceStackFrame)frame);
    }
  }

  return null;
}
 
Example 3
Source File: XVariablesView.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void processSessionEvent(@Nonnull SessionEvent event, @Nonnull XDebugSession session) {
  if (ApplicationManager.getApplication().isDispatchThread()) { // mark nodes obsolete asap
    getTree().markNodesObsolete();
  }

  XStackFrame stackFrame = session.getCurrentStackFrame();
  DebuggerUIUtil.invokeLater(() -> {
    XDebuggerTree tree = getTree();

    if (event == SessionEvent.BEFORE_RESUME || event == SessionEvent.SETTINGS_CHANGED) {
      saveCurrentTreeState(stackFrame);
      if (event == SessionEvent.BEFORE_RESUME) {
        return;
      }
    }

    tree.markNodesObsolete();
    if (stackFrame != null) {
      cancelClear();
      buildTreeAndRestoreState(stackFrame);
    }
    else {
      requestClear();
    }
  });
}
 
Example 4
Source File: XFramesView.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void processFrameSelection(XDebugSession session, boolean force) {
  mySelectedFrameIndex = myFramesList.getSelectedIndex();
  myExecutionStacksWithSelection.put(mySelectedStack, mySelectedFrameIndex);

  Object selected = myFramesList.getSelectedValue();
  if (selected instanceof XStackFrame) {
    if (session != null) {
      if (force || (!myRefresh && session.getCurrentStackFrame() != selected)) {
        session.setCurrentStackFrame(mySelectedStack, (XStackFrame)selected, mySelectedFrameIndex == 0);
      }
    }
  }
}
 
Example 5
Source File: XFramesView.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void processSessionEvent(@Nonnull SessionEvent event, @Nonnull XDebugSession session) {
  myRefresh = event == SessionEvent.SETTINGS_CHANGED;

  if (event == SessionEvent.BEFORE_RESUME) {
    return;
  }

  XExecutionStack currentExecutionStack = ((XDebugSessionImpl)session).getCurrentExecutionStack();
  XStackFrame currentStackFrame = session.getCurrentStackFrame();
  XSuspendContext suspendContext = session.getSuspendContext();

  if (event == SessionEvent.FRAME_CHANGED && Objects.equals(mySelectedStack, currentExecutionStack)) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    if (currentStackFrame != null) {
      myFramesList.setSelectedValue(currentStackFrame, true);
      mySelectedFrameIndex = myFramesList.getSelectedIndex();
      myExecutionStacksWithSelection.put(mySelectedStack, mySelectedFrameIndex);
    }
    return;
  }

  EdtExecutorService.getInstance().execute(() -> {
    if (event != SessionEvent.SETTINGS_CHANGED) {
      mySelectedFrameIndex = 0;
      mySelectedStack = null;
      myVisibleRect = null;
    }
    else {
      myVisibleRect = myFramesList.getVisibleRect();
    }

    myListenersEnabled = false;
    myBuilders.values().forEach(StackFramesListBuilder::dispose);
    myBuilders.clear();

    if (suspendContext == null) {
      requestClear();
      return;
    }

    if (event == SessionEvent.PAUSED) {
      // clear immediately
      cancelClear();
      clear();
    }

    XExecutionStack activeExecutionStack = mySelectedStack != null ? mySelectedStack : currentExecutionStack;
    addExecutionStacks(Collections.singletonList(activeExecutionStack));

    XExecutionStack[] executionStacks = suspendContext.getExecutionStacks();
    addExecutionStacks(Arrays.asList(executionStacks));

    myThreadComboBox.setSelectedItem(activeExecutionStack);
    myThreadsPanel.removeAll();
    myThreadsPanel.add(myToolbar.getComponent(), BorderLayout.EAST);
    final boolean invisible = executionStacks.length == 1 && StringUtil.isEmpty(executionStacks[0].getDisplayName());
    if (!invisible) {
      myThreadsPanel.add(myThreadComboBox, BorderLayout.CENTER);
    }
    updateFrames(activeExecutionStack, session, event == SessionEvent.FRAME_CHANGED ? currentStackFrame : null);
  });
}