use of org.checkerframework.common.value.ValueAnnotatedTypeFactory in project checker-framework by typetools.
the class MethodSignature method getMethodNamesFromStringArg.
/**
* Returns the string values for the argument passed. The String Values are estimated using the
* Value Checker.
*
* @param arg ExpressionTree whose string values are sought
* @return string values of arg or the empty list if no values were found
*/
private List<String> getMethodNamesFromStringArg(ExpressionTree arg) {
List<String> methodNames = new ArrayList<>();
ValueAnnotatedTypeFactory valueATF = getTypeFactoryOfSubchecker(ValueChecker.class);
AnnotatedTypeMirror valueAnno = valueATF.getAnnotatedType(arg);
AnnotationMirror annotation = valueAnno.getAnnotation(StringVal.class);
if (annotation != null) {
methodNames = AnnotationUtils.getElementValueArray(annotation, "value", String.class, true);
}
return methodNames;
}
use of org.checkerframework.common.value.ValueAnnotatedTypeFactory in project checker-framework by typetools.
the class UpperBoundVisitor method relaxedCommonAssignmentCheck.
/**
* Implements the actual check for the relaxed common assignment check. For what is permitted,
* see {@link #relaxedCommonAssignment}.
*/
private boolean relaxedCommonAssignmentCheck(LessThanLengthOf varLtlQual, ExpressionTree valueExp) {
AnnotatedTypeMirror expType = atypeFactory.getAnnotatedType(valueExp);
UBQualifier expQual = UBQualifier.createUBQualifier(expType, atypeFactory.UNKNOWN);
UBQualifier lessThanQual = atypeFactory.fromLessThan(valueExp, getCurrentPath());
if (lessThanQual != null) {
expQual = expQual.glb(lessThanQual);
}
UBQualifier lessThanOrEqualQual = atypeFactory.fromLessThanOrEqual(valueExp, getCurrentPath());
if (lessThanOrEqualQual != null) {
expQual = expQual.glb(lessThanOrEqualQual);
}
if (expQual.isSubtype(varLtlQual)) {
return true;
}
Long value = IndexUtil.getMaxValue(valueExp, atypeFactory.getValueAnnotatedTypeFactory());
if (value == null && !expQual.isLessThanLengthQualifier()) {
return false;
}
SameLenAnnotatedTypeFactory sameLenFactory = atypeFactory.getSameLenAnnotatedTypeFactory();
ValueAnnotatedTypeFactory valueAnnotatedTypeFactory = atypeFactory.getValueAnnotatedTypeFactory();
checkloop: for (String sequenceName : varLtlQual.getSequences()) {
List<String> sameLenSequences = sameLenFactory.getSameLensFromString(sequenceName, valueExp, getCurrentPath());
if (testSameLen(expQual, varLtlQual, sameLenSequences, sequenceName)) {
continue;
}
int minlen = valueAnnotatedTypeFactory.getMinLenFromString(sequenceName, valueExp, getCurrentPath());
if (testMinLen(value, minlen, sequenceName, varLtlQual)) {
continue;
}
for (String sequence : sameLenSequences) {
int minlenSL = valueAnnotatedTypeFactory.getMinLenFromString(sequence, valueExp, getCurrentPath());
if (testMinLen(value, minlenSL, sequenceName, varLtlQual)) {
continue checkloop;
}
}
return false;
}
return true;
}
Aggregations