pub trait SourceManager: Debug {
Show 14 methods
// Required methods
fn load_from_raw_parts(
&self,
name: Uri,
content: SourceContent,
) -> Arc<SourceFile>;
fn update(
&self,
id: SourceId,
text: String,
range: Option<Selection>,
version: i32,
) -> Result<(), SourceManagerError>;
fn get(&self, id: SourceId) -> Result<Arc<SourceFile>, SourceManagerError>;
fn find(&self, uri: &Uri) -> 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,
lang: SourceLanguage,
name: Uri,
content: String,
) -> Arc<SourceFile> { ... }
fn get_by_uri(&self, uri: &Uri) -> Option<Arc<SourceFile>> { ... }
}
Required Methods§
Sourcefn load_from_raw_parts(
&self,
name: Uri,
content: SourceContent,
) -> Arc<SourceFile>
fn load_from_raw_parts( &self, name: Uri, content: SourceContent, ) -> Arc<SourceFile>
Load content into this SourceManager from raw SourceFile components
Sourcefn update(
&self,
id: SourceId,
text: String,
range: Option<Selection>,
version: i32,
) -> Result<(), SourceManagerError>
fn update( &self, id: SourceId, text: String, range: Option<Selection>, version: i32, ) -> Result<(), SourceManagerError>
Update the source file corresponding to id
after being notified of a change event.
The version
indicates the new version of the document
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, uri: &Uri) -> Option<SourceId>
fn find(&self, uri: &Uri) -> Option<SourceId>
Search for a source file whose URI is uri
, 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,
lang: SourceLanguage,
name: Uri,
content: String,
) -> Arc<SourceFile>
fn load( &self, lang: SourceLanguage, name: Uri, content: String, ) -> Arc<SourceFile>
Load the given content
into this SourceManager with name
Sourcefn get_by_uri(&self, uri: &Uri) -> Option<Arc<SourceFile>>
fn get_by_uri(&self, uri: &Uri) -> Option<Arc<SourceFile>>
Get the most recent SourceFile whose URI is uri