Registering reference providers for Twig tokens in PHPStorm
Hey,
I try to register a reference provider for a TwigTokenTypes.STRING_TEXT, using the registrar in the contributor. Unfortunatly this leads not the call of the provider while ctrl+click or ctrl+hovering it.
I tried a simple matching condition:
PsiElementPattern.Capture<PsiElement> psiElementCapture = PlatformPatterns.psiElement(TwigTokenTypes.STRING_TEXT);
And I tried a more complex condition:
PsiElementPattern.Capture<PsiElement> psiElementCapture = PlatformPatterns.psiElement(
TwigTokenTypes.STRING_TEXT)
.afterSiblingSkipping(
PlatformPatterns.or(
PlatformPatterns.psiElement(TwigTokenTypes.SINGLE_QUOTE),
PlatformPatterns.psiElement(TwigTokenTypes.DOUBLE_QUOTE)),
PlatformPatterns.psiElement(TwigTokenTypes.LBRACE)
.afterSibling(
PlatformPatterns.psiElement(TwigTokenTypes.IDENTIFIER)
.withText(StandardPatterns.string().equalTo("path"))
)
);
Both do not match in any way.
请先登录再写评论。
I've tracked it down to these facts:
I'm clueless ...
PsiViewer plugin (http://plugins.intellij.net/plugin/?id=227) may be helpful to understand the PSI structure.
I used the PsiViewer to get the info I've already presented to you. But using the PsiElement(IDENTIFIER) from the viewer does not fire the event of the reference contributor.
Do it get it right, that PsiElement(IDENTIFIER) or Language:Twig refers to TwigTokenTypes.IDENTIFIER ? Maybe the problem is, that I use the wrong token class? I really don't know...