Struct clang::TranslationUnit
source · [−]pub struct TranslationUnit<'i> { /* private fields */ }
Expand description
A preprocessed and parsed source file.
Implementations
sourceimpl<'i> TranslationUnit<'i>
impl<'i> TranslationUnit<'i>
sourcepub fn from_ast<F: AsRef<Path>>(
index: &'i Index<'_>,
file: F
) -> Result<TranslationUnit<'i>, ()>
pub fn from_ast<F: AsRef<Path>>(
index: &'i Index<'_>,
file: F
) -> Result<TranslationUnit<'i>, ()>
sourcepub fn get_diagnostics(&'i self) -> Vec<Diagnostic<'i>>
pub fn get_diagnostics(&'i self) -> Vec<Diagnostic<'i>>
Returns the diagnostics for this translation unit.
sourcepub fn get_entity(&'i self) -> Entity<'i>
pub fn get_entity(&'i self) -> Entity<'i>
Returns the entity for this translation unit.
sourcepub fn get_file<F: AsRef<Path>>(&'i self, file: F) -> Option<File<'i>>
pub fn get_file<F: AsRef<Path>>(&'i self, file: F) -> Option<File<'i>>
Returns the file at the supplied path in this translation unit, if any.
sourcepub fn get_memory_usage(&self) -> HashMap<MemoryUsage, usize>
pub fn get_memory_usage(&self) -> HashMap<MemoryUsage, usize>
Returns the memory usage of this translation unit.
sourcepub fn get_skipped_ranges(&'i self) -> Vec<SourceRange<'i>>
pub fn get_skipped_ranges(&'i self) -> Vec<SourceRange<'i>>
Returns the source ranges in this translation unit that were skipped by the preprocessor.
This will always return an empty Vec
if the translation unit was not constructed with a
detailed preprocessing record.
sourcepub fn get_target(&self) -> Target
pub fn get_target(&self) -> Target
Returns information about the target for this translation unit.
sourcepub fn annotate(&'i self, tokens: &[Token<'i>]) -> Vec<Option<Entity<'i>>>
pub fn annotate(&'i self, tokens: &[Token<'i>]) -> Vec<Option<Entity<'i>>>
Returns the AST entities which correspond to the supplied tokens, if any.
sourcepub fn completer<F: Into<PathBuf>>(
&self,
file: F,
line: u32,
column: u32
) -> Completer<'_>
pub fn completer<F: Into<PathBuf>>(
&self,
file: F,
line: u32,
column: u32
) -> Completer<'_>
Returns a completer which runs code completion.
sourcepub fn save<F: AsRef<Path>>(&self, file: F) -> Result<(), SaveError>
pub fn save<F: AsRef<Path>>(&self, file: F) -> Result<(), SaveError>
Saves this translation unit to an AST file.
Failures
- errors in the translation unit prevent saving
- an unknown error occurs
sourcepub fn reparse(
self,
unsaved: &[Unsaved]
) -> Result<TranslationUnit<'i>, SourceError>
pub fn reparse(
self,
unsaved: &[Unsaved]
) -> Result<TranslationUnit<'i>, SourceError>
Consumes this translation unit and reparses the source file it was created from with the same compiler arguments that were used originally.
Failures
- an error occurs while deserializing an AST file
libclang
crashes- an unknown error occurs
Trait Implementations
sourceimpl<'i> Debug for TranslationUnit<'i>
impl<'i> Debug for TranslationUnit<'i>
Auto Trait Implementations
impl<'i> RefUnwindSafe for TranslationUnit<'i>
impl<'i> !Send for TranslationUnit<'i>
impl<'i> !Sync for TranslationUnit<'i>
impl<'i> Unpin for TranslationUnit<'i>
impl<'i> UnwindSafe for TranslationUnit<'i>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more