highlight query for constant,error and union
;enum and tag union field is constant
(
+ (ContainerDeclType
[
- ; union(Tag){}
- (ContainerDeclType (SuffixExpr (IDENTIFIER) @type))
-
- ; enum{}
- (ContainerDeclType "enum")
+ (SuffixExpr (IDENTIFIER) @type)
+ "enum"
]
+ )
(ContainerField (IDENTIFIER) @constant)?
)
-; INFO: .IDENTIFIER is a field?
+;error field is a constant
+(ErrorSetDecl (IDENTIFIER) @constant)
+
+; INFO: .IDENTIFIER and error.IDENTIFIER is a constant?
(SuffixExpr
+ "error"?
"."
- (IDENTIFIER) @field
+ .
+ (IDENTIFIER) @constant
)
-; error.OutOfMemory;
-(SuffixExpr
- "error"
- "."
+;const IDENTIFIER = 1;
+(VarDecl
+ "const"
(IDENTIFIER) @constant
)
+; const IDENTIFIER = struct/enum/union...
(VarDecl
(IDENTIFIER) @type
- [
- ; const IDENTIFIER = struct/enum/union...
(SuffixExpr (ContainerDecl))
+)
- ; const A = u8;
- (SuffixExpr (BuildinTypeExpr))
- ]
+(VarDecl
+ (IDENTIFIER) @exception
+ (SuffixExpr (ErrorSetDecl))
)
-; const fn_no_comma = fn (i32, i32) void;
+; INFO: const/var fn_no_comma = fn (i32, i32) void;
+; INFO: should this be a function, type, constant or variable?
(VarDecl
(IDENTIFIER) @function
(SuffixExpr (FnProto))
@@ -75,17 +79,14 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor)
; var.func().func().field
(
- (SuffixOp
- (IDENTIFIER) @function
- )
+ (SuffixOp (IDENTIFIER) @function)
.
(FnCallArguments)
)
+
; func()
(
- (
- (IDENTIFIER) @function
- )
+ ((IDENTIFIER) @function)
.
(FnCallArguments)
)
@@ -97,25 +98,14 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor)
("!")? @exception
)
-(ParamDecl
- (ParamType (SuffixExpr (IDENTIFIER) @parameter))
+; fn decl inside struct,enum...
+(ContainerDecl
+ (FnProto (IDENTIFIER) @method)
)
(ParamDecl
- (IDENTIFIER) @parameter
- ":"
- [
- (ParamType (SuffixExpr (IDENTIFIER) @type))
- (ParamType)
- ]
-)
-
-(SwitchItem
- (SuffixExpr
- "."
- .
- (IDENTIFIER) @constant
- )
+ (IDENTIFIER)? @parameter
+ (ParamType (SuffixExpr (IDENTIFIER) @type))?
)
(BUILTINIDENTIFIER) @function.builtin
@@ -275,3 +265,5 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor)
(PtrPayload "|")
(PtrIndexPayload "|")
] @punctuation.bracket
+; Error
+(ERROR) @error
