public class GuiEffectTypeFactory extends BaseAnnotatedTypeFactory
GenericAnnotatedTypeFactory.ScanState
AnnotatedTypeFactory.InheritedFromClassAnnotator, AnnotatedTypeFactory.ParameterizedMethodType
Modifier and Type | Field and Description |
---|---|
protected boolean |
debugSpew |
protected Set<TypeElement> |
uiAnonClasses
Keeps track of all anonymous inner classes with inferred UIEffect.
|
protected Set<LambdaExpressionTree> |
uiLambdas
Keeps track of all lambda expressions with inferred UIEffect.
|
analysis, cfgVisualizer, defaults, dependentTypesHelper, emptyStore, flowByDefault, flowResult, flowResultAnalysisCaches, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, returnStatementStores, scannedClasses, transfer, 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 |
constrainAnonymousClassToUI(TypeElement classElt)
Force the given anonymous inner class to be an @UI instantiation of its base class.
|
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(TypeElement declaringType,
ExecutableElement overridingMethod) |
Effect.EffectRange |
findInheritedEffectRange(TypeElement declaringType,
ExecutableElement overridingMethod,
boolean issueConflictWarning,
Tree errorNode) |
ExecutableElement |
findJavaOverride(ExecutableElement overrider,
TypeMirror parentType) |
AnnotatedTypeMirror |
getAnnotatedType(Tree tree)
Returns an AnnotatedTypeMirror representing the annotated type of
tree . |
Effect |
getComputedEffectAtCallsite(MethodInvocationTree node,
AnnotatedTypeMirror.AnnotatedDeclaredType callerReceiver,
ExecutableElement methodElt)
Get the effect of a method call at its callsite, acknowledging polymorphic instantiation
using type use annotations.
|
Effect |
getDeclaredEffect(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 |
isDirectlyMarkedUIThroughInference(Tree tree)
Test if this tree corresponds to a lambda expression or new class marked as UI affecting by
either
constrainLambdaToUI } or constrainAnonymousClassToUI(TypeElement) . |
boolean |
isPolymorphicType(TypeElement cls) |
boolean |
isUIType(TypeElement cls) |
createFlowAnalysis
addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addDefaultAnnotations, addTypeNameImplicit, addUncheckedCodeDefaults, addUncheckedStandardDefaults, analyze, applyInferredAnnotations, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, createAndInitQualifierDefaults, createCFGVisualizer, createDependentTypesHelper, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, createTypeAnnotator, fromNewClass, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpressionString, getAnnotationFromReceiver, getAnnotationMirrorFromJavaExpressionString, getCFGVisualizer, getDependentTypesHelper, getEmptyStore, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getMethodReturnType, getNodesForTree, getQualifierPolymorphism, 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 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.
protected final Set<TypeElement> uiAnonClasses
constrainAnonymousClassToUI
adds
anonymous inner classes to this set, and is called from GuiEffectVisitor whenever an
anonymous inner class calls a @UIEffect method. Afterwards isUIType
and getAnnotatedType
will treat this inner class as
if it had been annotated with @UI.
public GuiEffectTypeFactory(BaseTypeChecker checker, boolean spew)
public ExecutableElement findJavaOverride(ExecutableElement overrider, TypeMirror parentType)
public boolean isPolymorphicType(TypeElement cls)
public boolean isUIType(TypeElement cls)
public Effect getDeclaredEffect(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, 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 boolean isDirectlyMarkedUIThroughInference(Tree tree)
constrainLambdaToUI
} or constrainAnonymousClassToUI(TypeElement)
. Only explicit markings due to inference are
considered here, for the properly computed type of the expression, use getAnnotatedType(Tree)
instead.tree
- The tree to check.public AnnotatedTypeMirror getAnnotatedType(Tree tree)
AnnotatedTypeFactory
tree
.
getAnnotatedType
in class AnnotatedTypeFactory
tree
- the AST nodetree
public Effect.EffectRange findInheritedEffectRange(TypeElement declaringType, ExecutableElement overridingMethod)
public Effect.EffectRange findInheritedEffectRange(TypeElement declaringType, 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.public void constrainAnonymousClassToUI(TypeElement classElt)
Used by GuiEffectVisitor to mark as @UI all anonymous inner classes which: inherit from a PolyUIType annotated superclass, override a PolyUIEffect method from said superclass, and perform UIEffect calls inside the body of this method.
classElt
- The TypeElement corresponding to the anonymous inner class to mark as an @UI
instantiation of an UI-polymorphic superclass.