TranslationUnit
public class TranslationUnit
                Undocumented
- 
                  
                  
Creates a
TranslationUnitby parsing the file at the specified path, passing optional command line arguments and options to clang.Throws
ClangErrorif the translation unit could not be created successfully.Declaration
Swift
public init(filename: String, index: Index = Index(), commandLineArgs args: [String] = [], options: TranslationUnitOptions = []) throwsParameters
filenameThe path you’re going to parse
indexThe index (optional, will use a default index if not provided)
argsOptional command-line arguments to pass to clang
optionsOptions for how to handle the parsed file
 - 
                  
                  
Retrieve the cursor that represents the given translation unit. The translation unit cursor can be used to start traversing the various declarations within the given translation unit.
Declaration
Swift
public var cursor: Cursor - 
                  
                  
Visits each of the children of this translation unit, calling the provided callback for each child.
Note
The returned value of this callback defines what the next item visited will be. SeeChildVisitResultfor a list of possible results.Declaration
Swift
public func visitChildren(_ perCursorCallback: (Cursor) -> ChildVisitResult)Parameters
perCursorCallbackThe callback to call with each child in the receiver.
 - 
                  
                  
Get the original translation unit source file name.
Declaration
Swift
public var spelling: String - 
                  
                  
Tokenizes the source code described by the given range into raw lexical tokens.
Declaration
Swift
public func tokens(in range: SourceRange) -> [Token]Parameters
rangethe source range in which text should be tokenized. All of the tokens produced by tokenization will fall within this source range.
Return Value
All tokens that fall within the provided source range in this translation unit.
 - 
                  
                  
Annotate the given set of tokens by providing cursors for each token that can be mapped to a specific entity within the abstract syntax tree. This token-annotation routine is equivalent to invoking
cursor(at:)for the source locations of each of the tokens. The cursors provided are filtered, so that only those cursors that have a direct correspondence to the token are accepted. For example, given a function callf(x),cursor(at:)would provide the following cursors:- when the cursor is over the 
f, aDeclRefExprcursor referring tof. - when the cursor is over the 
(or the), aCallExprreferring tof. - when the cursor is over the 
x, aDeclRefExprcursor referring tox. 
Only the first and last of these cursors will occur within the annotate, since the tokens
f
and “x’ directly refer to a function and a variable, respectively, but the parentheses are just a small part of the full syntax of the function call expression, which is not provided as an annotation.Parameters
tokensThe set of tokens to annotate
Return Value
The cursors corresponding to each token provided
 - when the cursor is over the 
 
        TranslationUnit Class Reference