2024-01-06 15:05:50 +09:00
|
|
|
; Program structure
|
2023-07-22 15:29:32 +02:00
|
|
|
(module) @local.scope
|
2023-02-18 15:00:37 -05:00
|
|
|
|
|
|
|
|
; Function with parameters, defines parameters
|
|
|
|
|
(parameters
|
2023-07-22 15:29:32 +02:00
|
|
|
(identifier) @local.definition.parameter)
|
2023-02-18 15:00:37 -05:00
|
|
|
|
|
|
|
|
(default_parameter
|
2023-07-22 15:29:32 +02:00
|
|
|
(identifier) @local.definition.parameter)
|
2023-02-18 15:00:37 -05:00
|
|
|
|
|
|
|
|
(typed_parameter
|
2023-07-22 15:29:32 +02:00
|
|
|
(identifier) @local.definition.parameter)
|
2023-02-18 15:00:37 -05:00
|
|
|
|
|
|
|
|
(typed_default_parameter
|
2023-07-22 15:29:32 +02:00
|
|
|
(identifier) @local.definition.parameter)
|
2023-02-18 15:00:37 -05:00
|
|
|
|
|
|
|
|
; *args parameter
|
|
|
|
|
(parameters
|
|
|
|
|
(list_splat_pattern
|
2023-07-22 15:29:32 +02:00
|
|
|
(identifier) @local.definition.parameter))
|
2023-02-18 15:00:37 -05:00
|
|
|
|
|
|
|
|
; **kwargs parameter
|
|
|
|
|
(parameters
|
|
|
|
|
(dictionary_splat_pattern
|
2023-07-22 15:29:32 +02:00
|
|
|
(identifier) @local.definition.parameter))
|
2023-02-18 15:00:37 -05:00
|
|
|
|
|
|
|
|
; Function defines function and scope
|
|
|
|
|
((function_definition
|
2023-07-22 15:29:32 +02:00
|
|
|
name: (identifier) @local.definition.function) @local.scope
|
2024-01-06 15:05:50 +09:00
|
|
|
(#set! definition.function.scope "parent"))
|
2023-02-18 15:00:37 -05:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Loops
|
2023-02-18 15:00:37 -05:00
|
|
|
; not a scope!
|
|
|
|
|
(for_statement
|
2024-03-21 20:44:35 +09:00
|
|
|
left: (pattern_list
|
|
|
|
|
(identifier) @local.definition.var))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2023-02-18 15:00:37 -05:00
|
|
|
(for_statement
|
2024-03-21 20:44:35 +09:00
|
|
|
left: (tuple_pattern
|
|
|
|
|
(identifier) @local.definition.var))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2023-02-18 15:00:37 -05:00
|
|
|
(for_statement
|
2023-07-22 15:29:32 +02:00
|
|
|
left: (identifier) @local.definition.var)
|
2023-02-18 15:00:37 -05:00
|
|
|
|
|
|
|
|
; for in list comprehension
|
|
|
|
|
(for_in_clause
|
2023-07-22 15:29:32 +02:00
|
|
|
left: (identifier) @local.definition.var)
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2023-02-18 15:00:37 -05:00
|
|
|
(for_in_clause
|
2024-03-21 20:44:35 +09:00
|
|
|
left: (tuple_pattern
|
|
|
|
|
(identifier) @local.definition.var))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2023-02-18 15:00:37 -05:00
|
|
|
(for_in_clause
|
2024-03-21 20:44:35 +09:00
|
|
|
left: (pattern_list
|
|
|
|
|
(identifier) @local.definition.var))
|
2023-02-18 15:00:37 -05:00
|
|
|
|
2023-07-22 15:29:32 +02:00
|
|
|
(dictionary_comprehension) @local.scope
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2023-07-22 15:29:32 +02:00
|
|
|
(list_comprehension) @local.scope
|
2023-02-18 15:00:37 -05:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(set_comprehension) @local.scope
|
2023-02-18 15:00:37 -05:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Assignments
|
2023-02-18 15:00:37 -05:00
|
|
|
(assignment
|
2024-01-06 15:05:50 +09:00
|
|
|
left: (identifier) @local.definition.var)
|
2023-02-18 15:00:37 -05:00
|
|
|
|
|
|
|
|
(assignment
|
2024-03-21 20:44:35 +09:00
|
|
|
left: (pattern_list
|
|
|
|
|
(identifier) @local.definition.var))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2023-02-18 15:00:37 -05:00
|
|
|
(assignment
|
2024-03-21 20:44:35 +09:00
|
|
|
left: (tuple_pattern
|
|
|
|
|
(identifier) @local.definition.var))
|
2023-02-18 15:00:37 -05:00
|
|
|
|
|
|
|
|
(assignment
|
2024-03-21 20:44:35 +09:00
|
|
|
left: (attribute
|
|
|
|
|
(identifier)
|
|
|
|
|
(identifier) @local.definition.field))
|
2023-02-18 15:00:37 -05:00
|
|
|
|
|
|
|
|
; Walrus operator x := 1
|
|
|
|
|
(named_expression
|
2023-07-22 15:29:32 +02:00
|
|
|
(identifier) @local.definition.var)
|
2023-02-18 15:00:37 -05:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(as_pattern
|
2023-07-22 15:29:32 +02:00
|
|
|
alias: (as_pattern_target) @local.definition.var)
|
2023-02-18 15:00:37 -05:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; REFERENCES
|
2023-07-22 15:29:32 +02:00
|
|
|
(identifier) @local.reference
|
2023-02-18 15:00:37 -05:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Starlark-specific
|
2023-02-18 15:00:37 -05:00
|
|
|
; Loads
|
|
|
|
|
((call
|
|
|
|
|
function: (identifier) @_fn
|
2024-03-21 20:44:35 +09:00
|
|
|
arguments: (argument_list
|
|
|
|
|
(string) @local.definition.import))
|
2023-02-18 15:00:37 -05:00
|
|
|
(#eq? @_fn "load"))
|