Search in sources :

Example 76 with XAbstractFeatureCall

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

the class LinkingTest method testInstanceExtensionOverStaticConversion_01.

@Test
public void testInstanceExtensionOverStaticConversion_01() throws Exception {
    XtendClass clazz = clazz("" + "class C {" + "  def void get(Object[] array, int i) {}\n" + "  def m(Object[] array) {\n" + "    array.get(0)\n" + "  }\n" + "}");
    XAbstractFeatureCall substring = findSingleFeatureCall(clazz);
    assertEquals("C.get(java.lang.Object[],int)", substring.getFeature().getIdentifier());
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XAbstractFeatureCall(org.eclipse.xtext.xbase.XAbstractFeatureCall) Test(org.junit.Test)

Example 77 with XAbstractFeatureCall

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

the class ParserTest method testRichStringFOR_02.

@Test
public void testRichStringFOR_02() throws Exception {
    XtendFunction function = function("def withForLoop() '''�FOR i: 1..10 BEFORE 'a' SEPARATOR '\t' AFTER i��ENDFOR�'''");
    final RichString richString = (RichString) function.getExpression();
    final RichStringForLoop rsFor = (RichStringForLoop) richString.getExpressions().get(1);
    assertTrue(rsFor.getForExpression() instanceof XBinaryOperation);
    assertEquals("i", rsFor.getDeclaredParam().getName());
    assertTrue(rsFor.getSeparator() instanceof XStringLiteral);
    assertTrue(rsFor.getBefore() instanceof XStringLiteral);
    assertTrue(rsFor.getAfter() instanceof XFeatureCall);
    assertTrue(((XAbstractFeatureCall) rsFor.getAfter()).getFeature().eIsProxy());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XStringLiteral(org.eclipse.xtext.xbase.XStringLiteral) RichString(org.eclipse.xtend.core.xtend.RichString) XFeatureCall(org.eclipse.xtext.xbase.XFeatureCall) XBinaryOperation(org.eclipse.xtext.xbase.XBinaryOperation) RichStringForLoop(org.eclipse.xtend.core.xtend.RichStringForLoop) XAbstractFeatureCall(org.eclipse.xtext.xbase.XAbstractFeatureCall) Test(org.junit.Test)

Example 78 with XAbstractFeatureCall

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

the class TypeProviderTest method findSingleFeatureCall.

private XAbstractFeatureCall findSingleFeatureCall(XtendClass xtendClass) {
    XtendFunction function = (XtendFunction) xtendClass.getMembers().get(xtendClass.getMembers().size() - 1);
    XBlockExpression block = (XBlockExpression) function.getExpression();
    return (XAbstractFeatureCall) block.getExpressions().get(0);
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XAbstractFeatureCall(org.eclipse.xtext.xbase.XAbstractFeatureCall)

Example 79 with XAbstractFeatureCall

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

the class TypeProviderTest method testParameterizedExtension_05.

@Test
public void testParameterizedExtension_05() throws Exception {
    XtendFile file = file("package testPackage\n" + "import org.eclipse.xtext.testing.util.ParseHelper\n" + "import org.eclipse.xtend.core.xtend.XtendFile\n" + "class C<F extends XtendFile> extends ParseHelper<F> {\n" + "	def m() {" + "		parse('')\n" + "	}\n" + "}\n");
    XtendClass c = (XtendClass) file.getXtendTypes().get(0);
    XAbstractFeatureCall parse = findSingleFeatureCall(c);
    assertEquals("org.eclipse.xtext.testing.util.ParseHelper.parse(java.lang.CharSequence)", parse.getFeature().getIdentifier());
    assertEquals("F", getType(parse).getSimpleName());
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XAbstractFeatureCall(org.eclipse.xtext.xbase.XAbstractFeatureCall) Test(org.junit.Test)

Example 80 with XAbstractFeatureCall

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

the class TypeProviderTest method testParameterizedExtension_02.

@Test
public void testParameterizedExtension_02() throws Exception {
    XtendFile file = file("package testPackage\n" + "import org.eclipse.xtext.testing.util.ParseHelper\n" + "import org.eclipse.xtend.core.xtend.XtendFile\n" + "class C<T extends ParseHelper<XtendFile>> {\n" + "	extension T\n" + "	def m() {" + "		parse('')\n" + "	}\n" + "}\n");
    XtendClass c = (XtendClass) file.getXtendTypes().get(0);
    XAbstractFeatureCall parse = findSingleFeatureCall(c);
    assertEquals("org.eclipse.xtext.testing.util.ParseHelper.parse(java.lang.CharSequence)", parse.getFeature().getIdentifier());
    assertEquals("XtendFile", getType(parse).getSimpleName());
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XAbstractFeatureCall(org.eclipse.xtext.xbase.XAbstractFeatureCall) Test(org.junit.Test)

Aggregations

XAbstractFeatureCall (org.eclipse.xtext.xbase.XAbstractFeatureCall)122 Test (org.junit.Test)105 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)104 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)42 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)23 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)21 XExpression (org.eclipse.xtext.xbase.XExpression)17 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)11 JvmIdentifiableElement (org.eclipse.xtext.common.types.JvmIdentifiableElement)9 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)8 XFeatureCall (org.eclipse.xtext.xbase.XFeatureCall)6 EObject (org.eclipse.emf.ecore.EObject)5 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)5 XMemberFeatureCall (org.eclipse.xtext.xbase.XMemberFeatureCall)4 IFeatureLinkingCandidate (org.eclipse.xtext.xbase.typesystem.computation.IFeatureLinkingCandidate)4 Resource (org.eclipse.emf.ecore.resource.Resource)3 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)3 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)3 AbstractDiagnostic (org.eclipse.xtext.diagnostics.AbstractDiagnostic)3 XClosure (org.eclipse.xtext.xbase.XClosure)3