Skip to content

Commit

Permalink
[ voile ] Annotator
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed May 26, 2019
1 parent 2365a0b commit f44744e
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/org/ice1000/tt/editing/voile/editing.kt
Original file line number Diff line number Diff line change
@@ -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() = "// "
Expand All @@ -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
}
}
}

0 comments on commit f44744e

Please sign in to comment.