Run New, NewTemplate and FakeStruct through one bind pipeline naming where they differ
This commit is contained in:
@@ -32,7 +32,7 @@ func (f *Generator) NewTemplate(input string) (*Template, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("fejkdata: %w", err)
|
||||
}
|
||||
if err := bindInline(n, "template", f.categories, checkScope); err != nil {
|
||||
if err := inlineBinding(n, "template", f.categories).bind(); err != nil {
|
||||
return nil, fmt.Errorf("fejkdata: %w", err)
|
||||
}
|
||||
return &Template{g: f, n: n}, nil
|
||||
@@ -146,17 +146,17 @@ func inputValue(input string) (any, error) {
|
||||
return raw, nil
|
||||
}
|
||||
|
||||
// bindInline links an inline node's references against root and runs check over it, naming its
|
||||
// nodes from label.
|
||||
func bindInline(n node, label string, root map[string]node, check func(nodeScope) error) error {
|
||||
// inlineBinding binds an inline node against root, naming its nodes from label.
|
||||
func inlineBinding(n node, label string, root map[string]node) binding {
|
||||
scope := inlineScope(n, label)
|
||||
return binding{scope: scope, link: func() error { return linkInline(n, label, scope, root) }}
|
||||
}
|
||||
|
||||
func linkInline(n node, label string, scope nodeScope, root map[string]node) error {
|
||||
if t, isTemplate := n.(*template); isTemplate && t.drawGroup != "" {
|
||||
return fmt.Errorf("%s: drawGroup %q names nothing, since nothing can reference an inline template; drop it", label, t.drawGroup)
|
||||
}
|
||||
scope := inlineScope(n, label)
|
||||
if err := linkNodeRefs(scope, root); err != nil {
|
||||
return err
|
||||
}
|
||||
return check(scope)
|
||||
return linkNodeRefs(scope, root)
|
||||
}
|
||||
|
||||
// linkNodeRefs binds the references in an inline node's templates against the
|
||||
|
||||
Reference in New Issue
Block a user