@@ -12,9 +12,21 @@ import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory
1212import com.intellij.openapi.project.Project
1313import com.intellij.openapi.vfs.VirtualFile
1414import com.intellij.psi.tree.IElementType
15+ import dev.robotcode.robotcode4ij.psi.ARGUMENT
16+ import dev.robotcode.robotcode4ij.psi.COMMENT_BLOCK
17+ import dev.robotcode.robotcode4ij.psi.COMMENT_LINE
18+ import dev.robotcode.robotcode4ij.psi.CONTINUATION
19+ import dev.robotcode.robotcode4ij.psi.CONTROL_FLOW
1520import dev.robotcode.robotcode4ij.psi.ENVIRONMENT_VARIABLE_BEGIN
1621import dev.robotcode.robotcode4ij.psi.ENVIRONMENT_VARIABLE_END
22+ import dev.robotcode.robotcode4ij.psi.HEADER
23+ import dev.robotcode.robotcode4ij.psi.KEYWORD_CALL
24+ import dev.robotcode.robotcode4ij.psi.KEYWORD_NAME
25+ import dev.robotcode.robotcode4ij.psi.OPERATOR
1726import dev.robotcode.robotcode4ij.psi.RobotTextMateElementType
27+ import dev.robotcode.robotcode4ij.psi.SETTING
28+ import dev.robotcode.robotcode4ij.psi.TESTCASE_NAME
29+ import dev.robotcode.robotcode4ij.psi.VARIABLE
1830import dev.robotcode.robotcode4ij.psi.VARIABLE_BEGIN
1931import dev.robotcode.robotcode4ij.psi.VARIABLE_END
2032import org.jetbrains.plugins.textmate.language.syntax.highlighting.TextMateHighlighter
@@ -31,49 +43,27 @@ class RobotCodeHighlighterProvider : EditorHighlighterProvider {
3143
3244class RobotCodeHighlighter : TextMateHighlighter (RobotTextMateHighlightingLexer ()) {
3345 companion object {
34- val elementMap = mapOf (
35- " comment.line.robotframework" to arrayOf(RobotColors .LINE_COMMENT ),
36- " comment.line.rest.robotframework" to arrayOf(RobotColors .LINE_COMMENT ),
37- " comment.block.robotframework" to arrayOf(RobotColors .BLOCK_COMMENT ),
38- " keyword.other.header.robotframework" to arrayOf(RobotColors .HEADER ),
39- " keyword.other.header.settings.robotframework" to arrayOf(RobotColors .HEADER ),
40- " keyword.other.header.variable.robotframework" to arrayOf(RobotColors .HEADER ),
41- " keyword.other.header.testcase.robotframework" to arrayOf(RobotColors .HEADER ),
42- " keyword.other.header.task.robotframework" to arrayOf(RobotColors .HEADER ),
43- " keyword.other.header.keyword.robotframework" to arrayOf(RobotColors .HEADER ),
44- " keyword.other.header.comment.robotframework" to arrayOf(RobotColors .HEADER ),
45-
46- " keyword.control.settings.robotframework" to arrayOf(RobotColors .SETTING ),
47- " keyword.control.settings.documentation.robotframework" to arrayOf(RobotColors .SETTING ),
48-
49- " entity.name.function.testcase.name.robotframework" to arrayOf(RobotColors .TESTCASE_NAME ),
50- " entity.name.function.keyword.name.robotframework" to arrayOf(RobotColors .KEYWORD_NAME ),
51- " entity.name.function.keyword-call.robotframework" to arrayOf(RobotColors .KEYWORD_CALL ),
52- " keyword.control.flow.robotframework" to arrayOf(RobotColors .CONTROL_FLOW ),
53- " keyword.other.robotframework" to arrayOf(RobotColors .SETTING ),
54- " punctuation.definition.variable.begin.robotframework" to arrayOf(RobotColors .VARIABLE_BEGIN ),
55- " punctuation.definition.variable.end.robotframework" to arrayOf(RobotColors .VARIABLE_END ),
56- " variable.name.readwrite.robotframework" to arrayOf(RobotColors .VARIABLE ),
57- " punctuation.definition.envvar.begin.robotframework" to arrayOf(RobotColors .VARIABLE_BEGIN ),
58- " punctuation.definition.envvar.end.robotframework" to arrayOf(RobotColors .VARIABLE_END ),
59- " keyword.operator.robotframework" to arrayOf(RobotColors .OPERATOR ),
60- " constant.character.robotframework" to arrayOf(RobotColors .ARGUMENT ),
61- " string.unquoted.argument.robotframework" to arrayOf(RobotColors .ARGUMENT ),
62- " keyword.operator.continue.robotframework" to arrayOf(RobotColors .CONTINUATION ),
63- )
6446 val elementTypeMap = mapOf (
47+ COMMENT_LINE to arrayOf(RobotColors .LINE_COMMENT ),
48+ COMMENT_BLOCK to arrayOf(RobotColors .BLOCK_COMMENT ),
6549 VARIABLE_BEGIN to arrayOf(RobotColors .VARIABLE_BEGIN ),
6650 VARIABLE_END to arrayOf(RobotColors .VARIABLE_END ),
6751 ENVIRONMENT_VARIABLE_BEGIN to arrayOf(RobotColors .VARIABLE_BEGIN ),
6852 ENVIRONMENT_VARIABLE_END to arrayOf(RobotColors .VARIABLE_END ),
53+ TESTCASE_NAME to arrayOf(RobotColors .TESTCASE_NAME ),
54+ KEYWORD_NAME to arrayOf(RobotColors .KEYWORD_NAME ),
55+ HEADER to arrayOf(RobotColors .HEADER ),
56+ SETTING to arrayOf(RobotColors .SETTING ),
57+ KEYWORD_CALL to arrayOf(RobotColors .KEYWORD_CALL ),
58+ CONTROL_FLOW to arrayOf(RobotColors .CONTROL_FLOW ),
59+ VARIABLE to arrayOf(RobotColors .VARIABLE ),
60+ OPERATOR to arrayOf(RobotColors .OPERATOR ),
61+ ARGUMENT to arrayOf(RobotColors .ARGUMENT ),
62+ CONTINUATION to arrayOf(RobotColors .CONTINUATION ),
6963 )
7064 }
7165
7266 override fun getTokenHighlights (tokenType : IElementType ? ): Array <TextAttributesKey > {
73- if (tokenType is RobotTextMateElementType ) {
74- val result = elementMap[tokenType.element.scope.scopeName]
75- if (result != null ) return result
76- }
7767 if (tokenType in elementTypeMap) {
7868 val result = elementTypeMap[tokenType]
7969 if (result != null ) return result
0 commit comments