Skip to content

Commit

Permalink
add highlighting for attributes (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
i582 authored Oct 17, 2024
1 parent 27917a0 commit 8efa231
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class HighlightingAnnotator: MvAnnotatorBase() {
leafType == IDENTIFIER -> highlightIdentifier(parent)
leafType == HEX_INTEGER_LITERAL -> MvColor.NUMBER
parent is MvAssertMacroExpr -> MvColor.MACRO
parent is MvAttr -> MvColor.ATTRIBUTE
parent is MvCopyExpr
&& element.text == "copy" -> MvColor.KEYWORD
else -> null
Expand Down Expand Up @@ -80,6 +81,7 @@ class HighlightingAnnotator: MvAnnotatorBase() {
if (element is MvConst) return MvColor.CONSTANT
if (element is MvModule) return MvColor.MODULE
if (element is MvVectorLitExpr) return MvColor.VECTOR_LITERAL
if (element is MvAttrItem) return MvColor.ATTRIBUTE

return when (element) {
is MvPath -> highlightPathElement(element)
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/org/move/ide/colors/MvColor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum class MvColor(humanName: String, default: TextAttributesKey? = null) {
METHOD_CALL("Functions//Method call", Default.FUNCTION_CALL),

MACRO("Functions//Macro", Default.IDENTIFIER),
ATTRIBUTE("Attribute", Default.METADATA),

KEYWORD("Keywords//Keyword", Default.KEYWORD),
SELF_PARAMETER("Keywords//Self Parameter", Default.KEYWORD),
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/colors/highlighterDemoText.move
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module 0x1::<MODULE>main</MODULE> {

entry fun <ENTRY_FUNCTION>entry_fun</ENTRY_FUNCTION>() {}
inline fun <INLINE_FUNCTION>inline_fun</INLINE_FUNCTION>() {}
#[view]
<ATTRIBUTE>#[view]</ATTRIBUTE>
public fun <VIEW_FUNCTION>view_fun</VIEW_FUNCTION>() {}

fun <METHOD>receiver</METHOD>(<SELF_PARAMETER>self</SELF_PARAMETER>: S, <VARIABLE>self</VARIABLE>: u8): u8 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,13 @@ class HighlightingAnnotatorTest: AnnotatorTestCase(HighlightingAnnotator::class)
}
""")

fun `test attribute highlighting`() = checkHighlighting("""
module 0x1::m {
<ATTRIBUTE>#</ATTRIBUTE><ATTRIBUTE>[</ATTRIBUTE><ATTRIBUTE>view</ATTRIBUTE><ATTRIBUTE>]</ATTRIBUTE>
fun foo() {}
}
""")

// fun `test resource access control keywords highlighting`() = checkHighlighting(
// """
// module 0x1::m {
Expand Down

0 comments on commit 8efa231

Please sign in to comment.