Search in sources :

Example 21 with JvmIdentifiableElement

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

the class LinkingTest method testOverloadedMethods_11.

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

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

the class LinkingTest method testBug403580_06.

@Test
public void testBug403580_06() throws Exception {
    XtendFile file = file("abstract class C {\n" + "	def void m() {\n" + "		overloaded [ String s | s.length ]\n" + "	}\n" + "	def void overloaded((String)=>String s)" + "	def void overloaded(Object o)" + "}\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.Object)", 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) Test(org.junit.Test)

Example 23 with JvmIdentifiableElement

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

the class LinkingTest method testSugarOverTypeLiteral_02.

@Test
public void testSugarOverTypeLiteral_02() throws Exception {
    XtendFile file = file("import org.eclipse.emf.ecore.resource.Resource\n" + "import org.eclipse.emf.common.util.URI\n" + "class C {\n" + "	def m(Resource Resource, URI unused) {\n" + "		Resource.URI" + "	}\n" + "}\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.emf.ecore.resource.Resource.getURI()", 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) XMemberFeatureCall(org.eclipse.xtext.xbase.XMemberFeatureCall) Test(org.junit.Test)

Example 24 with JvmIdentifiableElement

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

the class LinkingTest method testStaticNestedClass_02.

@Test
public void testStaticNestedClass_02() throws Exception {
    XtendFile file = file("class C {\n" + "  static class D {\n" + "    def static void m(CharSequence c) { m('') }\n" + "  }\n" + "  def static void m(String s) {}\n" + "}");
    XtendClass c = (XtendClass) file.getXtendTypes().get(0);
    XtendClass d = (XtendClass) c.getMembers().get(0);
    XtendFunction m = (XtendFunction) d.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());
}
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)

Example 25 with JvmIdentifiableElement

use of org.eclipse.xtext.common.types.JvmIdentifiableElement 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)

Aggregations

JvmIdentifiableElement (org.eclipse.xtext.common.types.JvmIdentifiableElement)91 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)26 EObject (org.eclipse.emf.ecore.EObject)13 XAbstractFeatureCall (org.eclipse.xtext.xbase.XAbstractFeatureCall)9 XExpression (org.eclipse.xtext.xbase.XExpression)9 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)7 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)7 XtendField (org.eclipse.xtend.core.xtend.XtendField)5 JvmType (org.eclipse.xtext.common.types.JvmType)5 XtextResource (org.eclipse.xtext.resource.XtextResource)5 Resource (org.eclipse.emf.ecore.resource.Resource)4 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)4 JvmMember (org.eclipse.xtext.common.types.JvmMember)4 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)3