Search in sources :

Example 16 with XAssignment

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

the class AssignmentLinkingTest method testParameter.

@SuppressWarnings("deprecation")
@Test
public void testParameter() throws Exception {
    XtendClass clazz = clazz("class SomeClass {\n" + "  def void method(String aString) {\n" + "    aString = 'foo'\n" + "  }\n" + "}");
    XAssignment assignment = getLastAssignment(clazz);
    assertNotNull("feature is available", assignment.getFeature());
    JvmIdentifiableElement linked = assignment.getFeature();
    assertFalse("is resolved", linked.eIsProxy());
    assertEquals("aString", linked.getIdentifier());
    assertTrue(TypesPackage.Literals.JVM_FORMAL_PARAMETER.isInstance(linked));
    assertNull(assignment.getInvalidFeatureIssueCode(), assignment.getInvalidFeatureIssueCode());
}
Also used : JvmIdentifiableElement(org.eclipse.xtext.common.types.JvmIdentifiableElement) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XAssignment(org.eclipse.xtext.xbase.XAssignment) Test(org.junit.Test)

Example 17 with XAssignment

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

the class AssignmentLinkingTest method testQualifiedField.

@Test
public void testQualifiedField() throws Exception {
    XtendClass clazz = clazz("class SomeClass {\n" + "  def void method() {\n" + "    this.aString = 'foo'\n" + "  }" + "  String aString\n" + "}");
    XAssignment assignment = getLastAssignment(clazz);
    assertLinksTo("SomeClass.aString", assignment);
    assertNull(assignment.getImplicitReceiver());
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XAssignment(org.eclipse.xtext.xbase.XAssignment) Test(org.junit.Test)

Example 18 with XAssignment

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

the class AssignmentLinkingTest method testSugaredAssignment_onIt.

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

Example 19 with XAssignment

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

the class AssignmentLinkingTest method testBug447982_03.

@Test
public void testBug447982_03() throws Exception {
    XtendClass clazz = clazz("class C {\n" + "	def m() {\n" + "		x = 1\n" + "	} \n" + "	int x\n" + "	def setX(int x) {}\n" + "}");
    XAssignment assignment = getLastAssignment(clazz);
    assertLinksTo("C.x", TypesPackage.Literals.JVM_FIELD, assignment);
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XAssignment(org.eclipse.xtext.xbase.XAssignment) Test(org.junit.Test)

Example 20 with XAssignment

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

the class AssignmentLinkingTest method testBug447982_01.

@Test
public void testBug447982_01() throws Exception {
    XtendClass clazz = clazz("class C {\n" + "	def m() {\n" + "		x = 1\n" + "	} \n" + "	def x(int x) {}\n" + "	def setX(int x) {}\n" + "}");
    XAssignment assignment = getLastAssignment(clazz);
    assertLinksTo("C.setX(int)", TypesPackage.Literals.JVM_OPERATION, 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