use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class LinkingTest method testOverloadedWithLambdaArgument_01.
@Test
public void testOverloadedWithLambdaArgument_01() throws Exception {
XtendFile file = file("import static extension com.google.common.collect.Iterables.*" + "abstract class C {\n" + " def void m(Iterable<String> iter) {\n" + " iter.filter [ it != null ]\n" + " }\n" + "}\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 method = featureCall.getFeature();
assertEquals("com.google.common.collect.Iterables.filter(java.lang.Iterable,com.google.common.base.Predicate)", method.getIdentifier());
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class LinkingTest method testQualifiedSuper.
@Test
public void testQualifiedSuper() throws Exception {
XtendFile file = file("class B<T> { def T m1() {} }\n" + "class C extends B<String> {\n" + " def void m2() { C.super.m1.subSequence(1, 1) } \n" + "}");
XtendClass c = (XtendClass) file.getXtendTypes().get(1);
XtendFunction n = (XtendFunction) c.getMembers().get(0);
XBlockExpression body = (XBlockExpression) n.getExpression();
XMemberFeatureCall featureCall = (XMemberFeatureCall) body.getExpressions().get(0);
JvmIdentifiableElement feature = featureCall.getFeature();
assertEquals("java.lang.String.subSequence(int,int)", feature.getIdentifier());
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class LinkingTest method testExtensionMethodCall_04.
@Test
public void testExtensionMethodCall_04() throws Exception {
XtendClass clazz = clazz("" + "abstract class MyIterable implements Iterable<String> {" + " def doSomething() {\n" + " this.filter [ s.toUpperCase != null ]\n" + " }\n" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
final XAbstractFeatureCall call = (XAbstractFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
assertEquals("org.eclipse.xtext.xbase.lib.IterableExtensions.filter(java.lang.Iterable,org.eclipse.xtext.xbase.lib.Functions$Function1)", call.getFeature().getIdentifier());
JvmOperation operation = associator.getDirectlyInferredOperation(func);
assertEquals("Iterable<String>", operation.getReturnType().getSimpleName());
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class LinkingTest method testStaticImports_11.
@Test
public void testStaticImports_11() throws Exception {
String fileAsText = "import static com.google.common.collect.Iterables.*\n" + "import static java.util.Collections.*\n" + "class Clazz { def void method() {find(singletonList(''), [e|e.length!=0])} }";
XtendFile file = file(fileAsText, true);
XtendFunction function = (XtendFunction) ((XtendClass) file.getXtendTypes().get(0)).getMembers().get(0);
XFeatureCall featureCall = (XFeatureCall) ((XBlockExpression) function.getExpression()).getExpressions().get(0);
String identifier = featureCall.getFeature().getIdentifier();
assertEquals("com.google.common.collect.Iterables.find(java.lang.Iterable,com.google.common.base.Predicate)", identifier);
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class LinkingTest method testExtensionMethodCall_08.
@Test
public void testExtensionMethodCall_08() throws Exception {
XtendClass clazz = clazz("" + "class C {" + " def m() {\n" + " (null as String[]).m\n" + " }\n" + " def void m(String... s) {}\n" + " def void m(String s) {}\n" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
XMemberFeatureCall call = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
assertFalse(call.getFeature().eIsProxy());
assertEquals("C.m(java.lang.String[])", call.getFeature().getIdentifier());
}
Aggregations