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
           
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 builtin 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()
           
 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.
 IASTNodeLocation[] getLocationInfo(int offset, int length)
           
 IASTPreprocessorMacroDefinition[] getMacroDefinitions()
          Get the macro definitions encountered in parsing this translation unit.
 org.eclipse.cdt.core.parser.ParserLanguage getParserLanguage()
           
 IASTProblem[] getPreprocessorProblems()
          Get all preprocessor and scanner problems.
 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.
 String getUnpreprocessedSignature(IASTNodeLocation[] locations)
          For a given range of locations, return a String that represents what is there underneath the range.
 IASTNode selectNodeForLocation(String path, int offset, int length)
          Select the node in the treet that best fits the offset/length/file path.
 void setComments(IASTComment[] comments)
          Set comments to translation unit.
 void setIndex(org.eclipse.cdt.core.index.IIndex index)
          Set the Index to be used for this translation unit.
 
Methods inherited from interface org.eclipse.cdt.core.dom.ast.IASTNode
accept, contains, getContainingFilename, getFileLocation, getNodeLocations, getParent, getPropertyInParent, getRawSignature, getTranslationUnit, setParent, setPropertyInParent
 

Field Detail

OWNED_DECLARATION

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


SCANNER_PROBLEM

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


PREPROCESSOR_STATEMENT

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


EXPANSION_NAME

public static final ASTNodeProperty EXPANSION_NAME
Method Detail

getDeclarations

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

Returns:
List of IASTDeclaration

addDeclaration

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

Parameters:
declaration - IASTDeclaration

getScope

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

Returns:
the global scope

getDeclarations

public 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

public 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

public 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

public 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

public 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

getLocationInfo

public IASTNodeLocation[] getLocationInfo(int offset,
                                          int length)
Parameters:
offset -
length -
Returns:

selectNodeForLocation

public IASTNode selectNodeForLocation(String path,
                                      int offset,
                                      int length)
Select the node in the treet that best fits the offset/length/file path.

Parameters:
path - - file name specified through path
offset - - location in the file as an offset
length - - length of selection
Returns:
IASTNode that best fits

getMacroDefinitions

public IASTPreprocessorMacroDefinition[] getMacroDefinitions()
Get the macro definitions encountered in parsing this translation unit.

Returns:
IASTPreprocessorMacroDefinition[]

getBuiltinMacroDefinitions

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

Returns:
IASTPreprocessorMacroDefinition[]

getIncludeDirectives

public IASTPreprocessorIncludeStatement[] getIncludeDirectives()
Get the #include directives encountered in parsing this translation unit.

Returns:
IASTPreprocessorIncludeStatement[]

getAllPreprocessorStatements

public IASTPreprocessorStatement[] getAllPreprocessorStatements()
Get all preprocessor statements.

Returns:
IASTPreprocessorStatement[]

getPreprocessorProblems

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

Returns:
IASTProblem[]

getUnpreprocessedSignature

public String getUnpreprocessedSignature(IASTNodeLocation[] locations)
For a given range of locations, return a String that represents what is there underneath the range.

Parameters:
locations - A range of node locations
Returns:
A String signature.

getFilePath

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

Returns:
String representation of path.

flattenLocationsToFile

public 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

public IASTTranslationUnit.IDependencyTree getDependencyTree()
Returns:

getContainingFilename

public String getContainingFilename(int offset)
Parameters:
offset -
Returns:

getParserLanguage

public org.eclipse.cdt.core.parser.ParserLanguage getParserLanguage()
Returns:

getIndex

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

Returns:
the Index for this translation unit

setIndex

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

Parameters:
index -

setComments

public void setComments(IASTComment[] comments)
Set comments to translation unit.


getComments

public 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

Eclipse CDT
Pre-release 3.0

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