Search in sources :

Example 51 with XtendMember

use of org.eclipse.xtend.core.xtend.XtendMember 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 52 with XtendMember

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

the class ValueConverterExceptionProducesErrorTest method assertLiteral.

private void assertLiteral(final String expectation, final Resource resource) {
    EObject _head = IterableExtensions.<EObject>head(resource.getContents());
    final XtendFile file = ((XtendFile) _head);
    final XtendTypeDeclaration type = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
    XtendMember _head_1 = IterableExtensions.<XtendMember>head(type.getMembers());
    final XtendFunction method = ((XtendFunction) _head_1);
    XExpression _expression = method.getExpression();
    final RichString body = ((RichString) _expression);
    XExpression _head_2 = IterableExtensions.<XExpression>head(body.getExpressions());
    final RichStringLiteral singleElement = ((RichStringLiteral) _head_2);
    Assert.assertEquals(expectation, singleElement.getValue());
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) RichString(org.eclipse.xtend.core.xtend.RichString) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) EObject(org.eclipse.emf.ecore.EObject) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) RichStringLiteral(org.eclipse.xtend.core.xtend.RichStringLiteral) XExpression(org.eclipse.xtext.xbase.XExpression)

Example 53 with XtendMember

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

the class XtendValidationTest method testJavaDocRefs_5.

@Test
public void testJavaDocRefs_5() throws Exception {
    XtendFile file = file("class Foo {\n" + "/**" + " * {@link List}\n" + " */" + "String field = '42'\n" + "def doStuff(){}" + "}");
    XtendClass clazz = (XtendClass) file.getXtendTypes().get(0);
    XtendMember field = clazz.getMembers().get(0);
    helper.assertError(field, XTEND_FIELD, IssueCodes.JAVA_DOC_LINKING_DIAGNOSTIC, "javaDoc", "List", "cannot be resolved to a type");
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) Test(org.junit.Test)

Example 54 with XtendMember

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

the class XtendValidationTest method testJavaDocRefs_4.

@Test
public void testJavaDocRefs_4() throws Exception {
    XtendFile file = file("class Foo {\n" + "/**" + " * {@link List}\n" + " */" + "String field = '42'\n" + "def doStuff(){}" + "}");
    XtendClass clazz = (XtendClass) file.getXtendTypes().get(0);
    XtendMember field = clazz.getMembers().get(0);
    helper.assertError(field, XTEND_FIELD, IssueCodes.JAVA_DOC_LINKING_DIAGNOSTIC, "javaDoc", "List", "cannot be resolved to a type");
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) Test(org.junit.Test)

Example 55 with XtendMember

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

the class XtendValidationTest method testJavaDocRefs_6.

@Test
public void testJavaDocRefs_6() throws Exception {
    XtendFile file = file("class Foo {\n" + "/**" + " * {@link    List}\n" + " */" + "String field = '42'\n" + "def doStuff(){}" + "}");
    XtendClass clazz = (XtendClass) file.getXtendTypes().get(0);
    XtendMember field = clazz.getMembers().get(0);
    helper.assertError(field, XTEND_FIELD, IssueCodes.JAVA_DOC_LINKING_DIAGNOSTIC, "javaDoc", "List", "cannot be resolved to a type");
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) Test(org.junit.Test)

Aggregations

XtendMember (org.eclipse.xtend.core.xtend.XtendMember)175 Test (org.junit.Test)140 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)131 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)119 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)101 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)91 XExpression (org.eclipse.xtext.xbase.XExpression)84 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)57 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)56 XtendField (org.eclipse.xtend.core.xtend.XtendField)33 EObject (org.eclipse.emf.ecore.EObject)17 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)15 IResolvedTypes (org.eclipse.xtext.xbase.typesystem.IResolvedTypes)14 AnonymousClass (org.eclipse.xtend.core.xtend.AnonymousClass)12 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)12 XtendParameter (org.eclipse.xtend.core.xtend.XtendParameter)10 XtendConstructor (org.eclipse.xtend.core.xtend.XtendConstructor)9 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)9 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)8 JvmType (org.eclipse.xtext.common.types.JvmType)8