Skip to content

Commit e48943b

Browse files
committed
feat(intellij): support for more semantic highlight tokens
1 parent 6198707 commit e48943b

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

intellij-client/build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import org.jetbrains.intellij.platform.gradle.Constants.Constraints
44
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
55
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
66
import org.jetbrains.intellij.platform.gradle.tasks.PrepareSandboxTask
7+
import org.jetbrains.intellij.platform.gradle.tasks.aware.IntelliJPlatformVersionAware
78
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
89
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
910
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
@@ -204,6 +205,13 @@ tasks.withType<KotlinCompile> {
204205
prepareSandboxTask(prepareSandboxConfig)
205206
}
206207

208+
@Suppress("unused") val runIdePyCharmCommunityEAP by intellijPlatformTesting.runIde.registering {
209+
type = IntelliJPlatformType.PyCharmCommunity
210+
version = "LATEST-EAP-SNAPSHOT"
211+
212+
prepareSandboxTask(prepareSandboxConfig)
213+
}
214+
207215
@Suppress("unused") val runIdeIntellijIdeaC by intellijPlatformTesting.runIde.registering {
208216
type = IntelliJPlatformType.IntellijIdeaCommunity
209217

intellij-client/src/main/kotlin/dev/robotcode/robotcode4ij/configuration/RobotCodeColorSettingsPage.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class RobotCodeColorSettingsPage : ColorSettingsPage {
1717
AttributesDescriptor("Test case name", Colors.TESTCASE_NAME),
1818
AttributesDescriptor("Keyword name", Colors.KEYWORD_NAME),
1919
AttributesDescriptor("Keyword call", Colors.KEYWORD_CALL),
20+
AttributesDescriptor("Keyword call inner", Colors.KEYWORD_CALL_INNER),
21+
AttributesDescriptor("Name call", Colors.NAME_CALL),
2022
AttributesDescriptor("Setting", Colors.SETTING),
2123
AttributesDescriptor("Setting import", Colors.SETTING_IMPORT),
2224
AttributesDescriptor("Control flow", Colors.CONTROL_FLOW),

intellij-client/src/main/kotlin/dev/robotcode/robotcode4ij/highlighting/Colors.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ object Colors {
1616
createTextAttributesKey("ROBOTFRAMEWORK_KEYWORD_NAME", DefaultLanguageHighlighterColors.FUNCTION_DECLARATION)
1717
val KEYWORD_CALL: TextAttributesKey =
1818
createTextAttributesKey("ROBOTFRAMEWORK_KEYWORD_CALL", DefaultLanguageHighlighterColors.FUNCTION_CALL)
19+
val KEYWORD_CALL_INNER: TextAttributesKey =
20+
createTextAttributesKey("ROBOTFRAMEWORK_KEYWORD_CALL_INNER", DefaultLanguageHighlighterColors.FUNCTION_CALL)
21+
val NAME_CALL: TextAttributesKey =
22+
createTextAttributesKey("ROBOTFRAMEWORK_NAME_CALL", DefaultLanguageHighlighterColors.FUNCTION_CALL)
1923

2024
val SETTING: TextAttributesKey =
2125
createTextAttributesKey("ROBOTFRAMEWORK_SETTING", DefaultLanguageHighlighterColors.KEYWORD)

intellij-client/src/main/kotlin/dev/robotcode/robotcode4ij/lsp/RobotCodeSemanticTokensColorsProvider.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package dev.robotcode.robotcode4ij.lsp
22

3+
import com.intellij.openapi.diagnostic.thisLogger
34
import com.intellij.openapi.editor.colors.TextAttributesKey
45
import com.intellij.psi.PsiFile
6+
import com.redhat.devtools.lsp4ij.features.semanticTokens.DefaultSemanticTokensColorsProvider
57
import com.redhat.devtools.lsp4ij.features.semanticTokens.SemanticTokensColorsProvider
68
import dev.robotcode.robotcode4ij.highlighting.Colors
79

@@ -22,7 +24,8 @@ private val mapping by lazy {
2224
"testcaseName" to Colors.TESTCASE_NAME,
2325
"keywordName" to Colors.KEYWORD_NAME,
2426
"keywordCall" to Colors.KEYWORD_CALL,
25-
27+
"keywordCallInner" to Colors.KEYWORD_CALL_INNER,
28+
"nameCall" to Colors.NAME_CALL,
2629
"argument" to Colors.ARGUMENT,
2730
"embeddedArgument" to Colors.EMBEDDED_ARGUMENT,
2831
"namedArgument" to Colors.NAMED_ARGUMENT,
@@ -37,11 +40,16 @@ private val mapping by lazy {
3740
)
3841
}
3942

40-
class RobotCodeSemanticTokensColorsProvider : SemanticTokensColorsProvider {
43+
class RobotCodeSemanticTokensColorsProvider : DefaultSemanticTokensColorsProvider() {
4144
override fun getTextAttributesKey(
4245
tokenType: String, tokenModifiers: MutableList<String>, file: PsiFile
4346
): TextAttributesKey? {
44-
return mapping[tokenType]
47+
val result = mapping[tokenType] ?: super.getTextAttributesKey(tokenType, tokenModifiers, file)
48+
49+
return result ?: run {
50+
thisLogger().warn("Unknown token type: $tokenType")
51+
null
52+
}
4553
}
4654
}
4755

0 commit comments

Comments
 (0)