use of org.eclipse.xtext.xbase.XClosure in project xtext-xtend by eclipse.
the class LinkingTest method testBug345433_02.
@Test
public void testBug345433_02() throws Exception {
String classAsString = "import static extension org.eclipse.xtext.GrammarUtil.*\n" + "class Foo {" + " org.eclipse.xtext.Grammar grammar\n" + " def function1() {\n" + " grammar.containedRuleCalls.filter(e0 | " + " !e0.isAssigned() && !e0.isEObjectRuleCall()" + " ).map(e1 | e1.rule)\n" + " }\n" + "}";
XtendClass clazz = clazz(classAsString);
IResourceValidator validator = ((XtextResource) clazz.eResource()).getResourceServiceProvider().getResourceValidator();
List<Issue> issues = validator.validate(clazz.eResource(), CheckMode.ALL, CancelIndicator.NullImpl);
assertTrue("Resource contained errors : " + issues.toString(), issues.isEmpty());
XtendFunction function = (XtendFunction) clazz.getMembers().get(1);
XExpression body = function.getExpression();
LightweightTypeReference bodyType = getType(body);
assertEquals("java.lang.Iterable<org.eclipse.xtext.AbstractRule>", bodyType.getIdentifier());
XBlockExpression block = (XBlockExpression) body;
XMemberFeatureCall featureCall = (XMemberFeatureCall) block.getExpressions().get(0);
XClosure closure = (XClosure) featureCall.getMemberCallArguments().get(0);
JvmFormalParameter e1 = closure.getFormalParameters().get(0);
assertEquals("e1", e1.getSimpleName());
assertEquals("org.eclipse.xtext.RuleCall", getType(e1).getIdentifier());
}
Aggregations