|
Eclipse CDT Pre-release 3.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 |
Method Summary | |
IInclude |
createInclude(String name,
boolean isStd,
ICElement sibling,
IProgressMonitor monitor)
Creates and returns an include declaration in this translation unit with the given name. |
INamespace |
createNamespace(String namespace,
ICElement sibling,
IProgressMonitor monitor)
Creates and returns a namespace in this translation unit |
IUsing |
createUsing(String name,
boolean isDirective,
ICElement sibling,
IProgressMonitor monitor)
Creates and returns a using declaration/directive in this translation unit |
IWorkingCopy |
findSharedWorkingCopy(org.eclipse.cdt.internal.core.model.IBufferFactory bufferFactory)
Finds the shared working copy for this element, given a IBuffer factory.
|
IASTTranslationUnit |
getASTTranslationUnit()
Returns the root object of a DOM Abstract syntax tree. |
char[] |
getContents()
Returns the contents of a translation unit as a char[] |
String |
getContentTypeId()
Return the contentType id for this file. |
ICElement |
getElement(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(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. |
INamespace |
getNamespace(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. |
IWorkingCopy |
getSharedWorkingCopy(IProgressMonitor monitor,
org.eclipse.cdt.internal.core.model.IBufferFactory factory)
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. |
IWorkingCopy |
getSharedWorkingCopy(IProgressMonitor monitor,
org.eclipse.cdt.internal.core.model.IBufferFactory factory,
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(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,
org.eclipse.cdt.internal.core.model.IBufferFactory factory)
Returns a new working copy for the Translation Unit. |
boolean |
isASMLanguage()
True if assembly |
boolean |
isCLanguage()
True if the code is C |
boolean |
isCXXLanguage()
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. |
Map |
parse()
parse() returns a map of all new elements and their element info |
Methods inherited from interface org.eclipse.cdt.core.model.ICElement |
accept, exists, getAncestor, getCModel, getCProject, getElementName, getElementType, 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 |
getSource, getSourceRange, getTranslationUnit |
Methods inherited from interface org.eclipse.cdt.core.model.ISourceManipulation |
copy, delete, move, rename |
Method Detail |
public IInclude createInclude(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
public IUsing createUsing(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
public INamespace createNamespace(String namespace, ICElement sibling, IProgressMonitor monitor) throws CModelException
monitor
- the progress monitor to notify
CModelException
- if the element could not be created. Reasons include:
CoreException
occurred while updating an underlying resource
public IWorkingCopy findSharedWorkingCopy(org.eclipse.cdt.internal.core.model.IBufferFactory bufferFactory)
IBuffer
factory.
If no working copy has been created for this element associated with this
buffer factory, returns null
.
Users of this method must not destroy the resulting working copy.
bufferFactory
- the given IBuffer
factory
null
if noneIBufferFactory
public char[] getContents()
public 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 resourcepublic ICElement 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.
null
if none (excluding the translation unit).
CModelException
- if the translation unit does not exist or if an
exception occurs while accessing its corresponding resourcepublic ICElement[] getElementsAtOffset(int offset) throws CModelException
null
if none (excluding the translation unit).
CModelException
- if the translation unit does not exist or if an
exception occurs while accessing its corresponding resourcepublic ICElement getElement(String name) throws CModelException
CModelException
public IInclude getInclude(String name)
public IInclude[] getIncludes() throws CModelException
CModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resourcepublic IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, org.eclipse.cdt.internal.core.model.IBufferFactory factory) 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 reportedfactory
- the factory that creates a buffer that is used to get the content of the working copy
or null
if the internal factory should be used
CModelException
- if the contents of this element can not be
determined. Reasons include:
IBufferFactory
,
IProblemRequestor
public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, org.eclipse.cdt.internal.core.model.IBufferFactory factory, 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 reportedfactory
- the factory that creates a buffer that is used to get the content of the working copy
or null
if the internal factory should be used
CModelException
- if the contents of this element can not be
determined. Reasons include:
IBufferFactory
,
IProblemRequestor
public IUsing getUsing(String name)
name
- the name of the namespace declaration (For example, "std"
)public IUsing[] getUsings() throws CModelException
CModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resourcepublic INamespace getNamespace(String name)
name
- the name of the namespace declaration (For example, "std"
)public INamespace[] getNamespaces() throws CModelException
CModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resourcepublic boolean isHeaderUnit()
public boolean isSourceUnit()
public boolean isCLanguage()
public boolean isCXXLanguage()
public boolean isASMLanguage()
public IWorkingCopy getWorkingCopy() throws CModelException
CModelException
public IWorkingCopy getWorkingCopy(IProgressMonitor monitor, org.eclipse.cdt.internal.core.model.IBufferFactory factory) throws CModelException
CModelException
public String getContentTypeId()
public boolean isWorkingCopy()
public Map parse()
public IASTTranslationUnit getASTTranslationUnit()
|
Eclipse CDT Pre-release 3.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |