Skip to content

Commit e8722c0

Browse files
committed
go/types/internal/play: show types.Selection information
Change-Id: I668b2fa0108d9f4cdea0f1075a4c97728435edf2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/532395 Reviewed-by: Robert Findley <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent a819c61 commit e8722c0

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Diff for: go/types/internal/play/play.go

+20
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,26 @@ func handleSelectJSON(w http.ResponseWriter, req *http.Request) {
173173
}
174174
}
175175

176+
// selection x.f information (if cursor is over .f)
177+
for _, n := range path[:2] {
178+
if sel, ok := n.(*ast.SelectorExpr); ok {
179+
seln, ok := pkg.TypesInfo.Selections[sel]
180+
if ok {
181+
fmt.Fprintf(out, "Selection: %s recv=%v obj=%v type=%v indirect=%t index=%d\n\n",
182+
strings.Fields("FieldVal MethodVal MethodExpr")[seln.Kind()],
183+
seln.Recv(),
184+
seln.Obj(),
185+
seln.Type(),
186+
seln.Indirect(),
187+
seln.Index())
188+
189+
} else {
190+
fmt.Fprintf(out, "Selector is qualified identifier.\n\n")
191+
}
192+
break
193+
}
194+
}
195+
176196
// Object type information.
177197
switch n := path[0].(type) {
178198
case *ast.Ident:

0 commit comments

Comments
 (0)