Skip to main content

SymbolTable

Struct SymbolTable 

Source
pub struct SymbolTable { /* private fields */ }
Expand description

The scope tree of a program, the symbols each scope declares, every use of those symbols, and the files they live in.

Implementations§

Source§

impl SymbolTable

Source

pub const GLOBAL: ScopeId = 0

The main file’s global scope, always present.

Source

pub const MAIN: FileId = 0

The main file’s id, always present.

Source

pub fn file_path(&self, file: FileId) -> &str

Source

pub fn file_root(&self, file: FileId) -> ScopeId

Source

pub fn files(&self) -> impl Iterator<Item = (FileId, &str)>

Source

pub fn scope_file(&self, scope: ScopeId) -> FileId

Source

pub fn symbols(&self) -> &[Symbol]

Every symbol declared anywhere, in declaration order.

Source

pub fn scope_kind(&self, scope: ScopeId) -> ScopeKind

The kind of a scope.

Source

pub fn symbols_in(&self, scope: ScopeId) -> impl Iterator<Item = &Symbol>

The symbols reachable by bare name directly in scope.

Source

pub fn members_of(&self, owner: SymbolId) -> impl Iterator<Item = &Symbol>

The members (fields, enum cases) of a type or enum symbol — the candidates for completion after owner..

Source

pub fn member_id(&self, owner: SymbolId, name: &str) -> Option<SymbolId>

The member of owner named name, if any — resolves owner.name.

Source

pub fn exported_id(&self, scope: ScopeId, name: &str) -> Option<SymbolId>

An exported symbol named name declared directly in scope — how a member access resolves against an imported library’s global scope.

Source

pub fn declaration_location(&self, id: SymbolId) -> Option<(FileId, u32, u32)>

A symbol’s declaration location as (file, line, column) — go-to-def, including into an imported library file.

Source

pub fn symbol(&self, id: SymbolId) -> &Symbol

The symbol at index id.

Source

pub fn resolve(&self, scope: ScopeId, name: &str) -> Option<&Symbol>

Resolve name from scope outward, innermost first.

Source

pub fn resolve_id(&self, scope: ScopeId, name: &str) -> Option<SymbolId>

Like resolve but returns the symbol’s id, so a use can be recorded against it.

Source

pub fn references( &self, symbol: SymbolId, ) -> impl Iterator<Item = (FileId, u32, u32)> + '_

Source

pub fn occurrences_in_file( &self, file: FileId, ) -> impl Iterator<Item = (u32, u32, SymbolId)> + '_

Source

pub fn symbol_at( &self, file: FileId, line: u32, column: u32, ) -> Option<SymbolId>

The symbol referenced or declared at (file, line, column) — hover and go-to-definition, whether the cursor sits on a use or the declaration.

Source

pub fn find_declaration_at( &self, file: FileId, line: u32, column: u32, ) -> Option<&Symbol>

The symbol declared at (file, line, column), if any.

Trait Implementations§

Source§

impl Clone for SymbolTable

Source§

fn clone(&self) -> SymbolTable

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SymbolTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.