use of javax.annotation.processing.Filer in project tycho by eclipse.
the class JSR269Processor method process.
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (!roundEnv.processingOver()) {
final Filer filer = processingEnv.getFiler();
try {
final JavaFileObject sourceFile = filer.createSourceFile("tycho590.processed.Processor");
Writer sourceWriter = sourceFile.openWriter();
sourceWriter.append("package tycho590.processed;");
sourceWriter.append(String.format("%n"));
sourceWriter.append("public class Processor {}");
sourceWriter.close();
} catch (IOException ex) {
// That will happen on round 2 because source file already exists
System.out.println("[APT] " + ex.getMessage());
}
}
return false;
}
use of javax.annotation.processing.Filer in project potato by eyeem.
the class Processor method process.
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
ArrayList<CodeWriter> writers = new ArrayList<>();
Filer filer = processingEnv.getFiler();
// region for every annotation (should be just the one)
for (TypeElement annotation : annotations) {
// region for every class annotated with the annotation
for (Element element : roundEnv.getElementsAnnotatedWith(annotation)) {
log("generating for " + element.getSimpleName());
PackageElement packageElement = getPackage(element);
TypeElement classElement = getClass(element);
writers.add(new CodeWriter(this, packageElement, classElement, filer));
}
// endregion
}
for (CodeWriter writer : writers) {
writer.run();
}
return true;
}
Aggregations