1
0
mirror of https://github.com/golang/go synced 2024-09-30 16:18:35 -06:00

internal/lsp: make the symbols tests use the enum names rather than hard coding the values

this makes them less fragile, more portable and also more understandable.

Change-Id: Ife8a7ed76b7517eaae37bd3896fee87740ffb22a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172405
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Ian Cottrell 2019-04-16 15:47:48 -04:00
parent 35716ff3bc
commit 4ca4b55e20
2 changed files with 20 additions and 20 deletions

View File

@ -547,7 +547,7 @@ func (h highlights) test(t *testing.T, s *Server) {
}
}
func (s symbols) collect(e *packagestest.Exported, fset *token.FileSet, name string, rng span.Range, kind int64, parentName string) {
func (s symbols) collect(e *packagestest.Exported, fset *token.FileSet, name string, rng span.Range, kind string, parentName string) {
f := fset.File(rng.Start)
if f == nil {
return
@ -571,7 +571,7 @@ func (s symbols) collect(e *packagestest.Exported, fset *token.FileSet, name str
sym := protocol.DocumentSymbol{
Name: name,
Kind: protocol.SymbolKind(kind),
Kind: protocol.ParseSymbolKind(kind),
SelectionRange: prng,
}
if parentName == "" {

View File

@ -2,42 +2,42 @@ package main
import "io"
var x = 42 //@symbol("x", "x", 13, "")
var x = 42 //@symbol("x", "x", "Variable", "")
const y = 43 //@symbol("y", "y", 14, "")
const y = 43 //@symbol("y", "y", "Constant", "")
type Number int //@symbol("Number", "Number", 16, "")
type Number int //@symbol("Number", "Number", "Number", "")
type Alias = string //@symbol("Alias", "Alias", 15, "")
type Alias = string //@symbol("Alias", "Alias", "String", "")
type NumberAlias = Number //@symbol("NumberAlias", "NumberAlias", 16, "")
type NumberAlias = Number //@symbol("NumberAlias", "NumberAlias", "Number", "")
type (
Boolean bool //@symbol("Boolean", "Boolean", 17, "")
BoolAlias = bool //@symbol("BoolAlias", "BoolAlias", 17, "")
Boolean bool //@symbol("Boolean", "Boolean", "Boolean", "")
BoolAlias = bool //@symbol("BoolAlias", "BoolAlias", "Boolean", "")
)
type Foo struct { //@symbol("Foo", "Foo", 23, "")
Quux //@symbol("Quux", "Quux", 8, "Foo")
W io.Writer //@symbol("W" , "W", 8, "Foo")
Bar int //@symbol("Bar", "Bar", 8, "Foo")
baz string //@symbol("baz", "baz", 8, "Foo")
type Foo struct { //@symbol("Foo", "Foo", "Struct", "")
Quux //@symbol("Quux", "Quux", "Field", "Foo")
W io.Writer //@symbol("W" , "W", "Field", "Foo")
Bar int //@symbol("Bar", "Bar", "Field", "Foo")
baz string //@symbol("baz", "baz", "Field", "Foo")
}
type Quux struct { //@symbol("Quux", "Quux", 23, "")
X, Y float64 //@symbol("X", "X", 8, "Quux"), symbol("Y", "Y", 8, "Quux")
type Quux struct { //@symbol("Quux", "Quux", "Struct", "")
X, Y float64 //@symbol("X", "X", "Field", "Quux"), symbol("Y", "Y", "Field", "Quux")
}
func (f Foo) Baz() string { //@symbol("Baz", "Baz", 6, "Foo")
func (f Foo) Baz() string { //@symbol("Baz", "Baz", "Method", "Foo")
return f.baz
}
func (q *Quux) Do() {} //@symbol("Do", "Do", 6, "Quux")
func (q *Quux) Do() {} //@symbol("Do", "Do", "Method", "Quux")
func main() { //@symbol("main", "main", 12, "")
func main() { //@symbol("main", "main", "Function", "")
}
type Stringer interface { //@symbol("Stringer", "Stringer", 11, "")
type Stringer interface { //@symbol("Stringer", "Stringer", "Interface", "")
String() string
}