Skip to content

Commit ba892bb

Browse files
adonovangopherbot
authored andcommitted
go/types/internal/play: show formatted AST
Change-Id: Id9690ff1430d8a089b6ddf098ffa622c420f0979 Reviewed-on: https://go-review.googlesource.com/c/tools/+/492255 gopls-CI: kokoro <[email protected]> Reviewed-by: Robert Findley <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Alan Donovan <[email protected]> Run-TryBot: Alan Donovan <[email protected]>
1 parent 7df6af8 commit ba892bb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

go/types/internal/play/play.go

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"encoding/json"
1616
"fmt"
1717
"go/ast"
18+
"go/format"
1819
"go/token"
1920
"go/types"
2021
"io"
@@ -167,6 +168,10 @@ func handleSelectJSON(w http.ResponseWriter, req *http.Request) {
167168

168169
// Syntax debug output.
169170
ast.Fprint(out, fset, path[0], nil) // ignore errors
171+
fmt.Fprintf(out, "\n")
172+
173+
// Pretty-print of selected syntax.
174+
format.Node(out, fset, path[0])
170175

171176
// Clean up the messy temp file name.
172177
outStr := strings.ReplaceAll(out.String(), f.Name(), "play.go")
@@ -263,4 +268,5 @@ function onLoad() {
263268
const mainCSS = `
264269
textarea { width: 6in; }
265270
body { color: gray; }
271+
div#out { font-family: monospace; font-size: 80%; }
266272
`

0 commit comments

Comments
 (0)