Search in sources :

Example 36 with XtendClass

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

the class JavaConverterTest method testConstructorCase.

@Test
public void testConstructorCase() throws Exception {
    XtendClass clazz = this.toValidXtendClass("public class Clazz { public Clazz(){this(1);}public Clazz(int i){}}");
    XtendMember _get = clazz.getMembers().get(0);
    Assert.assertEquals(JvmVisibility.PUBLIC, ((XtendConstructor) _get).getVisibility());
    XtendMember _get_1 = clazz.getMembers().get(1);
    Assert.assertEquals(JvmVisibility.PUBLIC, ((XtendConstructor) _get_1).getVisibility());
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) Test(org.junit.Test)

Example 37 with XtendClass

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

the class JavaConverterTest method testSimpleInstanceOfCase.

@Test
public void testSimpleInstanceOfCase() throws Exception {
    XtendClass xtendClazz = this.toValidXtendClass("class Test {  void doStuff() { String x = null; if(!(x instanceof String)) x = \"\";}");
    Assert.assertNotNull(xtendClazz);
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) Test(org.junit.Test)

Example 38 with XtendClass

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

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

the class JvmModelTests method testJvmTypeParameter_05.

@Test
public void testJvmTypeParameter_05() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class Foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def < foo() {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(this.file(_builder.toString(), false, false).getXtendTypes());
        final JvmGenericType clazz = this._iXtendJvmAssociations.getInferredType(((XtendClass) _head));
        final JvmOperation member = IterableExtensions.<JvmOperation>head(Iterables.<JvmOperation>filter(clazz.getMembers(), JvmOperation.class));
        Assert.assertNull(member);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : JvmOperation(org.eclipse.xtext.common.types.JvmOperation) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) Test(org.junit.Test)

Example 40 with XtendClass

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

the class JvmModelTests method testJvmTypeParameter_07.

@Test
public void testJvmTypeParameter_07() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class Foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def <T> String foo() {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(this.file(_builder.toString(), false, false).getXtendTypes());
        final JvmGenericType clazz = this._iXtendJvmAssociations.getInferredType(((XtendClass) _head));
        final JvmOperation member = IterableExtensions.<JvmOperation>head(Iterables.<JvmOperation>filter(clazz.getMembers(), JvmOperation.class));
        EList<JvmTypeParameter> _typeParameters = member.getTypeParameters();
        String _plus = ("" + _typeParameters);
        Assert.assertEquals(_plus, 1, member.getTypeParameters().size());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : JvmOperation(org.eclipse.xtext.common.types.JvmOperation) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) JvmTypeParameter(org.eclipse.xtext.common.types.JvmTypeParameter) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) Test(org.junit.Test)

Aggregations

XtendClass (org.eclipse.xtend.core.xtend.XtendClass)1017 Test (org.junit.Test)988 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)249 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)229 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)169 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)129 XAbstractFeatureCall (org.eclipse.xtext.xbase.XAbstractFeatureCall)104 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)101 XMemberFeatureCall (org.eclipse.xtext.xbase.XMemberFeatureCall)74 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)73 JvmIdentifiableElement (org.eclipse.xtext.common.types.JvmIdentifiableElement)63 XExpression (org.eclipse.xtext.xbase.XExpression)62 XFeatureCall (org.eclipse.xtext.xbase.XFeatureCall)62 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)56 XtendField (org.eclipse.xtend.core.xtend.XtendField)37 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)36 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)35 XAssignment (org.eclipse.xtext.xbase.XAssignment)19 EObject (org.eclipse.emf.ecore.EObject)18 RichString (org.eclipse.xtend.core.xtend.RichString)17