2024-01-06 15:05:50 +09:00
|
|
|
; Program structure
|
2023-07-22 15:29:32 +02:00
|
|
|
(module) @local.scope
|
2020-05-15 18:49:21 +02:00
|
|
|
|
|
|
|
|
(class_definition
|
2024-01-06 15:05:50 +09:00
|
|
|
body:
|
|
|
|
|
(block
|
|
|
|
|
(expression_statement
|
|
|
|
|
(assignment
|
|
|
|
|
left: (identifier) @local.definition.field)))) @local.scope
|
|
|
|
|
|
2020-11-28 22:25:27 +01:00
|
|
|
(class_definition
|
2024-01-06 15:05:50 +09:00
|
|
|
body:
|
|
|
|
|
(block
|
|
|
|
|
(expression_statement
|
|
|
|
|
(assignment
|
|
|
|
|
left:
|
|
|
|
|
(_
|
|
|
|
|
(identifier) @local.definition.field))))) @local.scope
|
2020-05-15 18:49:21 +02:00
|
|
|
|
2020-07-08 15:18:28 +02:00
|
|
|
; Imports
|
|
|
|
|
(aliased_import
|
2023-07-22 15:29:32 +02:00
|
|
|
alias: (identifier) @local.definition.import)
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2020-07-08 15:18:28 +02:00
|
|
|
(import_statement
|
2024-01-06 15:05:50 +09:00
|
|
|
name:
|
|
|
|
|
(dotted_name
|
2024-01-21 22:05:44 +09:00
|
|
|
(identifier) @local.definition.import))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2020-07-08 15:18:28 +02:00
|
|
|
(import_from_statement
|
2024-01-06 15:05:50 +09:00
|
|
|
name:
|
|
|
|
|
(dotted_name
|
2024-01-21 22:05:44 +09:00
|
|
|
(identifier) @local.definition.import))
|
2020-07-08 15:18:28 +02:00
|
|
|
|
2020-05-15 18:49:21 +02:00
|
|
|
; Function with parameters, defines parameters
|
2020-07-08 17:35:12 +02:00
|
|
|
(parameters
|
2023-07-22 15:29:32 +02:00
|
|
|
(identifier) @local.definition.parameter)
|
2020-07-08 17:35:12 +02:00
|
|
|
|
|
|
|
|
(default_parameter
|
2023-07-22 15:29:32 +02:00
|
|
|
(identifier) @local.definition.parameter)
|
2020-07-08 17:35:12 +02:00
|
|
|
|
|
|
|
|
(typed_parameter
|
2023-07-22 15:29:32 +02:00
|
|
|
(identifier) @local.definition.parameter)
|
2020-07-08 17:35:12 +02:00
|
|
|
|
|
|
|
|
(typed_default_parameter
|
2023-07-22 15:29:32 +02:00
|
|
|
(identifier) @local.definition.parameter)
|
2020-05-15 18:49:21 +02:00
|
|
|
|
2020-06-02 21:13:09 +02:00
|
|
|
; *args parameter
|
2020-07-08 17:35:12 +02:00
|
|
|
(parameters
|
2020-11-03 18:50:26 +01:00
|
|
|
(list_splat_pattern
|
2023-07-22 15:29:32 +02:00
|
|
|
(identifier) @local.definition.parameter))
|
2020-06-02 21:13:09 +02:00
|
|
|
|
|
|
|
|
; **kwargs parameter
|
2020-07-08 17:35:12 +02:00
|
|
|
(parameters
|
2020-11-03 18:50:26 +01:00
|
|
|
(dictionary_splat_pattern
|
2023-07-22 15:29:32 +02:00
|
|
|
(identifier) @local.definition.parameter))
|
2020-06-02 21:13:09 +02:00
|
|
|
|
2020-05-15 18:49:21 +02:00
|
|
|
; Function defines function and scope
|
2020-08-15 19:43:43 -05:00
|
|
|
((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"))
|
2020-05-16 19:24:27 +02:00
|
|
|
|
2020-08-15 19:43:43 -05:00
|
|
|
((class_definition
|
2023-07-22 15:29:32 +02:00
|
|
|
name: (identifier) @local.definition.type) @local.scope
|
2024-01-06 15:05:50 +09:00
|
|
|
(#set! definition.type.scope "parent"))
|
2020-05-15 18:49:21 +02:00
|
|
|
|
2020-08-15 09:24:24 -05:00
|
|
|
(class_definition
|
2024-01-06 15:05:50 +09:00
|
|
|
body:
|
|
|
|
|
(block
|
|
|
|
|
(function_definition
|
|
|
|
|
name: (identifier) @local.definition.method)))
|
2020-05-15 18:49:21 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Loops
|
2020-05-15 18:49:21 +02:00
|
|
|
; not a scope!
|
|
|
|
|
(for_statement
|
2024-01-06 15:05:50 +09:00
|
|
|
left:
|
|
|
|
|
(pattern_list
|
|
|
|
|
(identifier) @local.definition.var))
|
|
|
|
|
|
2020-11-28 22:25:27 +01:00
|
|
|
(for_statement
|
2024-01-06 15:05:50 +09:00
|
|
|
left:
|
|
|
|
|
(tuple_pattern
|
|
|
|
|
(identifier) @local.definition.var))
|
|
|
|
|
|
2020-11-28 22:25:27 +01:00
|
|
|
(for_statement
|
2023-07-22 15:29:32 +02:00
|
|
|
left: (identifier) @local.definition.var)
|
2020-05-15 18:49:21 +02:00
|
|
|
|
|
|
|
|
; not a scope!
|
2023-07-22 15:29:32 +02:00
|
|
|
;(while_statement) @local.scope
|
2020-05-15 18:49:21 +02: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
|
|
|
|
2020-11-28 22:25:27 +01:00
|
|
|
(for_in_clause
|
2024-01-06 15:05:50 +09:00
|
|
|
left:
|
|
|
|
|
(tuple_pattern
|
|
|
|
|
(identifier) @local.definition.var))
|
|
|
|
|
|
2020-11-28 22:25:27 +01:00
|
|
|
(for_in_clause
|
2024-01-06 15:05:50 +09:00
|
|
|
left:
|
|
|
|
|
(pattern_list
|
|
|
|
|
(identifier) @local.definition.var))
|
2020-05-15 18:49:21 +02: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
|
2020-05-15 18:49:21 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(set_comprehension) @local.scope
|
2020-05-15 18:49:21 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Assignments
|
2020-11-28 22:25:27 +01:00
|
|
|
(assignment
|
2024-01-06 15:05:50 +09:00
|
|
|
left: (identifier) @local.definition.var)
|
2020-11-28 22:25:27 +01:00
|
|
|
|
|
|
|
|
(assignment
|
2024-01-06 15:05:50 +09:00
|
|
|
left:
|
|
|
|
|
(pattern_list
|
|
|
|
|
(identifier) @local.definition.var))
|
|
|
|
|
|
2020-11-28 22:25:27 +01:00
|
|
|
(assignment
|
2024-01-06 15:05:50 +09:00
|
|
|
left:
|
|
|
|
|
(tuple_pattern
|
|
|
|
|
(identifier) @local.definition.var))
|
2020-05-15 18:49:21 +02:00
|
|
|
|
2020-11-28 22:25:27 +01:00
|
|
|
(assignment
|
2024-01-06 15:05:50 +09:00
|
|
|
left:
|
|
|
|
|
(attribute
|
|
|
|
|
(identifier)
|
|
|
|
|
(identifier) @local.definition.field))
|
2020-05-15 18:49:21 +02:00
|
|
|
|
|
|
|
|
; Walrus operator x := 1
|
|
|
|
|
(named_expression
|
2023-07-22 15:29:32 +02:00
|
|
|
(identifier) @local.definition.var)
|
2020-05-15 18:49:21 +02: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)
|
2020-05-15 18:49:21 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; REFERENCES
|
2023-07-22 15:29:32 +02:00
|
|
|
(identifier) @local.reference
|