@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor
16
16
import org.jetbrains.kotlin.descriptors.VariableDescriptor
17
17
import org.jetbrains.kotlin.lexer.KtTokens
18
18
import org.jetbrains.kotlin.psi.KtClassOrObject
19
+ import org.jetbrains.kotlin.psi.KtFunction
19
20
import org.jetbrains.kotlin.psi.KtModifierListOwner
20
21
import org.jetbrains.kotlin.psi.KtNameReferenceExpression
21
22
import org.jetbrains.kotlin.psi.KtVariableDeclaration
@@ -123,6 +124,8 @@ private fun elementToken(element: PsiElement, bindingContext: BindingContext): S
123
124
val elementRange = range(file.text, element.textRange)
124
125
125
126
return when (element) {
127
+ // References (variables, types, functions, ...)
128
+
126
129
is KtNameReferenceExpression -> {
127
130
val target = bindingContext[BindingContext .REFERENCE_TARGET , element]
128
131
val tokenType = when (target) {
@@ -147,12 +150,16 @@ private fun elementToken(element: PsiElement, bindingContext: BindingContext): S
147
150
148
151
SemanticToken (elementRange, tokenType, modifiers)
149
152
}
153
+
154
+ // Declarations (variables, types, functions, ...)
155
+
150
156
is PsiNameIdentifierOwner -> {
151
157
val tokenType = when (element) {
152
158
is KtParameter -> SemanticTokenType .PARAMETER
153
159
is KtProperty -> SemanticTokenType .PROPERTY
154
160
is KtVariableDeclaration -> SemanticTokenType .VARIABLE
155
161
is KtClassOrObject -> SemanticTokenType .CLASS
162
+ is KtFunction -> SemanticTokenType .FUNCTION
156
163
else -> return null
157
164
}
158
165
val identifierRange = element.nameIdentifier?.let { range(file.text, it.textRange) } ? : return null
@@ -170,6 +177,9 @@ private fun elementToken(element: PsiElement, bindingContext: BindingContext): S
170
177
171
178
SemanticToken (identifierRange, tokenType, modifiers)
172
179
}
180
+
181
+ // Literals and string interpolations
182
+
173
183
is KtSimpleNameStringTemplateEntry , is KtBlockStringTemplateEntry ->
174
184
SemanticToken (elementRange, SemanticTokenType .INTERPOLATION_ENTRY )
175
185
is KtStringTemplateExpression -> SemanticToken (elementRange, SemanticTokenType .STRING )
0 commit comments