ReferenceContributor doesn't catch needed

Hi. I'm trying to implement this issue(https://youtrack.jetbrains.com/issue/WI-16368) as a plugin.

And CompletionContributor works ok.

public class TargetCompletionContributor extends CompletionContributor
{
public TargetCompletionContributor()
{
extend(CompletionType.BASIC, PlatformPatterns.psiElement(PhpTokenTypes.IDENTIFIER).withParent(MethodReference.class).withLanguage(PhpLanguage.INSTANCE), new TargetCompletionProvider());

Little proof - http://adelf.ru/temp/trait.png
But when I trying to implement ReferenceContributor for this it doesn't catch needed PsiElements using the same condition

public class TargetReferenceContributor extends PsiReferenceContributor
{
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar)
{
registrar.registerReferenceProvider(PlatformPatterns.psiElement(PhpTokenTypes.IDENTIFIER).withParent(MethodReference.class).withLanguage(PhpLanguage.INSTANCE), new TargetReferenceProvider());

Do I miss something? Or don't understand? Or standard ReferenceProvider for methods overrides it?
P.S. I added they both to plugin.xml:

<extensions defaultExtensionNs="com.intellij">
<completion.contributor language="PHP" implementationClass="ru.adelf.idea.trait.TargetCompletionContributor"/>
<psi.referenceContributor implementation="ru.adelf.idea.trait.TargetReferenceContributor"/>
</extensions>
5 comments
Comment actions Permalink

Hello Adel,

here is a note from tutorial:

10.6. Define a reference contributor

A reference contributor allows you to provide references from elements in other languages such as Java to elements in your language. 

 

here is a note I copied from elsewhere but can not find a source for:

For references within the same language,
implement PsiElement.getReferences() in your PsiElement implementation.

0
Comment actions Permalink

I use standard PhpStorm PsiElements... not my own. I think getReferences() already implemented there.

0
Comment actions Permalink

what happens if you remove 

referenceContributor

from plugin.xml?
0
Comment actions Permalink

The same thing. Autocompletion for @target class methods works. But IDEA doesn't have reference from this method calls to method declarations(which I want to implement).

0
Comment actions Permalink

I checked Community code but do not see PHP there. Is there a PHP plugin? 

if there is, you'd need to figure out how it implements references.

or hopefully someone else replies if they can help.

0

Please sign in to leave a comment.