Search in sources :

Example 76 with XFeatureCall

use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.

the class TypeProviderTest method testTypeOfThisInConstructor.

@Test
public void testTypeOfThisInConstructor() throws Exception {
    XtendConstructor constructor = constructor("new(int a) {\n" + "	this()\n" + "}\n" + "new() {}");
    XBlockExpression body = (XBlockExpression) constructor.getExpression();
    XFeatureCall thisCall = (XFeatureCall) body.getExpressions().get(0);
    assertEquals("void", getType(thisCall).getIdentifier());
    assertNull(getExpectedType(thisCall));
    assertNull(getExpectedReturnType(thisCall));
}
Also used : XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendConstructor(org.eclipse.xtend.core.xtend.XtendConstructor) XFeatureCall(org.eclipse.xtext.xbase.XFeatureCall) Test(org.junit.Test)

Example 77 with XFeatureCall

use of org.eclipse.xtext.xbase.XFeatureCall 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 78 with XFeatureCall

use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.

the class LinkingShadowingTest method testStaticImport_overloaded.

@Test
public void testStaticImport_overloaded() throws Exception {
    XtendClass clazz = clazz("import static org.junit.Assert.*\n" + "class SomeClass extends org.junit.Assert {\n" + "  def void method() {\n" + "    assertTrue(false)\n" + "  }\n" + "}");
    XFeatureCall featureCall = (XFeatureCall) getFirstFeatureCall(clazz);
    assertLinksTo("org.junit.Assert.assertTrue(boolean)", featureCall);
    assertNull(featureCall.getImplicitFirstArgument());
    assertNull(featureCall.getImplicitReceiver());
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XFeatureCall(org.eclipse.xtext.xbase.XFeatureCall) Test(org.junit.Test)

Example 79 with XFeatureCall

use of org.eclipse.xtext.xbase.XFeatureCall 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)

Example 80 with XFeatureCall

use of org.eclipse.xtext.xbase.XFeatureCall 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)

Aggregations

XFeatureCall (org.eclipse.xtext.xbase.XFeatureCall)93 Test (org.junit.Test)81 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)72 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)67 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)62 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)29 JvmIdentifiableElement (org.eclipse.xtext.common.types.JvmIdentifiableElement)26 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)20 XMemberFeatureCall (org.eclipse.xtext.xbase.XMemberFeatureCall)19 XExpression (org.eclipse.xtext.xbase.XExpression)14 RichString (org.eclipse.xtend.core.xtend.RichString)7 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)7 XAbstractFeatureCall (org.eclipse.xtext.xbase.XAbstractFeatureCall)6 XtendConstructor (org.eclipse.xtend.core.xtend.XtendConstructor)5 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)5 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)5 EObject (org.eclipse.emf.ecore.EObject)4 XtendField (org.eclipse.xtend.core.xtend.XtendField)4 JvmFormalParameter (org.eclipse.xtext.common.types.JvmFormalParameter)4 ParameterInfo (org.eclipse.jdt.internal.corext.refactoring.ParameterInfo)3