(d *ast.Object)
| 56 | var skipenc = regexp.MustCompile("(.*)ffjson:(\\s*)((skipencoder)|(noencoder))(.*)") |
| 57 | |
| 58 | func 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 | |
| 85 | func ExtractStructs(inputPath string) (string, []*StructInfo, error) { |
| 86 | fset := token.NewFileSet() |
no test coverage detected
searching dependent graphs…