use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class LinkingTest method testBug460191.
@Test
public void testBug460191() throws Exception {
XtendFile file = file("class C {\n" + " def Iterable<K> getFs(Iterable<I> l) {\n" + " l.filter[true]\n" + " }\n" + " interface I {}\n" + " interface K extends I {}\n" + "}");
XtendClass c = (XtendClass) file.getXtendTypes().get(0);
XtendFunction m = (XtendFunction) c.getMembers().get(0);
XBlockExpression body = (XBlockExpression) m.getExpression();
XMemberFeatureCall featureCall = (XMemberFeatureCall) body.getExpressions().get(0);
JvmIdentifiableElement feature = featureCall.getFeature();
assertEquals("org.eclipse.xtext.xbase.lib.IterableExtensions.filter(java.lang.Iterable,org.eclipse.xtext.xbase.lib.Functions$Function1)", feature.getIdentifier());
assertNull(featureCall.getImplicitReceiver());
assertNull(featureCall.getImplicitFirstArgument());
}
use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class LinkingTest method testImplicitFirstArgument_04.
@Test
public void testImplicitFirstArgument_04() throws Exception {
XtendClass clazz = clazz("import static extension test.ImplicitFirstArgumentStatics.*\n" + "class MyXtendClass {\n" + " def testExtensionMethods(CharSequence it) {\n" + " unique" + " }\n" + " extension String" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
XFeatureCall forth = (XFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
JvmOperation forthFeature = (JvmOperation) forth.getFeature();
assertEquals("test.ImplicitFirstArgumentStatics.unique()", forthFeature.getIdentifier());
assertNull(forth.getImplicitFirstArgument());
assertNull(forth.getImplicitReceiver());
assertNull(forth.getInvalidFeatureIssueCode());
}
use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class LinkingTest method testOverloadedMethods_04.
@Test
public void testOverloadedMethods_04() throws Exception {
XtendFile file = file("import java.util.List\n" + "class X {\n" + " def foo() {\n" + " var List<? extends Object> objects = null\n" + " var testdata.OverloadedMethods<Object> receiver = null\n" + " receiver.overloaded(objects, objects)\n" + " }\n" + "}");
XtendClass clazz = (XtendClass) file.getXtendTypes().get(0);
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
XMemberFeatureCall featureCall = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(2);
JvmIdentifiableElement overloaded = featureCall.getFeature();
assertNotNull(overloaded);
assertFalse(overloaded.eIsProxy());
assertEquals("testdata.OverloadedMethods.overloaded(java.lang.Iterable,java.lang.Iterable)", overloaded.getIdentifier());
}
use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class LinkingTest method testBug403580_03.
@Test
public void testBug403580_03() throws Exception {
XtendFile file = file("abstract class C {\n" + " def void m() {\n" + " overloaded [ String s | s ]\n" + " }\n" + " def void overloaded((String)=>String s)" + " def <T> void overloaded(Comparable<T> c)" + "}\n");
XtendClass c = (XtendClass) file.getXtendTypes().get(0);
XtendFunction m = (XtendFunction) c.getMembers().get(0);
XBlockExpression body = (XBlockExpression) m.getExpression();
XFeatureCall featureCall = (XFeatureCall) body.getExpressions().get(0);
JvmIdentifiableElement method = featureCall.getFeature();
assertEquals("C.overloaded(org.eclipse.xtext.xbase.lib.Functions$Function1)", method.getIdentifier());
}
use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class LinkingTest method testBug345827_05.
@Test
public void testBug345827_05() throws Exception {
XtendFunction function = function("def String name(String name) {\n" + " name()" + "}");
XBlockExpression block = (XBlockExpression) function.getExpression();
XFeatureCall featureCall = (XFeatureCall) block.getExpressions().get(0);
JvmOperation operation = associator.getDirectlyInferredOperation(function);
assertSame(operation, featureCall.getFeature());
}
Aggregations