Search in sources :

Example 51 with JvmGenericType

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

the class AbstractTypeProviderTest method testFindTypeByName_$StartsWithDollar_02.

@Test
public void testFindTypeByName_$StartsWithDollar_02() {
    // Class<org.eclipse.xtext.common.types.testSetups.$StartsWithDollar> clazz = org.eclipse.xtext.common.types.testSetups.$StartsWithDollar.class;
    String typeName = "org.eclipse.xtext.common.types.testSetups.$StartsWithDollar";
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName, false);
    doTestFindTypeByName_$StartsWithDollar(type);
}
Also used : JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) Test(org.junit.Test)

Example 52 with JvmGenericType

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

the class AbstractTypeProviderTest method testFindTypeByName_javaUtilList_03.

@Test
public void testFindTypeByName_javaUtilList_03() {
    String typeName = List.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmOperation toArray = (JvmOperation) type.eResource().getEObject("java.util.List.toArray(T[])");
    assertNotNull(toArray);
    assertEquals("T[]", toArray.getReturnType().getIdentifier());
}
Also used : JvmOperation(org.eclipse.xtext.common.types.JvmOperation) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) Test(org.junit.Test)

Example 53 with JvmGenericType

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

the class AbstractTypeProviderTest method testMemberCount_06.

@Test
public void testMemberCount_06() {
    String typeName = NestedTypes.Outer.Inner.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    doTestMemberCount_06(type);
}
Also used : JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) Test(org.junit.Test)

Example 54 with JvmGenericType

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

the class AbstractTypeProviderTest method testMemberCount_12.

@Test
public void testMemberCount_12() {
    String typeName = Fields.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    int constructorCount = Fields.class.getDeclaredConstructors().length;
    // default constructor
    assertEquals(1, constructorCount);
    int fieldCount = Fields.class.getDeclaredFields().length;
    assertEquals(7, fieldCount);
    int nestedCount = Fields.class.getDeclaredClasses().length;
    assertEquals(1, nestedCount);
    assertEquals(nestedCount + constructorCount + fieldCount, type.getMembers().size());
    diagnose(type);
    Resource resource = type.eResource();
    getAndResolveAllFragments(resource);
    recomputeAndCheckIdentifiers(resource);
}
Also used : Fields(org.eclipse.xtext.common.types.testSetups.Fields) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) Resource(org.eclipse.emf.ecore.resource.Resource) JvmTypeConstraint(org.eclipse.xtext.common.types.JvmTypeConstraint) Test(org.junit.Test)

Example 55 with JvmGenericType

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

the class AbstractTypeProviderTest method test_ParameterizedTypes_Inner_Z_01.

@Test
public void test_ParameterizedTypes_Inner_Z_01() {
    String typeName = ParameterizedTypes.Inner.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmTypeParameter typeParameterZ = type.getTypeParameters().get(2);
    assertEquals("Z", typeParameterZ.getIdentifier());
    assertSame(type, typeParameterZ.getDeclarator());
    assertEquals(1, typeParameterZ.getConstraints().size());
    JvmTypeConstraint typeConstraint = typeParameterZ.getConstraints().get(0);
    assertTrue(typeConstraint instanceof JvmUpperBound);
    JvmUpperBound upperBound = (JvmUpperBound) typeConstraint;
    assertNotNull(upperBound.getTypeReference());
    assertEquals("java.util.List<W>", upperBound.getTypeReference().getIdentifier());
    JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) upperBound.getTypeReference();
    assertEquals(1, listType.getArguments().size());
    JvmTypeReference typeArgument = listType.getArguments().get(0);
    assertEquals("W", typeArgument.getIdentifier());
    JvmTypeParameter w = ((JvmTypeParameterDeclarator) type.getDeclaringType()).getTypeParameters().get(4);
    assertSame(w, typeArgument.getType());
}
Also used : JvmUpperBound(org.eclipse.xtext.common.types.JvmUpperBound) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) JvmTypeParameter(org.eclipse.xtext.common.types.JvmTypeParameter) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) JvmTypeConstraint(org.eclipse.xtext.common.types.JvmTypeConstraint) JvmParameterizedTypeReference(org.eclipse.xtext.common.types.JvmParameterizedTypeReference) ParameterizedTypes(org.eclipse.xtext.common.types.testSetups.ParameterizedTypes) Test(org.junit.Test)

Aggregations

JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)297 Test (org.junit.Test)237 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)117 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)64 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)56 JvmType (org.eclipse.xtext.common.types.JvmType)49 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)47 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)33 JvmConstructor (org.eclipse.xtext.common.types.JvmConstructor)33 JvmTypeParameter (org.eclipse.xtext.common.types.JvmTypeParameter)33 JvmField (org.eclipse.xtext.common.types.JvmField)31 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)30 EObject (org.eclipse.emf.ecore.EObject)28 Resource (org.eclipse.emf.ecore.resource.Resource)28 JvmMember (org.eclipse.xtext.common.types.JvmMember)25 JvmParameterizedTypeReference (org.eclipse.xtext.common.types.JvmParameterizedTypeReference)24 JvmTypeConstraint (org.eclipse.xtext.common.types.JvmTypeConstraint)21 JvmUpperBound (org.eclipse.xtext.common.types.JvmUpperBound)17 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)15 JvmFormalParameter (org.eclipse.xtext.common.types.JvmFormalParameter)15