use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class ParserTest method testBug427257.
@Test
public void testBug427257() throws Exception {
XtendClass clazz = clazz("class C { def Iterable<=>String> m() { emptyList } }");
assertEquals(1, clazz.getMembers().size());
XtendFunction m = (XtendFunction) clazz.getMembers().get(0);
JvmParameterizedTypeReference returnType = (JvmParameterizedTypeReference) m.getReturnType();
JvmTypeReference typeArgument = returnType.getArguments().get(0);
assertTrue(typeArgument instanceof XFunctionTypeRef);
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class ParserTest method testRichStringFOR_03.
@Test
public void testRichStringFOR_03() throws Exception {
XtendFunction function = function("def withForLoop(String it) '''�it��val it = 1..10��FOR i: it SEPARATOR it��ENDFOR�'''");
final RichString richString = (RichString) function.getExpression();
assertTrue(richString.getExpressions().get(0) instanceof RichStringLiteral);
assertTrue(richString.getExpressions().get(1) instanceof XFeatureCall);
JvmOperation operation = associations.getDirectlyInferredOperation(function);
assertSame(operation.getParameters().get(0), ((XAbstractFeatureCall) richString.getExpressions().get(1)).getFeature());
assertTrue(richString.getExpressions().get(2) instanceof RichStringLiteral);
assertTrue(richString.getExpressions().get(3) instanceof XVariableDeclaration);
assertTrue(richString.getExpressions().get(4) instanceof RichStringLiteral);
assertTrue(richString.getExpressions().get(5) instanceof RichStringForLoop);
final RichStringForLoop rsFor = (RichStringForLoop) richString.getExpressions().get(5);
assertTrue(rsFor.getForExpression() instanceof XFeatureCall);
assertSame(richString.getExpressions().get(3), ((XAbstractFeatureCall) rsFor.getForExpression()).getFeature());
assertEquals("i", rsFor.getDeclaredParam().getName());
assertTrue(rsFor.getSeparator() instanceof XFeatureCall);
assertSame(richString.getExpressions().get(3), ((XAbstractFeatureCall) rsFor.getSeparator()).getFeature());
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class UTF8ParserErrorTest method testInvalidIdentifier_01.
@Test
public void testInvalidIdentifier_01() throws Exception {
XtendFunction func = function("def \\u0020invalidStart() {}");
assertEquals("invalidStart", func.getName());
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class UTF8ParserErrorTest method testIdentifiers_02.
@Test
public void testIdentifiers_02() throws Exception {
XtendFunction func = function("def invalid\\u0020Part() {}");
assertEquals("invalidPart", func.getName());
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class UTF8ParserErrorTest method testInvalidReference_01.
@Test
public void testInvalidReference_01() throws Exception {
XtendFunction func = function("def m() { \\u0020invalidStart }");
XBlockExpression block = (XBlockExpression) func.getExpression();
XFeatureCall featureCall = (XFeatureCall) block.getExpressions().get(0);
String featureName = featureCall.getConcreteSyntaxFeatureName();
assertEquals("\\u0020invalidStart", featureName);
assertTrue(featureCall.getFeature().eIsProxy());
List<Diagnostic> errorList = func.eResource().getErrors();
assertEquals(2, errorList.size());
XtextLinkingDiagnostic diagnostic = (XtextLinkingDiagnostic) errorList.get(1);
assertTrue(diagnostic.getMessage().contains("invalidStart"));
}
Aggregations