use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class LinkingTest method testImplicitPackageImport.
@Test
public void testImplicitPackageImport() throws Exception {
XtendFile file = file("package java.io class Foo implements Serializable {}");
List<JvmTypeReference> implementedInterfaces = ((XtendClass) file.getXtendTypes().get(0)).getImplements();
assertFalse(implementedInterfaces.isEmpty());
JvmType implementedInterface = implementedInterfaces.get(0).getType();
assertNotNull(implementedInterface);
assertEquals("java.io.Serializable", implementedInterface.getIdentifier());
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class LinkingTest method testTypeParameterReference_11.
@Test
public void testTypeParameterReference_11() throws Exception {
XtendFunction func = (XtendFunction) ((XtendClass) file("class X<Z> implements Iterable<Z> { def Iterable<Z> 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<Z>", returnType.getIdentifier());
LightweightTypeReference bodyType = getType(func.getExpression());
assertEquals("X<Z>", bodyType.getIdentifier());
LightweightTypeReference bodyReturnType = getReturnType(func.getExpression());
assertEquals("X<Z>", bodyReturnType.getIdentifier());
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class LinkingTest method testTypeParameterReference_2.
@Test
public void testTypeParameterReference_2() throws Exception {
XtendFunction func = (XtendFunction) ((XtendClass) file("class X<Y> { def foo(Y y) { return y }}").getXtendTypes().get(0)).getMembers().get(0);
JvmOperation operation = associator.getDirectlyInferredOperation(func);
JvmTypeReference returnType = operation.getReturnType();
assertEquals("Y", returnType.getIdentifier());
JvmTypeReference paramType = operation.getParameters().get(0).getParameterType();
assertEquals("Y", paramType.getIdentifier());
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class LinkingTest method testTypeParameterReference_10.
@Test
public void testTypeParameterReference_10() throws Exception {
XtendFunction func = (XtendFunction) ((XtendClass) file("class X<Y> { def foo(Iterable<Y> iter) { for(y: iter) { return y } null }}").getXtendTypes().get(0)).getMembers().get(0);
JvmOperation operation = associator.getDirectlyInferredOperation(func);
JvmTypeReference returnType = operation.getReturnType();
assertEquals("Y", returnType.getIdentifier());
JvmTypeReference paramType = operation.getParameters().get(0).getParameterType();
assertEquals("java.lang.Iterable<Y>", paramType.getIdentifier());
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class LinkingTest method testTypeParameterReference.
@Test
public void testTypeParameterReference() throws Exception {
XtendFunction func = function("def <X> X foo(X x) {x}");
JvmTypeReference returnType = func.getReturnType();
JvmTypeParameter typeParamDecl = (JvmTypeParameter) returnType.getType();
assertEquals("X", typeParamDecl.getIdentifier());
assertEquals("X", typeParamDecl.getName());
JvmTypeReference paramType = func.getParameters().get(0).getParameterType();
assertEquals(typeParamDecl, paramType.getType());
}
Aggregations