Skip to content

Commit 7d674aa

Browse files
committed
WIP12
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
1 parent c9204e3 commit 7d674aa

File tree

14 files changed

+92
-150
lines changed

14 files changed

+92
-150
lines changed

base.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const (
4545

4646
type CancelParams struct {
4747
// ID the request id to cancel.
48-
ID CancelParamsID `json:"id"`
48+
ID OneOf[int32, string] `json:"id"`
4949
}
5050

5151
type ProgressParams struct {

basic.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ type TextDocumentEdit struct {
370370
TextDocument OptionalVersionedTextDocumentIdentifier `json:"textDocument"`
371371

372372
// Edits the edits to be applied. 3.16.0 - support for AnnotatedTextEdit. This is guarded using a client capability. 3.18.0 - support for SnippetTextEdit. This is guarded using a client capability.
373-
Edits TextDocumentEditEdits `json:"edits"`
373+
Edits OneOf3[TextEdit, AnnotatedTextEdit, SnippetTextEdit] `json:"edits"`
374374
}
375375

376376
// ChangeAnnotation additional information that describes document changes.
@@ -401,7 +401,7 @@ type WorkspaceEdit struct {
401401

402402
// DocumentChanges depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes are
403403
// either an array of `TextDocumentEdit`s to express changes to n different text documents where each text document edit addresses a specific version of a text document. Or it can contain above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations. Whether a client supports versioned document edits is expressed via `workspace.workspaceEdit.documentChanges` client capability. If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then only plain `TextEdit`s using the `changes` property are supported.
404-
DocumentChanges *WorkspaceEditDocumentChanges `json:"documentChanges,omitempty"`
404+
DocumentChanges *OneOf4[TextDocumentEdit, CreateFile, RenameFile, DeleteFile] `json:"documentChanges,omitempty"`
405405

406406
// ChangeAnnotations a map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and delete file / folder operations. Whether clients honor this property depends on the client capability `workspace.changeAnnotationSupport`.
407407
ChangeAnnotations map[ChangeAnnotationIdentifier]ChangeAnnotation `json:"changeAnnotations,omitempty"`
@@ -463,7 +463,7 @@ type Diagnostic struct {
463463
Severity DiagnosticSeverity `json:"severity,omitempty"`
464464

465465
// Code the diagnostic's code, which usually appear in the user interface.
466-
Code *DiagnosticCode `json:"code,omitempty"`
466+
Code *OneOf[int32, string] `json:"code,omitempty"`
467467

468468
// CodeDescription an optional property to describe the error code. Requires the code field (above) to be present/not null.
469469
CodeDescription *CodeDescription `json:"codeDescription,omitempty"`

client_interface.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ func (UnimplementedClient) LogMessage(ctx context.Context, params *LogMessagePar
147147
func (UnimplementedClient) ShowMessage(ctx context.Context, params *ShowMessageParams) error {
148148
return jsonrpc2.ErrInternal
149149
}
150-
151150
func (UnimplementedClient) Registration(ctx context.Context, params *RegistrationParams) error {
152151
return jsonrpc2.ErrInternal
153152
}

document.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ type NotebookDocumentFilterWithCells struct {
128128
// Notebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook.
129129
//
130130
// @since 3.18.0
131-
Notebook *NotebookDocumentFilterWithCellsNotebook `json:"notebook,omitempty"`
131+
Notebook *OneOf[string, NotebookDocumentFilter] `json:"notebook,omitempty"`
132132

133133
// Cells the cells of the matching notebook to be synced.
134134
//
@@ -143,7 +143,7 @@ type NotebookDocumentFilterWithNotebook struct {
143143
// Notebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook.
144144
//
145145
// @since 3.18.0
146-
Notebook NotebookDocumentFilterWithNotebookNotebook `json:"notebook"`
146+
Notebook OneOf[string, NotebookDocumentFilter] `json:"notebook"`
147147

148148
// Cells the cells of the matching notebook to be synced.
149149
//
@@ -159,7 +159,7 @@ type NotebookDocumentSyncOptions struct {
159159
// NotebookSelector the notebooks to be synced.
160160
//
161161
// @since 3.17.0
162-
NotebookSelector NotebookDocumentSyncOptionsNotebookSelector `json:"notebookSelector"`
162+
NotebookSelector OneOf[NotebookDocumentFilterWithNotebook, NotebookDocumentFilterWithCells] `json:"notebookSelector"`
163163

164164
// Save whether save notification should be forwarded to the server. Will only be honored if mode === `notebook`.
165165
//
@@ -349,7 +349,7 @@ type TextDocumentSyncOptions struct {
349349
WillSaveWaitUntil bool `json:"willSaveWaitUntil,omitempty"`
350350

351351
// Save if present save notifications are sent to the server. If omitted the notification should not be sent.
352-
Save *TextDocumentSyncOptionsSave `json:"save,omitempty"`
352+
Save *OneOf[bool, SaveOptions] `json:"save,omitempty"`
353353
}
354354

355355
// DidOpenTextDocumentParams the parameters sent in an open text document notification.

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module go.lsp.dev/protocol
22

3-
go 1.22.2
3+
go 1.23
44

55
require (
6-
github.com/google/go-cmp v0.6.0
6+
github.com/google/go-cmp v0.7.0
77
go.lsp.dev/jsonrpc2 v0.10.0
88
go.lsp.dev/uri v0.3.0
99
go.uber.org/zap v1.27.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
22
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
33
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
4-
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
5-
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
4+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
5+
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
66
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
77
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
88
github.com/segmentio/asm v1.1.3 h1:WM03sfUOENvvKexOLp+pCqgb/WDjsi7EK8gIsICtzhc=

handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func notifyCancel(ctx context.Context, conn jsonrpc2.Conn, id jsonrpc2.ID) {
7777
ctx = context.WithoutCancel(ctx)
7878
// Note that only *jsonrpc2.ID implements json.Marshaler.
7979
cid := NewCancelParamsID(fmt.Sprint(id))
80-
conn.Notify(ctx, "$/cancelRequest", &CancelParams{ID: cid})
80+
conn.Notify(ctx, "$/cancelRequest", &CancelParams{ID: OneOf[int32, string](cid)})
8181
}
8282

8383
func replyParseError(ctx context.Context, reply jsonrpc2.Replier, err error) error {

language.go

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -909,12 +909,12 @@ type SemanticTokensOptions struct {
909909
// Range server supports providing semantic tokens for a specific range of a document.
910910
//
911911
// @since 3.16.0
912-
Range *SemanticTokensOptionsRange `json:"range,omitempty"`
912+
Range *OneOf[bool, Range] `json:"range,omitempty"`
913913

914914
// Full server supports providing semantic tokens for a full document.
915915
//
916916
// @since 3.16.0
917-
Full *SemanticTokensOptionsFull `json:"full,omitempty"`
917+
Full *OneOf[bool, SemanticTokensFullDelta] `json:"full,omitempty"`
918918
}
919919

920920
// SemanticTokensRegistrationOptions.
@@ -1272,7 +1272,7 @@ type InlayHintLabelPart struct {
12721272
// Tooltip the tooltip text when you hover over this label part. Depending on the client capability `inlayHint.resolveSupport` clients might resolve this property late using the resolve request.
12731273
//
12741274
// @since 3.17.0
1275-
Tooltip *InlayHintLabelPartTooltip `json:"tooltip,omitempty"`
1275+
Tooltip *OneOf[string, MarkupContent] `json:"tooltip,omitempty"`
12761276

12771277
// Location an optional source code location that represents this label part. The editor will use this location for the hover and for code navigation features: This part will become a clickable link that resolves
12781278
// to the definition of the symbol at the given location (not necessarily the location itself), it shows the hover that shows at the given location, and it shows a context menu with further code navigation commands. Depending on the client capability `inlayHint.resolveSupport` clients might resolve this property late using the resolve request.
@@ -1299,7 +1299,7 @@ type InlayHint struct {
12991299
// Label the label of this hint. A human readable string or an array of InlayHintLabelPart label parts. *Note* that neither the string nor the label part can be empty.
13001300
//
13011301
// @since 3.17.0
1302-
Label InlayHintLabel `json:"label"`
1302+
Label OneOf[string, []InlayHintLabelPart] `json:"label"`
13031303

13041304
// Kind the kind of this hint. Can be omitted in which case the client should fall back to a reasonable default.
13051305
//
@@ -1315,7 +1315,7 @@ type InlayHint struct {
13151315
// Tooltip the tooltip text when you hover over this item.
13161316
//
13171317
// @since 3.17.0
1318-
Tooltip *InlayHintTooltip `json:"tooltip,omitempty"`
1318+
Tooltip *OneOf[string, MarkupContent] `json:"tooltip,omitempty"`
13191319

13201320
// PaddingLeft render padding before the hint. Note: Padding should use the editor's background color, not the background color of the hint itself. That means padding can be used to visually align/separate an inlay hint.
13211321
//
@@ -1411,7 +1411,7 @@ type FullDocumentDiagnosticReport struct {
14111411
// @since 3.17.0
14121412
type DocumentDiagnosticReportPartialResult struct {
14131413
// @since 3.17.0
1414-
RelatedDocuments map[DocumentURI]DocumentDiagnosticReportPartialResultRelatedDocuments `json:"relatedDocuments"`
1414+
RelatedDocuments map[DocumentURI]OneOf[FullDocumentDiagnosticReport, UnchangedDocumentDiagnosticReport] `json:"relatedDocuments"`
14151415
}
14161416

14171417
// DiagnosticServerCancellationData cancellation data returned from a diagnostic request.
@@ -1560,7 +1560,7 @@ type InlineCompletionItem struct {
15601560
// InsertText the text to replace the range with. Must be set.
15611561
//
15621562
// @since 3.18.0 proposed
1563-
InsertText InlineCompletionItemInsertText `json:"insertText"`
1563+
InsertText OneOf[string, StringValue] `json:"insertText"`
15641564

15651565
// FilterText a text that is used to decide if this inline completion should be shown. When `falsy` the InlineCompletionItem.insertText is used.
15661566
//
@@ -1882,7 +1882,7 @@ type CompletionItem struct {
18821882
Detail string `json:"detail,omitempty"`
18831883

18841884
// Documentation a human-readable string that represents a doc-comment.
1885-
Documentation *CompletionItemDocumentation `json:"documentation,omitempty"`
1885+
Documentation *OneOf[string, MarkupContent] `json:"documentation,omitempty"`
18861886

18871887
// Deprecated indicates if this item is deprecated.
18881888
//
@@ -1909,7 +1909,7 @@ type CompletionItem struct {
19091909
InsertTextMode InsertTextMode `json:"insertTextMode,omitempty"`
19101910

19111911
// TextEdit an TextEdit edit which is applied to a document when selecting this completion. When an edit is provided the value of CompletionItem.insertText insertText is ignored. Most editors support two different operations when accepting a completion item. One is to insert a completion text and the other is to replace an existing text with a completion text. Since this can usually not be predetermined by a server it can report both ranges. Clients need to signal support for `InsertReplaceEdits` via the `textDocument.completion.insertReplaceSupport` client capability property. *Note 1:* The text edit's range as well as both ranges from an insert replace edit must be a [single line] and they must contain the position at which completion has been requested. *Note 2:* If an `InsertReplaceEdit` is returned the edit's insert range must be a prefix of the edit's replace range, that means it must be contained and starting at the same position. 3.16.0 additional type `InsertReplaceEdit`.
1912-
TextEdit *CompletionItemTextEdit `json:"textEdit,omitempty"`
1912+
TextEdit *OneOf[TextEdit, InsertReplaceEdit] `json:"textEdit,omitempty"`
19131913

19141914
// TextEditText the edit text used if the completion item is part of a CompletionList and CompletionList defines an item default for the text edit range. Clients will only honor this property if they opt into completion list item defaults using the capability `completionList.itemDefaults`. If not provided and a list's default range is provided the label property is used as a text.
19151915
TextEditText string `json:"textEditText,omitempty"`
@@ -1950,7 +1950,7 @@ type CompletionItemDefaults struct {
19501950

19511951
// EditRange a default edit range.
19521952
// @since 3.17.0
1953-
EditRange *CompletionItemDefaultsEditRange `json:"editRange,omitempty"`
1953+
EditRange *OneOf[Range, EditRangeWithInsertReplace] `json:"editRange,omitempty"`
19541954

19551955
// InsertTextFormat a default insert text format.
19561956
// @since 3.17.0
@@ -2012,7 +2012,7 @@ type HoverParams struct {
20122012
// Hover the result of a hover request.
20132013
type Hover struct {
20142014
// Contents the hover's content.
2015-
Contents HoverContents `json:"contents"`
2015+
Contents OneOf3[MarkupContent, MarkedString, []MarkedString] `json:"contents"`
20162016

20172017
// Range an optional range inside the text document that is used to visualize the hover, e.g. by changing the
20182018
// background color.
@@ -2030,10 +2030,13 @@ type HoverRegistrationOptions struct {
20302030
type ParameterInformation struct {
20312031
// Label the label of this parameter information. Either a string or an inclusive start and exclusive end offsets within its containing signature label. (see SignatureInformation.label). The offsets are based on a UTF-16 string representation as `Position` and `Range` does. To avoid ambiguities a server should use the [start, end] offset value instead of using a substring. Whether a client support this is controlled via `labelOffsetSupport` client capability. *Note*: a label of type string should be a substring of its containing signature label. Its intended use case is to highlight the parameter label
20322032
// part in the `SignatureInformation.label`.
2033-
Label ParameterInformationLabel `json:"label"`
2033+
Label OneOf[string, struct {
2034+
x uint32
2035+
y uint32
2036+
}] `json:"label"`
20342037

20352038
// Documentation the human-readable doc-comment of this parameter. Will be shown in the UI but can be omitted.
2036-
Documentation *ParameterInformationDocumentation `json:"documentation,omitempty"`
2039+
Documentation *OneOf[string, MarkupContent] `json:"documentation,omitempty"`
20372040
}
20382041

20392042
// SignatureInformation represents the signature of something callable. A signature can have a label, like a function-name, a doc-comment, and a set of parameters.
@@ -2042,7 +2045,7 @@ type SignatureInformation struct {
20422045
Label string `json:"label"`
20432046

20442047
// Documentation the human-readable doc-comment of this signature. Will be shown in the UI but can be omitted.
2045-
Documentation *SignatureInformationDocumentation `json:"documentation,omitempty"`
2048+
Documentation *OneOf[string, MarkupContent] `json:"documentation,omitempty"`
20462049

20472050
// Parameters the parameters of this signature.
20482051
Parameters []ParameterInformation `json:"parameters,omitempty"`
@@ -2608,7 +2611,7 @@ type RelatedFullDocumentDiagnosticReport struct {
26082611

26092612
// RelatedDocuments diagnostics of related documents. This information is useful in programming languages where code in a file A can generate diagnostics in a file B which A depends on. An example of such a language is C/C++ where marco definitions in a file a.cpp and result in errors in a header file b.hpp.
26102613
// @since 3.17.0
2611-
RelatedDocuments map[DocumentURI]*RelatedFullDocumentDiagnosticReportRelatedDocuments `json:"relatedDocuments,omitempty"`
2614+
RelatedDocuments map[DocumentURI]*OneOf[FullDocumentDiagnosticReport, UnchangedDocumentDiagnosticReport] `json:"relatedDocuments,omitempty"`
26122615
}
26132616

26142617
// RelatedUnchangedDocumentDiagnosticReport an unchanged diagnostic report with a set of related documents.
@@ -2620,7 +2623,7 @@ type RelatedUnchangedDocumentDiagnosticReport struct {
26202623

26212624
// RelatedDocuments diagnostics of related documents. This information is useful in programming languages where code in a file A can generate diagnostics in a file B which A depends on. An example of such a language is C/C++ where marco definitions in a file a.cpp and result in errors in a header file b.hpp.
26222625
// @since 3.17.0
2623-
RelatedDocuments map[DocumentURI]*RelatedUnchangedDocumentDiagnosticReportRelatedDocuments `json:"relatedDocuments,omitempty"`
2626+
RelatedDocuments map[DocumentURI]*OneOf[FullDocumentDiagnosticReport, UnchangedDocumentDiagnosticReport] `json:"relatedDocuments,omitempty"`
26242627
}
26252628

26262629
// PrepareRenamePlaceholder.
@@ -2728,7 +2731,7 @@ type NotebookCellTextDocumentFilter struct {
27282731
// Notebook a filter that matches against the notebook containing the notebook cell. If a string value is provided it matches against the notebook type. '*' matches every notebook.
27292732
//
27302733
// @since 3.17.0
2731-
Notebook NotebookCellTextDocumentFilterNotebook `json:"notebook"`
2734+
Notebook OneOf[string, NotebookDocumentFilter] `json:"notebook"`
27322735

27332736
// Language a language id like `python`. Will be matched against the language id of the notebook cell document. '*' matches every language.
27342737
//

0 commit comments

Comments
 (0)