|
Eclipse JDT 2.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | 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.
The source range for this type of node is ordinarily the entire source file, including leading and trailing whitespace and comments.
CompilationUnit: [ PackageDeclaration ] { ImportDeclaration } { TypeDeclaration | ; }
Method Summary | |
ASTNode |
findDeclaringNode(IBinding binding)
Finds the corresponding AST node in the given compilation unit from which the given binding originated. |
ASTNode |
findDeclaringNode(String key)
Finds the corresponding AST node in the given compilation unit from which the binding with the given key 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. |
IProblem[] |
getProblems()
Returns the list of detailed problem reports noted by the compiler during the parsing or the type checking of this compilation unit. |
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
org.eclipse.jdt.core.dom.ASTNode
public boolean subtreeMatch(ASTMatcher matcher, Object other)
ASTNode
subtreeMatch
in class ASTNode
org.eclipse.jdt.core.dom.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.
This method always returns null
if bindings were not requested
when this AST was built.
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
Each call to AST.parseCompilationUnit
with a request for bindings
gives rise to separate universe of binding objects. This method always returns
null
when the binding object comes from a different AST.
Use findDeclaringNode(binding.getKey())
when the binding comes
from a different AST.
binding
- the bindingnull
if the binding does not correspond to a node in this
compilation unit or if bindings were not requested when this AST was builtfindDeclaringNode(java.lang.String)
public ASTNode findDeclaringNode(String key)
null
if the corresponding node cannot be determined.
This method always returns null
if bindings were not requested
when this AST was built.
The following table indicates the expected node type for the various different kinds of binding keys:
PackageDeclaration
TypeDeclaration
or a
ClassInstanceCreation
(for anonymous classes) VariableDeclarationFragment
in a
FieldDeclaration
SingleVariableDeclaration
, or
a VariableDeclarationFragment
in a
VariableDeclarationStatement
or
VariableDeclarationExpression
MethodDeclaration
MethodDeclaration
key
- the binding key, or null
null
if the key is null
or if the key does not correspond to a node in this compilation unit
or if bindings were not requested when this AST was builtIBinding.getKey()
public int lineNumber(int position)
class A\n{\n}
has 3 lines
corresponding to inclusive character ranges [0,7], [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 range1
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()
This list of messages is suitable for simple clients that do little
more than log the messages or display them to the user. Clients that
need further details should call getProblems
to get
compiler problem objects.
getProblems()
,
AST.parseCompilationUnit(org.eclipse.jdt.core.ICompilationUnit, boolean)
public IProblem[] getProblems()
Simple clients that do little more than log the messages or display
them to the user should probably call getMessages
instead.
getMessages()
,
AST.parseCompilationUnit(org.eclipse.jdt.core.ICompilationUnit, boolean)
|
Eclipse JDT 2.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |