How do I get Java specific semantic information about a code token when context clicked?
Answered
Hi,
I want to add to the context menu in Intellij which pops up when you right click on code.
The use-case is, if you right-click on a code token, it would show a "Thank" button. When this search button is clicked, based on the type of token (is it a class? which package is it part of? is it a method? etc.) it uses all this information to send a request to a server with this info. Is this implementable?
I have been looking at documentation, but haven't found anything that exactly serves this purpose. It is enough if this works for just Java.
Can anyone please point at the docs that cover this?
Thanks
Please sign in to leave a comment.
Hi John,
I hope you don't want to replace the common editor menu with your popup. In order to add action there you need to add your AnAction to the popup menu. There are a lot of documentation how to do that, e.g. http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/creating_an_action.html
You would get in DataContext psiElement (by com.intellij.openapi.actionSystem.CommonDataKeys) which correspond to the token. Then you may access server (please async and in actionPerformed only! otherwise you would hang the UI completely)
Anna