Retrieving information from CompilerMessagesPopup on action

Answered

I added a new action to the compiler messages popup via

<add-to-group group-id="CompilerErrorViewPopupMenu" anchor="first"/>

Now I want to use this action to retrieve information about the message on which this action was invoked, like what text is being displayed in this message and any other information that can be provided.

This is where I am stuck, because I can't seem to retrieve any information from the generated AnActionEvent for the CompilerMessagesPopup and I can't seem to find any information on how to achieve this.

0
2 comments

CommonDataKeys.NAVIGATABLE will resolve to source location (if available).

You should be able to obtain tree component com.intellij.ide.errorTreeView.NewErrorTreeViewPanel via com.intellij.openapi.actionSystem.PlatformDataKeys#CONTEXT_COMPONENT which offers access to current node (getSelectedErrorTreeElement, getSelectedNodeDescriptor)

0
Avatar
Permanently deleted user

Thank you, that helped me a lot. Here is the code I'm using so far, if anyone else needs this.

Component component = e.getData(PlatformDataKeys.CONTEXT_COMPONENT);
NewErrorTreeViewPanel newErrorTreeViewPanel = ComponentUtil.getParentOfType(NewErrorTreeViewPanel.class, component);


// get error info
ErrorTreeElement errorTreeElement = newErrorTreeViewPanel.getSelectedErrorTreeElement();

// contains "java: incompatible types: int cannot be converted to java.lang.String":
String[] message = errorTreeElement.getText();

// contains "Error:":
ErrorTreeElementKind kind = errorTreeElement.getKind();


Navigatable navigatable = e.getData(CommonDataKeys.NAVIGATABLE);
OpenFileDescriptor ofd = (OpenFileDescriptor) navigatable;
int line = ofd.getLine();
int column = ofd.getColumn();

 

 

0

Please sign in to leave a comment.