CodebaseReflection

Struct CodebaseReflection 

Source
pub struct CodebaseReflection {
    pub constant_reflections: HashMap<Name, ConstantReflection>,
    pub constant_names: HashMap<StringIdentifier, Name>,
    pub function_like_reflections: HashMap<FunctionLikeName, FunctionLikeReflection>,
    pub function_names: HashMap<StringIdentifier, FunctionLikeName>,
    pub class_like_reflections: HashMap<ClassLikeName, ClassLikeReflection>,
    pub class_like_names: HashMap<StringIdentifier, ClassLikeName>,
    pub direct_classlike_descendants: HashMap<StringIdentifier, HashSet<StringIdentifier>>,
    pub all_classlike_descendants: HashMap<StringIdentifier, HashSet<StringIdentifier>>,
    pub populated: bool,
}

Fields§

§constant_reflections: HashMap<Name, ConstantReflection>

Reflections for all constants in the codebase, keyed by their Name.

§constant_names: HashMap<StringIdentifier, Name>

Mapping of constant names to their canonical Name representations.

§function_like_reflections: HashMap<FunctionLikeName, FunctionLikeReflection>

Reflections for all function-like entities (functions, closures, etc.), keyed by their FunctionLikeName.

§function_names: HashMap<StringIdentifier, FunctionLikeName>

Mapping of function-like names to their canonical FunctionLikeName representations.

§class_like_reflections: HashMap<ClassLikeName, ClassLikeReflection>

Reflections for all class-like entities (classes, traits, enums, interfaces), keyed by their ClassLikeName.

§class_like_names: HashMap<StringIdentifier, ClassLikeName>

Mapping of class-like names to their canonical ClassLikeName representations.

§direct_classlike_descendants: HashMap<StringIdentifier, HashSet<StringIdentifier>>

Direct descendants of each class-like entity, useful for hierarchy traversal.

§all_classlike_descendants: HashMap<StringIdentifier, HashSet<StringIdentifier>>

All descendants of each class-like entity, useful for comprehensive hierarchy analysis.

§populated: bool

Indicates whether all entities in the codebase have been fully populated.

Implementations§

Source§

impl CodebaseReflection

Source

pub fn new() -> Self

Creates a new, empty CodebaseReflection.

§Returns

A new instance of CodebaseReflection with populated set to false and all internal collections initialized to their default states.

Source

pub fn with_capacity(capacity: usize) -> Self

Create a new CodebaseReflection with a specified capacity.

§Arguments
  • capacity: The initial capacity for the internal collections.
§Returns

A new instance of CodebaseReflection with the internal collections pre-allocated to the specified capacity.

Source

pub fn is_empty(&self) -> bool

Checks if the codebase reflection is empty.

§Returns
  • true if the codebase reflection is empty.
  • false otherwise.
Source

pub fn merge(&mut self, interner: &ThreadedInterner, other: CodebaseReflection)

Merges another CodebaseReflection into this one.

This method combines the codebase reflections and issues from two CodebaseReflection instances into a single CodebaseReflection. If duplicates are found during merging (such as functions, classes, or constants with identical names), they are ignored.

§Arguments
  • interner: A ThreadedInterner instance for name handling.
  • other: The CodebaseReflection to merge into this one.
§Effects

This method modifies the current CodebaseReflection instance in place.

§Notes

This method invalidates the populated flag, as the codebase may have changed, unless the other reflection is empty, in which case no changes are made.

Source

pub fn register_constant( &mut self, interner: &ThreadedInterner, reflection: ConstantReflection, ) -> bool

Registers a new constant in the codebase.

This method ensures that the constant is uniquely registered, accounting for case-insensitive names. If a constant with the same name already exists, it will not be registered again.

§Arguments
  • interner: A ThreadedInterner instance for name handling.
  • reflection: The ConstantReflection to register.
§Returns
  • true if the constant was successfully registered.
  • false if the constant already exists.
Source

pub fn register_function_like( &mut self, interner: &ThreadedInterner, reflection: FunctionLikeReflection, ) -> bool

Registers a new function-like entity (e.g., function, closure, or arrow function) in the codebase.

This method ensures that the function-like entity is uniquely registered, accounting for case-insensitive names. If an entity with the same name already exists, it will not be registered again.

§Arguments
  • interner: A ThreadedInterner instance for name handling.
  • reflection: The FunctionLikeReflection to register.
§Returns
  • true if the entity was successfully registered.
  • false if the entity already exists.
