Search in sources :

Example 1 with JvmAnnotationTarget

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

the class XtendValidator method checkDeprecated.

@Override
public void checkDeprecated(XImportDeclaration decl) {
    XtendFile file = EcoreUtil2.getContainerOfType(decl, XtendFile.class);
    if (file != null) {
        for (XtendTypeDeclaration t : file.getXtendTypes()) {
            for (EObject e : jvmModelAssociations.getJvmElements(t)) {
                if (e instanceof JvmAnnotationTarget) {
                    if (DeprecationUtil.isDeprecated((JvmAnnotationTarget) e)) {
                        return;
                    }
                }
            }
            if (hasAnnotation(t, Deprecated.class)) {
                return;
            }
        }
    }
    super.checkDeprecated(decl);
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) JvmAnnotationTarget(org.eclipse.xtext.common.types.JvmAnnotationTarget) EObject(org.eclipse.emf.ecore.EObject) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration)

Example 2 with JvmAnnotationTarget

use of org.eclipse.xtext.common.types.JvmAnnotationTarget 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 3 with JvmAnnotationTarget

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

the class XtendHoverDocumentationProviderTest method bug380551_TestLinkToNativeJavaType.

@Test
public void bug380551_TestLinkToNativeJavaType() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package testpackage");
        _builder.newLine();
        _builder.append("import javax.annotation.Resource");
        _builder.newLine();
        _builder.append("@Resource");
        _builder.newLine();
        _builder.append("class Foo {");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet());
        final XtendClass clazz = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class));
        JvmGenericType _inferredType = this.jvmModelAssociations.getInferredType(clazz);
        final JvmAnnotationTarget target = ((JvmAnnotationTarget) _inferredType);
        Assert.assertNotNull(this.hoverProvider.getHoverInfo(IterableExtensions.<JvmAnnotationReference>head(target.getAnnotations()).getAnnotation()));
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) JvmAnnotationTarget(org.eclipse.xtext.common.types.JvmAnnotationTarget) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) Test(org.junit.Test)

Aggregations

JvmAnnotationTarget (org.eclipse.xtext.common.types.JvmAnnotationTarget)3 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)2 EObject (org.eclipse.emf.ecore.EObject)1 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)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 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)1 JvmType (org.eclipse.xtext.common.types.JvmType)1 Test (org.junit.Test)1