public class GuiEffectTypeFactory extends BaseAnnotatedTypeFactory
GenericAnnotatedTypeFactory.ScanStateAnnotatedTypeFactory.ParameterizedExecutableType| 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, contractsUtils, defaults, dependentTypesHelper, emptyStore, exceptionalExitStores, flowByDefault, flowResult, flowResultAnalysisCaches, formalParameterPattern, hasOrIsSubchecker, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, relevantJavaTypes, returnStatementStores, scannedClasses, shouldClearSubcheckerSharedCFGs, sideEffectsUnrefineAliases, subcheckerSharedCFG, transfer, treeAnnotator, typeAnnotatorajavaTypes, artificialTreeToEnclosingElementMap, checker, currentFileAjavaTypes, elements, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, ignoreUninferredTypeArguments, loader, methodValClassNameElement, methodValMethodNameElement, methodValParamsElement, objectGetClass, processingEnv, qualHierarchy, qualifierUpperBounds, reflectionResolver, root, shouldCache, stubTypes, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, visitorState, wpiOutputFormat| 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)
Find the greatest and least effects of methods the specified definition overrides.
|
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.
|
protected Set<? extends AnnotationMirror> |
getDefaultTypeDeclarationBounds()
Returns the set of qualifiers that are the upper bound for a type use if no other bound is
specified for the type.
|
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) |
createFlowAnalysisaddAnnotationsFromDefaultForType, addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForTypeAnnotator, createDefaultForUseTypeAnnotator, createDependentTypesHelper, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, createRequiresOrEnsuresQualifier, createTypeAnnotator, fromNewClass, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpression, getAnnotationFromJavaExpressionString, getAnnotationMirrorFromJavaExpressionString, getAnnotationsFromJavaExpression, getCFGVisualizer, getContractAnnotations, getContractAnnotations, getContractExpressions, getContractsFromMethod, getDefaultForTypeAnnotator, getDefaultValueAnnotatedType, getDependentTypesHelper, getEmptyStore, getEnsuresQualifierIfResult, getExceptionalExitStore, getExpressionAndOffsetFromJavaExpressionString, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getNodesForTree, getPostconditionAnnotations, getPostconditionAnnotations, getPostconditionAnnotations, getPreconditionAnnotations, getPreconditionAnnotations, getPreconditionAnnotations, getPreOrPostconditionAnnotations, getQualifierPolymorphism, getRegularExitStore, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getSharedCFGForTree, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, handleCFGViz, isRelevant, methodFromUse, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysis, postAnalyze, postAsMemberOf, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUseadaptGetClassReturnTypeToReceiver, addAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedDeclAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, applyCaptureConversion, applyCaptureConversion, applyUnboxing, areSameByClass, binaryTreeArgTypes, binaryTreeArgTypes, canonicalAnnotation, checkInvalidOptionsInferSignatures, compoundAssignmentTreeArgTypes, containsSameByClass, containsUninferredTypeArguments, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierHierarchy, createQualifierHierarchyWithMultiGraphFactory, createQualifierUpperBounds, createSupportedTypeQualifiers, createTypeArgumentInference, createTypeHierarchy, createTypeVariableSubstitutor, declarationFromElement, doesAnnotatedForApplyToThisChecker, fromElement, fromElement, fromElement, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationByClass, getAnnotationFormatter, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiers, getCacheSize, getChecker, getCheckerNames, getContractExpressions, getContractListValues, getCurrentClassTree, getCurrentClassType, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDummyAssignedTo, getElementUtils, getEnclosingClassOrMethod, getEnclosingElementForArtificialTree, getEnclosingType, getExpressionAndOffset, getFieldInvariantAnnotationTree, getFieldInvariantDeclarationAnnotations, getFieldInvariants, getFnInterfaceFromTree, getFunctionTypeFromTree, getFunctionTypeFromTree, getImplicitReceiverType, getIterableElementType, getIterableElementType, getMethodReturnType, getNarrowedAnnotations, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getQualifierParameterHierarchies, getQualifierParameterHierarchies, getQualifierUpperBounds, getReceiverType, getSelfType, getStringType, getSupportedTypeQualifierNames, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeDeclarationBounds, getTypeHierarchy, getTypeOfExtendsImplements, getTypeVarSubstitutor, getUnboxedType, getUninferredWildcardType, getVisitorState, getWholeProgramInference, getWidenedAnnotations, getWidenedType, getWidenedType, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, initializeAtm, initializeReflectionResolution, isFromByteCode, isFromStubFile, isImmutable, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isWithinConstructor, mergeAnnotationFileAnnosIntoType, methodFromUse, negateConstant, order, parseAnnotationFiles, postProcessClassTree, postTypeVarSubstitution, prepareMethodForWriting, prepareMethodForWriting, replaceAnnotations, replaceAnnotations, setEnclosingElementForArtificialTree, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type, wpiAdjustForUpdateField, wpiAdjustForUpdateNonFieldprotected 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 nodecallerReceiver - the type of the receiver object if available. Used to resolve direct
calls like "super()"methodElt - the element of the callee methodpublic 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 nodepublic 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 checkpublic AnnotatedTypeMirror getAnnotatedType(Tree tree)
AnnotatedTypeFactorytree.getAnnotatedType in class AnnotatedTypeFactorytree - the AST nodetreepublic Effect.EffectRange findInheritedEffectRange(TypeElement declaringType, ExecutableElement overridingMethod)
public Effect.EffectRange findInheritedEffectRange(TypeElement declaringType, ExecutableElement overridingMethod, boolean issueConflictWarning, Tree errorNode)
1. GuiEffectVisitor.visitMethod calls
this to perform an effect override check (that a method's effect is less than or equal to the
effect of any method it overrides). This use passes true for the issueConflictWarning in order to trigger warning messages.
2. getDeclaredEffect in this class uses this
to infer the default effect of methods in anonymous inner classes. This use passes false for issueConflictWarning, because it only needs the return value.
declaringType - the type declaring the overrideoverridingMethod - the method override itselfissueConflictWarning - whether or not to issue warningserrorNode - the method declaration node; used for reporting errorsprotected Set<? extends AnnotationMirror> getDefaultTypeDeclarationBounds()
AnnotatedTypeFactoryThis implementation returns the top qualifiers by default. Subclass may override to return different qualifiers.
getDefaultTypeDeclarationBounds in class AnnotatedTypeFactoryprotected TreeAnnotator createTreeAnnotator()
GenericAnnotatedTypeFactoryTreeAnnotator 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
LiteralTreeAnnotator: Adds annotations based on QualifierForLiterals
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 nodepublic 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.