Skip to content

Commit 0e18b7e

Browse files
committed
Prove semantic tokens for interpolation entries
1 parent 7045c43 commit 0e18b7e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

server/src/main/kotlin/org/javacs/kt/semantictokens/SemanticTokens.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.psi.KtVariableDeclaration
2222
import org.jetbrains.kotlin.psi.KtNamedDeclaration
2323
import org.jetbrains.kotlin.psi.KtProperty
2424
import org.jetbrains.kotlin.psi.KtParameter
25+
import org.jetbrains.kotlin.psi.KtStringTemplateEntry
2526
import org.jetbrains.kotlin.psi.KtStringTemplateExpression
2627
import org.jetbrains.kotlin.resolve.BindingContext
2728
import com.intellij.psi.PsiElement
@@ -42,7 +43,10 @@ enum class SemanticTokenType(val typeName: String) {
4243
ENUM(SemanticTokenTypes.Enum),
4344
TYPE(SemanticTokenTypes.Type),
4445
STRING(SemanticTokenTypes.String),
45-
NUMBER(SemanticTokenTypes.Number)
46+
NUMBER(SemanticTokenTypes.Number),
47+
// Since LSP does not provide a token type for string interpolation
48+
// entries, we use Variable as a fallback here for now
49+
INTERPOLATION_ENTRY(SemanticTokenTypes.Variable)
4650
}
4751

4852
enum class SemanticTokenModifier(val modifierName: String) {
@@ -165,6 +169,7 @@ private fun elementToken(element: PsiElement, bindingContext: BindingContext): S
165169

166170
SemanticToken(identifierRange, tokenType, modifiers)
167171
}
172+
is KtStringTemplateEntry -> SemanticToken(elementRange, SemanticTokenType.INTERPOLATION_ENTRY)
168173
is KtStringTemplateExpression -> SemanticToken(elementRange, SemanticTokenType.STRING)
169174
is PsiLiteralExpression -> {
170175
val tokenType = when (element.type) {

0 commit comments

Comments
 (0)