Search in sources :

Example 91 with JvmDeclaredType

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

the class AbstractTypeProviderTest method testFindTypeByName_javaLangNumber_02.

@Test
public void testFindTypeByName_javaLangNumber_02() {
    String typeName = Number[][].class.getName();
    JvmArrayType type = (JvmArrayType) getTypeProvider().findTypeByName(typeName);
    JvmOperation longValue = (JvmOperation) type.eResource().getEObject("java.lang.Number.longValue()");
    assertNotNull(longValue);
    JvmDeclaredType number = longValue.getDeclaringType();
    assertNotNull(number.getArrayType());
    assertSame(type, number.getArrayType().getArrayType());
    assertNull(type.eGet(TypesPackage.Literals.JVM_COMPONENT_TYPE__ARRAY_TYPE));
    // array will created on the fly
    assertNotNull(type.getArrayType());
    diagnose(type);
    Resource resource = type.eResource();
    getAndResolveAllFragments(resource);
    recomputeAndCheckIdentifiers(resource);
}
Also used : JvmOperation(org.eclipse.xtext.common.types.JvmOperation) Resource(org.eclipse.emf.ecore.resource.Resource) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) JvmArrayType(org.eclipse.xtext.common.types.JvmArrayType) Test(org.junit.Test)

Example 92 with JvmDeclaredType

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

the class AbstractTypeProviderTest method testDefaultAnnotationAnnotationValueByReference.

@Test
public void testDefaultAnnotationAnnotationValueByReference() throws Exception {
    String typeName = Bug334943Client.class.getName();
    JvmDeclaredType client = (JvmDeclaredType) getTypeProvider().findTypeByName(typeName);
    JvmOperation operation = Iterables.get(client.getDeclaredOperations(), 0);
    List<JvmAnnotationReference> annotations = operation.getAnnotations();
    assertEquals(1, annotations.size());
    JvmAnnotationReference annotation = annotations.get(0);
    for (JvmAnnotationValue value : annotation.getValues()) {
        if ("enumValue".equals(value.getValueName())) {
            JvmEnumAnnotationValue enumValue = (JvmEnumAnnotationValue) value;
            assertEquals(1, enumValue.getValues().size());
            assertEquals("FirstValue", enumValue.getValues().get(0).getSimpleName());
        }
    }
}
Also used : JvmOperation(org.eclipse.xtext.common.types.JvmOperation) JvmEnumAnnotationValue(org.eclipse.xtext.common.types.JvmEnumAnnotationValue) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference) JvmAnnotationValue(org.eclipse.xtext.common.types.JvmAnnotationValue) Test(org.junit.Test)

Example 93 with JvmDeclaredType

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

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

the class AbstractTypeProviderTest method testAnnotatedParameter_05.

@Test
public void testAnnotatedParameter_05() throws Exception {
    String typeName = TestAnnotation.Annotated.class.getName();
    JvmDeclaredType type = (JvmDeclaredType) getTypeProvider().findTypeByName(typeName);
    JvmOperation method = getMethodFromType(type, TestAnnotation.Annotated.class, "method(java.lang.String,java.lang.String,java.lang.String)");
    JvmAnnotationTarget target = method.getParameters().get(1);
    assertEquals(0, target.getAnnotations().size());
}
Also used : JvmOperation(org.eclipse.xtext.common.types.JvmOperation) JvmAnnotationTarget(org.eclipse.xtext.common.types.JvmAnnotationTarget) TestAnnotation(org.eclipse.xtext.common.types.testSetups.TestAnnotation) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) Test(org.junit.Test)

Example 95 with JvmDeclaredType

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

the class AbstractTypeProviderTest method testBug456328_01.

@Test
public void testBug456328_01() {
    String typeName = Bug456328.class.getName();
    JvmDeclaredType type = (JvmDeclaredType) getTypeProvider().findTypeByName(typeName);
    assertNotNull(type);
}
Also used : JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) Test(org.junit.Test)

Aggregations

JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)138 Test (org.junit.Test)41 EObject (org.eclipse.emf.ecore.EObject)26 JvmType (org.eclipse.xtext.common.types.JvmType)24 JvmMember (org.eclipse.xtext.common.types.JvmMember)21 JvmConstructor (org.eclipse.xtext.common.types.JvmConstructor)18 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)18 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)16 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)16 JvmAnnotationReference (org.eclipse.xtext.common.types.JvmAnnotationReference)15 JvmAnnotationType (org.eclipse.xtext.common.types.JvmAnnotationType)13 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)11 JvmAnnotationTarget (org.eclipse.xtext.common.types.JvmAnnotationTarget)10 TestAnnotation (org.eclipse.xtext.common.types.testSetups.TestAnnotation)10 Resource (org.eclipse.emf.ecore.resource.Resource)8 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)8 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)7 JvmArrayType (org.eclipse.xtext.common.types.JvmArrayType)7 JvmParameterizedTypeReference (org.eclipse.xtext.common.types.JvmParameterizedTypeReference)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)6