Skip to content

Commit 123b56b

Browse files
committed
WIP8
Signed-off-by: Koichi Shiraishi <[email protected]>
1 parent dcdf970 commit 123b56b

File tree

13 files changed

+403
-780
lines changed

13 files changed

+403
-780
lines changed

protocol/basic.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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 *WorkspaceEditDocumentChanges `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 *DiagnosticCode `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"`

protocol/client_interface.go

Lines changed: 54 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ import (
1212
const (
1313
MethodClientCancelRequest ClientMethod = "$/cancelRequest" // bidirect client notification
1414
MethodClientProgress ClientMethod = "$/progress" // bidirect client notification
15-
MethodWindowLogMessage ClientMethod = "window/logMessage" // client notification
1615
MethodLogTrace ClientMethod = "$/logTrace" // client notification
16+
MethodTelemetryEvent ClientMethod = "telemetry/event" // client notification
1717
MethodTextDocumentPublishDiagnostics ClientMethod = "textDocument/publishDiagnostics" // client notification
18+
MethodWindowLogMessage ClientMethod = "window/logMessage" // client notification
1819
MethodWindowShowMessage ClientMethod = "window/showMessage" // client notification
19-
MethodTelemetryEvent ClientMethod = "telemetry/event" // client notification
20+
MethodClientRegisterCapability ClientMethod = "client/registerCapability" // client request
21+
MethodClientUnregisterCapability ClientMethod = "client/unregisterCapability" // client request
22+
MethodWindowShowDocument ClientMethod = "window/showDocument" // client request
23+
MethodWindowShowMessageRequest ClientMethod = "window/showMessageRequest" // client request
24+
MethodWindowWorkDoneProgressCreate ClientMethod = "window/workDoneProgress/create" // client request
2025
MethodWorkspaceApplyEdit ClientMethod = "workspace/applyEdit" // client request
2126
MethodWorkspaceCodeLensRefresh ClientMethod = "workspace/codeLens/refresh" // client request
2227
MethodWorkspaceConfiguration ClientMethod = "workspace/configuration" // client request
2328
MethodWorkspaceDiagnosticRefresh ClientMethod = "workspace/diagnostic/refresh" // client request
2429
MethodWorkspaceFoldingRangeRefresh ClientMethod = "workspace/foldingRange/refresh" // client request
2530
MethodWorkspaceInlayHintRefresh ClientMethod = "workspace/inlayHint/refresh" // client request
2631
MethodWorkspaceInlineValueRefresh ClientMethod = "workspace/inlineValue/refresh" // client request
27-
MethodClientRegisterCapability ClientMethod = "client/registerCapability" // client request
2832
MethodWorkspaceSemanticTokensRefresh ClientMethod = "workspace/semanticTokens/refresh" // client request
29-
MethodWindowShowDocument ClientMethod = "window/showDocument" // client request
30-
MethodWindowShowMessageRequest ClientMethod = "window/showMessageRequest" // client request
3133
MethodWorkspaceTextDocumentContentRefresh ClientMethod = "workspace/textDocumentContent/refresh" // client request
32-
MethodClientUnregisterCapability ClientMethod = "client/unregisterCapability" // client request
33-
MethodWindowWorkDoneProgressCreate ClientMethod = "window/workDoneProgress/create" // client request
3434
MethodWorkspaceWorkspaceFolders ClientMethod = "workspace/workspaceFolders" // client request
3535
)
3636

@@ -39,19 +39,36 @@ type Client interface {
3939

4040
Progress(ctx context.Context, params *ProgressParams) error
4141

42-
// LogMessage the log message notification is sent from the server to the client to ask the client to log a particular message.
43-
LogMessage(ctx context.Context, params *LogMessageParams) error
44-
4542
LogTrace(ctx context.Context, params *LogTraceParams) error
4643

44+
// TelemetryEvent the telemetry event notification is sent from the server to the client to ask the client to log telemetry data.
45+
TelemetryEvent(ctx context.Context, params any) error
46+
4747
// PublishDiagnostics diagnostics notification are sent from the server to the client to signal results of validation runs.
4848
PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error
4949

50+
// LogMessage the log message notification is sent from the server to the client to ask the client to log a particular message.
51+
LogMessage(ctx context.Context, params *LogMessageParams) error
52+
5053
// ShowMessage the show message notification is sent from a server to a client to ask the client to display a particular message in the user interface.
5154
ShowMessage(ctx context.Context, params *ShowMessageParams) error
55+
// Registration the `client/registerCapability` request is sent from the server to the client to register a new capability handler on the client side.
56+
Registration(ctx context.Context, params *RegistrationParams) error
57+
58+
// Unregistration the `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability handler on the client side.
59+
Unregistration(ctx context.Context, params *UnregistrationParams) error
60+
61+
// ShowDocument a request to show a document. This request might open an external program depending on the value of the URI to open. For example a request to open `https://code.visualstudio.com/` will very likely open the URI in a WEB browser.
62+
//
63+
// @since 3.16.0
64+
ShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error)
65+
66+
// ShowMessageRequest the show message request is sent from the server to the client to show a message and a set of options actions to the user.
67+
ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error)
68+
69+
// WorkDoneProgressCreate the `window/workDoneProgress/create` request is sent from the server to the client to initiate progress reporting from the server.
70+
WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error
5271

53-
// TelemetryEvent the telemetry event notification is sent from the server to the client to ask the client to log telemetry data.
54-
TelemetryEvent(ctx context.Context, params any) error
5572
// ApplyWorkspaceEdit a request sent from the server to the client to modified certain resources.
5673
ApplyWorkspaceEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error)
5774

