Search in sources :

Example 31 with XtendMember

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

the class ValidationBug433213Test method test_02.

@Test
public void test_02() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class C {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def <T> m() {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("new Object {");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("def T m2() {}");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final XtendFile file = this.parser.parse(_builder);
        final XtendTypeDeclaration c = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
        XtendMember _head = IterableExtensions.<XtendMember>head(c.getMembers());
        final XtendFunction m = ((XtendFunction) _head);
        XExpression _expression = m.getExpression();
        final XBlockExpression body = ((XBlockExpression) _expression);
        XExpression _head_1 = IterableExtensions.<XExpression>head(body.getExpressions());
        final AnonymousClass anon = ((AnonymousClass) _head_1);
        XtendMember _head_2 = IterableExtensions.<XtendMember>head(anon.getMembers());
        final XtendFunction m2 = ((XtendFunction) _head_2);
        final JvmTypeReference returnType = m2.getReturnType();
        final JvmType t = returnType.getType();
        Assert.assertNotNull("notNull", t);
        Assert.assertFalse("t.eIsProxy", t.eIsProxy());
        this.helper.assertNoErrors(file);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) AnonymousClass(org.eclipse.xtend.core.xtend.AnonymousClass) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) XExpression(org.eclipse.xtext.xbase.XExpression) JvmType(org.eclipse.xtext.common.types.JvmType) Test(org.junit.Test)

Example 32 with XtendMember

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

the class CustomClassesTest method testEnumLiteralDefaults.

@Test
public void testEnumLiteralDefaults() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("enum Foo { BAR }");
        final XtendEnum enumeration = this.enumeration(_builder.toString());
        final XtendMember literal = enumeration.getMembers().get(0);
        Assert.assertTrue(literal.isStatic());
        Assert.assertTrue(literal.isFinal());
        Assert.assertEquals(JvmVisibility.PUBLIC, literal.getVisibility());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendMember(org.eclipse.xtend.core.xtend.XtendMember) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendEnum(org.eclipse.xtend.core.xtend.XtendEnum) Test(org.junit.Test)

Example 33 with XtendMember

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

the class CustomClassesTest method testFieldInAnnotationDefaults.

@Test
public void testFieldInAnnotationDefaults() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("annotation Foo { int foo }");
        XtendMember _get = this.annotationType(_builder.toString()).getMembers().get(0);
        final XtendField field = ((XtendField) _get);
        Assert.assertTrue(field.isFinal());
        Assert.assertTrue(field.isStatic());
        Assert.assertEquals(JvmVisibility.PUBLIC, field.getVisibility());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendMember(org.eclipse.xtend.core.xtend.XtendMember) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendField(org.eclipse.xtend.core.xtend.XtendField) Test(org.junit.Test)

Example 34 with XtendMember

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

the class CustomClassesTest method testFieldInInterfaceDefaults.

@Test
public void testFieldInInterfaceDefaults() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("interface Foo { int foo }");
        XtendMember _get = this.interfaze(_builder.toString()).getMembers().get(0);
        final XtendField field = ((XtendField) _get);
        Assert.assertTrue(field.isFinal());
        Assert.assertTrue(field.isStatic());
        Assert.assertEquals(JvmVisibility.PUBLIC, field.getVisibility());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendMember(org.eclipse.xtend.core.xtend.XtendMember) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendField(org.eclipse.xtend.core.xtend.XtendField) Test(org.junit.Test)

Example 35 with XtendMember

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

the class CustomNestedClassesTest method clazz.

@Override
protected XtendClass clazz(final String string) throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C { ");
    _builder.append(string);
    _builder.append(" }");
    XtendMember _head = IterableExtensions.<XtendMember>head(this.file(_builder.toString()).getXtendTypes().get(0).getMembers());
    return ((XtendClass) _head);
}
Also used : XtendMember(org.eclipse.xtend.core.xtend.XtendMember) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

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