pub struct CodebaseReflection {
pub constant_reflections: HashMap<Name, ConstantReflection>,
pub constant_identifiers: HashMap<StringIdentifier, Name>,
pub function_like_reflections: HashMap<FunctionLikeName, FunctionLikeReflection>,
pub function_identifiers: 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>§constant_identifiers: HashMap<StringIdentifier, Name>§function_like_reflections: HashMap<FunctionLikeName, FunctionLikeReflection>§function_identifiers: HashMap<StringIdentifier, FunctionLikeName>§class_like_reflections: HashMap<ClassLikeName, ClassLikeReflection>§class_like_names: HashMap<StringIdentifier, ClassLikeName>§direct_classlike_descendants: HashMap<StringIdentifier, HashSet<StringIdentifier>>§all_classlike_descendants: HashMap<StringIdentifier, HashSet<StringIdentifier>>§populated: boolImplementations§
Source§impl CodebaseReflection
impl CodebaseReflection
Sourcepub fn register_constant(&mut self, constant: ConstantReflection) -> bool
pub fn register_constant(&mut self, constant: ConstantReflection) -> bool
Registers a new constant in the codebase.
If the constant already exists, it will not be added again.
Returns false if the constant already exists.
Sourcepub fn register_function_like(
&mut self,
function_like: FunctionLikeReflection,
) -> bool
pub fn register_function_like( &mut self, function_like: FunctionLikeReflection, ) -> bool
Registers a new function-like entity in the codebase.
If the function-like entity already exists, it will not be added again.
Returns false if the function-like entity already exists.
Sourcepub fn register_class_like(&mut self, class_like: ClassLikeReflection) -> bool
pub fn register_class_like(&mut self, class_like: ClassLikeReflection) -> bool
Registers a new class-like entity (class, enum, interface, or trait) in the codebase.
If the class-like entity already exists, it will not be added again.
Returns false if the class-like entity already exists.
Sourcepub fn constant_exists(&self, name: &StringIdentifier) -> bool
pub fn constant_exists(&self, name: &StringIdentifier) -> bool
Checks if a constant with the given name exists.
Sourcepub fn function_exists(&self, name: &StringIdentifier) -> bool
pub fn function_exists(&self, name: &StringIdentifier) -> bool
Checks if a function with the given name exists.
Sourcepub fn class_exists(&self, name: &StringIdentifier) -> bool
pub fn class_exists(&self, name: &StringIdentifier) -> bool
Checks if a class with the given name exists.
Sourcepub fn enum_exists(&self, name: &StringIdentifier) -> bool
pub fn enum_exists(&self, name: &StringIdentifier) -> bool
Checks if an enum with the given name exists.
Sourcepub fn interface_exists(&self, name: &StringIdentifier) -> bool
pub fn interface_exists(&self, name: &StringIdentifier) -> bool
Checks if an interface with the given name exists.
Sourcepub fn trait_exists(&self, name: &StringIdentifier) -> bool
pub fn trait_exists(&self, name: &StringIdentifier) -> bool
Checks if a trait with the given name exists.
Sourcepub fn get_constant(
&self,
name: &StringIdentifier,
) -> Option<&ConstantReflection>
pub fn get_constant( &self, name: &StringIdentifier, ) -> Option<&ConstantReflection>
Retrieves a constant by name, if it exists.
Sourcepub fn get_function_like(
&self,
identifier: FunctionLikeName,
) -> Option<&FunctionLikeReflection>
pub fn get_function_like( &self, identifier: FunctionLikeName, ) -> Option<&FunctionLikeReflection>
Retrieves a function-like by its identifier, if it exists.
Sourcepub fn get_function(
&self,
name: &StringIdentifier,
) -> Option<&FunctionLikeReflection>
pub fn get_function( &self, name: &StringIdentifier, ) -> Option<&FunctionLikeReflection>
Retrieves a function by name, if it exists.
Sourcepub fn get_closure(
&self,
position: &impl HasPosition,
) -> Option<&FunctionLikeReflection>
pub fn get_closure( &self, position: &impl HasPosition, ) -> Option<&FunctionLikeReflection>
Retrieves a closure by its position, if it exists.
Sourcepub fn get_arrow_function(
&self,
position: &impl HasPosition,
) -> Option<&FunctionLikeReflection>
pub fn get_arrow_function( &self, position: &impl HasPosition, ) -> Option<&FunctionLikeReflection>
Retrieves an arrow function by its position, if it exists.
Sourcepub fn get_class_like(
&self,
identifier: ClassLikeName,
) -> Option<&ClassLikeReflection>
pub fn get_class_like( &self, identifier: ClassLikeName, ) -> Option<&ClassLikeReflection>
Retrieves a class-like entity by its identifier, if it exists.
Sourcepub fn get_named_class_like(
&self,
name: &StringIdentifier,
) -> Option<&ClassLikeReflection>
pub fn get_named_class_like( &self, name: &StringIdentifier, ) -> Option<&ClassLikeReflection>
Retrieves a class-like entity by its name, if it exists.
Sourcepub fn get_class(&self, name: &StringIdentifier) -> Option<&ClassLikeReflection>
pub fn get_class(&self, name: &StringIdentifier) -> Option<&ClassLikeReflection>
Retrieves a class by name, if it exists.
Sourcepub fn get_enum(&self, name: &StringIdentifier) -> Option<&ClassLikeReflection>
pub fn get_enum(&self, name: &StringIdentifier) -> Option<&ClassLikeReflection>
Retrieves an enum by name, if it exists.
Sourcepub fn get_interface(
&self,
name: &StringIdentifier,
) -> Option<&ClassLikeReflection>
pub fn get_interface( &self, name: &StringIdentifier, ) -> Option<&ClassLikeReflection>
Retrieves an interface by name, if it exists.
Sourcepub fn get_trait(&self, name: &StringIdentifier) -> Option<&ClassLikeReflection>
pub fn get_trait(&self, name: &StringIdentifier) -> Option<&ClassLikeReflection>
Retrieves a trait by name, if it exists.
Sourcepub fn get_enclosing_function_like(
&self,
has_position: &impl HasPosition,
) -> Option<&FunctionLikeReflection>
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.
Sourcepub fn get_enclosing_class_like(
&self,
has_position: &impl HasPosition,
) -> Option<&ClassLikeReflection>
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.
Trait Implementations§
Source§impl Clone for CodebaseReflection
impl Clone for CodebaseReflection
Source§fn clone(&self) -> CodebaseReflection
fn clone(&self) -> CodebaseReflection
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more