Class DoubleAnnotatedTypeScanner<R>
java.lang.Object
org.checkerframework.framework.type.visitor.AnnotatedTypeScanner<R,AnnotatedTypeMirror>
org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner<R>
- Type Parameters:
R
- the result of scanning the twoAnnotatedTypeMirror
s
- All Implemented Interfaces:
AnnotatedTypeVisitor<R,
AnnotatedTypeMirror>
- Direct Known Subclasses:
AnnotatedTypeCombiner
,AnnotatedTypeReplacer
public abstract class DoubleAnnotatedTypeScanner<R>
extends AnnotatedTypeScanner<R,AnnotatedTypeMirror>
An
AnnotatedTypeScanner
that scans two AnnotatedTypeMirror
s simultaneously and
performs defaultAction(AnnotatedTypeMirror, AnnotatedTypeMirror)
on the pair. Both
AnnotatedTypeMirrors must have the same structure, or a subclass must arrange not to continue
recursing past the point at which their structure diverges.
If the default action does not return a result, then R
should be Void
and
DoubleAnnotatedTypeScanner()
should be used to construct the scanner. If the default
action returns a result, then specify a AnnotatedTypeScanner.reduce(R, R)
function and use
DoubleAnnotatedTypeScanner(Reduce, Object)
.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.framework.type.visitor.AnnotatedTypeScanner
AnnotatedTypeScanner.Reduce<R>
-
Field Summary
Fields inherited from class org.checkerframework.framework.type.visitor.AnnotatedTypeScanner
defaultResult, reduceFunction, visitedNodes
-
Constructor Summary
ModifierConstructorDescriptionprotected
Constructs an AnnotatedTypeScanner where the reduce function returns the first result if it is nonnull; otherwise the second result is returned.protected
DoubleAnnotatedTypeScanner
(AnnotatedTypeScanner.Reduce<R> reduce, R defaultResult) Creates a scanner with the givenreduce
function anddefaultResult
. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract R
Called by default for any visit method that is not overridden.protected R
scan
(Iterable<? extends AnnotatedTypeMirror> types1, Iterable<? extends AnnotatedTypeMirror> types2) Scanstypes1
andtypes2
.protected R
scan
(AnnotatedTypeMirror type, AnnotatedTypeMirror p) Scantype
by callingtype.accept(this, p)
; this method may be overridden by subclasses.protected R
scanAndReduce
(Iterable<? extends AnnotatedTypeMirror> types, Iterable<? extends AnnotatedTypeMirror> p, R r) Runscan(java.lang.Iterable<? extends org.checkerframework.framework.type.AnnotatedTypeMirror>, java.lang.Iterable<? extends org.checkerframework.framework.type.AnnotatedTypeMirror>)
on types and p, then runAnnotatedTypeScanner.reduce(R, R)
on the result (plus r) to return a single element.protected final R
scanAndReduce
(Iterable<? extends AnnotatedTypeMirror> types, AnnotatedTypeMirror p, R r) final R
Visits an array type.final R
Visits a declared type.final R
Visits an executable type.Visits an intersection type.Visits a type variable.Visits an union type.Visits a wildcard type.Methods inherited from class org.checkerframework.framework.type.visitor.AnnotatedTypeScanner
reduce, reset, scan, scanAndReduce, visit, visit, visitNoType, visitNull, visitPrimitive
-
Constructor Details
-
DoubleAnnotatedTypeScanner
protected DoubleAnnotatedTypeScanner()Constructs an AnnotatedTypeScanner where the reduce function returns the first result if it is nonnull; otherwise the second result is returned. The default result isnull
. -
DoubleAnnotatedTypeScanner
Creates a scanner with the givenreduce
function anddefaultResult
.- Parameters:
reduce
- function used to combine the results of scandefaultResult
- result to use by default
-
-
Method Details
-
defaultAction
Called by default for any visit method that is not overridden.- Parameters:
type
- the type to visitp
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
scan
protected R scan(Iterable<? extends AnnotatedTypeMirror> types1, Iterable<? extends AnnotatedTypeMirror> types2) - Parameters:
types1
- typestypes2
- types- Returns:
- the result of scanning and reducing all the types in
types1
andtypes2
orAnnotatedTypeScanner.defaultResult
if they are empty
-
scanAndReduce
protected R scanAndReduce(Iterable<? extends AnnotatedTypeMirror> types, Iterable<? extends AnnotatedTypeMirror> p, R r) Runscan(java.lang.Iterable<? extends org.checkerframework.framework.type.AnnotatedTypeMirror>, java.lang.Iterable<? extends org.checkerframework.framework.type.AnnotatedTypeMirror>)
on types and p, then runAnnotatedTypeScanner.reduce(R, R)
on the result (plus r) to return a single element. -
scanAndReduce
protected final R scanAndReduce(Iterable<? extends AnnotatedTypeMirror> types, AnnotatedTypeMirror p, R r) - Overrides:
scanAndReduce
in classAnnotatedTypeScanner<R,
AnnotatedTypeMirror>
-
scan
Description copied from class:AnnotatedTypeScanner
Scantype
by callingtype.accept(this, p)
; this method may be overridden by subclasses.- Overrides:
scan
in classAnnotatedTypeScanner<R,
AnnotatedTypeMirror> - Parameters:
type
- type to scanp
- the parameter to use- Returns:
- the result of visiting
type
-
visitDeclared
Description copied from interface:AnnotatedTypeVisitor
Visits a declared type.- Specified by:
visitDeclared
in interfaceAnnotatedTypeVisitor<R,
AnnotatedTypeMirror> - Overrides:
visitDeclared
in classAnnotatedTypeScanner<R,
AnnotatedTypeMirror> - Parameters:
type
- the type to visitp
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
visitArray
Description copied from interface:AnnotatedTypeVisitor
Visits an array type.- Specified by:
visitArray
in interfaceAnnotatedTypeVisitor<R,
AnnotatedTypeMirror> - Overrides:
visitArray
in classAnnotatedTypeScanner<R,
AnnotatedTypeMirror> - Parameters:
type
- the type to visitp
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
visitExecutable
public final R visitExecutable(AnnotatedTypeMirror.AnnotatedExecutableType type, AnnotatedTypeMirror p) Description copied from interface:AnnotatedTypeVisitor
Visits an executable type.- Specified by:
visitExecutable
in interfaceAnnotatedTypeVisitor<R,
AnnotatedTypeMirror> - Overrides:
visitExecutable
in classAnnotatedTypeScanner<R,
AnnotatedTypeMirror> - Parameters:
type
- the type to visitp
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
visitTypeVariable
Description copied from interface:AnnotatedTypeVisitor
Visits a type variable.- Specified by:
visitTypeVariable
in interfaceAnnotatedTypeVisitor<R,
AnnotatedTypeMirror> - Overrides:
visitTypeVariable
in classAnnotatedTypeScanner<R,
AnnotatedTypeMirror> - Parameters:
type
- the type to visitp
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
visitWildcard
Description copied from interface:AnnotatedTypeVisitor
Visits a wildcard type.- Specified by:
visitWildcard
in interfaceAnnotatedTypeVisitor<R,
AnnotatedTypeMirror> - Overrides:
visitWildcard
in classAnnotatedTypeScanner<R,
AnnotatedTypeMirror> - Parameters:
type
- the type to visitp
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
visitIntersection
public R visitIntersection(AnnotatedTypeMirror.AnnotatedIntersectionType type, AnnotatedTypeMirror p) Description copied from interface:AnnotatedTypeVisitor
Visits an intersection type.- Specified by:
visitIntersection
in interfaceAnnotatedTypeVisitor<R,
AnnotatedTypeMirror> - Overrides:
visitIntersection
in classAnnotatedTypeScanner<R,
AnnotatedTypeMirror> - Parameters:
type
- the type to visitp
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
visitUnion
Description copied from interface:AnnotatedTypeVisitor
Visits an union type.- Specified by:
visitUnion
in interfaceAnnotatedTypeVisitor<R,
AnnotatedTypeMirror> - Overrides:
visitUnion
in classAnnotatedTypeScanner<R,
AnnotatedTypeMirror> - Parameters:
type
- the type to visitp
- a visitor-specified parameter- Returns:
- a visitor-specified result
-