1
0
mirror of https://github.com/golang/go synced 2024-11-19 04:54:41 -07:00
go/internal/lsp/testdata/symbols/main.go
Daisuke Suzuki 6e8b36d2c7 internal/lsp: add support for workspace symbol
This change adds support for the LSP workspace/symbol. Unlike
documentSymbol, the target is symbols that exist not only in a specific
file, but also in the current or imported packages. It returns symbols
whose name contains the query string of the request(case-insensitive),
or all symbols if the query string is empty.

However, the following is not implemented:
- Setting of deprecated and containerName fields in SymbolInformation
- Consideration of WorkspaceClientCapabilities
- Progress support
- CLI support

Updates golang/go#33844

Change-Id: Id2a8d3c468084b9d44228cc6ed2ad37c4b52c405
Reviewed-on: https://go-review.googlesource.com/c/tools/+/213317
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-02-05 19:03:17 +00:00

57 lines
1.9 KiB
Go

package main
import (
"io"
)
var x = 42 //@mark(symbolsx, "x"), symbol("x", "x", "Variable", "")
const y = 43 //@symbol("y", "y", "Constant", "")
type Number int //@symbol("Number", "Number", "Number", "")
type Alias = string //@symbol("Alias", "Alias", "String", "")
type NumberAlias = Number //@symbol("NumberAlias", "NumberAlias", "Number", "")
type (
Boolean bool //@symbol("Boolean", "Boolean", "Boolean", "")
BoolAlias = bool //@symbol("BoolAlias", "BoolAlias", "Boolean", "")
)
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 Quux struct { //@symbol("Quux", "Quux", "Struct", "")
X, Y float64 //@mark(qX, "X"), symbol("X", "X", "Field", "Quux"), symbol("Y", "Y", "Field", "Quux")
}
func (f Foo) Baz() string { //@symbol("Baz", "Baz", "Method", "Foo")
return f.baz
}
func (q *Quux) Do() {} //@mark(qDo, "Do"), symbol("Do", "Do", "Method", "Quux")
func main() { //@symbol("main", "main", "Function", "")
}
type Stringer interface { //@symbol("Stringer", "Stringer", "Interface", "")
String() string //@symbol("String", "String", "Method", "Stringer")
}
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 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")
}