use of org.checkerframework.framework.flow.CFAnalysis in project checker-framework by typetools.
the class GenericAnnotatedTypeFactory method createFlowAnalysis.
/**
* Returns the appropriate flow analysis class that is used for the
* org.checkerframework.dataflow analysis.
*
* <p>This implementation uses the checker naming convention to create the appropriate analysis.
* If no transfer function is found, it returns an instance of {@link CFAnalysis}.
*
* <p>Subclasses have to override this method to create the appropriate analysis if they do not
* follow the checker naming convention.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
protected FlowAnalysis createFlowAnalysis(List<Pair<VariableElement, Value>> fieldValues) {
// Try to reflectively load the visitor.
Class<?> checkerClass = checker.getClass();
while (checkerClass != BaseTypeChecker.class) {
final String classToLoad = checkerClass.getName().replace("Checker", "Analysis").replace("Subchecker", "Analysis");
FlowAnalysis result = BaseTypeChecker.invokeConstructorFor(classToLoad, new Class<?>[] { BaseTypeChecker.class, this.getClass(), List.class }, new Object[] { checker, this, fieldValues });
if (result != null) {
return result;
}
checkerClass = checkerClass.getSuperclass();
}
// If an analysis couldn't be loaded reflectively, return the
// default.
List<Pair<VariableElement, CFValue>> tmp = new ArrayList<>();
for (Pair<VariableElement, Value> fieldVal : fieldValues) {
assert fieldVal.second instanceof CFValue;
tmp.add(Pair.of(fieldVal.first, (CFValue) fieldVal.second));
}
return (FlowAnalysis) new CFAnalysis(checker, (GenericAnnotatedTypeFactory) this, tmp);
}
Aggregations