Skip to content

Commit

Permalink
internal/lsp: latest version of LSP stubs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
pjweinbgo committed Sep 13, 2022
1 parent ec74389 commit 9250e22
Show file tree
Hide file tree
Showing 11 changed files with 4,520 additions and 4,802 deletions.
6 changes: 5 additions & 1 deletion gopls/internal/lsp/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import (
"text/tabwriter"
"time"

"golang.org/x/tools/internal/jsonrpc2"
"golang.org/x/tools/gopls/internal/lsp"
"golang.org/x/tools/gopls/internal/lsp/cache"
"golang.org/x/tools/gopls/internal/lsp/debug"
"golang.org/x/tools/gopls/internal/lsp/lsprpc"
"golang.org/x/tools/gopls/internal/lsp/protocol"
"golang.org/x/tools/gopls/internal/lsp/source"
"golang.org/x/tools/internal/jsonrpc2"
"golang.org/x/tools/internal/span"
"golang.org/x/tools/internal/tool"
"golang.org/x/tools/internal/xcontext"
Expand Down Expand Up @@ -422,6 +422,10 @@ func fileURI(uri protocol.DocumentURI) span.URI {
return sURI
}

func (c *cmdClient) CodeLensRefresh(context.Context) error { return nil }

func (c *cmdClient) LogTrace(context.Context, *protocol.LogTraceParams) error { return nil }

func (c *cmdClient) ShowMessage(ctx context.Context, p *protocol.ShowMessageParams) error { return nil }

func (c *cmdClient) ShowMessageRequest(ctx context.Context, p *protocol.ShowMessageRequestParams) (*protocol.MessageActionItem, error) {
Expand Down
4 changes: 4 additions & 0 deletions gopls/internal/lsp/fake/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ type Client struct {
hooks ClientHooks
}

func (c *Client) CodeLensRefresh(context.Context) error { return nil }

func (c *Client) LogTrace(context.Context, *protocol.LogTraceParams) error { return nil }

func (c *Client) ShowMessage(ctx context.Context, params *protocol.ShowMessageParams) error {
if c.hooks.OnShowMessage != nil {
return c.hooks.OnShowMessage(ctx, params)
Expand Down
24 changes: 10 additions & 14 deletions gopls/internal/lsp/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import (
"path/filepath"
"sync"

"golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/jsonrpc2"
"golang.org/x/tools/internal/bug"
"golang.org/x/tools/gopls/internal/lsp/debug"
"golang.org/x/tools/gopls/internal/lsp/protocol"
"golang.org/x/tools/gopls/internal/lsp/source"
"golang.org/x/tools/internal/bug"
"golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/jsonrpc2"
"golang.org/x/tools/internal/span"
)

Expand Down Expand Up @@ -173,10 +173,7 @@ See https://github.com/golang/go/issues/45732 for more information.`,
},
},
},
ServerInfo: struct {
Name string `json:"name"`
Version string `json:"version,omitempty"`
}{
ServerInfo: protocol.PServerInfoMsg_initialize{
Name: "gopls",
Version: string(goplsVersion),
},
Expand Down Expand Up @@ -404,13 +401,12 @@ func (s *Server) fetchConfig(ctx context.Context, name string, folder span.URI,
return nil
}
configs, err := s.client.Configuration(ctx, &protocol.ParamConfiguration{
ConfigurationParams: protocol.ConfigurationParams{
Items: []protocol.ConfigurationItem{{
ScopeURI: string(folder),
Section: "gopls",
}},
},
})
Items: []protocol.ConfigurationItem{{
ScopeURI: string(folder),
Section: "gopls",
}},
},
)
if err != nil {
return fmt.Errorf("failed to get workspace configuration from client (%s): %v", folder, err)
}
Expand Down
15 changes: 0 additions & 15 deletions gopls/internal/lsp/protocol/enums.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

var (
namesTextDocumentSyncKind [int(Incremental) + 1]string
namesInitializeError [int(UnknownProtocolVersion) + 1]string
namesMessageType [int(Log) + 1]string
namesFileChangeType [int(Deleted) + 1]string
namesWatchKind [int(WatchDelete) + 1]string
Expand All @@ -29,8 +28,6 @@ func init() {
namesTextDocumentSyncKind[int(Full)] = "Full"
namesTextDocumentSyncKind[int(Incremental)] = "Incremental"

namesInitializeError[int(UnknownProtocolVersion)] = "UnknownProtocolVersion"

namesMessageType[int(Error)] = "Error"
namesMessageType[int(Warning)] = "Warning"
namesMessageType[int(Info)] = "Info"
Expand Down Expand Up @@ -149,14 +146,6 @@ func ParseTextDocumentSyncKind(s string) TextDocumentSyncKind {
return TextDocumentSyncKind(parseEnum(s, namesTextDocumentSyncKind[:]))
}

func (e InitializeError) Format(f fmt.State, c rune) {
formatEnum(f, c, int(e), namesInitializeError[:], "InitializeError")
}

func ParseInitializeError(s string) InitializeError {
return InitializeError(parseEnum(s, namesInitializeError[:]))
}

func (e MessageType) Format(f fmt.State, c rune) {
formatEnum(f, c, int(e), namesMessageType[:], "MessageType")
}
Expand All @@ -173,10 +162,6 @@ func ParseFileChangeType(s string) FileChangeType {
return FileChangeType(parseEnum(s, namesFileChangeType[:]))
}

func (e WatchKind) Format(f fmt.State, c rune) {
formatEnum(f, c, int(e), namesWatchKind[:], "WatchKind")
}

func ParseWatchKind(s string) WatchKind {
return WatchKind(parseEnum(s, namesWatchKind[:]))
}
Expand Down

0 comments on commit 9250e22

Please sign in to comment.