Search in sources :

Example 26 with XtendField

use of org.eclipse.xtend.core.xtend.XtendField in project xtext-xtend by eclipse.

the class JavaConverterTest method testRichStringSpecialCase2.

@Test
public void testRichStringSpecialCase2() throws Exception {
    XtendClass clazz = this.toValidXtendClass((("class Z { String richTxt = \"test\" + \"\'\'\'�FOR a: \'123\'.toCharArray SEPARATOR \',\\n  \\t\'�\\n" + "a\\n") + "�ENDFOR�\'\'\'\";}"));
    Assert.assertNotNull(clazz);
    XtendMember _get = clazz.getMembers().get(0);
    XtendField xtendMember = ((XtendField) _get);
    Assert.assertEquals("richTxt", xtendMember.getName());
    XExpression _initialValue = xtendMember.getInitialValue();
    Assert.assertFalse((_initialValue instanceof RichString));
}
Also used : RichString(org.eclipse.xtend.core.xtend.RichString) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) XExpression(org.eclipse.xtext.xbase.XExpression) XtendField(org.eclipse.xtend.core.xtend.XtendField) Test(org.junit.Test)

Example 27 with XtendField

use of org.eclipse.xtend.core.xtend.XtendField in project xtext-xtend by eclipse.

the class UnicodeEscapeLinkingTest method testIdentifiersWithUnicode_01.

@Test
public void testIdentifiersWithUnicode_01() throws Exception {
    XtendClass clazz = clazz("class A {\n" + " String a\n" + " def m() {\n" + "	    \\u0061\n" + "	}\n" + "}");
    XFeatureCall call = (XFeatureCall) ((XBlockExpression) ((XtendFunction) clazz.getMembers().get(1)).getExpression()).getExpressions().get(0);
    JvmIdentifiableElement feature = call.getFeature();
    assertFalse(feature.eIsProxy());
    assertSame(feature, associator.getJvmField((XtendField) clazz.getMembers().get(0)));
}
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) XtendField(org.eclipse.xtend.core.xtend.XtendField) Test(org.junit.Test)

Example 28 with XtendField

use of org.eclipse.xtend.core.xtend.XtendField in project xtext-xtend by eclipse.

the class ParserTest method testExtensionOnLambdaParameter_01.

@Test
public void testExtensionOnLambdaParameter_01() throws Exception {
    XtendClass clazz = clazz("class Foo { val x = [ extension String a, String b | 0 ] }");
    assertEquals(1, clazz.getMembers().size());
    XtendField f = (XtendField) clazz.getMembers().get(0);
    XClosure initializer = (XClosure) f.getInitialValue();
    List<JvmFormalParameter> parameters = initializer.getDeclaredFormalParameters();
    assertEquals(2, parameters.size());
    XtendFormalParameter firstParameter = (XtendFormalParameter) parameters.get(0);
    assertTrue(firstParameter.isExtension());
    XtendFormalParameter secondParameter = (XtendFormalParameter) parameters.get(1);
    assertFalse(secondParameter.isExtension());
}
Also used : JvmFormalParameter(org.eclipse.xtext.common.types.JvmFormalParameter) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XClosure(org.eclipse.xtext.xbase.XClosure) XtendFormalParameter(org.eclipse.xtend.core.xtend.XtendFormalParameter) XtendField(org.eclipse.xtend.core.xtend.XtendField) Test(org.junit.Test)

Example 29 with XtendField

use of org.eclipse.xtend.core.xtend.XtendField in project xtext-xtend by eclipse.

the class LinkingTest method testRelativeImports.

@Test
public void testRelativeImports() throws Exception {
    XtendFile file = file("package annotation class X {\n" + "  Annotation failed\n" + "  java.lang.annotation.Annotation success\n" + "  reflect.AccessibleObject failedToo\n" + "  Thread.State anotherSuccess\n" + "  Thread$State thirdSuccess\n" + "}");
    XtendClass xClass = (XtendClass) file.getXtendTypes().get(0);
    XtendField failed = (XtendField) xClass.getMembers().get(0);
    assertTrue("Annotation", failed.getType().getType().eIsProxy());
    XtendField success = (XtendField) xClass.getMembers().get(1);
    assertFalse("java.lang.annotation", success.getType().getType().eIsProxy());
    XtendField failedToo = (XtendField) xClass.getMembers().get(2);
    assertTrue("reflect.AccessibleObject", failedToo.getType().getType().eIsProxy());
    XtendField anotherSuccess = (XtendField) xClass.getMembers().get(3);
    assertFalse("Thread.State", anotherSuccess.getType().getType().eIsProxy());
    XtendField thirdSuccess = (XtendField) xClass.getMembers().get(4);
    assertFalse("Thread$State", thirdSuccess.getType().getType().eIsProxy());
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendField(org.eclipse.xtend.core.xtend.XtendField) Test(org.junit.Test)

Example 30 with XtendField

use of org.eclipse.xtend.core.xtend.XtendField in project xtext-xtend by eclipse.

the class CodeStyleValidationTest method testInferedApiField01.

@Test
public void testInferedApiField01() throws Exception {
    XtendField field = field("public val f = \"foo\" ");
    helper.assertError(field, XTEND_FIELD, API_TYPE_INFERENCE);
}
Also used : XtendField(org.eclipse.xtend.core.xtend.XtendField) Test(org.junit.Test)

Aggregations

XtendField (org.eclipse.xtend.core.xtend.XtendField)71 Test (org.junit.Test)50 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)38 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)33 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)29 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)23 XExpression (org.eclipse.xtext.xbase.XExpression)23 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)14 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)12 EObject (org.eclipse.emf.ecore.EObject)8 RichString (org.eclipse.xtend.core.xtend.RichString)7 XtendConstructor (org.eclipse.xtend.core.xtend.XtendConstructor)6 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)6 XClosure (org.eclipse.xtext.xbase.XClosure)6 JvmIdentifiableElement (org.eclipse.xtext.common.types.JvmIdentifiableElement)5 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)5 XtendAnnotationType (org.eclipse.xtend.core.xtend.XtendAnnotationType)4 JvmFormalParameter (org.eclipse.xtext.common.types.JvmFormalParameter)4 IResolvedTypes (org.eclipse.xtext.xbase.typesystem.IResolvedTypes)4 AnonymousClass (org.eclipse.xtend.core.xtend.AnonymousClass)3