Search in sources :

Example 81 with LightweightTypeReference

use of org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference in project xtext-xtend by eclipse.

the class LinkingTest method testTypeParameterReference_16.

@Test
public void testTypeParameterReference_16() throws Exception {
    XtendFunction func = (XtendFunction) ((XtendClass) file("class X<Z> implements Iterable<Z> { def <Y> Iterable<Y> foo() { val r = new X r }}").getXtendTypes().get(0)).getMembers().get(0);
    JvmOperation operation = associator.getDirectlyInferredOperation(func);
    JvmTypeReference returnType = operation.getReturnType();
    assertEquals("java.lang.Iterable<Y>", returnType.getIdentifier());
    LightweightTypeReference bodyType = getType(func.getExpression());
    assertEquals("X<Y>", bodyType.getIdentifier());
    LightweightTypeReference bodyReturnType = getReturnType(func.getExpression());
    assertEquals("X<Y>", bodyReturnType.getIdentifier());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) JvmOperation(org.eclipse.xtext.common.types.JvmOperation) LightweightTypeReference(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) Test(org.junit.Test)

Example 82 with LightweightTypeReference

use of org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference in project xtext-xtend by eclipse.

the class LinkingTest method testTypeParameterReference_15.

@Test
public void testTypeParameterReference_15() throws Exception {
    XtendFunction func = (XtendFunction) ((XtendClass) file("class X<Z> implements Iterable<Z> { def Iterable<String> foo() { val result = new X result }}").getXtendTypes().get(0)).getMembers().get(0);
    JvmOperation operation = associator.getDirectlyInferredOperation(func);
    JvmTypeReference returnType = operation.getReturnType();
    assertEquals("java.lang.Iterable<java.lang.String>", returnType.getIdentifier());
    LightweightTypeReference bodyType = getType(func.getExpression());
    assertEquals("X<java.lang.String>", bodyType.getIdentifier());
    LightweightTypeReference bodyReturnType = getReturnType(func.getExpression());
    assertEquals("X<java.lang.String>", bodyReturnType.getIdentifier());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) JvmOperation(org.eclipse.xtext.common.types.JvmOperation) LightweightTypeReference(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) Test(org.junit.Test)

Example 83 with LightweightTypeReference

use of org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference in project xtext-xtend by eclipse.

the class LinkingTest method testTypeParameterReference_12.

@Test
public void testTypeParameterReference_12() throws Exception {
    XtendFunction func = (XtendFunction) ((XtendClass) file("class X<Z> implements Iterable<Z> { def Iterable<String> foo() { val result = new X return result }}").getXtendTypes().get(0)).getMembers().get(0);
    JvmOperation operation = associator.getDirectlyInferredOperation(func);
    JvmTypeReference returnType = operation.getReturnType();
    assertEquals("java.lang.Iterable<java.lang.String>", returnType.getIdentifier());
    LightweightTypeReference bodyType = getType(func.getExpression());
    assertEquals("void", bodyType.getIdentifier());
    LightweightTypeReference bodyReturnType = getReturnType(func.getExpression());
    assertEquals("X<java.lang.String>", bodyReturnType.getIdentifier());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) JvmOperation(org.eclipse.xtext.common.types.JvmOperation) LightweightTypeReference(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) Test(org.junit.Test)

Aggregations

LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)83 Test (org.junit.Test)28 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)23 XExpression (org.eclipse.xtext.xbase.XExpression)22 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)20 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)19 JvmFormalParameter (org.eclipse.xtext.common.types.JvmFormalParameter)16 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)13 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)10 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)10 IFeatureCallArguments (org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments)10 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)9 XNumberLiteral (org.eclipse.xtext.xbase.XNumberLiteral)9 JvmType (org.eclipse.xtext.common.types.JvmType)8 ITypeReferenceOwner (org.eclipse.xtext.xbase.typesystem.references.ITypeReferenceOwner)8 EObject (org.eclipse.emf.ecore.EObject)7 JvmIdentifiableElement (org.eclipse.xtext.common.types.JvmIdentifiableElement)7 StandardTypeReferenceOwner (org.eclipse.xtext.xbase.typesystem.references.StandardTypeReferenceOwner)7 RichString (org.eclipse.xtend.core.xtend.RichString)6 JvmTypeParameter (org.eclipse.xtext.common.types.JvmTypeParameter)6