Class KeyForPropagationTreeAnnotator
- java.lang.Object
-
- com.sun.source.util.SimpleTreeVisitor<java.lang.Void,AnnotatedTypeMirror>
-
- org.checkerframework.framework.type.treeannotator.TreeAnnotator
-
- org.checkerframework.checker.nullness.KeyForPropagationTreeAnnotator
-
- All Implemented Interfaces:
com.sun.source.tree.TreeVisitor<java.lang.Void,AnnotatedTypeMirror>
public class KeyForPropagationTreeAnnotator extends TreeAnnotator
For the following initializations we wish to propagate the annotations from the left-hand side to the right-hand side or vice versa:1. If a keySet is being saved to a newly declared set, we transfer the annotations from the keySet to the lhs. e.g.,
2. If a variable declaration contains type arguments with an @KeyFor annotation and its initializer is a new class tree with corresponding type arguments that have an @UknownKeyFor primary annotation, we transfer from the LHS to RHS. e.g.,// The user is not required to explicitly annotate the LHS's type argument with @KeyFor("m") Set<String> keySet = m.keySet();
3. IMPORTANT NOTE: The following case must be (and is) handled in KeyForAnnotatedTypeFactory. In BaseTypeVisitor we check to make sure that the constructor called in a NewClassTree is actually compatible with the annotations placed on the NewClassTree. This requires that, prior to this check we also propagate the annotations to this constructor in constructorFromUse so that the constructor call matches the type given to the NewClassTree.// The user does not have to write @KeyFor("m") on both sides List<@KeyFor("m") String> keys = new ArrayList<String>();
-
-
Field Summary
-
Fields inherited from class org.checkerframework.framework.type.treeannotator.TreeAnnotator
atypeFactory
-
-
Constructor Summary
Constructors Constructor Description KeyForPropagationTreeAnnotator(AnnotatedTypeFactory atypeFactory, KeyForPropagator propagationTreeAnnotator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isCallToKeyset(com.sun.source.tree.ExpressionTree expression)
Returns true iff expression is a call to java.util.Map.KeySet.java.lang.Void
visitNewClass(com.sun.source.tree.NewClassTree tree, AnnotatedTypeMirror type)
Transfers annotations to type if the left hand side is a variable declaration.java.lang.Void
visitVariable(com.sun.source.tree.VariableTree variableTree, AnnotatedTypeMirror type)
Transfers annotations on type arguments from the initializer to the variableTree, if the initializer is a call to java.util.Map.keySet.-
Methods inherited from class org.checkerframework.framework.type.treeannotator.TreeAnnotator
log, visitBinary, visitMethod
-
Methods inherited from class com.sun.source.util.SimpleTreeVisitor
defaultAction, visit, visit, visitAnnotatedType, visitAnnotation, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBlock, visitBreak, visitCase, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitEnhancedForLoop, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitIntersectionType, visitLabeledStatement, visitLambdaExpression, visitLiteral, visitMemberReference, visitMemberSelect, visitMethodInvocation, visitModifiers, visitModule, visitNewArray, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitPrimitiveType, visitProvides, visitRequires, visitReturn, visitSwitch, visitSynchronized, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitUnionType, visitUses, visitWhileLoop, visitWildcard
-
-
-
-
Constructor Detail
-
KeyForPropagationTreeAnnotator
public KeyForPropagationTreeAnnotator(AnnotatedTypeFactory atypeFactory, KeyForPropagator propagationTreeAnnotator)
-
-
Method Detail
-
isCallToKeyset
public boolean isCallToKeyset(com.sun.source.tree.ExpressionTree expression)
Returns true iff expression is a call to java.util.Map.KeySet.- Returns:
- true iff expression is a call to java.util.Map.KeySet
-
visitVariable
public java.lang.Void visitVariable(com.sun.source.tree.VariableTree variableTree, AnnotatedTypeMirror type)
Transfers annotations on type arguments from the initializer to the variableTree, if the initializer is a call to java.util.Map.keySet.- Specified by:
visitVariable
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,AnnotatedTypeMirror>
- Overrides:
visitVariable
in classcom.sun.source.util.SimpleTreeVisitor<java.lang.Void,AnnotatedTypeMirror>
-
visitNewClass
public java.lang.Void visitNewClass(com.sun.source.tree.NewClassTree tree, AnnotatedTypeMirror type)
Transfers annotations to type if the left hand side is a variable declaration.- Specified by:
visitNewClass
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,AnnotatedTypeMirror>
- Overrides:
visitNewClass
in classcom.sun.source.util.SimpleTreeVisitor<java.lang.Void,AnnotatedTypeMirror>
-
-