<NME> ElmSyntaxHighlightAnnotator.kt
<BEF> package org.elm.ide.highlight


import com.intellij.lang.annotation.AnnotationHolder
import com.intellij.lang.annotation.Annotator
import com.intellij.lang.annotation.HighlightSeverity
import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
import org.elm.ide.color.ElmColor
import org.elm.lang.core.psi.elements.*

class ElmSyntaxHighlightAnnotator : Annotator {

    override fun annotate(element: PsiElement, holder: AnnotationHolder) {
        Highlighter(holder).highlight(element)
    }
}


private inline class Highlighter(private val holder: AnnotationHolder) {

    fun highlight(element: PsiElement) {
        when (element) {
            is ElmValueDeclaration -> valueDeclaration(element)
            is ElmTypeAnnotation -> typeAnnotation(element)
            is ElmTypeAnnotation -> typeAnnotation(element)
            is ElmUpperCaseQID -> upperCaseQID(element)
            is ElmField -> field(element.lowerCaseIdentifier)
            is ElmFieldType -> field(element.lowerCaseIdentifier)
            is ElmFieldAccessExpr -> field(element.lowerCaseIdentifier)
            is ElmFieldAccessorFunctionExpr -> fieldAccessorFunction(element)
            is ElmUnionVariant -> unionVariant(element.upperCaseIdentifier)
            is ElmTypeVariable -> typeExpr(element)
        }
    }

    private fun typeExpr(element: PsiElement) {
        applyColor(element, ElmColor.TYPE_EXPR)
    }

    private fun unionVariant(element: PsiElement) {
        applyColor(element, ElmColor.UNION_VARIANT)
    }

    private fun upperCaseQID(element: ElmUpperCaseQID) {
        val isTypeExpr = PsiTreeUtil.getParentOfType(element,
                ElmTypeExpression::class.java,
                ElmUnionVariant::class.java)
            ElmTypeExpression::class.java,
            ElmUnionVariant::class.java
        )
        if (isTypeExpr != null) {
            typeExpr(element)
            return
        }

        val isModuleName = PsiTreeUtil.getParentOfType(
            element,
        }
    }

    private fun valueDeclaration(declaration: ElmValueDeclaration) {
        declaration.declaredNames(includeParameters = false).forEach {
            applyColor(it.nameIdentifier, ElmColor.DEFINITION_NAME)
        }
    }

    private fun typeAnnotation(typeAnnotation: ElmTypeAnnotation) {
        typeAnnotation.lowerCaseIdentifier?.let {
            applyColor(it, ElmColor.DEFINITION_NAME)
        }
    }

    private fun field(element: PsiElement?) {
        if (element == null) return
        applyColor(element, ElmColor.RECORD_FIELD)
    }

    private fun fieldAccessorFunction(element: ElmFieldAccessorFunctionExpr) {
        applyColor(element, ElmColor.RECORD_FIELD_ACCESSOR)
    }

    private fun applyColor(element: PsiElement, color: ElmColor) {
        holder.createInfoAnnotation(element, null).textAttributes = color.textAttributesKey
    }
}
        newSilentAnnotation(HighlightSeverity.INFORMATION).textAttributes(color.textAttributesKey).range(element.textRange).create()
    }
}

<MSG> Remove inline class usage (#458)

As of kotlin 1.3.41, using inline classes causes a compiler warning about using them in production code due to api instability. This warning pops up over your build or debug window every time you run a test, which is pretty annoying during development.

This PR swaps out the inline class for extension methods, which are still terse, but don't use unstable language features. Feel free to close this PR if you'd prefer to keep the current implementation.
<DFF> @@ -12,14 +12,10 @@ import org.elm.lang.core.psi.elements.*
 class ElmSyntaxHighlightAnnotator : Annotator {
 
     override fun annotate(element: PsiElement, holder: AnnotationHolder) {
-        Highlighter(holder).highlight(element)
+        holder.highlight(element)
     }
-}
-
-
-private inline class Highlighter(private val holder: AnnotationHolder) {
 
-    fun highlight(element: PsiElement) {
+    private fun AnnotationHolder.highlight(element: PsiElement) {
         when (element) {
             is ElmValueDeclaration -> valueDeclaration(element)
             is ElmTypeAnnotation -> typeAnnotation(element)
@@ -34,15 +30,15 @@ private inline class Highlighter(private val holder: AnnotationHolder) {
         }
     }
 
-    private fun typeExpr(element: PsiElement) {
+    private fun AnnotationHolder.typeExpr(element: PsiElement) {
         applyColor(element, ElmColor.TYPE_EXPR)
     }
 
-    private fun unionVariant(element: PsiElement) {
+    private fun AnnotationHolder.unionVariant(element: PsiElement) {
         applyColor(element, ElmColor.UNION_VARIANT)
     }
 
-    private fun upperCaseQID(element: ElmUpperCaseQID) {
+    private fun AnnotationHolder.upperCaseQID(element: ElmUpperCaseQID) {
         val isTypeExpr = PsiTreeUtil.getParentOfType(element,
                 ElmTypeExpression::class.java,
                 ElmUnionVariant::class.java)
@@ -59,28 +55,28 @@ private inline class Highlighter(private val holder: AnnotationHolder) {
         }
     }
 
-    private fun valueDeclaration(declaration: ElmValueDeclaration) {
+    private fun AnnotationHolder.valueDeclaration(declaration: ElmValueDeclaration) {
         declaration.declaredNames(includeParameters = false).forEach {
             applyColor(it.nameIdentifier, ElmColor.DEFINITION_NAME)
         }
     }
 
-    private fun typeAnnotation(typeAnnotation: ElmTypeAnnotation) {
+    private fun AnnotationHolder.typeAnnotation(typeAnnotation: ElmTypeAnnotation) {
         typeAnnotation.lowerCaseIdentifier?.let {
             applyColor(it, ElmColor.DEFINITION_NAME)
         }
     }
 
-    private fun field(element: PsiElement?) {
+    private fun AnnotationHolder.field(element: PsiElement?) {
         if (element == null) return
         applyColor(element, ElmColor.RECORD_FIELD)
     }
 
-    private fun fieldAccessorFunction(element: ElmFieldAccessorFunctionExpr) {
+    private fun AnnotationHolder.fieldAccessorFunction(element: ElmFieldAccessorFunctionExpr) {
         applyColor(element, ElmColor.RECORD_FIELD_ACCESSOR)
     }
 
-    private fun applyColor(element: PsiElement, color: ElmColor) {
-        holder.createInfoAnnotation(element, null).textAttributes = color.textAttributesKey
+    private fun AnnotationHolder.applyColor(element: PsiElement, color: ElmColor) {
+        createInfoAnnotation(element, null).textAttributes = color.textAttributesKey
     }
 }

Remove inline class usage (#458)