Search in sources :

Example 1 with XtendAnnotationTypeDeclarationImpl

use of org.eclipse.xtend.core.macro.declaration.XtendAnnotationTypeDeclarationImpl in project xtext-xtend by eclipse.

the class AnnotationReferenceProviderImpl method newAnnotationReference.

@Override
public AnnotationReference newAnnotationReference(final Type annotationTypeDelcaration, final Procedure1<AnnotationReferenceBuildContext> initializer) {
    Object _xblockexpression = null;
    {
        this.compilationUnit.checkCanceled();
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("annotationTypeDelcaration cannot be null");
        Preconditions.checkArgument((annotationTypeDelcaration != null), _builder);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("initializer cannot be null");
        Preconditions.checkArgument((initializer != null), _builder_1);
        JvmDeclaredType _switchResult = null;
        boolean _matched = false;
        if (annotationTypeDelcaration instanceof JvmAnnotationTypeDeclarationImpl) {
            _matched = true;
            _switchResult = ((JvmAnnotationTypeDeclarationImpl) annotationTypeDelcaration).getDelegate();
        }
        if (!_matched) {
            if (annotationTypeDelcaration instanceof XtendAnnotationTypeDeclarationImpl) {
                _matched = true;
                _switchResult = this.compilationUnit.getJvmModelAssociations().getInferredType(((XtendAnnotationTypeDeclarationImpl) annotationTypeDelcaration).getDelegate());
            }
        }
        if (!_matched) {
            throw new IllegalArgumentException(("couldn\'t construct type reference for type " + annotationTypeDelcaration));
        }
        final JvmDeclaredType type = _switchResult;
        if ((type instanceof JvmAnnotationType)) {
            final JvmAnnotationReference newJvmAnnotationReference = this.createJvmAnnotationReference(type);
            AnnotationReferenceBuildContextImpl _annotationReferenceBuildContextImpl = new AnnotationReferenceBuildContextImpl();
            final Procedure1<AnnotationReferenceBuildContextImpl> _function = (AnnotationReferenceBuildContextImpl it) -> {
                it.setDelegate(newJvmAnnotationReference);
                it.setCompilationUnit(this.compilationUnit);
            };
            final AnnotationReferenceBuildContextImpl buildContext = ObjectExtensions.<AnnotationReferenceBuildContextImpl>operator_doubleArrow(_annotationReferenceBuildContextImpl, _function);
            initializer.apply(buildContext);
            return this.compilationUnit.toAnnotationReference(newJvmAnnotationReference);
        }
        _xblockexpression = null;
    }
    return ((AnnotationReference) _xblockexpression);
}
Also used : JvmAnnotationType(org.eclipse.xtext.common.types.JvmAnnotationType) AnnotationReferenceBuildContextImpl(org.eclipse.xtend.core.macro.declaration.AnnotationReferenceBuildContextImpl) JvmAnnotationTypeDeclarationImpl(org.eclipse.xtend.core.macro.declaration.JvmAnnotationTypeDeclarationImpl) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) XtendAnnotationTypeDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendAnnotationTypeDeclarationImpl) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference)

Example 2 with XtendAnnotationTypeDeclarationImpl

use of org.eclipse.xtend.core.macro.declaration.XtendAnnotationTypeDeclarationImpl in project xtext-xtend by eclipse.

the class CompilationUnitImpl method toXtendTypeDeclaration.

