use of org.eclipse.xtext.xbase.XFeatureCall 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.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class ParserTest method testFunction_6.
@Test
public void testFunction_6() throws Exception {
XtendFunction func = function("override dispatch foo(String s) { foo('x')}");
assertEquals("foo", func.getName());
assertTrue(((XBlockExpression) func.getExpression()).getExpressions().get(0) instanceof XFeatureCall);
assertEquals(1, func.getParameters().size());
assertNull(func.getReturnType());
assertTrue(func.isOverride());
assertTrue(func.isDispatch());
assertEquals(0, func.getTypeParameters().size());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class ParserTest method testFunction_3.
@Test
public void testFunction_3() throws Exception {
XtendFunction func = function("def foo(String s, Integer i) {s}");
assertEquals("foo", func.getName());
assertTrue(((XBlockExpression) func.getExpression()).getExpressions().get(0) instanceof XFeatureCall);
assertEquals(2, func.getParameters().size());
assertEquals("s", func.getParameters().get(0).getName());
assertNotNull(func.getParameters().get(0).getParameterType());
assertEquals("i", func.getParameters().get(1).getName());
assertNotNull(func.getParameters().get(1).getParameterType());
assertNull(func.getReturnType());
assertEquals(0, func.getTypeParameters().size());
}
use of org.eclipse.xtext.xbase.XFeatureCall 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.xtext.xbase.XFeatureCall 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