internal/lsp/tests: provide SymbolInformation.Name in @symbol annotations

In preparation for a later change where we alter the implementation of
the workspace Symbol method, we now specify the Name that should be used
when constructing a SymbolInformation value from a @symbol annocation.
There is no change in the test expectations.

Change-Id: I4ee5f714d6060aab2ee33ef18339504f443cecdc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/228757
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Paul Jolly 2020-04-15 18:14:08 +01:00 коммит произвёл Paul Jolly
Родитель 9f075f7bfe
Коммит b4d5569d26
4 изменённых файлов: 37 добавлений и 36 удалений

Просмотреть файл

@ -4,57 +4,57 @@ import (
"io"
)
var x = 42 //@mark(symbolsx, "x"), symbol("x", "x", "Variable", "")
var x = 42 //@mark(symbolsx, "x"), symbol("x", "x", "Variable", "", "x")
const y = 43 //@symbol("y", "y", "Constant", "")
const y = 43 //@symbol("y", "y", "Constant", "", "y")
type Number int //@symbol("Number", "Number", "Number", "")
type Number int //@symbol("Number", "Number", "Number", "", "Number")
type Alias = string //@symbol("Alias", "Alias", "String", "")
type Alias = string //@symbol("Alias", "Alias", "String", "", "Alias")
type NumberAlias = Number //@symbol("NumberAlias", "NumberAlias", "Number", "")
type NumberAlias = Number //@symbol("NumberAlias", "NumberAlias", "Number", "", "NumberAlias")
type (
Boolean bool //@symbol("Boolean", "Boolean", "Boolean", "")
BoolAlias = bool //@symbol("BoolAlias", "BoolAlias", "Boolean", "")
Boolean bool //@symbol("Boolean", "Boolean", "Boolean", "", "Boolean")
BoolAlias = bool //@symbol("BoolAlias", "BoolAlias", "Boolean", "", "BoolAlias")
)
type Foo struct { //@mark(symbolsFoo, "Foo"), symbol("Foo", "Foo", "Struct", "")
Quux //@mark(fQuux, "Quux"), symbol("Quux", "Quux", "Field", "Foo")
W io.Writer //@symbol("W" , "W", "Field", "Foo")
Bar int //@mark(fBar, "Bar"), symbol("Bar", "Bar", "Field", "Foo")
baz string //@symbol("baz", "baz", "Field", "Foo")
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 Quux struct { //@symbol("Quux", "Quux", "Struct", "")
X, Y float64 //@mark(qX, "X"), symbol("X", "X", "Field", "Quux"), symbol("Y", "Y", "Field", "Quux")
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")
}
func (f Foo) Baz() string { //@symbol("(Foo).Baz", "Baz", "Method", "")
func (f Foo) Baz() string { //@symbol("(Foo).Baz", "Baz", "Method", "", "Baz")
return f.baz
}
func (q *Quux) Do() {} //@mark(qDo, "Do"), symbol("(*Quux).Do", "Do", "Method", "")
func (q *Quux) Do() {} //@mark(qDo, "Do"), symbol("(*Quux).Do", "Do", "Method", "", "Do")
func main() { //@symbol("main", "main", "Function", "")
func main() { //@symbol("main", "main", "Function", "", "main")
}
type Stringer interface { //@symbol("Stringer", "Stringer", "Interface", "")
String() string //@symbol("String", "String", "Method", "Stringer")
type Stringer interface { //@symbol("Stringer", "Stringer", "Interface", "", "Stringer")
String() string //@symbol("String", "String", "Method", "Stringer", "String")
}
type ABer interface { //@mark(ABerInterface, "ABer"), symbol("ABer", "ABer", "Interface", "")
B() //@symbol("B", "B", "Method", "ABer")
A() string //@mark(ABerA, "A"), symbol("A", "A", "Method", "ABer")
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 WithEmbeddeds interface { //@symbol("WithEmbeddeds", "WithEmbeddeds", "Interface", "")
Do() //@symbol("Do", "Do", "Method", "WithEmbeddeds")
ABer //@symbol("ABer", "ABer", "Interface", "WithEmbeddeds")
io.Writer //@mark(ioWriter, "io.Writer"), symbol("io.Writer", "io.Writer", "Interface", "WithEmbeddeds")
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")
}
func Dunk() int { return 0 } //@symbol("Dunk", "Dunk", "Function", "")
func Dunk() int { return 0 } //@symbol("Dunk", "Dunk", "Function", "", "Dunk")
func dunk() {} //@symbol("dunk", "dunk", "Function", "")
func dunk() {} //@symbol("dunk", "dunk", "Function", "", "dunk")

Просмотреть файл

@ -1,9 +1,9 @@
package a
var WorkspaceSymbolVariableA = "a" //@symbol("WorkspaceSymbolVariableA", "WorkspaceSymbolVariableA", "Variable", "")
var WorkspaceSymbolVariableA = "a" //@symbol("WorkspaceSymbolVariableA", "WorkspaceSymbolVariableA", "Variable", "", "WorkspaceSymbolVariableA")
const WorkspaceSymbolConstantA = "a" //@symbol("WorkspaceSymbolConstantA", "WorkspaceSymbolConstantA", "Constant", "")
const WorkspaceSymbolConstantA = "a" //@symbol("WorkspaceSymbolConstantA", "WorkspaceSymbolConstantA", "Constant", "", "WorkspaceSymbolConstantA")
const (
workspacesymbolinvariable = iota //@symbol("workspacesymbolinvariable", "workspacesymbolinvariable", "Constant", "")
workspacesymbolinvariable = iota //@symbol("workspacesymbolinvariable", "workspacesymbolinvariable", "Constant", "", "workspacesymbolinvariable")
)

Просмотреть файл

@ -1,7 +1,7 @@
package b
var WorkspaceSymbolVariableB = "b" //@symbol("WorkspaceSymbolVariableB", "WorkspaceSymbolVariableB", "Variable", "")
var WorkspaceSymbolVariableB = "b" //@symbol("WorkspaceSymbolVariableB", "WorkspaceSymbolVariableB", "Variable", "", "WorkspaceSymbolVariableB")
type WorkspaceSymbolStructB struct { //@symbol("WorkspaceSymbolStructB", "WorkspaceSymbolStructB", "Struct", "")
Bar int //@mark(bBar, "Bar"), symbol("Bar", "Bar", "Field", "WorkspaceSymbolStructB")
type WorkspaceSymbolStructB struct { //@symbol("WorkspaceSymbolStructB", "WorkspaceSymbolStructB", "Struct", "", "WorkspaceSymbolStructB")
Bar int //@mark(bBar, "Bar"), symbol("Bar", "Bar", "Field", "WorkspaceSymbolStructB", "Bar")
}

Просмотреть файл

@ -1076,7 +1076,8 @@ func (data *Data) collectPrepareRenames(src span.Span, rng span.Range, placehold
}
}
func (data *Data) collectSymbols(name string, spn span.Span, kind string, parentName string) {
// collectSymbols is responsible for collecting @symbol annotations.
func (data *Data) collectSymbols(name string, spn span.Span, kind string, parentName string, siName string) {
m, err := data.Mapper(spn.URI())
if err != nil {
data.t.Fatal(err)
@ -1098,7 +1099,7 @@ func (data *Data) collectSymbols(name string, spn span.Span, kind string, parent
// Reuse @symbol in the workspace symbols tests.
si := protocol.SymbolInformation{
Name: sym.Name,
Name: siName,
Kind: sym.Kind,
Location: protocol.Location{
URI: protocol.URIFromSpanURI(spn.URI()),