internal/lsp: fully qualify workspace Symbol matches

Fully qualify (using a package's import path) symbols when matching
them. This is a minimal change in preparation for later changes to add
more advanced query functionality to the workspace Symbol method.

Add more comprehensive regtest tests (covering case sensitive, case
insensitive and fuzzy matchers) in addition to updating lsp tests.

Change-Id: I675cde2f7b492158988cf9c3206a0a55fe29622a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/228123
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/internal/lsp/regtest/symbol_test.go b/internal/lsp/regtest/symbol_test.go
index 094c49f..32db7ef 100644
--- a/internal/lsp/regtest/symbol_test.go
+++ b/internal/lsp/regtest/symbol_test.go
@@ -8,6 +8,7 @@
 	"testing"
 
 	"golang.org/x/tools/internal/lsp/fake"
+	"golang.org/x/tools/internal/lsp/protocol"
 )
 
 const symbolSetup = `
@@ -18,41 +19,193 @@
 -- main.go --
 package main
 
-import "fmt"
+import (
+	"encoding/json"
+	"fmt"
+)
 
-func main() {
-	fmt.Println(Message)
+func main() { // function
+	fmt.Println("Hello")
 }
--- const.go --
+
+var myvar int // variable
+
+type myType string // basic type
+
+type myDecoder json.Decoder // to use the encoding/json import
+
+func (m *myType) Blahblah() {} // method
+
+type myStruct struct { // struct type
+	myStructField int // struct field
+}
+
+type myInterface interface { // interface
+	DoSomeCoolStuff() string // interface method
+}
+-- p/p.go --
 package main
 
-const Message = "Hello World."
+const Message = "Hello World." // constant
 `
 
