diff options
author | Peter Weinberger <pjw@google.com> | 2023-02-13 14:06:13 -0500 |
---|---|---|
committer | Peter Weinberger <pjw@google.com> | 2023-02-13 20:24:50 +0000 |
commit | 0e300d3e60c209f5639b2d437d3e803486ef30d9 (patch) | |
tree | 0e017a2958424eee2ede9ba9db889e64f95670ff | |
parent | 80afb09f21e3b1e8f4ef681154ab7543cf6e9dfe (diff) | |
download | golang-x-tools-0e300d3e60c209f5639b2d437d3e803486ef30d9.tar.gz |
gopls/protocol: remove some special cases in stubs
These are some trivial changes. Replacing simplified types
with Or-types fails in general in json_test.go for two reasons:
First, when the custom unmarshaler in tsjson.go fails, it returns
an unexpected error type.
Second, when unmarshaling fails in json_test.go, cmp.Diff returns
multiple diffs for Or-types, when the old code caused only one.
json_test.go needs to be fixed in a separate change.
Change-Id: Idd1e9c244a76629c3686e2a9d59eb1f0d04443a2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/467795
Reviewed-by: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Peter Weinberger <pjw@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
-rw-r--r-- | gopls/internal/lsp/cmd/cmd.go | 2 | ||||
-rw-r--r-- | gopls/internal/lsp/protocol/generate/tables.go | 43 | ||||
-rw-r--r-- | gopls/internal/lsp/protocol/tsclient.go | 2 | ||||
-rw-r--r-- | gopls/internal/lsp/protocol/tsjson.go | 2 | ||||
-rw-r--r-- | gopls/internal/lsp/protocol/tsprotocol.go | 34 | ||||
-rw-r--r-- | gopls/internal/lsp/protocol/tsserver.go | 2 |
6 files changed, 42 insertions, 43 deletions
diff --git a/gopls/internal/lsp/cmd/cmd.go b/gopls/internal/lsp/cmd/cmd.go index 74725f70e..6d5332b5a 100644 --- a/gopls/internal/lsp/cmd/cmd.go +++ b/gopls/internal/lsp/cmd/cmd.go @@ -359,7 +359,7 @@ func (c *connection) initialize(ctx context.Context, options func(*source.Option } params.Capabilities.TextDocument.DocumentSymbol.HierarchicalDocumentSymbolSupport = opts.HierarchicalDocumentSymbolSupport params.Capabilities.TextDocument.SemanticTokens = protocol.SemanticTokensClientCapabilities{} - params.Capabilities.TextDocument.SemanticTokens.Formats = []string{"relative"} + params.Capabilities.TextDocument.SemanticTokens.Formats = []protocol.TokenFormat{"relative"} params.Capabilities.TextDocument.SemanticTokens.Requests.Range = true params.Capabilities.TextDocument.SemanticTokens.Requests.Full = true params.Capabilities.TextDocument.SemanticTokens.TokenTypes = lsp.SemanticTypes() diff --git a/gopls/internal/lsp/protocol/generate/tables.go b/gopls/internal/lsp/protocol/generate/tables.go index 838990c41..121894a98 100644 --- a/gopls/internal/lsp/protocol/generate/tables.go +++ b/gopls/internal/lsp/protocol/generate/tables.go @@ -140,18 +140,19 @@ var renameProp = map[prop]string{ {"Hover", "contents"}: "MarkupContent", {"InlayHint", "label"}: "[]InlayHintLabelPart", - {"Lit_NotebookDocumentChangeEvent_cells", "textContent"}: "[]FTextContentPCells", - {"Lit_NotebookDocumentSyncOptions_notebookSelector_Elem_Item0", "cells"}: "[]FCellsPNotebookSelector", - + // removing this causes the test in json_test.go to fail + // First, the custom unmarshaler returns the 'wrong' error type + // Second, cmp.Diff reports too many errors. + // TODO(pjw): fix json_test.go and maybe the generated code {"Lit_SemanticTokensClientCapabilities_requests", "full"}: "interface{}", {"Lit_SemanticTokensClientCapabilities_requests", "range"}: "bool", {"NotebookCellTextDocumentFilter", "notebook"}: "NotebookDocumentFilter", {"RelatedFullDocumentDiagnosticReport", "relatedDocuments"}: "map[DocumentURI]interface{}", {"RelatedUnchangedDocumentDiagnosticReport", "relatedDocuments"}: "map[DocumentURI]interface{}", + // this one also has the json_test.go problem {"RenameClientCapabilities", "prepareSupportDefaultBehavior"}: "interface{}", - {"SemanticTokensClientCapabilities", "formats"}: "[]string", {"SemanticTokensOptions", "full"}: "bool", {"SemanticTokensOptions", "range"}: "interface{}", {"ServerCapabilities", "callHierarchyProvider"}: "interface{}", @@ -235,27 +236,25 @@ var goplsType = map[string]string{ "Lit_CompletionClientCapabilities_completionItem_resolveSupport": "FResolveSupportPCompletionItem", "Lit_CompletionClientCapabilities_completionItem_tagSupport": "FTagSupportPCompletionItem", - "Lit_CompletionClientCapabilities_completionList": "PCompletionListPCompletion", - "Lit_CompletionList_itemDefaults": "PItemDefaultsMsg_textDocument_completion", - "Lit_CompletionList_itemDefaults_editRange_Item1": "FEditRangePItemDefaults", - "Lit_CompletionOptions_completionItem": "PCompletionItemPCompletionProvider", - "Lit_DocumentSymbolClientCapabilities_symbolKind": "PSymbolKindPDocumentSymbol", - "Lit_DocumentSymbolClientCapabilities_tagSupport": "PTagSupportPDocumentSymbol", - "Lit_FoldingRangeClientCapabilities_foldingRange": "PFoldingRangePFoldingRange", - "Lit_FoldingRangeClientCapabilities_foldingRangeKind": "PFoldingRangeKindPFoldingRange", - "Lit_GeneralClientCapabilities_staleRequestSupport": "PStaleRequestSupportPGeneral", - "Lit_InitializeResult_serverInfo": "PServerInfoMsg_initialize", - "Lit_InlayHintClientCapabilities_resolveSupport": "PResolveSupportPInlayHint", - "Lit_MarkedString_Item1": "Msg_MarkedString", - "Lit_NotebookDocumentChangeEvent_cells": "PCellsPChange", - "Lit_NotebookDocumentChangeEvent_cells_structure": "FStructurePCells", - "Lit_NotebookDocumentChangeEvent_cells_textContent_Elem": "FTextContentPCells", - "Lit_NotebookDocumentFilter_Item0": "Msg_NotebookDocumentFilter", + "Lit_CompletionClientCapabilities_completionList": "PCompletionListPCompletion", + "Lit_CompletionList_itemDefaults": "PItemDefaultsMsg_textDocument_completion", + "Lit_CompletionList_itemDefaults_editRange_Item1": "FEditRangePItemDefaults", + "Lit_CompletionOptions_completionItem": "PCompletionItemPCompletionProvider", + "Lit_DocumentSymbolClientCapabilities_symbolKind": "PSymbolKindPDocumentSymbol", + "Lit_DocumentSymbolClientCapabilities_tagSupport": "PTagSupportPDocumentSymbol", + "Lit_FoldingRangeClientCapabilities_foldingRange": "PFoldingRangePFoldingRange", + "Lit_FoldingRangeClientCapabilities_foldingRangeKind": "PFoldingRangeKindPFoldingRange", + "Lit_GeneralClientCapabilities_staleRequestSupport": "PStaleRequestSupportPGeneral", + "Lit_InitializeResult_serverInfo": "PServerInfoMsg_initialize", + "Lit_InlayHintClientCapabilities_resolveSupport": "PResolveSupportPInlayHint", + "Lit_MarkedString_Item1": "Msg_MarkedString", + "Lit_NotebookDocumentChangeEvent_cells": "PCellsPChange", + "Lit_NotebookDocumentChangeEvent_cells_structure": "FStructurePCells", + "Lit_NotebookDocumentFilter_Item0": "Msg_NotebookDocumentFilter", "Lit_NotebookDocumentSyncOptions_notebookSelector_Elem_Item0": "PNotebookSelectorPNotebookDocumentSync", - "Lit_NotebookDocumentSyncOptions_notebookSelector_Elem_Item0_cells_Elem": "FCellsPNotebookSelector", - "Lit_PrepareRenameResult_Item1": "Msg_PrepareRename2Gn", + "Lit_PrepareRenameResult_Item1": "Msg_PrepareRename2Gn", "Lit_PublishDiagnosticsClientCapabilities_tagSupport": "PTagSupportPPublishDiagnostics", "Lit_SemanticTokensClientCapabilities_requests": "PRequestsPSemanticTokens", diff --git a/gopls/internal/lsp/protocol/tsclient.go b/gopls/internal/lsp/protocol/tsclient.go index 96ec28474..839cde385 100644 --- a/gopls/internal/lsp/protocol/tsclient.go +++ b/gopls/internal/lsp/protocol/tsclient.go @@ -7,7 +7,7 @@ package protocol // Code generated from version 3.17.0 of protocol/metaModel.json. -// git hash 9b742021fb04ad081aa3676a9eecf4fa612084b4 (as of 2023-01-30) +// git hash 9b742021fb04ad081aa3676a9eecf4fa612084b4 (as of 2023-02-13) import ( "context" diff --git a/gopls/internal/lsp/protocol/tsjson.go b/gopls/internal/lsp/protocol/tsjson.go index a2904aa2d..333b6e398 100644 --- a/gopls/internal/lsp/protocol/tsjson.go +++ b/gopls/internal/lsp/protocol/tsjson.go @@ -7,7 +7,7 @@ package protocol // Code generated from version 3.17.0 of protocol/metaModel.json. -// git hash 9b742021fb04ad081aa3676a9eecf4fa612084b4 (as of 2023-01-30) +// git hash 9b742021fb04ad081aa3676a9eecf4fa612084b4 (as of 2023-02-13) import "encoding/json" diff --git a/gopls/internal/lsp/protocol/tsprotocol.go b/gopls/internal/lsp/protocol/tsprotocol.go index e1170fe94..c8b02d075 100644 --- a/gopls/internal/lsp/protocol/tsprotocol.go +++ b/gopls/internal/lsp/protocol/tsprotocol.go @@ -7,7 +7,7 @@ package protocol // Code generated from version 3.17.0 of protocol/metaModel.json. -// git hash 9b742021fb04ad081aa3676a9eecf4fa612084b4 (as of 2023-01-30) +// git hash 9b742021fb04ad081aa3676a9eecf4fa612084b4 (as of 2023-02-13) import "encoding/json" @@ -1769,11 +1769,6 @@ type ExecutionSummary struct { // line 10161 Success bool `json:"success,omitempty"` } -// created for Literal (Lit_NotebookDocumentSyncOptions_notebookSelector_Elem_Item0_cells_Elem) -type FCellsPNotebookSelector struct { // line 9830 - Language string `json:"language"` -} - // created for Literal (Lit_CodeActionClientCapabilities_codeActionLiteralSupport_codeActionKind) type FCodeActionKindPCodeActionLiteralSupport struct { // line 11741 /* @@ -1841,12 +1836,6 @@ type FTagSupportPCompletionItem struct { // line 11236 // The tags supported by the client. ValueSet []CompletionItemTag `json:"valueSet"` } - -// created for Literal (Lit_NotebookDocumentChangeEvent_cells_textContent_Elem) -type FTextContentPCells struct { // line 7544 - Document VersionedTextDocumentIdentifier `json:"document"` - Changes []TextDocumentContentChangeEvent `json:"changes"` -} type FailureHandlingKind string // line 13692 // The file event type type FileChangeType uint32 // line 13453 @@ -2688,6 +2677,12 @@ type LinkedEditingRanges struct { // line 3127 WordPattern string `json:"wordPattern,omitempty"` } +// created for Literal (Lit_NotebookDocumentChangeEvent_cells_textContent_Elem) +type Lit_NotebookDocumentChangeEvent_cells_textContent_Elem struct { // line 7544 + Document VersionedTextDocumentIdentifier `json:"document"` + Changes []TextDocumentContentChangeEvent `json:"changes"` +} + // created for Literal (Lit_NotebookDocumentFilter_Item1) type Lit_NotebookDocumentFilter_Item1 struct { // line 14292 // The type of the enclosing notebook. @@ -2708,6 +2703,11 @@ type Lit_NotebookDocumentFilter_Item2 struct { // line 14325 Pattern string `json:"pattern"` } +// created for Literal (Lit_NotebookDocumentSyncOptions_notebookSelector_Elem_Item0_cells_Elem) +type Lit_NotebookDocumentSyncOptions_notebookSelector_Elem_Item0_cells_Elem struct { // line 9830 + Language string `json:"language"` +} + // created for Literal (Lit_NotebookDocumentSyncOptions_notebookSelector_Elem_Item1) type Lit_NotebookDocumentSyncOptions_notebookSelector_Elem_Item1 struct { // line 9851 /* @@ -2962,8 +2962,8 @@ type Msg_TextDocumentContentChangeEvent struct { // line 14007 Text string `json:"text"` } -// created for Literal (Lit_TextDocumentFilter_Item0) -type Msg_TextDocumentFilter struct { // line 14150 +// created for Literal (Lit_TextDocumentFilter_Item1) +type Msg_TextDocumentFilter struct { // line 14183 // A language id, like `typescript`. Language string `json:"language"` // A Uri {@link Uri.scheme scheme}, like `file` or `untitled`. @@ -3506,7 +3506,7 @@ type PCellsPChange struct { // line 7480 */ Data []NotebookCell `json:"data"` // Changes to the text content of notebook cells. - TextContent []FTextContentPCells `json:"textContent"` + TextContent []Lit_NotebookDocumentChangeEvent_cells_textContent_Elem `json:"textContent"` } // created for Literal (Lit_WorkspaceEditClientCapabilities_changeAnnotationSupport) @@ -3729,7 +3729,7 @@ type PNotebookSelectorPNotebookDocumentSync struct { // line 9805 */ Notebook OrFNotebookPNotebookSelector `json:"notebook"` // The cells of the matching notebook to be synced. - Cells []FCellsPNotebookSelector `json:"cells"` + Cells []Lit_NotebookDocumentSyncOptions_notebookSelector_Elem_Item0_cells_Elem `json:"cells"` } // created for Literal (Lit_SemanticTokensOptions_range_Item1) @@ -4396,7 +4396,7 @@ type SemanticTokensClientCapabilities struct { // line 12156 // The token modifiers that the client supports. TokenModifiers []string `json:"tokenModifiers"` // The token formats the clients supports. - Formats []string `json:"formats"` + Formats []TokenFormat `json:"formats"` // Whether the client supports tokens that can overlap each other. OverlappingTokenSupport bool `json:"overlappingTokenSupport,omitempty"` // Whether the client supports tokens that can span multiple lines. diff --git a/gopls/internal/lsp/protocol/tsserver.go b/gopls/internal/lsp/protocol/tsserver.go index 8669a4e79..3fa638d19 100644 --- a/gopls/internal/lsp/protocol/tsserver.go +++ b/gopls/internal/lsp/protocol/tsserver.go @@ -7,7 +7,7 @@ package protocol // Code generated from version 3.17.0 of protocol/metaModel.json. -// git hash 9b742021fb04ad081aa3676a9eecf4fa612084b4 (as of 2023-01-30) +// git hash 9b742021fb04ad081aa3676a9eecf4fa612084b4 (as of 2023-02-13) import ( "context" |