Package org.checkerframework.javacutil
Class SwitchExpressionScanner<R,P>
- java.lang.Object
-
- com.sun.source.util.TreeScanner<R,P>
-
- org.checkerframework.javacutil.SwitchExpressionScanner<R,P>
-
- Type Parameters:
R
- the type of the result ofvisitSwitchResultExpression(ExpressionTree, Object)
P
- the type of the parameter to pass tovisitSwitchResultExpression(ExpressionTree, Object)
- All Implemented Interfaces:
com.sun.source.tree.TreeVisitor<R,P>
- Direct Known Subclasses:
SwitchExpressionScanner.FunctionalSwitchExpressionScanner
public abstract class SwitchExpressionScanner<R,P> extends com.sun.source.util.TreeScanner<R,P>
A class that visits each result expression of a switch expression and callsvisitSwitchResultExpression(ExpressionTree, Object)
on each result expression. The results of these method calls are combined usingcombineResults(Object, Object)
. CallscanSwitchExpression(Tree, Object)
to start scanning the switch expression.SwitchExpressionScanner.FunctionalSwitchExpressionScanner
can be used to pass functions for to use forvisitSwitchResultExpression(ExpressionTree, Object)
andcombineResults(Object, Object)
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SwitchExpressionScanner.FunctionalSwitchExpressionScanner<R1,P1>
An implementation ofSwitchExpressionScanner
that uses functions passed to the constructor forSwitchExpressionScanner.FunctionalSwitchExpressionScanner.visitSwitchResultExpression(ExpressionTree, Object)
andSwitchExpressionScanner.FunctionalSwitchExpressionScanner.combineResults(Object, Object)
.protected class
SwitchExpressionScanner.YieldVisitor
A scanner that visits all the yield trees in a given tree and callsvisitSwitchResultExpression(ExpressionTree, Object)
on the expression in the yield trees.
-
Field Summary
Fields Modifier and Type Field Description protected SwitchExpressionScanner.YieldVisitor
yieldVisitor
A scanner that visits all the yield trees in a given tree and callsvisitSwitchResultExpression(ExpressionTree, Object)
on the expression in the yield trees.
-
Constructor Summary
Constructors Constructor Description SwitchExpressionScanner()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract R
combineResults(@Nullable R r1, @Nullable R r2)
This method combines the result of two calls tovisitSwitchResultExpression(ExpressionTree, Object)
ornull
and the result of one call tovisitSwitchResultExpression(ExpressionTree, Object)
.R
scanSwitchExpression(com.sun.source.tree.Tree switchExpression, P p)
Scans the given switch expression and callsvisitSwitchResultExpression(ExpressionTree, Object)
on each result expression of the switch expression.protected abstract R
visitSwitchResultExpression(com.sun.source.tree.ExpressionTree resultExpressionTree, P p)
This method is called for each result expression of the switch expression passed inscanSwitchExpression(Tree, Object)
.-
Methods inherited from class com.sun.source.util.TreeScanner
reduce, scan, scan, visitAnnotatedType, visitAnnotation, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBinary, visitBlock, visitBreak, visitCase, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitEnhancedForLoop, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitIntersectionType, visitLabeledStatement, visitLambdaExpression, visitLiteral, visitMemberReference, visitMemberSelect, visitMethod, visitMethodInvocation, visitModifiers, visitModule, visitNewArray, visitNewClass, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitPrimitiveType, visitProvides, visitRequires, visitReturn, visitSwitch, visitSynchronized, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitUnionType, visitUses, visitVariable, visitWhileLoop, visitWildcard
-
-
-
-
Field Detail
-
yieldVisitor
protected final SwitchExpressionScanner.YieldVisitor yieldVisitor
A scanner that visits all the yield trees in a given tree and callsvisitSwitchResultExpression(ExpressionTree, Object)
on the expression in the yield trees. It does not descend into switch expressions.
-
-
Method Detail
-
visitSwitchResultExpression
protected abstract R visitSwitchResultExpression(com.sun.source.tree.ExpressionTree resultExpressionTree, P p)
This method is called for each result expression of the switch expression passed inscanSwitchExpression(Tree, Object)
.- Parameters:
resultExpressionTree
- a result expression of the switch expression currently being scannedp
- a parameter- Returns:
- the result of visiting the result expression
-
combineResults
protected abstract R combineResults(@Nullable R r1, @Nullable R r2)
This method combines the result of two calls tovisitSwitchResultExpression(ExpressionTree, Object)
ornull
and the result of one call tovisitSwitchResultExpression(ExpressionTree, Object)
.- Parameters:
r1
- a possibly null result returned byvisitSwitchResultExpression(ExpressionTree, Object)
r2
- a possibly null result returned byvisitSwitchResultExpression(ExpressionTree, Object)
- Returns:
- the combination of
r1
andr2
-
scanSwitchExpression
public R scanSwitchExpression(com.sun.source.tree.Tree switchExpression, P p)
Scans the given switch expression and callsvisitSwitchResultExpression(ExpressionTree, Object)
on each result expression of the switch expression.combineResults(Object, Object)
is called to combine the results of visiting multiple switch result expressions.- Parameters:
switchExpression
- a switch expression treep
- the parameter to pass tovisitSwitchResultExpression(ExpressionTree, Object)
- Returns:
- the result of calling
visitSwitchResultExpression(ExpressionTree, Object)
on each result expression ofswitchExpression
and combining the results usingcombineResults(Object, Object)
-
-