Search in sources :

Example 21 with XMemberFeatureCall

use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.

the class LinkingTest method testExtensionMethodCall_Bug351827_04.

@Test
public void testExtensionMethodCall_Bug351827_04() throws Exception {
    XtendClass clazz = clazz("" + "class Foo {" + "  extension testdata.Properties1 p\n" + "  def setProp1(String s) { s }" + "  def foo(String s) {\n" + "    s.setProp1()\n" + "  }\n" + "}");
    XtendFunction func = (XtendFunction) clazz.getMembers().get(2);
    final XMemberFeatureCall call = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
    assertEquals("Foo.setProp1(java.lang.String)", call.getFeature().getIdentifier());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XMemberFeatureCall(org.eclipse.xtext.xbase.XMemberFeatureCall) Test(org.junit.Test)

Example 22 with XMemberFeatureCall

use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.

the class LinkingTest method testImplicitFirstArgument_03.

@Test
public void testImplicitFirstArgument_03() throws Exception {
    XtendClass clazz = clazz("import static extension test.ImplicitFirstArgumentStatics.*\n" + "class MyXtendClass {\n" + "  def testExtensionMethods(CharSequence it) {\n" + "    toLowerCase\n" + "  }\n" + "  extension String" + "}");
    XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
    XFeatureCall third = (XFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
    JvmOperation thirdFeature = (JvmOperation) third.getFeature();
    assertEquals("java.lang.String.toLowerCase()", thirdFeature.getIdentifier());
    assertNull(third.getImplicitFirstArgument());
    XMemberFeatureCall thirdReceiver = (XMemberFeatureCall) third.getImplicitReceiver();
    assertTrue(thirdReceiver.getFeature() instanceof JvmField);
    assertNull(third.getInvalidFeatureIssueCode(), third.getInvalidFeatureIssueCode());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) JvmOperation(org.eclipse.xtext.common.types.JvmOperation) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XFeatureCall(org.eclipse.xtext.xbase.XFeatureCall) XMemberFeatureCall(org.eclipse.xtext.xbase.XMemberFeatureCall) JvmField(org.eclipse.xtext.common.types.JvmField) Test(org.junit.Test)

Example 23 with XMemberFeatureCall

use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.

the class LinkingTest method testBug460191.

@Test
public void testBug460191() throws Exception {
    XtendFile file = file("class C {\n" + "    def Iterable<K> getFs(Iterable<I> l) {\n" + "        l.filter[true]\n" + "    }\n" + "    interface I {}\n" + "    interface K extends I {}\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 feature = featureCall.getFeature();
    assertEquals("org.eclipse.xtext.xbase.lib.IterableExtensions.filter(java.lang.Iterable,org.eclipse.xtext.xbase.lib.Functions$Function1)", feature.getIdentifier());
    assertNull(featureCall.getImplicitReceiver());
    assertNull(featureCall.getImplicitFirstArgument());
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) JvmIdentifiableElement(org.eclipse.xtext.common.types.JvmIdentifiableElement) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XMemberFeatureCall(org.eclipse.xtext.xbase.XMemberFeatureCall) Test(org.junit.Test)

Example 24 with XMemberFeatureCall

use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.

the class LinkingTest method testOverloadedMethods_04.

@Test
public void testOverloadedMethods_04() throws Exception {
    XtendFile file = file("import java.util.List\n" + "class X {\n" + "  def foo() {\n" + "    var List<? extends Object> objects = null\n" + "    var testdata.OverloadedMethods<Object> receiver = null\n" + "    receiver.overloaded(objects, objects)\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.lang.Iterable,java.lang.Iterable)", overloaded.getIdentifier());
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) JvmIdentifiableElement(org.eclipse.xtext.common.types.JvmIdentifiableElement) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XMemberFeatureCall(org.eclipse.xtext.xbase.XMemberFeatureCall) Test(org.junit.Test)

Example 25 with XMemberFeatureCall

use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.

the class LinkingTest method testBug343102_02.

@Test
public void testBug343102_02() throws Exception {
    XtendFunction function = function("def <T> 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);
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XMemberFeatureCall(org.eclipse.xtext.xbase.XMemberFeatureCall) Test(org.junit.Test)

Aggregations

XMemberFeatureCall (org.eclipse.xtext.xbase.XMemberFeatureCall)88 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)82 Test (org.junit.Test)82 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)78 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)74 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)46 JvmIdentifiableElement (org.eclipse.xtext.common.types.JvmIdentifiableElement)39 XFeatureCall (org.eclipse.xtext.xbase.XFeatureCall)19 XExpression (org.eclipse.xtext.xbase.XExpression)14 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)7 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)6 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)5 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)5 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)5 XAbstractFeatureCall (org.eclipse.xtext.xbase.XAbstractFeatureCall)4 XIfExpression (org.eclipse.xtext.xbase.XIfExpression)4 XSwitchExpression (org.eclipse.xtext.xbase.XSwitchExpression)4 XtendParameter (org.eclipse.xtend.core.xtend.XtendParameter)3 AnonymousClass (org.eclipse.xtend.core.xtend.AnonymousClass)2 RichString (org.eclipse.xtend.core.xtend.RichString)2