use of com.helger.jcodemodel.JCodeModel in project androidannotations by androidannotations.
the class APTCodeModelHelper method createDelegatingAnonymousRunnableClass.
public JDefinedClass createDelegatingAnonymousRunnableClass(JBlock previousBody) {
JCodeModel codeModel = environment.getCodeModel();
JDefinedClass anonymousRunnableClass = codeModel.anonymousClass(Runnable.class);
JMethod runMethod = anonymousRunnableClass.method(JMod.PUBLIC, codeModel.VOID, "run");
runMethod.annotate(Override.class);
runMethod.body().add(previousBody);
return anonymousRunnableClass;
}
use of com.helger.jcodemodel.JCodeModel in project adt4j by sviperll.
the class GenerateValueClassForVisitorProcessor method finishProcessing.
private void finishProcessing() {
Set<TypeElement> elements = new HashSet<>();
for (String path : remainingElements) {
TypeElement typeElement = processingEnv.getElementUtils().getTypeElement(path);
if (typeElement == null)
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Unable to find type " + path);
else
elements.add(typeElement);
}
ElementProcessor elementProcessor = new ElementProcessor(elements, new JCodeModel());
elementProcessor.generateClasses();
elementProcessor.writeGeneratedCode();
for (Entry<String, List<String>> errors : errorMap.entrySet()) {
TypeElement typeElement = processingEnv.getElementUtils().getTypeElement(errors.getKey());
for (String error : errors.getValue()) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, error, typeElement);
}
}
}
use of com.helger.jcodemodel.JCodeModel in project adt4j by sviperll.
the class GenerateValueClassForVisitorProcessor method processRound.
private void processRound(RoundEnvironment roundEnv) {
Set<TypeElement> elements = new HashSet<>();
for (Element element : roundEnv.getElementsAnnotatedWith(GenerateValueClassForVisitor.class)) {
elements.add((TypeElement) element);
}
for (Element element : roundEnv.getElementsAnnotatedWith(WrapsGeneratedValueClass.class)) {
elements.add((TypeElement) element);
}
Set<String> elementsFromPreviousRound = new HashSet<>(remainingElements);
remainingElements.clear();
for (String path : elementsFromPreviousRound) {
TypeElement typeElement = processingEnv.getElementUtils().getTypeElement(path);
if (typeElement == null)
remainingElements.add(path);
else
elements.add(typeElement);
}
ElementProcessor elementProcessor = new ElementProcessor(elements, new JCodeModel());
elementProcessor.generateClassesWithoutErrors();
elementProcessor.writeGeneratedCode();
}
Aggregations