The problem: astcopy functions do not copy ast.Object fields because some projects may not care about them at all (go/types.Object is better and deprecates ast.Object). But if for whatever reason user must copy objects, there will be troubles.
I'm proposing this functions:
func IdentObjects(dst, src *ast.Ident) {/**/}
func ScopeObjects(dst, src *ast.Scope) {/**/}
func PackageObjects(dst, src *ast.Package) {/**/}
So, copy of *ast.Ident with objects may be done this way:
y := astcopy.Ident(x)
astcopy.IdentObjects(y, x)
This can be wrapped by user into simple function:
func copyIdent(x) *ast.Ident {
y := astcopy.Ident(x)
astcopy.IdentObjects(y, x)
return y
}
This way, we avoid quite expensive copy that may be unnecessary in a first place and provide a way to copy objects if they are required.
Note that copying objects may be non-trivial.
It needs some investigation and problem overview beforehand.
The problem: astcopy functions do not copy
ast.Objectfields because some projects may not care about them at all (go/types.Objectis better and deprecatesast.Object). But if for whatever reason user must copy objects, there will be troubles.I'm proposing this functions:
So, copy of
*ast.Identwith objects may be done this way:This can be wrapped by user into simple function:
This way, we avoid quite expensive copy that may be unnecessary in a first place and provide a way to copy objects if they are required.
Note that copying objects may be non-trivial.
It needs some investigation and problem overview beforehand.