use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testOverloadedMethods_13.
@Test
public void testOverloadedMethods_13() throws Exception {
XtendFile file = file("import java.util.Collection\n" + "class X {\n" + " def <T> foo(Collection<? super T> collection, Iterable<T> elements) {\n" + " collection.addAll(elements)\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,java.lang.Iterable)", addAll.getIdentifier());
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testExtensionMethodCall_05.
@Test
public void testExtensionMethodCall_05() throws Exception {
XtendClass clazz = clazz("" + "class C {" + " def m() {\n" + " ''.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().getIdentifier(), call.getFeature().eIsProxy());
assertEquals("C.m(java.lang.String[])", call.getFeature().getIdentifier());
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testLocalVarExtensionMethodCall.
@Test
public void testLocalVarExtensionMethodCall() throws Exception {
XtendClass clazz = clazz("" + "class Foo {" + " def foo() " + " { extension var local = '' (1 as int).indexOf() }" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
final XMemberFeatureCall call = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(1);
assertEquals("java.lang.String.indexOf(int)", call.getFeature().getIdentifier());
assertEquals("local", ((XFeatureCall) call.getImplicitReceiver()).getFeature().getIdentifier());
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testOverloadedMethods_11.
@Test
public void testOverloadedMethods_11() throws Exception {
XtendFile file = file("import java.util.List\n" + "class X {\n" + " def foo() {\n" + " var Integer i = 0\n" + " var testdata.OverloadedMethods<Object> receiver = null\n" + " receiver.overloadedInt(i)\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.overloadedInt(java.lang.Integer)", overloaded.getIdentifier());
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testSugarOverTypeLiteral_02.
@Test
public void testSugarOverTypeLiteral_02() throws Exception {
XtendFile file = file("import org.eclipse.emf.ecore.resource.Resource\n" + "import org.eclipse.emf.common.util.URI\n" + "class C {\n" + " def m(Resource Resource, URI unused) {\n" + " Resource.URI" + " }\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("org.eclipse.emf.ecore.resource.Resource.getURI()", method.getIdentifier());
}
Aggregations