Custom debugger action

I have little background OpenApi and on developing Intellij plugins. I have in mind developing my own debugger action that could work as plugin. I want to develop an action that will be used when debugger stops at File object.

This what I have so far:

public class ViewFileAction extends DebuggerAction {
    @Override
    public void update(AnActionEvent e) {
        Presentation presentation = e.getPresentation();
        DataContext dataContext = e.getDataContext();
        DebuggerTreeNodeImpl selectedNode = getSelectedNode(dataContext);
        Value value = getValue(selectedNode);
        boolean isFile = isFileType(value);
        boolean isObjectRef = value instanceof ObjectReference;
        if (!isFile || !isObjectRef) {
            presentation.setVisible(false);
            return;
        }
        presentation.setEnabled(true);
        presentation.setText("View File");
    }
    @Override
    public void actionPerformed(AnActionEvent e) {
       // once performed action (clicked on "View File presentation")
       // try to get all data from file object from current debugging context
      // [code redacted] 
     }
}

From this class I have other implementation for `File` type resolving, which are irrelevant in this case.

I have successfully exported the plugin and installed on Intellij. When I run the debugger of the running Intellij instance (the one that starts when you run a Plugin Developement project) when the debugger hits the breakpoint that has File object in context and line, I don't see the View File on the debugging node.

  1. Can custom Debugger actionswork from plugins?
  2. What I'm missing here I run the plugin?
  3. How do I debug a project that works with a debugger on another project?
  4. Do I explicitly need to run the plugin in debugging mode intellij instance in order to see the debugger action?
  5. Wouldn't it be better if I just write custom data type renderer?

This ""plugin"" will work on both Intellij IDEA and Android Studio

7 comments
Comment actions Permalink

Hi, have you registered the action in plugin.xml?

0
Comment actions Permalink

Yes I did register the action, but not sure in which group I should add it, in order to see the action text debugger node (I hope thats the correct terminology)

See image

---------------------------------------------------------------------------------------------------------------------------------------
| File@12345 | { File something something }                                                          View File|
_____________________________________________________________________________


Currently this is how I register the plugin:



<actions>
<action id="ViewFileAction" class="ViewFileAction" text="View File" description="This is nice File object">
<add-to-group group-id="Debugger.FramePanelPopup" anchor="last"/>
</action>
</actions>


I have tried different `group-id`s from Debugger group, but no luck. 

0
Comment actions Permalink

Debugger groups have moved to the general infrastructure, please use:

<add-to-group group-id="XDebugger.ValueGroup" anchor="last"/>
0
Comment actions Permalink

Thanks Egor, I've encounter another impediment, "com.sun.jdi.Value" is not recognized (PluginClassLoader fails to load class because it already loaded class with same name "com.sun.jdi.ObjectReference" although I have added tools.jar (jdk 8) to classpath. Should I use com.intellij.debugger.jdi. instead? 

0
Comment actions Permalink

Where do you get the Value? 

Value value = getValue(selectedNode);

where does this getValue method come from?

0
Comment actions Permalink

Egor, I have changed the code a little bit more after experimenting with XDebugger

XDebuggerTree tree1 = XDebuggerTree.getTree(e);
TreeSelectionModel selectionModel = tree1.getSelectionModel();
TreePath leadSelectionPath = selectionModel.getLeadSelectionPath();
XValueNodeImpl lastPathComponent = (XValueNodeImpl) leadSelectionPath.getLastPathComponent();
JavaValue javaValue = (JavaValue) lastPathComponent.getValueContainer();
value value = (Value) javaValue.getDescriptor().getValue();


This is how I get current selection and value from the descriptior, which returns com.sun.jdi.ObjectReferenceImpl which is Value implementation. Any thoughts?

0
Comment actions Permalink

I'm not sure what it could be, how do you build the plugin? com.sun.jdi.ObjectReference does not look like the same name as com.sun.jdi.Value...

0

Please sign in to leave a comment.