Compiler Tree API

com.sun.source.util
クラス TreeScanner<R,P>

java.lang.Object
  上位を拡張 com.sun.source.util.TreeScanner<R,P>
すべての実装されたインタフェース:
TreeVisitor<R,P>
直系の既知のサブクラス:
TreePathScanner

public class TreeScanner<R,P>
extends Object
implements TreeVisitor<R,P>

すべての子ツリーノードを巡回する TreeVisitor です。特定の型のノードを巡回するには、対応する visitXYZ メソッドを単にオーバーライドします。独自のメソッド内では、super.visitXYZ を呼び出して、下位ノードを巡回します。

visitXYZ メソッドのデフォルトの実装では、次の結果になります。

ツリー内の識別子ノードの数をカウントする例を次に示します。

   class CountIdentifiers extends TreeScanner {
        @Override
        public Integer visitIdentifier(IdentifierTree node, Void p) { 
            return 1; 
        }
        @Override
        public Integer reduce(Integer r1, Integer r2) { 
            return (r1 == null ? 0 : r1) + (r2 == null ? 0 : r2); 
        }
   }
 

導入されたバージョン:
1.6

コンストラクタの概要
TreeScanner()
           
 
メソッドの概要
 R reduce(R r1, R r2)
          2 つの結果を 1 つの結合された結果にします。
 R scan(Iterable<? extends Tree> nodes, P p)
          ノードのリストをスキャンします。
 R scan(Tree node, P p)
          単一ノードをスキャンします。
 R visitAnnotation(AnnotationTree node, P p)
           
 R visitArrayAccess(ArrayAccessTree node, P p)
           
 R visitArrayType(ArrayTypeTree node, P p)
           
 R visitAssert(AssertTree node, P p)
           
 R visitAssignment(AssignmentTree node, P p)
           
 R visitBinary(BinaryTree node, P p)
           
 R visitBlock(BlockTree node, P p)
           
 R visitBreak(BreakTree node, P p)
           
 R visitCase(CaseTree node, P p)
           
 R visitCatch(CatchTree node, P p)
           
 R visitClass(ClassTree node, P p)
           
 R visitCompilationUnit(CompilationUnitTree node, P p)
           
 R visitCompoundAssignment(CompoundAssignmentTree node, P p)
           
 R visitConditionalExpression(ConditionalExpressionTree node, P p)
           
 R visitContinue(ContinueTree node, P p)
           
 R visitDoWhileLoop(DoWhileLoopTree node, P p)
           
 R visitEmptyStatement(EmptyStatementTree node, P p)
           
 R visitEnhancedForLoop(EnhancedForLoopTree node, P p)
           
 R visitErroneous(ErroneousTree node, P p)
           
 R visitExpressionStatement(ExpressionStatementTree node, P p)
           
 R visitForLoop(ForLoopTree node, P p)
           
 R visitIdentifier(IdentifierTree node, P p)
           
 R visitIf(IfTree node, P p)
           
 R visitImport(ImportTree node, P p)
           
 R visitInstanceOf(InstanceOfTree node, P p)
           
 R visitLabeledStatement(LabeledStatementTree node, P p)
           
 R visitLiteral(LiteralTree node, P p)
           
 R visitMemberSelect(MemberSelectTree node, P p)
           
 R visitMethod(MethodTree node, P p)
           
 R visitMethodInvocation(MethodInvocationTree node, P p)
           
 R visitModifiers(ModifiersTree node, P p)
           
 R visitNewArray(NewArrayTree node, P p)
           
 R visitNewClass(NewClassTree node, P p)
           
 R visitOther(Tree node, P p)
           
 R visitParameterizedType(ParameterizedTypeTree node, P p)
           
 R visitParenthesized(ParenthesizedTree node, P p)
           
 R visitPrimitiveType(PrimitiveTypeTree node, P p)
           
 R visitReturn(ReturnTree node, P p)
           
 R visitSwitch(SwitchTree node, P p)
           
 R visitSynchronized(SynchronizedTree node, P p)
           
 R visitThrow(ThrowTree node, P p)
           
 R visitTry(TryTree node, P p)
           
 R visitTypeCast(TypeCastTree node, P p)
           
 R visitTypeParameter(TypeParameterTree node, P p)
           
 R visitUnary(UnaryTree node, P p)
           
 R visitVariable(VariableTree node, P p)
           
 R visitWhileLoop(WhileLoopTree node, P p)
           
 R visitWildcard(WildcardTree node, P p)
           
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

TreeScanner

public TreeScanner()
メソッドの詳細

scan

public R scan(Tree node,
              P p)
単一ノードをスキャンします。


scan

public R scan(Iterable<? extends Tree> nodes,
              P p)
ノードのリストをスキャンします。


reduce

public R reduce(R r1,
                R r2)
