use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class ParserTest method testRichStringWithComment_00.
@Test
public void testRichStringWithComment_00() throws Exception {
XtendFunction function = function("def foo() '''first��� comment \nsecond'''");
assertTrue(function.getExpression() instanceof RichString);
RichString richString = (RichString) function.getExpression();
assertEquals(2, richString.getExpressions().size());
RichStringLiteral first = (RichStringLiteral) richString.getExpressions().get(0);
assertEquals("first", first.getValue());
RichStringLiteral second = (RichStringLiteral) richString.getExpressions().get(1);
assertEquals("second", second.getValue());
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class ParserTest method testTypeParams_3.
@Test
public void testTypeParams_3() throws Exception {
XtendFunction func = function("def <T extends CharSequence & java.io.Serializable> foo(T t) { t}");
assertEquals(1, func.getTypeParameters().size());
JvmTypeParameter tp = func.getTypeParameters().get(0);
assertEquals("T", tp.getName());
assertEquals(2, tp.getConstraints().size());
for (JvmTypeConstraint constraint : tp.getConstraints()) {
assertTrue(constraint instanceof JvmUpperBound);
}
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class ParserTest method testExtensionOnForLoopParam_01.
@Test
public void testExtensionOnForLoopParam_01() throws Exception {
XtendClass clazz = clazz("class Foo { def void m() { for(extension i: 1..2) {} } }");
assertEquals(1, clazz.getMembers().size());
XtendFunction m = (XtendFunction) clazz.getMembers().get(0);
XBlockExpression body = (XBlockExpression) m.getExpression();
assertEquals(1, body.getExpressions().size());
XForLoopExpression forLoop = (XForLoopExpression) body.getExpressions().get(0);
XtendFormalParameter parameter = (XtendFormalParameter) forLoop.getDeclaredParam();
assertTrue(parameter.isExtension());
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class ParserTest method testFunction_1.
@Test
public void testFunction_1() throws Exception {
XtendFunction func = function("def String foo() {foo}");
assertEquals("foo", func.getName());
assertTrue(((XBlockExpression) func.getExpression()).getExpressions().get(0) instanceof XFeatureCall);
assertEquals(0, func.getParameters().size());
assertNotNull(func.getReturnType());
assertEquals(0, func.getTypeParameters().size());
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class ParserTest method testCreateExtension_01.
@Test
public void testCreateExtension_01() throws Exception {
XtendClass clazz = clazz("class Foo { " + " def create foo : newArrayList('foo') getListWithFooAnd(String s) {" + " foo.add(s)" + " }" + "}");
assertEquals(1, clazz.getMembers().size());
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
assertNotNull(func.getCreateExtensionInfo().getCreateExpression());
assertEquals("foo", func.getCreateExtensionInfo().getName());
}
Aggregations