@@ -84,40 +101,25 @@ type Client interface {
84101
// @since 3.17.0
85102
InlineValueRefresh(ctx context.Context) error
86103

87-
// Registration the `client/registerCapability` request is sent from the server to the client to register a new capability handler on the client side.
88-
Registration(ctx context.Context, params *RegistrationParams) error
89-
90104
// SemanticTokensRefresh.
91105
//
92106
// @since 3.16.0
93107
SemanticTokensRefresh(ctx context.Context) error
94108

95-
// ShowDocument a request to show a document. This request might open an external program depending on the value of the URI to open. For example a request to open `https://code.visualstudio.com/` will very likely open the URI in a WEB browser.
96-
//
97-
// @since 3.16.0
98-
ShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error)
99-
100-
// ShowMessageRequest the show message request is sent from the server to the client to show a message and a set of options actions to the user.
101-
ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error)
102-
103109
// TextDocumentContentRefresh the `workspace/textDocumentContent` request is sent from the server to the client to refresh the content of a specific text document. 3.18.0 @proposed.
104110
//
105111
// @since 3.18.0 proposed
106112
TextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) error
107113

108-
// Unregistration the `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability handler on the client side.
109-
Unregistration(ctx context.Context, params *UnregistrationParams) error
110-
111-
// WorkDoneProgressCreate the `window/workDoneProgress/create` request is sent from the server to the client to initiate progress reporting from the server.
112-
WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error
113-
114114
// WorkspaceFolders the `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.
115115
WorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error)
116116
}
117117

118118
// UnimplementedClient should be embedded to have forward compatible implementations.
119119
type UnimplementedClient struct{}
120120

121+
var _ Client = UnimplementedClient{}
122+
121123
func (UnimplementedClient) Cancel(ctx context.Context, params *CancelParams) error {
122124
return jsonrpc2.ErrInternal
123125
}
@@ -126,23 +128,43 @@ func (UnimplementedClient) Progress(ctx context.Context, params *ProgressParams)
126128
return jsonrpc2.ErrInternal
127129
}
128130

129-
func (UnimplementedClient) LogMessage(ctx context.Context, params *LogMessageParams) error {
131+
func (UnimplementedClient) LogTrace(ctx context.Context, params *LogTraceParams) error {
130132
return jsonrpc2.ErrInternal
131133
}
132134

133-
func (UnimplementedClient) LogTrace(ctx context.Context, params *LogTraceParams) error {
135+
func (UnimplementedClient) TelemetryEvent(ctx context.Context, params any) error {
134136
return jsonrpc2.ErrInternal
135137
}
136138

137139
func (UnimplementedClient) PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error {
138140
return jsonrpc2.ErrInternal
139141
}
140142

143+
func (UnimplementedClient) LogMessage(ctx context.Context, params *LogMessageParams) error {
144+
return jsonrpc2.ErrInternal
145+
}
146+
141147
func (UnimplementedClient) ShowMessage(ctx context.Context, params *ShowMessageParams) error {
142148
return jsonrpc2.ErrInternal
143149
}
144150

145-
func (UnimplementedClient) TelemetryEvent(ctx context.Context, params any) error {
151+
func (UnimplementedClient) Registration(ctx context.Context, params *RegistrationParams) error {
152+
return jsonrpc2.ErrInternal
153+
}
154+
155+
func (UnimplementedClient) Unregistration(ctx context.Context, params *UnregistrationParams) error {
156+
return jsonrpc2.ErrInternal
157+
}
158+
159+
func (UnimplementedClient) ShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) {
160+
return nil, jsonrpc2.ErrInternal
161+
}
162+
163+
func (UnimplementedClient) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) {
164+
return nil, jsonrpc2.ErrInternal
165+
}
166+
167+
func (UnimplementedClient) WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error {
146168
return jsonrpc2.ErrInternal
147169
}
148170

@@ -174,34 +196,14 @@ func (UnimplementedClient) InlineValueRefresh(ctx context.Context) error {
174196
return jsonrpc2.ErrInternal
175197
}
176198

177-
func (UnimplementedClient) Registration(ctx context.Context, params *RegistrationParams) error {
178-
return jsonrpc2.ErrInternal
179-
}
180-
181199
func (UnimplementedClient) SemanticTokensRefresh(ctx context.Context) error {
182200
return jsonrpc2.ErrInternal
183201
}
184202

185-
func (UnimplementedClient) ShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) {
186-
return nil, jsonrpc2.ErrInternal
187-
}
188-
189-
func (UnimplementedClient) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) {
190-
return nil, jsonrpc2.ErrInternal
191-
}
192-
193203
func (UnimplementedClient) TextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) error {
194204
return jsonrpc2.ErrInternal
195205
}
196206

197-
func (UnimplementedClient) Unregistration(ctx context.Context, params *UnregistrationParams) error {
198-
return jsonrpc2.ErrInternal
199-
}
200-
201-
func (UnimplementedClient) WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error {
202-
return jsonrpc2.ErrInternal
203-
}
204-
205207
func (UnimplementedClient) WorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error) {
206208
return nil, jsonrpc2.ErrInternal
207209
}

protocol/document.go

Lines changed: 2 additions & 2 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 *NotebookDocumentFilterWithCellsNotebook `json:"notebook,omitempty"`
132132

133133
// Cells the cells of the matching notebook to be synced.
134134
//
@@ -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 *TextDocumentSyncOptionsSave `json:"save,omitempty"`
353353
}
354354

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

0 commit comments

Comments
 (0)