I have a simple test class:
public class Test {
public void foo() {
Object a = getClass();
}
}
Playing with the DefinitionsReferenceContributor I expect it to get the reference, but nothing happens. Breakpoint inside getReferencesByElement is not reached.
public class DefinitionsReferenceContributor extends PsiReferenceContributor {
@Override
public void registerReferenceProviders(PsiReferenceRegistrar registrar) {
PsiElementPattern.Capture<PsiMethodCallExpression> psiJavaTokenCapture = psiElement(PsiMethodCallExpression.class);
registrar.registerReferenceProvider(psiJavaTokenCapture, new PsiReferenceProvider() {
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
return new PsiReference[0];
}
});
}
}
Changes to plugin.xml:
<depends>com.intellij.modules.platform</depends>
<depends>com.intellij.java</depends>
<extensions defaultExtensionNs="com.intellij">
<psi.referenceContributor implementation="DefinitionsReferenceContributor"/>
</extensions>
What am I doing wrong?
question from:
https://stackoverflow.com/questions/65870661/psireferencecontributor-not-catching-element 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…