use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class LinkingTest method testTypeParameterShadowsType_2.
@Test
public void testTypeParameterShadowsType_2() throws Exception {
XtendFunction func = (XtendFunction) ((XtendClass) file("class A {} class B<A> { def A foo(A x) {x}}").getXtendTypes().get(1)).getMembers().get(0);
JvmTypeReference returnType = func.getReturnType();
JvmTypeParameter typeParamDecl = (JvmTypeParameter) returnType.getType();
assertEquals("A", typeParamDecl.getIdentifier());
JvmTypeParameter param = (JvmTypeParameter) func.getParameters().get(0).getParameterType().getType();
assertSame(typeParamDecl, param);
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class LinkingTest method testTypeReference_0.
@Test
public void testTypeReference_0() throws Exception {
XtendFunction func = function("def =>java.lang.Boolean foo() {[|true]}");
XFunctionTypeRef type = (XFunctionTypeRef) func.getReturnType();
JvmTypeReference returnType = type.getReturnType();
assertEquals("java.lang.Boolean", returnType.getIdentifier());
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class LinkingTest method testTypeParameterShadowsType_1.
@Test
public void testTypeParameterShadowsType_1() throws Exception {
XtendFunction func = (XtendFunction) ((XtendClass) file("class A {} class B { def <A> A foo(A x) {x}}").getXtendTypes().get(1)).getMembers().get(0);
JvmTypeReference returnType = func.getReturnType();
JvmTypeParameter typeParamDecl = (JvmTypeParameter) returnType.getType();
assertEquals("A", typeParamDecl.getIdentifier());
JvmTypeParameter param = (JvmTypeParameter) func.getParameters().get(0).getParameterType().getType();
assertSame(typeParamDecl, param);
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class UIStringsTest method testReferenceToString_0.
/**
* Only the simple name of the type is specified.
* The JvmTypeReference is not a proxy.
*/
@Test
public void testReferenceToString_0() throws Exception {
XtendFile file = file("package org.eclipse.xtend.core.tests.validation.uistrings\n" + "public interface InterfaceA { }\n" + "public class ClassB implements InterfaceA { }\n" + "public class ClassC extends ClassB {\n" + "}\n" + "class XtendClass1 {\n" + " def test() {\n" + " val x = new List<ClassC>\n" + " }\n" + "}\n");
XtendClass clazz = (XtendClass) file.getXtendTypes().get(3);
XBlockExpression block = (XBlockExpression) ((XtendFunction) clazz.getMembers().get(0)).getExpression();
XVariableDeclaration declaration = (XVariableDeclaration) block.getExpressions().get(0);
XConstructorCall cons = (XConstructorCall) declaration.getRight();
JvmTypeReference reference = cons.getTypeArguments().get(0);
assertNotNull(reference);
assertNotNull(reference.getType());
assertFalse(reference.getType().eIsProxy());
assertNotNull(reference.eResource());
assertEquals("ClassC", this.uiStrings.referenceToString(reference, "the-default-label"));
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class UIStringsTest method testReferenceToString_4.
@Test
public void testReferenceToString_4() throws Exception {
XtendFile file = file("class Foo { var test }");
assertFalse(validationTestHelper.validate(file).isEmpty());
XtendClass clazz = (XtendClass) file.getXtendTypes().get(0);
XtendField field = (XtendField) clazz.getMembers().get(0);
JvmField jvmField = associations.getJvmField(field);
JvmTypeReference reference = jvmField.getType();
assertNotNull(reference);
assertNotNull(reference.getType());
assertFalse(reference.getType().eIsProxy());
assertNotNull(reference.eResource());
assertEquals("Object", this.uiStrings.referenceToString(reference, "the-default-label"));
}
Aggregations