use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testExtensionMethodCall_Bug351827_03.
@Test
public void testExtensionMethodCall_Bug351827_03() throws Exception {
XtendClass clazz = clazz("" + "class Foo {" + " extension testdata.Properties1 p\n" + " def foo(String s) {\n" + " s.setProp1\n" + " }\n" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(1);
final XMemberFeatureCall call = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
assertEquals("testdata.Properties1.setProp1(java.lang.String)", call.getFeature().getIdentifier());
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testStaticImports_08.
@Test
public void testStaticImports_08() throws Exception {
String fileAsText = "import static com.google.common.collect.Iterables.*\n" + "import static java.util.Collections.*\n" + "class Clazz { def void method() {singletonList('').findFirst(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 testOverloadedMethods_09.
@Test
public void testOverloadedMethods_09() throws Exception {
XtendFile file = file("import java.util.List\n" + "class X {\n" + " def foo() {\n" + " var List<? extends CharSequence> chars = null\n" + " var testdata.OverloadedMethods<Object> receiver = null\n" + " receiver.overloaded2(chars, 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(2);
JvmIdentifiableElement overloaded = featureCall.getFeature();
assertNotNull(overloaded);
assertFalse(overloaded.eIsProxy());
assertEquals("testdata.OverloadedMethods.overloaded2(java.lang.Iterable,java.lang.Iterable)", overloaded.getIdentifier());
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testExtensionMethodCall_Bug351827_02.
@Test
public void testExtensionMethodCall_Bug351827_02() throws Exception {
XtendClass clazz = clazz("" + "class Foo {" + " extension testdata.Properties1 p\n" + " def foo(String s) {\n" + " s.setProp1\n" + " }\n" + " def setProp1(String s) { s }" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(1);
final XMemberFeatureCall call = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
assertEquals("Foo.setProp1(java.lang.String)", call.getFeature().getIdentifier());
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testOverloadedMethods_12.
@Test
public void testOverloadedMethods_12() throws Exception {
XtendFile file = file("import java.util.Collection\n" + "class X {\n" + " def <T> foo(Collection<? super T> collection, Collection<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("java.util.Collection.addAll(java.util.Collection)", addAll.getIdentifier());
}
Aggregations