Skip to content

Commit 3648bfc

Browse files
committed
Add conversion of current semantic token types to TextMate scopes
1 parent a192204 commit 3648bfc

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

rascal-textmate-core/src/main/rascal/lang/textmate/Conversion.rsc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,35 @@ RscGrammar preprocess(RscGrammar rsc) {
6161
when d := \lit("<stringChar(char)>"), isDelimiter(d)
6262
}
6363

64+
// Replace current semantic token types with TextMate scopes based on:
65+
// - https://github.com/microsoft/vscode/blob/9f3a7b5bc8a2758584b33d0385b227f25ae8d3fb/src/vs/platform/theme/common/tokenClassificationRegistry.ts#L543-L571
66+
rsc = visit (rsc) {
67+
case \tag("category"("comment")) => \tag("category"("comment"))
68+
case \tag("category"("string")) => \tag("category"("string"))
69+
case \tag("category"("keyword")) => \tag("category"("keyword.control"))
70+
case \tag("category"("number")) => \tag("category"("constant.numeric"))
71+
case \tag("category"("regexp")) => \tag("category"("constant.regexp"))
72+
case \tag("category"("operator")) => \tag("category"("keyword.operator"))
73+
case \tag("category"("namespace")) => \tag("category"("entity.name.namespace"))
74+
case \tag("category"("type")) => \tag("category"("support.type")) // Alternative: support.type
75+
case \tag("category"("struct")) => \tag("category"("entity.name.type.struct"))
76+
case \tag("category"("class")) => \tag("category"("entity.name.type.class")) // Alternative: support.class
77+
case \tag("category"("interface")) => \tag("category"("entity.name.type.interface"))
78+
case \tag("category"("enum")) => \tag("category"("entity.name.type.enum"))
79+
case \tag("category"("typeParameter")) => \tag("category"("entity.name.type.parameter"))
80+
case \tag("category"("function")) => \tag("category"("entity.name.function")) // Alternative: support.function
81+
case \tag("category"("method")) => \tag("category"("entity.name.function.member")) // Alternative: support.function
82+
case \tag("category"("macro")) => \tag("category"("entity.name.function.preprocessor"))
83+
case \tag("category"("variable")) => \tag("category"("variable.other.readwrite")) // Alternative: entity.name.variable
84+
case \tag("category"("parameter")) => \tag("category"("variable.parameter"))
85+
case \tag("category"("property")) => \tag("category"("variable.other.property"))
86+
case \tag("category"("enumMember")) => \tag("category"("variable.other.enummember"))
87+
case \tag("category"("event")) => \tag("category"("variable.other.event"))
88+
case \tag("category"("decorator")) => \tag("category"("entity.name.decorator")) // Alternative: entity.name.function
89+
// Note: Categories types `member` and `label` are deprecated/undefined
90+
// and therefore excluded from this mapping
91+
}
92+
6493
// Replace legacy semantic token types with TextMate scopes based on:
6594
// - https://github.com/usethesource/rascal/blob/83023f60a6eb9df7a19ccc7a4194b513ac7b7157/src/org/rascalmpl/values/parsetrees/TreeAdapter.java#L44-L59
6695
// - https://github.com/usethesource/rascal-language-servers/blob/752fea3ea09101e5b22ee426b11c5e36db880225/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/SemanticTokenizer.java#L121-L142

0 commit comments

Comments
 (0)