use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class AmbiguityValidationTest method assertAmbiguous.
protected void assertAmbiguous(final CharSequence contents, final String... messageParts) {
final XtendFile file = this.getParsedXtendFile(contents);
final EList<Resource.Diagnostic> errors = file.eResource().getErrors();
Assert.assertEquals(errors.toString(), 1, errors.size());
Resource.Diagnostic _head = IterableExtensions.<Resource.Diagnostic>head(errors);
final AbstractDiagnostic singleError = ((AbstractDiagnostic) _head);
Assert.assertEquals(singleError.getMessage(), IssueCodes.AMBIGUOUS_FEATURE_CALL, singleError.getCode());
final Function1<String, String> _function = (String it) -> {
return Strings.toUnixLineSeparator(it);
};
final Consumer<String> _function_1 = (String it) -> {
final String message = singleError.getMessage();
boolean _contains = message.contains(it);
boolean _not = (!_contains);
if (_not) {
Assert.assertEquals(it, message);
}
};
ListExtensions.<String, String>map(((List<String>) Conversions.doWrapArray(messageParts)), _function).forEach(_function_1);
final XtendTypeDeclaration firstType = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
XtendMember _head_1 = IterableExtensions.<XtendMember>head(firstType.getMembers());
final XtendFunction firstMember = ((XtendFunction) _head_1);
XExpression _expression = firstMember.getExpression();
final XBlockExpression block = ((XBlockExpression) _expression);
XExpression _last = IterableExtensions.<XExpression>last(block.getExpressions());
final XAbstractFeatureCall featureCall = ((XAbstractFeatureCall) _last);
final IFeatureLinkingCandidate linkingCandidate = this._iBatchTypeResolver.resolveTypes(file).getLinkingCandidate(featureCall);
Assert.assertTrue((linkingCandidate instanceof IAmbiguousLinkingCandidate));
}
use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class AssignmentLinkingTest method assertImplicitReceiver.
protected void assertImplicitReceiver(String identifier, XAssignment assignment) {
assertTrue("assignment.implicitReceiver instanceof XFeatureCall", assignment.getImplicitReceiver() instanceof XAbstractFeatureCall);
XAbstractFeatureCall implicitReceiver = (XAbstractFeatureCall) assignment.getImplicitReceiver();
JvmIdentifiableElement linked = implicitReceiver.getFeature();
assertFalse("is resolved", linked.eIsProxy());
assertEquals(identifier, linked.getIdentifier());
}
use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testExtensionMethodCall_04.
@Test
public void testExtensionMethodCall_04() throws Exception {
XtendClass clazz = clazz("" + "abstract class MyIterable implements Iterable<String> {" + " def doSomething() {\n" + " this.filter [ s.toUpperCase != null ]\n" + " }\n" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
final XAbstractFeatureCall call = (XAbstractFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
assertEquals("org.eclipse.xtext.xbase.lib.IterableExtensions.filter(java.lang.Iterable,org.eclipse.xtext.xbase.lib.Functions$Function1)", call.getFeature().getIdentifier());
JvmOperation operation = associator.getDirectlyInferredOperation(func);
assertEquals("Iterable<String>", operation.getReturnType().getSimpleName());
}
use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testBug400807.
@Test
public void testBug400807() throws Exception {
XtendFile file = file("package testPackage\n" + "import bug400807.Bug400807\n" + "class C {\n" + " def Bug400807 m() {\n" + " [ string ]\n" + " }\n" + "}\n");
XtendClass c = (XtendClass) file.getXtendTypes().get(0);
XtendFunction m = (XtendFunction) c.getMembers().get(0);
XBlockExpression body = (XBlockExpression) m.getExpression();
XClosure lambda = (XClosure) body.getExpressions().get(0);
XBlockExpression innerBody = (XBlockExpression) lambda.getExpression();
XAbstractFeatureCall string = (XAbstractFeatureCall) innerBody.getExpressions().get(0);
assertEquals("bug400807.Bug400807Param.getString()", string.getFeature().getIdentifier());
}
use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testExtensionOverInstanceIfIncompatible_01.
@Test
public void testExtensionOverInstanceIfIncompatible_01() throws Exception {
XtendClass clazz = clazz("" + "class C {" + " def put(java.util.Map<String, String> map, Integer i, Integer j) {\n" + " map.put(i, j)\n" + " }\n" + "}");
XAbstractFeatureCall substring = findSingleFeatureCall(clazz);
assertEquals("C.put(java.util.Map,java.lang.Integer,java.lang.Integer)", substring.getFeature().getIdentifier());
}
Aggregations