Eclipse CDT
Pre-release 3.0

org.eclipse.cdt.core.dom.ast
Interface IASTTranslationUnit

All Superinterfaces:
IASTNode
All Known Subinterfaces:
ICPPASTTranslationUnit

public interface IASTTranslationUnit
extends IASTNode

The translation unit represents a compilable unit of source.


Nested Class Summary
static interface IASTTranslationUnit.IDependencyTree
           
 
Field Summary
static ASTNodeProperty EXPANSION_NAME
          Deprecated. names for macro expansions are nested inside of IASTPreprocessorMacroExpansion.
static ASTNodeProperty MACRO_EXPANSION
           
static ASTNodeProperty OWNED_DECLARATION
          OWNED_DECLARATION represents the relationship between an IASTTranslationUnit and it's nested IASTDeclaration's.
static ASTNodeProperty PREPROCESSOR_STATEMENT
          PREPROCESSOR_STATEMENT represents the relationship between an IASTTranslationUnit and it's nested IASTPreprocessorStatement.
static ASTNodeProperty SCANNER_PROBLEM
          SCANNER_PROBLEM represents the relationship between an IASTTranslationUnit and it's nested IASTProblem.
 
Fields inherited from interface org.eclipse.cdt.core.dom.ast.IASTNode
EMPTY_NODE_ARRAY
 
Method Summary
 void addDeclaration(IASTDeclaration declaration)
          Add declaration to translation unit.
 IASTFileLocation flattenLocationsToFile(IASTNodeLocation[] nodeLocations)
          Flatten the node locations provided into a single file location.
 IASTPreprocessorStatement[] getAllPreprocessorStatements()
          Get all preprocessor statements.
 IASTPreprocessorMacroDefinition[] getBuiltinMacroDefinitions()
          Get built-in macro definitions used when parsing this translation unit.
 IASTComment[] getComments()
          In case the ast was created in a way that supports comment parsing, all comments of the translation unit are returned.
 String getContainingFilename(int offset)
           
 IASTDeclaration[] getDeclarations()
          A translation unit contains an ordered sequence of declarations.
 org.eclipse.cdt.core.dom.IName[] getDeclarations(IBinding binding)
          Returns the list of declarations in this translation unit for the given binding.
 IASTName[] getDeclarationsInAST(IBinding binding)
          Returns the list of declarations in this translation unit for the given binding.
 org.eclipse.cdt.core.dom.IName[] getDefinitions(IBinding binding)
          Returns the array of definitions in this translation unit for the given binding.
 IASTName[] getDefinitionsInAST(IBinding binding)
          Returns the array of definitions in this translation unit for the given binding.
 IASTTranslationUnit.IDependencyTree getDependencyTree()
          Return the dependency tree for the translation unit.
 String getFilePath()
          Get the translation unit's full path.
 IASTPreprocessorIncludeStatement[] getIncludeDirectives()
          Get the include directives encountered in parsing this translation unit.
 org.eclipse.cdt.core.index.IIndex getIndex()
          Return the Index associated with this translation unit.
 org.eclipse.cdt.core.dom.ILinkage getLinkage()
          Returns the linkage this ast was parsed in
 IASTPreprocessorMacroDefinition[] getMacroDefinitions()
          Get the macro definitions encountered in parsing this translation unit.
 IASTPreprocessorMacroExpansion[] getMacroExpansions()
          Returns an array with all macro expansions of this translation unit.
 IASTNodeSelector getNodeSelector(String filePath)
          Returns an IASTNodeSelector object for finding nodes by file offsets.
 org.eclipse.cdt.core.parser.ParserLanguage getParserLanguage()
           
 IASTProblem[] getPreprocessorProblems()
          Get all preprocessor and scanner problems.
 int getPreprocessorProblemsCount()
          Fast access to the count of preprocessor problems to support statistics.
 IASTName[] getReferences(IBinding binding)
          Returns the list of references in this translation unit to the given binding.
 IScope getScope()
          This returns the global scope for the translation unit.
 boolean isHeaderUnit()
          Returns whether this ast represents a header file.
 IASTNode selectNodeForLocation(String path, int offset, int length)
          Deprecated. use getNodeSelector(String), instead.
 void setIndex(org.eclipse.cdt.core.index.IIndex index)
          Set the Index to be used for this translation unit.
 void setIsHeaderUnit(boolean headerUnit)
          Sets whether this ast represents a header file.
 
Methods inherited from interface org.eclipse.cdt.core.dom.ast.IASTNode
accept, contains, getContainingFilename, getFileLocation, getNodeLocations, getParent, getPropertyInParent, getRawSignature, getTranslationUnit, isPartOfTranslationUnitFile, setParent, setPropertyInParent
 

Field Detail

OWNED_DECLARATION

static final ASTNodeProperty OWNED_DECLARATION
OWNED_DECLARATION represents the relationship between an IASTTranslationUnit and it's nested IASTDeclaration's.


SCANNER_PROBLEM

static final ASTNodeProperty SCANNER_PROBLEM
SCANNER_PROBLEM represents the relationship between an IASTTranslationUnit and it's nested IASTProblem.


PREPROCESSOR_STATEMENT

static final ASTNodeProperty PREPROCESSOR_STATEMENT
PREPROCESSOR_STATEMENT represents the relationship between an IASTTranslationUnit and it's nested IASTPreprocessorStatement.


EXPANSION_NAME

@Deprecated
static final ASTNodeProperty EXPANSION_NAME
Deprecated. names for macro expansions are nested inside of IASTPreprocessorMacroExpansion.

MACRO_EXPANSION

static final ASTNodeProperty MACRO_EXPANSION
Method Detail

getDeclarations

