use of com.palantir.goethe.GoetheException in project tritium by palantir.
the class TritiumAnnotationProcessor method process.
@Override
public boolean process(Set<? extends TypeElement> _annotations, RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) {
if (!invalidElements.isEmpty()) {
messager.printMessage(Kind.ERROR, "Processing completed with unresolved elements: " + invalidElements);
}
return false;
}
for (Element element : getElementsToProcess(roundEnv)) {
if (element.getKind() != ElementKind.INTERFACE) {
messager.printMessage(Kind.ERROR, "Only interfaces may be instrumented using @" + Instrument.class.getSimpleName(), element);
continue;
}
TypeElement typeElement = (TypeElement) element;
List<DeclaredType> allInterfaces = new ArrayList<>();
List<DeclaredType> minimalInterfaces = new ArrayList<>();
if (isInvalid(element.asType(), allInterfaces, minimalInterfaces)) {
invalidElements.add(typeElement.getQualifiedName());
continue;
}
if (allInterfaces.isEmpty()) {
messager.printMessage(Kind.ERROR, "Cannot generate a instrumented implementation. " + "The annotated class implements no interfaces.", typeElement);
continue;
}
try {
JavaFile generatedFile = generate(typeElement, allInterfaces, minimalInterfaces);
try {
Goethe.formatAndEmit(generatedFile, filer);
} catch (GoetheException e) {
messager.printMessage(Kind.ERROR, "Failed to write instrumented class: " + Throwables.getStackTraceAsString(e));
}
} catch (RuntimeException e) {
messager.printMessage(Kind.ERROR, "Failed to generate instrumented class: " + Throwables.getStackTraceAsString(e));
}
}
return false;
}
Aggregations