Skip to main content

SymbolTable

Struct SymbolTable 

Source
pub struct SymbolTable<'src> { /* private fields */ }
Expand description

Collected symbols and imports from a PHP source file.

Implementations§

Source§

impl<'src> SymbolTable<'src>

Source

pub fn build<'arena>(program: &Program<'arena, 'src>) -> Self

Walk the program AST and extract all declarations.

Source

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

All collected symbols.

Source

pub fn imports(&self) -> &[UseImport<'src>]

All use imports.

Source

pub fn symbols_of_kind( &self, kind: SymbolKind, ) -> impl Iterator<Item = &Symbol<'src>>

Iterate symbols of a specific kind.

Source

pub fn find_by_fqn(&self, fqn: &str) -> Option<&Symbol<'src>>

Find a symbol by its fully qualified name.

Source

pub fn symbols_at(&self, offset: u32) -> Vec<&Symbol<'src>>

Find all symbols at a given byte offset (i.e. whose span contains the offset).

Source

pub fn resolve_name(&self, name: &str) -> Option<&str>

Resolve a simple (unqualified) name using the imports and current namespace. Returns the FQN if found, None otherwise.

Source

pub fn functions(&self) -> impl Iterator<Item = &Symbol<'src>>

Convenience: all functions.

Source

pub fn classes(&self) -> impl Iterator<Item = &Symbol<'src>>

Convenience: all classes.

Source

pub fn interfaces(&self) -> impl Iterator<Item = &Symbol<'src>>

Convenience: all interfaces.

Source

pub fn traits(&self) -> impl Iterator<Item = &Symbol<'src>>

Convenience: all traits.

Source

pub fn enums(&self) -> impl Iterator<Item = &Symbol<'src>>

Convenience: all enums.

Source

pub fn constants(&self) -> impl Iterator<Item = &Symbol<'src>>

Convenience: all constants.

Source

pub fn members_of<'a>( &'a self, parent_fqn: &'a str, ) -> impl Iterator<Item = &'a Symbol<'src>>

Get all members (methods, properties, class constants, enum cases) of a given parent FQN.

Auto Trait Implementations§

§

impl<'src> Freeze for SymbolTable<'src>

§

impl<'src> RefUnwindSafe for SymbolTable<'src>

§

impl<'src> Send for SymbolTable<'src>

§

impl<'src> Sync for SymbolTable<'src>

§

impl<'src> Unpin for SymbolTable<'src>

§

impl<'src> UnsafeUnpin for SymbolTable<'src>

§

impl<'src> UnwindSafe for SymbolTable<'src>

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> 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, 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.