use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testImplicitFirstArgument_00_a.
@Test
public void testImplicitFirstArgument_00_a() throws Exception {
XtendClass clazz = clazz("class MyXtendClass {\n" + " def prependHello(String myString) {\n" + " 'Hello '+myString\n" + " }\n" + " def testExtensionMethods(String it) {\n" + " it.prependHello\n" + " }\n" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(1);
XMemberFeatureCall first = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
JvmOperation firstFeature = (JvmOperation) first.getFeature();
assertEquals("prependHello", firstFeature.getSimpleName());
assertNull(first.getInvalidFeatureIssueCode(), first.getInvalidFeatureIssueCode());
XFeatureCall firstReceiver = (XFeatureCall) first.getImplicitReceiver();
assertEquals("MyXtendClass", firstReceiver.getFeature().getSimpleName());
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testOverloadedMethods_03.
@Test
public void testOverloadedMethods_03() throws Exception {
XtendFile file = file("import java.util.List\n" + "class X {\n" + " def foo() {\n" + " var List<String> strings = null\n" + " var testdata.OverloadedMethods<Object> receiver = null\n" + " receiver.overloaded(strings, strings)\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.overloaded(java.util.List,java.util.List)", overloaded.getIdentifier());
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class Bug409780Test method testConstraintsInfluenceFeatureScope.
@Test
public void testConstraintsInfluenceFeatureScope() throws Exception {
XtendFile file = file("class C {\n" + " def private a(Iterable<CharSequence> it) {\n" + " map[ b ].map[ append('') ]\n" + " }\n" + " def private <T extends Appendable> T b(CharSequence c) {}\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.xtext.xbase.lib.IterableExtensions.map(java.lang.Iterable,org.eclipse.xtext.xbase.lib.Functions$Function1)", method.getIdentifier());
assertTrue(featureCall.isStatic());
assertTrue(featureCall.isExtension());
assertFalse(featureCall.isTypeLiteral());
LightweightTypeReference type = getType(featureCall);
assertEquals("java.lang.Iterable<java.lang.Appendable>", type.getIdentifier());
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class TypeProviderTest method testExpectationRelevantExpressionType_05.
@Test
public void testExpectationRelevantExpressionType_05() throws Exception {
String clazzString = "class C<T> {\n" + " def String m(String s, Class<? super T>[] types) {\n" + " this.m('', newArrayList)\n" + " }\n" + "}";
XtendClass clazz = (XtendClass) file(clazzString, false).getXtendTypes().get(0);
XtendFunction function = (XtendFunction) clazz.getMembers().get(0);
XBlockExpression body = (XBlockExpression) function.getExpression();
XMemberFeatureCall invocation = (XMemberFeatureCall) body.getExpressions().get(0);
XFeatureCall newArrayList = (XFeatureCall) invocation.getActualArguments().get(1);
assertEquals("newArrayList", newArrayList.getFeature().getSimpleName());
assertEquals("Class<? super T>[]", getExpectedType(newArrayList).getSimpleName());
assertEquals("ArrayList<Class<? super T>>", getType(newArrayList).getSimpleName());
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class TypeProviderTest method testExpectationRelevantExpressionType_03.
@Test
public void testExpectationRelevantExpressionType_03() throws Exception {
String clazzString = "class C {\n" + " def m() {\n" + " typeof(C).getMethod('', newArrayList)\n" + " }\n" + "}";
XtendClass clazz = (XtendClass) file(clazzString, false).getXtendTypes().get(0);
XtendFunction function = (XtendFunction) clazz.getMembers().get(0);
XBlockExpression body = (XBlockExpression) function.getExpression();
XMemberFeatureCall invocation = (XMemberFeatureCall) body.getExpressions().get(0);
XFeatureCall newArrayList = (XFeatureCall) invocation.getActualArguments().get(1);
assertEquals("newArrayList", newArrayList.getFeature().getSimpleName());
assertEquals("Class<?>[]", getExpectedType(newArrayList).getSimpleName());
assertEquals("ArrayList<Class<?>>", getType(newArrayList).getSimpleName());
}
Aggregations