Search in sources :

Example 16 with JvmIdentifiableElement

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

the class LinkingShadowingTest method testOperation_implicitArgumentOnStatic.

@Test
public void testOperation_implicitArgumentOnStatic() throws Exception {
    XtendClass clazz = clazz("import static testdata.LinkingStaticTypeEquallyNamed.*" + "class SomeClass {\n" + "  def void method(Object it) {\n" + "    withArgument\n" + "  }\n" + "}");
    XAbstractFeatureCall featureCall = getFirstFeatureCall(clazz);
    assertNotNull("feature is available", featureCall.getFeature());
    JvmIdentifiableElement linked = featureCall.getFeature();
    assertFalse("is resolved", linked.eIsProxy());
    assertTrue("testdata.LinkingStaticTypeEquallyNamed.withArgument(java.lang.Object)".equals(linked.getIdentifier()) || "testdata.LinkingStaticTypeEquallyNamed.withArgument(java.lang.Object,int,int)".equals(linked.getIdentifier()));
    assertFalse(clazz.eResource().getErrors().isEmpty());
}
Also used : JvmIdentifiableElement(org.eclipse.xtext.common.types.JvmIdentifiableElement) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XAbstractFeatureCall(org.eclipse.xtext.xbase.XAbstractFeatureCall) Test(org.junit.Test)

Example 17 with JvmIdentifiableElement

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

the class LinkingShadowingTest method assertLinksTo.

protected void assertLinksTo(String identifier, EClass type, XAbstractFeatureCall featureCall, boolean withIssues) {
    assertNotNull("feature is available", featureCall.getFeature());
    JvmIdentifiableElement linked = featureCall.getFeature();
    assertFalse("is resolved", linked.eIsProxy());
    assertEquals(identifier, linked.getIdentifier());
    assertTrue(type.isInstance(linked));
    if (!withIssues) {
        validator.assertNoErrors(featureCall);
    } else {
        assertFalse(featureCall.eResource().getErrors().isEmpty());
    }
}
Also used : JvmIdentifiableElement(org.eclipse.xtext.common.types.JvmIdentifiableElement)

Example 18 with JvmIdentifiableElement

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

the class LinkingTest method testQualifiedSuperOuter.

@Test
public void testQualifiedSuperOuter() throws Exception {
    XtendFile file = file("class B<T> { def T m1() {} }\n" + "class C extends B<String> {\n" + "  def void m2() { new Object { def m3() { C.super.m1.subSequence(1, 1) } } }\n" + "}");
    XtendClass c = (XtendClass) file.getXtendTypes().get(1);
    XtendFunction m = (XtendFunction) c.getMembers().get(0);
    XBlockExpression outer = (XBlockExpression) m.getExpression();
    AnonymousClass anonymousClass = (AnonymousClass) outer.getExpressions().get(0);
    XtendFunction m3 = (XtendFunction) anonymousClass.getMembers().get(0);
    XBlockExpression body = (XBlockExpression) m3.getExpression();
    XMemberFeatureCall featureCall = (XMemberFeatureCall) body.getExpressions().get(0);
    JvmIdentifiableElement feature = featureCall.getFeature();
    assertEquals("java.lang.String.subSequence(int,int)", 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) AnonymousClass(org.eclipse.xtend.core.xtend.AnonymousClass) XMemberFeatureCall(org.eclipse.xtext.xbase.XMemberFeatureCall) Test(org.junit.Test)

Example 19 with JvmIdentifiableElement

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

the class LinkingTest method testOverloadedMethods_13.

@Test
public void testOverloadedMethods_13() throws Exception {
    XtendFile file = file("import java.util.Collection\n" + "class X {\n" + "  def <T> foo(Collection<? super T> collection, Iterable<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("org.eclipse.xtext.xbase.lib.CollectionExtensions.addAll(java.util.Collection,java.lang.Iterable)", addAll.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 20 with JvmIdentifiableElement

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

the class LinkingTest method testBug403580_01.

@Test
public void testBug403580_01() throws Exception {
    XtendFile file = file("abstract class C {\n" + "	def void m() {\n" + "		overloaded [ String s | s ]\n" + "	}\n" + "	def void overloaded(Object o)" + "	def <T> void overloaded(Comparable<T> c)" + "}\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)

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