Search in sources :

Example 1 with XtendEnumLiteral

use of org.eclipse.xtend.core.xtend.XtendEnumLiteral in project xtext-xtend by eclipse.

the class XAnnotationExtensions method getAnnotatedTarget.

public XtendAnnotationTarget getAnnotatedTarget(final XAnnotation annotation) {
    XtendAnnotationTarget _switchResult = null;
    EObject _eContainer = annotation.eContainer();
    final EObject container = _eContainer;
    boolean _matched = false;
    if (container instanceof XtendAnnotationType) {
        _matched = true;
    }
    if (!_matched) {
        if (container instanceof XtendClass) {
            _matched = true;
        }
    }
    if (!_matched) {
        if (container instanceof XtendInterface) {
            _matched = true;
        }
    }
    if (!_matched) {
        if (container instanceof XtendEnum) {
            _matched = true;
        }
    }
    if (!_matched) {
        if (container instanceof XtendField) {
            _matched = true;
        }
    }
    if (!_matched) {
        if (container instanceof XtendFunction) {
            _matched = true;
        }
    }
    if (!_matched) {
        if (container instanceof XtendConstructor) {
            _matched = true;
        }
    }
    if (!_matched) {
        if (container instanceof XtendEnumLiteral) {
            _matched = true;
        }
    }
    if (!_matched) {
        if (container instanceof XtendParameter) {
            _matched = true;
        }
    }
    if (_matched) {
        _switchResult = ((XtendAnnotationTarget) container);
    }
    if (!_matched) {
        if (container instanceof XtendAnnotationTarget) {
            _matched = true;
            XtendAnnotationTarget _xblockexpression = null;
            {
                final EObject containerContainer = ((XtendAnnotationTarget) container).eContainer();
                XtendAnnotationTarget _xifexpression = null;
                if ((containerContainer instanceof XtendAnnotationTarget)) {
                    _xifexpression = ((XtendAnnotationTarget) containerContainer);
                } else {
                    _xifexpression = ((XtendAnnotationTarget) container);
                }
                _xblockexpression = _xifexpression;
            }
            _switchResult = _xblockexpression;
        }
    }
    if (!_matched) {
        if (container instanceof XAnnotation) {
            _matched = true;
            _switchResult = this.getAnnotatedTarget(((XAnnotation) container));
        }
    }
    if (!_matched) {
        _switchResult = null;
    }
    return _switchResult;
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XtendConstructor(org.eclipse.xtend.core.xtend.XtendConstructor) XtendField(org.eclipse.xtend.core.xtend.XtendField) XtendParameter(org.eclipse.xtend.core.xtend.XtendParameter) XtendAnnotationTarget(org.eclipse.xtend.core.xtend.XtendAnnotationTarget) XtendAnnotationType(org.eclipse.xtend.core.xtend.XtendAnnotationType) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendInterface(org.eclipse.xtend.core.xtend.XtendInterface) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) XAnnotation(org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation) XtendEnum(org.eclipse.xtend.core.xtend.XtendEnum) XtendEnumLiteral(org.eclipse.xtend.core.xtend.XtendEnumLiteral)

Example 2 with XtendEnumLiteral

use of org.eclipse.xtend.core.xtend.XtendEnumLiteral in project xtext-xtend by eclipse.

the class CompilationUnitImpl method toXtendMemberDeclaration.

