Search in sources :

Example 6 with JvmAnnotationType

use of org.eclipse.xtext.common.types.JvmAnnotationType in project xtext-xtend by eclipse.

the class CompilationUnitImpl method toMemberDeclaration.

public MemberDeclaration toMemberDeclaration(final JvmMember delegate) {
    final Function1<JvmMember, MemberDeclaration> _function = (JvmMember it) -> {
        MemberDeclaration _switchResult = null;
        boolean _matched = false;
        if (delegate instanceof JvmDeclaredType) {
            _matched = true;
            _switchResult = this.toTypeDeclaration(((JvmDeclaredType) delegate));
        }
        if (!_matched) {
            if (delegate instanceof JvmOperation) {
                _matched = true;
                MemberDeclaration _xifexpression = null;
                JvmDeclaredType _declaringType = ((JvmOperation) delegate).getDeclaringType();
                if ((_declaringType instanceof JvmAnnotationType)) {
                    JvmAnnotationTypeElementDeclarationImpl _xifexpression_1 = null;
                    boolean _isBelongedToCompilationUnit = this.isBelongedToCompilationUnit(delegate);
                    if (_isBelongedToCompilationUnit) {
                        MutableJvmAnnotationTypeElementDeclarationImpl _mutableJvmAnnotationTypeElementDeclarationImpl = new MutableJvmAnnotationTypeElementDeclarationImpl();
                        final Procedure1<MutableJvmAnnotationTypeElementDeclarationImpl> _function_1 = (MutableJvmAnnotationTypeElementDeclarationImpl it_1) -> {
                            it_1.setDelegate(((JvmOperation) delegate));
                            it_1.setCompilationUnit(this);
                        };
                        _xifexpression_1 = ObjectExtensions.<MutableJvmAnnotationTypeElementDeclarationImpl>operator_doubleArrow(_mutableJvmAnnotationTypeElementDeclarationImpl, _function_1);
                    } else {
                        JvmAnnotationTypeElementDeclarationImpl _jvmAnnotationTypeElementDeclarationImpl = new JvmAnnotationTypeElementDeclarationImpl();
                        final Procedure1<JvmAnnotationTypeElementDeclarationImpl> _function_2 = (JvmAnnotationTypeElementDeclarationImpl it_1) -> {
                            it_1.setDelegate(((JvmOperation) delegate));
                            it_1.setCompilationUnit(this);
                        };
                        _xifexpression_1 = ObjectExtensions.<JvmAnnotationTypeElementDeclarationImpl>operator_doubleArrow(_jvmAnnotationTypeElementDeclarationImpl, _function_2);
                    }
                    _xifexpression = _xifexpression_1;
                } else {
                    JvmMethodDeclarationImpl _xifexpression_2 = null;
                    boolean _isBelongedToCompilationUnit_1 = this.isBelongedToCompilationUnit(delegate);
                    if (_isBelongedToCompilationUnit_1) {
                        MutableJvmMethodDeclarationImpl _mutableJvmMethodDeclarationImpl = new MutableJvmMethodDeclarationImpl();
                        final Procedure1<MutableJvmMethodDeclarationImpl> _function_3 = (MutableJvmMethodDeclarationImpl it_1) -> {
                            it_1.setDelegate(((JvmOperation) delegate));
                            it_1.setCompilationUnit(this);
                        };
                        _xifexpression_2 = ObjectExtensions.<MutableJvmMethodDeclarationImpl>operator_doubleArrow(_mutableJvmMethodDeclarationImpl, _function_3);
                    } else {
                        JvmMethodDeclarationImpl _jvmMethodDeclarationImpl = new JvmMethodDeclarationImpl();
                        final Procedure1<JvmMethodDeclarationImpl> _function_4 = (JvmMethodDeclarationImpl it_1) -> {
                            it_1.setDelegate(((JvmOperation) delegate));
                            it_1.setCompilationUnit(this);
                        };
                        _xifexpression_2 = ObjectExtensions.<JvmMethodDeclarationImpl>operator_doubleArrow(_jvmMethodDeclarationImpl, _function_4);
                    }
                    _xifexpression = ((MemberDeclaration) _xifexpression_2);
                }
                _switchResult = _xifexpression;
            }
        }
        if (!_matched) {
            if (delegate instanceof JvmConstructor) {
                _matched = true;
                JvmConstructorDeclarationImpl _xifexpression = null;
                boolean _isBelongedToCompilationUnit = this.isBelongedToCompilationUnit(delegate);
                if (_isBelongedToCompilationUnit) {
                    MutableJvmConstructorDeclarationImpl _mutableJvmConstructorDeclarationImpl = new MutableJvmConstructorDeclarationImpl();
                    final Procedure1<MutableJvmConstructorDeclarationImpl> _function_1 = (MutableJvmConstructorDeclarationImpl it_1) -> {
                        it_1.setDelegate(((JvmConstructor) delegate));
                        it_1.setCompilationUnit(this);
                    };
                    _xifexpression = ObjectExtensions.<MutableJvmConstructorDeclarationImpl>operator_doubleArrow(_mutableJvmConstructorDeclarationImpl, _function_1);
                } else {
                    JvmConstructorDeclarationImpl _jvmConstructorDeclarationImpl = new JvmConstructorDeclarationImpl();
                    final Procedure1<JvmConstructorDeclarationImpl> _function_2 = (JvmConstructorDeclarationImpl it_1) -> {
                        it_1.setDelegate(((JvmConstructor) delegate));
                        it_1.setCompilationUnit(this);
                    };
                    _xifexpression = ObjectExtensions.<JvmConstructorDeclarationImpl>operator_doubleArrow(_jvmConstructorDeclarationImpl, _function_2);
                }
                _switchResult = _xifexpression;
            }
        }
        if (!_matched) {
            if (delegate instanceof JvmEnumerationLiteral) {
                _matched = true;
                JvmEnumerationValueDeclarationImpl _xifexpression = null;
                boolean _isBelongedToCompilationUnit = this.isBelongedToCompilationUnit(delegate);
                if (_isBelongedToCompilationUnit) {
                    MutableJvmEnumerationValueDeclarationImpl _mutableJvmEnumerationValueDeclarationImpl = new MutableJvmEnumerationValueDeclarationImpl();
                    final Procedure1<MutableJvmEnumerationValueDeclarationImpl> _function_1 = (MutableJvmEnumerationValueDeclarationImpl it_1) -> {
                        it_1.setDelegate(((JvmEnumerationLiteral) delegate));
                        it_1.setCompilationUnit(this);
                    };
                    _xifexpression = ObjectExtensions.<MutableJvmEnumerationValueDeclarationImpl>operator_doubleArrow(_mutableJvmEnumerationValueDeclarationImpl, _function_1);
                } else {
                    JvmEnumerationValueDeclarationImpl _jvmEnumerationValueDeclarationImpl = new JvmEnumerationValueDeclarationImpl();
                    final Procedure1<JvmEnumerationValueDeclarationImpl> _function_2 = (JvmEnumerationValueDeclarationImpl it_1) -> {
                        it_1.setDelegate(((JvmEnumerationLiteral) delegate));
                        it_1.setCompilationUnit(this);
                    };
                    _xifexpression = ObjectExtensions.<JvmEnumerationValueDeclarationImpl>operator_doubleArrow(_jvmEnumerationValueDeclarationImpl, _function_2);
                }
                _switchResult = _xifexpression;
            }
        }
        if (!_matched) {
            if (delegate instanceof JvmField) {
                _matched = true;
                JvmFieldDeclarationImpl _xifexpression = null;
                boolean _isBelongedToCompilationUnit = this.isBelongedToCompilationUnit(delegate);
                if (_isBelongedToCompilationUnit) {
                    MutableJvmFieldDeclarationImpl _mutableJvmFieldDeclarationImpl = new MutableJvmFieldDeclarationImpl();
                    final Procedure1<MutableJvmFieldDeclarationImpl> _function_1 = (MutableJvmFieldDeclarationImpl it_1) -> {
                        it_1.setDelegate(((JvmField) delegate));
                        it_1.setCompilationUnit(this);
                    };
                    _xifexpression = ObjectExtensions.<MutableJvmFieldDeclarationImpl>operator_doubleArrow(_mutableJvmFieldDeclarationImpl, _function_1);
                } else {
                    JvmFieldDeclarationImpl _jvmFieldDeclarationImpl = new JvmFieldDeclarationImpl();
                    final Procedure1<JvmFieldDeclarationImpl> _function_2 = (JvmFieldDeclarationImpl it_1) -> {
                        it_1.setDelegate(((JvmField) delegate));
                        it_1.setCompilationUnit(this);
                    };
                    _xifexpression = ObjectExtensions.<JvmFieldDeclarationImpl>operator_doubleArrow(_jvmFieldDeclarationImpl, _function_2);
                }
                _switchResult = _xifexpression;
            }
        }
        return _switchResult;
    };
    return this.<JvmMember, MemberDeclaration>getOrCreate(delegate, _function);
}
Also used : JvmAnnotationType(org.eclipse.xtext.common.types.JvmAnnotationType) MutableJvmConstructorDeclarationImpl(org.eclipse.xtend.core.macro.declaration.MutableJvmConstructorDeclarationImpl) JvmConstructorDeclarationImpl(org.eclipse.xtend.core.macro.declaration.JvmConstructorDeclarationImpl) MemberDeclaration(org.eclipse.xtend.lib.macro.declaration.MemberDeclaration) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) MutableJvmMethodDeclarationImpl(org.eclipse.xtend.core.macro.declaration.MutableJvmMethodDeclarationImpl) MutableJvmMethodDeclarationImpl(org.eclipse.xtend.core.macro.declaration.MutableJvmMethodDeclarationImpl) JvmMethodDeclarationImpl(org.eclipse.xtend.core.macro.declaration.JvmMethodDeclarationImpl) JvmOperation(org.eclipse.xtext.common.types.JvmOperation) MutableJvmFieldDeclarationImpl(org.eclipse.xtend.core.macro.declaration.MutableJvmFieldDeclarationImpl) JvmFieldDeclarationImpl(org.eclipse.xtend.core.macro.declaration.JvmFieldDeclarationImpl) JvmAnnotationTypeElementDeclarationImpl(org.eclipse.xtend.core.macro.declaration.JvmAnnotationTypeElementDeclarationImpl) MutableJvmAnnotationTypeElementDeclarationImpl(org.eclipse.xtend.core.macro.declaration.MutableJvmAnnotationTypeElementDeclarationImpl) MutableJvmAnnotationTypeElementDeclarationImpl(org.eclipse.xtend.core.macro.declaration.MutableJvmAnnotationTypeElementDeclarationImpl) MutableJvmEnumerationValueDeclarationImpl(org.eclipse.xtend.core.macro.declaration.MutableJvmEnumerationValueDeclarationImpl) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) JvmEnumerationValueDeclarationImpl(org.eclipse.xtend.core.macro.declaration.JvmEnumerationValueDeclarationImpl) MutableJvmEnumerationValueDeclarationImpl(org.eclipse.xtend.core.macro.declaration.MutableJvmEnumerationValueDeclarationImpl) JvmConstructor(org.eclipse.xtext.common.types.JvmConstructor) JvmEnumerationLiteral(org.eclipse.xtext.common.types.JvmEnumerationLiteral) MutableJvmFieldDeclarationImpl(org.eclipse.xtend.core.macro.declaration.MutableJvmFieldDeclarationImpl) JvmMember(org.eclipse.xtext.common.types.JvmMember) JvmField(org.eclipse.xtext.common.types.JvmField) MutableJvmConstructorDeclarationImpl(org.eclipse.xtend.core.macro.declaration.MutableJvmConstructorDeclarationImpl)

