use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testBug343102_01.
@Test
public void testBug343102_01() throws Exception {
XtendFunction function = function("def <T extends java.lang.Object> test(T t) {\n" + " t.getClass\n" + "}");
XMemberFeatureCall featureCall = (XMemberFeatureCall) ((XBlockExpression) function.getExpression()).getExpressions().get(0);
String identifier = featureCall.getFeature().getIdentifier();
assertEquals("java.lang.Object.getClass()", identifier);
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testExtensionMethodCall_09.
@Test
public void testExtensionMethodCall_09() 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.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testOverloadedMethods_18.
@Test
public void testOverloadedMethods_18() throws Exception {
XtendFile file = file("import java.util.Collection\n" + "class X {\n" + " def <T> foo(Collection<T> collection, Iterable<? extends T> elements) {\n" + " collection.addAll(elements.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.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testStaticImports_09.
@Test
public void testStaticImports_09() throws Exception {
String fileAsText = "import static java.util.Collections.* class Clazz { def void method() {singletonList('').findFirst(String e|e!=null)} }";
XtendFile file = file(fileAsText, true);
XtendFunction function = (XtendFunction) ((XtendClass) file.getXtendTypes().get(0)).getMembers().get(0);
XMemberFeatureCall featureCall = (XMemberFeatureCall) ((XBlockExpression) function.getExpression()).getExpressions().get(0);
String identifier = featureCall.getFeature().getIdentifier();
assertEquals("org.eclipse.xtext.xbase.lib.IterableExtensions.findFirst(java.lang.Iterable,org.eclipse.xtext.xbase.lib.Functions$Function1)", identifier);
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testQualifiedSuperOuter.
@Test
public void testQualifiedSuperOuter() throws Exception {
XtendFile file = file("class B<T> { def T m1() {} }\n" + "class C extends B<String> {\n" + " def void m2() { new Object { def m3() { C.super.m1.subSequence(1, 1) } } }\n" + "}");
XtendClass c = (XtendClass) file.getXtendTypes().get(1);
XtendFunction m = (XtendFunction) c.getMembers().get(0);
XBlockExpression outer = (XBlockExpression) m.getExpression();
AnonymousClass anonymousClass = (AnonymousClass) outer.getExpressions().get(0);
XtendFunction m3 = (XtendFunction) anonymousClass.getMembers().get(0);
XBlockExpression body = (XBlockExpression) m3.getExpression();
XMemberFeatureCall featureCall = (XMemberFeatureCall) body.getExpressions().get(0);
JvmIdentifiableElement feature = featureCall.getFeature();
assertEquals("java.lang.String.subSequence(int,int)", feature.getIdentifier());
}
Aggregations