Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'runtime/queries/solidity/highlights.scm')
-rw-r--r--runtime/queries/solidity/highlights.scm206
1 files changed, 78 insertions, 128 deletions
diff --git a/runtime/queries/solidity/highlights.scm b/runtime/queries/solidity/highlights.scm
index 0e49429d..61c89ac8 100644
--- a/runtime/queries/solidity/highlights.scm
+++ b/runtime/queries/solidity/highlights.scm
@@ -1,23 +1,21 @@
-; identifiers
-; -----------
-(identifier) @variable
-((identifier) @variable.builtin (#any-of? @variable.builtin "this" "msg" "block" "tx"))
-(yul_identifier) @variable
+(comment) @comment
; Pragma
-(pragma_directive) @keyword.directive
-(solidity_version_comparison_operator _ @keyword.directive)
+(pragma_directive) @tag
+(solidity_version_comparison_operator ">=" @tag)
+(solidity_version_comparison_operator "<=" @tag)
+(solidity_version_comparison_operator "=" @tag)
+(solidity_version_comparison_operator "~" @tag)
+(solidity_version_comparison_operator "^" @tag)
+
; Literals
-; --------
[
(string)
(hex_string_literal)
(unicode_string_literal)
(yul_string_literal)
] @string
-(hex_string_literal "hex" @string.special.symbol)
-(unicode_string_literal "unicode" @string.special.symbol)
[
(number_literal)
(yul_decimal_number)
@@ -26,87 +24,68 @@
[
(true)
(false)
- (yul_boolean)
-] @constant.builtin.boolean
+] @constant.builtin
-(comment) @comment
-; Definitions and references
-; -----------
+; Type
(type_name) @type
-
-[
- (primitive_type)
- (number_unit)
-] @type.builtin
-
-(user_defined_type (_) @type)
-(user_defined_type_definition name: (identifier) @type)
-(type_alias (identifier) @type)
-
+(primitive_type) @type
+(struct_declaration struct_name: (identifier) @type)
+(enum_declaration enum_type_name: (identifier) @type)
; Color payable in payable address conversion as type and not as keyword
(payable_conversion_expression "payable" @type)
+(emit_statement . (identifier) @type)
+; Handles ContractA, ContractB in function foo() override(ContractA, contractB) {}
+(override_specifier (identifier) @type)
; Ensures that delimiters in mapping( ... => .. ) are not colored like types
(type_name "(" @punctuation.bracket "=>" @punctuation.delimiter ")" @punctuation.bracket)
-; Definitions
-(struct_declaration name: (identifier) @type)
-(enum_declaration name: (identifier) @type)
-(contract_declaration name: (identifier) @type)
-(library_declaration name: (identifier) @type)
-(interface_declaration name: (identifier) @type)
-(event_definition name: (identifier) @type)
-(error_declaration name: (identifier) @type)
-(function_definition name: (identifier) @function)
-(modifier_definition name: (identifier) @function)
+
+
+; Functions and parameters
+
+(function_definition
+ function_name: (identifier) @function)
+(modifier_definition
+ name: (identifier) @function)
(yul_evm_builtin) @function.builtin
-; Use constructor coloring for special functions
+; Use contructor coloring for special functions
(constructor_definition "constructor" @constructor)
-(error_declaration "error" @constructor)
(fallback_receive_definition "receive" @constructor)
(fallback_receive_definition "fallback" @constructor)
-(struct_member name: (identifier) @variable.other.member)
-(enum_value) @constant
-; SCREAMING_SNAKE_CASE identifier are constants
-((identifier) @constant (#match? @constant "^[A-Z][A-Z_]+$"))
+(modifier_invocation (identifier) @function)
-; Invocations
-(emit_statement name: (expression (identifier) @type))
-(revert_statement error: (expression (identifier) @type))
-(modifier_invocation . (_) @function)
+; Handles expressions like structVariable.g();
+(call_expression . (member_expression (property_identifier) @function.method))
-(call_expression . (_(member_expression property: (_) @function.method)))
-(call_expression . (expression (identifier) @function))
+; Handles expressions like g();
+(call_expression . (identifier) @function)
; Function parameters
-(call_struct_argument name: (identifier) @field)
-(event_parameter name: (identifier) @variable.parameter)
-(parameter name: (identifier) @variable.parameter)
+(event_paramater name: (identifier) @variable.parameter)
+(function_definition
+ function_name: (identifier) @variable.parameter)
; Yul functions
-(yul_function_call function: (_) @function)
-(yul_function_definition
- ("function" (yul_identifier) @function "(" (
- (yul_identifier) @variable.parameter ("," (yul_identifier) @variable.parameter)*
- )
- )
-)
+(yul_function_call function: (yul_identifier) @function)
-; Structs and members
-(member_expression property: (identifier) @variable.other.member)
-(struct_expression type: ((expression (identifier)) @type .))
-(struct_field_assignment name: (identifier) @variable.other.member)
+; Yul function parameters
+(yul_function_definition . (yul_identifier) @function (yul_identifier) @variable.parameter)
+
+(meta_type_expression "type" @keyword)
+(member_expression (property_identifier) @variable.other.member)
+(property_identifier) @variable.other.member
+(struct_expression ((identifier) @variable.other.member . ":"))
+(enum_value) @variable.other.member
-; Tokens
-; -------
; Keywords
-(meta_type_expression "type" @keyword)
[
- "abstract"
+ "pragma"
+ "import"
"contract"
"interface"
"library"
@@ -114,8 +93,21 @@
"struct"
"enum"
"event"
- "type"
+ "using"
"assembly"
+ "switch"
+ "case"
+ "default"
+ "break"
+ "continue"
+ "if"
+ "else"
+ "for"
+ "while"
+ "do"
+ "try"
+ "catch"
+ "return"
"emit"
"public"
"internal"
@@ -125,58 +117,24 @@
"view"
"payable"
"modifier"
+ "returns"
+ "memory"
+ "storage"
+ "calldata"
+ "function"
"var"
- "let"
+ (constant)
(virtual)
(override_specifier)
(yul_leave)
] @keyword
-[
- "memory"
- "storage"
- "calldata"
- "constant"
- "transient"
- (immutable)
-] @keyword.storage.modifier
-
-[
- "for"
- "while"
- "do"
-] @keyword.control.repeat
-
-[
- "break"
- "continue"
- "if"
- "else"
- "switch"
- "case"
- "default"
-] @keyword.control.conditional
-
-[
- "try"
- "catch"
- "revert"
-] @keyword.control.exception
-
-[
- "return"
- "returns"
-] @keyword.control.return
-
-"function" @keyword.function
-
-"import" @keyword.control.import
-"using" @keyword.control.import
-(import_directive "as" @keyword.control.import)
-(import_directive "from" @keyword.control.import)
-(event_parameter "indexed" @keyword)
+(import_directive "as" @keyword)
+(import_directive "from" @keyword)
+(event_paramater "indexed" @keyword)
; Punctuation
+
[
"("
")"
@@ -184,21 +142,22 @@
"]"
"{"
"}"
-] @punctuation.bracket
+] @punctuation.bracket
+
[
"."
","
- ":"
- "->"
- "=>"
] @punctuation.delimiter
+
; Operators
+
[
"&&"
"||"
">>"
+ ">>>"
"<<"
"&"
"^"
@@ -213,27 +172,18 @@
"<="
"=="
"!="
+ "!=="
">="
">"
"!"
"~"
"-"
"+"
+ "delete"
+ "new"
"++"
"--"
- "+="
- "-="
- "*="
- "/="
- "%="
- "^="
- "&="
- "|="
- "<<="
- ">>="
] @operator
-[
- "delete"
- "new"
-] @keyword.operator
+(identifier) @variable
+(yul_identifier) @variable