Search in sources :

Example 1 with ReportUse

use of org.checkerframework.common.util.report.qual.ReportUse in project checker-framework by typetools.

the class ReportVisitor method checkReportUse.

/**
 * Check for uses of the {@link ReportUse} annotation. This method has to be called for every
 * explicit or implicit use of a type, most cases are simply covered by the type validator.
 *
 * @param node the tree for error reporting only
 * @param member the element from which to start looking
 */
private void checkReportUse(Tree node, Element member) {
    Element loop = member;
    while (loop != null) {
        boolean report = this.atypeFactory.getDeclAnnotation(loop, ReportUse.class) != null;
        if (report) {
            checker.report(Result.failure("usage", node, ElementUtils.getVerboseName(loop), loop.getKind(), ElementUtils.getVerboseName(member), member.getKind()), node);
            break;
        } else {
            if (loop.getKind() == ElementKind.PACKAGE) {
                loop = ElementUtils.parentPackage((PackageElement) loop, elements);
                continue;
            }
        }
        // Package will always be the last iteration.
        loop = loop.getEnclosingElement();
    }
}
Also used : ReportUse(org.checkerframework.common.util.report.qual.ReportUse) PackageElement(javax.lang.model.element.PackageElement) TypeElement(javax.lang.model.element.TypeElement) ExecutableElement(javax.lang.model.element.ExecutableElement) Element(javax.lang.model.element.Element) PackageElement(javax.lang.model.element.PackageElement)

Aggregations

Element (javax.lang.model.element.Element)1 ExecutableElement (javax.lang.model.element.ExecutableElement)1 PackageElement (javax.lang.model.element.PackageElement)1 TypeElement (javax.lang.model.element.TypeElement)1 ReportUse (org.checkerframework.common.util.report.qual.ReportUse)1