Skip to main content

BindingResolver

Trait BindingResolver 

Source
pub trait BindingResolver: Send + Sync {
    // Required methods
    fn resolve(
        &self,
        tree: &Tree,
        source: &str,
        node: Node<'_>,
    ) -> Option<Binding>;
    fn is_shadowed(&self, tree: &Tree, source: &str, node: Node<'_>) -> bool;
}
Expand description

Language-specific resolution of identifiers to bindings.

Implementations are expected to be cheap to call repeatedly for one file — the engine resolves per match, and a query can match many times. Building a per-file index once and reusing it is the intended shape.

Required Methods§

Source

fn resolve(&self, tree: &Tree, source: &str, node: Node<'_>) -> Option<Binding>

What the identifier at node refers to, or None if it is not an identifier or nothing in this file declares it.

Source

fn is_shadowed(&self, tree: &Tree, source: &str, node: Node<'_>) -> bool

Whether the identifier resolves to a binding that shadows an outer one of the same name.

Distinct from resolve returning a local binding: a name declared once, locally, is not shadowing anything. This is specifically “there is more than one, and you got the inner one”.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§