Documentation
¶
Index ¶
Constants ¶
const CallQueries = `
(call
function: (identifier) @callee) @call
(call
function: (attribute
attribute: (identifier) @callee)) @call
`
CallQueries captures direct function and method call sites in Python. Matches:
- plain calls: foo()
- attribute/method calls: obj.method()
const ImportQueries = `` /* 285-byte string literal not displayed */
ImportQueries contains tree-sitter query patterns for Python import extraction. Matches import_statement and import_from_statement nodes:
- plain import: import os → path="os", alias=""
- aliased import: import os as op_sys → path="os", alias="op_sys"
- from import: from os import path → path="os", alias=""
- from relative import: from . import something → path=".", alias=""
Each match yields a @path capture (dotted_name or relative_import text) and an optional @alias capture (the identifier after 'as').
const Queries = `` /* 607-byte string literal not displayed */
Queries contains tree-sitter query patterns for Python symbol extraction. Covers:
- top-level function definitions (def foo — direct children of module)
- decorated top-level function definitions (@decorator def foo)
- class definitions (class Foo)
- decorated class definitions (@decorator class Foo)
- method definitions (def foo inside a class body)
- decorated method definitions (@decorator def foo inside a class body)
The @function patterns are anchored to module-level to avoid matching methods that are already captured by the @method patterns.
In Python's tree-sitter grammar, decorated definitions are wrapped in a decorated_definition node, so we need separate patterns for each case.
const RefQueries = `
(assignment
right: (identifier) @ref)
(pair
value: (identifier) @ref)
(keyword_argument
value: (identifier) @ref)
`
RefQueries captures identifiers used as values (not called directly) in:
- assignment statements: f = my_func (right-hand side plain identifier)
- dict literal values: {"handler": my_func}
- keyword arguments: handler=my_func
Combined with CallQueries in ExtractCalls so functions passed as values are recorded as "used" and do not appear as dead code.
Variables ¶
var Extensions = []string{".py", ".pyw"}
Extensions lists file extensions handled by the Python grammar.
var Language = tree_sitter.NewLanguage(tree_sitter_python.Language())
Language is the single shared tree-sitter language instance for Python.
Functions ¶
This section is empty.
Types ¶
This section is empty.