pub trait SourceManager: Debug {
Show 13 methods
// Required methods
fn load_from_raw_parts(
&self,
name: Arc<str>,
content: SourceContent,
) -> Arc<SourceFile>;
fn get(&self, id: SourceId) -> Result<Arc<SourceFile>, SourceManagerError>;
fn find(&self, name: &str) -> Option<SourceId>;
fn file_line_col_to_span(&self, loc: FileLineCol) -> Option<SourceSpan>;
fn file_line_col(
&self,
span: SourceSpan,
) -> Result<FileLineCol, SourceManagerError>;
fn location_to_span(&self, loc: Location) -> Option<SourceSpan>;
fn location(&self, span: SourceSpan) -> Result<Location, SourceManagerError>;
fn source(&self, id: SourceId) -> Result<&str, SourceManagerError>;
fn source_slice(&self, span: SourceSpan) -> Result<&str, SourceManagerError>;
// Provided methods
fn is_manager_of(&self, file: &SourceFile) -> bool { ... }
fn copy_into(&self, file: &SourceFile) -> Arc<SourceFile> { ... }
fn load(&self, name: &str, content: String) -> Arc<SourceFile> { ... }
fn get_by_path(&self, path: &str) -> Option<Arc<SourceFile>> { ... }
}
Required Methods§
Sourcefn load_from_raw_parts(
&self,
name: Arc<str>,
content: SourceContent,
) -> Arc<SourceFile>
fn load_from_raw_parts( &self, name: Arc<str>, content: SourceContent, ) -> Arc<SourceFile>
Load content into this SourceManager from raw SourceFile components
Sourcefn get(&self, id: SourceId) -> Result<Arc<SourceFile>, SourceManagerError>
fn get(&self, id: SourceId) -> Result<Arc<SourceFile>, SourceManagerError>
Get the SourceFile corresponding to id
Sourcefn find(&self, name: &str) -> Option<SourceId>
fn find(&self, name: &str) -> Option<SourceId>
Search for a source file named name
, and return its SourceId if found.
Sourcefn file_line_col_to_span(&self, loc: FileLineCol) -> Option<SourceSpan>
fn file_line_col_to_span(&self, loc: FileLineCol) -> Option<SourceSpan>
Convert a FileLineCol to an equivalent SourceSpan, if the referenced file is available
Sourcefn file_line_col(
&self,
span: SourceSpan,
) -> Result<FileLineCol, SourceManagerError>
fn file_line_col( &self, span: SourceSpan, ) -> Result<FileLineCol, SourceManagerError>
Convert a SourceSpan to an equivalent FileLineCol, if the span is valid
Sourcefn location_to_span(&self, loc: Location) -> Option<SourceSpan>
fn location_to_span(&self, loc: Location) -> Option<SourceSpan>
Convert a Location to an equivalent SourceSpan, if the referenced file is available
Sourcefn location(&self, span: SourceSpan) -> Result<Location, SourceManagerError>
fn location(&self, span: SourceSpan) -> Result<Location, SourceManagerError>
Convert a SourceSpan to an equivalent Location, if the span is valid
Sourcefn source(&self, id: SourceId) -> Result<&str, SourceManagerError>
fn source(&self, id: SourceId) -> Result<&str, SourceManagerError>
Get the source associated with id
as a string slice
Sourcefn source_slice(&self, span: SourceSpan) -> Result<&str, SourceManagerError>
fn source_slice(&self, span: SourceSpan) -> Result<&str, SourceManagerError>
Get the source corresponding to span
as a string slice
Provided Methods§
Sourcefn is_manager_of(&self, file: &SourceFile) -> bool
fn is_manager_of(&self, file: &SourceFile) -> bool
Returns true if file
is managed by this source manager
Sourcefn copy_into(&self, file: &SourceFile) -> Arc<SourceFile>
fn copy_into(&self, file: &SourceFile) -> Arc<SourceFile>
Copies file
into this source manager (if not already managed by this manager).
The returned source file is guaranteed to be owned by this manager.
Sourcefn load(&self, name: &str, content: String) -> Arc<SourceFile>
fn load(&self, name: &str, content: String) -> Arc<SourceFile>
Load the given content
into this SourceManager with name
Sourcefn get_by_path(&self, path: &str) -> Option<Arc<SourceFile>>
fn get_by_path(&self, path: &str) -> Option<Arc<SourceFile>>
Get the most recent SourceFile whose path is path