Example 7 with JvmAnnotationType

use of org.eclipse.xtext.common.types.JvmAnnotationType in project xtext-xtend by eclipse.

the class XtendAnnotationReferenceImpl method getAnnotationTypeDeclaration.

@Override
public AnnotationTypeDeclaration getAnnotationTypeDeclaration() {
    AnnotationTypeDeclaration _switchResult = null;
    JvmType _annotationType = this.getAnnotationType();
    final JvmType type = _annotationType;
    boolean _matched = false;
    if (type instanceof JvmAnnotationType) {
        _matched = true;
        TypeDeclaration _typeDeclaration = this.getCompilationUnit().toTypeDeclaration(((JvmDeclaredType) type));
        _switchResult = ((AnnotationTypeDeclaration) _typeDeclaration);
    }
    if (!_matched) {
        _switchResult = null;
    }
    return _switchResult;
}
Also used : JvmAnnotationType(org.eclipse.xtext.common.types.JvmAnnotationType) AnnotationTypeDeclaration(org.eclipse.xtend.lib.macro.declaration.AnnotationTypeDeclaration) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) JvmType(org.eclipse.xtext.common.types.JvmType) AnnotationTypeDeclaration(org.eclipse.xtend.lib.macro.declaration.AnnotationTypeDeclaration) TypeDeclaration(org.eclipse.xtend.lib.macro.declaration.TypeDeclaration)

