use of org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType in project checker-framework by typetools.
the class TypeOutputtingChecker method printClassType.
/**
* Prints the types of the class and all of its enclosing fields, methods, and inner classes
*/
protected static void printClassType(TypeElement typeElt, AnnotatedTypeFactory atypeFactory) {
assert typeElt != null;
String simpleName = typeElt.getSimpleName().toString();
// Output class info
AnnotatedDeclaredType type = atypeFactory.fromElement(typeElt);
System.out.println(simpleName + "\t" + type + "\t" + type.directSuperTypes());
// output fields and methods
for (Element enclosedElt : typeElt.getEnclosedElements()) {
if (enclosedElt instanceof TypeElement) {
printClassType((TypeElement) enclosedElt, atypeFactory);
}
if (!enclosedElt.getKind().isField() && !(enclosedElt instanceof ExecutableElement))
continue;
AnnotatedTypeMirror memberType = atypeFactory.fromElement(enclosedElt);
System.out.println(simpleName + "." + enclosedElt + "\t\t" + memberType);
}
}
use of org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType in project checker-framework by typetools.
the class ReportVisitor method visitMethod.
@Override
public Void visitMethod(MethodTree node, Void p) {
ExecutableElement method = TreeUtils.elementFromDeclaration(node);
boolean report = false;
// Check all overridden methods.
Map<AnnotatedDeclaredType, ExecutableElement> overriddenMethods = AnnotatedTypes.overriddenMethods(elements, atypeFactory, method);
for (Map.Entry<AnnotatedDeclaredType, ExecutableElement> pair : overriddenMethods.entrySet()) {
// AnnotatedDeclaredType overriddenType = pair.getKey();
ExecutableElement exe = pair.getValue();
report = this.atypeFactory.getDeclAnnotation(exe, ReportOverride.class) != null;
if (report) {
// Set method to report the right method, if found.
method = exe;
break;
}
}
if (report) {
checker.report(Result.failure("override", node, ElementUtils.getVerboseName(method)), node);
}
return super.visitMethod(node, p);
}
Aggregations