Skip to content

Commit

Permalink
add: 使用原生 ast 采集生产 bean
Browse files Browse the repository at this point in the history
  • Loading branch information
cyz-home committed Jul 27, 2023
1 parent 4875921 commit c1705c3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion parser/goast.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ func getAstGoFileParser(fileName string) GoFileParser {
for _, d := range decl.Doc.List {
doc = doc + d.Text + "\n"
}
} else {
// 没有注释, 跳过
continue
}
for _, spec := range decl.Specs {
Spec := spec.(*ast.TypeSpec)
Expand All @@ -99,7 +102,7 @@ func getAstGoFileParser(fileName string) GoFileParser {
attr.Name = strings.Trim(expr.Sel.Name, ".")
}
attr.TypeAlias = expr.X.(*ast.Ident).Name
attr.TypeName = "*" + attr.TypeAlias + "." + expr.Sel.Name
attr.TypeName = attr.TypeAlias + "." + expr.Sel.Name
attr.TypeImport = got.Imports[attr.TypeAlias]
} else if expr, ok := field.Type.(*ast.Ident); ok {
if attr.Name == "" {
Expand Down Expand Up @@ -146,6 +149,9 @@ func getAstGoFileParser(fileName string) GoFileParser {
}
}
}
if attr.TypeName == "" {
continue
}
t.Attrs[attr.Name] = attr
t.AttrsSort = append(t.AttrsSort, attr.Name)
}
Expand Down

0 comments on commit c1705c3

Please sign in to comment.