mirror of
https://github.com/golang/go
synced 2024-11-18 16:44:43 -07:00
internal/lsp: use span.URI constructor everywhere
We should never be converting to a URI directly, in case it's encoded or needs Windows-specific fixes. Change-Id: I8af272f878e2e4faf428bd7b74b7cba4f65093a3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/217086 Run-TryBot: Heschi Kreinick <heschi@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
fe90550fed
commit
b4207ef493
@ -368,7 +368,7 @@ func (c *cmdClient) PublishDiagnostics(ctx context.Context, p *protocol.PublishD
|
||||
c.filesMu.Lock()
|
||||
defer c.filesMu.Unlock()
|
||||
|
||||
uri := span.URI(p.URI)
|
||||
uri := span.NewURI(p.URI)
|
||||
file := c.getFile(ctx, uri)
|
||||
file.diagnostics = p.Diagnostics
|
||||
return nil
|
||||
|
@ -81,7 +81,7 @@ func (r *rename) Run(ctx context.Context, args ...string) error {
|
||||
var orderedURIs []string
|
||||
edits := map[span.URI][]protocol.TextEdit{}
|
||||
for _, c := range edit.DocumentChanges {
|
||||
uri := span.URI(c.TextDocument.URI)
|
||||
uri := span.NewURI(c.TextDocument.URI)
|
||||
edits[uri] = append(edits[uri], c.Edits...)
|
||||
orderedURIs = append(orderedURIs, c.TextDocument.URI)
|
||||
}
|
||||
@ -89,7 +89,7 @@ func (r *rename) Run(ctx context.Context, args ...string) error {
|
||||
changeCount := len(orderedURIs)
|
||||
|
||||
for _, u := range orderedURIs {
|
||||
uri := span.URI(u)
|
||||
uri := span.NewURI(u)
|
||||
cmdFile := conn.AddFile(ctx, uri)
|
||||
filename := cmdFile.uri.Filename()
|
||||
|
||||
|
@ -636,7 +636,7 @@ func (r *runner) Rename(t *testing.T, spn span.Span, newText string) {
|
||||
if i != 0 {
|
||||
got += "\n"
|
||||
}
|
||||
uri := span.URI(orderedURIs[i])
|
||||
uri := span.NewURI(orderedURIs[i])
|
||||
if len(res) > 1 {
|
||||
got += filepath.Base(uri.Filename()) + ":\n"
|
||||
}
|
||||
@ -701,7 +701,7 @@ func (r *runner) PrepareRename(t *testing.T, src span.Span, want *source.Prepare
|
||||
func applyWorkspaceEdits(r *runner, wedit protocol.WorkspaceEdit) (map[span.URI]string, error) {
|
||||
res := map[span.URI]string{}
|
||||
for _, docEdits := range wedit.DocumentChanges {
|
||||
uri := span.URI(docEdits.TextDocument.URI)
|
||||
uri := span.NewURI(docEdits.TextDocument.URI)
|
||||
m, err := r.data.Mapper(uri)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -1006,7 +1006,7 @@ func TestModfileSuggestedFixes(t *testing.T) {
|
||||
}
|
||||
res := map[span.URI]string{}
|
||||
for _, docEdits := range actions[0].Edit.DocumentChanges {
|
||||
uri := span.URI(docEdits.TextDocument.URI)
|
||||
uri := span.NewURI(docEdits.TextDocument.URI)
|
||||
content, err := ioutil.ReadFile(uri.Filename())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -115,7 +115,7 @@ func (s *Server) nonstandardRequest(ctx context.Context, method string, params i
|
||||
paramMap := params.(map[string]interface{})
|
||||
if method == "gopls/diagnoseFiles" {
|
||||
for _, file := range paramMap["files"].([]interface{}) {
|
||||
uri := span.URI(file.(string))
|
||||
uri := span.NewURI(file.(string))
|
||||
view, err := s.session.ViewOf(uri)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user