.gitignore added
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.1.1-0.20210319172145-bda8f5cee399 / internal / lsp / command / interface.go
1 // Copyright 2021 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Package command defines the interface provided by gopls for the
6 // workspace/executeCommand LSP request.
7 //
8 // This interface is fully specified by the Interface type, provided it
9 // conforms to the restrictions outlined in its doc string.
10 //
11 // Bindings for server-side command dispatch and client-side serialization are
12 // also provided by this package, via code generation.
13 package command
14
15 //go:generate go run -tags=generate generate.go
16
17 import (
18         "context"
19
20         "golang.org/x/tools/internal/lsp/protocol"
21 )
22
23 // Interface defines the interface gopls exposes for the
24 // workspace/executeCommand request.
25 //
26 // This interface is used to generate marshaling/unmarshaling code, dispatch,
27 // and documentation, and so has some additional restrictions:
28 //  1. All method arguments must be JSON serializable.
29 //  2. Methods must return either error or (T, error), where T is a
30 //     JSON serializable type.
31 //  3. The first line of the doc string is special. Everything after the colon
32 //     is considered the command 'Title'.
33 //     TODO(rFindley): reconsider this -- Title may be unnecessary.
34 type Interface interface {
35         // ApplyFix: Apply a fix
36         //
37         // Applies a fix to a region of source code.
38         ApplyFix(context.Context, ApplyFixArgs) error
39         // Test: Run test(s) (legacy)
40         //
41         // Runs `go test` for a specific set of test or benchmark functions.
42         Test(context.Context, protocol.DocumentURI, []string, []string) error
43
44         // TODO: deprecate Test in favor of RunTests below.
45
46         // Test: Run test(s)
47         //
48         // Runs `go test` for a specific set of test or benchmark functions.
49         RunTests(context.Context, RunTestsArgs) error
50
51         // Generate: Run go generate
52         //
53         // Runs `go generate` for a given directory.
54         Generate(context.Context, GenerateArgs) error
55
56         // RegenerateCgo: Regenerate cgo
57         //
58         // Regenerates cgo definitions.
59         RegenerateCgo(context.Context, URIArg) error
60
61         // Tidy: Run go mod tidy
62         //
63         // Runs `go mod tidy` for a module.
64         Tidy(context.Context, URIArgs) error
65
66         // Vendor: Run go mod vendor
67         //
68         // Runs `go mod vendor` for a module.
69         Vendor(context.Context, URIArg) error
70
71         // UpdateGoSum: Update go.sum
72         //
73         // Updates the go.sum file for a module.
74         UpdateGoSum(context.Context, URIArgs) error
75
76         // CheckUpgrades: Check for upgrades
77         //
78         // Checks for module upgrades.
79         CheckUpgrades(context.Context, CheckUpgradesArgs) error
80
81         // AddDependency: Add dependency
82         //
83         // Adds a dependency to the go.mod file for a module.
84         AddDependency(context.Context, DependencyArgs) error
85
86         // UpgradeDependency: Upgrade dependency
87         //
88         // Upgrades a dependency in the go.mod file for a module.
89         UpgradeDependency(context.Context, DependencyArgs) error
90
91         // RemoveDependency: Remove dependency
92         //
93         // Removes a dependency from the go.mod file of a module.
94         RemoveDependency(context.Context, RemoveDependencyArgs) error
95
96         // GoGetPackage: go get package
97         //
98         // Runs `go get` to fetch a package.
99         GoGetPackage(context.Context, GoGetPackageArgs) error
100
101         // GCDetails: Toggle gc_details
102         //
103         // Toggle the calculation of gc annotations.
104         GCDetails(context.Context, protocol.DocumentURI) error
105
106         // TODO: deprecate GCDetails in favor of ToggleGCDetails below.
107
108         // ToggleGCDetails: Toggle gc_details
109         //
110         // Toggle the calculation of gc annotations.
111         ToggleGCDetails(context.Context, URIArg) error
112
113         // GenerateGoplsMod: Generate gopls.mod
114         //
115         // (Re)generate the gopls.mod file for a workspace.
116         GenerateGoplsMod(context.Context, URIArg) error
117
118         ListKnownPackages(context.Context, URIArg) (ListKnownPackagesResult, error)
119
120         AddImport(context.Context, AddImportArgs) (AddImportResult, error)
121 }
122
123 type RunTestsArgs struct {
124         // The test file containing the tests to run.
125         URI protocol.DocumentURI
126
127         // Specific test names to run, e.g. TestFoo.
128         Tests []string
129
130         // Specific benchmarks to run, e.g. BenchmarkFoo.
131         Benchmarks []string
132 }
133
134 type GenerateArgs struct {
135         // URI for the directory to generate.
136         Dir protocol.DocumentURI
137
138         // Whether to generate recursively (go generate ./...)
139         Recursive bool
140 }
141
142 // TODO(rFindley): document the rest of these once the docgen is fleshed out.
143
144 type ApplyFixArgs struct {
145         // The fix to apply.
146         Fix string
147         // The file URI for the document to fix.
148         URI protocol.DocumentURI
149         // The document range to scan for fixes.
150         Range protocol.Range
151 }
152
153 type URIArg struct {
154         // The file URI.
155         URI protocol.DocumentURI
156 }
157
158 type URIArgs struct {
159         // The file URIs.
160         URIs []protocol.DocumentURI
161 }
162
163 type CheckUpgradesArgs struct {
164         // The go.mod file URI.
165         URI protocol.DocumentURI
166         // The modules to check.
167         Modules []string
168 }
169
170 type DependencyArgs struct {
171         // The go.mod file URI.
172         URI protocol.DocumentURI
173         // Additional args to pass to the go command.
174         GoCmdArgs []string
175         // Whether to add a require directive.
176         AddRequire bool
177 }
178
179 type RemoveDependencyArgs struct {
180         // The go.mod file URI.
181         URI protocol.DocumentURI
182         // The module path to remove.
183         ModulePath     string
184         OnlyDiagnostic bool
185 }
186
187 type GoGetPackageArgs struct {
188         // Any document URI within the relevant module.
189         URI protocol.DocumentURI
190         // The package to go get.
191         Pkg        string
192         AddRequire bool
193 }
194
195 // TODO (Marwan): document :)
196
197 type AddImportArgs struct {
198         ImportPath string
199         URI        protocol.DocumentURI
200 }
201
202 type AddImportResult struct {
203         Edits []protocol.TextDocumentEdit
204 }
205
206 type ListKnownPackagesResult struct {
207         Packages []string
208 }