Skip to content

Commit

Permalink
unsupported-field: Deleted unsupported fields from result struct. (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekhabarov authored Mar 10, 2020
1 parent 7fa09e9 commit 8c3ecaa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 38 deletions.
7 changes: 3 additions & 4 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ func inspect(
}

id, fn, _, ptr := typsw(field.Type)
if id == nil {
continue
}

if fn != "" {
fname = fn
Expand Down Expand Up @@ -172,10 +175,6 @@ func typsw(fieldType ast.Expr) (id *ast.Ident, fname, typ string, ptr bool) {
case *ast.ArrayType:
id, fname, typ, ptr = typsw(t.Elt)
return

default:
typ = fmt.Sprintf("%T", t)
fname = fmt.Sprintf("unsupported_%s_%d", typ, t.Pos())
}
return
}
Expand Down
36 changes: 2 additions & 34 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,7 @@ var _ = Describe("Parser", func() {
Expect(str).To(gs.MatchAllFields(gs.Fields{
"Package": Equal("whatever"),
"Structs": gs.MatchAllKeys(gs.Keys{

"UnsupportedSlices": gs.MatchAllKeys(gs.Keys{

"unsupported_*ast.MapType_1024": gs.MatchAllFields(gs.Fields{
"Type": BeNil(),
"IsPointer": BeFalse(),
"Tags": BeZero(),
"Ord": Equal(uint8(0)),
}),
}),
"UnsupportedSlices": HaveLen(0),
}),
}))
})
Expand Down Expand Up @@ -369,30 +360,7 @@ var _ = Describe("Parser", func() {
Expect(str).To(gs.MatchAllFields(gs.Fields{
"Package": Equal("whatever"),
"Structs": gs.MatchAllKeys(gs.Keys{

"UnsupportedTypes": gs.MatchAllKeys(gs.Keys{

"unsupported_*ast.FuncType_659": gs.MatchAllFields(gs.Fields{
"Type": BeNil(),
"IsPointer": BeFalse(),
"Tags": BeZero(),
"Ord": Equal(uint8(0)),
}),

"unsupported_*ast.MapType_671": gs.MatchAllFields(gs.Fields{
"Type": BeNil(),
"IsPointer": BeFalse(),
"Tags": BeZero(),
"Ord": Equal(uint8(1)),
}),

"unsupported_*ast.MapType_692": gs.MatchAllFields(gs.Fields{
"Type": BeNil(),
"IsPointer": BeTrue(),
"Tags": BeZero(),
"Ord": Equal(uint8(2)),
}),
}),
"UnsupportedTypes": HaveLen(0),
}),
}))
})
Expand Down

0 comments on commit 8c3ecaa

Please sign in to comment.