Search in sources :

Example 1 with ValidationParticipant

use of org.eclipse.xtend.lib.macro.ValidationParticipant in project xtext-xtend by eclipse.

the class AnnotationProcessor method validationPhase.

public Object validationPhase(final ActiveAnnotationContext ctx, final CancelIndicator monitor) {
    Object _xblockexpression = null;
    {
        final Stopwatches.StoppedTask task = Stopwatches.forTask("[macros] validationPhase (AnnotationProcessor.validationPhase)");
        task.start();
        Object _xtrycatchfinallyexpression = null;
        try {
            Object _switchResult = null;
            Object _processorInstance = ctx.getProcessorInstance();
            final Object processor = _processorInstance;
            boolean _matched = false;
            if (processor instanceof ValidationParticipant) {
                _matched = true;
                Object _xblockexpression_1 = null;
                {
                    final ValidationContextImpl validationContext = this.validationContextProvider.get();
                    validationContext.setUnit(ctx.getCompilationUnit());
                    final Runnable _function = () -> {
                        final Function1<XtendAnnotationTarget, NamedElement> _function_1 = (XtendAnnotationTarget it) -> {
                            Declaration _switchResult_1 = null;
                            boolean _matched_1 = false;
                            if (it instanceof XtendMember) {
                                _matched_1 = true;
                                _switchResult_1 = ctx.getCompilationUnit().toXtendMemberDeclaration(((XtendMember) it));
                            }
                            if (!_matched_1) {
                                if (it instanceof XtendParameter) {
                                    _matched_1 = true;
                                    _switchResult_1 = ctx.getCompilationUnit().toXtendParameterDeclaration(((XtendParameter) it));
                                }
                            }
                            final Declaration xtendMember = _switchResult_1;
                            Element _primaryGeneratedJavaElement = validationContext.getPrimaryGeneratedJavaElement(xtendMember);
                            return ((NamedElement) _primaryGeneratedJavaElement);
                        };
                        final List<NamedElement> map = ListExtensions.<XtendAnnotationTarget, NamedElement>map(ctx.getAnnotatedSourceElements(), _function_1);
                        ((ValidationParticipant<NamedElement>) processor).doValidate(map, validationContext);
                    };
                    _xblockexpression_1 = this.runWithCancelIndiciator(ctx, monitor, _function);
                }
                _switchResult = _xblockexpression_1;
            }
            _xtrycatchfinallyexpression = _switchResult;
        } finally {
            task.stop();
        }
        _xblockexpression = _xtrycatchfinallyexpression;
    }
    return _xblockexpression;
}
Also used : ValidationParticipant(org.eclipse.xtend.lib.macro.ValidationParticipant) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) MutableNamedElement(org.eclipse.xtend.lib.macro.declaration.MutableNamedElement) NamedElement(org.eclipse.xtend.lib.macro.declaration.NamedElement) Element(org.eclipse.xtend.lib.macro.declaration.Element) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) XtendParameter(org.eclipse.xtend.core.xtend.XtendParameter) XtendAnnotationTarget(org.eclipse.xtend.core.xtend.XtendAnnotationTarget) List(java.util.List) Declaration(org.eclipse.xtend.lib.macro.declaration.Declaration) MutableNamedElement(org.eclipse.xtend.lib.macro.declaration.MutableNamedElement) NamedElement(org.eclipse.xtend.lib.macro.declaration.NamedElement)

Aggregations

List (java.util.List)1 XtendAnnotationTarget (org.eclipse.xtend.core.xtend.XtendAnnotationTarget)1 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)1 XtendParameter (org.eclipse.xtend.core.xtend.XtendParameter)1 ValidationParticipant (org.eclipse.xtend.lib.macro.ValidationParticipant)1 Declaration (org.eclipse.xtend.lib.macro.declaration.Declaration)1 Element (org.eclipse.xtend.lib.macro.declaration.Element)1 MutableNamedElement (org.eclipse.xtend.lib.macro.declaration.MutableNamedElement)1 NamedElement (org.eclipse.xtend.lib.macro.declaration.NamedElement)1 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)1