x/tools/cmd/guru: implements output is strange when cursor is over the interface keyword #20003
Comments
The guru implements mode calls This effect can also be observed with a describe query (describe also calls fun.go:
Output of
Output of
The fix to your problem would be to continue to the type name, if the type node occurs in an case *ast.ArrayType,
*ast.StructType,
*ast.FuncType,
*ast.InterfaceType,
*ast.MapType,
*ast.ChanType:
+ // Continue to type name, if possible.
+ if spec, ok := path[1].(*ast.TypeSpec); ok {
+ path = append([]ast.Node{spec.Name}, path...)
+ continue
+ }
return path, actionType For an example, similar to yours: iface.go:
Output of
This change also affects the output of the describe query.
If this is not considered problematic, I could submit a CL. /cc @alandonovan
|
For a simple main.go file:
When I run an implements query with the cursor over
Fooer
, I get reasonable output:However, when the cursor is moved a few bytes to the right (over
interface
) the output looks much different:It seems like
guru
is now identifying the selection as an anonymous interface and not the type declaration for theFooer
interface.I'm finding the behavior in the latter case to be difficult to build tooling around, mostly because:
type.name
field is long and hard to read for anything but the most simple interfacesto
entry makes it seem like there is an extra interface in the programtype.pos
field is no longer populatedThe text was updated successfully, but these errors were encountered: