File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -30,8 +30,10 @@ import (
3030 "strings"
3131
3232 "golang.org/x/tools/go/ast/astutil"
33+ "golang.org/x/tools/go/ast/inspector"
3334 "golang.org/x/tools/go/packages"
3435 "golang.org/x/tools/go/types/typeutil"
36+ "golang.org/x/tools/internal/astutil/cursor"
3537 "golang.org/x/tools/internal/typeparams"
3638)
3739
@@ -161,6 +163,15 @@ func handleSelectJSON(w http.ResponseWriter, req *http.Request) {
161163 innermostExpr = e
162164 }
163165 }
166+ // Show the cursor stack too.
167+ // It's usually the same, but may differ in edge
168+ // cases (e.g. around FuncType.Func).
169+ inspect := inspector .New ([]* ast.File {file })
170+ if cur , ok := cursor .Root (inspect ).FindPos (startPos , endPos ); ok {
171+ fmt .Fprintf (out , "Cursor.FindPos().Stack() = %v\n " , cur .Stack (nil ))
172+ } else {
173+ fmt .Fprintf (out , "Cursor.FindPos() failed\n " )
174+ }
164175 fmt .Fprintf (out , "\n " )
165176
166177 // Expression type information
You can’t perform that action at this time.
0 commit comments