use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class TypeProviderTest method testReturnTypeInConstructor_02.
@Test
public void testReturnTypeInConstructor_02() throws Exception {
XtendConstructor constructor = constructor("new() {\n" + " return ''.toString\n" + "}\n", false);
XBlockExpression body = (XBlockExpression) constructor.getExpression();
assertEquals("void", getExpectedType(body).getIdentifier());
assertEquals("void", getExpectedReturnType(body).getIdentifier());
XReturnExpression returnExpression = (XReturnExpression) body.getExpressions().get(0);
XMemberFeatureCall toString = (XMemberFeatureCall) returnExpression.getExpression();
assertEquals("void", getExpectedType(toString).getIdentifier());
assertEquals("void", getExpectedReturnType(toString).getIdentifier());
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class TypeProviderTest method testBug380063NoException.
@Test
public void testBug380063NoException() throws Exception {
XtendClass clazz = clazz("class Foo<T> { " + "def foo(java.util.List<? extends T> l) { " + " l.add(null)" + "}}");
XtendFunction function = (XtendFunction) clazz.getMembers().get(0);
XtendParameter xtendParameter = function.getParameters().get(0);
XBlockExpression expr = (XBlockExpression) function.getExpression();
XMemberFeatureCall call = (XMemberFeatureCall) expr.getExpressions().get(0);
LightweightTypeReference type = getType(call.getMemberCallTarget());
assertEquals("List<? extends T>", type.getSimpleName());
assertEquals("List<? extends T>", xtendParameter.getParameterType().getSimpleName());
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class InferredJvmModelShadowingJavaLinkingTests method testLinkJavaMethod.
@Test
public void testLinkJavaMethod() throws Exception {
XtendClass bar = classFile("test/Bar", "package test class Bar { def bar(Foo foo) {foo.foo()} }");
final XExpression block = ((XtendFunction) bar.getMembers().get(0)).getExpression();
XMemberFeatureCall methodCall = (XMemberFeatureCall) ((XBlockExpression) block).getExpressions().get(0);
assertTrue(isJavaElement(methodCall.getFeature()));
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class InferredJvmModelShadowingJavaLinkingTests method testLinkInferredJvmOperationWithSyntaxError.
@Test
public void testLinkInferredJvmOperationWithSyntaxError() throws Exception {
// syntax error is intentional
XtendClass foo = classFile("test/Foo", "package test class Foo { def foo() :this; }");
XtendClass bar = classFile("test/Bar", "package test class Bar { def bar(Foo foo) {foo.foo()} }");
final XBlockExpression block = (XBlockExpression) ((XtendFunction) bar.getMembers().get(0)).getExpression();
XMemberFeatureCall methodCall = (XMemberFeatureCall) block.getExpressions().get(0);
assertEquals(associations.getDirectlyInferredOperation((XtendFunction) foo.getMembers().get(0)), methodCall.getFeature());
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingErrorTest method testFieldsAreNotSugared_01.
@Test
public void testFieldsAreNotSugared_01() throws Exception {
XtendClass clazz = clazz("class A {\n" + " String getFoo\n" + " def String doStuff() {\n" + " this.foo\n" + " }");
XMemberFeatureCall call = (XMemberFeatureCall) ((XBlockExpression) ((XtendFunction) clazz.getMembers().get(1)).getExpression()).getExpressions().get(0);
JvmIdentifiableElement feature = call.getFeature();
assertTrue(feature.eIsProxy());
}
Aggregations