public MemberDeclaration toXtendMemberDeclaration(final XtendMember delegate) {
    final Function1<XtendMember, XtendMemberDeclarationImpl<? extends XtendMember>> _function = (XtendMember it) -> {
        XtendMemberDeclarationImpl<? extends XtendMember> _switchResult = null;
        boolean _matched = false;
        if (delegate instanceof XtendTypeDeclaration) {
            _matched = true;
            _switchResult = this.toXtendTypeDeclaration(((XtendTypeDeclaration) delegate));
        }
        if (!_matched) {
            if (delegate instanceof XtendFunction) {
                _matched = true;
                XtendMethodDeclarationImpl _xtendMethodDeclarationImpl = new XtendMethodDeclarationImpl();
                final Procedure1<XtendMethodDeclarationImpl> _function_1 = (XtendMethodDeclarationImpl it_1) -> {
                    it_1.setDelegate(((XtendFunction) delegate));
                    it_1.setCompilationUnit(this);
                };
                _switchResult = ObjectExtensions.<XtendMethodDeclarationImpl>operator_doubleArrow(_xtendMethodDeclarationImpl, _function_1);
            }
        }
        if (!_matched) {
            if (delegate instanceof XtendConstructor) {
                _matched = true;
                XtendConstructorDeclarationImpl _xtendConstructorDeclarationImpl = new XtendConstructorDeclarationImpl();
                final Procedure1<XtendConstructorDeclarationImpl> _function_1 = (XtendConstructorDeclarationImpl it_1) -> {
                    it_1.setDelegate(((XtendConstructor) delegate));
                    it_1.setCompilationUnit(this);
                };
                _switchResult = ObjectExtensions.<XtendConstructorDeclarationImpl>operator_doubleArrow(_xtendConstructorDeclarationImpl, _function_1);
            }
        }
        if (!_matched) {
            if (delegate instanceof XtendField) {
                _matched = true;
                XtendMemberDeclarationImpl<XtendField> _xifexpression = null;
                EObject _eContainer = ((XtendField) delegate).eContainer();
                if ((_eContainer instanceof XtendAnnotationType)) {
                    XtendAnnotationTypeElementDeclarationImpl _xtendAnnotationTypeElementDeclarationImpl = new XtendAnnotationTypeElementDeclarationImpl();
                    final Procedure1<XtendAnnotationTypeElementDeclarationImpl> _function_1 = (XtendAnnotationTypeElementDeclarationImpl it_1) -> {
                        it_1.setDelegate(((XtendField) delegate));
                        it_1.setCompilationUnit(this);
                    };
                    _xifexpression = ObjectExtensions.<XtendAnnotationTypeElementDeclarationImpl>operator_doubleArrow(_xtendAnnotationTypeElementDeclarationImpl, _function_1);
                } else {
                    XtendFieldDeclarationImpl _xtendFieldDeclarationImpl = new XtendFieldDeclarationImpl();
                    final Procedure1<XtendFieldDeclarationImpl> _function_2 = (XtendFieldDeclarationImpl it_1) -> {
                        it_1.setDelegate(((XtendField) delegate));
                        it_1.setCompilationUnit(this);
                    };
                    _xifexpression = ObjectExtensions.<XtendFieldDeclarationImpl>operator_doubleArrow(_xtendFieldDeclarationImpl, _function_2);
                }
                _switchResult = _xifexpression;
            }
        }
        if (!_matched) {
            if (delegate instanceof XtendEnumLiteral) {
                _matched = true;
                XtendEnumerationValueDeclarationImpl _xtendEnumerationValueDeclarationImpl = new XtendEnumerationValueDeclarationImpl();
                final Procedure1<XtendEnumerationValueDeclarationImpl> _function_1 = (XtendEnumerationValueDeclarationImpl it_1) -> {
                    it_1.setDelegate(((XtendEnumLiteral) delegate));
                    it_1.setCompilationUnit(this);
                };
                _switchResult = ObjectExtensions.<XtendEnumerationValueDeclarationImpl>operator_doubleArrow(_xtendEnumerationValueDeclarationImpl, _function_1);
            }
        }
        return _switchResult;
    };
    return this.<XtendMember, XtendMemberDeclarationImpl<? extends XtendMember>>getOrCreate(delegate, _function);
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XtendMethodDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendMethodDeclarationImpl) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) XtendConstructor(org.eclipse.xtend.core.xtend.XtendConstructor) XtendEnumerationValueDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendEnumerationValueDeclarationImpl) XtendConstructorDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendConstructorDeclarationImpl) XtendField(org.eclipse.xtend.core.xtend.XtendField) XtendFieldDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendFieldDeclarationImpl) XtendAnnotationType(org.eclipse.xtend.core.xtend.XtendAnnotationType) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) EObject(org.eclipse.emf.ecore.EObject) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) XtendAnnotationTypeElementDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendAnnotationTypeElementDeclarationImpl) XtendEnumLiteral(org.eclipse.xtend.core.xtend.XtendEnumLiteral) XtendMemberDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendMemberDeclarationImpl)

Example 3 with XtendEnumLiteral

use of org.eclipse.xtend.core.xtend.XtendEnumLiteral in project xtext-xtend by eclipse.

the class XtendQualifiedNameProvider method getFullyQualifiedName.

