diff options
| author | Thomas Vigouroux <39092278+vigoux@users.noreply.github.com> | 2020-05-23 15:19:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-23 15:19:03 +0200 |
| commit | 9afad9698ec395afb837908031ca03e3c6a7470b (patch) | |
| tree | a27ba10c44ffcdf57de7e7b43104271687f2c49e /queries/python/locals.scm | |
| parent | fb672f2630f00ff171b552a1d96b53fc0cd0f288 (diff) | |
| parent | f6bf56974ea3ee4a2640c9ddd1b42c20a53188cc (diff) | |
Merge pull request #56 from theHamsta/python-locals
Add python locals.scm
Diffstat (limited to 'queries/python/locals.scm')
| -rw-r--r-- | queries/python/locals.scm | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/queries/python/locals.scm b/queries/python/locals.scm new file mode 100644 index 00000000..bc33d306 --- /dev/null +++ b/queries/python/locals.scm @@ -0,0 +1,71 @@ +;;; Programm structure +(module) @scope + +(class_definition + body: (block + (expression_statement + (assignment + left: (expression_list + (identifier) @definition.associated))))) @scope + +; Function with parameters, defines parameters +(function_definition + name: (identifier) + parameters: (parameters + (identifier) @definition.var)) + +; Function defines function and scope +(function_definition + name: (identifier) @definition.function) @scope + +;; Should be extended to when syntax supported +;(function_definition + ;name: (identifier) @definition.function + ;body: (block (expression_statement (string) @definition.function.doc)?)) @scope + + +(class_definition + name: (identifier) @definition.type) @scope + +(class_definition + body: (block + (function_definition + name: (identifier) @definition.method))) + +;;; Loops +; not a scope! +(for_statement + left: (variables + (identifier) @definition.var)) + +; not a scope! +;(while_statement) @scope + +; for in list comprehension +(for_in_clause + left: (variables + (identifier) @definition.var)) + +(dictionary_comprehension) @scope +(list_comprehension) @scope +(set_comprehension) @scope + +;;; Assignments + +(assignment + left: (expression_list + (identifier) @definition.var)) + +(assignment + left: (expression_list + (attribute + (identifier) + (identifier) @definition.field))) + +; Walrus operator x := 1 +(named_expression + (identifier) @definition.var) + + +;;; REFERENCES +(identifier) @reference |
