use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class TypeProviderTest method testTypeOfRichStringWithExpectedString_2.
@Ignore("TODO improve expectation if the expected type is an unresolved type parameter")
@Test
public void testTypeOfRichStringWithExpectedString_2() throws Exception {
XtendFunction function = function("def String foo(String x) {" + "println('''someString''')" + "}");
XBlockExpression block = (XBlockExpression) function.getExpression();
XAbstractFeatureCall call = (XAbstractFeatureCall) block.getExpressions().get(0);
XExpression expression = call.getExplicitArguments().get(0);
assertEquals("java.lang.String", getType(expression).getIdentifier());
}
use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class TypeProviderTest method testReturnTypeInConstructor_01.
@Test
public void testReturnTypeInConstructor_01() throws Exception {
XtendConstructor constructor = constructor("new() {\n" + " ''.toString\n" + "}\n");
XBlockExpression body = (XBlockExpression) constructor.getExpression();
assertEquals("void", getExpectedType(body).getIdentifier());
assertEquals("void", getExpectedReturnType(body).getIdentifier());
XMemberFeatureCall toString = (XMemberFeatureCall) body.getExpressions().get(0);
assertNull(getExpectedType(toString));
assertNull(getExpectedReturnType(toString));
}
use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class TypeProviderTest method testTypeOfRichStringWithExpectedString_1.
@Test
public void testTypeOfRichStringWithExpectedString_1() throws Exception {
XtendFunction function = function("def String foo(String x) {" + "foo('''someString''')" + "}");
XBlockExpression block = (XBlockExpression) function.getExpression();
XAbstractFeatureCall call = (XAbstractFeatureCall) block.getExpressions().get(0);
XExpression expression = call.getExplicitArguments().get(0);
assertEquals("java.lang.String", getType(expression).getIdentifier());
}
use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class XtendValidationTest method testInaccessibleMethod6.
@Test
public void testInaccessibleMethod6() throws Exception {
XtendClass xtendClass = clazz("class C { def m() { ''.clone }}");
helper.assertError(((XBlockExpression) ((XtendFunction) xtendClass.getMembers().get(0)).getExpression()).getExpressions().get(0), XMEMBER_FEATURE_CALL, FEATURE_NOT_VISIBLE, "The method clone", "not", "visible");
}
use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class XtendValidationTest method testInaccessibleMethod7.
@Test
public void testInaccessibleMethod7() throws Exception {
XtendClass xtendClass = clazz("class C { def m(String s) { s.clone }}");
helper.assertError(((XBlockExpression) ((XtendFunction) xtendClass.getMembers().get(0)).getExpression()).getExpressions().get(0), XMEMBER_FEATURE_CALL, FEATURE_NOT_VISIBLE, "The method clone", "not", "visible");
}
Aggregations