mirror of
https://github.com/golang/go
synced 2024-11-18 16:54:43 -07:00
internal/lsp: provide arguments deterministically to packages.Load
This is just to ensure that arguments are always ordered when passed to packages.Load. Change-Id: I2c74673eff31efc31854dc0d306809890f633789 Reviewed-on: https://go-review.googlesource.com/c/tools/+/216600 Run-TryBot: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
9ab2d800b2
commit
345141a368
9
internal/lsp/cache/load.go
vendored
9
internal/lsp/cache/load.go
vendored
@ -8,6 +8,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"go/types"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/tools/go/packages"
|
||||
@ -41,14 +42,10 @@ func (s *snapshot) load(ctx context.Context, scopes ...interface{}) ([]*metadata
|
||||
var query []string
|
||||
for _, scope := range scopes {
|
||||
switch scope := scope.(type) {
|
||||
case []packagePath:
|
||||
case packagePath:
|
||||
// The only time we pass package paths is when we're doing a
|
||||
// partial workspace load. In those cases, the paths came back from
|
||||
// go list and should already be GOPATH-vendorized when appropriate.
|
||||
for _, p := range scope {
|
||||
query = append(query, string(p))
|
||||
}
|
||||
case packagePath:
|
||||
query = append(query, string(scope))
|
||||
case fileURI:
|
||||
query = append(query, fmt.Sprintf("file=%s", span.URI(scope).Filename()))
|
||||
@ -74,6 +71,8 @@ func (s *snapshot) load(ctx context.Context, scopes ...interface{}) ([]*metadata
|
||||
panic(fmt.Sprintf("unknown scope type %T", scope))
|
||||
}
|
||||
}
|
||||
sort.Strings(query) // for determinism
|
||||
|
||||
ctx, done := trace.StartSpan(ctx, "cache.view.load", telemetry.Query.Of(query))
|
||||
defer done()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user