Search in sources :

Example 11 with JvmAnnotationReference

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

the class AbstractConstructorScopeTest method testGetElementByInstance_03.

@Test
public void testGetElementByInstance_03() {
    JvmAnnotationReference annotationReference = TypesFactory.eINSTANCE.createJvmAnnotationReference();
    IEObjectDescription element = getConstructorScope().getSingleElement(annotationReference);
    assertNull(element);
}
Also used : JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Example 12 with JvmAnnotationReference

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

the class AbstractTypeScopeTest method testGetElementByInstance_02.

@Test
public void testGetElementByInstance_02() {
    JvmAnnotationReference annotationReference = TypesFactory.eINSTANCE.createJvmAnnotationReference();
    IEObjectDescription element = getTypeScope().getSingleElement(annotationReference);
    assertNull(element);
}
Also used : JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Example 13 with JvmAnnotationReference

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

the class XbaseHoverDocumentationProvider method addAnnotations.

protected void addAnnotations(EObject object) {
    List<JvmAnnotationReference> annotations = Lists.newArrayList();
    if (object instanceof JvmAnnotationTarget) {
        annotations.addAll(((JvmAnnotationTarget) object).getAnnotations());
    } else {
        Set<EObject> jvmElements = associations.getJvmElements(object);
        if (jvmElements.size() > 0) {
            EObject associatedElement = Lists.newArrayList(jvmElements).get(0);
            if (associatedElement instanceof JvmAnnotationTarget) {
                annotations.addAll(((JvmAnnotationTarget) associatedElement).getAnnotations());
            }
        }
    }
    for (JvmAnnotationReference annotationReference : annotations) {
        if (!typeExtensions.isSynthetic(annotationReference)) {
            buffer.append(annotationValuePrinter.toHtmlString(annotationReference));
            buffer.append("<br>");
        }
    }
}
Also used : JvmAnnotationTarget(org.eclipse.xtext.common.types.JvmAnnotationTarget) EObject(org.eclipse.emf.ecore.EObject) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference)

Example 14 with JvmAnnotationReference

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

the class InferredJvmModelTest method testExtensionToAnnotation_01.

@Test
public void testExtensionToAnnotation_01() throws Exception {
    XtendFile xtendFile = file("class C { extension String }");
    JvmGenericType inferredType = getInferredType(xtendFile);
    JvmField jvmField = (JvmField) inferredType.getMembers().get(1);
    assertEquals("_string", jvmField.getSimpleName());
    List<JvmAnnotationReference> annotations = jvmField.getAnnotations();
    assertEquals(1, annotations.size());
    assertEquals(Extension.class.getCanonicalName(), annotations.get(0).getAnnotation().getQualifiedName());
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) Extension(org.eclipse.xtext.xbase.lib.Extension) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) JvmField(org.eclipse.xtext.common.types.JvmField) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference) Test(org.junit.Test)

Example 15 with JvmAnnotationReference

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

the class InferredJvmModelTest method testExtensionToAnnotation_02.

@Test
public void testExtensionToAnnotation_02() throws Exception {
    XtendFile xtendFile = file("class C { def void m(extension String s) {} }");
    JvmGenericType inferredType = getInferredType(xtendFile);
    JvmOperation jvmOperation = (JvmOperation) inferredType.getMembers().get(1);
    List<JvmFormalParameter> parameters = jvmOperation.getParameters();
    JvmFormalParameter singleParameter = parameters.get(0);
    List<JvmAnnotationReference> annotations = singleParameter.getAnnotations();
    assertEquals(1, annotations.size());
    assertEquals(Extension.class.getCanonicalName(), annotations.get(0).getAnnotation().getQualifiedName());
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) JvmOperation(org.eclipse.xtext.common.types.JvmOperation) Extension(org.eclipse.xtext.xbase.lib.Extension) JvmFormalParameter(org.eclipse.xtext.common.types.JvmFormalParameter) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference) Test(org.junit.Test)

Aggregations

JvmAnnotationReference (org.eclipse.xtext.common.types.JvmAnnotationReference)47 Test (org.junit.Test)23 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)15 JvmAnnotationValue (org.eclipse.xtext.common.types.JvmAnnotationValue)11 JvmAnnotationType (org.eclipse.xtext.common.types.JvmAnnotationType)9 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)7 JvmAnnotationAnnotationValue (org.eclipse.xtext.common.types.JvmAnnotationAnnotationValue)6 JvmAnnotationTarget (org.eclipse.xtext.common.types.JvmAnnotationTarget)6 JvmTypeAnnotationValue (org.eclipse.xtext.common.types.JvmTypeAnnotationValue)6 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)6 EObject (org.eclipse.emf.ecore.EObject)5 AnnotationReference (org.eclipse.xtend.lib.macro.declaration.AnnotationReference)5 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)5 JvmStringAnnotationValue (org.eclipse.xtext.common.types.JvmStringAnnotationValue)5 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)5 TestAnnotation (org.eclipse.xtext.common.types.testSetups.TestAnnotation)4 TestAnnotationWithStringDefault (org.eclipse.xtext.common.types.testSetups.TestAnnotationWithStringDefault)4 Extension (org.eclipse.xtext.xbase.lib.Extension)4 IFile (org.eclipse.core.resources.IFile)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3