T
- the type used by the storage to store annotations. The methods atmFromStorageLocation(javax.lang.model.type.TypeMirror, T)
and updateStorageLocationFromAtm(org.checkerframework.framework.type.AnnotatedTypeMirror, org.checkerframework.framework.type.AnnotatedTypeMirror, T, org.checkerframework.framework.qual.TypeUseLocation, boolean)
can be used to manipulate
a storage location.public interface WholeProgramInferenceStorage<T>
Also writes stored annotations to storage files. The specific format depends on the implementation.
Modifier and Type | Method and Description |
---|---|
boolean |
addMethodDeclarationAnnotation(ExecutableElement methodElt,
AnnotationMirror anno)
Updates a method to add a declaration annotation.
|
AnnotatedTypeMirror |
atmFromStorageLocation(TypeMirror typeMirror,
T storageLocation)
Obtain the type from a storage location.
|
T |
getFieldAnnotations(Element element,
String fieldName,
AnnotatedTypeMirror lhsATM,
AnnotatedTypeFactory atypeFactory)
Get the annotations for a field type.
|
String |
getFileForElement(Element elt)
Returns the file corresponding to the given element.
|
T |
getParameterAnnotations(ExecutableElement methodElt,
int i,
AnnotatedTypeMirror paramATM,
VariableElement ve,
AnnotatedTypeFactory atypeFactory)
Get the annotations for a formal parameter type.
|
T |
getPreOrPostconditions(Analysis.BeforeOrAfter preOrPost,
ExecutableElement methodElement,
String expression,
AnnotatedTypeMirror declaredType,
AnnotatedTypeFactory atypeFactory)
Returns the pre- or postcondition annotations for an expression.
|
T |
getReceiverAnnotations(ExecutableElement methodElt,
AnnotatedTypeMirror paramATM,
AnnotatedTypeFactory atypeFactory)
Get the annotations for the receiver type.
|
T |
getReturnAnnotations(ExecutableElement methodElt,
AnnotatedTypeMirror atm,
AnnotatedTypeFactory atypeFactory)
Get the annotations for the return type.
|
boolean |
hasStorageLocationForMethod(ExecutableElement methodElt)
Given an ExecutableElement in a compilation unit that has already been read into storage,
returns whether there exists a stored method matching
elt . |
void |
preprocessClassTree(ClassTree classTree)
Performs any preparation required for inference on the elements of a class.
|
void |
setFileModified(String path)
Indicates that inferred annotations for the file at
path have changed since last
written. |
void |
updateStorageLocationFromAtm(AnnotatedTypeMirror newATM,
AnnotatedTypeMirror curATM,
T storageLocationToUpdate,
TypeUseLocation defLoc,
boolean ignoreIfAnnotated)
Updates a storage location to have the annotations of the given
AnnotatedTypeMirror . |
void |
writeResultsToFile(WholeProgramInference.OutputFormat outputFormat,
BaseTypeChecker checker)
Writes the inferred results to a file.
|
String getFileForElement(Element elt)
elt
- an elementboolean hasStorageLocationForMethod(ExecutableElement methodElt)
elt
.
An implementation is permitted to return false if elt
represents a method that was
synthetically added by javac, such as zero-argument constructors or valueOf(String) methods for
enum types.
methodElt
- a method or constructor Elementelt
T getParameterAnnotations(ExecutableElement methodElt, int i, AnnotatedTypeMirror paramATM, VariableElement ve, AnnotatedTypeFactory atypeFactory)
methodElt
- the method or constructor Elementi
- the parameter index (0-based)paramATM
- the parameter typeve
- the parameter variableatypeFactory
- the type factoryT getReceiverAnnotations(ExecutableElement methodElt, AnnotatedTypeMirror paramATM, AnnotatedTypeFactory atypeFactory)
methodElt
- the method or constructor ElementparamATM
- the receiver typeatypeFactory
- the type factoryT getReturnAnnotations(ExecutableElement methodElt, AnnotatedTypeMirror atm, AnnotatedTypeFactory atypeFactory)
methodElt
- the method or constructor Elementatm
- the return typeatypeFactory
- the type factoryT getFieldAnnotations(Element element, String fieldName, AnnotatedTypeMirror lhsATM, AnnotatedTypeFactory atypeFactory)
element
- the element for the fieldfieldName
- the simple field namelhsATM
- the field typeatypeFactory
- the annotated type factoryT getPreOrPostconditions(Analysis.BeforeOrAfter preOrPost, ExecutableElement methodElement, String expression, AnnotatedTypeMirror declaredType, AnnotatedTypeFactory atypeFactory)
RequiresQualifier
or EnsuresQualifier
annotation.
This method may return null if the given expression is not a supported expression type. Currently, the supported expression types are: fields of "this" (e.g. "this.f", pre- and postconditions), "this" (postconditions only), and method parameters (e.g. "#1", "#2", postconditions only).
preOrPost
- whether to get the precondition or postconditionmethodElement
- the methodexpression
- the expressiondeclaredType
- the declared type of the expressionatypeFactory
- the type factoryboolean addMethodDeclarationAnnotation(ExecutableElement methodElt, AnnotationMirror anno)
methodElt
- the method to annotateanno
- the declaration annotation to add to the methodanno
is a new declaration annotation for methodElt
, false
otherwiseAnnotatedTypeMirror atmFromStorageLocation(TypeMirror typeMirror, T storageLocation)
typeMirror
- the underlying type for the resultstorageLocation
- the storage location from which to obtain annotationstypeMirror
and annotations from
storageLocation
void updateStorageLocationFromAtm(AnnotatedTypeMirror newATM, AnnotatedTypeMirror curATM, T storageLocationToUpdate, TypeUseLocation defLoc, boolean ignoreIfAnnotated)
AnnotatedTypeMirror
.
Annotations in the original set that should be ignored are not added to the resulting set. If
ignoreIfAnnotated
is true, doesn't add annotations for locations with explicit
annotations in source code.
This method removes from the storage location all annotations supported by the
AnnotatedTypeFactory before inserting new ones. It is assumed that every time this method is
called, the new AnnotatedTypeMirror
has a better type estimate for the given location.
Therefore, it is not a problem to remove all annotations before inserting the new annotations.
The update*
methods in WholeProgramInference
perform LUB. This one just does
replacement. (Thus, the naming may be a bit confusing.)
newATM
- the type whose annotations will be added to the AnnotatedTypeMirror
curATM
- the annotations currently stored at the location, used to check if the element
that will be updated has explicit annotations in source codestorageLocationToUpdate
- the storage location that will be updateddefLoc
- the location where the annotation will be addedignoreIfAnnotated
- if true, don't update any type that is explicitly annotated in the
source codevoid writeResultsToFile(WholeProgramInference.OutputFormat outputFormat, BaseTypeChecker checker)
outputFormat
- the file format in which to write the resultschecker
- the checker from which this method is called, for naming annotation filesvoid setFileModified(String path)
path
have changed since last
written. This causes output files for path
to be written out next time writeResultsToFile(org.checkerframework.common.wholeprograminference.WholeProgramInference.OutputFormat, org.checkerframework.common.basetype.BaseTypeChecker)
is called.path
- path to the file with annotations that have been modifiedvoid preprocessClassTree(ClassTree classTree)
classTree
- the class to preprocess