Skip to content

Commit 9728af4

Browse files
committed
Switch to language specific annotators.
1 parent d49d0eb commit 9728af4

File tree

10 files changed

+101
-13
lines changed

10 files changed

+101
-13
lines changed

build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ repositories {
3434
dependencies {
3535
intellijPlatform {
3636
create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion"))
37+
bundledPlugins("org.jetbrains.kotlin", "com.intellij.java")
38+
plugins(
39+
"com.cursiveclojure.cursive:2025.2-252",
40+
"JavaScript:252.27397.106",
41+
"org.intellij.scala:2025.2.30",
42+
"org.jetbrains.plugins.go:252.26830.24",
43+
"PsiViewer:252.23892.248"
44+
)
3745
}
3846
}
3947

src/main/kotlin/com/github/simy4/alabaster/KeywordAnnotator.kt renamed to src/main/kotlin/com/github/simy4/alabaster/JavaAnnotator.kt

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,15 @@ import com.intellij.lang.annotation.AnnotationHolder
44
import com.intellij.lang.annotation.Annotator
55
import com.intellij.lang.annotation.HighlightSeverity
66
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors
7-
import com.intellij.openapi.util.TextRange
7+
import com.intellij.psi.JavaTokenType
88
import com.intellij.psi.PsiElement
9-
import com.intellij.psi.util.startOffset
109

11-
class KeywordAnnotator: Annotator {
10+
class JavaAnnotator: Annotator {
1211
override fun annotate(element: PsiElement, holder: AnnotationHolder) {
13-
val elementType = element.node.elementType.debugName
14-
if ("true" == elementType
15-
|| "false" == elementType
16-
|| "null" == elementType
17-
|| "NULL" == elementType
18-
|| "NULL_KEYWORD" == elementType
19-
|| "TRUE_KEYWORD" == elementType
20-
|| "FALSE_KEYWORD" == elementType) {
12+
val elementType = element.node.elementType
13+
if (JavaTokenType.TRUE_KEYWORD == elementType
14+
|| JavaTokenType.FALSE_KEYWORD == elementType
15+
|| JavaTokenType.NULL_KEYWORD == elementType) {
2116
holder.newSilentAnnotation(HighlightSeverity.INFORMATION)
2217
.textAttributes(DefaultLanguageHighlighterColors.NUMBER)
2318
.create()
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.github.simy4.alabaster
2+
3+
import com.intellij.lang.annotation.AnnotationHolder
4+
import com.intellij.lang.annotation.Annotator
5+
import com.intellij.lang.annotation.HighlightSeverity
6+
import com.intellij.lang.javascript.JSTokenTypes
7+
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors
8+
import com.intellij.psi.PsiElement
9+
10+
class JavaScriptAnnotator: Annotator {
11+
override fun annotate(element: PsiElement, holder: AnnotationHolder) {
12+
val elementType = element.node.elementType
13+
if (JSTokenTypes.TRUE_KEYWORD == elementType
14+
|| JSTokenTypes.FALSE_KEYWORD == elementType
15+
|| JSTokenTypes.NULL_KEYWORD == elementType) {
16+
holder.newSilentAnnotation(HighlightSeverity.INFORMATION)
17+
.textAttributes(DefaultLanguageHighlighterColors.NUMBER)
18+
.create()
19+
}
20+
}
21+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.github.simy4.alabaster
2+
3+
import com.intellij.lang.annotation.AnnotationHolder
4+
import com.intellij.lang.annotation.Annotator
5+
import com.intellij.lang.annotation.HighlightSeverity
6+
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors
7+
import com.intellij.psi.PsiElement
8+
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
9+
10+
class KotlinAnnotator: Annotator {
11+
override fun annotate(element: PsiElement, holder: AnnotationHolder) {
12+
val elementType = element.node.elementType
13+
if (KtStubElementTypes.BOOLEAN_CONSTANT == elementType
14+
|| KtStubElementTypes.NULL == elementType) {
15+
holder.newSilentAnnotation(HighlightSeverity.INFORMATION)
16+
.textAttributes(DefaultLanguageHighlighterColors.NUMBER)
17+
.create()
18+
}
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.github.simy4.alabaster
2+
3+
import com.intellij.lang.annotation.AnnotationHolder
4+
import com.intellij.lang.annotation.Annotator
5+
import com.intellij.lang.annotation.HighlightSeverity
6+
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors
7+
import com.intellij.psi.PsiElement
8+
import org.jetbrains.plugins.scala.lang.lexer.ScalaTokenTypes
9+
10+
class ScalaAnnotator: Annotator {
11+
override fun annotate(element: PsiElement, holder: AnnotationHolder) {
12+
val elementType = element.node.elementType
13+
if (ScalaTokenTypes.BOOLEAN_TOKEN_SET.contains(elementType)
14+
|| ScalaTokenTypes.kNULL == elementType) {
15+
holder.newSilentAnnotation(HighlightSeverity.INFORMATION)
16+
.textAttributes(DefaultLanguageHighlighterColors.NUMBER)
17+
.create()
18+
}
19+
}
20+
}

src/main/resources/META-INF/plugin.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ Other languages work perfectly fine as well, but may do some extra unnecessary h
2626
<p>This is a simple wrapper around <a href="https://github.com/tonsky/intellij-alabaster">Alabaster Color Scheme</a></p>
2727
<p>LICENSE: <a href="https://github.com/simy4/jetbrains-alabaster-theme/blob/main/LICENSE">MIT</a></p>
2828
]]></description>
29+
2930
<depends>com.intellij.modules.platform</depends>
30-
<extensions defaultExtensionNs="com.intellij">
31-
<annotator implementationClass="com.github.simy4.alabaster.KeywordAnnotator"/>
31+
<depends optional="true" config-file="with-java.xml">com.intellij.java</depends>
32+
<depends optional="true" config-file="with-javascript.xml">JavaScript</depends>
33+
<depends optional="true" config-file="with-kotlin.xml">org.jetbrains.kotlin</depends>
34+
<depends optional="true" config-file="with-scala.xml">org.intellij.scala</depends>
3235

36+
<extensions defaultExtensionNs="com.intellij">
3337
<themeProvider id="com.github.simy4.alabaster.light" path="/themes/alabaster.theme.json"/>
3438
<themeProvider id="com.github.simy4.alabaster.bg-light" path="/themes/alabaster-bg.theme.json"/>
3539
<themeProvider id="com.github.simy4.alabaster.dark" path="/themes/alabaster-dark.theme.json"/>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<idea-plugin>
2+
<extensions defaultExtensionNs="com.intellij">
3+
<annotator implementationClass="com.github.simy4.alabaster.JavaAnnotator"/>
4+
</extensions>
5+
</idea-plugin>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<idea-plugin>
2+
<extensions defaultExtensionNs="com.intellij">
3+
<annotator implementationClass="com.github.simy4.alabaster.JavaScriptAnnotator"/>
4+
</extensions>
5+
</idea-plugin>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<idea-plugin>
2+
<extensions defaultExtensionNs="com.intellij">
3+
<annotator implementationClass="com.github.simy4.alabaster.KotlinAnnotator"/>
4+
</extensions>
5+
</idea-plugin>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<idea-plugin>
2+
<extensions defaultExtensionNs="com.intellij">
3+
<annotator implementationClass="com.github.simy4.alabaster.ScalaAnnotator"/>
4+
</extensions>
5+
</idea-plugin>

0 commit comments

Comments
 (0)