pub struct PythonLexicalScopeInventory<'tree> { /* private fields */ }Expand description
Function-scope Python bindings discovered from tree-sitter structure.
The inventory models Python’s whole-function symbol-table behavior while
retaining the implicit scope of comprehension targets. Construction is
iterative and every inspected node is gated by scope_step; None means
the caller stopped discovery and must conservatively avoid module fallback.
Implementations§
Source§impl<'tree> PythonLexicalScopeInventory<'tree>
impl<'tree> PythonLexicalScopeInventory<'tree>
Sourcepub fn collect_bounded(
callable: Node<'tree>,
source: &str,
parameter_names: impl IntoIterator<Item = String>,
scope_step: impl FnMut() -> bool,
) -> Option<Self>
pub fn collect_bounded( callable: Node<'tree>, source: &str, parameter_names: impl IntoIterator<Item = String>, scope_step: impl FnMut() -> bool, ) -> Option<Self>
parameter_names is the callable’s formal-parameter name stream. The
layout it comes from is resolved by analyzer/lexical_definitions.rs,
which dispatches through the analysis-side language registry and so
cannot be named here; analyzer/python/lexical_scope.rs in
brokk-bifrost-analysis is the one caller that computes it, under the
same scope_step meter this walk uses.
pub fn into_bindings(self) -> PythonLexicalScopeBindings
pub fn name_resolution_at( &self, name: &str, reference: Node<'_>, ) -> PythonLexicalNameResolution
pub fn name_resolution_at_bounded( &self, name: &str, reference: Node<'_>, scope_step: impl FnMut() -> bool, ) -> Option<PythonLexicalNameResolution>
pub fn has_runtime_callable_binding_at( &self, name: &str, reference: Node<'_>, ) -> bool
pub fn has_runtime_callable_binding_at_bounded( &self, name: &str, reference: Node<'_>, scope_step: impl FnMut() -> bool, ) -> Option<bool>
pub fn local_function_declaration( &self, name: &str, reference: Node<'_>, ) -> Option<Node<'tree>>
pub fn local_function_declaration_bounded( &self, name: &str, reference: Node<'_>, scope_step: impl FnMut() -> bool, ) -> Option<Node<'tree>>
Sourcepub fn local_class_declaration_bounded(
&self,
name: &str,
reference: Node<'_>,
scope_step: impl FnMut() -> bool,
) -> Option<Node<'tree>>
pub fn local_class_declaration_bounded( &self, name: &str, reference: Node<'_>, scope_step: impl FnMut() -> bool, ) -> Option<Node<'tree>>
A single untouched local class declaration, not an inferred instance type. Statement ordering/containment is checked at the selected use.
Sourcepub fn unique_import_declaration_bounded(
&self,
name: &str,
reference: Node<'_>,
scope_step: impl FnMut() -> bool,
) -> Option<Option<Node<'tree>>>
pub fn unique_import_declaration_bounded( &self, name: &str, reference: Node<'_>, scope_step: impl FnMut() -> bool, ) -> Option<Option<Node<'tree>>>
The import must be the only binding event, not merely the first retained token. Competing imports, def/class names and writes collapse ImportOnly to Other during collection, even when import metadata is absent.
Sourcepub fn binding_nodes(&self) -> impl Iterator<Item = Node<'tree>> + '_
pub fn binding_nodes(&self) -> impl Iterator<Item = Node<'tree>> + '_
All binding tokens, including repeated and globally redirected writes. The native producer attributes these after the whole scope inventory exists.
pub fn global_names(&self) -> impl Iterator<Item = &str>
pub fn nonlocal_names(&self) -> impl Iterator<Item = &str>
pub fn local_bindings(&self) -> impl Iterator<Item = (&str, Node<'tree>)> + '_
Auto Trait Implementations§
impl<'tree> Freeze for PythonLexicalScopeInventory<'tree>
impl<'tree> RefUnwindSafe for PythonLexicalScopeInventory<'tree>
impl<'tree> Send for PythonLexicalScopeInventory<'tree>
impl<'tree> Sync for PythonLexicalScopeInventory<'tree>
impl<'tree> Unpin for PythonLexicalScopeInventory<'tree>
impl<'tree> UnsafeUnpin for PythonLexicalScopeInventory<'tree>
impl<'tree> UnwindSafe for PythonLexicalScopeInventory<'tree>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more