-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deps: upgrade to gopls and x/tools 323f198c (#580)
* internal/lsp: support implementations requests for implementations in other packages 323f198c * go/packages: fix failing Windows TryBots for adhoc packages test dce577ff * internal/lsp: handle the didChangeConfiguration message 74addff5 * internal/lsp: make View.SetOptions save and useful c41a8f58 * tools/gopls: add cmd support for folding_ranges a3f652f1 * internal/lsp/cache: avoid returning errors when building source.Errors 52adfe5c * cmd/go-contrib-init: add unit test for the cmdErr function 9d59ce8a * internal/testenv: reject the resolved 'go' command if it does not match runtime.GOROOT 7dd52f09 * internal/lsp/cache: have NewView create view even if load all packages fails 50fa39b7 * go/analysis/unitchecker: add erroras analysis to align with go vet 8cb0d021 * internal/lsp: support implements for methods on an interface a99edfee * internal/lsp/protocol: define types in alphabetical order in tsprotocol.go 9f4e7946
- Loading branch information
Showing
23 changed files
with
3,170 additions
and
2,826 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
cmd/govim/internal/golang_org_x_tools/lsp/cmd/folding_range.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright 2019 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package cmd | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"fmt" | ||
|
||
"github.com/govim/govim/cmd/govim/internal/golang_org_x_tools/lsp/protocol" | ||
"github.com/govim/govim/cmd/govim/internal/golang_org_x_tools/span" | ||
"github.com/govim/govim/cmd/govim/internal/golang_org_x_tools/tool" | ||
) | ||
|
||
// foldingRanges implements the folding_ranges verb for gopls | ||
type foldingRanges struct { | ||
app *Application | ||
} | ||
|
||
func (r *foldingRanges) Name() string { return "folding_ranges" } | ||
func (r *foldingRanges) Usage() string { return "<file>" } | ||
func (r *foldingRanges) ShortHelp() string { return "display selected file's folding ranges" } | ||
func (r *foldingRanges) DetailedHelp(f *flag.FlagSet) { | ||
fmt.Fprint(f.Output(), ` | ||
Example: | ||
$ gopls folding_ranges helper/helper.go | ||
`) | ||
f.PrintDefaults() | ||
} | ||
|
||
func (r *foldingRanges) Run(ctx context.Context, args ...string) error { | ||
if len(args) != 1 { | ||
return tool.CommandLineErrorf("folding_ranges expects 1 argument (file)") | ||
} | ||
|
||
conn, err := r.app.connect(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
defer conn.terminate(ctx) | ||
|
||
from := span.Parse(args[0]) | ||
file := conn.AddFile(ctx, from.URI()) | ||
if file.err != nil { | ||
return file.err | ||
} | ||
|
||
p := protocol.FoldingRangeParams{ | ||
TextDocument: protocol.TextDocumentIdentifier{ | ||
URI: protocol.NewURI(from.URI()), | ||
}, | ||
} | ||
|
||
ranges, err := conn.FoldingRange(ctx, &p) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, r := range ranges { | ||
fmt.Printf("%v:%v-%v:%v\n", | ||
r.StartLine+1, | ||
r.StartCharacter+1, | ||
r.EndLine+1, | ||
r.EndCharacter, | ||
) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
cmd/govim/internal/golang_org_x_tools/lsp/cmd/test/folding_range.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package cmdtest | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/govim/govim/cmd/govim/internal/golang_org_x_tools/lsp/cmd" | ||
"github.com/govim/govim/cmd/govim/internal/golang_org_x_tools/span" | ||
"github.com/govim/govim/cmd/govim/internal/golang_org_x_tools/tool" | ||
) | ||
|
||
func (r *runner) FoldingRanges(t *testing.T, spn span.Span) { | ||
goldenTag := "foldingRange-cmd" | ||
uri := spn.URI() | ||
filename := uri.Filename() | ||
|
||
app := cmd.New("gopls-test", r.data.Config.Dir, r.data.Config.Env, r.options) | ||
got := CaptureStdOut(t, func() { | ||
err := tool.Run(r.ctx, app, append([]string{"-remote=internal", "folding_ranges"}, filename)) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
}) | ||
|
||
expect := string(r.data.Golden(goldenTag, filename, func() ([]byte, error) { | ||
return []byte(got), nil | ||
})) | ||
|
||
if expect != got { | ||
t.Errorf("folding_ranges failed failed for %s expected:\n%s\ngot:\n%s", filename, expect, got) | ||
} | ||
} |
Oops, something went wrong.