com.intellij.xdebugger.frame.XStackFrame Java Examples

The following examples show how to use com.intellij.xdebugger.frame.XStackFrame. 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: XVariablesViewBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected void buildTreeAndRestoreState(@Nonnull final XStackFrame stackFrame) {
  XSourcePosition position = stackFrame.getSourcePosition();
  XDebuggerTree tree = getTree();
  tree.setSourcePosition(position);
  createNewRootNode(stackFrame);
  final Project project = tree.getProject();
  project.putUserData(XVariablesView.DEBUG_VARIABLES, new XVariablesView.InlineVariablesInfo());
  project.putUserData(XVariablesView.DEBUG_VARIABLES_TIMESTAMPS, new ObjectLongHashMap<>());
  clearInlays(tree);
  Object newEqualityObject = stackFrame.getEqualityObject();
  if (myFrameEqualityObject != null && newEqualityObject != null && myFrameEqualityObject.equals(newEqualityObject) && myTreeState != null) {
    disposeTreeRestorer();
    myTreeRestorer = myTreeState.restoreState(tree);
  }
  if (position != null && XDebuggerSettingsManager.getInstance().getDataViewSettings().isValueTooltipAutoShowOnSelection()) {
    registerInlineEvaluator(stackFrame, position, project);
  }
}
 
Example #2
Source File: XDebuggerEvaluateActionHandler.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void showDialog(@Nonnull XDebugSession session,
                               VirtualFile file,
                               XDebuggerEditorsProvider editorsProvider,
                               XStackFrame stackFrame,
                               XDebuggerEvaluator evaluator,
                               @Nonnull XExpression expression) {
  if (expression.getLanguage() == null) {
    Language language = null;
    if (stackFrame != null) {
      XSourcePosition position = stackFrame.getSourcePosition();
      if (position != null) {
        language = LanguageUtil.getFileLanguage(position.getFile());
      }
    }
    if (language == null && file != null) {
      language = LanguageUtil.getFileTypeLanguage(file.getFileType());
    }
    expression = new XExpressionImpl(expression.getExpression(), language, expression.getCustomInfo(), expression.getMode());
  }
  new XDebuggerEvaluationDialog(session, editorsProvider, evaluator, expression, stackFrame == null ? null : stackFrame.getSourcePosition()).show();
}
 
Example #3
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 #4
Source File: XFramesView.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void addStackFrames(@Nonnull final List<? extends XStackFrame> stackFrames, @Nullable XStackFrame toSelect, final boolean last) {
  if (isObsolete()) return;
  EdtExecutorService.getInstance().execute(() -> {
    if (isObsolete()) return;
    myStackFrames.addAll(stackFrames);
    addFrameListElements(stackFrames, last);

    if (toSelect != null) {
      setToSelect(toSelect);
    }

    myNextFrameIndex += stackFrames.size();
    myAllFramesLoaded = last;

    selectCurrentFrame();

    if (last) {
      if (myVisibleRect != null) {
        myFramesList.scrollRectToVisible(myVisibleRect);
      }
      myRunning = false;
      myListenersEnabled = true;
    }
  });
}
 
Example #5
Source File: XFramesView.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void selectCurrentFrame() {
  if (myToSelect instanceof XStackFrame) {
    if (!Objects.equals(myFramesList.getSelectedValue(), myToSelect) && myFramesList.getModel().contains(myToSelect)) {
      myFramesList.setSelectedValue(myToSelect, true);
      processFrameSelection(mySession, false);
      myListenersEnabled = true;
    }
    if (myAllFramesLoaded && myFramesList.getSelectedValue() == null) {
      LOG.error("Frame was not found, " + myToSelect.getClass() + " must correctly override equals");
    }
  }
  else if (myToSelect instanceof Integer) {
    int selectedFrameIndex = (int)myToSelect;
    if (myFramesList.getSelectedIndex() != selectedFrameIndex &&
        myFramesList.getElementCount() > selectedFrameIndex &&
        myFramesList.getModel().get(selectedFrameIndex) != null) {
      myFramesList.setSelectedIndex(selectedFrameIndex);
      processFrameSelection(mySession, false);
      myListenersEnabled = true;
    }
  }
}
 
