use of org.checkerframework.framework.type.AnnotatedTypeMirror in project checker-framework by typetools.
the class IndexUtil method getMinLenFromTree.
/**
* Looks up the minlen of a member select tree. The tree must be an access to a sequence length.
*/
public static Integer getMinLenFromTree(Tree tree, ValueAnnotatedTypeFactory valueATF) {
AnnotatedTypeMirror minLenType = valueATF.getAnnotatedType(tree);
Long min = valueATF.getMinimumIntegralValue(minLenType);
if (min == null) {
return null;
}
if (min < 0 || min > Integer.MAX_VALUE) {
min = 0L;
}
return min.intValue();
}
use of org.checkerframework.framework.type.AnnotatedTypeMirror in project checker-framework by typetools.
the class LessThanAnnotatedTypeFactory method isLessThan.
/**
* @return Is left less than right?
*/
public boolean isLessThan(Tree left, String right) {
AnnotatedTypeMirror leftATM = getAnnotatedType(left);
if (leftATM.getAnnotations().size() != 1) {
return false;
}
List<String> expressions = getLessThanExpressions(leftATM.getAnnotations().iterator().next());
if (expressions == null) {
return true;
}
return expressions.contains(right);
}
use of org.checkerframework.framework.type.AnnotatedTypeMirror in project checker-framework by typetools.
the class LowerBoundAnnotatedTypeFactory method addComputedTypeAnnotations.
/**
* Handles cases 1, 2, and 3.
*/
@Override
public void addComputedTypeAnnotations(Element element, AnnotatedTypeMirror type) {
super.addComputedTypeAnnotations(element, type);
if (element != null) {
AnnotatedTypeMirror valueType = getValueAnnotatedTypeFactory().getAnnotatedType(element);
addLowerBoundTypeFromValueType(valueType, type);
}
}
use of org.checkerframework.framework.type.AnnotatedTypeMirror in project checker-framework by typetools.
the class LowerBoundAnnotatedTypeFactory method addComputedTypeAnnotations.
/**
* Handles cases 1, 2, and 3.
*/
@Override
public void addComputedTypeAnnotations(Tree tree, AnnotatedTypeMirror type, boolean iUseFlow) {
super.addComputedTypeAnnotations(tree, type, iUseFlow);
// "int i = 1; --i;" fails.)
if (iUseFlow && tree != null && TreeUtils.isExpressionTree(tree)) {
AnnotatedTypeMirror valueType = getValueAnnotatedTypeFactory().getAnnotatedType(tree);
addLowerBoundTypeFromValueType(valueType, type);
}
}
use of org.checkerframework.framework.type.AnnotatedTypeMirror in project checker-framework by typetools.
the class WholeProgramInferenceScenes method updateInferredMethodParameterTypes.
/**
* Updates the parameter types of the method {@code methodElt} in the Scene of the method's
* enclosing class based on the overridden method {@code overriddenMethod} parameter types.
*
* <p>For each method parameter in methodElt:
*
* <ul>
* <li>If the Scene does not contain an annotated type for that parameter, then the type of
* the respective parameter on the overridden method will be added to the parameter in the
* Scene.
* <li>If the Scene previously contained an annotated type for that parameter, then its new
* type will be the LUB between the previous type and the type of the respective parameter
* on the overridden method.
* </ul>
*
* <p>
*
* @param methodTree the tree of the method that contains the parameter
* @param methodElt the element of the method
* @param overriddenMethod the AnnotatedExecutableType of the overridden method
* @param atf the annotated type factory of a given type system, whose type hierarchy will be
* used to update the parameter type
*/
@Override
public void updateInferredMethodParameterTypes(MethodTree methodTree, ExecutableElement methodElt, AnnotatedExecutableType overriddenMethod, AnnotatedTypeFactory atf) {
ClassSymbol classSymbol = getEnclosingClassSymbol(methodTree);
String className = classSymbol.flatname.toString();
String jaifPath = helper.getJaifPath(className);
AClass clazz = helper.getAClass(className, jaifPath);
String methodName = JVMNames.getJVMMethodName(methodElt);
AMethod method = clazz.methods.vivify(methodName);
for (int i = 0; i < overriddenMethod.getParameterTypes().size(); i++) {
VariableElement ve = methodElt.getParameters().get(i);
AnnotatedTypeMirror paramATM = atf.getAnnotatedType(ve);
AnnotatedTypeMirror argATM = overriddenMethod.getParameterTypes().get(i);
AField param = method.parameters.vivify(i);
helper.updateAnnotationSetInScene(param.type, atf, jaifPath, argATM, paramATM, TypeUseLocation.PARAMETER);
}
}
Aggregations