@@ -22,9 +22,12 @@ import org.jetbrains.kotlin.psi.KtVariableDeclaration
22
22
import org.jetbrains.kotlin.psi.KtNamedDeclaration
23
23
import org.jetbrains.kotlin.psi.KtProperty
24
24
import org.jetbrains.kotlin.psi.KtParameter
25
+ import org.jetbrains.kotlin.psi.KtStringTemplateExpression
25
26
import org.jetbrains.kotlin.resolve.BindingContext
26
27
import com.intellij.psi.PsiElement
27
28
import com.intellij.psi.PsiNameIdentifierOwner
29
+ import com.intellij.psi.PsiLiteralExpression
30
+ import com.intellij.psi.PsiType
28
31
import com.intellij.openapi.util.TextRange
29
32
30
33
enum class SemanticTokenType (val typeName : String ) {
@@ -37,7 +40,9 @@ enum class SemanticTokenType(val typeName: String) {
37
40
CLASS (SemanticTokenTypes .Class ),
38
41
INTERFACE (SemanticTokenTypes .Interface ),
39
42
ENUM (SemanticTokenTypes .Enum ),
40
- TYPE (SemanticTokenTypes .Type )
43
+ TYPE (SemanticTokenTypes .Type ),
44
+ STRING (SemanticTokenTypes .String ),
45
+ NUMBER (SemanticTokenTypes .Number )
41
46
}
42
47
43
48
enum class SemanticTokenModifier (val modifierName : String ) {
@@ -160,6 +165,15 @@ private fun elementToken(element: PsiElement, bindingContext: BindingContext): S
160
165
161
166
SemanticToken (identifierRange, tokenType, modifiers)
162
167
}
168
+ is KtStringTemplateExpression -> SemanticToken (elementRange, SemanticTokenType .STRING )
169
+ is PsiLiteralExpression -> {
170
+ val tokenType = when (element.type) {
171
+ PsiType .INT , PsiType .LONG , PsiType .DOUBLE -> SemanticTokenType .NUMBER
172
+ PsiType .CHAR -> SemanticTokenType .STRING
173
+ else -> return null
174
+ }
175
+ SemanticToken (elementRange, tokenType)
176
+ }
163
177
else -> null
164
178
}
165
179
}
0 commit comments