mirror of https://github.com/ceph/go-ceph
implements: track all public functions, including stable ones
The go source (ast) visitor will now keep track of all public functions it finds putting them into lists by category: deprecated, preview, stable. Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
parent
2ebd4bc1d5
commit
d1aa76c613
|
@ -51,6 +51,7 @@ type visitor struct {
|
||||||
docMap map[string]*goFunction
|
docMap map[string]*goFunction
|
||||||
deprecated []*goFunction
|
deprecated []*goFunction
|
||||||
preview []*goFunction
|
preview []*goFunction
|
||||||
|
stable []*goFunction
|
||||||
}
|
}
|
||||||
|
|
||||||
func newVisitor() *visitor {
|
func newVisitor() *visitor {
|
||||||
|
@ -59,6 +60,7 @@ func newVisitor() *visitor {
|
||||||
docMap: map[string]*goFunction{},
|
docMap: map[string]*goFunction{},
|
||||||
deprecated: []*goFunction{},
|
deprecated: []*goFunction{},
|
||||||
preview: []*goFunction{},
|
preview: []*goFunction{},
|
||||||
|
stable: []*goFunction{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +105,10 @@ func readDocComment(fdec *ast.FuncDecl, gfunc *goFunction) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isPublic(gfunc *goFunction) bool {
|
||||||
|
return ast.IsExported(gfunc.shortName)
|
||||||
|
}
|
||||||
|
|
||||||
func (v *visitor) checkCalled(s *ast.SelectorExpr) {
|
func (v *visitor) checkCalled(s *ast.SelectorExpr) {
|
||||||
ident, ok := s.X.(*ast.Ident)
|
ident, ok := s.X.(*ast.Ident)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -141,13 +147,14 @@ func (v *visitor) Visit(node ast.Node) ast.Visitor {
|
||||||
}
|
}
|
||||||
readDocComment(n, gfunc)
|
readDocComment(n, gfunc)
|
||||||
v.currentFunc = gfunc
|
v.currentFunc = gfunc
|
||||||
if gfunc.isDeprecated {
|
if isPublic(gfunc) {
|
||||||
v.deprecated = append(v.deprecated, gfunc)
|
if gfunc.isDeprecated {
|
||||||
logger.Printf("rem1 %v\n", v.deprecated)
|
v.deprecated = append(v.deprecated, gfunc)
|
||||||
}
|
} else if gfunc.isPreview {
|
||||||
if gfunc.isPreview {
|
v.preview = append(v.preview, gfunc)
|
||||||
v.preview = append(v.preview, gfunc)
|
} else {
|
||||||
logger.Printf("rem2 %v\n", v.preview)
|
v.stable = append(v.stable, gfunc)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return v
|
return v
|
||||||
case *ast.CallExpr:
|
case *ast.CallExpr:
|
||||||
|
|
Loading…
Reference in New Issue