+var caseSensitiveSymbolChecks = map[string]*expSymbolInformation{
+	"main": {
+		Name: pString("mod.com.main"),
+		Kind: pKind(protocol.Function),
+		Location: &expLocation{
+			Path: pString("main.go"),
+			Range: &expRange{
+				Start: &expPos{
+					Line:   pInt(7),
+					Column: pInt(5),
+				},
+			},
+		},
+	},
+	"Message": {
+		Name: pString("mod.com/p.Message"),
+		Kind: pKind(protocol.Constant),
+		Location: &expLocation{
+			Path: pString("p/p.go"),
+			Range: &expRange{
+				Start: &expPos{
+					Line:   pInt(2),
+					Column: pInt(6),
+				},
+			},
+		},
+	},
+	"myvar": {
+		Name: pString("mod.com.myvar"),
+		Kind: pKind(protocol.Variable),
+		Location: &expLocation{
+			Path: pString("main.go"),
+			Range: &expRange{
+				Start: &expPos{
+					Line:   pInt(11),
+					Column: pInt(4),
+				},
+			},
+		},
+	},
+	"myType": {
+		Name: pString("mod.com.myType"),
+		Kind: pKind(protocol.String),
+		Location: &expLocation{
+			Path: pString("main.go"),
+			Range: &expRange{
+				Start: &expPos{
+					Line:   pInt(13),
+					Column: pInt(5),
+				},
+			},
+		},
+	},
+	"Blahblah": {
+		Name: pString("mod.com.myType.Blahblah"),
+		Kind: pKind(protocol.Method),
+		Location: &expLocation{
+			Path: pString("main.go"),
+			Range: &expRange{
+				Start: &expPos{
+					Line:   pInt(17),
+					Column: pInt(17),
+				},
+			},
+		},
+	},
+	"NewEncoder": {
+		Name: pString("encoding/json.NewEncoder"),
+		Kind: pKind(protocol.Function),
+	},
+	"myStruct": {
+		Name: pString("mod.com.myStruct"),
+		Kind: pKind(protocol.Struct),
+		Location: &expLocation{
+			Path: pString("main.go"),
+			Range: &expRange{
+				Start: &expPos{
+					Line:   pInt(19),
+					Column: pInt(5),
+				},
+			},
+		},
+	},
+	// TODO: not sure we should be returning struct fields
+	"myStructField": {
+		Name: pString("mod.com.myStruct.myStructField"),
+		Kind: pKind(protocol.Field),
+		Location: &expLocation{
+			Path: pString("main.go"),
+			Range: &expRange{
+				Start: &expPos{
+					Line:   pInt(20),
+					Column: pInt(1),
+				},
+			},
+		},
+	},
+	"myInterface": {
+		Name: pString("mod.com.myInterface"),
+		Kind: pKind(protocol.Interface),
+		Location: &expLocation{
+			Path: pString("main.go"),
+			Range: &expRange{
+				Start: &expPos{
+					Line:   pInt(23),
+					Column: pInt(5),
+				},
+			},
+		},
+	},
+	// TODO: not sure we should be returning interface methods
+	"DoSomeCoolStuff": {
+		Name: pString("mod.com.myInterface.DoSomeCoolStuff"),
+		Kind: pKind(protocol.Method),
+		Location: &expLocation{
+			Path: pString("main.go"),
+			Range: &expRange{
+				Start: &expPos{
+					Line:   pInt(24),
+					Column: pInt(1),
+				},
+			},
+		},
+	},
+}
+
+var caseInsensitiveSymbolChecks = map[string]*expSymbolInformation{
+	"Main": caseSensitiveSymbolChecks["main"],
+}
+
+var fuzzySymbolChecks = map[string]*expSymbolInformation{
+	"mod.Mn": caseSensitiveSymbolChecks["main"],
+}
+
 // TestSymbolPos tests that, at a basic level, we get the correct position
 // information for symbols matches that are returned.
 func TestSymbolPos(t *testing.T) {
-	matcher := "caseSensitive"
+	checkChecks(t, "caseSensitive", caseSensitiveSymbolChecks)
+	checkChecks(t, "caseInsensitive", caseInsensitiveSymbolChecks)
+	checkChecks(t, "fuzzy", fuzzySymbolChecks)
+}
+
+func checkChecks(t *testing.T, matcher string, checks map[string]*expSymbolInformation) {
+	t.Helper()
 	opts := []RunOption{
 		WithEditorConfig(fake.EditorConfig{SymbolMatcher: &matcher}),
 	}
-
 	runner.Run(t, symbolSetup, func(t *testing.T, env *Env) {
-		res := env.Symbol("main")
-		exp := &expSymbolInformation{
-			Name: pString("main"),
-			Location: &expLocation{
-				Path: pString("main.go"),
-				Range: &expRange{
-					Start: &expPos{
-						Line:   pInt(4),
-						Column: pInt(5),
-					},
-				},
-			},
-		}
-		if !exp.matchAgainst(res) {
-			t.Fatalf("failed to find match for main function")
-		}
+		t.Run(matcher, func(t *testing.T) {
+			for query, exp := range checks {
+				t.Run(query, func(t *testing.T) {
+					res := env.Symbol(query)
+					if !exp.matchAgainst(res) {
+						t.Fatalf("failed to find a match against query %q for %v", query, exp)
+					}
+				})
+			}
+		})
 	}, opts...)
 }
diff --git a/internal/lsp/source/workspace_symbol.go b/internal/lsp/source/workspace_symbol.go
index b4d98b4..17b7496 100644
--- a/internal/lsp/source/workspace_symbol.go
+++ b/internal/lsp/source/workspace_symbol.go
@@ -65,7 +65,7 @@
 				if err != nil {
 					return nil, err
 				}
-				for _, si := range findSymbol(file.Decls, pkg.GetTypesInfo(), matcher) {
+				for _, si := range findSymbol(file.Decls, pkg.GetTypesInfo(), matcher, pkg.PkgPath()) {
 					mrng, err := posToMappedRange(view, pkg, si.node.Pos(), si.node.End())
 					if err != nil {
 						event.Error(ctx, "Error getting mapped range for node", err)
@@ -121,18 +121,26 @@
 	}
 }
 
-func findSymbol(decls []ast.Decl, info *types.Info, matcher matcherFunc) []symbolInformation {
+func findSymbol(decls []ast.Decl, info *types.Info, matcher matcherFunc, prefix string) []symbolInformation {
 	var result []symbolInformation
 	for _, decl := range decls {
 		switch decl := decl.(type) {
 		case *ast.FuncDecl:
-			if matcher(decl.Name.Name) {
-				kind := protocol.Function
-				if decl.Recv != nil {
-					kind = protocol.Method
+			fn := decl.Name.Name
+			kind := protocol.Function
+			if decl.Recv != nil {
+				kind = protocol.Method
+				switch typ := decl.Recv.List[0].Type.(type) {
+				case *ast.StarExpr:
+					fn = typ.X.(*ast.Ident).Name + "." + fn
+				case *ast.Ident:
+					fn = typ.Name + "." + fn
 				}
+			}
+			target := prefix + "." + fn
+			if matcher(target) {
 				result = append(result, symbolInformation{
-					name: decl.Name.Name,
+					name: target,
 					kind: kind,
 					node: decl.Name,
 				})
@@ -141,9 +149,10 @@
 			for _, spec := range decl.Specs {
 				switch spec := spec.(type) {
 				case *ast.TypeSpec:
-					if matcher(spec.Name.Name) {
+					target := prefix + "." + spec.Name.Name
+					if matcher(target) {
 						result = append(result, symbolInformation{
-							name: spec.Name.Name,
+							name: target,
 							kind: typeToKind(info.TypeOf(spec.Type)),
 							node: spec.Name,
 						})
@@ -151,7 +160,7 @@
 					switch st := spec.Type.(type) {
 					case *ast.StructType:
 						for _, field := range st.Fields.List {
-							result = append(result, findFieldSymbol(field, protocol.Field, matcher)...)
+							result = append(result, findFieldSymbol(field, protocol.Field, matcher, target)...)
 						}
 					case *ast.InterfaceType:
 						for _, field := range st.Methods.List {
@@ -159,18 +168,19 @@
 							if len(field.Names) == 0 {
 								kind = protocol.Interface
 							}
-							result = append(result, findFieldSymbol(field, kind, matcher)...)
+							result = append(result, findFieldSymbol(field, kind, matcher, target)...)
 						}
 					}
 				case *ast.ValueSpec:
 					for _, name := range spec.Names {
-						if matcher(name.Name) {
+						target := prefix + "." + name.Name
+						if matcher(target) {
 							kind := protocol.Variable
 							if decl.Tok == token.CONST {
 								kind = protocol.Constant
 							}
 							result = append(result, symbolInformation{
-								name: name.Name,
+								name: target,
 								kind: kind,
 								node: name,
 							})
@@ -210,14 +220,15 @@
 	return protocol.Variable
 }
 
-func findFieldSymbol(field *ast.Field, kind protocol.SymbolKind, matcher matcherFunc) []symbolInformation {
+func findFieldSymbol(field *ast.Field, kind protocol.SymbolKind, matcher matcherFunc, prefix string) []symbolInformation {
 	var result []symbolInformation
 
 	if len(field.Names) == 0 {
 		name := types.ExprString(field.Type)
-		if matcher(name) {
+		target := prefix + "." + name
+		if matcher(target) {
 			result = append(result, symbolInformation{
-				name: name,
+				name: target,
 				kind: kind,
 				node: field,
 			})
@@ -226,9 +237,10 @@
 	}
 
 	for _, name := range field.Names {
-		if matcher(name.Name) {
+		target := prefix + "." + name.Name
+		if matcher(target) {
 			result = append(result, symbolInformation{
-				name: name.Name,
+				name: target,
 				kind: kind,
 				node: name,
 			})
diff --git a/internal/lsp/testdata/lsp/primarymod/symbols/main.go b/internal/lsp/testdata/lsp/primarymod/symbols/main.go
index 1f6cc11..794b62a 100644
--- a/internal/lsp/testdata/lsp/primarymod/symbols/main.go
+++ b/internal/lsp/testdata/lsp/primarymod/symbols/main.go
@@ -4,57 +4,57 @@
 	"io"
 )
 
-var x = 42 //@mark(symbolsx, "x"), symbol("x", "x", "Variable", "", "x")
+var x = 42 //@mark(symbolsx, "x"), symbol("x", "x", "Variable", "", "golang.org/x/tools/internal/lsp/symbols.x")
 
-const y = 43 //@symbol("y", "y", "Constant", "", "y")
+const y = 43 //@symbol("y", "y", "Constant", "", "golang.org/x/tools/internal/lsp/symbols.y")
 
-type Number int //@symbol("Number", "Number", "Number", "", "Number")
+type Number int //@symbol("Number", "Number", "Number", "", "golang.org/x/tools/internal/lsp/symbols.Number")
 
-type Alias = string //@symbol("Alias", "Alias", "String", "", "Alias")
+type Alias = string //@symbol("Alias", "Alias", "String", "", "golang.org/x/tools/internal/lsp/symbols.Alias")
 
-type NumberAlias = Number //@symbol("NumberAlias", "NumberAlias", "Number", "", "NumberAlias")
+type NumberAlias = Number //@symbol("NumberAlias", "NumberAlias", "Number", "", "golang.org/x/tools/internal/lsp/symbols.NumberAlias")
 
 type (
-	Boolean   bool   //@symbol("Boolean", "Boolean", "Boolean", "", "Boolean")
-	BoolAlias = bool //@symbol("BoolAlias", "BoolAlias", "Boolean", "", "BoolAlias")
+	Boolean   bool   //@symbol("Boolean", "Boolean", "Boolean", "", "golang.org/x/tools/internal/lsp/symbols.Boolean")
+	BoolAlias = bool //@symbol("BoolAlias", "BoolAlias", "Boolean", "", "golang.org/x/tools/internal/lsp/symbols.BoolAlias")
 )
 
-type Foo struct { //@mark(symbolsFoo, "Foo"), symbol("Foo", "Foo", "Struct", "", "Foo")
-	Quux           //@mark(fQuux, "Quux"), symbol("Quux", "Quux", "Field", "Foo", "Quux")
-	W    io.Writer //@symbol("W" , "W", "Field", "Foo", "W")
-	Bar  int       //@mark(fBar, "Bar"), symbol("Bar", "Bar", "Field", "Foo", "Bar")
-	baz  string    //@symbol("baz", "baz", "Field", "Foo", "baz")
+type Foo struct { //@mark(symbolsFoo, "Foo"), symbol("Foo", "Foo", "Struct", "", "golang.org/x/tools/internal/lsp/symbols.Foo")
+	Quux           //@mark(fQuux, "Quux"), symbol("Quux", "Quux", "Field", "Foo", "golang.org/x/tools/internal/lsp/symbols.Foo.Quux")
+	W    io.Writer //@symbol("W" , "W", "Field", "Foo", "golang.org/x/tools/internal/lsp/symbols.Foo.W")
+	Bar  int       //@mark(fBar, "Bar"), symbol("Bar", "Bar", "Field", "Foo", "golang.org/x/tools/internal/lsp/symbols.Foo.Bar")
+	baz  string    //@symbol("baz", "baz", "Field", "Foo", "golang.org/x/tools/internal/lsp/symbols.Foo.baz")
 }
 
-type Quux struct { //@symbol("Quux", "Quux", "Struct", "", "Quux")
-	X, Y float64 //@mark(qX, "X"), symbol("X", "X", "Field", "Quux", "X"), symbol("Y", "Y", "Field", "Quux", "Y")
+type Quux struct { //@symbol("Quux", "Quux", "Struct", "", "golang.org/x/tools/internal/lsp/symbols.Quux")
+	X, Y float64 //@mark(qX, "X"), symbol("X", "X", "Field", "Quux", "golang.org/x/tools/internal/lsp/symbols.X"), symbol("Y", "Y", "Field", "Quux", "golang.org/x/tools/internal/lsp/symbols.Y")
 }
 
-func (f Foo) Baz() string { //@symbol("(Foo).Baz", "Baz", "Method", "", "Baz")
+func (f Foo) Baz() string { //@symbol("(Foo).Baz", "Baz", "Method", "", "golang.org/x/tools/internal/lsp/symbols.Foo.Baz")
 	return f.baz
 }
 
-func (q *Quux) Do() {} //@mark(qDo, "Do"), symbol("(*Quux).Do", "Do", "Method", "", "Do")
+func (q *Quux) Do() {} //@mark(qDo, "Do"), symbol("(*Quux).Do", "Do", "Method", "", "golang.org/x/tools/internal/lsp/symbols.Quux.Do")
 
-func main() { //@symbol("main", "main", "Function", "", "main")
+func main() { //@symbol("main", "main", "Function", "", "golang.org/x/tools/internal/lsp/symbols.main")
 
 }
 
-type Stringer interface { //@symbol("Stringer", "Stringer", "Interface", "", "Stringer")
-	String() string //@symbol("String", "String", "Method", "Stringer", "String")
+type Stringer interface { //@symbol("Stringer", "Stringer", "Interface", "", "golang.org/x/tools/internal/lsp/symbols.Stringer")
+	String() string //@symbol("String", "String", "Method", "Stringer", "golang.org/x/tools/internal/lsp/symbols.Stringer.String")
 }
 
-type ABer interface { //@mark(ABerInterface, "ABer"), symbol("ABer", "ABer", "Interface", "", "ABer")
-	B()        //@symbol("B", "B", "Method", "ABer", "B")
-	A() string //@mark(ABerA, "A"), symbol("A", "A", "Method", "ABer", "A")
+type ABer interface { //@mark(ABerInterface, "ABer"), symbol("ABer", "ABer", "Interface", "", "golang.org/x/tools/internal/lsp/symbols.ABer")
+	B()        //@symbol("B", "B", "Method", "ABer", "golang.org/x/tools/internal/lsp/symbols.ABer.B")
+	A() string //@mark(ABerA, "A"), symbol("A", "A", "Method", "ABer", "golang.org/x/tools/internal/lsp/symbols.ABer.A")
 }
 
-type WithEmbeddeds interface { //@symbol("WithEmbeddeds", "WithEmbeddeds", "Interface", "", "WithEmbeddeds")
-	Do()      //@symbol("Do", "Do", "Method", "WithEmbeddeds", "Do")
-	ABer      //@symbol("ABer", "ABer", "Interface", "WithEmbeddeds", "ABer")
-	io.Writer //@mark(ioWriter, "io.Writer"), symbol("io.Writer", "io.Writer", "Interface", "WithEmbeddeds", "Writer")
+type WithEmbeddeds interface { //@symbol("WithEmbeddeds", "WithEmbeddeds", "Interface", "", "golang.org/x/tools/internal/lsp/symbols.WithEmbeddeds")
+	Do()      //@symbol("Do", "Do", "Method", "WithEmbeddeds", "golang.org/x/tools/internal/lsp/symbols.WithEmbeddeds.Do")
+	ABer      //@symbol("ABer", "ABer", "Interface", "WithEmbeddeds", "golang.org/x/tools/internal/lsp/symbols.WithEmbeddeds.ABer")
+	io.Writer //@mark(ioWriter, "io.Writer"), symbol("io.Writer", "io.Writer", "Interface", "WithEmbeddeds", "golang.org/x/tools/internal/lsp/symbols.WithEmbeddeds.Writer")
 }
 
-func Dunk() int { return 0 } //@symbol("Dunk", "Dunk", "Function", "", "Dunk")
+func Dunk() int { return 0 } //@symbol("Dunk", "Dunk", "Function", "", "golang.org/x/tools/internal/lsp/symbols.Dunk")
 
-func dunk() {} //@symbol("dunk", "dunk", "Function", "", "dunk")
+func dunk() {} //@symbol("dunk", "dunk", "Function", "", "golang.org/x/tools/internal/lsp/symbols.dunk")
diff --git a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/a/a.go b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/a/a.go
index 072f4cb..93bfee3 100644
--- a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/a/a.go
+++ b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/a/a.go
@@ -1,9 +1,9 @@
 package a
 
-var RandomGopherVariableA = "a" //@symbol("RandomGopherVariableA", "RandomGopherVariableA", "Variable", "", "RandomGopherVariableA")
+var RandomGopherVariableA = "a" //@symbol("RandomGopherVariableA", "RandomGopherVariableA", "Variable", "", "golang.org/x/tools/internal/lsp/workspacesymbol/a.RandomGopherVariableA")
 
-const RandomGopherConstantA = "a" //@symbol("RandomGopherConstantA", "RandomGopherConstantA", "Constant", "", "RandomGopherConstantA")
+const RandomGopherConstantA = "a" //@symbol("RandomGopherConstantA", "RandomGopherConstantA", "Constant", "", "golang.org/x/tools/internal/lsp/workspacesymbol/a.RandomGopherConstantA")
 
 const (
-	randomgopherinvariable = iota //@symbol("randomgopherinvariable", "randomgopherinvariable", "Constant", "", "randomgopherinvariable")
+	randomgopherinvariable = iota //@symbol("randomgopherinvariable", "randomgopherinvariable", "Constant", "", "golang.org/x/tools/internal/lsp/workspacesymbol/a.randomgopherinvariable")
 )
diff --git a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/b/b.go b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/b/b.go
index b90b3a9..31bb923 100644
--- a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/b/b.go
+++ b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/b/b.go
@@ -1,7 +1,7 @@
 package b
 
-var RandomGopherVariableB = "b" //@symbol("RandomGopherVariableB", "RandomGopherVariableB", "Variable", "", "RandomGopherVariableB")
+var RandomGopherVariableB = "b" //@symbol("RandomGopherVariableB", "RandomGopherVariableB", "Variable", "", "golang.org/x/tools/internal/lsp/workspacesymbol/b.RandomGopherVariableB")
 
-type RandomGopherStructB struct { //@symbol("RandomGopherStructB", "RandomGopherStructB", "Struct", "", "RandomGopherStructB")
-	Bar int //@mark(bBar, "Bar"), symbol("Bar", "Bar", "Field", "RandomGopherStructB", "Bar")
+type RandomGopherStructB struct { //@symbol("RandomGopherStructB", "RandomGopherStructB", "Struct", "", "golang.org/x/tools/internal/lsp/workspacesymbol/b.RandomGopherStructB")
+	Bar int //@mark(bBar, "Bar"), symbol("Bar", "Bar", "Field", "RandomGopherStructB", "golang.org/x/tools/internal/lsp/workspacesymbol/b.RandomGopherStructB.Bar")
 }
diff --git "a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/casesensitive/\041dunk.golden" "b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/casesensitive/\041dunk.golden"
index 52f25a7..9bcd639 100644
--- "a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/casesensitive/\041dunk.golden"
+++ "b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/casesensitive/\041dunk.golden"
@@ -1,2 +1,2 @@
 -- workspace_symbol --
-symbols/main.go:58:6-10 Dunk Function
+symbols/main.go:58:6-10 golang.org/x/tools/internal/lsp/symbols.Dunk Function
diff --git a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/casesensitive/dunk.golden b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/casesensitive/dunk.golden
index 9de7528..041a87c 100644
--- a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/casesensitive/dunk.golden
+++ b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/casesensitive/dunk.golden
@@ -1,2 +1,2 @@
 -- workspace_symbol --
-symbols/main.go:60:6-10 dunk Function
+symbols/main.go:60:6-10 golang.org/x/tools/internal/lsp/symbols.dunk Function
diff --git a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/fuzzy/fuzzy.go b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/fuzzy/fuzzy.go
index 4bc8b54..f4a8821 100644
--- a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/fuzzy/fuzzy.go
+++ b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/fuzzy/fuzzy.go
@@ -7,17 +7,20 @@
 	randomgopherinvariable,
 	RandomGopherVariableB,
 	RandomGopherStructB,
+	bBar,
 )
 workspacesymbolfuzzy("randoma",
 	RandomGopherVariableA,
 	RandomGopherConstantA,
 	randomgopherinvariable,
 	RandomGopherVariableB,
+	bBar,
 )
 workspacesymbolfuzzy("randomb",
 	RandomGopherVariableA,
 	randomgopherinvariable,
 	RandomGopherVariableB,
 	RandomGopherStructB,
+	bBar,
 )
 */
diff --git a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/fuzzy/randoma.golden b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/fuzzy/randoma.golden
index bfdcb21..3fe3775 100644
--- a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/fuzzy/randoma.golden
+++ b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/fuzzy/randoma.golden
@@ -1,5 +1,6 @@
 -- workspace_symbol --
-workspacesymbol/a/a.go:3:5-26 RandomGopherVariableA Variable
-workspacesymbol/a/a.go:5:7-28 RandomGopherConstantA Constant
-workspacesymbol/a/a.go:8:2-24 randomgopherinvariable Constant
-workspacesymbol/b/b.go:3:5-26 RandomGopherVariableB Variable
+workspacesymbol/a/a.go:3:5-26 golang.org/x/tools/internal/lsp/workspacesymbol/a.RandomGopherVariableA Variable
+workspacesymbol/a/a.go:5:7-28 golang.org/x/tools/internal/lsp/workspacesymbol/a.RandomGopherConstantA Constant
+workspacesymbol/a/a.go:8:2-24 golang.org/x/tools/internal/lsp/workspacesymbol/a.randomgopherinvariable Constant
+workspacesymbol/b/b.go:3:5-26 golang.org/x/tools/internal/lsp/workspacesymbol/b.RandomGopherVariableB Variable
+workspacesymbol/b/b.go:6:2-5 golang.org/x/tools/internal/lsp/workspacesymbol/b.RandomGopherStructB.Bar Field
diff --git a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/fuzzy/randomb.golden b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/fuzzy/randomb.golden
index d0fef3e..9108df7 100644
--- a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/fuzzy/randomb.golden
+++ b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/fuzzy/randomb.golden
@@ -1,5 +1,6 @@
 -- workspace_symbol --
-workspacesymbol/a/a.go:3:5-26 RandomGopherVariableA Variable
-workspacesymbol/a/a.go:8:2-24 randomgopherinvariable Constant
-workspacesymbol/b/b.go:3:5-26 RandomGopherVariableB Variable
-workspacesymbol/b/b.go:5:6-25 RandomGopherStructB Struct
+workspacesymbol/a/a.go:3:5-26 golang.org/x/tools/internal/lsp/workspacesymbol/a.RandomGopherVariableA Variable
+workspacesymbol/a/a.go:8:2-24 golang.org/x/tools/internal/lsp/workspacesymbol/a.randomgopherinvariable Constant
+workspacesymbol/b/b.go:3:5-26 golang.org/x/tools/internal/lsp/workspacesymbol/b.RandomGopherVariableB Variable
+workspacesymbol/b/b.go:5:6-25 golang.org/x/tools/internal/lsp/workspacesymbol/b.RandomGopherStructB Struct
+workspacesymbol/b/b.go:6:2-5 golang.org/x/tools/internal/lsp/workspacesymbol/b.RandomGopherStructB.Bar Field
diff --git a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/fuzzy/rgop.golden b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/fuzzy/rgop.golden
index 0c5fde3..98c65ca 100644
--- a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/fuzzy/rgop.golden
+++ b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/fuzzy/rgop.golden
@@ -1,6 +1,7 @@
 -- workspace_symbol --
-workspacesymbol/a/a.go:3:5-26 RandomGopherVariableA Variable
-workspacesymbol/a/a.go:5:7-28 RandomGopherConstantA Constant
-workspacesymbol/a/a.go:8:2-24 randomgopherinvariable Constant
-workspacesymbol/b/b.go:3:5-26 RandomGopherVariableB Variable
-workspacesymbol/b/b.go:5:6-25 RandomGopherStructB Struct
+workspacesymbol/a/a.go:3:5-26 golang.org/x/tools/internal/lsp/workspacesymbol/a.RandomGopherVariableA Variable
+workspacesymbol/a/a.go:5:7-28 golang.org/x/tools/internal/lsp/workspacesymbol/a.RandomGopherConstantA Constant
+workspacesymbol/a/a.go:8:2-24 golang.org/x/tools/internal/lsp/workspacesymbol/a.randomgopherinvariable Constant
+workspacesymbol/b/b.go:3:5-26 golang.org/x/tools/internal/lsp/workspacesymbol/b.RandomGopherVariableB Variable
+workspacesymbol/b/b.go:5:6-25 golang.org/x/tools/internal/lsp/workspacesymbol/b.RandomGopherStructB Struct
+workspacesymbol/b/b.go:6:2-5 golang.org/x/tools/internal/lsp/workspacesymbol/b.RandomGopherStructB.Bar Field
diff --git a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/randomgophervar.golden b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/randomgophervar.golden
index 02e9954..30c3492 100644
--- a/internal/lsp/testdata/lsp/primarymod/workspacesymbol/randomgophervar.golden
+++ b/internal/lsp/testdata/lsp/primarymod/workspacesymbol/randomgophervar.golden
@@ -1,3 +1,3 @@
 -- workspace_symbol --
-workspacesymbol/a/a.go:3:5-26 RandomGopherVariableA Variable
-workspacesymbol/b/b.go:3:5-26 RandomGopherVariableB Variable
+workspacesymbol/a/a.go:3:5-26 golang.org/x/tools/internal/lsp/workspacesymbol/a.RandomGopherVariableA Variable
+workspacesymbol/b/b.go:3:5-26 golang.org/x/tools/internal/lsp/workspacesymbol/b.RandomGopherVariableB Variable