use of org.checkerframework.checker.mustcall.MustCallAnnotatedTypeFactory in project checker-framework by typetools.
the class ResourceLeakTransfer method visitMethodInvocation.
@Override
public TransferResult<CFValue, CFStore> visitMethodInvocation(final MethodInvocationNode node, final TransferInput<CFValue, CFStore> input) {
TransferResult<CFValue, CFStore> result = super.visitMethodInvocation(node, input);
handleCreatesMustCallFor(node, result);
updateStoreWithTempVar(result, node);
// If there is a temporary variable for the receiver, update its type.
Node receiver = node.getTarget().getReceiver();
MustCallAnnotatedTypeFactory mcAtf = rlTypeFactory.getTypeFactoryOfSubchecker(MustCallChecker.class);
Node accumulationTarget = mcAtf.getTempVar(receiver);
if (accumulationTarget != null) {
String methodName = node.getTarget().getMethod().getSimpleName().toString();
methodName = rlTypeFactory.adjustMethodNameUsingValueChecker(methodName, node.getTree());
accumulate(accumulationTarget, result, methodName);
}
return result;
}
use of org.checkerframework.checker.mustcall.MustCallAnnotatedTypeFactory in project checker-framework by typetools.
the class ResourceLeakVisitor method isMustCallMethod.
/**
* Returns true iff the {@code MustCall} annotation of the class that encloses the methodTree
* names this method.
*
* @param methodTree the declaration of a method
* @return whether that method is one of the must-call methods for its enclosing class
*/
private boolean isMustCallMethod(MethodTree methodTree) {
ExecutableElement elt = TreeUtils.elementFromDeclaration(methodTree);
TypeElement containingClass = ElementUtils.enclosingTypeElement(elt);
MustCallAnnotatedTypeFactory mustCallAnnotatedTypeFactory = rlTypeFactory.getTypeFactoryOfSubchecker(MustCallChecker.class);
AnnotationMirror mcAnno = mustCallAnnotatedTypeFactory.getAnnotatedType(containingClass).getAnnotationInHierarchy(mustCallAnnotatedTypeFactory.TOP);
List<String> mcValues = AnnotationUtils.getElementValueArray(mcAnno, mustCallAnnotatedTypeFactory.getMustCallValueElement(), String.class);
String methodName = elt.getSimpleName().toString();
return mcValues.contains(methodName);
}
Aggregations