Search in sources :

Example 66 with XtendField

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

the class UnicodeEscapeLinkingTest method testIdentifiersWithUnicode_02.

@Test
public void testIdentifiersWithUnicode_02() throws Exception {
    XtendClass clazz = clazz("class A {\n" + " String \\u0061\n" + " def m() {\n" + "	    a\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 67 with XtendField

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

the class ParserTest method testXtendField_03.

@Test
public void testXtendField_03() throws Exception {
    XtendClass clazz = clazz("class Foo { " + "  @com.google.inject.Inject java.util.Map<String,String> map" + "  @com.google.inject.Inject java.util.List myList" + "}");
    assertEquals(2, clazz.getMembers().size());
    XtendField field = (XtendField) clazz.getMembers().get(0);
    assertEquals("java.util.Map", field.getType().getType().getIdentifier());
    assertEquals("map", field.getName());
    assertEquals("java.util.Map<java.lang.String, java.lang.String>", field.getType().getIdentifier());
    field = (XtendField) clazz.getMembers().get(1);
    assertEquals("java.util.List", field.getType().getType().getIdentifier());
    assertEquals("myList", field.getName());
    assertEquals("java.util.List", field.getType().getIdentifier());
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendField(org.eclipse.xtend.core.xtend.XtendField) Test(org.junit.Test)

Example 68 with XtendField

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

the class ParserTest method testXtendField_00.

@Test
public void testXtendField_00() throws Exception {
    XtendClass clazz = clazz("class Foo { " + "  @com.google.inject.Inject java.util.Map<String,String> map" + "}");
    assertEquals(1, clazz.getMembers().size());
    XtendField field = (XtendField) clazz.getMembers().get(0);
    assertEquals("java.util.Map", field.getType().getType().getIdentifier());
    assertEquals("map", field.getName());
    assertEquals("java.util.Map<java.lang.String, java.lang.String>", field.getType().getIdentifier());
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendField(org.eclipse.xtend.core.xtend.XtendField) Test(org.junit.Test)

Example 69 with XtendField

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

the class ParserTest method testXtendField_01.

@Test
public void testXtendField_01() throws Exception {
    XtendClass clazz = clazz("class Foo { " + "  @com.google.inject.Inject java.util.Map<String,String> map def map() {null as String}" + "}");
    assertEquals(2, clazz.getMembers().size());
    XtendField field = (XtendField) clazz.getMembers().get(0);
    assertEquals("java.util.Map", field.getType().getType().getIdentifier());
    assertEquals("map", field.getName());
    assertEquals("java.util.Map<java.lang.String, java.lang.String>", field.getType().getIdentifier());
    assertTrue(clazz.getMembers().get(1) instanceof XtendFunction);
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendField(org.eclipse.xtend.core.xtend.XtendField) Test(org.junit.Test)

Example 70 with XtendField

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

the class ParserTest method testXtendField_04.

@Test
public void testXtendField_04() throws Exception {
    XtendClass clazz = clazz("class Foo { " + "  @com.google.inject.Inject val foo = 'foo'" + "  @com.google.inject.Inject var java.util.List myList" + "}");
    assertEquals(2, clazz.getMembers().size());
    XtendField field = (XtendField) clazz.getMembers().get(0);
    assertNull(field.getType());
    assertEquals("foo", field.getName());
    assertTrue(field.getInitialValue() instanceof XStringLiteral);
    field = (XtendField) clazz.getMembers().get(1);
    assertEquals("java.util.List", field.getType().getType().getIdentifier());
    assertEquals("myList", field.getName());
    assertEquals("java.util.List", field.getType().getIdentifier());
}
Also used : XStringLiteral(org.eclipse.xtext.xbase.XStringLiteral) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) 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