public class BaseTypeValidator extends AnnotatedTypeScanner<Void,Tree> implements TypeValidator
| Modifier and Type | Field and Description |
|---|---|
protected AnnotatedTypeFactory |
atypeFactory |
protected BaseTypeChecker |
checker |
protected boolean |
isValid |
protected BaseTypeVisitor<?> |
visitor |
visitedNodes| Constructor and Description |
|---|
BaseTypeValidator(BaseTypeChecker checker,
BaseTypeVisitor<?> visitor,
AnnotatedTypeFactory atypeFactory) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
areBoundsValid(AnnotatedTypeMirror upperBound,
AnnotatedTypeMirror lowerBound) |
boolean |
checkConflictingPrimaryAnnos(AnnotatedTypeMirror type,
Tree tree)
Determines if there are multiple qualifiers from a single hierarchy in type's primary
annotations.
|
boolean |
isValid(AnnotatedTypeMirror type,
Tree tree)
The entry point to the type validator.
|
protected void |
reportError(AnnotatedTypeMirror type,
Tree p) |
protected void |
reportInvalidBounds(AnnotatedTypeMirror type,
Tree tree)
Most errors reported by this class are of the form type.invalid.
|
protected void |
reportValidityResult(@CompilerMessageKey String errorType,
AnnotatedTypeMirror type,
Tree p) |
Void |
visitArray(AnnotatedTypeMirror.AnnotatedArrayType type,
Tree tree)
Visits an array type.
|
Void |
visitDeclared(AnnotatedTypeMirror.AnnotatedDeclaredType type,
Tree tree)
Visits a declared type.
|
Void |
visitNull(AnnotatedTypeMirror.AnnotatedNullType type,
Tree tree)
Visits a
null type. |
protected Void |
visitParameterizedType(AnnotatedTypeMirror.AnnotatedDeclaredType type,
ParameterizedTypeTree tree)
Checks that the annotations on the type arguments supplied to a type or a method invocation
are within the bounds of the type variables as declared, and issues the
"type.argument.type.incompatible" error if they are not.
|
Void |
visitPrimitive(AnnotatedTypeMirror.AnnotatedPrimitiveType type,
Tree tree)
Visits a primitive type.
|
Void |
visitTypeVariable(AnnotatedTypeMirror.AnnotatedTypeVariable type,
Tree tree)
Visits a type variable.
|
Void |
visitWildcard(AnnotatedTypeMirror.AnnotatedWildcardType type,
Tree tree)
Visits a wildcard type.
|
reduce, reset, scan, scan, scanAndReduce, scanAndReduce, visit, visit, visitExecutable, visitIntersection, visitNoType, visitUnionprotected boolean isValid
protected final BaseTypeChecker checker
protected final BaseTypeVisitor<?> visitor
protected final AnnotatedTypeFactory atypeFactory
public BaseTypeValidator(BaseTypeChecker checker, BaseTypeVisitor<?> visitor, AnnotatedTypeFactory atypeFactory)
public boolean isValid(AnnotatedTypeMirror type, Tree tree)
BaseTypeVisitor.validateTypeOf(Tree).isValid in interface TypeValidatortype - the type to validatetree - the tree from which the type originated. Note that the tree might be a method
tree -- the return type should then be validated. Note that the tree might be a variable
tree -- the field type should then be validated.protected void reportValidityResult(@CompilerMessageKey String errorType, AnnotatedTypeMirror type, Tree p)
protected void reportInvalidBounds(AnnotatedTypeMirror type, Tree tree)
protected void reportError(AnnotatedTypeMirror type, Tree p)
public Void visitDeclared(AnnotatedTypeMirror.AnnotatedDeclaredType type, Tree tree)
AnnotatedTypeVisitorvisitDeclared in interface AnnotatedTypeVisitor<Void,Tree>visitDeclared in class AnnotatedTypeScanner<Void,Tree>type - the type to visittree - a visitor-specified parameterpublic Void visitPrimitive(AnnotatedTypeMirror.AnnotatedPrimitiveType type, Tree tree)
AnnotatedTypeVisitorvisitPrimitive in interface AnnotatedTypeVisitor<Void,Tree>visitPrimitive in class AnnotatedTypeScanner<Void,Tree>type - the type to visittree - a visitor-specified parameterpublic Void visitArray(AnnotatedTypeMirror.AnnotatedArrayType type, Tree tree)
AnnotatedTypeVisitorvisitArray in interface AnnotatedTypeVisitor<Void,Tree>visitArray in class AnnotatedTypeScanner<Void,Tree>type - the type to visittree - a visitor-specified parameterprotected Void visitParameterizedType(AnnotatedTypeMirror.AnnotatedDeclaredType type, ParameterizedTypeTree tree)
This method used to be visitParameterizedType, which incorrectly handles the main annotation on generic types.
public Void visitTypeVariable(AnnotatedTypeMirror.AnnotatedTypeVariable type, Tree tree)
AnnotatedTypeVisitorvisitTypeVariable in interface AnnotatedTypeVisitor<Void,Tree>visitTypeVariable in class AnnotatedTypeScanner<Void,Tree>type - the type to visittree - a visitor-specified parameterpublic Void visitWildcard(AnnotatedTypeMirror.AnnotatedWildcardType type, Tree tree)
AnnotatedTypeVisitorvisitWildcard in interface AnnotatedTypeVisitor<Void,Tree>visitWildcard in class AnnotatedTypeScanner<Void,Tree>type - the type to visittree - a visitor-specified parameterpublic Void visitNull(AnnotatedTypeMirror.AnnotatedNullType type, Tree tree)
AnnotatedTypeVisitornull type.visitNull in interface AnnotatedTypeVisitor<Void,Tree>visitNull in class AnnotatedTypeScanner<Void,Tree>type - the type to visittree - a visitor-specified parameterpublic boolean areBoundsValid(AnnotatedTypeMirror upperBound, AnnotatedTypeMirror lowerBound)
public boolean checkConflictingPrimaryAnnos(AnnotatedTypeMirror type, Tree tree)
type - the type to checktree - tree on which an error is reported