Skip to content

Commit

Permalink
Fix parsing field types for when we have generic method receivers
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronjwood committed Oct 19, 2022
1 parent fd46275 commit 086ee27
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
18 changes: 10 additions & 8 deletions parser/class_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,19 @@ func (p *ClassParser) parsePackage(node ast.Node) {
for fileName := range pack.Files {
sortedFiles = append(sortedFiles, fileName)
}

sort.Strings(sortedFiles)
for _, fileName := range sortedFiles {
if strings.HasSuffix(fileName, "_test.go") {
continue
}

if !strings.HasSuffix(fileName, "_test.go") {
f := pack.Files[fileName]
for _, d := range f.Imports {
p.parseImports(d)
}
for _, d := range f.Decls {
p.parseFileDeclarations(d)
}
f := pack.Files[fileName]
for _, d := range f.Imports {
p.parseImports(d)
}
for _, d := range f.Decls {
p.parseFileDeclarations(d)
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions parser/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,22 @@ func getFieldType(exp ast.Expr, aliases map[string]string) (string, []string) {
return getFuncType(v, aliases)
case *ast.Ellipsis:
return getEllipsis(v, aliases)
case *ast.IndexExpr:
return getIndexExpr(v, aliases)
case *ast.IndexListExpr:
return getIndexListExpr(v, aliases)
}
return "", []string{}
}

func getIndexExpr(v *ast.IndexExpr, aliases map[string]string) (string, []string) {
return getFieldType(v.X, aliases)
}

func getIndexListExpr(v *ast.IndexListExpr, aliases map[string]string) (string, []string) {
return getFieldType(v.X, aliases)
}

func getIdent(v *ast.Ident, aliases map[string]string) (string, []string) {
if isPrimitive(v) {
return v.Name, []string{}
Expand Down

0 comments on commit 086ee27

Please sign in to comment.