Search in sources :

Example 11 with XtendClass

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

the class JavaConverterTest method testTryCatchCase_02.

@Test
public void testTryCatchCase_02() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("public void checkTryCatch() {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("try {");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("} catch (IllegalArgumentException | IllegalStateException e) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("throw e;");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("} finally {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("System.out.println();");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    final String javaBody = _builder.toString();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class Test {");
    _builder_1.append(javaBody);
    _builder_1.append("}");
    final XtendClass clazz = this.toValidXtendClass(_builder_1);
    Assert.assertNotNull(clazz);
    String body = this.toXtendClassBodyDeclr(javaBody);
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("def void checkTryCatch() {");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("try {");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("} catch (IllegalArgumentException | IllegalStateException e) {");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("throw e");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("} finally {");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("System.out.println() ");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("}");
    _builder_2.newLine();
    _builder_2.append("}");
    Assert.assertEquals(_builder_2.toString(), body);
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) RichString(org.eclipse.xtend.core.xtend.RichString) Test(org.junit.Test)

Example 12 with XtendClass

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

the class JavaConverterTest method testStaticAccessCase2.

@Test
public void testStaticAccessCase2() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.Map;");
    _builder.newLine();
    _builder.append("import java.util.Map.Entry;");
    _builder.newLine();
    _builder.append("public abstract class Test implements Map.Entry<String,String>{}");
    _builder.newLine();
    XtendClass xtendClazz = this.toValidXtendClass(_builder);
    Assert.assertNotNull(xtendClazz);
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 13 with XtendClass

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

the class JavaConverterTest method testPrefixPlusMinusCase.

@Test
public void testPrefixPlusMinusCase() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("public class Clazz { ");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public static main(String[] args) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("int i=3;");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("System.out.print(\"4=\");");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("System.out.println(++i);");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("System.out.print(\"3=\");");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("System.out.println(--i);");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    XtendClass clazz = this.toValidXtendClass(_builder);
    Assert.assertNotNull(clazz);
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 14 with XtendClass

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

the class JavaConverterTest method testSimpleAssigmentCase.

@Test
public void testSimpleAssigmentCase() throws Exception {
    XtendClass xtendClazz = this.toValidXtendClass("class TestAssiment {  \n\t\t\t\tvoid doStuff() {\n\t\t\t\t\tString x = null;\n\t\t\t\t\tx = new String();\n\t\t\t\t}\n\t\t\t}");
    Assert.assertNotNull(xtendClazz);
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) Test(org.junit.Test)

Example 15 with XtendClass

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

the class JavaConverterTest method testCastCase_02.

@Test
public void testCastCase_02() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("public class TestCast {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public void foo(long value) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("int x = (int) (value >>> 56) & 0xFF;");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    XtendClass xtendClazz = this.toValidXtendClass(_builder);
    Assert.assertNotNull(xtendClazz);
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) 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