Skip to content

Commit 086ee27

Browse files
committed
Fix parsing field types for when we have generic method receivers
1 parent fd46275 commit 086ee27

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

parser/class_parser.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,19 @@ func (p *ClassParser) parsePackage(node ast.Node) {
220220
for fileName := range pack.Files {
221221
sortedFiles = append(sortedFiles, fileName)
222222
}
223+
223224
sort.Strings(sortedFiles)
224225
for _, fileName := range sortedFiles {
226+
if strings.HasSuffix(fileName, "_test.go") {
227+
continue
228+
}
225229

226-
if !strings.HasSuffix(fileName, "_test.go") {
227-
f := pack.Files[fileName]
228-
for _, d := range f.Imports {
229-
p.parseImports(d)
230-
}
231-
for _, d := range f.Decls {
232-
p.parseFileDeclarations(d)
233-
}
230+
f := pack.Files[fileName]
231+
for _, d := range f.Imports {
232+
p.parseImports(d)
233+
}
234+
for _, d := range f.Decls {
235+
p.parseFileDeclarations(d)
234236
}
235237
}
236238
}

parser/field.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,22 @@ func getFieldType(exp ast.Expr, aliases map[string]string) (string, []string) {
4040
return getFuncType(v, aliases)
4141
case *ast.Ellipsis:
4242
return getEllipsis(v, aliases)
43+
case *ast.IndexExpr:
44+
return getIndexExpr(v, aliases)
45+
case *ast.IndexListExpr:
46+
return getIndexListExpr(v, aliases)
4347
}
4448
return "", []string{}
4549
}
4650

51+
func getIndexExpr(v *ast.IndexExpr, aliases map[string]string) (string, []string) {
52+
return getFieldType(v.X, aliases)
53+
}
54+
55+
func getIndexListExpr(v *ast.IndexListExpr, aliases map[string]string) (string, []string) {
56+
return getFieldType(v.X, aliases)
57+
}
58+
4759
func getIdent(v *ast.Ident, aliases map[string]string) (string, []string) {
4860
if isPrimitive(v) {
4961
return v.Name, []string{}

0 commit comments

Comments
 (0)