Source

pub fn register_class_like( &mut self, interner: &ThreadedInterner, reflection: ClassLikeReflection, ) -> bool

Registers a new class-like entity (e.g., class, interface, trait, or enum) in the codebase.

This method ensures that the class-like entity is uniquely registered, accounting for case-insensitive names. If an entity with the same name already exists, it will not be registered again.

§Arguments
  • interner: A ThreadedInterner instance for name handling.
  • reflection: The ClassLikeReflection to register.
§Returns
  • true if the entity was successfully registered.
  • false if the entity already exists.
Source

pub fn constant_exists( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> bool

Checks if a constant exists in the codebase.

§Arguments
  • interner: A ThreadedInterner instance for name handling.
  • id: A StringIdentifier representing the constant’s name.
§Returns
  • true if the constant exists.
  • false otherwise.
Source

pub fn function_exists( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> bool

Checks if a function exists in the codebase.

§Arguments
  • interner: A ThreadedInterner instance for name handling.
  • id: A StringIdentifier representing the function’s name.
§Returns
  • true if the function exists.
  • false otherwise.
Source

pub fn class_exists( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> bool

Checks if a class exists in the codebase.

§Arguments
  • interner: A ThreadedInterner instance for name handling.
  • id: A StringIdentifier representing the class’s name.
§Returns
  • true if the class exists.
  • false otherwise.
Source

pub fn enum_exists( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> bool

Checks if an enum exists in the codebase.

§Arguments
  • interner: A ThreadedInterner instance for name handling.
  • id: A StringIdentifier representing the enum’s name.
§Returns
  • true if the enum exists.
  • false otherwise.
Source

pub fn interface_exists( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> bool

Checks if an interface exists in the codebase.

§Arguments
  • interner: A ThreadedInterner instance for name handling.
  • id: A StringIdentifier representing the interface’s name.
§Returns
  • true if the interface exists.
  • false otherwise.
Source

pub fn trait_exists( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> bool

Checks if a trait exists in the codebase.

§Arguments
  • interner: A ThreadedInterner instance for name handling.
  • id: A StringIdentifier representing the trait’s name.
§Returns
  • true if the trait exists.
  • false otherwise.
Source

pub fn get_constant( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> Option<&ConstantReflection>

Retrieves a constant reflection by name, if it exists.

§Arguments
  • interner: A ThreadedInterner instance for name handling.
  • id: A StringIdentifier representing the constant’s name.
§Returns
  • Some(&ConstantReflection) if the constant exists.
  • None otherwise.
Source

pub fn get_function_like( &self, name: FunctionLikeName, ) -> Option<&FunctionLikeReflection>

Retrieves a function-like reflection by its name, if it exists.

§Arguments
  • name: The name of the function-like entity as a FunctionLikeName.
§Returns
  • Some(&FunctionLikeReflection) if the function-like entity exists.
  • None otherwise.
Source

pub fn get_function( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> Option<&FunctionLikeReflection>

Retrieves a function reflection by name, if it exists.

§Arguments
  • interner: A ThreadedInterner instance for name handling.
  • id: A StringIdentifier representing the function’s name.
§Returns
  • Some(&FunctionLikeReflection) if the function exists.
  • None otherwise.
Source

pub fn get_closure( &self, position: &impl HasPosition, ) -> Option<&FunctionLikeReflection>

Retrieves a closure reflection by its position, if it exists.

§Arguments
  • position: The position to search for as an implementation of HasPosition.
§Returns
  • Some(&FunctionLikeReflection) if the closure exists at the given position.
  • None otherwise.
Source

pub fn get_arrow_function( &self, position: &impl HasPosition, ) -> Option<&FunctionLikeReflection>

Retrieves an arrow function reflection by its position, if it exists.

§Arguments
  • position: The position to search for as an implementation of HasPosition.
§Returns
  • Some(&FunctionLikeReflection) if the arrow function exists at the given position.
  • None otherwise.
Source

pub fn get_class_like( &self, name: &ClassLikeName, ) -> Option<&ClassLikeReflection>

Retrieves a class-like reflection by its identifier, if it exists.

§Arguments
  • name: The ClassLikeName representing the class-like entity.
§Returns
  • Some(&ClassLikeReflection) if the class-like entity exists.
  • None otherwise.
Source

pub fn get_named_class_like( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> Option<&ClassLikeReflection>

Retrieves a class-like reflection by its name, if it exists.

§Arguments
  • interner: A ThreadedInterner instance for name handling.
  • id: A StringIdentifier representing the class-like entity’s name.
§Returns
  • Some(&ClassLikeReflection) if the class-like entity exists.
  • None otherwise.
Source

pub fn get_class( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> Option<&ClassLikeReflection>

Retrieves a class reflection by its name, if it exists.

§Arguments
  • interner: A ThreadedInterner instance for name handling.
  • id: A StringIdentifier representing the class’s name.
§Returns
  • Some(&ClassLikeReflection) if the class exists.
  • None otherwise.
Source

pub fn get_enum( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> Option<&ClassLikeReflection>

Retrieves an enum reflection by its name, if it exists.

§Arguments
  • interner: A ThreadedInterner instance for name handling.
  • id: A StringIdentifier representing the enum’s name.
§Returns
  • Some(&ClassLikeReflection) if the enum exists.
  • None otherwise.
Source

pub fn get_interface( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> Option<&ClassLikeReflection>

Retrieves an interface reflection by its name, if it exists.

§Arguments
  • interner: A ThreadedInterner instance for name handling.
  • id: A StringIdentifier representing the interface’s name.
§Returns
  • Some(&ClassLikeReflection) if the interface exists.
  • None otherwise.
Source

pub fn get_trait( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> Option<&ClassLikeReflection>

Retrieves a trait reflection by its name, if it exists.

§Arguments
  • interner: A ThreadedInterner instance for name handling.
  • id: A StringIdentifier representing the trait’s name.
§Returns
  • Some(&ClassLikeReflection) if the trait exists.
  • None otherwise.
Source

pub fn get_anonymous_class( &self, node: &impl HasSpan, ) -> Option<&ClassLikeReflection>

Retrieves an anonymous class reflection by its span, if it exists.

§Arguments
  • node: The node containing the span as an implementation of HasSpan.
§Returns
  • Some(&ClassLikeReflection) if the anonymous class exists.
  • None otherwise.
Source

pub fn get_method<'a>( &'a self, interner: &ThreadedInterner, class: &'a ClassLikeReflection, method: &StringIdentifier, ) -> Option<&'a FunctionLikeReflection>

Retrieves a method reflection from a class-like entity by its name, if it exists.

This method first checks the class-like entity for the method. If the method is not found, it checks the class-like entity’s ancestors for the method.

§Arguments
  • class: The class-like reflection to search for the method.
  • method: The name of the method to retrieve.
§Returns
  • Some(&FunctionLikeReflection) if the method exists.
  • None otherwise.
Source

pub fn get_enclosing_function_like( &self, has_position: &impl HasPosition, ) -> Option<&FunctionLikeReflection>

Returns the function-like reflection (function, closure, etc.) that encloses the given offset.

This method iterates through the reflections in the codebase, filtering for function-like reflections that contain the given offset in their definition range. It returns the reflection with the largest starting offset, effectively finding the innermost function-like reflection containing the offset.

§Arguments
  • has_position - The position to search for.
§Returns
  • Option<&FunctionLikeReflection> - The enclosing function-like reflection, if found.
Source

pub fn get_enclosing_class_like( &self, has_position: &impl HasPosition, ) -> Option<&ClassLikeReflection>

Returns the class-like reflection (class, trait, etc.) that encloses the given offset.

This method iterates through the reflections in the codebase, filtering for class-like reflections that contain the given offset in their definition range. It returns the reflection with the largest starting offset, effectively finding the innermost class-like reflection containing the offset.

§Arguments
  • has_position - The position to search for.
§Returns
  • Option<&ClassLikeReflection> - The enclosing class-like reflection, if found.
Source

pub fn take_issues(&mut self) -> IssueCollection

Takes all issues from the codebase reflection and its children.

This method iterates over all constant, function-like, and class-like reflections in the codebase, collecting all issues found during the population of the metadata.

§Returns
  • An IssueCollection containing all issues found in the codebase and its children.

Trait Implementations§

Source§

impl Clone for CodebaseReflection

Source§

fn clone(&self) -> CodebaseReflection

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CodebaseReflection

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for CodebaseReflection

Source§

fn default() -> CodebaseReflection

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for CodebaseReflection

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for CodebaseReflection

Source§

fn eq(&self, other: &CodebaseReflection) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for CodebaseReflection

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for CodebaseReflection

Source§

impl StructuralPartialEq for CodebaseReflection

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,