Struct clang::TranslationUnit
[−]
[src]
pub struct TranslationUnit<'i> { // some fields omitted }
A preprocessed and parsed source file.
Methods
impl<'i> TranslationUnit<'i>
[src]
fn from_ast<F: AsRef<Path>>(index: &'i Index, file: F) -> Result<TranslationUnit<'i>, ()>
fn from_source<F: AsRef<Path>>(index: &'i Index, file: F, arguments: &[&str], unsaved: &[Unsaved], options: ParseOptions) -> Result<TranslationUnit<'i>, SourceError>
Constructs a new TranslationUnit
from a source file.
Any compiler argument that may be supplied to clang
may be supplied to this function.
However, the following arguments are ignored:
-c
-emit-ast
-fsyntax-only
-o
and the following<output>
Failures
- an error occurs while deserializing an AST file
libclang
crashes- an unknown error occurs
fn annotate(&'i self, tokens: &[Token<'i>]) -> Vec<Option<Entity<'i>>>
Returns the AST entities which correspond to the supplied tokens, if any.
fn complete<F: AsRef<Path>>(&self, file: F, line: u32, column: u32, unsaved: &[Unsaved], options: CompletionOptions) -> CompletionResults
Runs code completion at the supplied location.
fn get_diagnostics(&'i self) -> Vec<Diagnostic<'i>>
Returns the diagnostics for this translation unit.
fn get_entity(&'i self) -> Entity<'i>
Returns the entity for this translation unit.
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.
fn get_memory_usage(&self) -> HashMap<MemoryUsage, usize>
Returns the memory usage of this translation unit.
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
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