pub struct Sources { /* private fields */ }
Expand description
Register of loaded source files and their syntax trees.
Source file definitions (SourceFile
) are stored in a vector (Vec<Rc<SourceFile>>
)
and mapped by hash, path and name via index to this vector.
The root model (given at creation) will be stored but will only be accessible by hash and path but not by it’s qualified name.
Implementations§
Source§impl Sources
impl Sources
Sourcepub fn load(root: Rc<SourceFile>, search_paths: &[PathBuf]) -> ParseResult<Self>
pub fn load(root: Rc<SourceFile>, search_paths: &[PathBuf]) -> ParseResult<Self>
Create source cache
Inserts the root
file and loads all files from search_paths
.
Sourcepub fn root(&self) -> Rc<SourceFile>
pub fn root(&self) -> Rc<SourceFile>
Return root file.
Sourcepub fn resolve(&self) -> ResolveResult<SymbolMap>
pub fn resolve(&self) -> ResolveResult<SymbolMap>
Create initial symbol map from externals.
Sourcepub fn name_by_path(&self, filename: &Path) -> ResolveResult<QualifiedName>
pub fn name_by_path(&self, filename: &Path) -> ResolveResult<QualifiedName>
Return the qualified name of a file by it’s path
Sourcepub fn get_by_src_ref(
&self,
referrer: &impl SrcReferrer,
) -> ResolveResult<Rc<SourceFile>>
pub fn get_by_src_ref( &self, referrer: &impl SrcReferrer, ) -> ResolveResult<Rc<SourceFile>>
Convenience function to get a source file by from a SrcReferrer
.
Sourcepub fn ref_str(&self, referrer: &impl SrcReferrer) -> String
pub fn ref_str(&self, referrer: &impl SrcReferrer) -> String
Return a string describing the given source code position.
Sourcepub fn get_by_path(&self, path: &Path) -> ResolveResult<Rc<SourceFile>>
pub fn get_by_path(&self, path: &Path) -> ResolveResult<Rc<SourceFile>>
Find a project file by it’s file path.
Sourcepub fn get_name_by_hash(&self, hash: u64) -> ResolveResult<&QualifiedName>
pub fn get_name_by_hash(&self, hash: u64) -> ResolveResult<&QualifiedName>
Get qualified name of a file by hash value.
Sourcepub fn get_by_name(&self, name: &QualifiedName) -> ResolveResult<Rc<SourceFile>>
pub fn get_by_name(&self, name: &QualifiedName) -> ResolveResult<Rc<SourceFile>>
Find a project file by the qualified name which represents the file path.
Sourcepub fn search_paths(&self) -> &Vec<PathBuf>
pub fn search_paths(&self) -> &Vec<PathBuf>
Return search paths of this cache.
Trait Implementations§
Source§impl GetSourceByHash for Sources
impl GetSourceByHash for Sources
Source§fn get_by_hash(&self, hash: u64) -> ResolveResult<Rc<SourceFile>>
fn get_by_hash(&self, hash: u64) -> ResolveResult<Rc<SourceFile>>
Find a project file by it’s hash value.
Auto Trait Implementations§
impl Freeze for Sources
impl !RefUnwindSafe for Sources
impl !Send for Sources
impl !Sync for Sources
impl Unpin for Sources
impl !UnwindSafe for Sources
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string()
Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString
. Read more