pub struct FileResolver<'a> { /* private fields */ }
Expand description
Performs file resolution by applying import paths and mappings.
Implementations§
Source§impl<'a> FileResolver<'a>
impl<'a> FileResolver<'a>
Sourcepub fn set_current_dir(&mut self, current_dir: &Path)
pub fn set_current_dir(&mut self, current_dir: &Path)
Sourcepub fn add_include_paths(&mut self, paths: impl IntoIterator<Item = PathBuf>)
pub fn add_include_paths(&mut self, paths: impl IntoIterator<Item = PathBuf>)
Adds include paths.
Sourcepub fn add_include_path(&mut self, path: PathBuf)
pub fn add_include_path(&mut self, path: PathBuf)
Adds an include path.
Sourcepub fn add_import_remappings(
&mut self,
remappings: impl IntoIterator<Item = ImportRemapping>,
)
pub fn add_import_remappings( &mut self, remappings: impl IntoIterator<Item = ImportRemapping>, )
Adds import remappings.
Sourcepub fn add_import_remapping(&mut self, remapping: ImportRemapping)
pub fn add_import_remapping(&mut self, remapping: ImportRemapping)
Adds an import remapping.
Sourcepub fn source_map(&self) -> &'a SourceMap
pub fn source_map(&self) -> &'a SourceMap
Returns the source map.
Sourcepub fn current_dir(&self) -> &Path
pub fn current_dir(&self) -> &Path
Returns the current directory, or .
if it could not be resolved.
Sourcepub fn try_current_dir(&self) -> Option<&Path>
pub fn try_current_dir(&self) -> Option<&Path>
Returns the current directory, if resolved successfully.
Sourcepub fn canonicalize(&self, path: &Path) -> Result<PathBuf>
pub fn canonicalize(&self, path: &Path) -> Result<PathBuf>
Canonicalizes a path using Self::current_dir
.
Sourcepub fn normalize<'b>(&self, path: &'b Path) -> Cow<'b, Path>
pub fn normalize<'b>(&self, path: &'b Path) -> Cow<'b, Path>
Normalizes a path removing unnecessary components.
Does not perform I/O.
Sourcepub fn make_absolute<'b>(&self, path: &'b Path) -> Cow<'b, Path>
pub fn make_absolute<'b>(&self, path: &'b Path) -> Cow<'b, Path>
Makes the path absolute by joining it with the current directory.
Does not perform I/O.
Sourcepub fn resolve_file(
&self,
path: &Path,
parent: Option<&Path>,
) -> Result<Arc<SourceFile>, ResolveError>
pub fn resolve_file( &self, path: &Path, parent: Option<&Path>, ) -> Result<Arc<SourceFile>, ResolveError>
Resolves an import path.
parent
is the path of the file that contains the import, if any.
Sourcepub fn remap_path<'b>(
&self,
path: &'b Path,
parent: Option<&Path>,
) -> Cow<'b, Path>
pub fn remap_path<'b>( &self, path: &'b Path, parent: Option<&Path>, ) -> Cow<'b, Path>
Applies the import path mappings to path
.
Sourcepub fn load_stdin(&self) -> Result<Arc<SourceFile>, ResolveError>
pub fn load_stdin(&self) -> Result<Arc<SourceFile>, ResolveError>
Loads stdin into the source map.
Sourcepub fn try_file(
&self,
path: &Path,
) -> Result<Option<Arc<SourceFile>>, ResolveError>
pub fn try_file( &self, path: &Path, ) -> Result<Option<Arc<SourceFile>>, ResolveError>
Loads path
into the source map. Returns None
if the file doesn’t exist.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for FileResolver<'a>
impl<'a> !RefUnwindSafe for FileResolver<'a>
impl<'a> Send for FileResolver<'a>
impl<'a> Sync for FileResolver<'a>
impl<'a> Unpin for FileResolver<'a>
impl<'a> !UnwindSafe for FileResolver<'a>
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
Mutably borrows from an owned value. Read more
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
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> ⓘ
Converts
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> ⓘ
Converts
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