Annotator for custom language

I’m developing a custom language plugin.
The language support @xxxx to refer to xxxx argument defined some other golang files

I tried to add an annotator for those “@xxxx” element to make it

  • display in red color when there is no “xxxx” argument it can refer to.
final class MyAnnotator implements Annotator {
  @Override
  public void annotate(@NotNull final PsiElement element, @NotNull AnnotationHolder holder) {
     ...
  }
}
<annotator language="MyLang" implementationClass=".....MyAnnotator" />

But it seems like that then annotator is never called.

I have some similar annotator, it works for yaml. So I guess to support annotator, custom language PSI element should implement some special methods ? ( Just like this issue )

Hi!

When I create a new language support plugin I usually start highlighting the code nodes.
I use Annotators to highlight nodes that aren’t leaf, because there no other way.

As far as I remember there were no big issues with doing so.

Here is how .gitattributes plugin looks like inside:

I don’t know may it help you or not, but you may check if there are no extra difficulty in your codebase.

I guess Annotator may not find you psi elements because they are not in the psi tree. Check your code snippet with PsiViewer.

Maybe the annotator did not get scheduled in the background the last time I tried.

Now it works.

Good news.
Sometimes restarting IDE really helps.