MCPcopy
hub / github.com/pquerna/ffjson / shouldInclude

Function shouldInclude

generator/parser.go:58–83  ·  view source on GitHub ↗
(d *ast.Object)

Source from the content-addressed store, hash-verified

56var skipenc = regexp.MustCompile("(.*)ffjson:(\\s*)((skipencoder)|(noencoder))(.*)")
57
58func shouldInclude(d *ast.Object) (bool, error) {
59 ts, ok := d.Decl.(*ast.TypeSpec)
60 if !ok {
61 return false, fmt.Errorf("Unknown type without TypeSec: %v", d)
62 }
63
64 _, ok = ts.Type.(*ast.StructType)
65 if !ok {
66 ident, ok := ts.Type.(*ast.Ident)
67 if !ok || ident.Name == "" {
68 return false, nil
69 }
70
71 // It must be in this package, and not a pointer alias
72 if strings.Contains(ident.Name, ".") || strings.Contains(ident.Name, "*") {
73 return false, nil
74 }
75
76 // if Obj is nil, we have an external type or built-in.
77 if ident.Obj == nil || ident.Obj.Decl == nil {
78 return false, nil
79 }
80 return shouldInclude(ident.Obj)
81 }
82 return true, nil
83}
84
85func ExtractStructs(inputPath string) (string, []*StructInfo, error) {
86 fset := token.NewFileSet()

Callers 1

ExtractStructsFunction · 0.85

Calls 1

ContainsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…