use of org.eclipse.xtext.xbase.typesystem.computation.ILinkingCandidate 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);
final IResolvedTypes resolvedTypes = this._iBatchTypeResolver.resolveTypes(file);
ILinkingCandidate _switchResult = null;
XExpression _last = IterableExtensions.<XExpression>last(block.getExpressions());
final XExpression featureOrConstructorCall = _last;
boolean _matched = false;
if (featureOrConstructorCall instanceof XAbstractFeatureCall) {
_matched = true;
_switchResult = resolvedTypes.getLinkingCandidate(((XAbstractFeatureCall) featureOrConstructorCall));
}
if (!_matched) {
if (featureOrConstructorCall instanceof XConstructorCall) {
_matched = true;
_switchResult = resolvedTypes.getLinkingCandidate(((XConstructorCall) featureOrConstructorCall));
}
}
if (!_matched) {
String _valueOf = String.valueOf(featureOrConstructorCall.eClass().getName());
throw new IllegalArgumentException(_valueOf);
}
final ILinkingCandidate linkingCandidate = _switchResult;
Assert.assertTrue((linkingCandidate instanceof IAmbiguousLinkingCandidate));
}
Aggregations