@@ -15,13 +15,17 @@ import org.jetbrains.kotlin.descriptors.VariableDescriptor
15
15
import org.jetbrains.kotlin.psi.KtNameReferenceExpression
16
16
import org.jetbrains.kotlin.psi.KtVariableDeclaration
17
17
import org.jetbrains.kotlin.psi.KtNamedDeclaration
18
+ import org.jetbrains.kotlin.psi.KtProperty
19
+ import org.jetbrains.kotlin.psi.KtParameter
18
20
import org.jetbrains.kotlin.resolve.BindingContext
19
21
import com.intellij.psi.PsiElement
22
+ import com.intellij.psi.PsiNameIdentifierOwner
20
23
21
24
private enum class SemanticTokenType (val typeName : String ) {
22
25
VARIABLE (SemanticTokenTypes .Variable ),
23
26
FUNCTION (SemanticTokenTypes .Function ),
24
27
PROPERTY (SemanticTokenTypes .Property ),
28
+ PARAMETER (SemanticTokenTypes .Parameter ),
25
29
ENUM_MEMBER (SemanticTokenTypes .EnumMember ),
26
30
CLASS (SemanticTokenTypes .Class ),
27
31
INTERFACE (SemanticTokenTypes .Interface ),
@@ -99,6 +103,17 @@ private fun elementToken(element: PsiElement, bindingContext: BindingContext): S
99
103
}
100
104
SemanticToken (elementRange, tokenType)
101
105
}
106
+ is PsiNameIdentifierOwner -> {
107
+ val tokenType = when (element) {
108
+ is KtProperty -> SemanticTokenType .PROPERTY
109
+ is KtParameter -> SemanticTokenType .PARAMETER
110
+ is KtVariableDeclaration -> SemanticTokenType .VARIABLE
111
+ else -> return null
112
+ }
113
+ val identifierRange = element.nameIdentifier?.let { range(file.text, it.textRange) } ? : return null
114
+ val modifiers = setOf (SemanticTokenModifier .DECLARATION )
115
+ SemanticToken (identifierRange, tokenType, modifiers)
116
+ }
102
117
else -> null
103
118
}
104
119
}
0 commit comments