use of org.eclipse.xtext.xbase.typesystem.computation.IFeatureLinkingCandidate 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.typesystem.computation.IFeatureLinkingCandidate in project xtext-xtend by eclipse.
the class XtendHyperlinkHelper method createHyperlinksForCrossRef.
@Override
protected void createHyperlinksForCrossRef(XtextResource resource, INode crossRefNode, IHyperlinkAcceptor acceptor) {
EObject crossLinkedEObject = getEObjectAtOffsetHelper().getCrossReferencedElement(crossRefNode);
if (crossLinkedEObject != null && !crossLinkedEObject.eIsProxy()) {
EObject containedElementAt = getEObjectAtOffsetHelper().resolveContainedElementAt(resource, crossRefNode.getOffset());
if (containedElementAt instanceof XAbstractFeatureCall) {
XAbstractFeatureCall casted = (XAbstractFeatureCall) containedElementAt;
if (casted.getFeature() == crossLinkedEObject) {
IFeatureLinkingCandidate candidate = getBatchTypeResolver().resolveTypes(casted).getLinkingCandidate(casted);
if (candidate instanceof IAmbiguousLinkingCandidate) {
createMultipleLinks(resource, crossRefNode, ((IAmbiguousLinkingCandidate) candidate).getAlternatives(), acceptor);
} else if (candidate instanceof ISuspiciouslyOverloadedCandidate) {
ISuspiciouslyOverloadedCandidate castedCandidate = (ISuspiciouslyOverloadedCandidate) candidate;
createMultipleLinks(resource, crossRefNode, Lists.newArrayList(castedCandidate.getChosenCandidate(), castedCandidate.getRejectedCandidate()), acceptor);
}
}
} else if (containedElementAt instanceof XConstructorCall) {
XConstructorCall casted = (XConstructorCall) containedElementAt;
if (casted.getConstructor() == crossLinkedEObject) {
IConstructorLinkingCandidate candidate = getBatchTypeResolver().resolveTypes(casted).getLinkingCandidate(casted);
if (candidate instanceof IAmbiguousLinkingCandidate) {
createMultipleLinks(resource, crossRefNode, ((IAmbiguousLinkingCandidate) candidate).getAlternatives(), acceptor);
}
}
}
}
super.createHyperlinksForCrossRef(resource, crossRefNode, acceptor);
}
use of org.eclipse.xtext.xbase.typesystem.computation.IFeatureLinkingCandidate in project xtext-xtend by eclipse.
the class SuspiciousOverloadValidationTest method assertSuspicious.
protected void assertSuspicious(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.SUSPICIOUSLY_OVERLOADED_FEATURE, 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 Function1<XAbstractFeatureCall, Boolean> _function_2 = (XAbstractFeatureCall it) -> {
return Boolean.valueOf(((!Objects.equal(it.eContainingFeature(), XbasePackage.Literals.XABSTRACT_FEATURE_CALL__IMPLICIT_RECEIVER)) && (it.getFeature() instanceof JvmOperation)));
};
final XAbstractFeatureCall featureCall = IteratorExtensions.<XAbstractFeatureCall>findLast(Iterators.<XAbstractFeatureCall>filter(block.eAllContents(), XAbstractFeatureCall.class), _function_2);
final IFeatureLinkingCandidate linkingCandidate = this._iBatchTypeResolver.resolveTypes(file).getLinkingCandidate(featureCall);
Assert.assertTrue((linkingCandidate instanceof ISuspiciouslyOverloadedCandidate));
}
use of org.eclipse.xtext.xbase.typesystem.computation.IFeatureLinkingCandidate in project xtext-xtend by eclipse.
the class SuspiciousOverloadValidationTest method assertSuspiciousInInnerClass.
protected void assertSuspiciousInInnerClass(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.SUSPICIOUSLY_OVERLOADED_FEATURE, 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 XtendClass innerType = ((XtendClass) _head_1);
XtendMember _head_2 = IterableExtensions.<XtendMember>head(innerType.getMembers());
final XtendFunction firstMember = ((XtendFunction) _head_2);
XExpression _expression = firstMember.getExpression();
final XBlockExpression block = ((XBlockExpression) _expression);
final Function1<XAbstractFeatureCall, Boolean> _function_2 = (XAbstractFeatureCall it) -> {
return Boolean.valueOf(((!Objects.equal(it.eContainingFeature(), XbasePackage.Literals.XABSTRACT_FEATURE_CALL__IMPLICIT_RECEIVER)) && (it.getFeature() instanceof JvmOperation)));
};
final XAbstractFeatureCall featureCall = IteratorExtensions.<XAbstractFeatureCall>findLast(Iterators.<XAbstractFeatureCall>filter(block.eAllContents(), XAbstractFeatureCall.class), _function_2);
final IFeatureLinkingCandidate linkingCandidate = this._iBatchTypeResolver.resolveTypes(file).getLinkingCandidate(featureCall);
Assert.assertTrue((linkingCandidate instanceof ISuspiciouslyOverloadedCandidate));
}
Aggregations