public class KeyForPropagationTreeAnnotator extends TreeAnnotator
1. If a keySet is being saved to a newly declared set, we transfer the annotations from the keySet to the lhs. e.g.,
// Previously, the user would be required to annotate the LHS's type argument with @KeyFor("m")
Set<String> keySet = m.keySet();
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.,
// normally a user would have to write the @KeyFor("m") on both sides
List<@KeyFor("m") String> keys = new ArrayList<String>();
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.atypeFactory
Constructor and Description |
---|
KeyForPropagationTreeAnnotator(AnnotatedTypeFactory atypeFactory,
KeyForPropagator propagationTreeAnnotator) |
Modifier and Type | Method and Description |
---|---|
boolean |
isCallToKeyset(com.sun.source.tree.ExpressionTree expression) |
java.lang.Void |
visitNewClass(com.sun.source.tree.NewClassTree node,
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 to the variableTree if the right side is a call to
java.util.Map.KeySet.
|
visitBinary, visitMethod
defaultAction, visit, visit, visitAnnotatedType, visitAnnotation, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBlock, visitBreak, visitCase, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitEnhancedForLoop, visitErroneous, visitExpressionStatement, visitForLoop, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitIntersectionType, visitLabeledStatement, visitLambdaExpression, visitLiteral, visitMemberReference, visitMemberSelect, visitMethodInvocation, visitModifiers, visitNewArray, visitOther, visitParameterizedType, visitParenthesized, visitPrimitiveType, visitReturn, visitSwitch, visitSynchronized, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitUnionType, visitWhileLoop, visitWildcard
public KeyForPropagationTreeAnnotator(AnnotatedTypeFactory atypeFactory, KeyForPropagator propagationTreeAnnotator)
public boolean isCallToKeyset(com.sun.source.tree.ExpressionTree expression)
public java.lang.Void visitVariable(com.sun.source.tree.VariableTree variableTree, AnnotatedTypeMirror type)
visitVariable
in interface com.sun.source.tree.TreeVisitor<java.lang.Void,AnnotatedTypeMirror>
visitVariable
in class com.sun.source.util.SimpleTreeVisitor<java.lang.Void,AnnotatedTypeMirror>
public java.lang.Void visitNewClass(com.sun.source.tree.NewClassTree node, AnnotatedTypeMirror type)
visitNewClass
in interface com.sun.source.tree.TreeVisitor<java.lang.Void,AnnotatedTypeMirror>
visitNewClass
in class com.sun.source.util.SimpleTreeVisitor<java.lang.Void,AnnotatedTypeMirror>