Search in sources :

Example 16 with MemberDeclaration

use of org.eclipse.xtend.lib.macro.declaration.MemberDeclaration 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);
    }
}
Also used : MemberDeclaration(org.eclipse.xtend.lib.macro.declaration.MemberDeclaration) XtendAnnotationTarget(org.eclipse.xtend.core.xtend.XtendAnnotationTarget) ActiveAnnotationContexts(org.eclipse.xtend.core.macro.ActiveAnnotationContexts) ActiveAnnotationContext(org.eclipse.xtend.core.macro.ActiveAnnotationContext) CodeGenerationParticipant(org.eclipse.xtend.lib.macro.CodeGenerationParticipant) CodeGenerationContextImpl(org.eclipse.xtend.core.macro.CodeGenerationContextImpl) EObject(org.eclipse.emf.ecore.EObject)

Aggregations

MemberDeclaration (org.eclipse.xtend.lib.macro.declaration.MemberDeclaration)16 EObject (org.eclipse.emf.ecore.EObject)5 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)5 MutableMemberDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableMemberDeclaration)4 JvmMember (org.eclipse.xtext.common.types.JvmMember)4 MutableFieldDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableFieldDeclaration)3 CompilationUnitImpl (org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl)2 AnnotationTypeDeclaration (org.eclipse.xtend.lib.macro.declaration.AnnotationTypeDeclaration)2 ClassDeclaration (org.eclipse.xtend.lib.macro.declaration.ClassDeclaration)2 FieldDeclaration (org.eclipse.xtend.lib.macro.declaration.FieldDeclaration)2 MethodDeclaration (org.eclipse.xtend.lib.macro.declaration.MethodDeclaration)2 MutableClassDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration)2 MutableMethodDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableMethodDeclaration)2 TypeDeclaration (org.eclipse.xtend.lib.macro.declaration.TypeDeclaration)2 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)2 JvmConstructor (org.eclipse.xtext.common.types.JvmConstructor)2 JvmEnumerationLiteral (org.eclipse.xtext.common.types.JvmEnumerationLiteral)2 JvmField (org.eclipse.xtext.common.types.JvmField)2 IResolvedOperation (org.eclipse.xtext.xbase.typesystem.override.IResolvedOperation)2 ResolvedFeatures (org.eclipse.xtext.xbase.typesystem.override.ResolvedFeatures)2