Search in sources :

Example 86 with JvmIdentifiableElement

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

the class LinkingErrorTest method testFieldsAreNotSugared_01.

@Test
public void testFieldsAreNotSugared_01() throws Exception {
    XtendClass clazz = clazz("class A {\n" + " String getFoo\n" + " def String doStuff() {\n" + "	    this.foo\n" + "	}");
    XMemberFeatureCall call = (XMemberFeatureCall) ((XBlockExpression) ((XtendFunction) clazz.getMembers().get(1)).getExpression()).getExpressions().get(0);
    JvmIdentifiableElement feature = call.getFeature();
    assertTrue(feature.eIsProxy());
}
Also used : 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 87 with JvmIdentifiableElement

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

the class LinkingErrorTest method testFieldsAreNotSugared.

@Test
public void testFieldsAreNotSugared() throws Exception {
    XtendClass clazz = clazz("class A {\n" + " String getFoo\n" + " def String doStuff() {\n" + "	    foo\n" + "	}");
    XFeatureCall call = (XFeatureCall) ((XBlockExpression) ((XtendFunction) clazz.getMembers().get(1)).getExpression()).getExpressions().get(0);
    JvmIdentifiableElement feature = call.getFeature();
    assertTrue(feature.eIsProxy());
}
Also used : 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 88 with JvmIdentifiableElement

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

the class LinkingShadowingTest method testLocalVariable_shadows_parameter.

@SuppressWarnings("deprecation")
@Test
public void testLocalVariable_shadows_parameter() throws Exception {
    XtendClass clazz = clazz("class SomeClass {\n" + "  def method(String aString) {\n" + "    val String aString = null\n" + "    aString\n" + "  }\n" + "}");
    XAbstractFeatureCall featureCall = getFeatureCall(clazz, 1);
    assertNotNull("feature is available", featureCall.getFeature());
    JvmIdentifiableElement linked = featureCall.getFeature();
    assertFalse("is resolved", linked.eIsProxy());
    assertEquals("aString", linked.getIdentifier());
    assertTrue(XbasePackage.Literals.XVARIABLE_DECLARATION.isInstance(linked));
    assertNull(featureCall.getInvalidFeatureIssueCode(), featureCall.getInvalidFeatureIssueCode());
}
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 89 with JvmIdentifiableElement

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

the class LinkingTest method testOverloadedMethods_19.

@Test
public void testOverloadedMethods_19() throws Exception {
    XtendFile file = file("import java.util.Collection\n" + "class X {\n" + "  def <T> foo(Collection<? super T> collection, Iterable<? extends T> elements) {\n" + "    collection.<T>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,T[])", 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 90 with JvmIdentifiableElement

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

the class LinkingTest method testSugarOverTypeLiteral_04.

@Test
public void testSugarOverTypeLiteral_04() throws Exception {
    XtendFile file = file("import org.eclipse.emf.ecore.EPackage\n" + "class C {\n" + "	def m(Object it) {\n" + "		EPackage" + "	}" + "	def void getEPackage(String s) {}\n" + "}\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("org.eclipse.emf.ecore.EPackage", 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)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