- 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:
SimpleTreeVisitorES5_1
,SimpleTreeVisitorES6
public interface TreeVisitor<R,P>
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 ECMAScript programming language. When new visit methods are added for new Tree subtypes, default method bodies will be introduced which will call visitUnknown method as a fallback.
- Since:
- 9
-
Method Summary
Modifier and TypeMethodDescriptionvisitArrayAccess
(ArrayAccessTree node, P p) Visit array access expression tree.visitArrayLiteral
(ArrayLiteralTree node, P p) Visit array literal expression tree.visitAssignment
(AssignmentTree node, P p) Visit assignment tree.visitBinary
(BinaryTree node, P p) Visit binary expression tree.visitBlock
(BlockTree node, P p) Visit block statement tree.visitBreak
(BreakTree node, P p) Visit break statement tree.Visit case statement tree.visitCatch
(CatchTree node, P p) Visit catch block statement tree.visitClassDeclaration
(ClassDeclarationTree node, P p) Visit class statement tree.visitClassExpression
(ClassExpressionTree node, P p) Visit class expression tree.visitCompilationUnit
(CompilationUnitTree node, P p) Visit compilation unit tree.Visit compound assignment tree.Visit conditional expression tree.visitContinue
(ContinueTree node, P p) Visit continue statement tree.visitDebugger
(DebuggerTree node, P p) Visit debugger statement tree.visitDoWhileLoop
(DoWhileLoopTree node, P p) Visit do-while statement tree.visitEmptyStatement
(EmptyStatementTree node, P p) Visit an empty statement tree.visitErroneous
(ErroneousTree node, P p) Visit error expression tree.visitExportEntry
(ExportEntryTree node, P p) Visit Module ExportEntry tree.Visit expression statement tree.visitForInLoop
(ForInLoopTree node, P p) Visit for..in statement tree.visitForLoop
(ForLoopTree node, P p) Visit 'for' statement tree.visitForOfLoop
(ForOfLoopTree node, P p) Visit for..of statement tree.visitFunctionCall
(FunctionCallTree node, P p) Visit function call expression tree.Visit function declaration tree.Visit function expression tree.visitIdentifier
(IdentifierTree node, P p) Visit identifier tree.Visit 'if' statement tree.visitImportEntry
(ImportEntryTree node, P p) Visit Module ImportEntry tree.visitInstanceOf
(InstanceOfTree node, P p) Visit 'instanceof' expression tree.visitLabeledStatement
(LabeledStatementTree node, P p) Visit labeled statement tree.visitLiteral
(LiteralTree node, P p) Visit literal expression tree.visitMemberSelect
(MemberSelectTree node, P p) Visit member select expression tree.visitModule
(ModuleTree node, P p) Visit Module tree.Visit 'new' expression tree.visitObjectLiteral
(ObjectLiteralTree node, P p) Visit object literal tree.visitParenthesized
(ParenthesizedTree node, P p) Visit parenthesized expression tree.visitProperty
(PropertyTree node, P p) Visit a property of an object literal expression tree.visitRegExpLiteral
(RegExpLiteralTree node, P p) Visit regular expression literal tree.visitReturn
(ReturnTree node, P p) Visit return statement tree.visitSpread
(SpreadTree node, P p) Visit 'spread' expression tree.visitSwitch
(SwitchTree node, P p) Visit 'switch' statement tree.visitTemplateLiteral
(TemplateLiteralTree node, P p) Visit template literal tree.visitThrow
(ThrowTree node, P p) Visit 'throw' expression tree.Visit 'try' statement tree.visitUnary
(UnaryTree node, P p) Visit unary expression tree.visitUnknown
(Tree node, P p) Visit unknown expression/statement tree.visitVariable
(VariableTree node, P p) Visit variable declaration tree.visitWhileLoop
(WhileLoopTree node, P p) Visit 'while' statement tree.Visit 'with' statement tree.visitYield
(YieldTree node, P p) Visit 'yield' expression tree.
-
Method Details
-
visitAssignment
Visit assignment tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitCompoundAssignment
Visit compound assignment tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitBinary
Visit binary expression tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitBlock
Visit block statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitBreak
Visit break statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitCase
Visit case statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitCatch
Visit catch block statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitClassDeclaration
Visit class statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitClassExpression
Visit class expression tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitConditionalExpression
Visit conditional expression tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitContinue
Visit continue statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitDebugger
Visit debugger statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitDoWhileLoop
Visit do-while statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitErroneous
Visit error expression tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitExpressionStatement
Visit expression statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitForLoop
Visit 'for' statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitForInLoop
Visit for..in statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitForOfLoop
Visit for..of statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitFunctionCall
Visit function call expression tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitFunctionDeclaration
Visit function declaration tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitFunctionExpression
Visit function expression tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitIdentifier
Visit identifier tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitIf
Visit 'if' statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitArrayAccess
Visit array access expression tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitArrayLiteral
Visit array literal expression tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitLabeledStatement
Visit labeled statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitLiteral
Visit literal expression tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitParenthesized
Visit parenthesized expression tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitReturn
Visit return statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitMemberSelect
Visit member select expression tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitNew
Visit 'new' expression tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitObjectLiteral
Visit object literal tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitProperty
Visit a property of an object literal expression tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitRegExpLiteral
Visit regular expression literal tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitTemplateLiteral
Visit template literal tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitEmptyStatement
Visit an empty statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitSpread
Visit 'spread' expression tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitSwitch
Visit 'switch' statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitThrow
Visit 'throw' expression tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitCompilationUnit
Visit compilation unit tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitModule
Visit Module tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitExportEntry
Visit Module ExportEntry tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitImportEntry
Visit Module ImportEntry tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitTry
Visit 'try' statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitInstanceOf
Visit 'instanceof' expression tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitUnary
Visit unary expression tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitVariable
Visit variable declaration tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitWhileLoop
Visit 'while' statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitWith
Visit 'with' statement tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitYield
Visit 'yield' expression tree.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitUnknown
Visit unknown expression/statement tree. This fallback will be called if new Tree subtypes are introduced in future. A specific implementation may throw {unknown tree exception if the visitor implementation was for an older language version.- Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- value from the visitor
-