summaryrefslogtreecommitdiff
path: root/queries/solidity
diff options
context:
space:
mode:
authorYongJieYongJie <KhooYongJie@gmx.com>2022-03-12 01:11:17 +0800
committerStephan Seitz <stephan.seitz@fau.de>2022-03-11 19:06:39 +0100
commitfc0b881f93851a79ae3506d54e0e3e368c98ce58 (patch)
tree645e9148d5b518010d3b3c1d12eae8d2dd0441f2 /queries/solidity
parent8f3991065d4753c4b458fb19b9a2332f3d740c50 (diff)
Refactor solidity highlights.scm further
- Instead of @keyword, use @conditional, @exception, @return, @function as appropriate - Standardize to using @field (instead of @property)for struct members
Diffstat (limited to 'queries/solidity')
-rw-r--r--queries/solidity/highlights.scm49
1 files changed, 30 insertions, 19 deletions
diff --git a/queries/solidity/highlights.scm b/queries/solidity/highlights.scm
index 14fd6c52..abb3ec3d 100644
--- a/queries/solidity/highlights.scm
+++ b/queries/solidity/highlights.scm
@@ -32,7 +32,7 @@
(primitive_type) @type
(contract_declaration name: (identifier) @type)
(struct_declaration struct_name: (identifier) @type)
-; (struct_member name: (identifier) @field) ;; Technically correct, but makes highlight worst
+(struct_member name: (identifier) @field)
(enum_declaration enum_type_name: (identifier) @type)
; Color payable in payable address conversion as type and not as keyword
(payable_conversion_expression "payable" @type)
@@ -63,14 +63,15 @@
; Handles expressions like g();
(call_expression . (identifier) @function)
+(function_definition
+ function_name: (identifier) @function)
; Handles the field in struct literals like MyStruct({MyField: MyVar * 2})
(call_expression (identifier) @field . ":")
; Function parameters
(event_paramater name: (identifier) @parameter)
-(function_definition
- function_name: (identifier) @parameter)
+(parameter name: (identifier) @parameter)
; Yul functions
(yul_function_call function: (yul_identifier) @function)
@@ -80,10 +81,10 @@
(meta_type_expression "type" @keyword)
-(member_expression (property_identifier) @property)
-(property_identifier) @property
-(struct_expression ((identifier) @property . ":"))
-(enum_value) @property
+(member_expression (property_identifier) @field)
+(property_identifier) @field
+(struct_expression ((identifier) @field . ":"))
+(enum_value) @constant
; Keywords
@@ -98,16 +99,6 @@
"event"
"using"
"assembly"
- "switch"
- "case"
- "default"
- "break"
- "continue"
- "if"
- "else"
- "try"
- "catch"
- "return"
"emit"
"public"
"internal"
@@ -117,11 +108,9 @@
"view"
"payable"
"modifier"
- "returns"
"memory"
"storage"
"calldata"
- "function"
"var"
(constant)
(virtual)
@@ -135,6 +124,28 @@
"do"
] @repeat
+[
+ "break"
+ "continue"
+ "if"
+ "else"
+ "switch"
+ "case"
+ "default"
+] @conditional
+
+[
+ "try"
+ "catch"
+] @exception
+
+[
+ "return"
+ "returns"
+] @keyword.return
+
+"function" @keyword.function
+
"import" @include
(import_directive "as" @include)
(import_directive "from" @include)