- Type Parameters:
R
- the return type of this visitor's methods. UseVoid
for visitors that do not need to return results.P
- the type of the additional parameter to this visitor's methods. UseVoid
for visitors that do not need an additional parameter.
- All Known Implementing Classes:
SimpleTreeVisitor
,TreePathScanner
,TreeScanner
public interface TreeVisitor<R,P>
TreeVisitor
relies on preview features of the Java platform:
TreeVisitor
refers to one or more reflective preview APIs:DefaultCaseLabelTree
,GuardedPatternTree
,ParenthesizedPatternTree
.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
A visitor of trees, in the style of the visitor design pattern.
Classes implementing this interface are used to operate
on a tree when the kind of tree is unknown at compile time.
When a visitor is passed to an tree's
accept
method, the visitXyz
method most applicable
to that tree is invoked.
Classes implementing this interface may or may not throw a
NullPointerException
if the additional parameter p
is null
; see documentation of the implementing class for
details.
WARNING: It is possible that methods will be added to this interface to accommodate new, currently unknown, language structures added to future versions of the Java programming language. Therefore, visitor classes directly implementing this interface may be source incompatible with future versions of the platform.
- Since:
- 1.6
-
Method Summary
Modifier and TypeMethodDescriptionvisitAnnotatedType
(AnnotatedTypeTree node, P p) Visits an AnnotatedTypeTree node.visitAnnotation
(AnnotationTree node, P p) Visits an AnnotatedTree node.visitArrayAccess
(ArrayAccessTree node, P p) Visits an ArrayAccessTree node.visitArrayType
(ArrayTypeTree node, P p) Visits an ArrayTypeTree node.visitAssert
(AssertTree node, P p) Visits an AssertTree node.visitAssignment
(AssignmentTree node, P p) Visits an AssignmentTree node.visitBinary
(BinaryTree node, P p) Visits a BinaryTree node.visitBindingPattern
(BindingPatternTree node, P p) Visits an BindingPattern node.visitBlock
(BlockTree node, P p) Visits a BlockTree node.visitBreak
(BreakTree node, P p) Visits a BreakTree node.Visits a CaseTree node.visitCatch
(CatchTree node, P p) Visits a CatchTree node.visitClass
(ClassTree node, P p) Visits a ClassTree node.visitCompilationUnit
(CompilationUnitTree node, P p) Visits a CompilationUnitTree node.Visits a CompoundAssignmentTree node.Visits a ConditionalExpressionTree node.visitContinue
(ContinueTree node, P p) Visits a ContinueTree node.Preview.Visits a DefaultCaseLabelTree node.visitDoWhileLoop
(DoWhileLoopTree node, P p) Visits a DoWhileTree node.visitEmptyStatement
(EmptyStatementTree node, P p) Visits an EmptyStatementTree node.visitEnhancedForLoop
(EnhancedForLoopTree node, P p) Visits an EnhancedForLoopTree node.visitErroneous
(ErroneousTree node, P p) Visits an ErroneousTree node.visitExports
(ExportsTree node, P p) Visits an ExportsTree node.Visits an ExpressionStatementTree node.visitForLoop
(ForLoopTree node, P p) Visits a ForLoopTree node.Preview.Visits a GuardPatternTree node.visitIdentifier
(IdentifierTree node, P p) Visits an IdentifierTree node.Visits an IfTree node.visitImport
(ImportTree node, P p) Visits an ImportTree node.visitInstanceOf
(InstanceOfTree node, P p) Visits an InstanceOfTree node.visitIntersectionType
(IntersectionTypeTree node, P p) Visits an IntersectionTypeTree node.visitLabeledStatement
(LabeledStatementTree node, P p) Visits a LabeledStatementTree node.visitLambdaExpression
(LambdaExpressionTree node, P p) Visits a LambdaExpressionTree node.visitLiteral
(LiteralTree node, P p) Visits a LiteralTree node.visitMemberReference
(MemberReferenceTree node, P p) Visits a MemberReferenceTree node.visitMemberSelect
(MemberSelectTree node, P p) Visits a MemberSelectTree node.visitMethod
(MethodTree node, P p) Visits a MethodTree node.visitMethodInvocation
(MethodInvocationTree node, P p) Visits a MethodInvocationTree node.visitModifiers
(ModifiersTree node, P p) Visits a ModifiersTree node.visitModule
(ModuleTree node, P p) Visits a ModuleTree node.visitNewArray
(NewArrayTree node, P p) Visits a NewArrayTree node.visitNewClass
(NewClassTree node, P p) Visits a NewClassTree node.visitOpens
(OpensTree node, P p) Visits an OpensTree node.visitOther
(Tree node, P p) Visits an unknown type of Tree node.visitPackage
(PackageTree node, P p) Visits a PackageTree node.visitParameterizedType
(ParameterizedTypeTree node, P p) Visits a ParameterizedTypeTree node.visitParenthesized
(ParenthesizedTree node, P p) Visits a ParenthesizedTree node.Preview.Visits a ParenthesizedPatternTree node.visitPrimitiveType
(PrimitiveTypeTree node, P p) Visits a PrimitiveTypeTree node.visitProvides
(ProvidesTree node, P p) Visits a ProvidesTree node.visitRequires
(RequiresTree node, P p) Visits a RequiresTree node.visitReturn
(ReturnTree node, P p) Visits a ReturnTree node.visitSwitch
(SwitchTree node, P p) Visits a SwitchTree node.visitSwitchExpression
(SwitchExpressionTree node, P p) Visits a SwitchExpressionTree node.visitSynchronized
(SynchronizedTree node, P p) Visits a SynchronizedTree node.visitThrow
(ThrowTree node, P p) Visits a ThrowTree node.Visits a TryTree node.visitTypeCast
(TypeCastTree node, P p) Visits a TypeCastTree node.visitTypeParameter
(TypeParameterTree node, P p) Visits a TypeParameterTree node.visitUnary
(UnaryTree node, P p) Visits a UnaryTree node.visitUnionType
(UnionTypeTree node, P p) Visits a UnionTypeTree node.Visits a UsesTree node.visitVariable
(VariableTree node, P p) Visits a VariableTree node.visitWhileLoop
(WhileLoopTree node, P p) Visits a WhileLoopTree node.visitWildcard
(WildcardTree node, P p) Visits a WildcardTypeTree node.visitYield
(YieldTree node, P p) Visits a YieldTree node.
-
Method Details
-
visitAnnotatedType
Visits an AnnotatedTypeTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitAnnotation
Visits an AnnotatedTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitMethodInvocation
Visits a MethodInvocationTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitAssert
Visits an AssertTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitAssignment
Visits an AssignmentTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitCompoundAssignment
Visits a CompoundAssignmentTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitBinary
Visits a BinaryTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitBlock
Visits a BlockTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitBreak
Visits a BreakTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitCase
Visits a CaseTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitCatch
Visits a CatchTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitClass
Visits a ClassTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitConditionalExpression
Visits a ConditionalExpressionTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitContinue
Visits a ContinueTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitDoWhileLoop
Visits a DoWhileTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitErroneous
Visits an ErroneousTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitExpressionStatement
Visits an ExpressionStatementTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitEnhancedForLoop
Visits an EnhancedForLoopTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitForLoop
Visits a ForLoopTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitIdentifier
Visits an IdentifierTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitIf
Visits an IfTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitImport
Visits an ImportTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitArrayAccess
Visits an ArrayAccessTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitLabeledStatement
Visits a LabeledStatementTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitLiteral
Visits a LiteralTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitBindingPattern
Visits an BindingPattern node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
- Since:
- 16
-
visitDefaultCaseLabel
visitDefaultCaseLabel
is a reflective preview API of the Java platform.Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.Visits a DefaultCaseLabelTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
- Since:
- 17
-
visitMethod
Visits a MethodTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitModifiers
Visits a ModifiersTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitNewArray
Visits a NewArrayTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitGuardedPattern
visitGuardedPattern
is a reflective preview API of the Java platform.Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.Visits a GuardPatternTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
- Since:
- 17
-
visitParenthesizedPattern
visitParenthesizedPattern
is a reflective preview API of the Java platform.Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.Visits a ParenthesizedPatternTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
- Since:
- 17
-
visitNewClass
Visits a NewClassTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitLambdaExpression
Visits a LambdaExpressionTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitPackage
Visits a PackageTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitParenthesized
Visits a ParenthesizedTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitReturn
Visits a ReturnTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitMemberSelect
Visits a MemberSelectTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitMemberReference
Visits a MemberReferenceTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitEmptyStatement
Visits an EmptyStatementTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitSwitch
Visits a SwitchTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitSwitchExpression
Visits a SwitchExpressionTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
- Since:
- 12
-
visitSynchronized
Visits a SynchronizedTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitThrow
Visits a ThrowTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitCompilationUnit
Visits a CompilationUnitTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitTry
Visits a TryTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitParameterizedType
Visits a ParameterizedTypeTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitUnionType
Visits a UnionTypeTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitIntersectionType
Visits an IntersectionTypeTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitArrayType
Visits an ArrayTypeTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitTypeCast
Visits a TypeCastTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitPrimitiveType
Visits a PrimitiveTypeTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitTypeParameter
Visits a TypeParameterTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitInstanceOf
Visits an InstanceOfTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitUnary
Visits a UnaryTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitVariable
Visits a VariableTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitWhileLoop
Visits a WhileLoopTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitWildcard
Visits a WildcardTypeTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitModule
Visits a ModuleTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitExports
Visits an ExportsTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitOpens
Visits an OpensTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitProvides
Visits a ProvidesTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitRequires
Visits a RequiresTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitUses
Visits a UsesTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitOther
Visits an unknown type of Tree node. This can occur if the language evolves and new kinds of nodes are added to theTree
hierarchy.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
-
visitYield
Visits a YieldTree node.- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- a result value
- Since:
- 13
-
TreeVisitor
when preview features are enabled.