use of org.eclipse.xtext.common.types.JvmArrayType in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method testFindTypeByName_int_array_03.
@Test
public void testFindTypeByName_int_array_03() {
String typeName = int[][][].class.getName();
JvmType type = getTypeProvider().findTypeByName(typeName);
assertNotNull(type);
assertTrue(type instanceof JvmArrayType);
assertEquals("int[][][]", type.getIdentifier());
diagnose(type);
Resource resource = type.eResource();
getAndResolveAllFragments(resource);
recomputeAndCheckIdentifiers(resource);
}
use of org.eclipse.xtext.common.types.JvmArrayType in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method test_ParameterizedTypes_Inner_08.
@Test
public void test_ParameterizedTypes_Inner_08() {
String typeName = ParameterizedTypes.Inner.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodZArray_02()");
JvmTypeReference listZ = methodV.getReturnType();
assertEquals("java.util.List<Z[]>[]", listZ.getIdentifier());
JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) ((JvmGenericArrayTypeReference) listZ).getComponentType();
assertEquals(1, listType.getArguments().size());
JvmTypeReference typeArgument = listType.getArguments().get(0);
JvmType argumentType = typeArgument.getType();
assertTrue(argumentType instanceof JvmArrayType);
JvmComponentType componentType = ((JvmArrayType) argumentType).getComponentType();
JvmTypeParameter z = type.getTypeParameters().get(2);
assertSame(z, componentType);
}
use of org.eclipse.xtext.common.types.JvmArrayType 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());
}
use of org.eclipse.xtext.common.types.JvmArrayType in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method testFindTypeByName_int_array_01.
@Test
public void testFindTypeByName_int_array_01() {
String typeName = "int[]";
JvmType type = getTypeProvider().findTypeByName(typeName);
assertNotNull(type);
assertTrue(type instanceof JvmArrayType);
assertEquals(typeName, type.getIdentifier());
diagnose(type);
Resource resource = type.eResource();
getAndResolveAllFragments(resource);
recomputeAndCheckIdentifiers(resource);
}
use of org.eclipse.xtext.common.types.JvmArrayType in project xtext-xtend by eclipse.
the class ConstantExpressionsInterpreter method getJavaType.
protected Class<?> getJavaType(final JvmType type, final ClassFinder classFinder) throws ClassNotFoundException {
if ((type instanceof JvmArrayType)) {
JvmType t = type;
String dimensions = "";
while ((t instanceof JvmArrayType)) {
{
dimensions = (dimensions + "[]");
t = ((JvmArrayType) t).getComponentType();
}
}
final Class<?> componentClass = this.getJavaType(t, classFinder);
String _name = componentClass.getName();
String _plus = (_name + dimensions);
return classFinder.forName(_plus);
}
String _identifier = type.getIdentifier();
boolean _equals = Objects.equal(_identifier, "java.lang.Class");
if (_equals) {
return JvmTypeReference.class;
}
if ((type instanceof JvmEnumerationType)) {
return JvmEnumerationLiteral.class;
}
if ((type instanceof JvmAnnotationType)) {
return XAnnotation.class;
}
return classFinder.forName(type.getIdentifier());
}
Aggregations