use of org.checkerframework.framework.util.dependenttypes.DependentTypesHelper in project checker-framework by typetools.
the class BaseTypeVisitor method standardizeAnnotationFromContract.
/**
* Standardize a type qualifier annotation obtained from a contract.
*/
private AnnotationMirror standardizeAnnotationFromContract(AnnotationMirror annoFromContract, FlowExpressionContext flowExprContext, TreePath path) {
DependentTypesHelper dependentTypesHelper = atypeFactory.getDependentTypesHelper();
if (dependentTypesHelper != null) {
AnnotationMirror anno = dependentTypesHelper.standardizeAnnotation(flowExprContext, path, annoFromContract, false);
dependentTypesHelper.checkAnnotation(anno, path.getLeaf());
return anno;
} else {
return annoFromContract;
}
}
use of org.checkerframework.framework.util.dependenttypes.DependentTypesHelper in project checker-framework by typetools.
the class LockAnnotatedTypeFactory method createDependentTypesHelper.
@Override
protected DependentTypesHelper createDependentTypesHelper() {
return new DependentTypesHelper(this) {
@Override
protected void reportErrors(Tree errorTree, List<DependentTypesError> errors) {
// If the error message is NOT_EFFECTIVELY_FINAL, then report lock.expression.not
// .final instead of an expression.unparsable.type.invalid error.
List<DependentTypesError> superErrors = new ArrayList<>();
for (DependentTypesError error : errors) {
if (error.error.equals(NOT_EFFECTIVELY_FINAL)) {
checker.report(Result.failure("lock.expression.not.final", error.expression), errorTree);
} else {
superErrors.add(error);
}
}
super.reportErrors(errorTree, superErrors);
}
@Override
protected String standardizeString(String expression, FlowExpressionContext context, TreePath localScope, boolean useLocalScope) {
if (DependentTypesError.isExpressionError(expression)) {
return expression;
}
// Adds logic to parse <self> expression, which only the Lock Checker uses.
if (LockVisitor.selfReceiverPattern.matcher(expression).matches()) {
return expression;
}
try {
FlowExpressions.Receiver result = FlowExpressionParseUtil.parse(expression, context, localScope, useLocalScope);
if (result == null) {
return new DependentTypesError(expression, " ").toString();
}
if (!isExpressionEffectivelyFinal(result)) {
// NOT_EFFECTIVELY_FINAL error string.
return new DependentTypesError(expression, NOT_EFFECTIVELY_FINAL).toString();
}
return result.toString();
} catch (FlowExpressionParseUtil.FlowExpressionParseException e) {
return new DependentTypesError(expression, e).toString();
}
}
};
}
Aggregations