|
Eclipse JDT 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.jdt.core.dom.ASTNode | +--org.eclipse.jdt.core.dom.CompilationUnit
Java compilation unit AST node type. This is the type of the root of an AST. Range 0: first character through last character of the source file.
CompilationUnit: [ PackageDeclaration ] { ImportDeclaration } { TypeDeclaration | ; }
Field Summary |
Method Summary | |
ASTNode |
findDeclaringNode(IBinding binding)
Finds the corresponding AST node in the given compilation unit from which the given binding originated. |
Message[] |
getMessages()
Returns the list of messages reported by the compiler during the parsing or the type checking of this compilation unit. |
int |
getNodeType()
Returns an integer value identifying the type of this concrete AST node. |
PackageDeclaration |
getPackage()
Returns the node for the package declaration of this compilation unit, or null if this compilation unit is in the
default package. |
List |
imports()
Returns the live list of nodes for the import declaration of this compilation unit, in order of appearance. |
int |
lineNumber(int position)
Returns the line number corresponding to the given source character position in the original source string. |
void |
setPackage(PackageDeclaration pkgDecl)
Sets or clears the package declaration of this compilation unit node to the given package declaration node. |
boolean |
subtreeMatch(ASTMatcher matcher,
Object other)
Returns whether the subtree rooted at the given node matches the given other object as decided by the given matcher. |
List |
types()
Returns the live list of nodes for the top-level type declaration of this compilation unit, in order of appearance. |
Methods inherited from class org.eclipse.jdt.core.dom.ASTNode |
accept, copySubtree, copySubtrees, equals, getAST, getFlags, getLength, getParent, getProperty, getRoot, getStartPosition, properties, setFlags, setProperty, setSourceRange, subtreeBytes, toString |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
public int getNodeType()
ASTNode
For each concrete node type there is a unique node type constant (name
and value). The unique node type constant for a concrete node type such as
CastExpression
is ASTNode.CAST_EXPRESSION
.
getNodeType
in class ASTNode
public boolean subtreeMatch(ASTMatcher matcher, Object other)
ASTNode
subtreeMatch
in class ASTNode
matcher
- the matcherother
- the other object, or null
true
if the subtree matches, or
false
if they do not matchpublic PackageDeclaration getPackage()
null
if this compilation unit is in the
default package.
null
if nonepublic void setPackage(PackageDeclaration pkgDecl)
pkgDecl
- the new package declaration node, or
null
if this compilation unit does not have a package
declaration (that is in the default package)
IllegalArgumentException
- if:
public List imports()
ImportDeclaration
)public List types()
TypeDeclaration
)public ASTNode findDeclaringNode(IBinding binding)
null
if the
binding does not correspond to any node in this compilation unit.
The following table indicates the expected node type for the various different kinds of bindings:
PackageDeclaration
TypeDeclaration
or a
ClassInstanceCreation
(for anonymous classes) VariableDeclarationFragment
in a
FieldDeclaration
SingleVariableDeclaration
, or
a VariableDeclarationFragment
in a
VariableDeclarationStatement
or
VariableDeclarationExpression
MethodDeclaration
MethodDeclaration
Note that bindings are generally unavailable unless requested when the AST is being built.
binding
- the binding
null
if nonepublic int lineNumber(int position)
class A\n{\n}
has 3 lines
corresponding to inclusive character ranges [0,8], [8,9], and [10,10].
Returns 1 for a character position that does not correspond to any
source line, or if no line number information is available for this
compilation unit.
position
- a 0-based character position, possibly
negative or out of range
1
if the character
position does not correspond to a source line in the original
source file or if line number information is not known for this
compilation unitAST.parseCompilationUnit(org.eclipse.jdt.core.ICompilationUnit, boolean)
public Message[] getMessages()
AST.parseCompilationUnit(org.eclipse.jdt.core.ICompilationUnit, boolean)
|
Eclipse JDT 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |