in lib/src/solver/incompatibility.dart [280:351]
String? _tryRequiresThrough(Incompatibility other,
[Map<String, PackageDetail>? details, int? thisLine, int? otherLine]) {
if (terms.length == 1 || other.terms.length == 1) return null;
var thisNegative = _singleTermWhere((term) => !term.isPositive);
var otherNegative = other._singleTermWhere((term) => !term.isPositive);
if (thisNegative == null && otherNegative == null) return null;
var thisPositive = _singleTermWhere((term) => term.isPositive);
var otherPositive = other._singleTermWhere((term) => term.isPositive);
Incompatibility prior;
Term priorNegative;
int? priorLine;
Incompatibility latter;
int? latterLine;
if (thisNegative != null &&
otherPositive != null &&
thisNegative.package.name == otherPositive.package.name &&
thisNegative.inverse.satisfies(otherPositive)) {
prior = this;
priorNegative = thisNegative;
priorLine = thisLine;
latter = other;
latterLine = otherLine;
} else if (otherNegative != null &&
thisPositive != null &&
otherNegative.package.name == thisPositive.package.name &&
otherNegative.inverse.satisfies(thisPositive)) {
prior = other;
priorNegative = otherNegative;
priorLine = otherLine;
latter = this;
latterLine = thisLine;
} else {
return null;
}
var priorPositives = prior.terms.where((term) => term.isPositive);
var buffer = StringBuffer();
if (priorPositives.length > 1) {
var priorString =
priorPositives.map((term) => _terse(term, details)).join(' or ');
buffer.write('if $priorString then ');
} else {
var verb = prior.cause == IncompatibilityCause.dependency
? 'depends on'
: 'requires';
buffer.write('${_terse(priorPositives.first, details, allowEvery: true)} '
'$verb ');
}
buffer.write(_terse(priorNegative, details));
if (priorLine != null) buffer.write(' ($priorLine)');
buffer.write(' which ');
if (latter.cause == IncompatibilityCause.dependency) {
buffer.write('depends on ');
} else {
buffer.write('requires ');
}
buffer.write(latter.terms
.where((term) => !term.isPositive)
.map((term) => _terse(term, details))
.join(' or '));
if (latterLine != null) buffer.write(' ($latterLine)');
return buffer.toString();
}