Search in sources :

Example 96 with JvmDeclaredType

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

the class AbstractTypeProviderTest method test_arrayWildcard_02.

@Test
public void test_arrayWildcard_02() {
    JvmOperation arrayWildcard = getMethodFromParameterizedMethods("arrayWildcard(java.util.List[])");
    JvmTypeReference paramType = arrayWildcard.getParameters().get(0).getParameterType();
    assertEquals("java.util.List<? extends java.lang.Object>[]", paramType.getIdentifier());
    assertTrue(paramType.getType() instanceof JvmArrayType);
    JvmArrayType arrayType = (JvmArrayType) paramType.getType();
    assertTrue(arrayType.getComponentType() instanceof JvmDeclaredType);
    assertTrue(paramType instanceof JvmGenericArrayTypeReference);
    assertTrue(((JvmGenericArrayTypeReference) paramType).getComponentType() instanceof JvmParameterizedTypeReference);
}
Also used : JvmOperation(org.eclipse.xtext.common.types.JvmOperation) JvmGenericArrayTypeReference(org.eclipse.xtext.common.types.JvmGenericArrayTypeReference) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) JvmParameterizedTypeReference(org.eclipse.xtext.common.types.JvmParameterizedTypeReference) JvmArrayType(org.eclipse.xtext.common.types.JvmArrayType) Test(org.junit.Test)

Example 97 with JvmDeclaredType

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

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

the class AbstractTypeProviderTest method testDeprecatedBit_02.

@Test
public void testDeprecatedBit_02() {
    String typeName = DeprecatedMembers.class.getName();
    JvmDeclaredType type = (JvmDeclaredType) getTypeProvider().findTypeByName(typeName);
    assertTrue(type.isSetDeprecated());
    assertFalse(type.isDeprecated());
    for (JvmMember member : type.getMembers()) {
        assertTrue(member.isSetDeprecated());
        assertTrue(member.isDeprecated());
    }
}
Also used : JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) JvmMember(org.eclipse.xtext.common.types.JvmMember) Test(org.junit.Test)

Example 99 with JvmDeclaredType

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

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

the class JdtTypeMirror method initialize.

/**
 * @since 2.7
 */
@Override
public void initialize(TypeResource typeResource, Map<?, ?> options) {
    try {
        if (typeFactory instanceof ITypeFactory.OptionsAware<?, ?>) {
            JvmDeclaredType jvmType = ((ITypeFactory.OptionsAware<IType, JvmDeclaredType>) typeFactory).createType(mirroredType, typeResource, options);
            typeResource.getContents().add(jvmType);
        } else {
            typeResource.getContents().add(typeFactory.createType(mirroredType));
        }
    } catch (RuntimeException e) {
        if (typeResourceServices != null) {
            typeResourceServices.getOperationCanceledManager().propagateAsErrorIfCancelException(e);
        }
        LOG.error("Error initializing type " + typeResource.getURI(), e);
        throw e;
    }
    this.typeResource = typeResource;
}
Also used : IMirrorOptionsAware(org.eclipse.xtext.common.types.access.IMirrorOptionsAware) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType)

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