resolve method

List<InspectNode> resolve(
  1. String selector
)

Every node selector could mean — an id first, then a name matched the way matching matches.

One list rather than one node, because how to answer "several" is up to the caller and differs per call site: a crop refuses and lists them, a tree read might narrow to the outermost. What is not the caller's business is the rule — an id is exact and a name is a search — and having that written once is why this is here rather than in each of them.

An id wins outright when it hits: ids are positions like 0/3/1/0 and no widget is called that, so the two vocabularies do not collide in practice — and if one ever did, the exact answer is the right one.

Implementation

List<InspectNode> resolve(String selector) {
  var exact = nodeAt(selector);
  return exact != null ? [exact] : matching(selector).toList();
}