@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.descriptors.ClassKind
12
12
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
13
13
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
14
14
import org.jetbrains.kotlin.descriptors.VariableDescriptor
15
+ import org.jetbrains.kotlin.lexer.KtTokens
15
16
import org.jetbrains.kotlin.psi.KtNameReferenceExpression
16
17
import org.jetbrains.kotlin.psi.KtVariableDeclaration
17
18
import org.jetbrains.kotlin.psi.KtNamedDeclaration
@@ -22,6 +23,7 @@ import com.intellij.psi.PsiElement
22
23
import com.intellij.psi.PsiNameIdentifierOwner
23
24
24
25
private enum class SemanticTokenType (val typeName : String ) {
26
+ KEYWORD (SemanticTokenTypes .Keyword ),
25
27
VARIABLE (SemanticTokenTypes .Variable ),
26
28
FUNCTION (SemanticTokenTypes .Function ),
27
29
PROPERTY (SemanticTokenTypes .Property ),
@@ -117,7 +119,7 @@ private fun elementToken(element: PsiElement, bindingContext: BindingContext): S
117
119
}
118
120
val identifierRange = element.nameIdentifier?.let { range(file.text, it.textRange) } ? : return null
119
121
val modifiers = mutableSetOf (SemanticTokenModifier .DECLARATION )
120
- val isConstant = (element as ? KtVariableDeclaration )?.let { ! it.isVar() } ? : false
122
+ val isConstant = (element as ? KtVariableDeclaration )?.let { ! it.isVar() || it.hasModifier( KtTokens . CONST_KEYWORD ) } ? : false
121
123
if (isConstant) {
122
124
modifiers.add(SemanticTokenModifier .READONLY )
123
125
}
0 commit comments