internal/lsp/protocol: update LSP definitions and stubs
There are some (presumably provisional) new RPCs, PrepareTypeHierarchy,
SuperTYpes, and Subtypes. ServerCapabilities has a corresponding field
TypeHierarchyProvider, and the client has TypeHierarchy which is
a TypeHierarchyClientCapabilities
The name of the return type of ApplyEdit has been changed from
ApplyWorkspaceResponse to ApplyWorkspaceResult.
(its content has not changed, just the name)
srver_gen.go and its generator helper/helper.go needed a small change
to avoid using _ as an argument.
Change-Id: I8fc828e69659e0333af686ec1dd138b0c09c1c62
Reviewed-on: https://go-review.googlesource.com/c/tools/+/353169
Run-TryBot: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Peter Weinberger <pjw@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/internal/lsp/cmd/cmd.go b/internal/lsp/cmd/cmd.go
index ad344f7..8245e12 100644
--- a/internal/lsp/cmd/cmd.go
+++ b/internal/lsp/cmd/cmd.go
@@ -418,8 +418,8 @@
return results, nil
}
-func (c *cmdClient) ApplyEdit(ctx context.Context, p *protocol.ApplyWorkspaceEditParams) (*protocol.ApplyWorkspaceEditResponse, error) {
- return &protocol.ApplyWorkspaceEditResponse{Applied: false, FailureReason: "not implemented"}, nil
+func (c *cmdClient) ApplyEdit(ctx context.Context, p *protocol.ApplyWorkspaceEditParams) (*protocol.ApplyWorkspaceEditResult, error) {
+ return &protocol.ApplyWorkspaceEditResult{Applied: false, FailureReason: "not implemented"}, nil
}
func (c *cmdClient) PublishDiagnostics(ctx context.Context, p *protocol.PublishDiagnosticsParams) error {
diff --git a/internal/lsp/fake/client.go b/internal/lsp/fake/client.go
index 331b9bd..fdc67a6 100644
--- a/internal/lsp/fake/client.go
+++ b/internal/lsp/fake/client.go
@@ -115,14 +115,14 @@
}
// ApplyEdit applies edits sent from the server.
-func (c *Client) ApplyEdit(ctx context.Context, params *protocol.ApplyWorkspaceEditParams) (*protocol.ApplyWorkspaceEditResponse, error) {
+func (c *Client) ApplyEdit(ctx context.Context, params *protocol.ApplyWorkspaceEditParams) (*protocol.ApplyWorkspaceEditResult, error) {
if len(params.Edit.Changes) != 0 {
- return &protocol.ApplyWorkspaceEditResponse{FailureReason: "Edit.Changes is unsupported"}, nil
+ return &protocol.ApplyWorkspaceEditResult{FailureReason: "Edit.Changes is unsupported"}, nil
}
for _, change := range params.Edit.DocumentChanges {
if err := c.editor.applyProtocolEdit(ctx, change); err != nil {
return nil, err
}
}
- return &protocol.ApplyWorkspaceEditResponse{Applied: true}, nil
+ return &protocol.ApplyWorkspaceEditResult{Applied: true}, nil
}
diff --git a/internal/lsp/helper/helper.go b/internal/lsp/helper/helper.go
index e9e71e6..cadda02 100644
--- a/internal/lsp/helper/helper.go
+++ b/internal/lsp/helper/helper.go
@@ -158,6 +158,9 @@
nm := ""
if len(f.Names) > 0 {
nm = f.Names[0].String()
+ if nm == "_" {
+ nm = "_gen"
+ }
}
fx.paramnames = append(fx.paramnames, nm)
}
diff --git a/internal/lsp/lsp_test.go b/internal/lsp/lsp_test.go
index d21d71d..32cd597 100644
--- a/internal/lsp/lsp_test.go
+++ b/internal/lsp/lsp_test.go
@@ -117,13 +117,13 @@
return nil
}
-func (c testClient) ApplyEdit(ctx context.Context, params *protocol.ApplyWorkspaceEditParams) (*protocol.ApplyWorkspaceEditResponse, error) {
+func (c testClient) ApplyEdit(ctx context.Context, params *protocol.ApplyWorkspaceEditParams) (*protocol.ApplyWorkspaceEditResult, error) {
res, err := applyTextDocumentEdits(c.runner, params.Edit.DocumentChanges)
if err != nil {
return nil, err
}
c.runner.editRecv <- res
- return &protocol.ApplyWorkspaceEditResponse{Applied: true}, nil
+ return &protocol.ApplyWorkspaceEditResult{Applied: true}, nil
}
func (r *runner) CallHierarchy(t *testing.T, spn span.Span, expectedCalls *tests.CallHierarchyResult) {
diff --git a/internal/lsp/protocol/tsclient.go b/internal/lsp/protocol/tsclient.go
index 9a88f33..646beb0 100644
--- a/internal/lsp/protocol/tsclient.go
+++ b/internal/lsp/protocol/tsclient.go
@@ -6,8 +6,8 @@
// Package protocol contains data types and code for LSP jsonrpcs
// generated automatically from vscode-languageserver-node
-// commit: 0cb3812e7d540ef3a904e96df795bc37a21de9b0
-// last fetched Mon Aug 02 2021 10:08:19 GMT-0400 (Eastern Daylight Time)
+// commit: 10b56de150ad67c3c330da8e2df53ebf2cf347c4
+// last fetched Wed Sep 29 2021 12:31:31 GMT-0400 (Eastern Daylight Time)
// Code generated (see typescript/README.md) DO NOT EDIT.
@@ -32,7 +32,7 @@
RegisterCapability(context.Context, *RegistrationParams) error
UnregisterCapability(context.Context, *UnregistrationParams) error
ShowMessageRequest(context.Context, *ShowMessageRequestParams) (*MessageActionItem /*MessageActionItem | null*/, error)
- ApplyEdit(context.Context, *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResponse, error)
+ ApplyEdit(context.Context, *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error)
}
func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, r jsonrpc2.Request) (bool, error) {
@@ -196,8 +196,8 @@
return result, nil
}
-func (s *clientDispatcher) ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResponse, error) {
- var result *ApplyWorkspaceEditResponse
+func (s *clientDispatcher) ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) {
+ var result *ApplyWorkspaceEditResult
if err := s.sender.Call(ctx, "workspace/applyEdit", params, &result); err != nil {
return nil, err
}
diff --git a/internal/lsp/protocol/tsprotocol.go b/internal/lsp/protocol/tsprotocol.go
index fe0e749..f587d0f 100644
--- a/internal/lsp/protocol/tsprotocol.go
+++ b/internal/lsp/protocol/tsprotocol.go
@@ -4,8 +4,8 @@
// Package protocol contains data types and code for LSP jsonrpcs
// generated automatically from vscode-languageserver-node
-// commit: 0cb3812e7d540ef3a904e96df795bc37a21de9b0
-// last fetched Mon Aug 02 2021 10:08:19 GMT-0400 (Eastern Daylight Time)
+// commit: 10b56de150ad67c3c330da8e2df53ebf2cf347c4
+// last fetched Wed Sep 29 2021 12:31:31 GMT-0400 (Eastern Daylight Time)
package protocol
// Code generated (see typescript/README.md) DO NOT EDIT.
@@ -42,9 +42,11 @@
}
/**
- * A response returned from the apply workspace edit request.
+ * The result returned from the apply workspace edit request.
+ *
+ * @since 3.17 renamed from ApplyWorkspaceEditResponse
*/
-type ApplyWorkspaceEditResponse struct {
+type ApplyWorkspaceEditResult struct {
/**
* Indicates whether the edit was applied or not.
*/
@@ -976,12 +978,12 @@
*/
type CompletionItemLabelDetails struct {
/**
- * An optional string which is rendered less prominently directly after {@link CompletionItemLabel.label label},
+ * An optional string which is rendered less prominently directly after {@link CompletionItem.label label},
* without any spacing. Should be used for function signatures or type annotations.
*/
Detail string `json:"detail,omitempty"`
/**
- * An optional string which is rendered less prominently after {@link CompletionItemLabel.detail}. Should be used
+ * An optional string which is rendered less prominently after {@link CompletionItem.detail}. Should be used
* for fully qualified names or file path.
*/
Description string `json:"description,omitempty"`
@@ -3692,6 +3694,12 @@
*/
MonikerProvider interface{}/* bool | MonikerOptions | MonikerRegistrationOptions*/ `json:"monikerProvider,omitempty"`
/**
+ * The server provides type hierarchy support.
+ *
+ * @since 3.17.0 - proposed state
+ */
+ TypeHierarchyProvider interface{}/* bool | TypeHierarchyOptions | TypeHierarchyRegistrationOptions*/ `json:"typeHierarchyProvider,omitempty"`
+ /**
* Experimental server capabilities.
*/
Experimental interface{} `json:"experimental,omitempty"`
@@ -4174,6 +4182,12 @@
* @since 3.16.0
*/
Moniker MonikerClientCapabilities `json:"moniker,omitempty"`
+ /**
+ * Capabilities specific to the various type hierarchy requests.
+ *
+ * @since 3.17.0 - proposed state
+ */
+ TypeHierarchy TypeHierarchyClientCapabilities `json:"typeHierarchy,omitempty"`
}
/**
@@ -4392,6 +4406,114 @@
}
/**
+ * @since 3.17.0 - proposed state
+ */
+type TypeHierarchyClientCapabilities struct {
+ /**
+ * Whether implementation supports dynamic registration. If this is set to `true`
+ * the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`
+ * return value for the corresponding server capability as well.
+ */
+ DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
+}
+
+/**
+ * @since 3.17.0 - proposed state
+ */
+type TypeHierarchyItem struct {
+ /**
+ * The name of this item.
+ */
+ Name string `json:"name"`
+ /**
+ * The kind of this item.
+ */
+ Kind SymbolKind `json:"kind"`
+ /**
+ * Tags for this item.
+ */
+ Tags []SymbolTag `json:"tags,omitempty"`
+ /**
+ * More detail for this item, e.g. the signature of a function.
+ */
+ Detail string `json:"detail,omitempty"`
+ /**
+ * The resource identifier of this item.
+ */
+ URI DocumentURI `json:"uri"`
+ /**
+ * The range enclosing this symbol not including leading/trailing whitespace
+ * but everything else, e.g. comments and code.
+ */
+ Range Range `json:"range"`
+ /**
+ * The range that should be selected and revealed when this symbol is being
+ * picked, e.g. the name of a function. Must be contained by the
+ * [`range`](#TypeHierarchyItem.range).
+ */
+ SelectionRange Range `json:"selectionRange"`
+ /**
+ * A data entry field that is preserved between a type hierarchy prepare and
+ * supertypes or subtypes requests. It could also be used to identify the
+ * type hierarchy in the server, helping improve the performance on
+ * resolving supertypes and subtypes.
+ */
+ Data interface{} `json:"data,omitempty"`
+}
+
+/**
+ * Type hierarchy options used during static registration.
+ *
+ * @since 3.17.0 - proposed state
+ */
+type TypeHierarchyOptions struct {
+ WorkDoneProgressOptions
+}
+
+/**
+ * The parameter of a `textDocument/prepareTypeHierarchy` request.
+ *
+ * @since 3.17.0 - proposed state
+ */
+type TypeHierarchyPrepareParams struct {
+ TextDocumentPositionParams
+ WorkDoneProgressParams
+}
+
+/**
+ * Type hierarchy options used during static or dynamic registration.
+ *
+ * @since 3.17.0 - proposed state
+ */
+type TypeHierarchyRegistrationOptions struct {
+ TextDocumentRegistrationOptions
+ TypeHierarchyOptions
+ StaticRegistrationOptions
+}
+
+/**
+ * The parameter of a `typeHierarchy/subtypes` request.
+ *
+ * @since 3.17.0 - proposed state
+ */
+type TypeHierarchySubtypesParams struct {
+ Item TypeHierarchyItem `json:"item"`
+ WorkDoneProgressParams
+ PartialResultParams
+}
+
+/**
+ * The parameter of a `typeHierarchy/supertypes` request.
+ *
+ * @since 3.17.0 - proposed state
+ */
+type TypeHierarchySupertypesParams struct {
+ Item TypeHierarchyItem `json:"item"`
+ WorkDoneProgressParams
+ PartialResultParams
+}
+
+/**
* A tagging type for string properties that are actually URIs
*
* @since 3.16.0
diff --git a/internal/lsp/protocol/tsserver.go b/internal/lsp/protocol/tsserver.go
index b274eb1..dec6d41 100644
--- a/internal/lsp/protocol/tsserver.go
+++ b/internal/lsp/protocol/tsserver.go
@@ -6,8 +6,8 @@
// Package protocol contains data types and code for LSP jsonrpcs
// generated automatically from vscode-languageserver-node
-// commit: 0cb3812e7d540ef3a904e96df795bc37a21de9b0
-// last fetched Mon Aug 02 2021 10:08:19 GMT-0400 (Eastern Daylight Time)
+// commit: 10b56de150ad67c3c330da8e2df53ebf2cf347c4
+// last fetched Wed Sep 29 2021 12:31:31 GMT-0400 (Eastern Daylight Time)
// Code generated (see typescript/README.md) DO NOT EDIT.
@@ -55,6 +55,9 @@
WillRenameFiles(context.Context, *RenameFilesParams) (*WorkspaceEdit /*WorkspaceEdit | null*/, error)
WillDeleteFiles(context.Context, *DeleteFilesParams) (*WorkspaceEdit /*WorkspaceEdit | null*/, error)
Moniker(context.Context, *MonikerParams) ([]Moniker /*Moniker[] | null*/, error)
+ PrepareTypeHierarchy(context.Context, *TypeHierarchyPrepareParams) ([]TypeHierarchyItem /*TypeHierarchyItem[] | null*/, error)
+ Supertypes(context.Context, *TypeHierarchySupertypesParams) ([]TypeHierarchyItem /*TypeHierarchyItem[] | null*/, error)
+ Subtypes(context.Context, *TypeHierarchySubtypesParams) ([]TypeHierarchyItem /*TypeHierarchyItem[] | null*/, error)
Initialize(context.Context, *ParamInitialize) (*InitializeResult, error)
Shutdown(context.Context) error
WillSaveWaitUntil(context.Context, *WillSaveTextDocumentParams) ([]TextEdit /*TextEdit[] | null*/, error)
@@ -328,6 +331,27 @@
}
resp, err := server.Moniker(ctx, ¶ms)
return true, reply(ctx, resp, err)
+ case "textDocument/prepareTypeHierarchy": // req
+ var params TypeHierarchyPrepareParams
+ if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
+ return true, sendParseError(ctx, reply, err)
+ }
+ resp, err := server.PrepareTypeHierarchy(ctx, ¶ms)
+ return true, reply(ctx, resp, err)
+ case "typeHierarchy/supertypes": // req
+ var params TypeHierarchySupertypesParams
+ if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
+ return true, sendParseError(ctx, reply, err)
+ }
+ resp, err := server.Supertypes(ctx, ¶ms)
+ return true, reply(ctx, resp, err)
+ case "typeHierarchy/subtypes": // req
+ var params TypeHierarchySubtypesParams
+ if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
+ return true, sendParseError(ctx, reply, err)
+ }
+ resp, err := server.Subtypes(ctx, ¶ms)
+ return true, reply(ctx, resp, err)
case "initialize": // req
var params ParamInitialize
if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
@@ -740,6 +764,30 @@
return result, nil
}
+func (s *serverDispatcher) PrepareTypeHierarchy(ctx context.Context, params *TypeHierarchyPrepareParams) ([]TypeHierarchyItem /*TypeHierarchyItem[] | null*/, error) {
+ var result []TypeHierarchyItem /*TypeHierarchyItem[] | null*/
+ if err := s.sender.Call(ctx, "textDocument/prepareTypeHierarchy", params, &result); err != nil {
+ return nil, err
+ }
+ return result, nil
+}
+
+func (s *serverDispatcher) Supertypes(ctx context.Context, params *TypeHierarchySupertypesParams) ([]TypeHierarchyItem /*TypeHierarchyItem[] | null*/, error) {
+ var result []TypeHierarchyItem /*TypeHierarchyItem[] | null*/
+ if err := s.sender.Call(ctx, "typeHierarchy/supertypes", params, &result); err != nil {
+ return nil, err
+ }
+ return result, nil
+}
+
+func (s *serverDispatcher) Subtypes(ctx context.Context, params *TypeHierarchySubtypesParams) ([]TypeHierarchyItem /*TypeHierarchyItem[] | null*/, error) {
+ var result []TypeHierarchyItem /*TypeHierarchyItem[] | null*/
+ if err := s.sender.Call(ctx, "typeHierarchy/subtypes", params, &result); err != nil {
+ return nil, err
+ }
+ return result, nil
+}
+
func (s *serverDispatcher) Initialize(ctx context.Context, params *ParamInitialize) (*InitializeResult, error) {
var result *InitializeResult
if err := s.sender.Call(ctx, "initialize", params, &result); err != nil {
diff --git a/internal/lsp/protocol/typescript/util.ts b/internal/lsp/protocol/typescript/util.ts
index a32aab0..84fdcf3 100644
--- a/internal/lsp/protocol/typescript/util.ts
+++ b/internal/lsp/protocol/typescript/util.ts
@@ -15,7 +15,7 @@
`${dir}/${srcDir}/protocol/src/browser/main.ts`, `${dir}${srcDir}/types/src/main.ts`,
`${dir}${srcDir}/jsonrpc/src/node/main.ts`
];
-export const gitHash = '0cb3812e7d540ef3a904e96df795bc37a21de9b0';
+export const gitHash = '10b56de150ad67c3c330da8e2df53ebf2cf347c4';
let outFname = 'tsprotocol.go';
let fda: number, fdb: number, fde: number; // file descriptors
diff --git a/internal/lsp/server_gen.go b/internal/lsp/server_gen.go
index 75069a0..3ed3952 100644
--- a/internal/lsp/server_gen.go
+++ b/internal/lsp/server_gen.go
@@ -56,8 +56,8 @@
return s.didChange(ctx, params)
}
-func (s *Server) DidChangeConfiguration(ctx context.Context, _ *protocol.DidChangeConfigurationParams) error {
- return s.didChangeConfiguration(ctx, nil)
+func (s *Server) DidChangeConfiguration(ctx context.Context, _gen *protocol.DidChangeConfigurationParams) error {
+ return s.didChangeConfiguration(ctx, _gen)
}
func (s *Server) DidChangeWatchedFiles(ctx context.Context, params *protocol.DidChangeWatchedFilesParams) error {
@@ -176,6 +176,10 @@
return s.prepareRename(ctx, params)
}
+func (s *Server) PrepareTypeHierarchy(context.Context, *protocol.TypeHierarchyPrepareParams) ([]protocol.TypeHierarchyItem, error) {
+ return nil, notImplemented("PrepareTypeHierarchy")
+}
+
func (s *Server) RangeFormatting(context.Context, *protocol.DocumentRangeFormattingParams) ([]protocol.TextEdit, error) {
return nil, notImplemented("RangeFormatting")
}
@@ -236,6 +240,14 @@
return s.signatureHelp(ctx, params)
}
+func (s *Server) Subtypes(context.Context, *protocol.TypeHierarchySubtypesParams) ([]protocol.TypeHierarchyItem, error) {
+ return nil, notImplemented("Subtypes")
+}
+
+func (s *Server) Supertypes(context.Context, *protocol.TypeHierarchySupertypesParams) ([]protocol.TypeHierarchyItem, error) {
+ return nil, notImplemented("Supertypes")
+}
+
func (s *Server) Symbol(ctx context.Context, params *protocol.WorkspaceSymbolParams) ([]protocol.SymbolInformation, error) {
return s.symbol(ctx, params)
}