Search in sources :

Example 91 with JvmIdentifiableElement

use of org.eclipse.xtext.common.types.JvmIdentifiableElement in project xtext-xtend by eclipse.

the class LinkingTest method testOverloadedMethods_10.

@Test
public void testOverloadedMethods_10() throws Exception {
    XtendFile file = file("import java.util.List\n" + "class X {\n" + "  def foo() {\n" + "    var int 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(int)", 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 92 with JvmIdentifiableElement

use of org.eclipse.xtext.common.types.JvmIdentifiableElement in project xtext-xtend by eclipse.

the class LinkingTest method testOverloadedMethods_08.

@Test
public void testOverloadedMethods_08() 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.overloaded2(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.overloaded2(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 93 with JvmIdentifiableElement

use of org.eclipse.xtext.common.types.JvmIdentifiableElement in project xtext-xtend by eclipse.

the class LinkingTest method testBug403580_07.

@Ignore("Depends on the order of the overloaded methods")
@Test
public void testBug403580_07() throws Exception {
    XtendFile file = file("abstract class C {\n" + "	def void m() {\n" + "		overloaded [ String s | s.length ]\n" + "	}\n" + "	def <T> void overloaded(Comparable<T> c)" + "	def void overloaded((String)=>int s)" + "}\n");
    XtendClass c = (XtendClass) file.getXtendTypes().get(0);
    XtendFunction m = (XtendFunction) c.getMembers().get(0);
    XBlockExpression body = (XBlockExpression) m.getExpression();
    XFeatureCall featureCall = (XFeatureCall) body.getExpressions().get(0);
    JvmIdentifiableElement method = featureCall.getFeature();
    assertEquals("C.overloaded(java.lang.Comparable)", method.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) XFeatureCall(org.eclipse.xtext.xbase.XFeatureCall) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 94 with JvmIdentifiableElement

use of org.eclipse.xtext.common.types.JvmIdentifiableElement 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());
}
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 95 with JvmIdentifiableElement

use of org.eclipse.xtext.common.types.JvmIdentifiableElement in project xtext-xtend by eclipse.

the class LinkingTest method testOverloadStaticInstance_01.

@Test
public void testOverloadStaticInstance_01() throws Exception {
    XtendFile file = file("class C {\n" + "	def void m(CharSequence c) {\n" + "		m('')\n" + "	}\n" + "	def static void m(String s) {}\n" + "}");
    XtendClass c = (XtendClass) file.getXtendTypes().get(0);
    XtendFunction m = (XtendFunction) c.getMembers().get(0);
    XBlockExpression body = (XBlockExpression) m.getExpression();
    XFeatureCall featureCall = (XFeatureCall) body.getExpressions().get(0);
    JvmIdentifiableElement feature = featureCall.getFeature();
    assertEquals("C.m(java.lang.String)", 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) XFeatureCall(org.eclipse.xtext.xbase.XFeatureCall) Test(org.junit.Test)

Aggregations

JvmIdentifiableElement (org.eclipse.xtext.common.types.JvmIdentifiableElement)112 Test (org.junit.Test)65 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)63 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)62 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)60 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)58 XMemberFeatureCall (org.eclipse.xtext.xbase.XMemberFeatureCall)39 XFeatureCall (org.eclipse.xtext.xbase.XFeatureCall)27 EObject (org.eclipse.emf.ecore.EObject)26 XAbstractFeatureCall (org.eclipse.xtext.xbase.XAbstractFeatureCall)13 XExpression (org.eclipse.xtext.xbase.XExpression)12 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)11 IJavaElement (org.eclipse.jdt.core.IJavaElement)10 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)8 JvmFormalParameter (org.eclipse.xtext.common.types.JvmFormalParameter)6 JvmType (org.eclipse.xtext.common.types.JvmType)6 XtextResource (org.eclipse.xtext.resource.XtextResource)6 XtendField (org.eclipse.xtend.core.xtend.XtendField)5 JvmExecutable (org.eclipse.xtext.common.types.JvmExecutable)5 JvmMember (org.eclipse.xtext.common.types.JvmMember)5