1
0
mirror of https://github.com/golang/go synced 2024-10-01 01:08:33 -06:00

cmd/gopls: fix incomplete ClientCapabilities struct

go.ts, the program that generates Go types for the LSP protocol, now
handles Typescript type merging for ClientCapabilites, so fields are no
longer missing. Also, to silence go lint and go vet there are changes
in the comments generated in tsprotocol.go. All the *structs were changed
to structs in ClientCapabilities as it was absurdly complex to write literals
of the type. Finally, several otherwise unused types are no longer
generated.

Change-Id: If414a32bc4d733adb2cf8befda9d8a0703c568a6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/171026
Run-TryBot: Peter Weinberger <pjw@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
Peter Weinberger 2019-04-08 09:16:48 -04:00
parent e5b8258f49
commit 04e50493df
3 changed files with 1225 additions and 1097 deletions

View File

@ -152,11 +152,7 @@ func (app *Application) connect(ctx context.Context, client cmdClient) (protocol
}
params := &protocol.InitializeParams{}
params.RootURI = string(span.FileURI(app.Config.Dir))
params.Capabilities = map[string]interface{}{
"workspace": map[string]interface{}{
"configuration": true,
},
}
params.Capabilities.Workspace.Configuration = true
client.prepare(app, server)
if _, err := server.Initialize(ctx, params); err != nil {
return nil, err

File diff suppressed because it is too large Load Diff

View File

@ -149,54 +149,34 @@ func (s *Server) Initialize(ctx context.Context, params *protocol.InitializePara
return &protocol.InitializeResult{
Capabilities: protocol.ServerCapabilities{
InnerServerCapabilities: protocol.InnerServerCapabilities{
CodeActionProvider: true,
CompletionProvider: &protocol.CompletionOptions{
TriggerCharacters: []string{"."},
},
DefinitionProvider: true,
DocumentFormattingProvider: true,
DocumentRangeFormattingProvider: true,
DocumentSymbolProvider: true,
HoverProvider: true,
DocumentHighlightProvider: true,
SignatureHelpProvider: &protocol.SignatureHelpOptions{
TriggerCharacters: []string{"(", ","},
},
TextDocumentSync: &protocol.TextDocumentSyncOptions{
Change: s.textDocumentSyncKind,
OpenClose: true,
},
CodeActionProvider: true,
CompletionProvider: &protocol.CompletionOptions{
TriggerCharacters: []string{"."},
},
TypeDefinitionServerCapabilities: protocol.TypeDefinitionServerCapabilities{
TypeDefinitionProvider: true,
DefinitionProvider: true,
DocumentFormattingProvider: true,
DocumentRangeFormattingProvider: true,
DocumentSymbolProvider: true,
HoverProvider: true,
DocumentHighlightProvider: true,
SignatureHelpProvider: &protocol.SignatureHelpOptions{
TriggerCharacters: []string{"(", ","},
},
TextDocumentSync: &protocol.TextDocumentSyncOptions{
Change: s.textDocumentSyncKind,
OpenClose: true,
},
TypeDefinitionProvider: true,
},
}, nil
}
func (s *Server) setClientCapabilities(caps protocol.ClientCapabilities) {
// Check if the client supports snippets in completion items.
if x, ok := caps["textDocument"].(map[string]interface{}); ok {
if x, ok := x["completion"].(map[string]interface{}); ok {
if x, ok := x["completionItem"].(map[string]interface{}); ok {
if x, ok := x["snippetSupport"].(bool); ok {
s.snippetsSupported = x
}
}
}
}
s.snippetsSupported = caps.TextDocument.Completion.CompletionItem.SnippetSupport
// Check if the client supports configuration messages.
if x, ok := caps["workspace"].(map[string]interface{}); ok {
if x, ok := x["configuration"].(bool); ok {
s.configurationSupported = x
}
if x, ok := x["didChangeConfiguration"].(map[string]interface{}); ok {
if x, ok := x["dynamicRegistration"].(bool); ok {
s.dynamicConfigurationSupported = x
}
}
}
s.configurationSupported = caps.Workspace.Configuration
s.dynamicConfigurationSupported = caps.Workspace.DidChangeConfiguration.DynamicRegistration
}
func (s *Server) Initialized(ctx context.Context, params *protocol.InitializedParams) error {