Skip to content

Commit

Permalink
gopls/internal/lsp/cmd: don't use x/exp/slices
Browse files Browse the repository at this point in the history
A direct dependency on x/exp/slices was added in CL 497756. As a matter
of policy, we don't depend on x/exp from gopls. Also, this left the
module in an untidy state.

I suspect that the slices package was added by a bad goimports
operation, which is another issue entirely. In any case, the standard
library slices package is not available in 1.18.

Change-Id: I76b78313537ef9918317ecec25c4b12ed526c62f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/524817
gopls-CI: kokoro <noreply+kokoro@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
  • Loading branch information
findleyr authored and gopherbot committed Sep 1, 2023
1 parent 77c6ac6 commit 5a96569
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions gopls/internal/lsp/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"text/tabwriter"
"time"

"golang.org/x/exp/slices"
"golang.org/x/tools/gopls/internal/lsp"
"golang.org/x/tools/gopls/internal/lsp/browser"
"golang.org/x/tools/gopls/internal/lsp/cache"
Expand Down Expand Up @@ -547,22 +546,23 @@ func (c *cmdClient) ApplyEdit(ctx context.Context, p *protocol.ApplyWorkspaceEdi
// files, honoring the preferred edit mode specified by cli.app.editMode.
// (Used by rename and by ApplyEdit downcalls.)
func (cli *cmdClient) applyWorkspaceEdit(edit *protocol.WorkspaceEdit) error {
var orderedURIs []span.URI
var orderedURIs []string
edits := map[span.URI][]protocol.TextEdit{}
for _, c := range edit.DocumentChanges {
if c.TextDocumentEdit != nil {
uri := fileURI(c.TextDocumentEdit.TextDocument.URI)
edits[uri] = append(edits[uri], c.TextDocumentEdit.Edits...)
orderedURIs = append(orderedURIs, uri)
orderedURIs = append(orderedURIs, string(uri))
}
if c.RenameFile != nil {
return fmt.Errorf("client does not support file renaming (%s -> %s)",
c.RenameFile.OldURI,
c.RenameFile.NewURI)
}
}
slices.Sort(orderedURIs)
for _, uri := range orderedURIs {
sort.Strings(orderedURIs)
for _, u := range orderedURIs {
uri := span.URIFromURI(u)
f := cli.openFile(uri)
if f.err != nil {
return f.err
Expand Down

0 comments on commit 5a96569

Please sign in to comment.