How to add support for special JAVA fields?

We are using a certain persistence framework where a reference to another type is not done via a basic member but via something like this:

static Reference<TargetType> target = Reference.create(TargetType.class);

I would love to have this supported, at least for the diagram generation (it should show a reference to TargetType). I therefore started writing a plugin and I thought that "Reference Contributor" is the way to go. However I noticed that I don't even see the PsiField and PsiClass in my PsiReferenceContributor, although I registered it for PsiElement. Is that because Fields are already handled? Is this the way to go at all or should I try something different?


Comment actions Permalink

I'm not quite understand your case. Is this static 'target' field generated in class-files by the framework or it is written in directly the source code? 

What do you mean by 'support this for the diagram generation'?

Comment actions Permalink

Those static fields are written by the developers in the source code. The persistence framework uses those to create the persistence mapping and all kinds of fancy stuff. It also generates getters and setters. So there is no instance member for a relation.

Unfortunately this means when I right-click let's say a package in the project panel and choose "Diagrams->Show Diagram..." then the classes will be there but the relations will not be there as Idea does not understand that those static fields represent relations. I would love to have a fix/workaround for this.

I thought that maybe the diagram generator uses the Psi structure and that maybe I could change the Psi structure by contributing references for these fields.


Please sign in to leave a comment.