public class GuiEffectTypeFactory extends BaseAnnotatedTypeFactory
GenericAnnotatedTypeFactory.ScanState
AnnotatedTypeFactory.InheritedFromClassAnnotator
Modifier and Type | Field and Description |
---|---|
protected boolean |
debugSpew |
protected java.util.Set<LambdaExpressionTree> |
uiLambdas
Keeps track of all lambda expressions with inferred UIEffect.
|
analyses, cfgVisualizer, defaults, dependentTypesHelper, FLOW_BY_DEFAULT, flowResult, flowResultAnalysisCaches, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, returnStatementStores, scannedClasses, treeAnnotator, typeAnnotator
checker, elements, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, ignoreUninferredTypeArguments, loader, processingEnv, qualHierarchy, reflectionResolver, root, shouldCache, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, visitorState
Constructor and Description |
---|
GuiEffectTypeFactory(BaseTypeChecker checker,
boolean spew) |
Modifier and Type | Method and Description |
---|---|
void |
constrainLambdaToUI(LambdaExpressionTree lambdaExpressionTree)
Force the given lambda expression to have UIEffect.
|
protected TreeAnnotator |
createTreeAnnotator()
Returns a
TreeAnnotator that adds annotations to a type based on the contents of a
tree. |
Effect.EffectRange |
findInheritedEffectRange(javax.lang.model.element.TypeElement declaringType,
javax.lang.model.element.ExecutableElement overridingMethod) |
Effect.EffectRange |
findInheritedEffectRange(javax.lang.model.element.TypeElement declaringType,
javax.lang.model.element.ExecutableElement overridingMethod,
boolean issueConflictWarning,
Tree errorNode) |
javax.lang.model.element.ExecutableElement |
findJavaOverride(javax.lang.model.element.ExecutableElement overrider,
javax.lang.model.type.TypeMirror parentType) |
AnnotatedTypeMirror |
getAnnotatedType(Tree tree)
Returns an AnnotatedTypeMirror representing the annotated type of
tree . |
Effect |
getComputedEffectAtCallsite(MethodInvocationTree node,
AnnotatedTypeMirror.AnnotatedDeclaredType callerReceiver,
javax.lang.model.element.ExecutableElement methodElt)
Get the effect of a method call at its callsite, acknowledging polymorphic instantiation
using type use annotations.
|
Effect |
getDeclaredEffect(javax.lang.model.element.ExecutableElement methodElt)
Calling context annotations
|
Effect |
getInferedEffectForLambdaExpression(LambdaExpressionTree lambdaTree)
Get the inferred effect of a lambda expression based on the type annotations of its
functional interface and the effects of the calls in its body.
|
boolean |
isPolymorphicType(javax.lang.model.element.TypeElement cls) |
boolean |
isUIType(javax.lang.model.element.TypeElement cls) |
createFlowAnalysis
addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addDefaultAnnotations, addTypeNameImplicit, addUncheckedCodeDefaults, addUncheckedStandardDefaults, analyze, analyze, applyInferredAnnotations, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, createAndInitQualifierDefaults, createCFGVisualizer, createDependentTypesHelper, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, createTypeAnnotator, fromNewClass, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpressionString, getAnnotationFromReceiver, getCFGVisualizer, getDependentTypesHelper, getEmptyStore, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getMethodReturnType, getNodesForTree, getReceiverFromJavaExpressionString, getRegularExitStore, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, handleCFGViz, methodFromUse, performFlowAnalysis, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUse
adaptGetClassReturnTypeToReceiver, addAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedDeclAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, aliasedAnnotation, annotateInheritedFromClass, annotateInheritedFromClass, checkInvalidOptionsInferSignatures, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierHierarchy, createQualifierHierarchy, createQualifierHierarchy, createQualifierHierarchyFactory, createSupportedTypeQualifiers, createTypeArgumentInference, createTypeHierarchy, createTypeVariableSubstitutor, declarationFromElement, fromElement, fromElement, fromElement, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationFormatter, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiersWithoutPolyAll, getBundledTypeQualifiersWithPolyAll, getCacheSize, getContext, getCurrentClassTree, getCurrentClassType, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getElementUtils, getEnclosingMethod, getEnclosingType, getFieldInvariantAnnotationTree, getFieldInvariantDeclarationAnnotations, getFieldInvariants, getFnInterfaceFromTree, getFnInterfaceFromTree, getImplicitReceiverType, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getReceiverType, getSelfType, getStringType, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeHierarchy, getTypeVarSubstitutor, getUnboxedType, getUninferredWildcardType, getVisitorState, getWholeProgramInference, initializeReflectionResolution, isAnyEnclosingThisDeref, isFromByteCode, isFromStubFile, isMostEnclosingThisDeref, isSupportedQualifier, isWithinConstructor, methodFromUse, parseStubFiles, postAsMemberOf, postProcessClassTree, postTypeVarSubstitution, setPathHack, toAnnotatedType, toString, type, widenToUpperBound
protected final boolean debugSpew
protected final java.util.Set<LambdaExpressionTree> uiLambdas
constrainLambdaToUI
adds lambda
expressions to this set, and is called from GuiEffectVisitor whenever a lambda expression
calls a @UIEffect method. Afterwards getInferedEffectForLambdaExpression
uses this set and the type annotations of the functional
interface of the lambda to figure out if it can affect the UI or not.
public GuiEffectTypeFactory(BaseTypeChecker checker, boolean spew)
public javax.lang.model.element.ExecutableElement findJavaOverride(javax.lang.model.element.ExecutableElement overrider, javax.lang.model.type.TypeMirror parentType)
public boolean isPolymorphicType(javax.lang.model.element.TypeElement cls)
public boolean isUIType(javax.lang.model.element.TypeElement cls)
public Effect getDeclaredEffect(javax.lang.model.element.ExecutableElement methodElt)
To make anon-inner-classes work, I need to climb the inheritance DAG, until I:
public Effect getComputedEffectAtCallsite(MethodInvocationTree node, AnnotatedTypeMirror.AnnotatedDeclaredType callerReceiver, javax.lang.model.element.ExecutableElement methodElt)
node
- The method invocation as an AST node.callerReceiver
- The type of the receiver object if available. Used to resolve direct
calls like "super()"methodElt
- The element of the callee method.public Effect getInferedEffectForLambdaExpression(LambdaExpressionTree lambdaTree)
This relies on GuiEffectVisitor to perform the actual inference step and mark lambdas
with @PolyUIEffect functional interfaces as being explicitly UI-affecting using the constrainLambdaToUI
method.
lambdaTree
- A lambda expression's AST node.public AnnotatedTypeMirror getAnnotatedType(Tree tree)
AnnotatedTypeFactory
tree
.
getAnnotatedType
in class AnnotatedTypeFactory
tree
- the AST nodetree
public Effect.EffectRange findInheritedEffectRange(javax.lang.model.element.TypeElement declaringType, javax.lang.model.element.ExecutableElement overridingMethod)
public Effect.EffectRange findInheritedEffectRange(javax.lang.model.element.TypeElement declaringType, javax.lang.model.element.ExecutableElement overridingMethod, boolean issueConflictWarning, Tree errorNode)
protected TreeAnnotator createTreeAnnotator()
GenericAnnotatedTypeFactory
TreeAnnotator
that adds annotations to a type based on the contents of a
tree.
The default tree annotator is a ListTreeAnnotator
of the following:
PropagationTreeAnnotator
: Propagates annotations from subtrees
ImplicitsTreeAnnotator
: Adds annotations based on ImplicitFor
meta-annotations
DependentTypesTreeAnnotator
: Adapts dependent annotations based on context
Subclasses may override this method to specify additional tree annotators, for example:
new ListTreeAnnotator(super.createTreeAnnotator(), new KeyLookupTreeAnnotator(this));
createTreeAnnotator
in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
public void constrainLambdaToUI(LambdaExpressionTree lambdaExpressionTree)
Used by GuiEffectVisitor to mark as UIEffect all lambdas that perform UIEffect calls inside their bodies.
lambdaExpressionTree
- A lambda expression's AST node.