当前页面:
在线文档首页 >
NetBeans API Javadoc (Current Development Version)
TreeUtilities (Java Source) - NetBeans API Javadoc (Current Development Version)
org.netbeans.api.java.source
Class TreeUtilities
java.lang.Object
org.netbeans.api.java.source.TreeUtilities
public final class TreeUtilities
- extends Object
Method Summary |
TypeMirror |
attributeTree(Tree tree,
Scope scope)
|
Scope |
attributeTreeTo(Tree tree,
Scope scope,
Tree to)
|
StatementTree |
getBreakContinueTarget(CompilationInfo info,
TreePath breakOrContinue)
Find the target of break or continue . |
List<Comment> |
getComments(Tree tree,
boolean preceding)
Returns list of comments attached to a given tree. |
Set<TypeMirror> |
getUncaughtExceptions(TreePath path)
|
boolean |
isAccessible(Scope scope,
Element member,
TypeMirror type)
|
boolean |
isAnnotation(ClassTree tree)
|
boolean |
isEnum(ClassTree tree)
|
boolean |
isInterface(ClassTree tree)
|
boolean |
isStaticContext(Scope scope)
|
boolean |
isSynthetic(TreePath path)
Returns whether or not the given tree is synthetic - generated by the parser. |
ExpressionTree |
parseExpression(String expr,
SourcePositions[] sourcePositions)
|
StatementTree |
parseStatement(String stmt,
SourcePositions[] sourcePositions)
|
BlockTree |
parseStaticBlock(String block,
SourcePositions[] sourcePositions)
|
TypeMirror |
parseType(String expr,
TypeElement scope)
|
ExpressionTree |
parseVariableInitializer(String init,
SourcePositions[] sourcePositions)
|
TreePath |
pathFor(int pos)
|
TreePath |
pathFor(TreePath path,
int pos)
|
TreePath |
pathFor(TreePath path,
int pos,
SourcePositions sourcePositions)
|
TypeMirror |
reattributeTree(Tree tree,
Scope scope)
|
Scope |
reattributeTreeTo(Tree tree,
Scope scope,
Tree to)
|
Scope |
scopeFor(int pos)
|
TokenSequence<org.netbeans.api.java.lexer.JavaTokenId> |
tokensFor(Tree tree)
|
TokenSequence<org.netbeans.api.java.lexer.JavaTokenId> |
tokensFor(Tree tree,
SourcePositions sourcePositions)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
isInterface
public boolean isInterface(ClassTree tree)
isEnum
public boolean isEnum(ClassTree tree)
isAnnotation
public boolean isAnnotation(ClassTree tree)
isSynthetic
public boolean isSynthetic(TreePath path)
throws NullPointerException
- Returns whether or not the given tree is synthetic - generated by the parser.
- Returns:
- true if the given tree is synthetic, false otherwise
- Throws:
NullPointerException
- if the given tree is null
getComments
public List<Comment> getComments(Tree tree,
boolean preceding)
- Returns list of comments attached to a given tree. Can return either
preceding or trailing comments.
- Parameters:
tree
- for which comments should be returnedpreceding
- true if preceding comments should be returned, false if trailing comments should be returned.
- Returns:
- list of preceding/trailing comments attached to the given tree
pathFor
public TreePath pathFor(int pos)
pathFor
public TreePath pathFor(TreePath path,
int pos)
pathFor
public TreePath pathFor(TreePath path,
int pos,
SourcePositions sourcePositions)
parseType
public TypeMirror parseType(String expr,
TypeElement scope)
parseStatement
public StatementTree parseStatement(String stmt,
SourcePositions[] sourcePositions)
parseExpression
public ExpressionTree parseExpression(String expr,
SourcePositions[] sourcePositions)
parseVariableInitializer
public ExpressionTree parseVariableInitializer(String init,
SourcePositions[] sourcePositions)
parseStaticBlock
public BlockTree parseStaticBlock(String block,
SourcePositions[] sourcePositions)
scopeFor
public Scope scopeFor(int pos)
attributeTree
public TypeMirror attributeTree(Tree tree,
Scope scope)
attributeTreeTo
public Scope attributeTreeTo(Tree tree,
Scope scope,
Tree to)
reattributeTree
public TypeMirror reattributeTree(Tree tree,
Scope scope)
reattributeTreeTo
public Scope reattributeTreeTo(Tree tree,
Scope scope,
Tree to)
tokensFor
public TokenSequence<org.netbeans.api.java.lexer.JavaTokenId> tokensFor(Tree tree)
tokensFor
public TokenSequence<org.netbeans.api.java.lexer.JavaTokenId> tokensFor(Tree tree,
SourcePositions sourcePositions)
isAccessible
public boolean isAccessible(Scope scope,
Element member,
TypeMirror type)
isStaticContext
public boolean isStaticContext(Scope scope)
getUncaughtExceptions
public Set<TypeMirror> getUncaughtExceptions(TreePath path)
getBreakContinueTarget
public StatementTree getBreakContinueTarget(CompilationInfo info,
TreePath breakOrContinue)
throws IllegalArgumentException
- Find the target of
break
or continue
. The given
CompilationInfo
has to be at least in the JavaSource.Phase.RESOLVED
phase.
- Parameters:
info
- CompilationInfo to work againstbreakOrContinue
- TreePath
to the tree that should be inspected.
The breakOrContinue.getLeaf().getKind()
has to be either Tree.Kind.BREAK
or Tree.Kind.CONTINUE
, or
an IllegalArgumentException is thrown
- Returns:
- the tree that is the "target" for the given break or continue statement, or null if there is none.
- Throws:
IllegalArgumentException
- if the given tree is not a break or continue tree or if the given CompilationInfo
is not in the JavaSource.Phase.RESOLVED
phase.- Since:
- 0.11