Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: missing symbol information #50924

Closed
katsusan opened this issue Jan 31, 2022 · 2 comments
Closed

x/tools/gopls: missing symbol information #50924

katsusan opened this issue Jan 31, 2022 · 2 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@katsusan
Copy link

gopls version

➜  gopls git:(master) ✗ gopls -v version
Build info
----------
golang.org/x/tools/gopls master
    golang.org/x/tools/gopls@(devel)
    github.com/BurntSushi/toml@v0.4.1 h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw=
    github.com/google/go-cmp@v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38=
    golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
    golang.org/x/sys@v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0=
    golang.org/x/text@v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
    golang.org/x/tools@v0.1.7 => ../
    golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
    honnef.co/go/tools@v0.2.1 h1:/EPr//+UMMXwMTkXvCCoaJDq8cpjMO80Ou+L4PDo2mY=
    mvdan.cc/gofumpt@v0.1.1 h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA=
    mvdan.cc/xurls/v2@v2.3.0 h1:59Olnbt67UKpxF1EwVBopJvkSUBmgtb468E4GVWIZ1I=

go env

➜  gopls git:(master) ✗ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.1"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/root/projects/tools/gopls/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1107766469=/tmp/go-build -gno-record-gcc-switches"

What did you do?

  1. open $GOROOT\src\cmd\compile\internal\escape\escape.go.
  2. check the symbols listed in the outline view.

What did you expect to see?

show complete symbol information of escape.go.
by cd /usr/local/go/src/cmd/compile/internal/escape; gopls symbols escape.go, there should be
at most 84 symbols(less than upper limit 100) in this file.

➜  ~ cd /usr/local/go/src/cmd/compile/internal/escape; gopls symbols escape.go
got symbols: 84  // len(docSymbols) from `docSymbols, err = source.DocumentSymbols(ctx, snapshot, fh)`
batch Struct 90:6-90:11
        allLocs Field 91:2-91:9
        blankLoc Field 95:2-95:10
        closures Field 92:2-92:10
        heapLoc Field 94:2-94:9
closure Struct 100:6-100:13
        clo Field 102:2-102:5
        k Field 101:2-101:3
escape Struct 107:6-107:12
        batch Field 108:2-108:8
        curfn Field 110:2-110:7
        labels Field 112:2-112:8
        loopDepth Field 118:2-118:11
...

What did you see instead?

image

Editor and settings

Logs

// rpc trace log

[Trace - 15:18:13.191 PM] Sending request 'textDocument/documentSymbol - (145)'.
Params: {"textDocument":{"uri":"file:///usr/local/go/src/cmd/compile/internal/escape/escape.go"}}

[Trace - 15:18:13.924 PM] Received response 'textDocument/documentSymbol - (145)' in 732ms.
Result: [{"name":"batch","detail":"struct{...}","kind":23,"range":{"start":{"line":89,"character":5},"end":{"line":95,"character":1}},"selectionRange":{"start":{"line":89,"character":5},"end":{"line":89,"character":10}}},{"name":"Fmt","detail":"(n ir.Node)","kind":12,"range":{"start":{"line":174,"character":0},"end":{"line":174,"character":26}},"selectionRange":{"start":{"line":174,"character":5},"end":{"line":174,"character":8}}},{"name":"Batch","detail":"(fns []*ir.Func, recursive bool)","kind":12,"range":{"start":{"line":208,"character":0},"end":{"line":208,"character":42}},"selectionRange":{"start":{"line":208,"character":5},"end":{"line":208,"character":10}}},{"name":"numEscResults","detail":"untyped int","kind":14,"range":{"start":{"line":1724,"character":0},"end":{"line":1724,"character":23}},"selectionRange":{"start":{"line":1724,"character":6},"end":{"line":1724,"character":19}}},{"name":"Funcs","detail":"(all []ir.Node)","kind":12,"range":{"start":{"line":1819,"character":0},"end":{"line":1819,"character":25}},"selectionRange":{"start":{"line":1819,"character":5},"end":{"line":1819,"character":10}}},{"name":"escFuncUnknown","detail":"untyped int","kind":14,"range":{"start":{"line":1823,"character":0},"end":{"line":1828,"character":1}},"selectionRange":{"start":{"line":1824,"character":1},"end":{"line":1824,"character":15}}},{"name":"escFuncPlanned","detail":"untyped int","kind":14,"range":{"start":{"line":1823,"character":0},"end":{"line":1828,"character":1}},"selectionRange":{"start":{"line":1825,"character":1},"end":{"line":1825,"character":15}}},{"name":"escFuncStarted","detail":"untyped int","kind":14,"range":{"start":{"line":1823,"character":0},"end":{"line":1828,"character":1}},"selectionRange":{"start":{"line":1826,"character":1},"end":{"line":1826,"character":15}}},{"name":"escFuncTagged","detail":"untyped int","kind":14,"range":{"start":{"line":1823,"character":0},"end":{"line":1828,"character":1}},"selectionRange":{"start":{"line":1827,"character":1},"end":{"line":1827,"character":14}}},{"name":"labelState","detail":"int","kind":16,"range":{"start":{"line":1831,"character":5},"end":{"line":1831,"character":19}},"selectionRange":{"start":{"line":1831,"character":5},"end":{"line":1831,"character":15}}},{"name":"looping","detail":"labelState","kind":14,"range":{"start":{"line":1833,"character":0},"end":{"line":1836,"character":1}},"selectionRange":{"start":{"line":1834,"character":1},"end":{"line":1834,"character":8}}},{"name":"nonlooping","detail":"labelState","kind":14,"range":{"start":{"line":1833,"character":0},"end":{"line":1836,"character":1}},"selectionRange":{"start":{"line":1835,"character":1},"end":{"line":1835,"character":11}}},{"name":"HeapAllocReason","detail":"(n ir.Node)","kind":12,"range":{"start":{"line":1998,"character":0},"end":{"line":1998,"character":38}},"selectionRange":{"start":{"line":1998,"character":5},"end":{"line":1998,"character":20}}},{"name":"UnsafeUintptrNote","detail":"untyped string","kind":14,"range":{"start":{"line":2046,"character":0},"end":{"line":2046,"character":42}},"selectionRange":{"start":{"line":2046,"character":6},"end":{"line":2046,"character":23}}},{"name":"UintptrEscapesNote","detail":"untyped string","kind":14,"range":{"start":{"line":2050,"character":0},"end":{"line":2050,"character":44}},"selectionRange":{"start":{"line":2050,"character":6},"end":{"line":2050,"character":24}}}]
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jan 31, 2022
@gopherbot gopherbot added this to the Unreleased milestone Jan 31, 2022
@findleyr
Copy link
Contributor

Hi, thanks for the report.

I have a theory. Can you confirm which folder you opened as your workspace root? I suspect it is not inside of go/src/cmd, is that right?

@findleyr findleyr added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jan 31, 2022
@katsusan
Copy link
Author

katsusan commented Feb 1, 2022

Hi @findleyr, escape.go is outside the workspace folder(/root/projects/tools/gopls),
after trying gopls symbols in go source directory, indeed it looks like there is a behaviour difference.

Thanks for reminding this, since it works as intended (I can see there are ranking mechanisms
for symbols in workspace_symbol.go), close the issue for avoiding noise.

@katsusan katsusan closed this as completed Feb 1, 2022
@golang golang locked and limited conversation to collaborators Feb 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants