unify complex

This commit is contained in:
Natalie Weizenbaum 2016-07-28 17:40:52 -07:00
parent 9caecbe0d0
commit ab2d8ae3f3

View File

@ -186,8 +186,8 @@ class Extender {
var unified = _unifyComplex(group1, group2);
if (unified == null) return null;
if (unified.members.length > 1) return null;
return unified.members.first.members;
if (unified.length > 1) return null;
return unified.first;
});
var choices = [[initialCombinator]];
@ -519,6 +519,24 @@ class Extender {
return result;
}
List<List<ComplexSelectorComponent> _unifyComplex(
List<SimpleSelector> complex1, List<SimpleSelector> complex2) {
var base1 = complex1.members.last;
var base2 = complex2.members.last;
if (base1 is CompoundSelector && base2 is CompoundSelector) {
var unified = _unifyCompound(base2.components, base1.components);
if (unified == null) return null;
return weave([
base1.components.take(base1.components.length - 1).toList(),
base2.components.take(base2.components.length - 1).toList()
..add(unified)
]);
} else {
return null;
}
}
CompoundSelector _unifyCompound(List<SimpleSelector> compound1,
List<SimpleSelector> compound2) {
var result = compound2;