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 + } + } +}