[][src]Struct clang::TranslationUnit

pub struct TranslationUnit<'i> { /* fields omitted */ }

A preprocessed and parsed source file.

Implementations

impl<'i> TranslationUnit<'i>[src]

pub fn from_ast<F: AsRef<Path>>(
    index: &'i Index<'_>,
    file: F
) -> Result<TranslationUnit<'i>, ()>
[src]

Constructs a new TranslationUnit from an AST file.

Failures

  • an unknown error occurs

pub fn get_diagnostics(&'i self) -> Vec<Diagnostic<'i>>[src]

Returns the diagnostics for this translation unit.

pub fn get_entity(&'i self) -> Entity<'i>[src]

Returns the entity for this translation unit.

pub fn get_file<F: AsRef<Path>>(&'i self, file: F) -> Option<File<'i>>[src]

Returns the file at the supplied path in this translation unit, if any.

pub fn get_memory_usage(&self) -> HashMap<MemoryUsage, usize>[src]

Returns the memory usage of this translation unit.

pub fn get_skipped_ranges(&'i self) -> Vec<SourceRange<'i>>[src]

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.

pub fn get_target(&self) -> Target[src]

Returns information about the target for this translation unit.

pub fn annotate(&'i self, tokens: &[Token<'i>]) -> Vec<Option<Entity<'i>>>[src]

Returns the AST entities which correspond to the supplied tokens, if any.

pub fn completer<F: Into<PathBuf>>(
    &self,
    file: F,
    line: u32,
    column: u32
) -> Completer<'_>
[src]

Returns a completer which runs code completion.

pub fn save<F: AsRef<Path>>(&self, file: F) -> Result<(), SaveError>[src]

Saves this translation unit to an AST file.

Failures

  • errors in the translation unit prevent saving
  • an unknown error occurs

pub fn reparse(
    self,
    unsaved: &[Unsaved]
) -> Result<TranslationUnit<'i>, SourceError>
[src]

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

impl<'i> Debug for TranslationUnit<'i>[src]

impl<'i> Drop for TranslationUnit<'i>[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.