|
Eclipse CDT 7.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ITranslationUnit
Represents an entire C translation unit (.c
source file).
The children are of type IStructureElement
,
IInclude
, etc..
and appear in the order in which they are declared in the source.
If a .c
file cannot be parsed, its structure remains unknown.
Use ICElement.isStructureKnown
to determine whether this is
the case.
Field Summary | |
---|---|
static int |
AST_CONFIGURE_USING_SOURCE_CONTEXT
Style constant for getAST(IIndex, int) . |
static int |
AST_CREATE_COMMENT_NODES
Deprecated. The option has no effect. |
static int |
AST_PARSE_INACTIVE_CODE
Style constant for getAST(IIndex, int) . |
static int |
AST_SKIP_ALL_HEADERS
Style constant for getAST(IIndex, int) . |
static int |
AST_SKIP_FUNCTION_BODIES
Style constant for getAST(IIndex, int) . |
static int |
AST_SKIP_IF_NO_BUILD_INFO
Style constant for getAST(IIndex, int) . |
static int |
AST_SKIP_INDEXED_HEADERS
Style constant for getAST(IIndex, int) . |
static int |
AST_SKIP_NONINDEXED_HEADERS
Style constant for getAST(IIndex, int) . |
static int |
AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS
Style constant for getAST(IIndex, int) . |
Method Summary | |
---|---|
IInclude |
createInclude(java.lang.String name,
boolean isStd,
ICElement sibling,
IProgressMonitor monitor)
Creates and returns an include declaration in this translation unit with the given name. |
INamespace |
createNamespace(java.lang.String namespace,
ICElement sibling,
IProgressMonitor monitor)
Creates and returns a namespace in this translation unit |
IUsing |
createUsing(java.lang.String name,
boolean isDirective,
ICElement sibling,
IProgressMonitor monitor)
Creates and returns a using declaration/directive in this translation unit. |
IWorkingCopy |
findSharedWorkingCopy()
Returns the shared working copy for this element, using the default IBuffer
factory, or null , if no working copy has been created for this element. |
IWorkingCopy |
findSharedWorkingCopy(org.eclipse.cdt.internal.core.model.IBufferFactory bufferFactory)
Deprecated. use findSharedWorkingCopy() ,
or CDTUITools.getWorkingCopyManager() instead. |
IASTTranslationUnit |
getAST()
Creates the full AST for this translation unit. |
IASTTranslationUnit |
getAST(org.eclipse.cdt.core.index.IIndex index,
int style)
Creates an AST based on the requested style. |
org.eclipse.cdt.core.parser.CodeReader |
getCodeReader()
Deprecated. |
IASTCompletionNode |
getCompletionNode(org.eclipse.cdt.core.index.IIndex index,
int style,
int offset)
Return the completion node using the given index and parsing style at the given offset. |
char[] |
getContents()
Returns the contents of a translation unit as a char[] |
java.lang.String |
getContentTypeId()
Return the contentType id for this file. |
ICElement |
getElement(java.lang.String name)
|
ICElement |
getElementAtLine(int line)
Returns the smallest element within this translation unit that includes the given source position (that is, a method, field, etc.), or null if there is no element other than the translation
unit itself at the given position, or if the given position is not
within the source range of this translation unit. |
ICElement |
getElementAtOffset(int offset)
Returns the smallest element within this translation unit that includes the given source position (that is, a method, field, etc.), or null if there is no element other than the translation
unit itself at the given position, or if the given position is not
within the source range of this translation unit. |
ICElement[] |
getElementsAtOffset(int offset)
Returns the elements within this translation unit that includes the given source position (that is, a method, field, etc.), or an empty array if there are no elements other than the translation unit itself at the given position, or if the given position is not within the source range of this translation unit. |
IInclude |
getInclude(java.lang.String name)
Returns the include declaration in this translation unit with the given name. |
IInclude[] |
getIncludes()
Returns the include declarations in this translation unit in the order in which they appear in the source. |
ILanguage |
getLanguage()
Return the language for this translation unit. |
IPath |
getLocation()
Returns the absolute path of the location of the translation unit. |
INamespace |
getNamespace(java.lang.String name)
Returns the first namespace declaration in this translation unit with the given name This is a handle-only method. |
INamespace[] |
getNamespaces()
Returns the namespace declarations in this translation unit in the order in which they appear in the source. |
org.eclipse.cdt.core.parser.IScannerInfo |
getScannerInfo(boolean force)
Returns the scanner info associated with this translation unit. |
IWorkingCopy |
getSharedWorkingCopy(IProgressMonitor monitor,
org.eclipse.cdt.internal.core.model.IBufferFactory factory)
Deprecated. use getSharedWorkingCopy(IProgressMonitor, IProblemRequestor) ,
or CDTUITools.getWorkingCopyManager() instead. |
IWorkingCopy |
getSharedWorkingCopy(IProgressMonitor monitor,
org.eclipse.cdt.internal.core.model.IBufferFactory factory,
IProblemRequestor requestor)
Deprecated. use getSharedWorkingCopy(IProgressMonitor, IProblemRequestor) ,
or CDTUITools.getWorkingCopyManager() instead. |
IWorkingCopy |
getSharedWorkingCopy(IProgressMonitor monitor,
IProblemRequestor requestor)
Returns a shared working copy on this element using the given factory to create the buffer, or this element if this element is already a working copy. |
IUsing |
getUsing(java.lang.String name)
Returns the first using in this translation unit with the name This is a handle-only method. |
IUsing[] |
getUsings()
Returns the usings in this translation unit in the order in which they appear in the source. |
IWorkingCopy |
getWorkingCopy()
Returns a new working copy for the Translation Unit. |
IWorkingCopy |
getWorkingCopy(IProgressMonitor monitor)
Returns a new working copy for the Translation Unit. |
IWorkingCopy |
getWorkingCopy(IProgressMonitor monitor,
org.eclipse.cdt.internal.core.model.IBufferFactory factory)
Deprecated. use getWorkingCopy(IProgressMonitor) ,
or CDTUITools.getWorkingCopyManager() instead. |
boolean |
isASMLanguage()
Returns true if the code is assembly |
boolean |
isCLanguage()
Returns true if the code is C |
boolean |
isCXXLanguage()
Returns true if the code is C++ |
boolean |
isHeaderUnit()
True if its a header. |
boolean |
isSourceUnit()
True it is a source file. |
boolean |
isWorkingCopy()
Checks if this is a working copy. |
java.util.Map<?,?> |
parse()
Deprecated. don't use this method. |
void |
setIsStructureKnown(boolean wasSuccessful)
Used by contributed languages' model builders to indicate whether or not the parse of a translation unit was successful. |
Methods inherited from interface org.eclipse.cdt.core.model.ICElement |
---|
accept, exists, getAncestor, getCModel, getCProject, getElementName, getElementType, getHandleIdentifier, getLocationURI, getParent, getPath, getResource, getUnderlyingResource, isReadOnly, isStructureKnown |
Methods inherited from interface org.eclipse.cdt.core.model.IParent |
---|
getChildren, getChildrenOfType, hasChildren |
Methods inherited from interface org.eclipse.cdt.core.model.IOpenable |
---|
close, getBuffer, hasUnsavedChanges, isConsistent, isOpen, makeConsistent, makeConsistent, open, save |
Methods inherited from interface org.eclipse.cdt.core.model.IBufferChangedListener |
---|
bufferChanged |
Methods inherited from interface org.eclipse.cdt.core.model.ISourceReference |
---|
getIndex, getSource, getSourceRange, getTranslationUnit, isActive |
Methods inherited from interface org.eclipse.cdt.core.model.ISourceManipulation |
---|
copy, delete, move, rename |
Field Detail |
---|
static final int AST_SKIP_FUNCTION_BODIES
getAST(IIndex, int)
.
Meaning: Skip function and method bodies.
static final int AST_SKIP_INDEXED_HEADERS
getAST(IIndex, int)
.
Meaning: Skip over headers that are found in the index, parse all others.
Macro definitions and bindings are taken from index for skipped files.
static final int AST_SKIP_NONINDEXED_HEADERS
getAST(IIndex, int)
.
Meaning: Skip headers even if they are not found in the index.
Makes practically only sense in combination with AST_SKIP_INDEXED_HEADERS
.
static final int AST_SKIP_ALL_HEADERS
getAST(IIndex, int)
.
A combination of AST_SKIP_INDEXED_HEADERS
and AST_SKIP_NONINDEXED_HEADERS
.
Meaning: Don't parse header files at all, be they indexed or not.
Macro definitions and bindings are taken from the index if available.
static final int AST_SKIP_IF_NO_BUILD_INFO
getAST(IIndex, int)
.
Meaning: Don't parse the file if there is no build information for it.
@Deprecated static final int AST_CREATE_COMMENT_NODES
static final int AST_CONFIGURE_USING_SOURCE_CONTEXT
getAST(IIndex, int)
.
Meaning: Configure the parser with language and build-information taken from a source file
that directly or indirectly includes this file. If no suitable file is found in the index,
the flag is ignored.
static final int AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS
getAST(IIndex, int)
.
Instructs the parser not to create ast nodes for expressions within aggregate initializers
when they do not contain names.
static final int AST_PARSE_INACTIVE_CODE
getAST(IIndex, int)
.
Instructs the parser to make an attempt to create ast nodes for inactive code branches. The parser
makes its best effort to create ast for the inactive code branches but may decide to skip parts
of the inactive code (e.g. function bodies, entire code branches, etc.).
The inactive nodes can be accessed via IASTDeclarationListOwner.getDeclarations(boolean)
or
by using a visitor with ASTVisitor.includeInactiveNodes
set to true
.
Method Detail |
---|
IInclude createInclude(java.lang.String name, boolean isStd, ICElement sibling, IProgressMonitor monitor) throws CModelException
Optionally, the new element can be positioned before the specified sibling. If no sibling is specified, the element will be inserted as the last import declaration in this translation unit.
If the translation unit already includes the specified include declaration, the import is not generated (it does not generate duplicates).
name
- the name of the include declaration to add (For example: "stdio.h"
or
"sys/types.h"
)sibling
- the existing element which the include declaration will be inserted immediately before (if
null
, then this include will be inserted as the last include declaration.monitor
- the progress monitor to notify
CModelException
- if the element could not be created. Reasons include:
CoreException
occurred while updating an underlying resource
IUsing createUsing(java.lang.String name, boolean isDirective, ICElement sibling, IProgressMonitor monitor) throws CModelException
name
- the name of the usingmonitor
- the progress monitor to notify
CModelException
- if the element could not be created. Reasons include:
CoreException
occurred while updating an underlying resource
INamespace createNamespace(java.lang.String namespace, ICElement sibling, IProgressMonitor monitor) throws CModelException
name
- the name of the namespacemonitor
- the progress monitor to notify
CModelException
- if the element could not be created. Reasons include:
CoreException
occurred while updating an underlying resource
IWorkingCopy findSharedWorkingCopy()
IBuffer
factory, or null
, if no working copy has been created for this element.
Users of this method must not destroy the resulting working copy.
bufferFactory
- the given IBuffer
factory
null
if noneIBufferFactory
char[] getContents()
ICElement getElementAtLine(int line) throws CModelException
null
if there is no element other than the translation
unit itself at the given position, or if the given position is not
within the source range of this translation unit.
line
- a position inside the translation unit
null
if none (excluding the translation unit).
CModelException
- if the translation unit does not exist or if an
exception occurs while accessing its corresponding resourceICElement getElementAtOffset(int offset) throws CModelException
null
if there is no element other than the translation
unit itself at the given position, or if the given position is not
within the source range of this translation unit.
position
- a source position inside the translation unit
null
if none (excluding the translation unit).
CModelException
- if the translation unit does not exist or if an
exception occurs while accessing its corresponding resourceICElement[] getElementsAtOffset(int offset) throws CModelException
position
- a source position inside the translation unit
null
if none (excluding the translation unit).
CModelException
- if the translation unit does not exist or if an
exception occurs while accessing its corresponding resourceICElement getElement(java.lang.String name) throws CModelException
CModelException
IInclude getInclude(java.lang.String name)
the
- name of the include to find (For example: "stdio.h"
or "sys/types.h"
)
IInclude[] getIncludes() throws CModelException
CModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resourceIWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IProblemRequestor requestor) throws CModelException
Object#equals
).
The life time of a shared working copy is as follows:
getSharedWorkingCopy(...)
creates a new working copy for this
elementdestroy()
decrements the internal counter.Note that the buffer factory will be used for the life time of this working copy, i.e. if the working copy is closed then reopened, this factory will be used. The buffer will be automatically initialized with the original's compilation unit content upon creation.
When the shared working copy instance is created, an ADDED ICElementDelta is reported on this working copy.
monitor
- a progress monitor used to report progress while opening this compilation unit or
null
if no progress should be reportedrequestor
- a requestor which will get notified of problems detected during reconciling as they are
discovered. The requestor can be set to null
indicating that the client is not
interested in problems.
CModelException
- if the contents of this element can not be determined. Reasons include:
IBufferFactory
,
IProblemRequestor
IUsing getUsing(java.lang.String name)
name
- the name of the namespace declaration (For example, "std"
)IUsing[] getUsings() throws CModelException
CModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resourceINamespace getNamespace(java.lang.String name)
name
- the name of the namespace declaration (For example, "std"
)INamespace[] getNamespaces() throws CModelException
CModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resourceboolean isHeaderUnit()
boolean isSourceUnit()
boolean isCLanguage()
true
if the code is C
boolean isCXXLanguage()
true
if the code is C++
boolean isASMLanguage()
true
if the code is assembly
IWorkingCopy getWorkingCopy() throws CModelException
CModelException
IWorkingCopy getWorkingCopy(IProgressMonitor monitor) throws CModelException
CModelException
java.lang.String getContentTypeId()
boolean isWorkingCopy()
ILanguage getLanguage() throws CoreException
CoreException
void setIsStructureKnown(boolean wasSuccessful)
wasSuccessful
- TODO (DS) I'm not sure it's a good idea to put a setter in this
interface. We should revisit this.IPath getLocation()
null
, in
case the location does not exist.
null
org.eclipse.cdt.core.parser.IScannerInfo getScannerInfo(boolean force)
null
if no
configuration is available.
force
- if true
a default info is returned, even if nothing is configured for this
translation unit
null
if none is configuredIASTTranslationUnit getAST() throws CoreException
null
if the language
of this translation unit does not support ASTs.
null
CoreException
IASTTranslationUnit getAST(org.eclipse.cdt.core.index.IIndex index, int style) throws CoreException
null
if the language of
this translation unit does not support ASTs. If the index was supplied, the caller has to
hold a read lock on it. The returned AST is valid only while the index read lock is being
held and should not be accessed after releasing the lock.
index
- index to back up the parsing of the AST, may be null
style
- 0
or a combination of AST_SKIP_ALL_HEADERS
,
AST_SKIP_IF_NO_BUILD_INFO
, AST_SKIP_INDEXED_HEADERS
and AST_CONFIGURE_USING_SOURCE_CONTEXT
.
null
CoreException
IASTCompletionNode getCompletionNode(org.eclipse.cdt.core.index.IIndex index, int style, int offset) throws CoreException
CoreException
@Deprecated IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, org.eclipse.cdt.internal.core.model.IBufferFactory factory) throws CModelException
getSharedWorkingCopy(IProgressMonitor, IProblemRequestor)
,
or CDTUITools.getWorkingCopyManager() instead.
CModelException
@Deprecated IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, org.eclipse.cdt.internal.core.model.IBufferFactory factory, IProblemRequestor requestor) throws CModelException
getSharedWorkingCopy(IProgressMonitor, IProblemRequestor)
,
or CDTUITools.getWorkingCopyManager() instead.
CModelException
@Deprecated IWorkingCopy findSharedWorkingCopy(org.eclipse.cdt.internal.core.model.IBufferFactory bufferFactory)
findSharedWorkingCopy()
,
or CDTUITools.getWorkingCopyManager() instead.
@Deprecated IWorkingCopy getWorkingCopy(IProgressMonitor monitor, org.eclipse.cdt.internal.core.model.IBufferFactory factory) throws CModelException
getWorkingCopy(IProgressMonitor)
,
or CDTUITools.getWorkingCopyManager() instead.
CModelException
@Deprecated java.util.Map<?,?> parse()
@Deprecated org.eclipse.cdt.core.parser.CodeReader getCodeReader()
|
Eclipse CDT 7.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |