use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class LinkingTest method testExtensionMethodCall_07.
@Test
public void testExtensionMethodCall_07() throws Exception {
XtendClass clazz = clazz("" + "class C {" + " def m() {\n" + " (null as String[]).m\n" + " }\n" + " def void m(String[] s) {" + " }" + "}");
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());
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class LinkingTest method testExtensionMethodCall_03.
@Test
public void testExtensionMethodCall_03() throws Exception {
XtendClass clazz = clazz("" + "abstract class MyIterable implements Iterable<String> {" + " def doSomething() {\n" + " filter [ s.toUpperCase != null ]\n" + " }\n" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
final XFeatureCall call = (XFeatureCall) ((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());
assertNull(call.getInvalidFeatureIssueCode(), call.getInvalidFeatureIssueCode());
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 testOverloadedMethods_20.
@Test
public void testOverloadedMethods_20() throws Exception {
XtendFile file = file("import java.util.Collection\n" + "class X {\n" + " def <T> foo(Collection<T> collection, T head) {\n" + " collection.addAll(head)\n" + " }\n" + "}");
XtendClass clazz = (XtendClass) file.getXtendTypes().get(0);
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
XMemberFeatureCall featureCall = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
JvmIdentifiableElement addAll = featureCall.getFeature();
assertNotNull(addAll);
assertFalse(addAll.eIsProxy());
assertEquals("org.eclipse.xtext.xbase.lib.CollectionExtensions.addAll(java.util.Collection,T[])", addAll.getIdentifier());
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class LinkingTest method testTypeParameterReference_4.
@Test
public void testTypeParameterReference_4() throws Exception {
XtendFunction func = (XtendFunction) ((XtendClass) file("class X { def <Y> foo(Y y) { return y }}").getXtendTypes().get(0)).getMembers().get(0);
JvmOperation operation = associator.getDirectlyInferredOperation(func);
JvmTypeReference returnType = operation.getReturnType();
assertEquals("Y", returnType.getIdentifier());
JvmTypeReference paramType = operation.getParameters().get(0).getParameterType();
assertEquals("Y", paramType.getIdentifier());
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class LinkingTest method testOverloadedMethods_02.
@Test
public void testOverloadedMethods_02() throws Exception {
XtendFile file = file("import java.util.List\n" + "class X {\n" + " def foo() {\n" + " var List<CharSequence> chars = null\n" + " var List<String> strings = null\n" + " var testdata.OverloadedMethods<Object> receiver = null\n" + " receiver.overloaded(strings, chars)\n" + " }\n" + "}");
XtendClass clazz = (XtendClass) file.getXtendTypes().get(0);
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
XMemberFeatureCall featureCall = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(3);
JvmIdentifiableElement overloaded = featureCall.getFeature();
assertNotNull(overloaded);
assertFalse(overloaded.eIsProxy());
assertEquals("testdata.OverloadedMethods.overloaded(java.lang.Iterable,java.util.Collection)", overloaded.getIdentifier());
}
Aggregations