public XtendTypeDeclarationImpl<? extends XtendTypeDeclaration> toXtendTypeDeclaration(final XtendTypeDeclaration delegate) {
    final Function1<XtendTypeDeclaration, XtendTypeDeclarationImpl<? extends XtendTypeDeclaration>> _function = (XtendTypeDeclaration it) -> {
        XtendTypeDeclarationImpl<? extends XtendTypeDeclaration> _switchResult = null;
        boolean _matched = false;
        if (delegate instanceof XtendClass) {
            _matched = true;
            XtendClassDeclarationImpl _xtendClassDeclarationImpl = new XtendClassDeclarationImpl();
            final Procedure1<XtendClassDeclarationImpl> _function_1 = (XtendClassDeclarationImpl it_1) -> {
                it_1.setDelegate(((XtendClass) delegate));
                it_1.setCompilationUnit(this);
            };
            _switchResult = ObjectExtensions.<XtendClassDeclarationImpl>operator_doubleArrow(_xtendClassDeclarationImpl, _function_1);
        }
        if (!_matched) {
            if (delegate instanceof XtendInterface) {
                _matched = true;
                XtendInterfaceDeclarationImpl _xtendInterfaceDeclarationImpl = new XtendInterfaceDeclarationImpl();
                final Procedure1<XtendInterfaceDeclarationImpl> _function_1 = (XtendInterfaceDeclarationImpl it_1) -> {
                    it_1.setDelegate(((XtendInterface) delegate));
                    it_1.setCompilationUnit(this);
                };
                _switchResult = ObjectExtensions.<XtendInterfaceDeclarationImpl>operator_doubleArrow(_xtendInterfaceDeclarationImpl, _function_1);
            }
        }
        if (!_matched) {
            if (delegate instanceof XtendAnnotationType) {
                _matched = true;
                XtendAnnotationTypeDeclarationImpl _xtendAnnotationTypeDeclarationImpl = new XtendAnnotationTypeDeclarationImpl();
                final Procedure1<XtendAnnotationTypeDeclarationImpl> _function_1 = (XtendAnnotationTypeDeclarationImpl it_1) -> {
                    it_1.setDelegate(((XtendAnnotationType) delegate));
                    it_1.setCompilationUnit(this);
                };
                _switchResult = ObjectExtensions.<XtendAnnotationTypeDeclarationImpl>operator_doubleArrow(_xtendAnnotationTypeDeclarationImpl, _function_1);
            }
        }
        if (!_matched) {
            if (delegate instanceof XtendEnum) {
                _matched = true;
                XtendEnumerationDeclarationImpl _xtendEnumerationDeclarationImpl = new XtendEnumerationDeclarationImpl();
                final Procedure1<XtendEnumerationDeclarationImpl> _function_1 = (XtendEnumerationDeclarationImpl it_1) -> {
                    it_1.setDelegate(((XtendEnum) delegate));
                    it_1.setCompilationUnit(this);
                };
                _switchResult = ObjectExtensions.<XtendEnumerationDeclarationImpl>operator_doubleArrow(_xtendEnumerationDeclarationImpl, _function_1);
            }
        }
        return _switchResult;
    };
    return this.<XtendTypeDeclaration, XtendTypeDeclarationImpl<? extends XtendTypeDeclaration>>getOrCreate(delegate, _function);
}
Also used : XtendTypeDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendTypeDeclarationImpl) XtendClassDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendClassDeclarationImpl) XtendAnnotationType(org.eclipse.xtend.core.xtend.XtendAnnotationType) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendInterface(org.eclipse.xtend.core.xtend.XtendInterface) XtendInterfaceDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendInterfaceDeclarationImpl) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) XtendEnum(org.eclipse.xtend.core.xtend.XtendEnum) XtendAnnotationTypeDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendAnnotationTypeDeclarationImpl) XtendEnumerationDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendEnumerationDeclarationImpl)

Aggregations

XtendAnnotationTypeDeclarationImpl (org.eclipse.xtend.core.macro.declaration.XtendAnnotationTypeDeclarationImpl)2 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)2 AnnotationReferenceBuildContextImpl (org.eclipse.xtend.core.macro.declaration.AnnotationReferenceBuildContextImpl)1 JvmAnnotationTypeDeclarationImpl (org.eclipse.xtend.core.macro.declaration.JvmAnnotationTypeDeclarationImpl)1 XtendClassDeclarationImpl (org.eclipse.xtend.core.macro.declaration.XtendClassDeclarationImpl)1 XtendEnumerationDeclarationImpl (org.eclipse.xtend.core.macro.declaration.XtendEnumerationDeclarationImpl)1 XtendInterfaceDeclarationImpl (org.eclipse.xtend.core.macro.declaration.XtendInterfaceDeclarationImpl)1 XtendTypeDeclarationImpl (org.eclipse.xtend.core.macro.declaration.XtendTypeDeclarationImpl)1 XtendAnnotationType (org.eclipse.xtend.core.xtend.XtendAnnotationType)1 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)1 XtendEnum (org.eclipse.xtend.core.xtend.XtendEnum)1 XtendInterface (org.eclipse.xtend.core.xtend.XtendInterface)1 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)1 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)1 JvmAnnotationReference (org.eclipse.xtext.common.types.JvmAnnotationReference)1 JvmAnnotationType (org.eclipse.xtext.common.types.JvmAnnotationType)1 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)1