public class InitializationVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,Store,?,?>,Value extends CFAbstractValue<Value>,Store extends InitializationStore<Value,Store>> extends BaseTypeVisitor<Factory>
NullnessChecker
. Also
supports rawness as a type-system for tracking initialization, though FBC is preferred.BaseTypeVisitor.OverrideChecker
Modifier and Type | Field and Description |
---|---|
protected AnnotationFormatter |
annoFormatter |
protected java.util.List<com.sun.source.tree.VariableTree> |
initializedFields |
atypeFactory, checker, contractsUtils, positions, typeValidator, visitorState
elements, root, trees, types
Constructor and Description |
---|
InitializationVisitor(BaseTypeChecker checker) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkConstructorInvocation(AnnotatedTypeMirror.AnnotatedDeclaredType dt,
AnnotatedTypeMirror.AnnotatedExecutableType constructor,
com.sun.source.tree.NewClassTree src) |
protected boolean |
checkContract(FlowExpressions.Receiver expr,
javax.lang.model.element.AnnotationMirror necessaryAnnotation,
javax.lang.model.element.AnnotationMirror inferredAnnotation,
CFAbstractStore<?,?> store)
Returns true if and only if
inferredAnnotation is valid for a given expression to
match the necessaryAnnotation . |
protected void |
checkFieldsInitialized(com.sun.source.tree.Tree blockNode,
boolean staticFields,
Store store,
java.util.List<? extends javax.lang.model.element.AnnotationMirror> receiverAnnotations)
Checks that all fields (all static fields if
staticFields is true) are initialized in
the given store. |
protected void |
commonAssignmentCheck(com.sun.source.tree.Tree varTree,
com.sun.source.tree.ExpressionTree valueExp,
@CompilerMessageKey java.lang.String errorKey)
Checks the validity of an assignment (or pseudo-assignment) from a value to a variable and
emits an error message (through the compiler's messaging interface) if it is not valid.
|
void |
processClassTree(com.sun.source.tree.ClassTree node)
Type-check classTree.
|
void |
setRoot(com.sun.source.tree.CompilationUnitTree root) |
java.lang.Void |
visitBlock(com.sun.source.tree.BlockTree node,
java.lang.Void p) |
java.lang.Void |
visitMethod(com.sun.source.tree.MethodTree node,
java.lang.Void p)
Performs pseudo-assignment check: checks that the method obeys override and subtype rules to
all overridden methods.
|
java.lang.Void |
visitTypeCast(com.sun.source.tree.TypeCastTree node,
java.lang.Void p) |
java.lang.Void |
visitVariable(com.sun.source.tree.VariableTree node,
java.lang.Void p) |
checkAccess, checkArguments, checkArrayInitialization, checkAssignability, checkConditionalPostcondition, checkDefaultConstructor, checkExceptionParameter, checkFieldInvariantDeclarations, checkForAnnotatedJdk, checkMethodInvocability, checkMethodReferenceAsOverride, checkOverride, checkOverride, checkPostcondition, checkPreconditions, checkThrownExpression, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, checkVarargs, commonAssignmentCheck, commonAssignmentCheck, createOverrideChecker, createTypeFactory, createTypeValidator, enclosingMemberSelect, enclosingStatement, getExceptionParameterLowerBoundAnnotations, getThrowUpperBoundAnnotations, getTypeFactory, isAccessAllowed, isAssignable, isValidUse, isValidUse, isValidUse, isVectorCopyInto, reportPurityErrors, scan, shouldSkipUses, skipReceiverSubtypeCheck, testTypevarContainment, typeCheckVectorCopyIntoArgument, validateType, validateTypeOf, visitAnnotation, visitArrayAccess, visitAssignment, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitEnhancedForLoop, visitIdentifier, visitInstanceOf, visitLambdaExpression, visitMemberReference, visitMethodInvocation, visitNewArray, visitNewClass, visitParameterizedType, visitReturn, visitThrow, visitTry, visitTypeParameter, visitUnary
visit
reduce, scan, visitAnnotatedType, visitArrayType, visitAssert, visitBinary, visitBreak, visitCase, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExpressionStatement, visitForLoop, visitIf, visitImport, visitIntersectionType, visitLabeledStatement, visitLiteral, visitMemberSelect, visitModifiers, visitOther, visitParenthesized, visitPrimitiveType, visitSwitch, visitSynchronized, visitUnionType, visitWhileLoop, visitWildcard
protected final AnnotationFormatter annoFormatter
protected final java.util.List<com.sun.source.tree.VariableTree> initializedFields
public InitializationVisitor(BaseTypeChecker checker)
public void setRoot(com.sun.source.tree.CompilationUnitTree root)
setRoot
in class BaseTypeVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,Store,?,?>>
protected boolean checkConstructorInvocation(AnnotatedTypeMirror.AnnotatedDeclaredType dt, AnnotatedTypeMirror.AnnotatedExecutableType constructor, com.sun.source.tree.NewClassTree src)
checkConstructorInvocation
in class BaseTypeVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,Store,?,?>>
protected void commonAssignmentCheck(com.sun.source.tree.Tree varTree, com.sun.source.tree.ExpressionTree valueExp, @CompilerMessageKey java.lang.String errorKey)
BaseTypeVisitor
commonAssignmentCheck
in class BaseTypeVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,Store,?,?>>
varTree
- the AST node for the lvalue (usually a variable)valueExp
- the AST node for the rvalue (the new value)errorKey
- the error message to use if the check fails (must be a compiler message key,
see CompilerMessageKey
)public java.lang.Void visitVariable(com.sun.source.tree.VariableTree node, java.lang.Void p)
visitVariable
in interface com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
visitVariable
in class BaseTypeVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,Store,?,?>>
protected boolean checkContract(FlowExpressions.Receiver expr, javax.lang.model.element.AnnotationMirror necessaryAnnotation, javax.lang.model.element.AnnotationMirror inferredAnnotation, CFAbstractStore<?,?> store)
BaseTypeVisitor
inferredAnnotation
is valid for a given expression to
match the necessaryAnnotation
.
By default, inferredAnnotation
must be a subtype of necessaryAnnotation
,
but subclasses might override this behavior.
checkContract
in class BaseTypeVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,Store,?,?>>
public java.lang.Void visitTypeCast(com.sun.source.tree.TypeCastTree node, java.lang.Void p)
visitTypeCast
in interface com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
visitTypeCast
in class BaseTypeVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,Store,?,?>>
public java.lang.Void visitBlock(com.sun.source.tree.BlockTree node, java.lang.Void p)
visitBlock
in interface com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
visitBlock
in class com.sun.source.util.TreeScanner<java.lang.Void,java.lang.Void>
public void processClassTree(com.sun.source.tree.ClassTree node)
BaseTypeVisitor
BaseTypeVisitor.visitClass(ClassTree, Void)
.processClassTree
in class BaseTypeVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,Store,?,?>>
node
- class to checkpublic java.lang.Void visitMethod(com.sun.source.tree.MethodTree node, java.lang.Void p)
BaseTypeVisitor
The override rule specifies that a method, m1, may override a method m2 only if:
visitMethod
in interface com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
visitMethod
in class BaseTypeVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,Store,?,?>>
protected void checkFieldsInitialized(com.sun.source.tree.Tree blockNode, boolean staticFields, Store store, java.util.List<? extends javax.lang.model.element.AnnotationMirror> receiverAnnotations)
staticFields
is true) are initialized in
the given store.