use of org.eclipse.xtext.common.types.JvmUpperBound in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method test_ParameterizedTypes_W_02.
@Test
public void test_ParameterizedTypes_W_02() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmTypeParameter typeParameterW = type.getTypeParameters().get(4);
assertEquals("W", typeParameterW.getIdentifier());
assertSame(type, typeParameterW.getDeclarator());
assertEquals(2, typeParameterW.getConstraints().size());
JvmTypeConstraint secondTypeConstraint = typeParameterW.getConstraints().get(1);
assertTrue(secondTypeConstraint instanceof JvmUpperBound);
JvmUpperBound secondUpperBound = (JvmUpperBound) secondTypeConstraint;
assertNotNull(secondUpperBound.getTypeReference());
assertFalse(secondUpperBound.getTypeReference().toString(), secondUpperBound.getTypeReference().eIsProxy());
assertEquals("java.io.Serializable", secondUpperBound.getTypeReference().getIdentifier());
}
use of org.eclipse.xtext.common.types.JvmUpperBound 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.JvmUpperBound 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());
}
use of org.eclipse.xtext.common.types.JvmUpperBound in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method test_ParameterizedTypes_V_01.
@Test
public void test_ParameterizedTypes_V_01() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmTypeParameter typeParameterV = type.getTypeParameters().get(3);
assertEquals("V", typeParameterV.getIdentifier());
assertSame(type, typeParameterV.getDeclarator());
assertEquals(1, typeParameterV.getConstraints().size());
JvmTypeConstraint typeConstraint = typeParameterV.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<java.util.List<? extends V>>", upperBound.getTypeReference().getIdentifier());
JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) upperBound.getTypeReference();
assertEquals(1, listType.getArguments().size());
JvmTypeReference typeArgument = listType.getArguments().get(0);
assertEquals("java.util.List<? extends V>", typeArgument.getIdentifier());
JvmParameterizedTypeReference nestedListType = (JvmParameterizedTypeReference) typeArgument;
assertEquals(1, nestedListType.getArguments().size());
JvmTypeReference nestedArgument = nestedListType.getArguments().get(0);
assertTrue(nestedArgument instanceof JvmWildcardTypeReference);
assertEquals(1, ((JvmWildcardTypeReference) nestedArgument).getConstraints().size());
JvmUpperBound nestedUpperBound = (JvmUpperBound) ((JvmWildcardTypeReference) nestedArgument).getConstraints().get(0);
assertSame(typeParameterV, nestedUpperBound.getTypeReference().getType());
}
use of org.eclipse.xtext.common.types.JvmUpperBound in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method test_ParameterizedTypes_Inner_06.
@Test
public void test_ParameterizedTypes_Inner_06() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodVArray_02()");
JvmTypeReference listV = methodV.getReturnType();
assertEquals("java.util.List<? extends V[]>", listV.getIdentifier());
JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listV;
assertEquals(1, listType.getArguments().size());
JvmTypeReference typeArgument = listType.getArguments().get(0);
assertTrue(typeArgument instanceof JvmWildcardTypeReference);
JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
assertEquals("? extends V[]", wildcardTypeArgument.getIdentifier());
assertEquals(1, wildcardTypeArgument.getConstraints().size());
JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
JvmType upperBoundType = upperBound.getTypeReference().getType();
assertTrue(upperBoundType instanceof JvmArrayType);
assertTrue(((JvmArrayType) upperBoundType).getComponentType() instanceof JvmTypeParameter);
JvmTypeParameter v = type.getTypeParameters().get(3);
assertSame(v, ((JvmArrayType) upperBoundType).getComponentType());
}
Aggregations