summaryrefslogtreecommitdiff
path: root/runtime/queries/python/locals.scm
diff options
context:
space:
mode:
authorChrHorn2022-08-01 21:14:07 +0000
committerGitHub2022-08-01 21:14:07 +0000
commit11367488ac512241b61c6896bfd5d5d32e981b14 (patch)
tree8e61d944ed13268c44e74fb4d6ca8e59bc6b30a2 /runtime/queries/python/locals.scm
parent0c08ff1596b398d53c8c48cc96cfbd24ddec303b (diff)
Improve Python queries, add locals (#3284)
Diffstat (limited to 'runtime/queries/python/locals.scm')
-rw-r--r--runtime/queries/python/locals.scm44
1 files changed, 44 insertions, 0 deletions
diff --git a/runtime/queries/python/locals.scm b/runtime/queries/python/locals.scm
new file mode 100644
index 00000000..f7d5937e
--- /dev/null
+++ b/runtime/queries/python/locals.scm
@@ -0,0 +1,44 @@
+;; Scopes
+
+[
+ (module)
+ (function_definition)
+ (lambda)
+] @local.scope
+
+;; Definitions
+
+; Parameters
+(parameters
+ (identifier) @local.definition)
+(parameters
+ (typed_parameter
+ (identifier) @local.definition))
+(parameters
+ (default_parameter
+ name: (identifier) @local.definition))
+(parameters
+ (typed_default_parameter
+ name: (identifier) @local.definition))
+(parameters
+ (list_splat_pattern ; *args
+ (identifier) @local.definition))
+(parameters
+ (dictionary_splat_pattern ; **kwargs
+ (identifier) @local.definition))
+
+(lambda_parameters
+ (identifier) @local.definition)
+
+; Imports
+(import_statement
+ name: (dotted_name
+ (identifier) @local.definition))
+
+(aliased_import
+ alias: (identifier) @local.definition)
+
+;; References
+
+(identifier) @local.reference
+