3 comments

I use reference converters registered with @Converter on DOM interfaces.  They return specific PSI Reference contributors,
which hprovide lists of candidates. This was enough for code completion and display of error on broken links

0

Thank you for response!

I did not find the information that would be helpful.

Can you show details such as sample code?


0

Your reference provider  creates reference class for given PSI element (say, attribute value), and this reference class shall implement com.intellij.psi.PsiReference
( Usually you sholr extend PsiReferenceBase )  Usually you have to implement:


    @Nullable
    @Override
    public PsiElement resolve();

    @NotNull
    @Override
    public Object[] getVariants();



Where resolve() delievers PsiElement in question ( or null, in case no missing element is found - in this case error will be shown )
and getVariants()  delievers array of candidates for autocompletion ( either  plain strings, or LookupElementBuilder -  in case you like to have fancy icons etc )


Reference providers are registered by reference contributor, declared in your plugin.xml:

     <psi.referenceContributor
                implementation="ClaassContributingReferece extends PsiReferenceContributor"/>

where you can bind reference providers to certain psi elements.   Loook into  struts plugin for inspiration.


0

Please sign in to leave a comment.