From f44744e6510e3583cb29308eb937f7406ba7c206 Mon Sep 17 00:00:00 2001 From: ice1000 Date: Sun, 26 May 2019 15:05:14 -0700 Subject: [PATCH] [ voile ] Annotator --- src/org/ice1000/tt/editing/voile/editing.kt | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/org/ice1000/tt/editing/voile/editing.kt b/src/org/ice1000/tt/editing/voile/editing.kt index 869c1be..ce13649 100644 --- a/src/org/ice1000/tt/editing/voile/editing.kt +++ b/src/org/ice1000/tt/editing/voile/editing.kt @@ -1,14 +1,16 @@ package org.ice1000.tt.editing.voile import com.intellij.lang.BracePair +import com.intellij.lang.annotation.AnnotationHolder +import com.intellij.lang.annotation.Annotator import com.intellij.lang.cacheBuilder.DefaultWordsScanner +import com.intellij.psi.PsiElement import com.intellij.psi.tree.TokenSet import org.ice1000.tt.editing.TTBraceMatcher import org.ice1000.tt.editing.TTCommenter import org.ice1000.tt.editing.TTFindUsagesProvider import org.ice1000.tt.psi.redprl.redPrlLexer -import org.ice1000.tt.psi.voile.VoileTokenType -import org.ice1000.tt.psi.voile.VoileTypes +import org.ice1000.tt.psi.voile.* class VoileCommenter : TTCommenter() { override fun getLineCommentPrefix() = "// " @@ -26,3 +28,18 @@ class VoileBraceMatcher : TTBraceMatcher() { class VoileFindUsagesProvider : TTFindUsagesProvider() { override fun getWordsScanner() = DefaultWordsScanner(redPrlLexer(), VoileTokenType.IDENTIFIERS, VoileTokenType.COMMENTS, TokenSet.EMPTY) } + +class VoileAnnotator : Annotator { + override fun annotate(element: PsiElement, holder: AnnotationHolder) { + when (element) { + is VoileNameDeclMixin -> nameDeclMixin(element, holder) + } + } + + private fun nameDeclMixin(element: VoileNameDeclMixin, holder: AnnotationHolder) { + val parent = element.parent ?: return + if (parent is VoileImplementation || parent is VoileSignature) { + holder.createInfoAnnotation(element, null).textAttributes = VoileHighlighter.FUNCTION_NAME + } + } +}