1
0
mirror of https://github.com/golang/go synced 2024-11-18 14:04:45 -07:00

internal/lsp/tests: fix WorkspaceSymbols tests

The tests will not run because there is no workspacesymbol marker.
Therefore, restore testdata used in WorkspaceSymbols tests, and
initialize data so that the tests run even if the target of the marker
is 0.

Change-Id: I051b842183b7e23bb746cc282fc3921a90ca8df1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/221617
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Daisuke Suzuki 2020-02-29 14:47:19 +09:00 committed by Heschi Kreinick
parent aafaee8bce
commit 0d653b92c5
3 changed files with 13 additions and 1 deletions

View File

@ -0,0 +1,9 @@
package workspacesymbol
/*@
workspacesymbol("") // The result is 0 symbols due to the limit(golang.org/cl/220939).
workspacesymbol("workspacesymbolvar",
WorkspaceSymbolVariableA,
WorkspaceSymbolVariableB,
)
*/

View File

@ -19,7 +19,7 @@ ReferencesCount = 9
RenamesCount = 23
PrepareRenamesCount = 7
SymbolsCount = 3
WorkspaceSymbolsCount = 0
WorkspaceSymbolsCount = 2
FuzzyWorkspaceSymbolsCount = 3
CaseSensitiveWorkspaceSymbolsCount = 2
SignaturesCount = 24

View File

@ -1112,18 +1112,21 @@ func (data *Data) collectWorkspaceSymbols(typ WorkspaceSymbolsTestType) func(str
switch typ {
case WorkspaceSymbolsFuzzy:
return func(query string, targets []span.Span) {
data.FuzzyWorkspaceSymbols[query] = make([]protocol.SymbolInformation, 0, len(targets))
for _, target := range targets {
data.FuzzyWorkspaceSymbols[query] = append(data.FuzzyWorkspaceSymbols[query], data.symbolInformation[target])
}
}
case WorkspaceSymbolsCaseSensitive:
return func(query string, targets []span.Span) {
data.CaseSensitiveWorkspaceSymbols[query] = make([]protocol.SymbolInformation, 0, len(targets))
for _, target := range targets {
data.CaseSensitiveWorkspaceSymbols[query] = append(data.CaseSensitiveWorkspaceSymbols[query], data.symbolInformation[target])
}
}
default:
return func(query string, targets []span.Span) {
data.WorkspaceSymbols[query] = make([]protocol.SymbolInformation, 0, len(targets))
for _, target := range targets {
data.WorkspaceSymbols[query] = append(data.WorkspaceSymbols[query], data.symbolInformation[target])
}