Example #6
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 #7
Source File: WatchesRootNode.java    From consulo with Apache License 2.0 6 votes vote down vote up
public WatchesRootNode(@Nonnull XDebuggerTree tree,
                       @Nonnull XWatchesView watchesView,
                       @Nonnull XExpression[] expressions,
                       @Nullable XStackFrame stackFrame,
                       boolean watchesInVariables) {
  super(tree, null, new XValueContainer() {
    @Override
    public void computeChildren(@Nonnull XCompositeNode node) {
      if (stackFrame != null && watchesInVariables) {
        stackFrame.computeChildren(node);
      }
      else {
        node.addChildren(XValueChildrenList.EMPTY, true);
      }
    }
  });
  setLeaf(false);
  myWatchesView = watchesView;
  myChildren = ContainerUtil.newArrayList();
  for (XExpression watchExpression : expressions) {
    myChildren.add(new WatchNodeImpl(myTree, this, watchExpression, stackFrame));
  }
}
 
Example #8
Source File: WatchesRootNode.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void addWatchExpression(@Nullable XStackFrame stackFrame,
                               @Nonnull XExpression expression,
                               int index,
                               boolean navigateToWatchNode) {
  WatchNodeImpl message = new WatchNodeImpl(myTree, this, expression, stackFrame);
  if (index == -1) {
    myChildren.add(message);
    index = myChildren.size() - 1;
  }
  else {
    myChildren.add(index, message);
  }
  fireNodeInserted(index);
  TreeUtil.selectNode(myTree, message);
  if (navigateToWatchNode) {
    myTree.scrollPathToVisible(message.getPath());
  }
}
 
Example #9
Source File: XDebuggerFramesList.java    From consulo with Apache License 2.0 6 votes vote down vote up
Color getFrameBgColor(XStackFrame stackFrame) {
  VirtualFile virtualFile = getFile(stackFrame);
  if (virtualFile != null) {
    // handle null value
    if (myFileColors.containsKey(virtualFile)) {
      return myFileColors.get(virtualFile);
    }
    else if (virtualFile.isValid()) {
      Color color = myColorsManager.getFileColor(virtualFile);
      myFileColors.put(virtualFile, color);
      return color;
    }
  }
  else {
    return myColorsManager.getScopeColor(NonProjectFilesScope.NAME);
  }
  return null;
}
 
