Skip to main content

SourceManager

Trait SourceManager 

Source
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§

Source

fn load_from_raw_parts( &self, name: Uri, content: SourceContent, ) -> Arc<SourceFile>

Load content into this SourceManager from raw SourceFile components

Source

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

Source

fn get(&self, id: SourceId) -> Result<Arc<SourceFile>, SourceManagerError>

Get the SourceFile corresponding to id

Source

fn find(&self, uri: &Uri) -> Option<SourceId>

Search for a source file whose URI is uri, and return its SourceId if found.

Source

fn file_line_col_to_span(&self, loc: FileLineCol) -> Option<SourceSpan>

Convert a FileLineCol to an equivalent SourceSpan, if the referenced file is available

Source

fn file_line_col( &self, span: SourceSpan, ) -> Result<FileLineCol, SourceManagerError>

Convert a SourceSpan to an equivalent FileLineCol, if the span is valid

Source

fn location_to_span(&self, loc: Location) -> Option<SourceSpan>

Convert a Location to an equivalent SourceSpan, if the referenced file is available

Source

fn location(&self, span: SourceSpan) -> Result<Location, SourceManagerError>

Convert a SourceSpan to an equivalent Location, if the span is valid

Source

fn source(&self, id: SourceId) -> Result<&str, SourceManagerError>

Get the source associated with id as a string slice

Source

fn source_slice(&self, span: SourceSpan) -> Result<&str, SourceManagerError>

Get the source corresponding to span as a string slice

Provided Methods§

Source

fn is_manager_of(&self, file: &SourceFile) -> bool

Returns true if file is managed by this source manager

Source

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.

Source

fn load( &self, lang: SourceLanguage, name: Uri, content: String, ) -> Arc<SourceFile>

Load the given content into this SourceManager with name

Source

fn get_by_uri(&self, uri: &Uri) -> Option<Arc<SourceFile>>

Get the most recent SourceFile whose URI is uri

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> SourceManager for Arc<T>
where T: SourceManager + ?Sized,

Source§

fn is_manager_of(&self, file: &SourceFile) -> bool

Source§

fn copy_into(&self, file: &SourceFile) -> Arc<SourceFile>

Source§

fn load( &self, lang: SourceLanguage, uri: Uri, content: String, ) -> Arc<SourceFile>

Source§

fn load_from_raw_parts( &self, uri: Uri, content: SourceContent, ) -> Arc<SourceFile>

Source§

fn update( &self, id: SourceId, text: String, range: Option<Selection>, version: i32, ) -> Result<(), SourceManagerError>

Source§

fn get(&self, id: SourceId) -> Result<Arc<SourceFile>, SourceManagerError>

Source§

fn get_by_uri(&self, uri: &Uri) -> Option<Arc<SourceFile>>

Source§

fn find(&self, uri: &Uri) -> Option<SourceId>

Source§

fn file_line_col_to_span(&self, loc: FileLineCol) -> Option<SourceSpan>

Source§

fn file_line_col( &self, span: SourceSpan, ) -> Result<FileLineCol, SourceManagerError>

Source§

fn location_to_span(&self, loc: Location) -> Option<SourceSpan>

Source§

fn location(&self, span: SourceSpan) -> Result<Location, SourceManagerError>

Source§

fn source(&self, id: SourceId) -> Result<&str, SourceManagerError>

Source§

fn source_slice(&self, span: SourceSpan) -> Result<&str, SourceManagerError>

Implementors§