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: boolIndicates whether all entities in the codebase have been fully populated.
Implementations§
Source§impl CodebaseReflection
impl CodebaseReflection
Sourcepub fn new() -> Self
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.
Sourcepub fn register_constant(
&mut self,
interner: &ThreadedInterner,
reflection: ConstantReflection,
) -> bool
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: AThreadedInternerinstance for name handling.reflection: TheConstantReflectionto register.
§Returns
trueif the constant was successfully registered.falseif the constant already exists.
Sourcepub fn register_function_like(
&mut self,
interner: &ThreadedInterner,
reflection: FunctionLikeReflection,
) -> bool
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: AThreadedInternerinstance for name handling.reflection: TheFunctionLikeReflectionto register.
§Returns
trueif the entity was successfully registered.falseif the entity already exists.
Sourcepub fn register_class_like(
&mut self,
interner: &ThreadedInterner,
reflection: ClassLikeReflection,
) -> bool
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: AThreadedInternerinstance for name handling.reflection: TheClassLikeReflectionto register.
§Returns
trueif the entity was successfully registered.falseif the entity already exists.
Sourcepub fn constant_exists(
&self,
interner: &ThreadedInterner,
id: &StringIdentifier,
) -> bool
pub fn constant_exists( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> bool
Sourcepub fn function_exists(
&self,
interner: &ThreadedInterner,
id: &StringIdentifier,
) -> bool
pub fn function_exists( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> bool
Sourcepub fn class_exists(
&self,
interner: &ThreadedInterner,
id: &StringIdentifier,
) -> bool
pub fn class_exists( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> bool
Sourcepub fn enum_exists(
&self,
interner: &ThreadedInterner,
id: &StringIdentifier,
) -> bool
pub fn enum_exists( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> bool
Sourcepub fn interface_exists(
&self,
interner: &ThreadedInterner,
id: &StringIdentifier,
) -> bool
pub fn interface_exists( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> bool
Sourcepub fn trait_exists(
&self,
interner: &ThreadedInterner,
id: &StringIdentifier,
) -> bool
pub fn trait_exists( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> bool
Sourcepub fn get_constant(
&self,
interner: &ThreadedInterner,
id: &StringIdentifier,
) -> Option<&ConstantReflection>
pub fn get_constant( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> Option<&ConstantReflection>
Sourcepub fn get_function_like(
&self,
name: FunctionLikeName,
) -> Option<&FunctionLikeReflection>
pub fn get_function_like( &self, name: FunctionLikeName, ) -> Option<&FunctionLikeReflection>
Sourcepub fn get_function(
&self,
interner: &ThreadedInterner,
id: &StringIdentifier,
) -> Option<&FunctionLikeReflection>
pub fn get_function( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> Option<&FunctionLikeReflection>
Sourcepub fn get_closure(
&self,
position: &impl HasPosition,
) -> Option<&FunctionLikeReflection>
pub fn get_closure( &self, position: &impl HasPosition, ) -> Option<&FunctionLikeReflection>
Sourcepub fn get_arrow_function(
&self,
position: &impl HasPosition,
) -> Option<&FunctionLikeReflection>
pub fn get_arrow_function( &self, position: &impl HasPosition, ) -> Option<&FunctionLikeReflection>
Sourcepub fn get_class_like(
&self,
name: ClassLikeName,
) -> Option<&ClassLikeReflection>
pub fn get_class_like( &self, name: ClassLikeName, ) -> Option<&ClassLikeReflection>
Sourcepub fn get_named_class_like(
&self,
interner: &ThreadedInterner,
id: &StringIdentifier,
) -> Option<&ClassLikeReflection>
pub fn get_named_class_like( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> Option<&ClassLikeReflection>
Sourcepub fn get_class(
&self,
interner: &ThreadedInterner,
id: &StringIdentifier,
) -> Option<&ClassLikeReflection>
pub fn get_class( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> Option<&ClassLikeReflection>
Sourcepub fn get_enum(
&self,
interner: &ThreadedInterner,
id: &StringIdentifier,
) -> Option<&ClassLikeReflection>
pub fn get_enum( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> Option<&ClassLikeReflection>
Sourcepub fn get_interface(
&self,
interner: &ThreadedInterner,
id: &StringIdentifier,
) -> Option<&ClassLikeReflection>
pub fn get_interface( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> Option<&ClassLikeReflection>
Sourcepub fn get_trait(
&self,
interner: &ThreadedInterner,
id: &StringIdentifier,
) -> Option<&ClassLikeReflection>
pub fn get_trait( &self, interner: &ThreadedInterner, id: &StringIdentifier, ) -> Option<&ClassLikeReflection>
Sourcepub fn get_anonymous_class(
&self,
node: &impl HasSpan,
) -> Option<&ClassLikeReflection>
pub fn get_anonymous_class( &self, node: &impl HasSpan, ) -> Option<&ClassLikeReflection>
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