Search in sources :

Example 56 with JvmGenericType

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

the class AbstractTypeProviderTest method testMemberCount_06_01.

@Test
public void testMemberCount_06_01() {
    String typeName = NestedTypes.Outer.Inner.class.getName().replace('$', '.');
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName, false);
    doTestMemberCount_06(type);
}
Also used : StaticNestedTypes(org.eclipse.xtext.common.types.testSetups.StaticNestedTypes) NestedTypes(org.eclipse.xtext.common.types.testSetups.NestedTypes) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) Test(org.junit.Test)

Example 57 with JvmGenericType

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

the class AbstractTypeProviderTest method test_ParameterizedTypes_inner_return_01.

@Test
public void test_ParameterizedTypes_inner_return_01() {
    String typeName = ParameterizedTypes.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmOperation operation = getMethodFromType(type, ParameterizedTypes.class, "plainInner(org.eclipse.xtext.common.types.testSetups.ParameterizedTypes$Inner)");
    JvmTypeReference returnType = operation.getReturnType();
    assertTrue(returnType.getIdentifier(), returnType instanceof JvmInnerTypeReference);
    assertEquals("ParameterizedTypes<S, T, U, V, W>$Inner<W, List<W>, List<W>>", returnType.getSimpleName());
}
Also used : JvmOperation(org.eclipse.xtext.common.types.JvmOperation) JvmInnerTypeReference(org.eclipse.xtext.common.types.JvmInnerTypeReference) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) Test(org.junit.Test)

Example 58 with JvmGenericType

use of org.eclipse.xtext.common.types.JvmGenericType 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());
}
Also used : JvmUpperBound(org.eclipse.xtext.common.types.JvmUpperBound) JvmWildcardTypeReference(org.eclipse.xtext.common.types.JvmWildcardTypeReference) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) JvmTypeParameter(org.eclipse.xtext.common.types.JvmTypeParameter) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) JvmTypeConstraint(org.eclipse.xtext.common.types.JvmTypeConstraint) JvmParameterizedTypeReference(org.eclipse.xtext.common.types.JvmParameterizedTypeReference) Test(org.junit.Test)

Example 59 with JvmGenericType

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

the class AbstractTypeProviderTest method testMemberCount_05_02.

@Test
public void testMemberCount_05_02() {
    String typeName = NestedTypes.Outer.class.getName().replace('$', '.');
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName, true);
    assertNull(type);
}
Also used : JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) Test(org.junit.Test)

Example 60 with JvmGenericType

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

the class AbstractTypeProviderTest method testMethods_publicStrictFpMethod_01.

@Test
public void testMethods_publicStrictFpMethod_01() {
    String typeName = Methods.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmOperation method = getMethodFromType(type, Methods.class, "publicStrictFpMethod()");
    assertSame(type, method.getDeclaringType());
    assertFalse(method.isAbstract());
    assertFalse(method.isFinal());
    assertFalse(method.isStatic());
    assertFalse(method.isSynchronized());
    assertTrue(method.isStrictFloatingPoint());
    assertFalse(method.isNative());
    assertEquals(JvmVisibility.PUBLIC, method.getVisibility());
    JvmType methodType = method.getReturnType().getType();
    assertEquals("void", methodType.getIdentifier());
}
Also used : JvmOperation(org.eclipse.xtext.common.types.JvmOperation) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) JvmType(org.eclipse.xtext.common.types.JvmType) Test(org.junit.Test)

Aggregations

JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)297 Test (org.junit.Test)237 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)117 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)64 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)56 JvmType (org.eclipse.xtext.common.types.JvmType)49 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)47 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)33 JvmConstructor (org.eclipse.xtext.common.types.JvmConstructor)33 JvmTypeParameter (org.eclipse.xtext.common.types.JvmTypeParameter)33 JvmField (org.eclipse.xtext.common.types.JvmField)31 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)30 EObject (org.eclipse.emf.ecore.EObject)28 Resource (org.eclipse.emf.ecore.resource.Resource)28 JvmMember (org.eclipse.xtext.common.types.JvmMember)25 JvmParameterizedTypeReference (org.eclipse.xtext.common.types.JvmParameterizedTypeReference)24 JvmTypeConstraint (org.eclipse.xtext.common.types.JvmTypeConstraint)21 JvmUpperBound (org.eclipse.xtext.common.types.JvmUpperBound)17 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)15 JvmFormalParameter (org.eclipse.xtext.common.types.JvmFormalParameter)15