This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add coloring support for kotlin
- Loading branch information
Sebastian Barfurth
authored and
Sebastian Barfurth
committed
Dec 6, 2021
1 parent
2e35430
commit 7cfc536
Showing
13 changed files
with
110 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 0 additions & 60 deletions
60
src/main/kotlin/com/github/barfurth/jb/plastic/annotator/JavaPlasticColoringAnnotator.kt
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
src/main/kotlin/com/github/barfurth/jb/plastic/annotator/JavaSemanticColoringAnnotator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.github.barfurth.jb.plastic.annotator | ||
|
||
import com.intellij.psi.PsiElement | ||
import com.intellij.psi.PsiKeyword | ||
import com.intellij.psi.PsiLiteralExpression | ||
|
||
class JavaSemanticColoringAnnotator : AbstractSemanticColoringAnnotator() { | ||
|
||
override fun isKeyword(element: PsiElement): Boolean { | ||
return element is PsiKeyword || element is PsiLiteralExpression | ||
} | ||
|
||
override fun getSemanticKeywords(): Map<String, SemanticTokenType> { | ||
return mapOf( | ||
PsiKeyword.TRUE to SemanticTokenType.CONSTANT, | ||
PsiKeyword.FALSE to SemanticTokenType.CONSTANT, | ||
PsiKeyword.NULL to SemanticTokenType.CONSTANT, | ||
|
||
PsiKeyword.CLASS to SemanticTokenType.STORAGE, | ||
PsiKeyword.RECORD to SemanticTokenType.STORAGE, | ||
PsiKeyword.INTERFACE to SemanticTokenType.STORAGE, | ||
PsiKeyword.ENUM to SemanticTokenType.STORAGE, | ||
PsiKeyword.VAR to SemanticTokenType.STORAGE, | ||
PsiKeyword.CONST to SemanticTokenType.STORAGE, | ||
|
||
PsiKeyword.CHAR to SemanticTokenType.TYPE, | ||
PsiKeyword.BOOLEAN to SemanticTokenType.TYPE, | ||
PsiKeyword.LONG to SemanticTokenType.TYPE, | ||
PsiKeyword.FLOAT to SemanticTokenType.TYPE, | ||
PsiKeyword.INT to SemanticTokenType.TYPE, | ||
PsiKeyword.BYTE to SemanticTokenType.TYPE, | ||
PsiKeyword.SHORT to SemanticTokenType.TYPE, | ||
PsiKeyword.DOUBLE to SemanticTokenType.TYPE, | ||
PsiKeyword.VOID to SemanticTokenType.TYPE, | ||
) | ||
} | ||
|
||
} |
25 changes: 0 additions & 25 deletions
25
src/main/kotlin/com/github/barfurth/jb/plastic/annotator/KotlinPlasticColoringAnnotator.kt
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
src/main/kotlin/com/github/barfurth/jb/plastic/annotator/KotlinSemanticColoringAnnotator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.github.barfurth.jb.plastic.annotator | ||
|
||
import com.intellij.psi.PsiElement | ||
import com.intellij.psi.impl.source.tree.LeafPsiElement | ||
import org.jetbrains.kotlin.lexer.KtKeywordToken | ||
import org.jetbrains.kotlin.lexer.KtTokens | ||
import org.jetbrains.kotlin.psi.KtConstantExpression | ||
|
||
class KotlinSemanticColoringAnnotator : AbstractSemanticColoringAnnotator() { | ||
|
||
override fun isKeyword(element: PsiElement): Boolean { | ||
if (element is LeafPsiElement) { | ||
val type = element.elementType | ||
return type is KtKeywordToken | ||
} | ||
return element is KtConstantExpression | ||
} | ||
|
||
override fun getSemanticKeywords(): Map<String, SemanticTokenType> { | ||
return mapOf( | ||
KtTokens.NULL_KEYWORD.value to SemanticTokenType.CONSTANT, | ||
KtTokens.FALSE_KEYWORD.value to SemanticTokenType.CONSTANT, | ||
KtTokens.TRUE_KEYWORD.value to SemanticTokenType.CONSTANT, | ||
|
||
KtTokens.VAL_KEYWORD.value to SemanticTokenType.STORAGE, | ||
KtTokens.VAR_KEYWORD.value to SemanticTokenType.STORAGE, | ||
KtTokens.CLASS_KEYWORD.value to SemanticTokenType.STORAGE, | ||
KtTokens.OBJECT_KEYWORD.value to SemanticTokenType.STORAGE, | ||
KtTokens.ENUM_KEYWORD.value to SemanticTokenType.STORAGE, | ||
KtTokens.FUN_KEYWORD.value to SemanticTokenType.STORAGE, | ||
KtTokens.INTERFACE_KEYWORD.value to SemanticTokenType.STORAGE, | ||
KtTokens.ANNOTATION_KEYWORD.value to SemanticTokenType.STORAGE, | ||
KtTokens.DATA_KEYWORD.value to SemanticTokenType.STORAGE, | ||
KtTokens.CONST_KEYWORD.value to SemanticTokenType.STORAGE, | ||
|
||
KtTokens.GET_KEYWORD.value to SemanticTokenType.FUNCTION, | ||
KtTokens.SET_KEYWORD.value to SemanticTokenType.FUNCTION | ||
) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
src/main/kotlin/com/github/barfurth/jb/plastic/util/AnnotatorUtil.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...main/resources/META-INF/coloring-java.xml → ...main/resources/META-INF/semantic-java.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<idea-plugin> | ||
<extensions defaultExtensionNs="com.intellij"> | ||
<annotator language="JAVA" implementationClass="com.github.barfurth.jb.plastic.annotator.JavaPlasticColoringAnnotator"/> | ||
<annotator language="JAVA" implementationClass="com.github.barfurth.jb.plastic.annotator.JavaSemanticColoringAnnotator"/> | ||
</extensions> | ||
</idea-plugin> |
2 changes: 1 addition & 1 deletion
2
...in/resources/META-INF/coloring-kotlin.xml → ...in/resources/META-INF/semantic-kotlin.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<idea-plugin> | ||
<extensions defaultExtensionNs="com.intellij"> | ||
<annotator language="kotlin" implementationClass="com.github.barfurth.jb.plastic.annotator.KotlinPlasticColoringAnnotator"/> | ||
<annotator language="kotlin" implementationClass="com.github.barfurth.jb.plastic.annotator.KotlinSemanticColoringAnnotator"/> | ||
</extensions> | ||
</idea-plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters