Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Python queries, add locals #3284

Merged
merged 3 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion runtime/queries/python/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
; Imports

(dotted_name
(identifier)* @namespace)

(aliased_import
alias: (identifier) @namespace)

; Builtin functions

Expand Down Expand Up @@ -55,14 +60,16 @@
(parameters (typed_parameter (identifier) @variable.parameter))
(parameters (default_parameter name: (identifier) @variable.parameter))
(parameters (typed_default_parameter name: (identifier) @variable.parameter))
(keyword_argument name: (identifier) @variable.parameter)

(parameters
(list_splat_pattern ; *args
(identifier) @variable.parameter))
(parameters
(dictionary_splat_pattern ; **kwargs
(identifier) @variable.parameter))

(lambda_parameters
(identifier) @variable.parameter)

; Types

Expand Down
44 changes: 44 additions & 0 deletions runtime/queries/python/locals.scm
Original file line number Diff line number Diff line change
@@ -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