pub struct ScopeTree {
pub scopes: Vec<Scope>,
}Expand description
A tree of lexical scopes built from a parsed program.
Fields§
§scopes: Vec<Scope>Implementations§
Source§impl ScopeTree
impl ScopeTree
Sourcepub fn build(program: &Program, source: &str) -> Self
pub fn build(program: &Program, source: &str) -> Self
Build a scope tree from a parsed program.
Sourcepub fn references_of(&self, offset: usize) -> Option<Vec<(usize, usize)>>
pub fn references_of(&self, offset: usize) -> Option<Vec<(usize, usize)>>
Find all references to the binding at the given byte offset.
Returns the definition span + all reference spans, or None if no binding is found at the offset.
Sourcepub fn definition_of(&self, offset: usize) -> Option<(usize, usize)>
pub fn definition_of(&self, offset: usize) -> Option<(usize, usize)>
Find the definition span of the binding at the given byte offset.
Sourcepub fn binding_at(&self, offset: usize) -> Option<&Binding>
pub fn binding_at(&self, offset: usize) -> Option<&Binding>
Return the binding (definition + references) visible at the given offset. Used by hover to resolve shadowed variables correctly.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ScopeTree
impl RefUnwindSafe for ScopeTree
impl Send for ScopeTree
impl Sync for ScopeTree
impl Unpin for ScopeTree
impl UnsafeUnpin for ScopeTree
impl UnwindSafe for ScopeTree
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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