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 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.