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:
TreeVisitor<R,
P>
- Direct Known Subclasses:
SwitchExpressionScanner.FunctionalSwitchExpressionScanner
A class that visits each result expression of a switch expression and calls
visitSwitchResultExpression(ExpressionTree, Object)
on each result expression. The results of
these method calls are combined using combineResults(Object, Object)
. Call scanSwitchExpression(Tree, Object)
to start scanning the switch expression.
SwitchExpressionScanner.FunctionalSwitchExpressionScanner
can be used to pass functions for to use for visitSwitchResultExpression(ExpressionTree, Object)
and combineResults(Object, Object)
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An implementation ofSwitchExpressionScanner
that uses functions passed to the constructor forSwitchExpressionScanner.FunctionalSwitchExpressionScanner.visitSwitchResultExpression(ExpressionTree, Object)
andSwitchExpressionScanner.FunctionalSwitchExpressionScanner.combineResults(Object, Object)
.protected class
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
Modifier and TypeFieldDescriptionprotected final SwitchExpressionScanner<R,
P>.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
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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)
.scanSwitchExpression
(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
(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, visitAnyPattern, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBinary, visitBindingPattern, visitBlock, visitBreak, visitCase, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitConstantCaseLabel, visitContinue, visitDeconstructionPattern, visitDefaultCaseLabel, 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, visitPatternCaseLabel, visitPrimitiveType, visitProvides, visitRequires, visitReturn, visitStringTemplate, visitSwitch, visitSwitchExpression, visitSynchronized, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitUnionType, visitUses, visitVariable, visitWhileLoop, visitWildcard, visitYield
-
Field Details
-
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.
-
-
Constructor Details
-
SwitchExpressionScanner
public SwitchExpressionScanner()
-
-
Method Details
-
visitSwitchResultExpression
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
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
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)
-