Skip to content

Commit 3f6c3b3

Browse files
committed
gopls: upgrade to latest version of LSP protocol
There are no actual changes, but it's good to be up to date. And README.md changed to suppress markdown warnings. Change-Id: I013ed9065963f41002c7fb946f38188fa3a1ddb1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/491296 TryBot-Result: Gopher Robot <gobot@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> Run-TryBot: Peter Weinberger <pjw@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
1 parent 216928d commit 3f6c3b3

File tree

6 files changed

+17
-9
lines changed

6 files changed

+17
-9
lines changed

gopls/internal/lsp/protocol/generate/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ web page, or in the vscode-languageserver-node repository. This code uses the la
1313
exact version can be tied to a githash. By default, the command will download the `github.com/microsoft/vscode-languageserver-node` repository to a temporary directory.
1414

1515
The specification has five sections
16+
1617
1. Requests, which describe the Request and Response types for request methods (e.g., *textDocument/didChange*),
1718
2. Notifications, which describe the Request types for notification methods,
1819
3. Structures, which describe named struct-like types,
@@ -28,13 +29,15 @@ may need to be modified to avoid name collisions. (See the `disambiguate` map, a
2829
Finally, the specified types are Typescript types, which are quite different from Go types.
2930

3031
### Optionality
32+
3133
The specification can mark fields in structs as Optional. The client distinguishes between missing
3234
fields and `null` fields in some cases. The Go translation for an optional type
3335
should be making sure the field's value
3436
can be `nil`, and adding the json tag `,omitempty`. The former condition would be satisfied by
3537
adding `*` to the field's type if the type is not a reference type.
3638

3739
### Types
40+
3841
The specification uses a number of different types, only a few of which correspond directly to Go types.
3942
The specification's types are "base", "reference", "map", "literal", "stringLiteral", "tuple", "and", "or".
4043
The "base" types correspond directly to Go types, although some Go types needs to be chosen for `URI` and `DocumentUri`. (The "base" types`RegExp`, `BooleanLiteral`, `NumericLiteral` never occur.)
@@ -70,6 +73,7 @@ will have one of the permitted types. (`nil` is always allowed.) There are about
7073
have a single non-null component, and these are converted to the component type.
7174

7275
## Processing
76+
7377
The code parses the json specification file, and scans all the types. It assigns names, as described
7478
above, to the types that are unnamed in the specification, and constructs Go equivalents as required.
7579
(Most of this code is in typenames.go.)
@@ -80,6 +84,7 @@ of the Request or Notification. tsjson.go contains the custom marshaling and unm
8084
And tsprotocol.go contains the type and const definitions.
8185

8286
### Accommodating gopls
87+
8388
As the code generates output, mostly in generateoutput.go and main.go,
8489
it makes adjustments so that no changes are required to the existing Go code.
8590
(Organizing the computation this way makes the code's structure simpler, but results in
@@ -107,6 +112,7 @@ The solution is to make `LSPAny` an `interface{}`. Another instance is `_Initial
107112
whose type is an "or" of 3 stringLiterals, which just becomes a `string`.
108113

109114
### Checking
115+
110116
`TestAll(t *testing.T)` checks that there are no unexpected fields in the json specification.
111117

112118
While the code is executing, it checks that all the entries in the maps in tables.go are used.
@@ -119,6 +125,7 @@ that the older, more heuristic, code did not generate. (And the unused type `_In
119125
slightly between the new and the old, and is not worth fixing.)
120126

121127
### Some history
128+
122129
The original stub code was written by hand, but with the protocol under active development, that
123130
couldn't last. The web page existed before the json specification, but it lagged the implementation
124131
and was hard to process by machine. So the earlier version of the generating code was written in Typescript, and
@@ -128,6 +135,7 @@ to pick out the elements of the protocol, and another set of overlapping heurist
128135
The output was functional, but idiosyncratic, and the code was fragile and barely maintainable.
129136

130137
### The future
138+
131139
Most of the adjustments using the maps in tables.go could be removed by making changes, mostly to names,
132140
in the gopls code. Using more "or" types in gopls requires more elaborate, but stereotyped, changes.
133141
But even without all the adjustments, making this its own module would face problems; a number of

gopls/internal/lsp/protocol/generate/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const vscodeRepo = "https://github.com/microsoft/vscode-languageserver-node"
3131
// For example, tag release/protocol/3.17.3 of the repo defines protocol version 3.17.0.
3232
// (Point releases are reflected in the git tag version even when they are cosmetic
3333
// and don't change the protocol.)
34-
var lspGitRef = "release/protocol/3.17.3-next.6"
34+
var lspGitRef = "release/protocol/3.17.4-next.0"
3535

3636
var (
3737
repodir = flag.String("d", "", "directory containing clone of "+vscodeRepo)

gopls/internal/lsp/protocol/tsclient.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gopls/internal/lsp/protocol/tsjson.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gopls/internal/lsp/protocol/tsprotocol.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gopls/internal/lsp/protocol/tsserver.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)