use of org.checkerframework.common.wholeprograminference.WholeProgramInferenceImplementation in project checker-framework by typetools.
the class GenericAnnotatedTypeFactory method getPreconditionAnnotations.
/**
* Return the precondition annotations for the given AMethod. Does not modify the AMethod. This
* method must only be called when using WholeProgramInferenceScenes.
*
* @param m AFU representation of a method
* @return precondition annotations for the method
*/
public List<AnnotationMirror> getPreconditionAnnotations(AMethod m) {
List<AnnotationMirror> result = new ArrayList<>(m.getPreconditions().size());
for (Map.Entry<String, AField> entry : m.getPreconditions().entrySet()) {
WholeProgramInferenceImplementation<?> wholeProgramInference = (WholeProgramInferenceImplementation<?>) getWholeProgramInference();
WholeProgramInferenceScenesStorage storage = (WholeProgramInferenceScenesStorage) wholeProgramInference.getStorage();
TypeMirror typeMirror = entry.getValue().getTypeMirror();
if (typeMirror == null) {
throw new BugInCF("null TypeMirror in AField inferred by WPI precondition inference. AField: " + entry.getValue().toString());
}
AnnotatedTypeMirror declaredType = storage.getPreconditionDeclaredType(m, entry.getKey());
AnnotatedTypeMirror inferredType = storage.atmFromStorageLocation(typeMirror, entry.getValue().type);
result.addAll(getPreconditionAnnotations(entry.getKey(), inferredType, declaredType));
}
Collections.sort(result, Ordering.usingToString());
return result;
}
use of org.checkerframework.common.wholeprograminference.WholeProgramInferenceImplementation in project checker-framework by typetools.
the class GenericAnnotatedTypeFactory method getPostconditionAnnotations.
/**
* Return the postcondition annotations for the given AMethod. Does not modify the AMethod. This
* method must only be called when using WholeProgramInferenceScenes.
*
* @param m AFU representation of a method
* @param preconds the precondition annotations for the method; used to suppress redundant
* postconditions
* @return postcondition annotations for the method
*/
public List<AnnotationMirror> getPostconditionAnnotations(AMethod m, List<AnnotationMirror> preconds) {
List<AnnotationMirror> result = new ArrayList<>(m.getPostconditions().size());
for (Map.Entry<String, AField> entry : m.getPostconditions().entrySet()) {
WholeProgramInferenceImplementation<?> wholeProgramInference = (WholeProgramInferenceImplementation<?>) getWholeProgramInference();
WholeProgramInferenceScenesStorage storage = (WholeProgramInferenceScenesStorage) wholeProgramInference.getStorage();
TypeMirror typeMirror = entry.getValue().getTypeMirror();
if (typeMirror == null) {
throw new BugInCF("null TypeMirror in AField inferred by WPI postcondition inference. AField: " + entry.getValue().toString());
}
AnnotatedTypeMirror declaredType = storage.getPostconditionDeclaredType(m, entry.getKey());
AnnotatedTypeMirror inferredType = storage.atmFromStorageLocation(typeMirror, entry.getValue().type);
result.addAll(getPostconditionAnnotations(entry.getKey(), inferredType, declaredType, preconds));
}
Collections.sort(result, Ordering.usingToString());
return result;
}
Aggregations