Skip to content

Commit 2b3357a

Browse files
authored
feat(tlb): better highlighting (#741)
1 parent d4c2266 commit 2b3357a

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

server/src/languages/tlb/completion/providers/BuiltinTypesCompletionProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class BuiltinTypesCompletionProvider implements CompletionProvider {
2626
["Int", "257 bits"],
2727
["UInt", "256 bits"],
2828
["Bits", "1023 bits"],
29-
["bits", "1023 bits"],
29+
["bits", "X bits"],
3030
["uint", ""],
3131
["uint8", ""],
3232
["uint16", ""],

server/src/languages/tlb/semantic-tokens/index.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ export function provideTlbSemanticTokens(file: TlbFile): SemanticTokens {
2424

2525
RecursiveVisitor.visit(file.rootNode, (node): boolean => {
2626
switch (node.type) {
27-
case "##": {
27+
case "#":
28+
case "##":
29+
case "#<":
30+
case "#<=":
31+
case "builtin_field": {
2832
pushToken(node, SemanticTokenTypes.macro)
2933
break
3034
}
@@ -41,6 +45,11 @@ export function provideTlbSemanticTokens(file: TlbFile): SemanticTokens {
4145
break
4246
}
4347
case "type_identifier": {
48+
if (isBuiltinType(node.text)) {
49+
pushToken(node, SemanticTokenTypes.macro)
50+
break
51+
}
52+
4453
const parent = node.parent
4554
if (!parent) break
4655

@@ -91,13 +100,22 @@ export function provideTlbSemanticTokens(file: TlbFile): SemanticTokens {
91100
case "combinator": {
92101
break
93102
}
94-
case "builtin_field": {
95-
pushToken(node, SemanticTokenTypes.property)
96-
break
97-
}
98103
}
99104
return true
100105
})
101106

102107
return builder.build()
103108
}
109+
110+
function isBuiltinType(name: string): boolean {
111+
return (
112+
name === "Any" ||
113+
name === "Cell" ||
114+
name === "Int" ||
115+
name === "UInt" ||
116+
name === "Bits" ||
117+
name.startsWith("bits") ||
118+
name.startsWith("uint") ||
119+
name.startsWith("int")
120+
)
121+
}

0 commit comments

Comments
 (0)