use of org.eclipse.xtext.common.types.JvmUpperBound in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method test_ParameterizedTypes_04.
@Test
public void test_ParameterizedTypes_04() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmOperation methodY = getMethodFromType(type, ParameterizedTypes.class, "methodY(Y)");
assertEquals(1, methodY.getParameters().size());
JvmType parameterType = methodY.getParameters().get(0).getParameterType().getType();
assertFalse(parameterType.eIsProxy());
assertEquals("Y", parameterType.getIdentifier());
assertTrue(parameterType instanceof JvmTypeParameter);
assertSame(methodY, ((JvmTypeParameter) parameterType).getDeclarator());
JvmTypeParameter y = (JvmTypeParameter) parameterType;
assertEquals(1, y.getConstraints().size());
JvmUpperBound upperBound = (JvmUpperBound) y.getConstraints().get(0);
JvmTypeParameter t = type.getTypeParameters().get(1);
assertSame(t, upperBound.getTypeReference().getType());
}
use of org.eclipse.xtext.common.types.JvmUpperBound in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method test_ParameterizedTypes_03.
@Test
public void test_ParameterizedTypes_03() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmOperation methodT = getMethodFromType(type, ParameterizedTypes.class, "methodT(T)");
JvmTypeReference listS = methodT.getReturnType();
assertFalse(listS.toString(), listS.eIsProxy());
assertEquals("java.util.List<? extends java.lang.Object & super T>", listS.getIdentifier());
JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listS;
assertEquals(1, listType.getArguments().size());
JvmTypeReference typeArgument = listType.getArguments().get(0);
assertTrue(typeArgument instanceof JvmWildcardTypeReference);
JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
assertEquals("? extends java.lang.Object & super T", wildcardTypeArgument.getIdentifier());
assertEquals(2, wildcardTypeArgument.getConstraints().size());
JvmUpperBound uperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
assertEquals("java.lang.Object", uperBound.getTypeReference().getIdentifier());
JvmLowerBound lowerBound = (JvmLowerBound) wildcardTypeArgument.getConstraints().get(1);
JvmTypeParameter t = type.getTypeParameters().get(1);
assertSame(t, lowerBound.getTypeReference().getType());
}
use of org.eclipse.xtext.common.types.JvmUpperBound in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method test_twoListWildcardsListResult_03.
@Test
public void test_twoListWildcardsListResult_03() {
JvmOperation twoListWildcardsListResult = getMethodFromParameterizedMethods("twoListWildcardsListResult(java.util.List,java.util.List)");
JvmTypeReference returnType = twoListWildcardsListResult.getReturnType();
JvmParameterizedTypeReference parameterized = (JvmParameterizedTypeReference) returnType;
assertEquals(1, parameterized.getArguments().size());
JvmTypeReference typeParameter = parameterized.getArguments().get(0);
assertTrue(typeParameter instanceof JvmWildcardTypeReference);
JvmWildcardTypeReference wildcard = (JvmWildcardTypeReference) typeParameter;
assertEquals(1, wildcard.getConstraints().size());
assertTrue(wildcard.getConstraints().get(0) instanceof JvmUpperBound);
JvmUpperBound upperBound = (JvmUpperBound) wildcard.getConstraints().get(0);
assertNotNull(upperBound.getTypeReference());
JvmType upperBoundType = upperBound.getTypeReference().getType();
assertFalse(upperBoundType.eIsProxy());
assertEquals("java.lang.Object", upperBoundType.getIdentifier());
}
use of org.eclipse.xtext.common.types.JvmUpperBound in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method test_ParameterizedTypes_Inner_05.
@Test
public void test_ParameterizedTypes_Inner_05() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodVArray_01()");
JvmTypeReference listT = methodV.getReturnType();
assertEquals("java.util.List<? extends V>[]", listT.getIdentifier());
JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) ((JvmGenericArrayTypeReference) listT).getComponentType();
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);
JvmTypeParameter v = type.getTypeParameters().get(3);
assertSame(v, upperBound.getTypeReference().getType());
}
use of org.eclipse.xtext.common.types.JvmUpperBound in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method test_ParameterizedTypes_T_01.
@Test
public void test_ParameterizedTypes_T_01() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmTypeParameter typeVariable = type.getTypeParameters().get(1);
assertEquals("T", 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("S", upperBound.getTypeReference().getIdentifier());
JvmTypeParameter s = type.getTypeParameters().get(0);
assertSame(s, upperBound.getTypeReference().getType());
}
Aggregations