How to highlight Kotlin's label expression in Idea plugin

I'm trying to write a plug-in to highlight Kotlin's label expression, but it does not work:

class KotlinLabelHighlightAnnotator : Annotator {
override fun annotate(element: PsiElement, holder: AnnotationHolder) {
if (element is KtLabelReferenceExpression) {
holder.createInfoAnnotation(element, null)
.enforcedTextAttributes = TextAttributes(Color.BLUE, null, null, null, Font.PLAIN)
}
}
}

plugin.xml:

<depends optional="true" config-file="kotlin.xml">org.jetbrains.kotlin</depends>

kotlin.xml:

<idea-plugin>
<extensions defaultExtensionNs="com.intellij">
<annotator language="kotlin" implementationClass="myplugin.KotlinLabelHighlightAnnotator"/>
</extensions>
</idea-plugin>

 

Please help me, Thank!

0
2 comments

If the contents of your plugin.xml that you've posted is exactly as it is in your project, then the annotator doesn't work because you have a typo in the class name (an extra "w" letter).

0

Thanks, it has been fixed. Now, I'm sure the code has been executed, but the color of the label expression has not changed.

0

Please sign in to leave a comment.