Search in sources :

Example 16 with JvmArrayType

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

the class AbstractTypeProviderTest method test_arrayWildcard_02.

@Test
public void test_arrayWildcard_02() {
    JvmOperation arrayWildcard = getMethodFromParameterizedMethods("arrayWildcard(java.util.List[])");
    JvmTypeReference paramType = arrayWildcard.getParameters().get(0).getParameterType();
    assertEquals("java.util.List<? extends java.lang.Object>[]", paramType.getIdentifier());
    assertTrue(paramType.getType() instanceof JvmArrayType);
    JvmArrayType arrayType = (JvmArrayType) paramType.getType();
    assertTrue(arrayType.getComponentType() instanceof JvmDeclaredType);
    assertTrue(paramType instanceof JvmGenericArrayTypeReference);
    assertTrue(((JvmGenericArrayTypeReference) paramType).getComponentType() instanceof JvmParameterizedTypeReference);
}
Also used : JvmOperation(org.eclipse.xtext.common.types.JvmOperation) JvmGenericArrayTypeReference(org.eclipse.xtext.common.types.JvmGenericArrayTypeReference) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) JvmParameterizedTypeReference(org.eclipse.xtext.common.types.JvmParameterizedTypeReference) JvmArrayType(org.eclipse.xtext.common.types.JvmArrayType) Test(org.junit.Test)

Example 17 with JvmArrayType

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

the class AbstractTypeProviderTest method test_nestedArrayVariable_02.

@Test
public void test_nestedArrayVariable_02() {
    JvmOperation nestedArrayVariable = getMethodFromParameterizedMethods("nestedArrayVariable(T[][])");
    JvmType paramType = nestedArrayVariable.getParameters().get(0).getParameterType().getType();
    assertTrue(paramType instanceof JvmArrayType);
    JvmArrayType arrayType = (JvmArrayType) paramType;
    assertTrue(arrayType.getComponentType() instanceof JvmArrayType);
    arrayType = (JvmArrayType) arrayType.getComponentType();
    assertTrue(arrayType.getComponentType() instanceof JvmTypeParameter);
}
Also used : JvmOperation(org.eclipse.xtext.common.types.JvmOperation) JvmTypeParameter(org.eclipse.xtext.common.types.JvmTypeParameter) JvmType(org.eclipse.xtext.common.types.JvmType) JvmArrayType(org.eclipse.xtext.common.types.JvmArrayType) Test(org.junit.Test)

Example 18 with JvmArrayType

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

the class AbstractTypeProviderTest method test_arrayVariable_02.

@Test
public void test_arrayVariable_02() {
    JvmOperation arrayVariable = getMethodFromParameterizedMethods("arrayVariable(T[])");
    JvmType paramType = arrayVariable.getParameters().get(0).getParameterType().getType();
    assertEquals("T[]", paramType.getIdentifier());
    assertTrue(paramType instanceof JvmArrayType);
    JvmArrayType arrayType = (JvmArrayType) paramType;
    assertTrue(arrayType.getComponentType() instanceof JvmTypeParameter);
}
Also used : JvmOperation(org.eclipse.xtext.common.types.JvmOperation) JvmTypeParameter(org.eclipse.xtext.common.types.JvmTypeParameter) JvmType(org.eclipse.xtext.common.types.JvmType) JvmArrayType(org.eclipse.xtext.common.types.JvmArrayType) Test(org.junit.Test)

Aggregations

JvmArrayType (org.eclipse.xtext.common.types.JvmArrayType)18 Test (org.junit.Test)16 JvmType (org.eclipse.xtext.common.types.JvmType)13 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)10 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)10 JvmParameterizedTypeReference (org.eclipse.xtext.common.types.JvmParameterizedTypeReference)8 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)6 Resource (org.eclipse.emf.ecore.resource.Resource)5 JvmGenericArrayTypeReference (org.eclipse.xtext.common.types.JvmGenericArrayTypeReference)5 JvmTypeParameter (org.eclipse.xtext.common.types.JvmTypeParameter)5 JvmComponentType (org.eclipse.xtext.common.types.JvmComponentType)3 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)3 ParameterizedTypes (org.eclipse.xtext.common.types.testSetups.ParameterizedTypes)3 IFile (org.eclipse.core.resources.IFile)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 JvmEnumerationLiteral (org.eclipse.xtext.common.types.JvmEnumerationLiteral)2 JvmEnumerationType (org.eclipse.xtext.common.types.JvmEnumerationType)2 JvmWildcardTypeReference (org.eclipse.xtext.common.types.JvmWildcardTypeReference)2 IJvmTypeProvider (org.eclipse.xtext.common.types.access.IJvmTypeProvider)2 HashMap (java.util.HashMap)1