How do I tell that an interface method is a reference to a custom location, say xml file?

     It is easy for string literals, I create PsiReferenceContributor and do registrar.registerReferenceProvider(PsiJavaPatterns.psiLiteral(), new PsiReferenceProvider() { ... }); But it won't work for methods: registrar.registerReferenceProvider(PsiJavaPatterns.psiMethod().definedInClass(PsiJavaPatterns.psiClass().isInterface()), new PsiReferenceProvider() { ... }) does not help, I don't get my PsiReferenceProvider#getReferencesByElement invoked when I middle-click (ctrl+b) on a method declaration.

3 comments
Comment actions Permalink

You can't use a reference provider for this purpose. If you're interested specifically in overriding Goto Declaration, you can implement a GotoDeclarationHandler.

0
Comment actions Permalink

This is clear, thanks. I wonder what can reference provider be used for, except string literals?

0
Comment actions Permalink

The elements which query the reference providers registry in their implementation of getReferences(). :) It's not a fixed set.

0

Please sign in to leave a comment.