pub struct SourceMap { /* private fields */ }Expand description
Source map that tracks all mappings from Rust to Windjammer
Implementations§
Source§impl SourceMap
impl SourceMap
Sourcepub fn set_workspace_root(&mut self, root: impl Into<PathBuf>)
pub fn set_workspace_root(&mut self, root: impl Into<PathBuf>)
Set the workspace root for relative path calculation
Sourcepub fn add_mapping(
&mut self,
rust_file: impl Into<PathBuf>,
rust_line: usize,
rust_column: usize,
wj_file: impl Into<PathBuf>,
wj_line: usize,
wj_column: usize,
)
pub fn add_mapping( &mut self, rust_file: impl Into<PathBuf>, rust_line: usize, rust_column: usize, wj_file: impl Into<PathBuf>, wj_line: usize, wj_column: usize, )
Add a mapping from Rust location to Windjammer location If a workspace root is set, paths are automatically converted to relative paths
Sourcepub fn lookup(&self, rust_file: &Path, rust_line: usize) -> Option<&Mapping>
pub fn lookup(&self, rust_file: &Path, rust_line: usize) -> Option<&Mapping>
Look up the Windjammer location for a given Rust location
Sourcepub fn lookup_fuzzy(
&self,
rust_file: &Path,
rust_line: usize,
) -> Option<&Mapping>
pub fn lookup_fuzzy( &self, rust_file: &Path, rust_line: usize, ) -> Option<&Mapping>
Look up with fuzzy matching - finds the closest mapping if exact match not found
Sourcepub fn save_to_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
pub fn save_to_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
Save the source map to a JSON file
Sourcepub fn load_from_file(path: impl AsRef<Path>) -> Result<Self, Box<dyn Error>>
pub fn load_from_file(path: impl AsRef<Path>) -> Result<Self, Box<dyn Error>>
Load a source map from a JSON file
Sourcepub fn mappings_for_wj_file(&self, wj_file: &Path) -> Vec<&Mapping>
pub fn mappings_for_wj_file(&self, wj_file: &Path) -> Vec<&Mapping>
Get all mappings for a specific Windjammer file
Sourcepub fn mappings_for_rust_file(&self, rust_file: &Path) -> Vec<&Mapping>
pub fn mappings_for_rust_file(&self, rust_file: &Path) -> Vec<&Mapping>
Get all mappings for a specific Rust file
Sourcepub fn get_location(&self, rust_line: usize) -> Option<Location>
pub fn get_location(&self, rust_line: usize) -> Option<Location>
Get the Windjammer location for a given Rust line (backward compatibility)
This is a convenience method that returns a Location struct instead of a Mapping. Used by error_mapper.rs for translating Rust compiler errors.
Sourcepub fn map_rust_to_windjammer(
&self,
rust_location: &Location,
) -> Option<Location>
pub fn map_rust_to_windjammer( &self, rust_location: &Location, ) -> Option<Location>
Map a Rust location to a Windjammer location
This is the primary method used by error_mapper.rs to translate Rust compiler errors back to Windjammer source locations.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for SourceMap
impl<'de> Deserialize<'de> for SourceMap
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for SourceMap
impl RefUnwindSafe for SourceMap
impl Send for SourceMap
impl Sync for SourceMap
impl Unpin for SourceMap
impl UnsafeUnpin for SourceMap
impl UnwindSafe for SourceMap
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 more