Skip to content

Commit c224aae

Browse files
committed
gopls/internal/lsp/cmd/test: new integration test for gopls command
This change creates an entirely new set of integration tests for the client-side logic of the gopls command and its subcommands. Each test fork+execs the gopls command and makes assertions about its exit code and stdout/stderr. The tests run in parallel (~3s). This is not intended as a test of server-side behavior. By decoupling the client tests from the server tests, we'll be able to delete all the other files in this directory (in a follow-up), allowing us to reorganize the marker-based tests of the LSP protocol so that they can be used in regtests. Updates golang/go#54845 Change-Id: I5fe11849079f7cc5fe44fc50cfcfd6bbff384014 Reviewed-on: https://go-review.googlesource.com/c/tools/+/463515 gopls-CI: kokoro <noreply+kokoro@google.com> Run-TryBot: Alan Donovan <adonovan@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
1 parent deeb64b commit c224aae

File tree

6 files changed

+948
-51
lines changed

6 files changed

+948
-51
lines changed

gopls/internal/lsp/cmd/call_hierarchy.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,12 @@ func callItemPrintString(ctx context.Context, conn *connection, item protocol.Ca
129129
}
130130
var callRanges []string
131131
for _, rng := range calls {
132-
callSpan, err := callsFile.mapper.LocationSpan(protocol.Location{URI: item.URI, Range: rng})
132+
call, err := callsFile.mapper.RangeSpan(rng)
133133
if err != nil {
134134
return "", err
135135
}
136-
137-
spn := fmt.Sprint(callSpan)
138-
callRanges = append(callRanges, fmt.Sprint(spn[strings.Index(spn, ":")+1:]))
136+
callRange := fmt.Sprintf("%d:%d-%d", call.Start().Line(), call.Start().Column(), call.End().Column())
137+
callRanges = append(callRanges, callRange)
139138
}
140139

141140
printString := fmt.Sprintf("function %s in %v", item.Name, itemSpan)

gopls/internal/lsp/cmd/folding_range.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (r *foldingRanges) Run(ctx context.Context, args ...string) error {
6565
r.StartLine+1,
6666
r.StartCharacter+1,
6767
r.EndLine+1,
68-
r.EndCharacter,
68+
r.EndCharacter+1,
6969
)
7070
}
7171

0 commit comments

Comments
 (0)