use of org.eclipse.xtend.lib.macro.CodeGenerationParticipant in project xtext-xtend by eclipse.
the class XtendGenerator method callMacroProcessors.
public void callMacroProcessors(final Resource input) {
final ActiveAnnotationContexts ctxs = ActiveAnnotationContexts.find(input);
if ((ctxs == null)) {
return;
}
try {
ctxs.before(ActiveAnnotationContexts.AnnotationCallback.GENERATION);
Collection<ActiveAnnotationContext> _values = ctxs.getContexts().values();
for (final ActiveAnnotationContext context : _values) {
try {
Object _processorInstance = context.getProcessorInstance();
final Object processor = _processorInstance;
boolean _matched = false;
if (processor instanceof CodeGenerationParticipant) {
_matched = true;
CodeGenerationContextImpl _codeGenerationContextImpl = new CodeGenerationContextImpl();
final Procedure1<CodeGenerationContextImpl> _function = (CodeGenerationContextImpl it) -> {
it.setUnit(context.getCompilationUnit());
};
final CodeGenerationContextImpl codeGenServices = ObjectExtensions.<CodeGenerationContextImpl>operator_doubleArrow(_codeGenerationContextImpl, _function);
final Function1<XtendAnnotationTarget, MemberDeclaration> _function_1 = (XtendAnnotationTarget it) -> {
return context.getCompilationUnit().toXtendMemberDeclaration(((XtendMember) it));
};
final List<MemberDeclaration> elements = ListExtensions.<XtendAnnotationTarget, MemberDeclaration>map(context.getAnnotatedSourceElements(), _function_1);
((CodeGenerationParticipant<NamedElement>) processor).doGenerateCode(elements, codeGenServices);
}
} catch (final Throwable _t) {
if (_t instanceof Throwable) {
final Throwable t = (Throwable) _t;
this.operationCanceledManager.propagateAsErrorIfCancelException(t);
context.handleProcessingError(input, t);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
} finally {
ctxs.after(ActiveAnnotationContexts.AnnotationCallback.GENERATION);
}
}
Aggregations