@Override
public QualifiedName getFullyQualifiedName(EObject obj) {
    if (obj instanceof XtendTypeDeclaration) {
        XtendTypeDeclaration typeDecl = (XtendTypeDeclaration) obj;
        String typeName = typeDecl.getName();
        if (typeDecl.eContainer() instanceof XtendFile) {
            if (typeName == null)
                return null;
            XtendFile file = (XtendFile) typeDecl.eContainer();
            String packageName = file.getPackage();
            if (packageName != null) {
                return qualifiedNameConverter.toQualifiedName(packageName).append(typeName);
            }
            return QualifiedName.create(typeName);
        } else {
            return concatNames(obj, typeName);
        }
    }
    if (obj instanceof XtendConstructor) {
        return getFullyQualifiedName(obj.eContainer());
    }
    if (obj instanceof JvmIdentifiableElement && !(obj instanceof JvmTypeParameter)) {
        return getFullyQualifiedName((JvmIdentifiableElement) obj);
    }
    if (obj instanceof XtendField) {
        return concatNames(obj, ((XtendField) obj).getName());
    }
    if (obj instanceof XtendFunction) {
        return concatNames(obj, ((XtendFunction) obj).getName());
    }
    if (obj instanceof XtendEnumLiteral) {
        return concatNames(obj, ((XtendEnumLiteral) obj).getName());
    }
    return null;
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) JvmIdentifiableElement(org.eclipse.xtext.common.types.JvmIdentifiableElement) XtendConstructor(org.eclipse.xtend.core.xtend.XtendConstructor) JvmTypeParameter(org.eclipse.xtext.common.types.JvmTypeParameter) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) XtendEnumLiteral(org.eclipse.xtend.core.xtend.XtendEnumLiteral) XtendField(org.eclipse.xtend.core.xtend.XtendField)

Example 4 with XtendEnumLiteral

use of org.eclipse.xtend.core.xtend.XtendEnumLiteral in project xtext-xtend by eclipse.

the class XtendJvmModelInferrer method initialize.

protected void initialize(XtendEnum source, JvmEnumerationType inferredJvmType) {
    inferredJvmType.setVisibility(source.getVisibility());
    inferredJvmType.setStatic(source.isStatic() && !isTopLevel(source));
    translateAnnotationsTo(source.getAnnotations(), inferredJvmType);
    for (XtendMember member : source.getMembers()) {
        if (member instanceof XtendEnumLiteral)
            transform((XtendEnumLiteral) member, inferredJvmType);
    }
    jvmTypesBuilder.copyDocumentationTo(source, inferredJvmType);
}
Also used : XtendMember(org.eclipse.xtend.core.xtend.XtendMember) XtendEnumLiteral(org.eclipse.xtend.core.xtend.XtendEnumLiteral)

Aggregations

XtendEnumLiteral (org.eclipse.xtend.core.xtend.XtendEnumLiteral)4 XtendConstructor (org.eclipse.xtend.core.xtend.XtendConstructor)3 XtendField (org.eclipse.xtend.core.xtend.XtendField)3 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)3 EObject (org.eclipse.emf.ecore.EObject)2 XtendAnnotationType (org.eclipse.xtend.core.xtend.XtendAnnotationType)2 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)2 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)2 InternalEObject (org.eclipse.emf.ecore.InternalEObject)1 XtendAnnotationTypeElementDeclarationImpl (org.eclipse.xtend.core.macro.declaration.XtendAnnotationTypeElementDeclarationImpl)1 XtendConstructorDeclarationImpl (org.eclipse.xtend.core.macro.declaration.XtendConstructorDeclarationImpl)1 XtendEnumerationValueDeclarationImpl (org.eclipse.xtend.core.macro.declaration.XtendEnumerationValueDeclarationImpl)1 XtendFieldDeclarationImpl (org.eclipse.xtend.core.macro.declaration.XtendFieldDeclarationImpl)1 XtendMemberDeclarationImpl (org.eclipse.xtend.core.macro.declaration.XtendMemberDeclarationImpl)1 XtendMethodDeclarationImpl (org.eclipse.xtend.core.macro.declaration.XtendMethodDeclarationImpl)1 XtendAnnotationTarget (org.eclipse.xtend.core.xtend.XtendAnnotationTarget)1 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)1 XtendEnum (org.eclipse.xtend.core.xtend.XtendEnum)1 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)1 XtendInterface (org.eclipse.xtend.core.xtend.XtendInterface)1