Skip to content

Commit 6af5401

Browse files
committed
feat(highlighting): highlight builtin functions like ton() in constant documentation
Fixes #76
1 parent 235c130 commit 6af5401

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

src/main/kotlin/org/tonstudio/tact/ide/documentation/documentation.kt

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ private fun StringBuilder.generateOwnerDpc(element: TactNamedElement) {
4747

4848
val nameColor = when (element) {
4949
is TactContractDeclaration -> asContract
50-
is TactTraitDeclaration -> asTrait
51-
is TactMessageDeclaration -> asMessage
52-
is TactStructDeclaration -> asStruct
53-
else -> asStruct
50+
is TactTraitDeclaration -> asTrait
51+
is TactMessageDeclaration -> asMessage
52+
is TactStructDeclaration -> asStruct
53+
else -> asStruct
5454
}
5555

5656
colorize(kind, asKeyword)
@@ -513,6 +513,16 @@ fun TactExpression.generateDoc(): String {
513513
val string = TactTokenTypes.STRING_LITERALS.contains(type)
514514
val operators = TactTokenTypes.OPERATORS.contains(type)
515515
val booleanLiteral = tokenText == "true" || tokenText == "false"
516+
val builtinFunctions = tokenText == "ton" ||
517+
tokenText == "require" ||
518+
tokenText == "dump" ||
519+
tokenText == "sha256" ||
520+
tokenText == "cell" ||
521+
tokenText == "slice" ||
522+
tokenText == "rawSlice" ||
523+
tokenText == "ascii" ||
524+
tokenText == "crc32" ||
525+
tokenText == "address"
516526
val primitiveType = TactPrimitiveTypes.isPrimitiveType(tokenText)
517527

518528
if (tokenText.contains("\n")) {
@@ -522,13 +532,14 @@ fun TactExpression.generateDoc(): String {
522532

523533
builder.append(
524534
when {
525-
keyword -> colorize(tokenText, asKeyword)
526-
number -> colorize(tokenText, asNumber)
527-
string -> colorize(tokenText, asString)
528-
operators -> colorize(tokenText, asOperator)
529-
booleanLiteral -> colorize(tokenText, asKeyword)
530-
primitiveType -> colorize(tokenText, asBuiltin)
531-
else -> tokenText
535+
keyword -> colorize(tokenText, asKeyword)
536+
number -> colorize(tokenText, asNumber)
537+
string -> colorize(tokenText, asString)
538+
operators -> colorize(tokenText, asOperator)
539+
booleanLiteral -> colorize(tokenText, asKeyword)
540+
primitiveType -> colorize(tokenText, asBuiltin)
541+
builtinFunctions -> colorize(tokenText, asFunction)
542+
else -> tokenText
532543
}
533544
)
534545
lexer.advance()

0 commit comments

Comments
 (0)