2 つの結果を 1 つの結合された結果にします。デフォルトの実装では、1 番目のパラメータを返します。メソッドの一般的な規約によれば、メソッドはどのようなアクションを実行してもかまいません。


visitCompilationUnit

public R visitCompilationUnit(CompilationUnitTree node,
                              P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitCompilationUnit

visitImport

public R visitImport(ImportTree node,
                     P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitImport

visitClass

public R visitClass(ClassTree node,
                    P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitClass

visitMethod

public R visitMethod(MethodTree node,
                     P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitMethod

visitVariable

public R visitVariable(VariableTree node,
                       P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitVariable

visitEmptyStatement

public R visitEmptyStatement(EmptyStatementTree node,
                             P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitEmptyStatement

visitBlock

public R visitBlock(BlockTree node,
                    P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitBlock

visitDoWhileLoop

public R visitDoWhileLoop(DoWhileLoopTree node,
                          P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitDoWhileLoop

visitWhileLoop

public R visitWhileLoop(WhileLoopTree node,
                        P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitWhileLoop

visitForLoop

public R visitForLoop(ForLoopTree node,
                      P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitForLoop

visitEnhancedForLoop

public R visitEnhancedForLoop(EnhancedForLoopTree node,
                              P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitEnhancedForLoop

visitLabeledStatement

public R visitLabeledStatement(LabeledStatementTree node,
                               P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitLabeledStatement

visitSwitch

public R visitSwitch(SwitchTree node,
                     P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitSwitch

visitCase

public R visitCase(CaseTree node,
                   P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitCase

visitSynchronized

public R visitSynchronized(SynchronizedTree node,
                           P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitSynchronized

visitTry

public R visitTry(TryTree node,
                  P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitTry

visitCatch

public R visitCatch(CatchTree node,
                    P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitCatch

visitConditionalExpression

public R visitConditionalExpression(ConditionalExpressionTree node,
                                    P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitConditionalExpression

visitIf

public R visitIf(IfTree node,
                 P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitIf

visitExpressionStatement

public R visitExpressionStatement(ExpressionStatementTree node,
                                  P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitExpressionStatement

visitBreak

public R visitBreak(BreakTree node,
                    P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitBreak

visitContinue

public R visitContinue(ContinueTree node,
                       P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitContinue

visitReturn

public R visitReturn(ReturnTree node,
                     P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitReturn

visitThrow

public R visitThrow(ThrowTree node,
                    P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitThrow

visitAssert

public R visitAssert(AssertTree node,
                     P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitAssert

visitMethodInvocation

public R visitMethodInvocation(MethodInvocationTree node,
                               P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitMethodInvocation

visitNewClass

public R visitNewClass(NewClassTree node,
                       P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitNewClass

visitNewArray

public R visitNewArray(NewArrayTree node,
                       P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitNewArray

visitParenthesized

public R visitParenthesized(ParenthesizedTree node,
                            P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitParenthesized

visitAssignment

public R visitAssignment(AssignmentTree node,
                         P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitAssignment

visitCompoundAssignment

public R visitCompoundAssignment(CompoundAssignmentTree node,
                                 P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitCompoundAssignment

visitUnary

public R visitUnary(UnaryTree node,
                    P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitUnary

visitBinary

public R visitBinary(BinaryTree node,
                     P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitBinary

visitTypeCast

public R visitTypeCast(TypeCastTree node,
                       P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitTypeCast

visitInstanceOf

public R visitInstanceOf(InstanceOfTree node,
                         P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitInstanceOf

visitArrayAccess

public R visitArrayAccess(ArrayAccessTree node,
                          P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitArrayAccess

visitMemberSelect

public R visitMemberSelect(MemberSelectTree node,
                           P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitMemberSelect

visitIdentifier

public R visitIdentifier(IdentifierTree node,
                         P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitIdentifier

visitLiteral

public R visitLiteral(LiteralTree node,
                      P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitLiteral

visitPrimitiveType

public R visitPrimitiveType(PrimitiveTypeTree node,
                            P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitPrimitiveType

visitArrayType

public R visitArrayType(ArrayTypeTree node,
                        P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitArrayType

visitParameterizedType

public R visitParameterizedType(ParameterizedTypeTree node,
                                P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitParameterizedType

visitTypeParameter

public R visitTypeParameter(TypeParameterTree node,
                            P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitTypeParameter

visitWildcard

public R visitWildcard(WildcardTree node,
                       P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitWildcard

visitModifiers

public R visitModifiers(ModifiersTree node,
                        P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitModifiers

visitAnnotation

public R visitAnnotation(AnnotationTree node,
                         P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitAnnotation

visitOther

public R visitOther(Tree node,
                    P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitOther

visitErroneous

public R visitErroneous(ErroneousTree node,
                        P p)
定義:
インタフェース TreeVisitor<R,P> 内の visitErroneous

Compiler Tree API

Report a bug or request a feature.
Copyright Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.