pub struct ParsingContext<'gcx> {
pub sess: &'gcx Session,
pub file_resolver: FileResolver<'gcx>,
/* private fields */
}Expand description
Builder for parsing sources into a Compiler.
Created from CompilerRef::parse.
§Examples
compiler.enter_mut(|compiler| {
let mut pcx = compiler.parse();
pcx.set_resolve_imports(false);
pcx.load_stdin();
pcx.parse();
});Fields§
§sess: &'gcx SessionThe compiler session.
file_resolver: FileResolver<'gcx>The file resolver.
Implementations§
Source§impl<'gcx> ParsingContext<'gcx>
impl<'gcx> ParsingContext<'gcx>
Sourcepub fn set_resolve_imports(&mut self, resolve_imports: bool)
pub fn set_resolve_imports(&mut self, resolve_imports: bool)
Sets whether to recursively resolve and parse imports.
Default: !sess.opts.unstable.no_resolve_imports, true.
Sourcepub fn resolve_file(
&self,
path: impl AsRef<Path>,
) -> Result<Arc<SourceFile>, ErrorGuaranteed>
pub fn resolve_file( &self, path: impl AsRef<Path>, ) -> Result<Arc<SourceFile>, ErrorGuaranteed>
Resolves a file.
Sourcepub fn resolve_files(
&self,
paths: impl IntoIterator<Item = impl AsRef<Path>>,
) -> impl Iterator<Item = Result<Arc<SourceFile>, ErrorGuaranteed>>
pub fn resolve_files( &self, paths: impl IntoIterator<Item = impl AsRef<Path>>, ) -> impl Iterator<Item = Result<Arc<SourceFile>, ErrorGuaranteed>>
Resolves a list of files.
Sourcepub fn par_resolve_files(
&self,
paths: impl IntoParallelIterator<Item = impl AsRef<Path>>,
) -> impl ParallelIterator<Item = Result<Arc<SourceFile>, ErrorGuaranteed>>
pub fn par_resolve_files( &self, paths: impl IntoParallelIterator<Item = impl AsRef<Path>>, ) -> impl ParallelIterator<Item = Result<Arc<SourceFile>, ErrorGuaranteed>>
Resolves a list of files in parallel.
Sourcepub fn load_stdin(&mut self) -> Result<(), ErrorGuaranteed>
pub fn load_stdin(&mut self) -> Result<(), ErrorGuaranteed>
Loads stdin into the context.
Sourcepub fn load_files(
&mut self,
paths: impl IntoIterator<Item = impl AsRef<Path>>,
) -> Result<(), ErrorGuaranteed>
pub fn load_files( &mut self, paths: impl IntoIterator<Item = impl AsRef<Path>>, ) -> Result<(), ErrorGuaranteed>
Loads files into the context.
Sourcepub fn par_load_files(
&mut self,
paths: impl IntoParallelIterator<Item = impl AsRef<Path>>,
) -> Result<(), ErrorGuaranteed>
pub fn par_load_files( &mut self, paths: impl IntoParallelIterator<Item = impl AsRef<Path>>, ) -> Result<(), ErrorGuaranteed>
Loads files into the context in parallel.
Sourcepub fn load_file(&mut self, path: &Path) -> Result<(), ErrorGuaranteed>
pub fn load_file(&mut self, path: &Path) -> Result<(), ErrorGuaranteed>
Loads a file into the context.
Sourcepub fn add_files(&mut self, files: impl IntoIterator<Item = Arc<SourceFile>>)
pub fn add_files(&mut self, files: impl IntoIterator<Item = Arc<SourceFile>>)
Adds a preloaded file to the resolver.
Sourcepub fn add_file(&mut self, file: Arc<SourceFile>)
pub fn add_file(&mut self, file: Arc<SourceFile>)
Adds a preloaded file to the resolver.
Sourcepub fn force_resolve_all_imports(self)
pub fn force_resolve_all_imports(self)
Resolves all the imports of all the loaded sources.
Trait Implementations§
Auto Trait Implementations§
impl<'gcx> !Freeze for ParsingContext<'gcx>
impl<'gcx> !RefUnwindSafe for ParsingContext<'gcx>
impl<'gcx> Send for ParsingContext<'gcx>
impl<'gcx> Sync for ParsingContext<'gcx>
impl<'gcx> Unpin for ParsingContext<'gcx>
impl<'gcx> !UnwindSafe for ParsingContext<'gcx>
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