1
0
mirror of https://github.com/golang/go synced 2024-11-22 04:24:39 -07:00

go/ast: don't remove function bodies when filtering exports

This is a semantic but no API change. It is a cleaner
implementation of pure filtering. Applications that
need function bodies stripped can easily do this them-
selves.

R=rsc
CC=golang-dev
https://golang.org/cl/5206046
This commit is contained in:
Robert Griesemer 2011-10-06 16:07:56 -07:00
parent a64b2699c4
commit 3e46699958

View File

@ -18,8 +18,7 @@ func exportFilter(name string) bool {
// only exported nodes remain: all top-level identifiers which are not exported
// and their associated information (such as type, initial value, or function
// body) are removed. Non-exported fields and methods of exported types are
// stripped, and the function bodies of exported functions are set to nil.
// The File.Comments list is not changed.
// stripped. The File.Comments list is not changed.
//
// FileExports returns true if there are exported declarationa;
// it returns false otherwise.
@ -206,9 +205,6 @@ func FilterDecl(decl Decl, f Filter) bool {
d.Specs = filterSpecList(d.Specs, f)
return len(d.Specs) > 0
case *FuncDecl:
if f == exportFilter {
d.Body = nil // strip body
}
return f(d.Name.Name)
}
return false