Example #10
Source File: WatchesRootNode.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * @deprecated Use {@link #addWatchExpression(XStackFrame, XExpression, int, boolean)}
 */
@Deprecated
public void addWatchExpression(@Nullable XDebuggerEvaluator evaluator,
                               @Nonnull XExpression expression,
                               int index,
                               boolean navigateToWatchNode) {
  addWatchExpression((XStackFrame)null, expression, index, navigateToWatchNode);
}
 
Example #11
Source File: XVariablesViewBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void registerInlineEvaluator(final XStackFrame stackFrame, final XSourcePosition position, final Project project) {
  final VirtualFile file = position.getFile();
  final FileEditor fileEditor = FileEditorManagerEx.getInstanceEx(project).getSelectedEditor(file);
  if (fileEditor instanceof TextEditor) {
    final Editor editor = ((TextEditor)fileEditor).getEditor();
    removeSelectionListener();
    mySelectionListener = new MySelectionListener(editor, stackFrame, project);
    editor.getSelectionModel().addSelectionListener(mySelectionListener);
  }
}
 
Example #12
Source File: XVariablesViewBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected XValueContainerNode createNewRootNode(@Nullable XStackFrame stackFrame) {
  XValueContainerNode root;
  if (stackFrame == null) {
    root = new XValueContainerNode<XValueContainer>(getTree(), null, new XValueContainer() {
    }) {
    };
  }
  else {
    root = new XStackFrameNode(getTree(), stackFrame);
  }
  getTree().setRoot(root, false);
  return root;
}
 
Example #13
Source File: XDebugSessionImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void setCurrentStackFrame(@Nonnull XExecutionStack executionStack, @Nonnull XStackFrame frame, boolean isTopFrame) {
  if (mySuspendContext == null) return;

  boolean frameChanged = myCurrentStackFrame != frame;
  myCurrentExecutionStack = executionStack;
  myCurrentStackFrame = frame;
  myIsTopFrame = isTopFrame;
  activateSession();

  if (frameChanged) {
    myDispatcher.getMulticaster().stackFrameChanged();
  }
}
 
Example #14
Source File: XWatchesViewImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected XValueContainerNode createNewRootNode(@Nullable XStackFrame stackFrame) {
  WatchesRootNode node = new WatchesRootNode(getTree(), this, getExpressions(), stackFrame, myWatchesInVariables);
  myRootNode = node;
  getTree().setRoot(node, false);
  return node;
}
 
Example #15
Source File: XDebugSessionImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void showExecutionPoint() {
  if (mySuspendContext != null) {
    XExecutionStack executionStack = mySuspendContext.getActiveExecutionStack();
    if (executionStack != null) {
      XStackFrame topFrame = executionStack.getTopFrame();
      if (topFrame != null) {
        setCurrentStackFrame(executionStack, topFrame, true);
        myDebuggerManager.showExecutionPosition();
      }
    }
  }
}
 
Example #16
Source File: XVariablesViewBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected void saveCurrentTreeState(@Nullable XStackFrame stackFrame) {
  removeSelectionListener();
  myFrameEqualityObject = stackFrame != null ? stackFrame.getEqualityObject() : null;
  if (myTreeRestorer == null || myTreeRestorer.isFinished()) {
    myTreeState = XDebuggerTreeState.saveState(getTree());
  }
  disposeTreeRestorer();
}
 
Example #17
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 #18
Source File: XDebuggerUtilImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public static XDebuggerEvaluator getEvaluator(final XSuspendContext suspendContext) {
  XExecutionStack executionStack = suspendContext.getActiveExecutionStack();
  if (executionStack != null) {
    XStackFrame stackFrame = executionStack.getTopFrame();
    if (stackFrame != null) {
      return stackFrame.getEvaluator();
    }
  }
  return null;
}
 
Example #19
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 #20
Source File: XFramesView.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void updateFrames(XExecutionStack executionStack, @Nonnull XDebugSession session, @Nullable XStackFrame frameToSelect) {
  if (mySelectedStack != null) {
    getOrCreateBuilder(mySelectedStack, session).stop();
  }

  mySelectedStack = executionStack;
  if (executionStack != null) {
    mySelectedFrameIndex = myExecutionStacksWithSelection.get(executionStack);
    StackFramesListBuilder builder = getOrCreateBuilder(executionStack, session);
    builder.setToSelect(frameToSelect != null ? frameToSelect : mySelectedFrameIndex);
    myListenersEnabled = false;
    builder.initModel(myFramesList.getModel());
    myListenersEnabled = !builder.start();
  }
}
 
Example #21
Source File: XQueryExecutionStack.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@Override
public void computeStackFrames(int firstFrameIndex, XStackFrameContainer container) {
    List<XStackFrame> frames = new ArrayList<XStackFrame>();
    int stackDepth = dbgpIde.stackDepth();
    for (int i = firstFrameIndex; i < stackDepth; i++) {
        frames.add(getStackFrame(dbgpIde, dbgpIde.stackGet(i), i));
    }
    container.addStackFrames(frames, true);
}
 
Example #22
Source File: XQueryExecutionStack.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public XStackFrame getTopFrame() {
    int stackDepth = dbgpIde.stackDepth();
    if (stackDepth > 0) {
        return getStackFrame(dbgpIde, dbgpIde.stackGet(0), stackDepth - 1);
    }
    return null;
}
 
Example #23
Source File: DartVmServiceDebugProcess.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Nullable
public XDebuggerEvaluator getEvaluator() {
  final XStackFrame frame = getSession().getCurrentStackFrame();
  if (frame != null) {
    return frame.getEvaluator();
  }
  return new DartVmServiceEvaluator(this);
}
 
Example #24
Source File: DartVmServiceDebugProcess.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Nullable
public XDebuggerEvaluator getEvaluator() {
  final XStackFrame frame = getSession().getCurrentStackFrame();
  if (frame != null) {
    return frame.getEvaluator();
  }
  return new DartVmServiceEvaluator(this);
}
 
Example #25
Source File: XDebuggerFramesList.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected Transferable createTransferable(JComponent c) {
  if (!(c instanceof XDebuggerFramesList)) {
    return null;
  }
  XDebuggerFramesList list = (XDebuggerFramesList)c;
  //noinspection deprecation
  Object[] values = list.getSelectedValues();
  if (values == null || values.length == 0) {
    return null;
  }

  StringBuilder plainBuf = new StringBuilder();
  StringBuilder htmlBuf = new StringBuilder();
  TextTransferable.ColoredStringBuilder coloredTextContainer = new TextTransferable.ColoredStringBuilder();
  htmlBuf.append("<html>\n<body>\n<ul>\n");
  for (Object value : values) {
    htmlBuf.append("  <li>");
    if (value != null) {
      if (value instanceof XStackFrame) {
        ((XStackFrame)value).customizePresentation(coloredTextContainer);
        coloredTextContainer.appendTo(plainBuf, htmlBuf);
      }
      else {
        String text = value.toString();
        plainBuf.append(text);
        htmlBuf.append(text);
      }
    }
    plainBuf.append('\n');
    htmlBuf.append("</li>\n");
  }

  // remove the last newline
  plainBuf.setLength(plainBuf.length() - 1);
  htmlBuf.append("</ul>\n</body>\n</html>");
  return new TextTransferable(htmlBuf.toString(), plainBuf.toString());
}
 
Example #26
Source File: WeaveExecutionStack.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void computeStackFrames(int firstFrameIndex, XStackFrameContainer container)
{
    if (firstFrameIndex <= frames.size())
    {
        container.addStackFrames(frames.subList(firstFrameIndex, frames.size()), true);
    }
    else
    {
        container.addStackFrames(Collections.<XStackFrame>emptyList(), true);
    }
}
 
Example #27
Source File: XDebuggerFramesList.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void customizeCellRenderer(@Nonnull final JList list,
                                     final Object value,
                                     final int index,
                                     final boolean selected,
                                     final boolean hasFocus) {
  // Fix GTK background
  if (UIUtil.isUnderGTKLookAndFeel()){
    final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
    UIUtil.changeBackGround(this, background);
  }
  if (value == null) {
    append(XDebuggerBundle.message("stack.frame.loading.text"), SimpleTextAttributes.GRAY_ATTRIBUTES);
    return;
  }
  if (value instanceof String) {
    append((String)value, SimpleTextAttributes.ERROR_ATTRIBUTES);
    return;
  }

  XStackFrame stackFrame = (XStackFrame)value;
  if (!selected) {
    Color c = getFrameBgColor(stackFrame);
    if (c != null) {
      setBackground(c);
    }
  }
  stackFrame.customizePresentation(this);
}
 
Example #28
Source File: MuleExecutionStack.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void computeStackFrames(int firstFrameIndex, XStackFrameContainer container)
{
    if (firstFrameIndex <= frames.size())
    {
        container.addStackFrames(frames.subList(firstFrameIndex, frames.size()), true);
    }
    else
    {
        container.addStackFrames(Collections.<XStackFrame>emptyList(), true);
    }
}
 
Example #29
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);
  });
}
 
Example #30
Source File: XFramesView.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void selectFrame(XExecutionStack stack, XStackFrame frame) {
  myThreadComboBox.setSelectedItem(stack);

  EdtExecutorService.getInstance().execute(() -> myFramesList.setSelectedValue(frame, true));
}