How to add a PsiReferenceContributor for an existing language?
I'm having trouble understanding the correct way to implement a reference provider. I'm not creating a custom language plugin, so a lot of possible solutions i found to my problem don't apply here. So far i have:
plugin.xml
<extensions defaultExtensionNs="com.intellij">
<psi.referenceContributor language="PHP" implementation="my.plugin.MyReferenceContributor" />
</extensions>
MyReferenceContributor.java
public class MyReferenceContributor extends PsiReferenceContributor
{
@Override
public void registerReferenceProviders(PsiReferenceRegistrar registrar)
{
// this doesn't get executed at all
registrar.registerReferenceProvider(PlatformPatterns.psiElement(PhpNamedElement.class), new MyReferenceProvider());
}
}
MyReferenceProvider.java
public class MyReferenceProvider extends PsiReferenceProvider
{
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull final PsiElement element, @NotNull final ProcessingContext context)
{
// this doesn't execute
System.out.println(((PhpNamedElement) element).getName());
return new PsiReference[0];
}
}
Is this the correct way to do this? Why isn't my provider registered?
请先登录再写评论。
Did You try to register your contributor without language attribute?
BTW - remember, language ID is case sensitive.
You can take a look at working PHP reference contributor example in the sources of a very popular Symfony http://plugins.jetbrains.com/plugin/7219?pr=phpStorm
Hello, @...!
Did you find the answer?
I've similar problem here:
This should work, technically, but it is not...
I would be very grateful for your answer.
Regards,
Hi Danijel Fabijan & Богдан Гарнюк! Have either of you been able to figure out this problem? I am trying to extend annotations for XML language and am having some trouble getting started as all the tutorials provided by JetBrains are for a custom language.
Any help would be appreciated!