pub struct SymbolIndex {
pub definitions: Vec<Definition>,
pub references: Vec<Reference>,
pub name_to_defs: HashMap<String, Vec<usize>>,
pub block_spans: Vec<(String, BlockType, Span)>,
pub statement_spans: Vec<(String, Span)>,
pub call_sites: Vec<CallSite>,
}Expand description
The symbol index for a single document.
Fields§
§definitions: Vec<Definition>§references: Vec<Reference>§name_to_defs: HashMap<String, Vec<usize>>§block_spans: Vec<(String, BlockType, Span)>Maps block header names to their spans.
statement_spans: Vec<(String, Span)>Statement spans inferred from keyword..period token ranges.
call_sites: Vec<CallSite>Function call sites (f(…) and Call f …), caller-resolved.
Implementations§
Source§impl SymbolIndex
impl SymbolIndex
Sourcepub fn build(
stmts: &[OwnedStmt],
tokens: &[Token],
type_registry: &TypeRegistry,
interner: &Interner,
source: &str,
) -> Self
pub fn build( stmts: &[OwnedStmt], tokens: &[Token], type_registry: &TypeRegistry, interner: &Interner, source: &str, ) -> Self
Build the symbol index from parsed statements, tokens, the type registry, and the source text (literate docs read the prose).
Sourcepub fn enclosing_function(&self, offset: usize) -> Option<usize>
pub fn enclosing_function(&self, offset: usize) -> Option<usize>
The function definition whose block contains offset, if any.
Sourcepub fn definition_at(&self, offset: usize) -> Option<&Definition>
pub fn definition_at(&self, offset: usize) -> Option<&Definition>
Find the definition at the given byte offset.
Sourcepub fn definition_at_scoped(
&self,
name: &str,
offset: usize,
) -> Option<&Definition>
pub fn definition_at_scoped( &self, name: &str, offset: usize, ) -> Option<&Definition>
Scope-aware definition lookup. Given a byte offset for context,
returns the definition of name in the nearest scope.
Sourcepub fn references_to(&self, name: &str) -> Vec<&Reference>
pub fn references_to(&self, name: &str) -> Vec<&Reference>
Find all references to the definition with the given name.
Sourcepub fn references_in_scope(
&self,
name: &str,
def_offset: usize,
) -> Vec<&Reference>
pub fn references_in_scope( &self, name: &str, def_offset: usize, ) -> Vec<&Reference>
Find references to name that are in the same scope as the definition at def_offset.
Sourcepub fn definitions_of(&self, name: &str) -> Vec<&Definition>
pub fn definitions_of(&self, name: &str) -> Vec<&Definition>
Find all definitions with the given name.
Sourcepub fn block_name(&self, block_idx: usize) -> Option<&str>
pub fn block_name(&self, block_idx: usize) -> Option<&str>
Get the block name for a block index.
Trait Implementations§
Source§impl Clone for SymbolIndex
impl Clone for SymbolIndex
Source§fn clone(&self) -> SymbolIndex
fn clone(&self) -> SymbolIndex
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SymbolIndex
impl Debug for SymbolIndex
Source§impl Default for SymbolIndex
impl Default for SymbolIndex
Source§fn default() -> SymbolIndex
fn default() -> SymbolIndex
Auto Trait Implementations§
impl Freeze for SymbolIndex
impl RefUnwindSafe for SymbolIndex
impl Send for SymbolIndex
impl Sync for SymbolIndex
impl Unpin for SymbolIndex
impl UnsafeUnpin for SymbolIndex
impl UnwindSafe for SymbolIndex
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.