java.lang.Object
org.openjdk.nashorn.api.tree.SimpleTreeVisitorES5_1<R,P>
- 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 Implemented Interfaces:
TreeVisitor<R,
P>
- Direct Known Subclasses:
SimpleTreeVisitorES6
A simple implementation of the TreeVisitor for ECMAScript edition 5.1.
The visit methods corresponding to ES 5.1 language constructs walk the "components" of the given tree by calling accept method passing the current visitor and the additional parameter.
For constructs introduced in later versions, visitUnknown
is called instead which throws UnknownTreeException
.
Methods in this class may be overridden subject to their
general contract. Note that annotating methods in concrete
subclasses with @Override
will help
ensure that methods are overridden as intended.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvisitArrayAccess
(ArrayAccessTree node, P r) Visit array access expression tree.visitArrayLiteral
(ArrayLiteralTree node, P r) Visit array literal expression tree.visitAssignment
(AssignmentTree node, P r) Visit assignment tree.visitBinary
(BinaryTree node, P r) Visit binary expression tree.visitBlock
(BlockTree node, P r) Visit block statement tree.visitBreak
(BreakTree node, P r) Visit break statement tree.Visit case statement tree.visitCatch
(CatchTree node, P r) Visit catch block statement tree.visitClassDeclaration
(ClassDeclarationTree node, P p) Visits aClassDeclarationTree
tree by callingvisitUnknown
.visitClassExpression
(ClassExpressionTree node, P p) Visits aClassExpressionTree
tree by callingvisitUnknown
.visitCompilationUnit
(CompilationUnitTree node, P r) Visit compilation unit tree.Visit compound assignment tree.Visit conditional expression tree.visitContinue
(ContinueTree node, P r) Visit continue statement tree.visitDebugger
(DebuggerTree node, P r) Visit debugger statement tree.visitDoWhileLoop
(DoWhileLoopTree node, P r) Visit do-while statement tree.visitEmptyStatement
(EmptyStatementTree node, P r) Visit an empty statement tree.visitErroneous
(ErroneousTree node, P r) Visit error expression tree.visitExportEntry
(ExportEntryTree node, P p) Visits anExportEntryTree
tree by callingvisitUnknown
.Visit expression statement tree.visitForInLoop
(ForInLoopTree node, P r) Visit for..in statement tree.visitForLoop
(ForLoopTree node, P r) Visit 'for' statement tree.visitForOfLoop
(ForOfLoopTree node, P p) Visits aForOfLoopTree
tree by callingvisitUnknown
.visitFunctionCall
(FunctionCallTree node, P r) Visit function call expression tree.Visit function declaration tree.Visit function expression tree.visitIdentifier
(IdentifierTree node, P r) Visit identifier tree.Visit 'if' statement tree.visitImportEntry
(ImportEntryTree node, P p) Visits anImportEntryTree
tree by callingvisitUnknown
.visitInstanceOf
(InstanceOfTree node, P r) Visit 'instanceof' expression tree.visitLabeledStatement
(LabeledStatementTree node, P r) Visit labeled statement tree.visitLiteral
(LiteralTree node, P r) Visit literal expression tree.visitMemberSelect
(MemberSelectTree node, P r) Visit member select expression tree.visitModule
(ModuleTree node, P p) Visits aModuleTree
tree by callingvisitUnknown
.Visit 'new' expression tree.visitObjectLiteral
(ObjectLiteralTree node, P r) Visit object literal tree.visitParenthesized
(ParenthesizedTree node, P r) Visit parenthesized expression tree.visitProperty
(PropertyTree node, P r) Visit a property of an object literal expression tree.visitRegExpLiteral
(RegExpLiteralTree node, P r) Visit regular expression literal tree.visitReturn
(ReturnTree node, P r) Visit return statement tree.visitSpread
(SpreadTree node, P p) Visits aSpreadTree
tree by callingvisitUnknown
.visitSwitch
(SwitchTree node, P r) Visit 'switch' statement tree.visitTemplateLiteral
(TemplateLiteralTree node, P p) Visits aTemplateLiteralTree
tree by callingvisitUnknown
.visitThrow
(ThrowTree node, P r) Visit 'throw' expression tree.Visit 'try' statement tree.visitUnary
(UnaryTree node, P r) Visit unary expression tree.visitUnknown
(Tree node, P p) Visit unknown expression/statement tree.visitVariable
(VariableTree node, P r) Visit variable declaration tree.visitWhileLoop
(WhileLoopTree node, P r) Visit 'while' statement tree.Visit 'with' statement tree.visitYield
(YieldTree node, P p) Visits aYieldTree
tree by callingvisitUnknown
.
-
Constructor Details
-
SimpleTreeVisitorES5_1
public SimpleTreeVisitorES5_1()
-
-
Method Details
-
visitAssignment
Description copied from interface:TreeVisitor
Visit assignment tree.- Specified by:
visitAssignment
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitCompoundAssignment
Description copied from interface:TreeVisitor
Visit compound assignment tree.- Specified by:
visitCompoundAssignment
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitModule
Visits aModuleTree
tree by callingvisitUnknown
.- Specified by:
visitModule
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- the result of
visitUnknown
-
visitExportEntry
Visits anExportEntryTree
tree by callingvisitUnknown
.- Specified by:
visitExportEntry
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- the result of
visitUnknown
-
visitImportEntry
Visits anImportEntryTree
tree by callingvisitUnknown
.- Specified by:
visitImportEntry
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- the result of
visitUnknown
-
visitBinary
Description copied from interface:TreeVisitor
Visit binary expression tree.- Specified by:
visitBinary
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitBlock
Description copied from interface:TreeVisitor
Visit block statement tree.- Specified by:
visitBlock
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitBreak
Description copied from interface:TreeVisitor
Visit break statement tree.- Specified by:
visitBreak
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitCase
Description copied from interface:TreeVisitor
Visit case statement tree.- Specified by:
visitCase
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitCatch
Description copied from interface:TreeVisitor
Visit catch block statement tree.- Specified by:
visitCatch
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitClassDeclaration
Visits aClassDeclarationTree
tree by callingvisitUnknown
.- Specified by:
visitClassDeclaration
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- the result of
visitUnknown
-
visitClassExpression
Visits aClassExpressionTree
tree by callingvisitUnknown
.- Specified by:
visitClassExpression
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- the result of
visitUnknown
-
visitConditionalExpression
Description copied from interface:TreeVisitor
Visit conditional expression tree.- Specified by:
visitConditionalExpression
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitContinue
Description copied from interface:TreeVisitor
Visit continue statement tree.- Specified by:
visitContinue
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitDebugger
Description copied from interface:TreeVisitor
Visit debugger statement tree.- Specified by:
visitDebugger
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitDoWhileLoop
Description copied from interface:TreeVisitor
Visit do-while statement tree.- Specified by:
visitDoWhileLoop
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitErroneous
Description copied from interface:TreeVisitor
Visit error expression tree.- Specified by:
visitErroneous
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitExpressionStatement
Description copied from interface:TreeVisitor
Visit expression statement tree.- Specified by:
visitExpressionStatement
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitForLoop
Description copied from interface:TreeVisitor
Visit 'for' statement tree.- Specified by:
visitForLoop
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitForInLoop
Description copied from interface:TreeVisitor
Visit for..in statement tree.- Specified by:
visitForInLoop
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitForOfLoop
Visits aForOfLoopTree
tree by callingvisitUnknown
.- Specified by:
visitForOfLoop
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- the result of
visitUnknown
-
visitFunctionCall
Description copied from interface:TreeVisitor
Visit function call expression tree.- Specified by:
visitFunctionCall
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitFunctionDeclaration
Description copied from interface:TreeVisitor
Visit function declaration tree.- Specified by:
visitFunctionDeclaration
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitFunctionExpression
Description copied from interface:TreeVisitor
Visit function expression tree.- Specified by:
visitFunctionExpression
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitIdentifier
Description copied from interface:TreeVisitor
Visit identifier tree.- Specified by:
visitIdentifier
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitIf
Description copied from interface:TreeVisitor
Visit 'if' statement tree.- Specified by:
visitIf
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitArrayAccess
Description copied from interface:TreeVisitor
Visit array access expression tree.- Specified by:
visitArrayAccess
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitArrayLiteral
Description copied from interface:TreeVisitor
Visit array literal expression tree.- Specified by:
visitArrayLiteral
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitLabeledStatement
Description copied from interface:TreeVisitor
Visit labeled statement tree.- Specified by:
visitLabeledStatement
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitLiteral
Description copied from interface:TreeVisitor
Visit literal expression tree.- Specified by:
visitLiteral
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitParenthesized
Description copied from interface:TreeVisitor
Visit parenthesized expression tree.- Specified by:
visitParenthesized
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitReturn
Description copied from interface:TreeVisitor
Visit return statement tree.- Specified by:
visitReturn
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitMemberSelect
Description copied from interface:TreeVisitor
Visit member select expression tree.- Specified by:
visitMemberSelect
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitNew
Description copied from interface:TreeVisitor
Visit 'new' expression tree.- Specified by:
visitNew
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitObjectLiteral
Description copied from interface:TreeVisitor
Visit object literal tree.- Specified by:
visitObjectLiteral
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitProperty
Description copied from interface:TreeVisitor
Visit a property of an object literal expression tree.- Specified by:
visitProperty
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitRegExpLiteral
Description copied from interface:TreeVisitor
Visit regular expression literal tree.- Specified by:
visitRegExpLiteral
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitTemplateLiteral
Visits aTemplateLiteralTree
tree by callingvisitUnknown
.- Specified by:
visitTemplateLiteral
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- the result of
visitUnknown
-
visitEmptyStatement
Description copied from interface:TreeVisitor
Visit an empty statement tree.- Specified by:
visitEmptyStatement
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitSpread
Visits aSpreadTree
tree by callingvisitUnknown
.- Specified by:
visitSpread
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- the result of
visitUnknown
-
visitSwitch
Description copied from interface:TreeVisitor
Visit 'switch' statement tree.- Specified by:
visitSwitch
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitThrow
Description copied from interface:TreeVisitor
Visit 'throw' expression tree.- Specified by:
visitThrow
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitCompilationUnit
Description copied from interface:TreeVisitor
Visit compilation unit tree.- Specified by:
visitCompilationUnit
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitTry
Description copied from interface:TreeVisitor
Visit 'try' statement tree.- Specified by:
visitTry
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitInstanceOf
Description copied from interface:TreeVisitor
Visit 'instanceof' expression tree.- Specified by:
visitInstanceOf
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitUnary
Description copied from interface:TreeVisitor
Visit unary expression tree.- Specified by:
visitUnary
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitVariable
Description copied from interface:TreeVisitor
Visit variable declaration tree.- Specified by:
visitVariable
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitWhileLoop
Description copied from interface:TreeVisitor
Visit 'while' statement tree.- Specified by:
visitWhileLoop
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitWith
Description copied from interface:TreeVisitor
Visit 'with' statement tree.- Specified by:
visitWith
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedr
- extra parameter passed to the visitor- Returns:
- value from the visitor
-
visitYield
Visits aYieldTree
tree by callingvisitUnknown
.- Specified by:
visitYield
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- the result of
visitUnknown
-
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.- Specified by:
visitUnknown
in interfaceTreeVisitor<R,
P> - Parameters:
node
- node being visitedp
- extra parameter passed to the visitor- Returns:
- abnormal return by throwing exception always
- Throws:
UnknownTreeException
- a visitor implementation may optionally throw this exception- Implementation Requirements:
- The default implementation of this method in
SimpleTreeVisitorES5_1
will always throwUnknownTypeException
. This behavior is not required of a subclass.
-