use of org.eclipse.xtext.xbase.XVariableDeclaration in project xtext-xtend by eclipse.
the class UIStringsTest method testReferenceToString_1.
/**
* Only the simple name of the type is specified.
* The JvmTypeReference is proxy.
*/
@Test
public void testReferenceToString_1() throws Exception {
XtendFile file1 = 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");
assertNotNull(file1);
XtendFile file2 = file("package org.eclipse.xtend.core.tests.validation.uistrings\n" + "class XtendClass1 {\n" + " def test() {\n" + " val x = new List<ClassC>\n" + " }\n" + "}\n");
XtendClass clazz = (XtendClass) file2.getXtendTypes().get(0);
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());
assertTrue(reference.getType().eIsProxy());
assertNotNull(reference.eResource());
assertEquals("ClassC", this.uiStrings.referenceToString(reference, "the-default-label"));
}
use of org.eclipse.xtext.xbase.XVariableDeclaration in project xtext-xtend by eclipse.
the class UIStringsTest method testReferenceToString_2.
/**
* The qualified name of the type is specified.
* The JvmTypeReference is not a proxy.
*/
@Test
public void testReferenceToString_2() 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<org.eclipse.xtend.core.tests.validation.uistrings.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"));
}
Aggregations