Skip to content

Commit 2dc2755

Browse files
committed
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 <[email protected]> gopls-CI: kokoro <[email protected]> TryBot-Result: Go Bot <[email protected]> Trust: Peter Weinberger <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
1 parent 81efdbc commit 2dc2755

File tree

9 files changed

+208
-23
lines changed

9 files changed

+208
-23
lines changed

internal/lsp/cmd/cmd.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,8 @@ func (c *cmdClient) Configuration(ctx context.Context, p *protocol.ParamConfigur
418418
return results, nil
419419
}
420420

421-
func (c *cmdClient) ApplyEdit(ctx context.Context, p *protocol.ApplyWorkspaceEditParams) (*protocol.ApplyWorkspaceEditResponse, error) {
422-
return &protocol.ApplyWorkspaceEditResponse{Applied: false, FailureReason: "not implemented"}, nil
421+
func (c *cmdClient) ApplyEdit(ctx context.Context, p *protocol.ApplyWorkspaceEditParams) (*protocol.ApplyWorkspaceEditResult, error) {
422+
return &protocol.ApplyWorkspaceEditResult{Applied: false, FailureReason: "not implemented"}, nil
423423
}
424424

425425
func (c *cmdClient) PublishDiagnostics(ctx context.Context, p *protocol.PublishDiagnosticsParams) error {

internal/lsp/fake/client.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@ func (c *Client) ShowDocument(context.Context, *protocol.ShowDocumentParams) (*p
115115
}
116116

117117
// ApplyEdit applies edits sent from the server.
118-
func (c *Client) ApplyEdit(ctx context.Context, params *protocol.ApplyWorkspaceEditParams) (*protocol.ApplyWorkspaceEditResponse, error) {
118+
func (c *Client) ApplyEdit(ctx context.Context, params *protocol.ApplyWorkspaceEditParams) (*protocol.ApplyWorkspaceEditResult, error) {
119119
if len(params.Edit.Changes) != 0 {
120-
return &protocol.ApplyWorkspaceEditResponse{FailureReason: "Edit.Changes is unsupported"}, nil
120+
return &protocol.ApplyWorkspaceEditResult{FailureReason: "Edit.Changes is unsupported"}, nil
121121
}
122122
for _, change := range params.Edit.DocumentChanges {
123123
if err := c.editor.applyProtocolEdit(ctx, change); err != nil {
124124
return nil, err
125125
}
126126
}
127-
return &protocol.ApplyWorkspaceEditResponse{Applied: true}, nil
127+
return &protocol.ApplyWorkspaceEditResult{Applied: true}, nil
128128
}

internal/lsp/helper/helper.go

+3
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ func doUses() {
158158
nm := ""
159159
if len(f.Names) > 0 {
160160
nm = f.Names[0].String()
161+
if nm == "_" {
162+
nm = "_gen"
163+
}
161164
}
162165
fx.paramnames = append(fx.paramnames, nm)
163166
}

internal/lsp/lsp_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ func (c testClient) ShowMessage(context.Context, *protocol.ShowMessageParams) er
117117
return nil
118118
}
119119

120-
func (c testClient) ApplyEdit(ctx context.Context, params *protocol.ApplyWorkspaceEditParams) (*protocol.ApplyWorkspaceEditResponse, error) {
120+
func (c testClient) ApplyEdit(ctx context.Context, params *protocol.ApplyWorkspaceEditParams) (*protocol.ApplyWorkspaceEditResult, error) {
121121
res, err := applyTextDocumentEdits(c.runner, params.Edit.DocumentChanges)
122122
if err != nil {
123123
return nil, err
124124
}
125125
c.runner.editRecv <- res
126-
return &protocol.ApplyWorkspaceEditResponse{Applied: true}, nil
126+
return &protocol.ApplyWorkspaceEditResult{Applied: true}, nil
127127
}
128128

129129
func (r *runner) CallHierarchy(t *testing.T, spn span.Span, expectedCalls *tests.CallHierarchyResult) {

internal/lsp/protocol/tsclient.go

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/lsp/protocol/tsprotocol.go

+128-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/lsp/protocol/tsserver.go

+50-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/lsp/protocol/typescript/util.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const fnames = [
1515
`${dir}/${srcDir}/protocol/src/browser/main.ts`, `${dir}${srcDir}/types/src/main.ts`,
1616
`${dir}${srcDir}/jsonrpc/src/node/main.ts`
1717
];
18-
export const gitHash = '0cb3812e7d540ef3a904e96df795bc37a21de9b0';
18+
export const gitHash = '10b56de150ad67c3c330da8e2df53ebf2cf347c4';
1919
let outFname = 'tsprotocol.go';
2020
let fda: number, fdb: number, fde: number; // file descriptors
2121

internal/lsp/server_gen.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ func (s *Server) DidChange(ctx context.Context, params *protocol.DidChangeTextDo
5656
return s.didChange(ctx, params)
5757
}
5858

59-
func (s *Server) DidChangeConfiguration(ctx context.Context, _ *protocol.DidChangeConfigurationParams) error {
60-
return s.didChangeConfiguration(ctx, nil)
59+
func (s *Server) DidChangeConfiguration(ctx context.Context, _gen *protocol.DidChangeConfigurationParams) error {
60+
return s.didChangeConfiguration(ctx, _gen)
6161
}
6262

6363
func (s *Server) DidChangeWatchedFiles(ctx context.Context, params *protocol.DidChangeWatchedFilesParams) error {
@@ -176,6 +176,10 @@ func (s *Server) PrepareRename(ctx context.Context, params *protocol.PrepareRena
176176
return s.prepareRename(ctx, params)
177177
}
178178

179+
func (s *Server) PrepareTypeHierarchy(context.Context, *protocol.TypeHierarchyPrepareParams) ([]protocol.TypeHierarchyItem, error) {
180+
return nil, notImplemented("PrepareTypeHierarchy")
181+
}
182+
179183
func (s *Server) RangeFormatting(context.Context, *protocol.DocumentRangeFormattingParams) ([]protocol.TextEdit, error) {
180184
return nil, notImplemented("RangeFormatting")
181185
}
@@ -236,6 +240,14 @@ func (s *Server) SignatureHelp(ctx context.Context, params *protocol.SignatureHe
236240
return s.signatureHelp(ctx, params)
237241
}
238242

243+
func (s *Server) Subtypes(context.Context, *protocol.TypeHierarchySubtypesParams) ([]protocol.TypeHierarchyItem, error) {
244+
return nil, notImplemented("Subtypes")
245+
}
246+
247+
func (s *Server) Supertypes(context.Context, *protocol.TypeHierarchySupertypesParams) ([]protocol.TypeHierarchyItem, error) {
248+
return nil, notImplemented("Supertypes")
249+
}
250+
239251
func (s *Server) Symbol(ctx context.Context, params *protocol.WorkspaceSymbolParams) ([]protocol.SymbolInformation, error) {
240252
return s.symbol(ctx, params)
241253
}

0 commit comments

Comments
 (0)