List every node's children one way
authored and named differed only in whether a "..path" binding was skipped, which made two spellings of one question: what does this node contain? They could never disagree — loadDir rejects a category or folder carrying the prefix, so a group's children are never bindings, and TestReferenceErrors pins both rejections. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+3
-10
@@ -148,7 +148,7 @@ type namedNode struct {
|
|||||||
func contained(n node) []namedNode {
|
func contained(n node) []namedNode {
|
||||||
switch n := n.(type) {
|
switch n := n.(type) {
|
||||||
case *group:
|
case *group:
|
||||||
return authored(n.children)
|
return named(n.children)
|
||||||
case *choice:
|
case *choice:
|
||||||
out := make([]namedNode, len(n.items))
|
out := make([]namedNode, len(n.items))
|
||||||
for i, it := range n.items {
|
for i, it := range n.items {
|
||||||
@@ -164,7 +164,8 @@ func contained(n node) []namedNode {
|
|||||||
|
|
||||||
// named skips a bound {..path} key: it is a render edge, not containment, so using
|
// named skips a bound {..path} key: it is a render edge, not containment, so using
|
||||||
// it as a path segment would report a node under a path that does not reach it. Only
|
// it as a path segment would report a node under a path that does not reach it. Only
|
||||||
// a template's fields hold bindings, so group children go through authored.
|
// a template's fields hold bindings — loadDir rejects a category or folder carrying
|
||||||
|
// the prefix — so this one skip serves a group's children too.
|
||||||
func named(m map[string]node) []namedNode {
|
func named(m map[string]node) []namedNode {
|
||||||
out := make([]namedNode, 0, len(m))
|
out := make([]namedNode, 0, len(m))
|
||||||
for _, name := range sortedNames(m) {
|
for _, name := range sortedNames(m) {
|
||||||
@@ -176,14 +177,6 @@ func named(m map[string]node) []namedNode {
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
func authored(m map[string]node) []namedNode {
|
|
||||||
out := make([]namedNode, 0, len(m))
|
|
||||||
for _, name := range sortedNames(m) {
|
|
||||||
out = append(out, namedNode{name: name, node: m[name]})
|
|
||||||
}
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
func sortedNames(m map[string]node) []string {
|
func sortedNames(m map[string]node) []string {
|
||||||
names := make([]string, 0, len(m))
|
names := make([]string, 0, len(m))
|
||||||
for name := range m {
|
for name := range m {
|
||||||
|
|||||||
Reference in New Issue
Block a user