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 twoAnnotatedTypeMirrors
- All Implemented Interfaces:
AnnotatedTypeVisitor<R,AnnotatedTypeMirror>
- Direct Known Subclasses:
AnnotatedTypeCombiner,AnnotatedTypeReplacer,DependentTypesHelper.ViewpointAdaptedCopier
public abstract class DoubleAnnotatedTypeScanner<R>
extends AnnotatedTypeScanner<R,AnnotatedTypeMirror>
An
AnnotatedTypeScanner that scans two AnnotatedTypeMirrors 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, VISITED_NODES_INITIAL_CAPACITY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs an AnnotatedTypeScanner where the reduce function returns the first result if it is nonnull; otherwise the second result is returned.protectedDoubleAnnotatedTypeScanner(AnnotatedTypeScanner.Reduce<R> reduce, R defaultResult) Creates a scanner with the givenreducefunction anddefaultResult. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract RCalled by default for any visit method that is not overridden.protected Rscan(@Nullable List<? extends AnnotatedTypeMirror> types1, @Nullable List<? extends AnnotatedTypeMirror> types2) Scanstypes1andtypes2in parallel and returns the reduced result.protected Rscan(AnnotatedTypeMirror type, AnnotatedTypeMirror p) Scantypeby callingtype.accept(this, p); this method may be overridden by subclasses.protected RscanAndReduce(@Nullable List<? extends AnnotatedTypeMirror> types1, @Nullable List<? extends AnnotatedTypeMirror> types2, R r) Scanstypes1andtypes2in parallel and reduces the result withr.protected final RscanAndReduce(List<? extends AnnotatedTypeMirror> types, AnnotatedTypeMirror p, R r) Scans all types intypeswith parameterpand reduces the result withr.final RVisits an array type.final RVisits a declared type.final RVisits 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
getVisited, hasVisited, markVisited, 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 givenreducefunction 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(@Nullable List<? extends AnnotatedTypeMirror> types1, @Nullable List<? extends AnnotatedTypeMirror> types2) Scanstypes1andtypes2in parallel and returns the reduced result. Uses index-based access to avoid allocating iterators over the (typically unmodifiable) lists.- Parameters:
types1- types; may be nulltypes2- types; may be null- Returns:
- the result of scanning and reducing all paired types, or
AnnotatedTypeScanner.defaultResultif either list is null or both lists are empty
-
scanAndReduce
protected R scanAndReduce(@Nullable List<? extends AnnotatedTypeMirror> types1, @Nullable List<? extends AnnotatedTypeMirror> types2, R r) Scanstypes1andtypes2in parallel and reduces the result withr.- Parameters:
types1- types; may be nulltypes2- types; may be nullr- result to combine with the result of scanning the paired types- Returns:
- the combination of
rwith the result of scanning all paired types
-
scanAndReduce
protected final R scanAndReduce(List<? extends AnnotatedTypeMirror> types, AnnotatedTypeMirror p, R r) Description copied from class:AnnotatedTypeScannerScans all types intypeswith parameterpand reduces the result withr. Uses index-based access to avoid allocating an iterator.- Overrides:
scanAndReducein classAnnotatedTypeScanner<R,AnnotatedTypeMirror> - Parameters:
types- types to scan; may be nullp- parameter to use when scanningr- result to combine with the result of scanningtypes- Returns:
- the combination of
rwith the result of scanning all types
-
scan
Description copied from class:AnnotatedTypeScannerScantypeby callingtype.accept(this, p); this method may be overridden by subclasses.- Overrides:
scanin classAnnotatedTypeScanner<R,AnnotatedTypeMirror> - Parameters:
type- type to scanp- the parameter to use- Returns:
- the result of visiting
type
-
visitDeclared
Description copied from interface:AnnotatedTypeVisitorVisits a declared type.- Specified by:
visitDeclaredin interfaceAnnotatedTypeVisitor<R,AnnotatedTypeMirror> - Overrides:
visitDeclaredin classAnnotatedTypeScanner<R,AnnotatedTypeMirror> - Parameters:
type- the type to visitp- a visitor-specified parameter- Returns:
- a visitor-specified result
-
visitArray
Description copied from interface:AnnotatedTypeVisitorVisits an array type.- Specified by:
visitArrayin interfaceAnnotatedTypeVisitor<R,AnnotatedTypeMirror> - Overrides:
visitArrayin 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:AnnotatedTypeVisitorVisits an executable type.- Specified by:
visitExecutablein interfaceAnnotatedTypeVisitor<R,AnnotatedTypeMirror> - Overrides:
visitExecutablein classAnnotatedTypeScanner<R,AnnotatedTypeMirror> - Parameters:
type- the type to visitp- a visitor-specified parameter- Returns:
- a visitor-specified result
-
visitTypeVariable
Description copied from interface:AnnotatedTypeVisitorVisits a type variable.- Specified by:
visitTypeVariablein interfaceAnnotatedTypeVisitor<R,AnnotatedTypeMirror> - Overrides:
visitTypeVariablein classAnnotatedTypeScanner<R,AnnotatedTypeMirror> - Parameters:
type- the type to visitp- a visitor-specified parameter- Returns:
- a visitor-specified result
-
visitWildcard
Description copied from interface:AnnotatedTypeVisitorVisits a wildcard type.- Specified by:
visitWildcardin interfaceAnnotatedTypeVisitor<R,AnnotatedTypeMirror> - Overrides:
visitWildcardin 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:AnnotatedTypeVisitorVisits an intersection type.- Specified by:
visitIntersectionin interfaceAnnotatedTypeVisitor<R,AnnotatedTypeMirror> - Overrides:
visitIntersectionin classAnnotatedTypeScanner<R,AnnotatedTypeMirror> - Parameters:
type- the type to visitp- a visitor-specified parameter- Returns:
- a visitor-specified result
-
visitUnion
Description copied from interface:AnnotatedTypeVisitorVisits an union type.- Specified by:
visitUnionin interfaceAnnotatedTypeVisitor<R,AnnotatedTypeMirror> - Overrides:
visitUnionin classAnnotatedTypeScanner<R,AnnotatedTypeMirror> - Parameters:
type- the type to visitp- a visitor-specified parameter- Returns:
- a visitor-specified result
-