Skip to content

Commit b5e741b

Browse files
committed
gopls/internal/cmd: rename conn to cli
This renaming was partially achieved using an LLM-based agent. But then I got bored of waiting for it to deal with each file in turn and did the whole job much faster using sed and Emacs. Change-Id: If74f920ada1ce43c1077d3a4851442fd4f2dd84a Reviewed-on: https://go-review.googlesource.com/c/tools/+/685275 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 8b11e06 commit b5e741b

22 files changed

+106
-106
lines changed

gopls/internal/cmd/call_hierarchy.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ func (c *callHierarchy) Run(ctx context.Context, args ...string) error {
3939
return tool.CommandLineErrorf("call_hierarchy expects 1 argument (position)")
4040
}
4141

42-
conn, _, err := c.app.connect(ctx)
42+
cli, _, err := c.app.connect(ctx)
4343
if err != nil {
4444
return err
4545
}
46-
defer conn.terminate(ctx)
46+
defer cli.terminate(ctx)
4747

4848
from := parseSpan(args[0])
49-
file, err := conn.openFile(ctx, from.URI())
49+
file, err := cli.openFile(ctx, from.URI())
5050
if err != nil {
5151
return err
5252
}
@@ -60,7 +60,7 @@ func (c *callHierarchy) Run(ctx context.Context, args ...string) error {
6060
TextDocumentPositionParams: protocol.LocationTextDocumentPositionParams(loc),
6161
}
6262

63-
callItems, err := conn.server.PrepareCallHierarchy(ctx, &p)
63+
callItems, err := cli.server.PrepareCallHierarchy(ctx, &p)
6464
if err != nil {
6565
return err
6666
}
@@ -69,34 +69,34 @@ func (c *callHierarchy) Run(ctx context.Context, args ...string) error {
6969
}
7070

