@@ -199,7 +199,7 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
199
199
200
200
// extract AST information for all packages
201
201
packages .Visit (pkgs , nil , func (pkg * packages.Package ) {
202
- for root , _ := range wantedRoots {
202
+ for root := range wantedRoots {
203
203
pkgInfo := pkgInfos [pkg .PkgPath ]
204
204
relDir , err := filepath .Rel (root , pkgInfo .PkgDir )
205
205
if err != nil || noExtractRe .MatchString (relDir ) {
@@ -397,15 +397,15 @@ func extractObjects(tw *trap.Writer, scope *types.Scope, scopeLabel trap.Label)
397
397
// do not appear as objects in any scope, so they have to be dealt
398
398
// with separately in extractMethods.
399
399
if funcObj , ok := obj .(* types.Func ); ok {
400
- populateTypeParamParents (tw , funcObj .Type ().(* types.Signature ).TypeParams (), obj )
401
- populateTypeParamParents (tw , funcObj .Type ().(* types.Signature ).RecvTypeParams (), obj )
400
+ populateTypeParamParents (funcObj .Type ().(* types.Signature ).TypeParams (), obj )
401
+ populateTypeParamParents (funcObj .Type ().(* types.Signature ).RecvTypeParams (), obj )
402
402
}
403
403
// Populate type parameter parents for named types. Note that we
404
404
// skip type aliases as the original type should be the parent
405
405
// of any type parameters.
406
406
if typeNameObj , ok := obj .(* types.TypeName ); ok && ! typeNameObj .IsAlias () {
407
407
if tp , ok := typeNameObj .Type ().(* types.Named ); ok {
408
- populateTypeParamParents (tw , tp .TypeParams (), obj )
408
+ populateTypeParamParents (tp .TypeParams (), obj )
409
409
}
410
410
}
411
411
extractObject (tw , obj , lbl )
@@ -431,8 +431,8 @@ func extractMethod(tw *trap.Writer, meth *types.Func) trap.Label {
431
431
if ! exists {
432
432
// Populate type parameter parents for methods. They do not appear as
433
433
// objects in any scope, so they have to be dealt with separately here.
434
- populateTypeParamParents (tw , meth .Type ().(* types.Signature ).TypeParams (), meth )
435
- populateTypeParamParents (tw , meth .Type ().(* types.Signature ).RecvTypeParams (), meth )
434
+ populateTypeParamParents (meth .Type ().(* types.Signature ).TypeParams (), meth )
435
+ populateTypeParamParents (meth .Type ().(* types.Signature ).RecvTypeParams (), meth )
436
436
extractObject (tw , meth , methlbl )
437
437
}
438
438
@@ -490,7 +490,7 @@ func extractObject(tw *trap.Writer, obj types.Object, lbl trap.Label) {
490
490
func extractObjectTypes (tw * trap.Writer ) {
491
491
// calling `extractType` on a named type will extract all methods defined
492
492
// on it, which will add new objects. Therefore we need to do this first
493
- // before we loops over all objects and emit them.
493
+ // before we loop over all objects and emit them.
494
494
changed := true
495
495
for changed {
496
496
changed = tw .ForEachObject (extractObjectType )
@@ -1129,11 +1129,9 @@ func extractExpr(tw *trap.Writer, expr ast.Expr, parent trap.Label, idx int) {
1129
1129
// each child over its preceding child (usually either 1 for assigning increasing indices, or
1130
1130
// -1 for decreasing indices)
1131
1131
func extractExprs (tw * trap.Writer , exprs []ast.Expr , parent trap.Label , idx int , dir int ) {
1132
- if exprs != nil {
1133
- for _ , expr := range exprs {
1134
- extractExpr (tw , expr , parent , idx )
1135
- idx += dir
1136
- }
1132
+ for _ , expr := range exprs {
1133
+ extractExpr (tw , expr , parent , idx )
1134
+ idx += dir
1137
1135
}
1138
1136
}
1139
1137
@@ -1389,13 +1387,10 @@ func extractStmt(tw *trap.Writer, stmt ast.Stmt, parent trap.Label, idx int) {
1389
1387
// each child over its preceding child (usually either 1 for assigning increasing indices, or
1390
1388
// -1 for decreasing indices)
1391
1389
func extractStmts (tw * trap.Writer , stmts []ast.Stmt , parent trap.Label , idx int , dir int ) {
1392
- if stmts != nil {
1393
- for _ , stmt := range stmts {
1394
- extractStmt (tw , stmt , parent , idx )
1395
- idx += dir
1396
- }
1390
+ for _ , stmt := range stmts {
1391
+ extractStmt (tw , stmt , parent , idx )
1392
+ idx += dir
1397
1393
}
1398
-
1399
1394
}
1400
1395
1401
1396
// extractDecl extracts AST information for the given declaration
@@ -1944,7 +1939,7 @@ func extractTypeParamDecls(tw *trap.Writer, fields *ast.FieldList, parent trap.L
1944
1939
}
1945
1940
1946
1941
// populateTypeParamParents sets `parent` as the parent of the elements of `typeparams`
1947
- func populateTypeParamParents (tw * trap. Writer , typeparams * types.TypeParamList , parent types.Object ) {
1942
+ func populateTypeParamParents (typeparams * types.TypeParamList , parent types.Object ) {
1948
1943
if typeparams != nil {
1949
1944
for idx := 0 ; idx < typeparams .Len (); idx ++ {
1950
1945
setTypeParamParent (typeparams .At (idx ), parent )
@@ -1966,16 +1961,6 @@ func getObjectBeingUsed(tw *trap.Writer, ident *ast.Ident) types.Object {
1966
1961
}
1967
1962
}
1968
1963
1969
- // tryGetGenericType returns the generic type of `tp`, and a boolean indicating
1970
- // whether it is the same as `tp`.
1971
- func tryGetGenericType (tp types.Type ) (* types.Named , bool ) {
1972
- if namedType , ok := tp .(* types.Named ); ok {
1973
- originType := namedType .Origin ()
1974
- return originType , namedType == originType
1975
- }
1976
- return nil , false
1977
- }
1978
-
1979
1964
// trackInstantiatedStructFields tries to give the fields of an instantiated
1980
1965
// struct type underlying `tp` the same labels as the corresponding fields of
1981
1966
// the generic struct type. This is so that when we come across the
0 commit comments