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!
请先登录再写评论。
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).
Thanks, it has been fixed. Now, I'm sure the code has been executed, but the color of the label expression has not changed.