use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class XtendValidationTest method testInaccessibleMethod14.
@Test
public void testInaccessibleMethod14() throws Exception {
XtendClass xtendClass = clazz("class Foo { private var int x def foo() { val o = new Foo { } o.x = 2 }}");
helper.assertError(((XBlockExpression) ((XtendFunction) xtendClass.getMembers().get(1)).getExpression()).getExpressions().get(1), XABSTRACT_FEATURE_CALL, FEATURE_NOT_VISIBLE, "private", " x ");
}
use of org.eclipse.xtext.xbase.XBlockExpression 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.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class FindReferencesTest method testFindReferencesToConstructor.
@Test
public void testFindReferencesToConstructor() throws Exception {
XtendClass classFoo = (XtendClass) testHelper.xtendFile("Foo", "class Foo {}").getXtendTypes().get(0);
XtendClass classBar = (XtendClass) testHelper.xtendFile("Bar", "class Bar { def bar() {new Foo()} }").getXtendTypes().get(0);
waitForBuild();
JvmConstructor inferredConstructor = associations.getInferredConstructor(classFoo);
XtendFunction functionBar = (XtendFunction) classBar.getMembers().get(0);
final MockAcceptor mockAcceptor = new MockAcceptor();
mockAcceptor.expect(((XBlockExpression) functionBar.getExpression()).getExpressions().get(0), inferredConstructor, XCONSTRUCTOR_CALL__CONSTRUCTOR);
findReferencesTester.checkFindReferences(classFoo, "Java References to Foo (/test.project/src/Foo.xtend)", mockAcceptor);
}
use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class FindReferencesTest method testFindReferencesThis.
@Test
public void testFindReferencesThis() throws Exception {
XtendClass classFoo = (XtendClass) testHelper.xtendFile("Foo", "class Foo { def foo() {this} }").getXtendTypes().get(0);
waitForBuild();
JvmGenericType inferredType = associations.getInferredType(classFoo);
XtendFunction functionFoo = (XtendFunction) classFoo.getMembers().get(0);
final MockAcceptor mockAcceptor = new MockAcceptor();
mockAcceptor.expect(((XBlockExpression) functionFoo.getExpression()).getExpressions().get(0), inferredType, XABSTRACT_FEATURE_CALL__FEATURE);
findReferencesTester.checkFindReferences(inferredType, "Java References to Foo (/test.project/src/Foo.xtend)", mockAcceptor);
}
use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class FindReferencesTest method testFindReferencesTypeLiteral.
@Test
public void testFindReferencesTypeLiteral() throws Exception {
XtendClass classFoo = (XtendClass) testHelper.xtendFile("Foo", "class Foo { def foo() { Foo } }").getXtendTypes().get(0);
waitForBuild();
JvmGenericType inferredType = associations.getInferredType(classFoo);
XtendFunction functionFoo = (XtendFunction) classFoo.getMembers().get(0);
final MockAcceptor mockAcceptor = new MockAcceptor();
mockAcceptor.expect(((XBlockExpression) functionFoo.getExpression()).getExpressions().get(0), inferredType, XABSTRACT_FEATURE_CALL__FEATURE);
findReferencesTester.checkFindReferences(inferredType, "Java References to Foo (/test.project/src/Foo.xtend)", mockAcceptor);
}
Aggregations