Example 8 with JvmAnnotationType

use of org.eclipse.xtext.common.types.JvmAnnotationType in project xtext-xtend by eclipse.

the class AnnotationValidation method isValidAnnotationValueType.

public boolean isValidAnnotationValueType(final JvmTypeReference reference) {
    JvmTypeReference _switchResult = null;
    boolean _matched = false;
    if (reference instanceof JvmGenericArrayTypeReference) {
        _matched = true;
        _switchResult = ((JvmGenericArrayTypeReference) reference).getComponentType();
    }
    if (!_matched) {
        _switchResult = reference;
    }
    final JvmTypeReference toCheck = _switchResult;
    if ((toCheck == null)) {
        return true;
    }
    JvmType _type = toCheck.getType();
    if ((_type instanceof JvmPrimitiveType)) {
        return true;
    }
    JvmType _type_1 = toCheck.getType();
    if ((_type_1 instanceof JvmEnumerationType)) {
        return true;
    }
    JvmType _type_2 = toCheck.getType();
    if ((_type_2 instanceof JvmAnnotationType)) {
        return true;
    }
    if ((Objects.equal(toCheck.getType().getQualifiedName(), "java.lang.String") || Objects.equal(toCheck.getType().getQualifiedName(), "java.lang.Class"))) {
        return true;
    }
    return false;
}
Also used : JvmAnnotationType(org.eclipse.xtext.common.types.JvmAnnotationType) JvmGenericArrayTypeReference(org.eclipse.xtext.common.types.JvmGenericArrayTypeReference) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) JvmPrimitiveType(org.eclipse.xtext.common.types.JvmPrimitiveType) JvmType(org.eclipse.xtext.common.types.JvmType) JvmEnumerationType(org.eclipse.xtext.common.types.JvmEnumerationType)

