|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object checkers.types.visitors.AnnotatedTypeScanner<R,P>
R
- the return type of this visitor's methods. Use Void for
visitors that do not need to return results.P
- the type of the additional parameter to this visitor's
methods. Use Void for visitors that do not need an
additional parameter.public class AnnotatedTypeScanner<R,P> extends Object implements AnnotatedTypeVisitor<R,P>
A TypeVisitor that visits all the child tree nodes. To visit types of a particular type, just override the corresponding visitXYZ method. Inside your method, call super.visitXYZ to visit descendant nodes. The default implementation of the visitXYZ methods will determine a result as follows: If the node being visited has no children, the result will be null. If the node being visited has one child, the result will be the result of calling scan on that child. The child may be a simple node or itself a list of nodes. If the node being visited has more than one child, the result will be determined by calling scan each child in turn, and then combining the result of each scan after the first with the cumulative result so far, as determined by the reduce(R, R) method. Each child may be either a simple node of a list of nodes. The default behavior of the reduce method is such that the result of the visitXYZ method will be the result of the last child scanned. Here is an example to count the parameter types number of nodes in a tree:
class CountTypeVariable extends TreeScanner { @Override public Integer visitTypeVariable(ATypeVariable node, Void p) { return 1; } @Override public Integer reduce(Integer r1, Integer r2) { return (r1 == null ? 0 : r1) + (r2 == null ? 0 : r2); } }
Modifier and Type | Field and Description |
---|---|
protected Map<AnnotatedTypeMirror,R> |
visitedNodes
|
Constructor and Description |
---|
AnnotatedTypeScanner()
|
Modifier and Type | Method and Description |
---|---|
protected R |
reduce(R r1,
R r2)
|
protected R |
scan(AnnotatedTypeMirror type,
P p)
Processes an element by calling e.accept(this, p); this method may be overridden by subclasses. |
protected R |
scan(Iterable<? extends AnnotatedTypeMirror> types,
P p)
Processes an element by calling e.accept(this, p); this method may be overridden by subclasses. |
R |
scanAndReduce(AnnotatedTypeMirror type,
P p,
R r)
|
protected R |
scanAndReduce(Iterable<? extends AnnotatedTypeMirror> types,
P p,
R r)
|
R |
visit(AnnotatedTypeMirror t)
A Convenience method equivalent to v.visit(t, null) . |
R |
visit(AnnotatedTypeMirror type,
P p)
Visits a type. |
R |
visitArray(AnnotatedTypeMirror.AnnotatedArrayType type,
P p)
Visits an array type. |
R |
visitDeclared(AnnotatedTypeMirror.AnnotatedDeclaredType type,
P p)
Visits a declared type. |
R |
visitExecutable(AnnotatedTypeMirror.AnnotatedExecutableType type,
P p)
Visits an executable type. |
R |
visitNoType(AnnotatedTypeMirror.AnnotatedNoType type,
P p)
Visits NoType type. |
R |
visitNull(AnnotatedTypeMirror.AnnotatedNullType type,
P p)
Visits a null type. |
R |
visitPrimitive(AnnotatedTypeMirror.AnnotatedPrimitiveType type,
P p)
Visits a primitive type. |
R |
visitTypeVariable(AnnotatedTypeMirror.AnnotatedTypeVariable type,
P p)
Visits a type variable. |
R |
visitWildcard(AnnotatedTypeMirror.AnnotatedWildcardType type,
P p)
Visits a wildcard type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Map<AnnotatedTypeMirror,R> visitedNodes
Constructor Detail |
---|
public AnnotatedTypeScanner()
Method Detail |
---|
public final R visit(AnnotatedTypeMirror t)
AnnotatedTypeVisitor
v.visit(t, null)
.
visit
in interface AnnotatedTypeVisitor<R,P>
t
- the type to visitpublic final R visit(AnnotatedTypeMirror type, P p)
AnnotatedTypeVisitor
visit
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameterprotected R scan(AnnotatedTypeMirror type, P p)
type
protected R scan(Iterable<? extends AnnotatedTypeMirror> types, P p)
types
- p
- protected R scanAndReduce(Iterable<? extends AnnotatedTypeMirror> types, P p, R r)
public R scanAndReduce(AnnotatedTypeMirror type, P p, R r)
protected R reduce(R r1, R r2)
public R visitDeclared(AnnotatedTypeMirror.AnnotatedDeclaredType type, P p)
AnnotatedTypeVisitor
visitDeclared
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameterpublic R visitArray(AnnotatedTypeMirror.AnnotatedArrayType type, P p)
AnnotatedTypeVisitor
visitArray
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameterpublic R visitExecutable(AnnotatedTypeMirror.AnnotatedExecutableType type, P p)
AnnotatedTypeVisitor
visitExecutable
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameterpublic R visitTypeVariable(AnnotatedTypeMirror.AnnotatedTypeVariable type, P p)
AnnotatedTypeVisitor
visitTypeVariable
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameterpublic R visitNoType(AnnotatedTypeMirror.AnnotatedNoType type, P p)
AnnotatedTypeVisitor
visitNoType
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameterpublic R visitNull(AnnotatedTypeMirror.AnnotatedNullType type, P p)
AnnotatedTypeVisitor
null
type.
visitNull
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameterpublic R visitPrimitive(AnnotatedTypeMirror.AnnotatedPrimitiveType type, P p)
AnnotatedTypeVisitor
visitPrimitive
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameterpublic R visitWildcard(AnnotatedTypeMirror.AnnotatedWildcardType type, P p)
AnnotatedTypeVisitor
visitWildcard
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameter
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |