use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class JavaConverterTest method testRichStringCase.
@Test
public void testRichStringCase() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("public class Clazz {");
_builder.newLine();
_builder.append("\t");
_builder.append("static int i = 2;");
_builder.newLine();
_builder.append("\t");
_builder.append("static String a = (i-i)+i+\"4=\"+(--i)+\"1=\"+(i++)+i;");
_builder.newLine();
_builder.append("\t");
_builder.append("static String b =\"4=\"+\"1=\";");
_builder.newLine();
_builder.append("}");
XtendClass clazz = this.toValidXtendClass(_builder);
Assert.assertNotNull(clazz);
XtendMember _get = clazz.getMembers().get(1);
XtendField xtendMember = ((XtendField) _get);
Assert.assertEquals("a", xtendMember.getName());
XExpression _initialValue = xtendMember.getInitialValue();
Assert.assertTrue((_initialValue instanceof RichString));
XtendMember _get_1 = clazz.getMembers().get(2);
XExpression _initialValue_1 = ((XtendField) _get_1).getInitialValue();
Assert.assertTrue((_initialValue_1 instanceof RichString));
Assert.assertEquals("static package String a=\'\'\'�(i - i)��i�4=�({i=i - 1})�1=�(i++)��i�\'\'\'", this.toXtendClassBodyDeclr("static String a = (i-i)+i+\"4=\"+(--i)+\"1=\"+(i++)+i;"));
}
use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class JavaConverterTest method testSuperCalls.
@Test
public void testSuperCalls() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("import java.awt.TextField;");
_builder.newLine();
_builder.append("public class Clazz extends TextField {");
_builder.newLine();
_builder.append("\t");
_builder.append("public Clazz() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("super();");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("public Clazz(String txt) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("super(txt);");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public String toString() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("Object o = super.textListener;");
_builder.newLine();
_builder.append("\t\t");
_builder.append("return super.toString();");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
XtendClass clazz = this.toValidXtendClass(_builder);
XtendMember _get = clazz.getMembers().get(0);
Assert.assertEquals(JvmVisibility.PUBLIC, ((XtendConstructor) _get).getVisibility());
}
use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class JavaConverterTest method testLambdaCase.
@Test
public void testLambdaCase() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("import java.awt.event.ActionEvent;");
_builder.newLine();
_builder.append("import java.awt.event.ActionListener;");
_builder.newLine();
_builder.append("class Clazz {");
_builder.newLine();
_builder.append("\t");
_builder.append("ActionListener listener = new ActionListener() {");
_builder.newLine();
_builder.append("\t \t");
_builder.append("public void actionPerformed(ActionEvent arg0) {");
_builder.newLine();
_builder.append("\t \t\t");
_builder.append("arg0.getID();");
_builder.newLine();
_builder.append("\t \t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("};");
_builder.newLine();
_builder.append("}");
XtendClass clazz = this.toValidXtendClass(_builder);
Assert.assertNotNull(clazz);
XtendMember _get = clazz.getMembers().get(0);
XtendField xtendMember = ((XtendField) _get);
Assert.assertEquals("listener", xtendMember.getName());
XExpression _initialValue = xtendMember.getInitialValue();
Assert.assertTrue((_initialValue instanceof XClosure));
}
use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class JavaConverterTest method testRichStringSpecialCase.
@Test
public void testRichStringSpecialCase() throws Exception {
XtendClass clazz = this.toValidXtendClass("class Z { String richTxt = \"a\" +\"\" +\"\'\" +\"s \" + \"\'\'\' no �\'foo\'.length� side-effect \'\'\'\";}");
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));
}
use of org.eclipse.xtend.core.xtend.XtendMember 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());
}
Aggregations