Search in sources :

Example 6 with JvmIdentifiableElement

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

the class NonOverridableTypesProviderTest method assertTypeInScope.

protected void assertTypeInScope(final String typeName, final JvmMember context) {
    final JvmIdentifiableElement visibleType = this.typesFromHierarchy.getVisibleType(context, typeName);
    Assert.assertNotNull(visibleType);
    Assert.assertTrue((visibleType instanceof JvmType));
}
Also used : JvmIdentifiableElement(org.eclipse.xtext.common.types.JvmIdentifiableElement) JvmType(org.eclipse.xtext.common.types.JvmType)

Example 7 with JvmIdentifiableElement

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

the class AssignmentLinkingTest method assertImplicitReceiver.

protected void assertImplicitReceiver(String identifier, XAssignment assignment) {
    assertTrue("assignment.implicitReceiver instanceof XFeatureCall", assignment.getImplicitReceiver() instanceof XAbstractFeatureCall);
    XAbstractFeatureCall implicitReceiver = (XAbstractFeatureCall) assignment.getImplicitReceiver();
    JvmIdentifiableElement linked = implicitReceiver.getFeature();
    assertFalse("is resolved", linked.eIsProxy());
    assertEquals(identifier, linked.getIdentifier());
}
Also used : JvmIdentifiableElement(org.eclipse.xtext.common.types.JvmIdentifiableElement) XAbstractFeatureCall(org.eclipse.xtext.xbase.XAbstractFeatureCall)

Example 8 with JvmIdentifiableElement

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

the class AssignmentLinkingTest method assertLinksTo.

@SuppressWarnings("deprecation")
protected void assertLinksTo(String identifier, EClass type, XAssignment 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)
        assertNotNull("Expected issues", featureCall.getInvalidFeatureIssueCode());
    else {
        assertNull(featureCall.getInvalidFeatureIssueCode(), featureCall.getInvalidFeatureIssueCode());
        validator.assertNoErrors(featureCall);
    }
}
Also used : JvmIdentifiableElement(org.eclipse.xtext.common.types.JvmIdentifiableElement)

Example 9 with JvmIdentifiableElement

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

the class LinkingTest method testOverloadedWithLambdaArgument_01.

@Test
public void testOverloadedWithLambdaArgument_01() throws Exception {
    XtendFile file = file("import static extension com.google.common.collect.Iterables.*" + "abstract class C {\n" + "	def void m(Iterable<String> iter) {\n" + "		iter.filter [ it != null ]\n" + "	}\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("com.google.common.collect.Iterables.filter(java.lang.Iterable,com.google.common.base.Predicate)", 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 10 with JvmIdentifiableElement

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

the class LinkingTest method testQualifiedSuper.

@Test
public void testQualifiedSuper() throws Exception {
    XtendFile file = file("class B<T> { def T m1() {} }\n" + "class C extends B<String> {\n" + "  def void m2() { C.super.m1.subSequence(1, 1) } \n" + "}");
    XtendClass c = (XtendClass) file.getXtendTypes().get(1);
    XtendFunction n = (XtendFunction) c.getMembers().get(0);
    XBlockExpression body = (XBlockExpression) n.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) 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