Search in sources :

Example 21 with XAssignment

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

the class AssignmentLinkingTest method getAssignment.

protected XAssignment getAssignment(XtendClass clazz, int assignmentInFunction) {
    XtendFunction function = (XtendFunction) clazz.getMembers().get(0);
    XBlockExpression body = (XBlockExpression) function.getExpression();
    List<XExpression> expressions = body.getExpressions();
    int idx = assignmentInFunction;
    if (idx == -1)
        idx = expressions.size() - 1;
    XAssignment result = (XAssignment) expressions.get(idx);
    return result;
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XExpression(org.eclipse.xtext.xbase.XExpression) XAssignment(org.eclipse.xtext.xbase.XAssignment)

Example 22 with XAssignment

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

the class AssignmentLinkingTest method testUnqualifiedField_onIt.

@Test
public void testUnqualifiedField_onIt() throws Exception {
    XtendClass clazz = clazz("class SomeClass {\n" + "  def void method(testdata.FieldAccess it) {\n" + "    stringField = 'foo'\n" + "  }" + "}");
    XAssignment assignment = getLastAssignment(clazz);
    assertLinksTo("testdata.FieldAccess.stringField", assignment);
    assertImplicitReceiver("it", assignment);
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XAssignment(org.eclipse.xtext.xbase.XAssignment) Test(org.junit.Test)

Aggregations

XAssignment (org.eclipse.xtext.xbase.XAssignment)22 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)19 Test (org.junit.Test)19 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)4 XFeatureCall (org.eclipse.xtext.xbase.XFeatureCall)3 XtendConstructor (org.eclipse.xtend.core.xtend.XtendConstructor)2 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)2 JvmIdentifiableElement (org.eclipse.xtext.common.types.JvmIdentifiableElement)2 XConstructorCall (org.eclipse.xtext.xbase.XConstructorCall)2 XExpression (org.eclipse.xtext.xbase.XExpression)2 EPackage (org.eclipse.emf.ecore.EPackage)1 RichString (org.eclipse.xtend.core.xtend.RichString)1 RichStringLiteral (org.eclipse.xtend.core.xtend.RichStringLiteral)1 XtendAnnotationType (org.eclipse.xtend.core.xtend.XtendAnnotationType)1 XtendEnum (org.eclipse.xtend.core.xtend.XtendEnum)1 XtendField (org.eclipse.xtend.core.xtend.XtendField)1 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)1 XtendFormalParameter (org.eclipse.xtend.core.xtend.XtendFormalParameter)1 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)1 XtendInterface (org.eclipse.xtend.core.xtend.XtendInterface)1