Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: update protocol generation to support unions #52969

Closed
findleyr opened this issue May 18, 2022 · 8 comments
Closed

x/tools/gopls: update protocol generation to support unions #52969

findleyr opened this issue May 18, 2022 · 8 comments
Assignees
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Contributor

In the implementation of #41567, it is likely that we will need to extend our support for workspace edits.

Specifically, the WorkspaceEdit protocol type supports resource operations creating, renaming, and deleting files:

documentChanges?: (
		[TextDocumentEdit](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocumentEdit)[] |
		([TextDocumentEdit](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocumentEdit) | [CreateFile](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#createFile) | [RenameFile](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#renameFile) | [DeleteFile](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#deleteFile))[]
	);

However, our protocol generation only supports []TextDocumentEdit:
https://cs.opensource.google/go/x/tools/+/master:internal/lsp/protocol/tsprotocol.go;l=5702;drc=b7d757405fe14c924baefbdedd785e4c6a7a0f88

In order to implement package renaming, we'll want to rename directories, and so will need to be able to express this in our WorkspaceEdit response.

CC @dle8 @pjweinb

@findleyr findleyr added this to the gopls/v0.9.0 milestone May 18, 2022
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels May 18, 2022
@findleyr findleyr modified the milestones: gopls/v0.9.0, gopls/v0.9.1 Jun 27, 2022
@findleyr findleyr modified the milestones: gopls/v0.9.1, gopls/v0.9.2 Jul 13, 2022
@findleyr findleyr modified the milestones: gopls/v0.9.2, gopls/v0.10.0 Aug 4, 2022
@gopherbot
Copy link

Change https://go.dev/cl/424214 mentions this issue: internal/lsp: latest version of LSP stubs

gopherbot pushed a commit to golang/tools that referenced this issue Sep 13, 2022
This CL updates the LSP to 3.17.0. It is a DANGEROUS CL as the stubs
are being generated by Go code reading vscode's language independent
description of the protocol (in metaMode.json in the vscode-languageserver-node
repository.)

Some of the union types in the protocol have Go types with names containing  'Or'.
These types have custom marshaling and unmarshaling code.

Embedded structures in the protocol are broken out as their own
types, with names constructed from the context in which they occur.

The natural output has been modified to minimize the number of changes
needed for gopls. (e.g., Workspace6Gn is preserved for compatibility.0
Thus, many types that are union types in the LSP description have been replaced by the
types gopls already uses.

Updates golang/go#52969

Change-Id: I16f6d877215155ac9e782b0f5bcbdab3f1aa2593
Reviewed-on: https://go-review.googlesource.com/c/tools/+/424214
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>
@findleyr
Copy link
Contributor Author

@pjweinb what's left here? Of the top of my head:

  • check in the new generator
  • sync with Dylan's change for DocumentChanges

Anything else?

@pjweinb
Copy link

pjweinb commented Sep 14, 2022 via email

@findleyr
Copy link
Contributor Author

FYI: just filed #55080 for an issue I'm seeing with JSON marshalling now.

@findleyr
Copy link
Contributor Author

I think we should attempt to do some additional conformance testing following #55099. One possibility would be the following:

  1. capture LSP logs from e.g. our regression tests, before and after this change
  2. for each test, do something silly to make the RPCs deterministic, such as sorting them
  3. diff. If there's something causing noise, filter it out, repeat.

@findleyr findleyr modified the milestones: gopls/v0.10.0, gopls/v0.11.0 Oct 11, 2022
@gopherbot
Copy link

Change https://go.dev/cl/443055 mentions this issue: gopls/internal: start on LSP stub generator in Go.

gopherbot pushed a commit to golang/tools that referenced this issue Oct 26, 2022
This is the first in a series of CLs implementing the new stub
generator. The code is intended to reproduce exactly the current
state of the generated code.

This CL has the final file layout, but primarily consists
of the parsing of the specification.

The LSP maintainers now provide a .json file describing the messages and
types used in the protocol. The new code in this CL, written in Go,
parses this file and generates Go definitions.

The tests need to be run by hand because the metaModel.json file is not
available to the presubmit tests.

Related golang/go#52969

Change-Id: Id2fc58c973a92c39ba98c936f2af03b1c40ada44
Reviewed-on: https://go-review.googlesource.com/c/tools/+/443055
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Peter Weinberger <pjw@google.com>
@gopherbot
Copy link

Change https://go.dev/cl/446595 mentions this issue: gopls/internal: LSP stub generator in Go.

@pjweinb
Copy link

pjweinb commented Jan 26, 2023

I think this is done.
(https://go-review.git.corp.google.com/c/tools/+/455475)

@pjweinb pjweinb closed this as completed Jan 26, 2023
@golang golang locked and limited conversation to collaborators Jan 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants