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: fully qualify symbol names for Symbol #38273

Closed
myitcv opened this issue Apr 6, 2020 · 2 comments
Closed

x/tools/gopls: fully qualify symbol names for Symbol #38273

myitcv opened this issue Apr 6, 2020 · 2 comments
Labels
FeatureRequest FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@myitcv
Copy link
Member

myitcv commented Apr 6, 2020

What version of Go are you using (go version)?

$ go version
go version devel +801cd7c84d Thu Apr 2 09:00:44 2020 +0000 linux/amd64
$ go list -m golang.org/x/tools
golang.org/x/tools v0.0.0-20200402175326-9fc00b0a7ff6
$ go list -m golang.org/x/tools/gopls
golang.org/x/tools/gopls v0.1.8-0.20200402175326-9fc00b0a7ff6

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/myitcv/.cache/go-build"
GOENV="/home/myitcv/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/myitcv/gos"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/myitcv/.vim/plugged/govim/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build616148717=/tmp/go-build -gno-record-gcc-switches"

What did you do?

This request complements/is complemented by #37237.

Currently the workspace symbol method performs a case-insensitive search on a symbol by its name only, rather than the fully qualified path. Furthermore it returns only this name in the Name field of a SymbolInformation struct.

Consider the following cut-down example:

-- go.mod --
module github.com/myitcv/playground

go 1.12
-- main.go --
package main

import (
	"fmt"

	"github.com/myitcv/playground/p"
)

const name = "main"

func main() {
	fmt.Println(name, p.Name)
}
-- p/p.go --
package p

const Name = "p"

A symbol search for "na" returns:

[]protocol.SymbolInformation{
    {
        Name:       "name",
        Kind:       14,
        Tags:       nil,
        Deprecated: false,
        Location:   protocol.Location{
            URI:   "file:///home/myitcv/gostuff/src/github.com/myitcv/playground/main.go",
            Range: protocol.Range{
                Start: protocol.Position{Line:8, Character:6},
                End:   protocol.Position{Line:8, Character:10},
            },
        },
        ContainerName: "",
    },
    {
        Name:       "Name",
        Kind:       14,
        Tags:       nil,
        Deprecated: false,
        Location:   protocol.Location{
            URI:   "file:///home/myitcv/gostuff/src/github.com/myitcv/playground/p/p.go",
            Range: protocol.Range{
                Start: protocol.Position{Line:2, Character:6},
                End:   protocol.Position{Line:2, Character:10},
            },
        },
        ContainerName: "",
    },
    ....

What did you expect to see?

  • matches to be performed against the fully qualified symbols, e.g. github.com/myitcv/playground.name and github.com/myitcv/playground/p.Name
  • matches to be fuzzy matches that understand the nature of / and ., e.g. "p.na" would only return results in a package which fuzzy matches "p" and where the symbol within those packages fuzzy matches "na"
  • the fully qualified symbol to be returned in the SymbolInformation.Name field

A further question is how the type of a symbol can be returned as part of a match; whilst this should likely not play a part in the match, it is relevant in the presentation of results.

What did you see instead?

Per above


cc @stamblerre @findleyr

FYI @leitzler

@myitcv myitcv added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. gopls Issues related to the Go language server, gopls. labels Apr 6, 2020
@gopherbot gopherbot added this to the Unreleased milestone Apr 6, 2020
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Apr 6, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.5.0 Apr 6, 2020
@gopherbot
Copy link

Change https://golang.org/cl/227677 mentions this issue: internal/lsp: first cut of advanced query syntax for WorkspaceSymbol

myitcv added a commit to myitcvforks/tools that referenced this issue Apr 8, 2020
DO NOT REVIEW
DO NOT SUBMIT

* Add config option for SymbolMatcher
* Fully qualify symbols and match against fully-qualified symbol
* Define and implement workspaceOnly and nonWorkspaceExportedOnly search
  options

Fixes golang/go#38273
Updates golang/go#37237

Change-Id: Ie58ae992bf2d22673c3daa2c495c15279a1fa54b
myitcv added a commit to myitcvforks/tools that referenced this issue Apr 8, 2020
DO NOT REVIEW
DO NOT SUBMIT

* Add config option for SymbolMatcher
* Fully qualify symbols and match against fully-qualified symbol
* Define and implement workspaceOnly and nonWorkspaceExportedOnly search
  options

Fixes golang/go#38273
Updates golang/go#37237

Change-Id: Ie58ae992bf2d22673c3daa2c495c15279a1fa54b
@stamblerre stamblerre removed this from the gopls/v0.5.0 milestone Jun 20, 2020
@stamblerre stamblerre added this to the gopls/unplanned milestone Oct 21, 2020
@findleyr
Copy link
Contributor

Just came across this. Isn't this done? (symbolStyle: Full).

Closing now. Please reopen if I missed something.

@findleyr findleyr modified the milestones: gopls/unplanned, gopls/later Aug 14, 2022
@golang golang locked and limited conversation to collaborators Aug 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants