use of org.eclipse.xtext.common.types.JvmGenericType in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method test_staticNestedTypes_Outer.
@Test
public void test_staticNestedTypes_Outer() {
String typeName = StaticNestedTypes.Outer.class.getName();
String expectedSuffix = StaticNestedTypes.class.getSimpleName() + "$" + StaticNestedTypes.Outer.class.getSimpleName();
assertTrue(typeName + " endsWith " + expectedSuffix, typeName.endsWith(expectedSuffix));
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
assertNotNull(type);
assertTrue(type.isStatic());
assertEquals(typeName, type.getIdentifier());
JvmType outerType = (JvmType) type.eContainer();
assertEquals(StaticNestedTypes.class.getName(), outerType.getIdentifier());
}
use of org.eclipse.xtext.common.types.JvmGenericType in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method test_ParameterizedTypes_U_01.
@Test
public void test_ParameterizedTypes_U_01() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmTypeParameter typeVariable = type.getTypeParameters().get(2);
assertEquals("U", typeVariable.getIdentifier());
assertSame(type, typeVariable.getDeclarator());
assertEquals(1, typeVariable.getConstraints().size());
JvmTypeConstraint typeConstraint = typeVariable.getConstraints().get(0);
assertTrue(typeConstraint instanceof JvmUpperBound);
JvmUpperBound upperBound = (JvmUpperBound) typeConstraint;
assertNotNull(upperBound.getTypeReference());
assertFalse(upperBound.getTypeReference().toString(), upperBound.getTypeReference().eIsProxy());
assertEquals("java.util.List<S>", upperBound.getTypeReference().getIdentifier());
JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) upperBound.getTypeReference();
assertEquals(1, listType.getArguments().size());
JvmTypeReference typeArgument = listType.getArguments().get(0);
JvmTypeParameter s = type.getTypeParameters().get(0);
assertSame(s, typeArgument.getType());
}
use of org.eclipse.xtext.common.types.JvmGenericType in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method testMemberCount_06_02.
@Test
public void testMemberCount_06_02() {
String typeName = NestedTypes.Outer.Inner.class.getName().replace('$', '.');
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName, true);
assertNull(type);
}
use of org.eclipse.xtext.common.types.JvmGenericType in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method test_staticNestedTypes_Outer_method.
@Test
public void test_staticNestedTypes_Outer_method() {
String typeName = StaticNestedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmOperation operation = getMethodFromType(type, StaticNestedTypes.Outer.class, "method()");
assertEquals("int", operation.getReturnType().getIdentifier());
}
use of org.eclipse.xtext.common.types.JvmGenericType in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method testMemberCount_03.
@Test
public void testMemberCount_03() {
String typeName = InitializerWithoutConstructor.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
int methodCount = InitializerWithoutConstructor.class.getDeclaredMethods().length;
assertEquals(0, methodCount);
int constructorCount = InitializerWithoutConstructor.class.getDeclaredConstructors().length;
// default constructor
assertEquals(1, constructorCount);
assertEquals(methodCount + constructorCount, type.getMembers().size());
diagnose(type);
Resource resource = type.eResource();
getAndResolveAllFragments(resource);
recomputeAndCheckIdentifiers(resource);
}
Aggregations