Search in sources :

Example 31 with JvmAnnotationReference

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

the class AbstractTypeProviderTest method testDefaultAnnotationAnnotationValue_01.

@Test
public void testDefaultAnnotationAnnotationValue_01() throws Exception {
    JvmAnnotationAnnotationValue value = (JvmAnnotationAnnotationValue) getDefaultAnnotationValue("annotationValue");
    assertEquals(1, value.getValues().size());
    JvmAnnotationReference reference = value.getValues().get(0);
    assertEquals(TestAnnotationWithDefaults.NestedAnnotation.class.getName(), reference.getAnnotation().getIdentifier());
    JvmAnnotationValue nestedAnnotationValue = reference.getValues().get(0);
    assertTrue(nestedAnnotationValue instanceof JvmStringAnnotationValue);
    assertEquals("AnotherString", ((JvmStringAnnotationValue) nestedAnnotationValue).getValues().get(0));
}
Also used : JvmAnnotationAnnotationValue(org.eclipse.xtext.common.types.JvmAnnotationAnnotationValue) JvmStringAnnotationValue(org.eclipse.xtext.common.types.JvmStringAnnotationValue) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference) JvmAnnotationValue(org.eclipse.xtext.common.types.JvmAnnotationValue) Test(org.junit.Test)

Example 32 with JvmAnnotationReference

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

the class AbstractTypeProviderTest method testAnnotationWithStringDefault_04.

@Test
public void testAnnotationWithStringDefault_04() throws Exception {
    String typeName = AnnotatedClassWithStringDefault.class.getName();
    JvmDeclaredType type = (JvmDeclaredType) getTypeProvider().findTypeByName(typeName);
    List<JvmAnnotationReference> annotations = type.getAnnotations();
    assertEquals(1, annotations.size());
    JvmAnnotationReference annotationReference = annotations.get(0);
    assertEquals(TestAnnotationWithStringDefault.class.getName(), annotationReference.getAnnotation().getIdentifier());
    checkDefaultAnnotationValuesAnnotatedExternalClass(annotationReference);
}
Also used : TestAnnotationWithStringDefault(org.eclipse.xtext.common.types.testSetups.TestAnnotationWithStringDefault) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference) Test(org.junit.Test)

Example 33 with JvmAnnotationReference

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

the class AbstractTypeProviderTest method testAnnotatedParameter_01.

@Test
public void testAnnotatedParameter_01() throws Exception {
    String typeName = TestAnnotation.Annotated.class.getName();
    JvmAnnotationType annotationType = (JvmAnnotationType) getTypeProvider().findTypeByName(TestAnnotation.class.getName());
    JvmDeclaredType type = (JvmDeclaredType) getTypeProvider().findTypeByName(typeName);
    JvmConstructor constructor = getConstructorFromType(type, TestAnnotation.Annotated.class, "Annotated(java.lang.String,java.lang.String,java.lang.String)");
    JvmAnnotationTarget target = constructor.getParameters().get(0);
    assertEquals(2, target.getAnnotations().size());
    JvmAnnotationReference annotationReference = target.getAnnotations().get(0);
    assertSame(annotationType, annotationReference.getAnnotation());
    annotationType = (JvmAnnotationType) getTypeProvider().findTypeByName(TestAnnotation.NestedAnnotation.class.getName());
    annotationReference = target.getAnnotations().get(1);
    assertSame(annotationType, annotationReference.getAnnotation());
}
Also used : JvmAnnotationType(org.eclipse.xtext.common.types.JvmAnnotationType) JvmAnnotationTarget(org.eclipse.xtext.common.types.JvmAnnotationTarget) TestAnnotation(org.eclipse.xtext.common.types.testSetups.TestAnnotation) JvmConstructor(org.eclipse.xtext.common.types.JvmConstructor) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference) Test(org.junit.Test)

Example 34 with JvmAnnotationReference

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

the class AbstractTypeProviderTest method testBug428340.

@Test
public void testBug428340() {
    String typeName = Bug428340.class.getName();
    JvmDeclaredType type = (JvmDeclaredType) getTypeProvider().findTypeByName(typeName);
    JvmAnnotationReference myAnnotation = type.getAnnotations().get(0);
    assertEquals("MyAnnotation", myAnnotation.getAnnotation().getSimpleName());
}
Also used : JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference) Test(org.junit.Test)

Example 35 with JvmAnnotationReference

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

the class AbstractTypeProviderTest method testAnnotationAnnotationValue_01.

@Test
public void testAnnotationAnnotationValue_01() throws Exception {
    JvmAnnotationAnnotationValue value = (JvmAnnotationAnnotationValue) getAnnotationValue("annotationValue");
    assertEquals(1, value.getValues().size());
    JvmAnnotationReference annotationReference = value.getValues().get(0);
    assertEquals(TestAnnotation.NestedAnnotation.class.getName(), annotationReference.getAnnotation().getIdentifier());
    assertEquals(1, annotationReference.getValues().size());
    JvmStringAnnotationValue nestedValue = (JvmStringAnnotationValue) annotationReference.getValues().get(0);
    assertEquals(1, nestedValue.getValues().size());
    assertEquals("MyString", nestedValue.getValues().get(0));
}
Also used : JvmAnnotationAnnotationValue(org.eclipse.xtext.common.types.JvmAnnotationAnnotationValue) JvmStringAnnotationValue(org.eclipse.xtext.common.types.JvmStringAnnotationValue) 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