resolveReference method
The element ref points to, or null if it doesn't exist or is
ambiguous. Never returns the hidden base node.
Implementation
TreeElement? resolveReference(TreeReference ref) {
if (!ref.isAbsolute) return null;
TreeElement? node = base;
TreeElement? result;
for (var i = 0; i < ref.size; i++) {
final name = ref.nameAt(i);
var multiplicity = ref.multiplicityAt(i);
if (multiplicity == TreeReference.indexAttribute) {
node = result = node!.getAttribute(null, name);
continue;
}
if (multiplicity == TreeReference.indexUnbound) {
if (node!.childMultiplicity(name) == 1) {
multiplicity = 0;
} else {
node = result = null;
break;
}
}
node = result = node!.getChild(name, multiplicity);
if (node == null) break;
}
if (identical(node, base) || result == null) return null;
if (result.isPartial) throw PartialElementEncounteredException();
return result;
}