@@ -2,37 +2,40 @@ package org.covscript.devkt.lang
2
2
3
3
import org.covscript.devkt.lang.psi.CovSymbol
4
4
import org.covscript.devkt.lang.psi.CovTypes
5
-
6
- import org.ice1000.devkt.openapi.AnnotationHolder
7
- import org.ice1000.devkt.openapi.Annotator
8
- import org.ice1000.devkt.openapi.ColorScheme
9
- import org.ice1000.devkt.openapi.ExtendedDevKtLanguage
10
- import org.ice1000.devkt.openapi.SyntaxHighlighter
11
-
5
+ import org.ice1000.devkt.openapi.*
6
+ import org.ice1000.devkt.openapi.ui.IconLoader
12
7
import org.jetbrains.kotlin.com.intellij.psi.PsiElement
13
8
import org.jetbrains.kotlin.com.intellij.psi.tree.IElementType
9
+ import javax.swing.Icon
14
10
15
- class CovScriptSyntaxHighlighter <TextAttributes > : SyntaxHighlighter <TextAttributes > {
16
- override fun attributesOf (type : IElementType , colorScheme : ColorScheme <TextAttributes >) = when (type) {
17
- in CovTokenType .KEYWORDS_LIST -> colorScheme.keywords
18
- in CovTokenType .COMMENTS -> colorScheme.lineComments
19
- CovTypes .NUM -> colorScheme.numbers
20
- CovTypes .STR , CovTypes .CHAR -> colorScheme.string
21
- CovTypes .COLLAPSER_BEGIN , CovTypes .COLLAPSER_END -> colorScheme.typeParam
22
- else -> null
23
- }
24
- }
11
+ class CovScript <TextAttributes > : ExtendedDevKtLanguage <TextAttributes >(
12
+ CovLanguage .INSTANCE ,
13
+ CovParserDefinition ()) {
14
+ override fun satisfies (fileName : String ) = fileName.endsWith(" .csc" ) or fileName.endsWith(" .csp" )
15
+ override val lineCommentStart: String get() = " # "
16
+ override val icon: Icon = IconLoader .getIcon(" /icons/csc.png" )
25
17
26
- class CovScriptAnnotator <TextAttributes > : Annotator <TextAttributes > {
27
18
override fun annotate (
28
19
element : PsiElement ,
29
20
document : AnnotationHolder <TextAttributes >,
30
21
colorScheme : ColorScheme <TextAttributes >) {
31
22
when (element) {
32
23
is CovSymbol -> symbol(element, document, colorScheme)
24
+ else -> super .annotate(element, document, colorScheme)
33
25
}
34
26
}
35
27
28
+ override fun attributesOf (type : IElementType , colorScheme : ColorScheme <TextAttributes >) = when (type) {
29
+ in CovTokenType .KEYWORDS_LIST -> colorScheme.keywords
30
+ in CovTokenType .OPERATOR_LIST -> colorScheme.operators
31
+ in CovTokenType .COMMENTS -> colorScheme.lineComments
32
+ CovTypes .NUM -> colorScheme.numbers
33
+ CovTypes .STR -> colorScheme.string
34
+ CovTypes .CHAR -> colorScheme.charLiteral
35
+ CovTypes .COLLAPSER_BEGIN , CovTypes .COLLAPSER_END -> colorScheme.typeParam
36
+ else -> super .attributesOf(type, colorScheme)
37
+ }
38
+
36
39
private fun symbol (
37
40
element : CovSymbol ,
38
41
document : AnnotationHolder <TextAttributes >,
@@ -43,12 +46,3 @@ class CovScriptAnnotator<TextAttributes> : Annotator<TextAttributes> {
43
46
}
44
47
}
45
48
}
46
-
47
- class CovScript <TextAttributes > : ExtendedDevKtLanguage <TextAttributes >(
48
- CovLanguage .INSTANCE ,
49
- CovParserDefinition ()),
50
- Annotator <TextAttributes > by CovScriptAnnotator (),
51
- SyntaxHighlighter <TextAttributes > by CovScriptSyntaxHighlighter () {
52
- override fun satisfies (fileName : String ) = fileName.endsWith(" .csc" ) or fileName.endsWith(" .csp" )
53
- override val lineCommentStart: String get() = " # "
54
- }
0 commit comments