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.
Please sign in to leave a comment.
You can't use a reference provider for this purpose. If you're interested specifically in overriding Goto Declaration, you can implement a GotoDeclarationHandler.
This is clear, thanks. I wonder what can reference provider be used for, except string literals?
The elements which query the reference providers registry in their implementation of getReferences(). :) It's not a fixed set.