7171
for _, item := range callItems {
72-
incomingCalls, err := conn.server.IncomingCalls(ctx, &protocol.CallHierarchyIncomingCallsParams{Item: item})
72+
incomingCalls, err := cli.server.IncomingCalls(ctx, &protocol.CallHierarchyIncomingCallsParams{Item: item})
7373
if err != nil {
7474
return err
7575
}
7676
for i, call := range incomingCalls {
7777
// From the spec: CallHierarchyIncomingCall.FromRanges is relative to
7878
// the caller denoted by CallHierarchyIncomingCall.from.
79-
printString, err := callItemPrintString(ctx, conn, call.From, call.From.URI, call.FromRanges)
79+
printString, err := callItemPrintString(ctx, cli, call.From, call.From.URI, call.FromRanges)
8080
if err != nil {
8181
return err
8282
}
8383
fmt.Printf("caller[%d]: %s\n", i, printString)
8484
}
8585

86-
printString, err := callItemPrintString(ctx, conn, item, "", nil)
86+
printString, err := callItemPrintString(ctx, cli, item, "", nil)
8787
if err != nil {
8888
return err
8989
}
9090
fmt.Printf("identifier: %s\n", printString)
9191

92-
outgoingCalls, err := conn.server.OutgoingCalls(ctx, &protocol.CallHierarchyOutgoingCallsParams{Item: item})
92+
outgoingCalls, err := cli.server.OutgoingCalls(ctx, &protocol.CallHierarchyOutgoingCallsParams{Item: item})
9393
if err != nil {
9494
return err
9595
}
9696
for i, call := range outgoingCalls {
9797
// From the spec: CallHierarchyOutgoingCall.FromRanges is the range
9898
// relative to the caller, e.g the item passed to
99-
printString, err := callItemPrintString(ctx, conn, call.To, item.URI, call.FromRanges)
99+
printString, err := callItemPrintString(ctx, cli, call.To, item.URI, call.FromRanges)
100100
if err != nil {
101101
return err
102102
}
@@ -109,8 +109,8 @@ func (c *callHierarchy) Run(ctx context.Context, args ...string) error {
109109

110110
// callItemPrintString returns a protocol.CallHierarchyItem object represented as a string.
111111
// item and call ranges (protocol.Range) are converted to user friendly spans (1-indexed).
112-
func callItemPrintString(ctx context.Context, conn *client, item protocol.CallHierarchyItem, callsURI protocol.DocumentURI, calls []protocol.Range) (string, error) {
113-
itemFile, err := conn.openFile(ctx, item.URI)
112+
func callItemPrintString(ctx context.Context, cli *client, item protocol.CallHierarchyItem, callsURI protocol.DocumentURI, calls []protocol.Range) (string, error) {
113+
itemFile, err := cli.openFile(ctx, item.URI)
114114
if err != nil {
115115
return "", err
116116
}
@@ -121,7 +121,7 @@ func callItemPrintString(ctx context.Context, conn *client, item protocol.CallHi
121121

122122
var callRanges []string
123123
if callsURI != "" {
124-
callsFile, err := conn.openFile(ctx, callsURI)
124+
callsFile, err := cli.openFile(ctx, callsURI)
125125
if err != nil {
126126
return "", err
127127
}

gopls/internal/cmd/check.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ func (c *check) Run(ctx context.Context, args ...string) error {
6666
opts.RelatedInformationSupported = true
6767
}
6868

69-
conn, _, err := c.app.connect(ctx)
69+
cli, _, err := c.app.connect(ctx)
7070
if err != nil {
7171
return err
7272
}
73-
defer conn.terminate(ctx)
73+
defer cli.terminate(ctx)
7474

7575
// Open and diagnose the requested files.
7676
var (
@@ -80,19 +80,19 @@ func (c *check) Run(ctx context.Context, args ...string) error {
8080
for _, arg := range args {
8181
uri := protocol.URIFromPath(arg)
8282
uris = append(uris, uri)
83-
file, err := conn.openFile(ctx, uri)
83+
file, err := cli.openFile(ctx, uri)
8484
if err != nil {
8585
return err
8686
}
8787
checking[uri] = file
8888
}
89-
if err := diagnoseFiles(ctx, conn.server, uris); err != nil {
89+
if err := diagnoseFiles(ctx, cli.server, uris); err != nil {
9090
return err
9191
}
9292

9393
// print prints a single element of a diagnostic.
9494
print := func(uri protocol.DocumentURI, rng protocol.Range, message string) error {
95-
file, err := conn.openFile(ctx, uri)
95+
file, err := cli.openFile(ctx, uri)
9696
if err != nil {
9797
return err
9898
}

gopls/internal/cmd/codeaction.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ func (cmd *codeaction) Run(ctx context.Context, args ...string) error {
108108
return tool.CommandLineErrorf("codeaction expects at least 1 argument")
109109
}
110110
cmd.app.editFlags = &cmd.EditFlags
111-
conn, _, err := cmd.app.connect(ctx)
111+
cli, _, err := cmd.app.connect(ctx)
112112
if err != nil {
113113
return err
114114
}
115-
defer conn.terminate(ctx)
115+
defer cli.terminate(ctx)
116116

117117
from := parseSpan(args[0])
118118
uri := from.URI()
119-
file, err := conn.openFile(ctx, uri)
119+
file, err := cli.openFile(ctx, uri)
120120
if err != nil {
121121
return err
122122
}
@@ -131,7 +131,7 @@ func (cmd *codeaction) Run(ctx context.Context, args ...string) error {
131131
}
132132

133133
// Get diagnostics, as they may encode various lazy code actions.
134-
if err := diagnoseFiles(ctx, conn.server, []protocol.DocumentURI{uri}); err != nil {
134+
if err := diagnoseFiles(ctx, cli.server, []protocol.DocumentURI{uri}); err != nil {
135135
return err
136136
}
137137
file.diagnosticsMu.Lock()
@@ -147,7 +147,7 @@ func (cmd *codeaction) Run(ctx context.Context, args ...string) error {
147147
} else {
148148
kinds = append(kinds, protocol.Empty) // => all
149149
}
150-
actions, err := conn.server.CodeAction(ctx, &protocol.CodeActionParams{
150+
actions, err := cli.server.CodeAction(ctx, &protocol.CodeActionParams{
151151
TextDocument: protocol.TextDocumentIdentifier{URI: uri},
152152
Range: rng,
153153
Context: protocol.CodeActionContext{
@@ -184,7 +184,7 @@ func (cmd *codeaction) Run(ctx context.Context, args ...string) error {
184184
if act.Command != nil {
185185
// This may cause the server to make
186186
// an ApplyEdit downcall to the client.
187-
if _, err := executeCommand(ctx, conn.server, act.Command); err != nil {
187+
if _, err := executeCommand(ctx, cli.server, act.Command); err != nil {
188188
return err
189189
}
190190
// The specification says that commands should
@@ -193,7 +193,7 @@ func (cmd *codeaction) Run(ctx context.Context, args ...string) error {
193193
// duplicate edits.
194194
} else {
195195
// Partially apply CodeAction.Edit, a WorkspaceEdit.
196-
// (See also conn.Client.applyWorkspaceEdit(a.Edit)).
196+
// (See also cli.applyWorkspaceEdit(a.Edit)).
197197
for _, c := range act.Edit.DocumentChanges {
198198
tde := c.TextDocumentEdit
199199
if tde != nil && tde.TextDocument.URI == uri {

gopls/internal/cmd/codelens.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ func (r *codelens) Run(ctx context.Context, args ...string) error {
8383
opts.Codelenses[settings.CodeLensTest] = true
8484
}
8585

86-
conn, _, err := r.app.connect(ctx)
86+
cli, _, err := r.app.connect(ctx)
8787
if err != nil {
8888
return err
8989
}
90-
defer conn.terminate(ctx)
90+
defer cli.terminate(ctx)
9191

9292
filespan := parseSpan(filename)
93-
file, err := conn.openFile(ctx, filespan.URI())
93+
file, err := cli.openFile(ctx, filespan.URI())
9494
if err != nil {
9595
return err
9696
}
@@ -102,7 +102,7 @@ func (r *codelens) Run(ctx context.Context, args ...string) error {
102102
p := protocol.CodeLensParams{
103103
TextDocument: protocol.TextDocumentIdentifier{URI: loc.URI},
104104
}
105-
lenses, err := conn.server.CodeLens(ctx, &p)
105+
lenses, err := cli.server.CodeLens(ctx, &p)
106106
if err != nil {
107107
return err
108108
}
@@ -122,7 +122,7 @@ func (r *codelens) Run(ctx context.Context, args ...string) error {
122122

123123
// -exec: run the first matching code lens.
124124
if r.Exec {
125-
_, err := executeCommand(ctx, conn.server, lens.Command)
125+
_, err := executeCommand(ctx, cli.server, lens.Command)
126126
return err
127127
}
128128

gopls/internal/cmd/definition.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ func (d *definition) Run(ctx context.Context, args ...string) error {
7373
o.PreferredContentFormat = protocol.Markdown
7474
}
7575
}
76-
conn, _, err := d.app.connect(ctx)
76+
cli, _, err := d.app.connect(ctx)
7777
if err != nil {
7878
return err
7979
}
80-
defer conn.terminate(ctx)
80+
defer cli.terminate(ctx)
8181
from := parseSpan(args[0])
82-
file, err := conn.openFile(ctx, from.URI())
82+
file, err := cli.openFile(ctx, from.URI())
8383
if err != nil {
8484
return err
8585
}
@@ -90,15 +90,15 @@ func (d *definition) Run(ctx context.Context, args ...string) error {
9090
p := protocol.DefinitionParams{
9191
TextDocumentPositionParams: protocol.LocationTextDocumentPositionParams(loc),
9292
}
93-
locs, err := conn.server.Definition(ctx, &p)
93+
locs, err := cli.server.Definition(ctx, &p)
9494
if err != nil {
9595
return fmt.Errorf("%v: %v", from, err)
9696
}
9797

9898
if len(locs) == 0 {
9999
return fmt.Errorf("%v: no definition location (not an identifier?)", from)
100100
}
101-
file, err = conn.openFile(ctx, locs[0].URI)
101+
file, err = cli.openFile(ctx, locs[0].URI)
102102
if err != nil {
103103
return fmt.Errorf("%v: %v", from, err)
104104
}
@@ -110,7 +110,7 @@ func (d *definition) Run(ctx context.Context, args ...string) error {
110110
q := protocol.HoverParams{
111111
TextDocumentPositionParams: protocol.LocationTextDocumentPositionParams(loc),
112112
}
113-
hover, err := conn.server.Hover(ctx, &q)
113+
hover, err := cli.server.Hover(ctx, &q)
114114
if err != nil {
115115
return fmt.Errorf("%v: %v", from, err)
116116
}

gopls/internal/cmd/execute.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ func (e *execute) Run(ctx context.Context, args ...string) error {
7171

7272
e.app.editFlags = &e.EditFlags // in case command performs an edit
7373

74-
conn, _, err := e.app.connect(ctx)
74+
cli, _, err := e.app.connect(ctx)
7575
if err != nil {
7676
return err
7777
}
78-
defer conn.terminate(ctx)
78+
defer cli.terminate(ctx)
7979

80-
res, err := executeCommand(ctx, conn.server, &protocol.Command{
80+
res, err := executeCommand(ctx, cli.server, &protocol.Command{
8181
Command: cmd,
8282
Arguments: jsonArgs,
8383
})

gopls/internal/cmd/folding_range.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ func (r *foldingRanges) Run(ctx context.Context, args ...string) error {
3636
return tool.CommandLineErrorf("folding_ranges expects 1 argument (file)")
3737
}
3838

39-
conn, _, err := r.app.connect(ctx)
39+
cli, _, err := r.app.connect(ctx)
4040
if err != nil {
4141
return err
4242
}
43-
defer conn.terminate(ctx)
43+
defer cli.terminate(ctx)
4444

4545
from := parseSpan(args[0])
46-
if _, err := conn.openFile(ctx, from.URI()); err != nil {
46+
if _, err := cli.openFile(ctx, from.URI()); err != nil {
4747
return err
4848
}
4949

@@ -53,7 +53,7 @@ func (r *foldingRanges) Run(ctx context.Context, args ...string) error {
5353
},
5454
}
5555

56-
ranges, err := conn.server.FoldingRange(ctx, &p)
56+
ranges, err := cli.server.FoldingRange(ctx, &p)
5757
if err != nil {
5858
return err
5959
}

gopls/internal/cmd/format.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ func (c *format) Run(ctx context.Context, args ...string) error {
4242
return nil
4343
}
4444
c.app.editFlags = &c.EditFlags
45-
conn, _, err := c.app.connect(ctx)
45+
cli, _, err := c.app.connect(ctx)
4646
if err != nil {
4747
return err
4848
}
49-
defer conn.terminate(ctx)
49+
defer cli.terminate(ctx)
5050
for _, arg := range args {
5151
spn := parseSpan(arg)
52-
file, err := conn.openFile(ctx, spn.URI())
52+
file, err := cli.openFile(ctx, spn.URI())
5353
if err != nil {
5454
return err
5555
}
@@ -63,7 +63,7 @@ func (c *format) Run(ctx context.Context, args ...string) error {
6363
p := protocol.DocumentFormattingParams{
6464
TextDocument: protocol.TextDocumentIdentifier{URI: loc.URI},
6565
}
66-
edits, err := conn.server.Formatting(ctx, &p)
66+
edits, err := cli.server.Formatting(ctx, &p)
6767
if err != nil {
6868
return fmt.Errorf("%v: %v", spn, err)
6969
}

gopls/internal/cmd/highlight.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ func (r *highlight) Run(ctx context.Context, args ...string) error {
3838
return tool.CommandLineErrorf("highlight expects 1 argument (position)")
3939
}
4040

41-
conn, _, err := r.app.connect(ctx)
41+
cli, _, err := r.app.connect(ctx)
4242
if err != nil {
4343
return err
4444
}
45-
defer conn.terminate(ctx)
45+
defer cli.terminate(ctx)
4646

4747
from := parseSpan(args[0])
48-
file, err := conn.openFile(ctx, from.URI())
48+
file, err := cli.openFile(ctx, from.URI())
4949
if err != nil {
5050
return err
5151
}
@@ -58,7 +58,7 @@ func (r *highlight) Run(ctx context.Context, args ...string) error {
5858
p := protocol.DocumentHighlightParams{
5959
TextDocumentPositionParams: protocol.LocationTextDocumentPositionParams(loc),
6060
}
61-
highlights, err := conn.server.DocumentHighlight(ctx, &p)
61+
highlights, err := cli.server.DocumentHighlight(ctx, &p)
6262
if err != nil {
6363
return err
6464
}

gopls/internal/cmd/implementation.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ func (i *implementation) Run(ctx context.Context, args ...string) error {
3939
return tool.CommandLineErrorf("implementation expects 1 argument (position)")
4040
}
4141

42-
conn, _, err := i.app.connect(ctx)
42+
cli, _, err := i.app.connect(ctx)
4343
if err != nil {
4444
return err
4545
}
46-
defer conn.terminate(ctx)
46+
defer cli.terminate(ctx)
4747

4848
from := parseSpan(args[0])
49-
file, err := conn.openFile(ctx, from.URI())
49+
file, err := cli.openFile(ctx, from.URI())
5050
if err != nil {
5151
return err
5252
}
@@ -59,14 +59,14 @@ func (i *implementation) Run(ctx context.Context, args ...string) error {
5959
p := protocol.ImplementationParams{
6060
TextDocumentPositionParams: protocol.LocationTextDocumentPositionParams(loc),
6161
}
62-
implementations, err := conn.server.Implementation(ctx, &p)
62+
implementations, err := cli.server.Implementation(ctx, &p)
6363
if err != nil {
6464
return err
6565
}
6666

6767
var spans []string
6868
for _, impl := range implementations {
69-
f, err := conn.openFile(ctx, impl.URI)
69+
f, err := cli.openFile(ctx, impl.URI)
7070
if err != nil {
7171
return err
7272
}

0 commit comments

Comments
 (0)