internal/lsp/source: offer the fast fuzzy matcher as an option

Hook up the new fast SymbolMatcher as an option.

Benchmark ("test" in x/tools): 48ms->21ms (with the new matcher)
Benchmark ("test" in kubernetes): 857ms->199ms (with the new matcher)

Change-Id: Ic638eda1ed10572638f32879dd9b56467ae305ef
Reviewed-on: https://go-review.googlesource.com/c/tools/+/338695
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Rob Findley 2021-07-30 15:23:27 -04:00 committed by Robert Findley
parent bfe69c31e5
commit f35d7dcca5
4 changed files with 9 additions and 0 deletions

View File

@ -397,6 +397,7 @@ Must be one of:
* `"CaseInsensitive"`
* `"CaseSensitive"`
* `"FastFuzzy"`
* `"Fuzzy"`
Default: `"Fuzzy"`.

View File

@ -325,6 +325,10 @@ var GeneratedAPIJSON = &APIJSON{
Value: "\"CaseSensitive\"",
Doc: "",
},
{
Value: "\"FastFuzzy\"",
Doc: "",
},
{
Value: "\"Fuzzy\"",
Doc: "",

View File

@ -543,6 +543,7 @@ type SymbolMatcher string
const (
SymbolFuzzy SymbolMatcher = "Fuzzy"
SymbolFastFuzzy SymbolMatcher = "FastFuzzy"
SymbolCaseInsensitive SymbolMatcher = "CaseInsensitive"
SymbolCaseSensitive SymbolMatcher = "CaseSensitive"
)
@ -834,6 +835,7 @@ func (o *Options) set(name string, value interface{}, seen map[string]struct{})
case "symbolMatcher":
if s, ok := result.asOneOf(
string(SymbolFuzzy),
string(SymbolFastFuzzy),
string(SymbolCaseInsensitive),
string(SymbolCaseSensitive),
); ok {

View File

@ -157,6 +157,8 @@ func newSymbolCollector(matcher SymbolMatcher, style SymbolStyle, query string)
switch matcher {
case SymbolFuzzy:
m = parseQuery(query)
case SymbolFastFuzzy:
m = fuzzy.NewSymbolMatcher(query).Match
case SymbolCaseSensitive:
m = matchExact(query)
case SymbolCaseInsensitive: