New to IntelliJ plugins, need some guidelines

Hi all,

We are using TestNG for our automation framework. For each testcase we have TestNG notation like this:
@Testcase(ids = {"242994"})
public void testSomething(DataObject data) {
...
}

Then we have an xml file contains the data for the testcase like this:
... ]]>

I would like to write a plugin that can show the xml data in a tooltip when I Ctrl-hover over the number 242994 in the java file; and when I Ctrl-click on the number, it takes me to the corresponding xml file.

With these requirements in mind, where would you suggest me to look at? FindUsagesProvider? Would it be a project-level plugin?

Thanks in advance,
Phuong

Message was edited by:
Phuong

4 comments

I have searched around and found out that it has something to do with ReferenceProviderRegistry. But the posts I have seen only deal with getting Java reference from Xml files, which is the other way around.

Any help would be appreciated.

0

Hello Phuong,

I have searched around and found out that it has something to do with
ReferenceProviderRegistry. But the posts I have seen only deal with
getting Java reference from Xml files, which is the other way around.


It's actually the correct API to use for this purpose. You'll need to provide
your own implementation of PsiReference that returns the correct XmlElement
from its resolve() method, and return it from PsiReferenceProvider.getReferencesByElement()
if the correct element was passed to you. Use PsiLiteralExpression.class
as the scope for registering your reference provider.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Thanks, I'm totally new to this, so I have very little idea about PsiReference and PsiElement. I will research more and when I have the answer I will post it here.

0

I am totally new to this also, well , more or less. What I found helpful was to read the beginning tutorial by Dimitry which is available on the plug-in developer's main site and to look at the Inspector Gadgets plug in which makes full use of lots of the OpenAPI.

Also just writing stupid little plugins that prove to yourself that you can touch certain parts of the API, like, create and show a panel , inject arbitrary code etc. helps.

Download the PSIViewer and try to understand how the PSI sees your program using that.

Just get creative about opening an OS plugin in IntelliJ and then using IntelliJ as a sort of query database for the API to see find where this or that class might have been used and how it was used.

Going the other way, from seeing a plug-in do something and wanting to be able to do that in your plug-in is harder, but questions get answered here by IntelliJ staff every day. The answers I can make the most use of come when I make the question be about something very specific, like when I've been working on something and I can gain a lot of certain knowledge if I only knew something like - does this class or method do this or not? Is this the right class to use to get this information or do I want another one? What is this class's concern? Just my experience.

0

Please sign in to leave a comment.