Update dependencies (#5518)

This commit is contained in:
hongming
2023-02-12 23:09:20 +08:00
committed by GitHub
parent d3b35fb2da
commit a979342f56
1486 changed files with 126660 additions and 71128 deletions

View File

@@ -13,7 +13,7 @@ import (
// be set to nil and no transformations will be applied to children of the
// element.
type Transformer interface {
Transform(v interface{}) (interface{}, error)
Transform(interface{}) (interface{}, error)
}
// Transform iterates the AST and calls the Transform function on the
@@ -116,6 +116,9 @@ func Transform(t Transformer, x interface{}) (interface{}, error) {
}
return y, nil
case *Head:
if y.Reference, err = transformRef(t, y.Reference); err != nil {
return nil, err
}
if y.Name, err = transformVar(t, y.Name); err != nil {
return nil, err
}
@@ -327,7 +330,7 @@ func TransformComprehensions(x interface{}, f func(interface{}) (Value, error))
// GenericTransformer implements the Transformer interface to provide a utility
// to transform AST nodes using a closure.
type GenericTransformer struct {
f func(x interface{}) (interface{}, error)
f func(interface{}) (interface{}, error)
}
// NewGenericTransformer returns a new GenericTransformer that will transform
@@ -414,3 +417,15 @@ func transformVar(t Transformer, v Var) (Var, error) {
}
return r, nil
}
func transformRef(t Transformer, r Ref) (Ref, error) {
r1, err := Transform(t, r)
if err != nil {
return nil, err
}
r2, ok := r1.(Ref)
if !ok {
return nil, fmt.Errorf("illegal transform: %T != %T", r, r2)
}
return r2, nil
}