diff options
Diffstat (limited to 'gopls/internal/regtest/misc/workspace_symbol_test.go')
-rw-r--r-- | gopls/internal/regtest/misc/workspace_symbol_test.go | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/gopls/internal/regtest/misc/workspace_symbol_test.go b/gopls/internal/regtest/misc/workspace_symbol_test.go index a21d47312..a492e1d49 100644 --- a/gopls/internal/regtest/misc/workspace_symbol_test.go +++ b/gopls/internal/regtest/misc/workspace_symbol_test.go @@ -7,16 +7,12 @@ package misc import ( "testing" - "golang.org/x/tools/internal/lsp/protocol" - . "golang.org/x/tools/internal/lsp/regtest" - "golang.org/x/tools/internal/lsp/source" - "golang.org/x/tools/internal/testenv" + "golang.org/x/tools/gopls/internal/lsp/protocol" + . "golang.org/x/tools/gopls/internal/lsp/regtest" + "golang.org/x/tools/gopls/internal/lsp/source" ) func TestWorkspaceSymbolMissingMetadata(t *testing.T) { - // We get 2 symbols on 1.12, for some reason. - testenv.NeedsGo1Point(t, 13) - const files = ` -- go.mod -- module mod.com @@ -26,26 +22,27 @@ go 1.17 package p const C1 = "a.go" --- ignore.go -- +-- exclude.go -- -// +build ignore +//go:build exclude +// +build exclude -package ignore +package exclude -const C2 = "ignore.go" +const C2 = "exclude.go" ` Run(t, files, func(t *testing.T, env *Env) { env.OpenFile("a.go") - syms := env.WorkspaceSymbol("C") + syms := env.Symbol("C") if got, want := len(syms), 1; got != want { t.Errorf("got %d symbols, want %d", got, want) } // Opening up an ignored file will result in an overlay with missing // metadata, but this shouldn't break workspace symbols requests. - env.OpenFile("ignore.go") - syms = env.WorkspaceSymbol("C") + env.OpenFile("exclude.go") + syms = env.Symbol("C") if got, want := len(syms), 1; got != want { t.Errorf("got %d symbols, want %d", got, want) } @@ -72,9 +69,7 @@ const ( var symbolMatcher = string(source.SymbolFastFuzzy) WithOptions( - EditorConfig{ - SymbolMatcher: &symbolMatcher, - }, + Settings{"symbolMatcher": symbolMatcher}, ).Run(t, files, func(t *testing.T, env *Env) { want := []string{ "Foo", // prefer exact segment matches first @@ -83,8 +78,8 @@ const ( "Fooey", // shorter than Fooest, Foobar "Fooest", } - got := env.WorkspaceSymbol("Foo") - compareSymbols(t, got, want) + got := env.Symbol("Foo") + compareSymbols(t, got, want...) }) } @@ -105,19 +100,17 @@ const ( var symbolMatcher = string(source.SymbolFastFuzzy) WithOptions( - EditorConfig{ - SymbolMatcher: &symbolMatcher, - }, + Settings{"symbolMatcher": symbolMatcher}, ).Run(t, files, func(t *testing.T, env *Env) { - compareSymbols(t, env.WorkspaceSymbol("ABC"), []string{"ABC", "AxxBxxCxx"}) - compareSymbols(t, env.WorkspaceSymbol("'ABC"), []string{"ABC"}) - compareSymbols(t, env.WorkspaceSymbol("^mod.com"), []string{"mod.com/a.ABC", "mod.com/a.AxxBxxCxx"}) - compareSymbols(t, env.WorkspaceSymbol("^mod.com Axx"), []string{"mod.com/a.AxxBxxCxx"}) - compareSymbols(t, env.WorkspaceSymbol("C$"), []string{"ABC"}) + compareSymbols(t, env.Symbol("ABC"), "ABC", "AxxBxxCxx") + compareSymbols(t, env.Symbol("'ABC"), "ABC") + compareSymbols(t, env.Symbol("^mod.com"), "mod.com/a.ABC", "mod.com/a.AxxBxxCxx") + compareSymbols(t, env.Symbol("^mod.com Axx"), "mod.com/a.AxxBxxCxx") + compareSymbols(t, env.Symbol("C$"), "ABC") }) } -func compareSymbols(t *testing.T, got []protocol.SymbolInformation, want []string) { +func compareSymbols(t *testing.T, got []protocol.SymbolInformation, want ...string) { t.Helper() if len(got) != len(want) { t.Errorf("got %d symbols, want %d", len(got), len(want)) |