IASTDeclaration[] getDeclarations()
A translation unit contains an ordered sequence of declarations.

Returns:
List of IASTDeclaration

addDeclaration

void addDeclaration(IASTDeclaration declaration)
Add declaration to translation unit.

Parameters:
declaration - IASTDeclaration

getScope

IScope getScope()
This returns the global scope for the translation unit.

Returns:
the global scope

getDeclarations

org.eclipse.cdt.core.dom.IName[] getDeclarations(IBinding binding)
Returns the list of declarations in this translation unit for the given binding. The list contains the IName nodes that declare the binding. These may be part of the AST or are pulled in from the index.

Parameters:
binding -
Returns:
Array of IName nodes for the binding's declaration

getDeclarationsInAST

IASTName[] getDeclarationsInAST(IBinding binding)
Returns the list of declarations in this translation unit for the given binding. The list contains the IASTName nodes that declare the binding. These are part of the AST no declarations are pulled in from the index.

Parameters:
binding -
Returns:
Array of IASTName nodes for the binding's declaration

getDefinitions

org.eclipse.cdt.core.dom.IName[] getDefinitions(IBinding binding)
Returns the array of definitions in this translation unit for the given binding. The array contains the IName nodes that define the binding. These may be part of the AST or are pulled in from the index.

Parameters:
binding -
Returns:
the definition of the IBinding

getDefinitionsInAST

IASTName[] getDefinitionsInAST(IBinding binding)
Returns the array of definitions in this translation unit for the given binding. The array contains the IASTName nodes that define the binding. These are part of the AST no definitions are pulled in from the index.

Parameters:
binding -
Returns:
Array of IASTName nodes for the binding's declaration

getReferences

IASTName[] getReferences(IBinding binding)
Returns the list of references in this translation unit to the given binding. This list contains the IName nodes that represent a use of the binding. They may be part of the AST or pulled in from the index.

Parameters:
binding -
Returns:
List of IASTName nodes representing uses of the binding

getNodeSelector

IASTNodeSelector getNodeSelector(String filePath)
Returns an IASTNodeSelector object for finding nodes by file offsets. The object is suitable for working in one of the files that is part of the translation unit.

Parameters:
filePath - file of interest, as returned by IASTFileLocation.getFileName(), or null to specify the root source of the translation-unit.
Returns:
an IASTNodeSelector.
Since:
5.0

selectNodeForLocation

@Deprecated
IASTNode selectNodeForLocation(String path,
                                          int offset,
                                          int length)
Deprecated. use getNodeSelector(String), instead.


getMacroDefinitions

IASTPreprocessorMacroDefinition[] getMacroDefinitions()
Get the macro definitions encountered in parsing this translation unit. The result will not contain definitions for built-in macros.

In case the information for a header-file is pulled in from the index, macro definitions contained therein are not returned.


getBuiltinMacroDefinitions

IASTPreprocessorMacroDefinition[] getBuiltinMacroDefinitions()
Get built-in macro definitions used when parsing this translation unit. This includes macros obtained from the index.


getIncludeDirectives

IASTPreprocessorIncludeStatement[] getIncludeDirectives()
Get the include directives encountered in parsing this translation unit. This will also contain directives used for handling the gcc-options -imacros and -include.

In case the information for a header-file is pulled in from the index, include directives contained therein are not returned.


getAllPreprocessorStatements

IASTPreprocessorStatement[] getAllPreprocessorStatements()
Get all preprocessor statements. In case the information for a header-file is pulled in from the index, preprocessing statements contained therein are not returned.


getMacroExpansions

IASTPreprocessorMacroExpansion[] getMacroExpansions()
Returns an array with all macro expansions of this translation unit.


getPreprocessorProblems

IASTProblem[] getPreprocessorProblems()
Get all preprocessor and scanner problems.

Returns:
IASTProblem[]

getPreprocessorProblemsCount

int getPreprocessorProblemsCount()
Fast access to the count of preprocessor problems to support statistics.


getFilePath

String getFilePath()
Get the translation unit's full path.

Returns:
String representation of path.

flattenLocationsToFile

IASTFileLocation flattenLocationsToFile(IASTNodeLocation[] nodeLocations)
Flatten the node locations provided into a single file location.

Parameters:
nodeLocations - IASTNodeLocations to flatten
Returns:
null if not possible, otherwise, a file location representing where the macros are.

getDependencyTree

IASTTranslationUnit.IDependencyTree getDependencyTree()
Return the dependency tree for the translation unit.

In case the information for a header-file is pulled in from the index, dependencies contained therein are not part of the dependency tree.


getContainingFilename

String getContainingFilename(int offset)
Parameters:
offset -

getParserLanguage

org.eclipse.cdt.core.parser.ParserLanguage getParserLanguage()

getIndex

org.eclipse.cdt.core.index.IIndex getIndex()
Return the Index associated with this translation unit.

Returns:
the Index for this translation unit

setIndex

void setIndex(org.eclipse.cdt.core.index.IIndex index)
Set the Index to be used for this translation unit.

Parameters:
index -

getComments

IASTComment[] getComments()
In case the ast was created in a way that supports comment parsing, all comments of the translation unit are returned. Otherwise an empty array will be supplied.

Returns:
IASTComment[]
Since:
4.0

getLinkage

org.eclipse.cdt.core.dom.ILinkage getLinkage()
Returns the linkage this ast was parsed in


isHeaderUnit

boolean isHeaderUnit()
Returns whether this ast represents a header file.


setIsHeaderUnit

void setIsHeaderUnit(boolean headerUnit)
Sets whether this ast represents a header file.


Eclipse CDT
Pre-release 3.0

Copyright (c) IBM Corp. and others 2004. All Rights Reserved.