Skip to content

Commit f8c8719

Browse files
committed
fix: avoid reloading IDE to apply settings and better recognize elements
1 parent 324bac6 commit f8c8719

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/main/kotlin/com/github/lppedd/kotlin/KotlinAnnotator.kt

+6-6
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ internal val KOTLIN_MATH_OPERATOR_FUN: TextAttributesKey =
3434
*/
3535
private class KotlinAnnotator : Annotator {
3636
private val globalScheme = EditorColorsManager.getInstance().globalScheme
37-
private val infixFunAttributes = globalScheme.getAttributes(KOTLIN_INFIX_FUN)
38-
private val keywordOperatorFunAttributes = globalScheme.getAttributes(KOTLIN_KEYWORD_OPERATOR_FUN)
39-
private val mathOperatorFunAttributes = globalScheme.getAttributes(KOTLIN_MATH_OPERATOR_FUN)
4037

4138
override fun annotate(element: PsiElement, annotationHolder: AnnotationHolder) {
4239
if (element is KtOperationReferenceExpression) {
@@ -49,9 +46,9 @@ private class KotlinAnnotator : Annotator {
4946
private fun getTextAttributes(expr: KtOperationReferenceExpression): TextAttributes? {
5047
val operationSignTokenType = expr.operationSignTokenType
5148
return when {
52-
!expr.isConventionOperator() -> infixFunAttributes
53-
operationSignTokenType is KtKeywordToken -> keywordOperatorFunAttributes
54-
operationSignTokenType is KtSingleValueToken -> mathOperatorFunAttributes
49+
operationSignTokenType is KtKeywordToken -> KOTLIN_KEYWORD_OPERATOR_FUN.getAttributes()
50+
operationSignTokenType is KtSingleValueToken -> KOTLIN_MATH_OPERATOR_FUN.getAttributes()
51+
!expr.isConventionOperator() -> KOTLIN_INFIX_FUN.getAttributes()
5552
else -> null
5653
}
5754
}
@@ -61,4 +58,7 @@ private class KotlinAnnotator : Annotator {
6158
textAttributes: TextAttributes) {
6259
createInfoAnnotation(element, null).enforcedTextAttributes = textAttributes
6360
}
61+
62+
private fun TextAttributesKey.getAttributes(): TextAttributes =
63+
globalScheme.getAttributes(this)
6464
}

0 commit comments

Comments
 (0)