@@ -26,7 +26,7 @@ import com.intellij.psi.PsiElement
26
26
import com.intellij.psi.PsiNameIdentifierOwner
27
27
import com.intellij.openapi.util.TextRange
28
28
29
- private enum class SemanticTokenType (val typeName : String ) {
29
+ enum class SemanticTokenType (val typeName : String ) {
30
30
KEYWORD (SemanticTokenTypes .Keyword ),
31
31
VARIABLE (SemanticTokenTypes .Variable ),
32
32
FUNCTION (SemanticTokenTypes .Function ),
@@ -39,7 +39,7 @@ private enum class SemanticTokenType(val typeName: String) {
39
39
TYPE (SemanticTokenTypes .Type )
40
40
}
41
41
42
- private enum class SemanticTokenModifier (val modifierName : String ) {
42
+ enum class SemanticTokenModifier (val modifierName : String ) {
43
43
DECLARATION (SemanticTokenModifiers .Declaration ),
44
44
DEFINITION (SemanticTokenModifiers .Definition ),
45
45
ABSTRACT (SemanticTokenModifiers .Abstract ),
@@ -51,14 +51,21 @@ val semanticTokensLegend = SemanticTokensLegend(
51
51
SemanticTokenModifier .values().map { it.modifierName }
52
52
)
53
53
54
- private data class SemanticToken (val range : Range , val type : SemanticTokenType , val modifiers : Set <SemanticTokenModifier > = setOf())
54
+ data class SemanticToken (val range : Range , val type : SemanticTokenType , val modifiers : Set <SemanticTokenModifier > = setOf())
55
+
56
+ /* *
57
+ * Computes LSP-encoded semantic tokens for the given range in the
58
+ * document. No range means the entire document.
59
+ */
60
+ fun encodedSemanticTokens (file : CompiledFile , range : Range ? = null): List <Int > =
61
+ encodeTokens(semanticTokens(file, range))
55
62
56
63
/* *
57
64
* Computes semantic tokens for the given range in the document.
58
65
* No range means the entire document.
59
66
*/
60
- fun semanticTokens (file : CompiledFile , range : Range ? = null): List < Int > =
61
- encodeTokens( elementTokens(file.parse, file.compile, range) )
67
+ fun semanticTokens (file : CompiledFile , range : Range ? = null): Sequence < SemanticToken > =
68
+ elementTokens(file.parse, file.compile, range)
62
69
63
70
private fun encodeTokens (tokens : Sequence <SemanticToken >): List <Int > {
64
71
val encoded = mutableListOf<Int >()
0 commit comments