in src/com/facebook/buck/java/abi/TypeSummary.java [82:139]
private void appendTypeSignature(StringBuilder builder, TypeElement element) {
ElementKind kind = element.getKind();
builder.append(Annotations.printAnnotations(element.getAnnotationMirrors()));
// Note that this causes all interfaces to be marked as "abstract". Since we're just generating
// a text representation of the interface and not something perfect, I'm okay with this.
builder.append(Modifiers.printModifiers(element.getModifiers()));
switch (kind) {
case ANNOTATION_TYPE:
builder.append("@interface ");
break;
case CLASS:
builder.append("class ");
break;
case ENUM:
builder.append("enum ");
break;
case INTERFACE:
builder.append("interface ");
break;
default:
throw new RuntimeException("Unhandled kind: " + kind);
}
builder.append(element.getQualifiedName());
List<? extends TypeParameterElement> typeParams = element.getTypeParameters();
if (!typeParams.isEmpty()) {
builder.append("<");
Joiner.on(", ").appendTo(builder, typeParams);
builder.append(">");
}
if (kind == CLASS) {
builder.append(" extends ").append(element.getSuperclass());
}
// Sort the list alphabetically.
List<String> converted = new ArrayList<>();
for (TypeMirror mirror : element.getInterfaces()) {
converted.add(mirror.toString());
}
Collections.sort(converted);
if (!converted.isEmpty()) {
if (kind == CLASS || kind == ENUM) {
builder.append(" implements ");
} else {
builder.append(" extends ");
}
Joiner.on(", ").appendTo(builder, converted);
}
builder.append("\n");
}