Example 9 with JvmAnnotationType

use of org.eclipse.xtext.common.types.JvmAnnotationType in project xtext-xtend by eclipse.

the class XtendHighlightingCalculator method highlightAnnotation.

@Override
protected void highlightAnnotation(XAnnotation annotation, IHighlightedPositionAcceptor acceptor) {
    JvmType annotationType = annotation.getAnnotationType();
    if (annotationType instanceof JvmAnnotationTarget) {
        for (JvmAnnotationReference annotationReference : ((JvmAnnotationTarget) annotationType).getAnnotations()) {
            JvmAnnotationType otherAnnotation = annotationReference.getAnnotation();
            if (otherAnnotation != null && !otherAnnotation.eIsProxy() && Active.class.getName().equals(otherAnnotation.getIdentifier())) {
                highlightAnnotation(annotation, acceptor, ACTIVE_ANNOTATION);
                return;
            }
        }
    }
    super.highlightAnnotation(annotation, acceptor);
}
Also used : JvmAnnotationType(org.eclipse.xtext.common.types.JvmAnnotationType) JvmAnnotationTarget(org.eclipse.xtext.common.types.JvmAnnotationTarget) JvmType(org.eclipse.xtext.common.types.JvmType) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference)

Example 10 with JvmAnnotationType

use of org.eclipse.xtext.common.types.JvmAnnotationType in project xtext-xtend by eclipse.

the class XtendHighlightingCalculator method highlightDeprecatedXtendAnnotationTarget.

protected void highlightDeprecatedXtendAnnotationTarget(IHighlightedPositionAcceptor acceptor, XtendAnnotationTarget target, XAnnotation annotation) {
    JvmType annotationType = annotation.getAnnotationType();
    if (annotationType instanceof JvmAnnotationType && DeprecationUtil.isDeprecatedAnnotation((JvmAnnotationType) annotationType)) {
        if (target instanceof XtendConstructor) {
            ICompositeNode compositeNode = NodeModelUtils.getNode(target);
            for (ILeafNode leaf : compositeNode.getLeafNodes()) {
                if (leaf.getGrammarElement() == xtendGrammarAccess.getMemberAccess().getNewKeyword_2_2_2()) {
                    highlightNode(acceptor, leaf, XbaseHighlightingStyles.DEPRECATED_MEMBERS);
                    highlightNode(acceptor, leaf, HighlightingStyles.KEYWORD_ID);
                    return;
                }
            }
        } else {
            EStructuralFeature nameFeature = target.eClass().getEStructuralFeature("name");
            if (nameFeature != null) {
                highlightFeature(acceptor, target, nameFeature, XbaseHighlightingStyles.DEPRECATED_MEMBERS);
            }
        }
    }
}
Also used : JvmAnnotationType(org.eclipse.xtext.common.types.JvmAnnotationType) ILeafNode(org.eclipse.xtext.nodemodel.ILeafNode) XtendConstructor(org.eclipse.xtend.core.xtend.XtendConstructor) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) JvmType(org.eclipse.xtext.common.types.JvmType)

Aggregations

JvmAnnotationType (org.eclipse.xtext.common.types.JvmAnnotationType)26 JvmType (org.eclipse.xtext.common.types.JvmType)9 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)8 JvmEnumerationType (org.eclipse.xtext.common.types.JvmEnumerationType)6 EObject (org.eclipse.emf.ecore.EObject)5 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)5 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)5 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)5 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)5 JvmAnnotationReference (org.eclipse.xtext.common.types.JvmAnnotationReference)4 JvmMember (org.eclipse.xtext.common.types.JvmMember)4 Test (org.junit.Test)4 InternalEObject (org.eclipse.emf.ecore.InternalEObject)3 JvmAnnotationTypeDeclarationImpl (org.eclipse.xtend.core.macro.declaration.JvmAnnotationTypeDeclarationImpl)3 XAnnotation (org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation)3 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)3 URI (org.eclipse.emf.common.util.URI)2 XtendAnnotationType (org.eclipse.xtend.core.xtend.XtendAnnotationType)2 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)2 XtendConstructor (org.eclipse.xtend.core.xtend.XtendConstructor)2