Skip to content

Commit 1b68a73

Browse files
committed
WIP5
Signed-off-by: Koichi Shiraishi <[email protected]>
1 parent 2464d76 commit 1b68a73

21 files changed

+1787
-1395
lines changed

protocol/base.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const (
3939
// ContentModifiedLSPErrorCodes the server detected that the content of a document got modified outside normal conditions. A server should NOT send this error code if it detects a content change in it unprocessed messages. The result even computed on an older state might still be useful for the client. If a client decides that a result is not of any use anymore the client should cancel the request.
4040
ContentModifiedLSPErrorCodes LSPErrorCodes = -32801
4141

42-
// RequestCancelledLSPErrorCodes the client has canceled a request and a server as detected the cancel.
42+
// RequestCancelledLSPErrorCodes the client has canceled a request and a server has detected the cancel.
4343
RequestCancelledLSPErrorCodes LSPErrorCodes = -32800
4444
)
4545

protocol/basic.go

Lines changed: 91 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ const (
8888

8989
HandlebarsLanguageKind LanguageKind = "handlebars"
9090

91+
HaskellLanguageKind LanguageKind = "haskell"
92+
9193
HTMLLanguageKind LanguageKind = "html"
9294

9395
IniLanguageKind LanguageKind = "ini"
@@ -256,12 +258,12 @@ type TextDocumentIdentifier struct {
256258
//
257259
// @since 3.17.0 - support for negotiated position encoding.
258260
type Position struct {
259-
// Line line position in a document (zero-based). If a line number is greater than the number of lines in a document, it defaults back to the number of lines in the document. If a line number is negative, it defaults to .
261+
// Line line position in a document (zero-based).
260262
//
261263
// @since 3.17.0 - support for negotiated position encoding.
262264
Line uint32 `json:"line"`
263265

264-
// Character character offset on a line in a document (zero-based). The meaning of this offset is determined by the negotiated `PositionEncodingKind`. If the character value is greater than the line length it defaults back to the line length.
266+
// Character character offset on a line in a document (zero-based). The meaning of this offset is determined by the negotiated `PositionEncodingKind`.
265267
//
266268
// @since 3.17.0 - support for negotiated position encoding.
267269
Character uint32 `json:"character"`
@@ -316,6 +318,38 @@ type OptionalVersionedTextDocumentIdentifier struct {
316318
Version int32 `json:"version,omitempty"`
317319
}
318320

321+
// StringValue a string value used as a snippet is a template which allows to insert text and to control the editor
322+
// cursor when insertion happens. A snippet can define tab stops and placeholders with `$1`, `$2`
323+
// and `${3:foo}`. `$0` defines the final tab stop, it defaults to the end of the snippet. Variables are defined with `$name` and `${name:default value}`. 3.18.0 @proposed.
324+
//
325+
// @since 3.18.0 proposed
326+
type StringValue struct {
327+
// Value the snippet string.
328+
//
329+
// @since 3.18.0 proposed
330+
Value string `json:"value"`
331+
}
332+
333+
// SnippetTextEdit an interactive text edit. 3.18.0 @proposed.
334+
//
335+
// @since 3.18.0 proposed
336+
type SnippetTextEdit struct {
337+
// Range the range of the text document to be manipulated.
338+
//
339+
// @since 3.18.0 proposed
340+
Range Range `json:"range"`
341+
342+
// Snippet the snippet to be inserted.
343+
//
344+
// @since 3.18.0 proposed
345+
Snippet StringValue `json:"snippet"`
346+
347+
// AnnotationID the actual identifier of the snippet edit.
348+
//
349+
// @since 3.18.0 proposed
350+
AnnotationID *ChangeAnnotationIdentifier `json:"annotationId,omitempty"`
351+
}
352+
319353
// AnnotatedTextEdit a special text edit with an additional change annotation.
320354
//
321355
// @since 3.16.0.
@@ -335,7 +369,7 @@ type TextDocumentEdit struct {
335369
// TextDocument the text document to change.
336370
TextDocument OptionalVersionedTextDocumentIdentifier `json:"textDocument"`
337371

338-
// Edits the edits to be applied. 3.16.0 - support for AnnotatedTextEdit. This is guarded using a client capability.
372+
// 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.
339373
Edits TextDocumentEditEdits `json:"edits"`
340374
}
341375

@@ -425,7 +459,7 @@ type Diagnostic struct {
425459
// Range the range at which the message applies.
426460
Range Range `json:"range"`
427461

428-
// Severity the diagnostic's severity. Can be omitted. If omitted it is up to the client to interpret diagnostics as error, warning, info or hint.
462+
// Severity the diagnostic's severity. To avoid interpretation mismatches when a server is used with different clients it is highly recommended that servers always provide a severity value.
429463
Severity DiagnosticSeverity `json:"severity,omitempty"`
430464

431465
// Code the diagnostic's code, which usually appear in the user interface.
@@ -475,25 +509,64 @@ type VersionedTextDocumentIdentifier struct {
475509
Version int32 `json:"version"`
476510
}
477511

478-
// StringValue a string value used as a snippet is a template which allows to insert text and to control the editor
479-
// cursor when insertion happens. A snippet can define tab stops and placeholders with `$1`, `$2`
480-
// and `${3:foo}`. `$0` defines the final tab stop, it defaults to the end of the snippet. Variables are defined with `$name` and `${name:default value}`. 3.18.0 @proposed.
512+
// TextDocumentContentParams parameters for the `workspace/textDocumentContent` request. 3.18.0 @proposed.
481513
//
482514
// @since 3.18.0 proposed
483-
type StringValue struct {
484-
// Value the snippet string.
515+
type TextDocumentContentParams struct {
516+
// URI the uri of the text document.
485517
//
486518
// @since 3.18.0 proposed
487-
Value string `json:"value"`
519+
URI DocumentURI `json:"uri"`
488520
}
489521

490-
// ChangeAnnotationsSupportOptions.
522+
// TextDocumentContentResult result of the `workspace/textDocumentContent` request. 3.18.0 @proposed.
523+
//
524+
// @since 3.18.0 proposed
525+
type TextDocumentContentResult struct {
526+
// Text the text content of the text document. Please note, that the content of any subsequent open notifications for the text document might differ from the returned content due to whitespace and line ending
527+
// normalizations done on the client.
528+
//
529+
// @since 3.18.0 proposed
530+
Text string `json:"text"`
531+
}
532+
533+
// TextDocumentContentOptions text document content provider options. 3.18.0 @proposed.
534+
//
535+
// @since 3.18.0 proposed
536+
type TextDocumentContentOptions struct {
537+
// Schemes the schemes for which the server provides content.
538+
//
539+
// @since 3.18.0 proposed
540+
Schemes []string `json:"schemes"`
541+
}
542+
543+
// TextDocumentContentRegistrationOptions text document content provider registration options. 3.18.0 @proposed.
491544
//
492545
// @since 3.18.0 proposed
546+
type TextDocumentContentRegistrationOptions struct {
547+
// extends
548+
TextDocumentContentOptions
549+
// mixins
550+
StaticRegistrationOptions
551+
}
552+
553+
// TextDocumentContentRefreshParams parameters for the `workspace/textDocumentContent/refresh` request. 3.18.0 @proposed.
554+
//
555+
// @since 3.18.0 proposed
556+
type TextDocumentContentRefreshParams struct {
557+
// URI the uri of the text document to refresh.
558+
//
559+
// @since 3.18.0 proposed
560+
URI DocumentURI `json:"uri"`
561+
}
562+
563+
// ChangeAnnotationsSupportOptions.
564+
//
565+
// @since 3.18.0
493566
type ChangeAnnotationsSupportOptions struct {
494567
// GroupsOnLabel whether the client groups edits with equal labels into tree nodes, for instance all edits labelled with "Changes in Strings" would be a tree node.
495568
//
496-
// @since 3.18.0 proposed
569+
// @since 3.18.0
497570
GroupsOnLabel bool `json:"groupsOnLabel,omitempty"`
498571
}
499572

@@ -512,6 +585,12 @@ type WorkspaceEditClientCapabilities struct {
512585

513586
// ChangeAnnotationSupport whether the client in general supports change annotations on text edits, create file, rename file and delete file changes.
514587
ChangeAnnotationSupport *ChangeAnnotationsSupportOptions `json:"changeAnnotationSupport,omitempty"`
588+
589+
// MetadataSupport whether the client supports `WorkspaceEditMetadata` in `WorkspaceEdit`s. 3.18.0 @proposed.
590+
MetadataSupport bool `json:"metadataSupport,omitempty"`
591+
592+
// SnippetEditSupport whether the client supports snippets as text edits. 3.18.0 @proposed.
593+
SnippetEditSupport bool `json:"snippetEditSupport,omitempty"`
515594
}
516595

517596
type WorkDoneProgressBegin struct {

protocol/client.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,13 @@ func (c *client) WorkspaceConfiguration(ctx context.Context, params *Configurati
433433
return result, nil
434434
}
435435

436+
func (c *client) refresh(ctx context.Context, method string) (err error) {
437+
c.logger.Debug("call " + method)
438+
defer c.logger.Debug("end "+method, zap.Error(err))
439+
440+
return c.Conn.Notify(ctx, method, nil)
441+
}
442+
436443
func (c *client) WorkspaceDiagnosticRefresh(ctx context.Context) (err error) {
437444
return c.refresh(ctx, MethodWorkspaceDiagnosticRefresh)
438445
}
@@ -453,11 +460,18 @@ func (c *client) WorkspaceSemanticTokensRefresh(ctx context.Context) (err error)
453460
return c.refresh(ctx, MethodWorkspaceSemanticTokensRefresh)
454461
}
455462

456-
func (c *client) refresh(ctx context.Context, method string) (err error) {
457-
c.logger.Debug("call " + method)
458-
defer c.logger.Debug("end "+method, zap.Error(err))
463+
// WorkspaceTextDocumentContentRefresh 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.
464+
//
465+
// @since 3.18.0 proposed
466+
func (c *client) WorkspaceTextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) (err error) {
467+
c.logger.Debug("call " + MethodWorkspaceTextDocumentContentRefresh)
468+
defer c.logger.Debug("end "+MethodWorkspaceTextDocumentContentRefresh, zap.Error(err))
459469

460-
return c.Conn.Notify(ctx, method, nil)
470+
if err := Call(ctx, c.Conn, MethodWorkspaceTextDocumentContentRefresh, params, nil); err != nil {
471+
return err
472+
}
473+
474+
return nil
461475
}
462476

463477
// WorkspaceFolders sends the request from the server to the client to fetch the current open list of workspace folders.

protocol/client_interface.go

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,28 @@ import (
1010
)
1111

1212
const (
13-
MethodClientCancelRequest ClientMethod = "$/cancelRequest" // bidirect client notification
14-
MethodClientProgress ClientMethod = "$/progress" // bidirect client notification
15-
MethodLogTrace ClientMethod = "$/logTrace" // client notification
16-
MethodTelemetryEvent ClientMethod = "telemetry/event" // client notification
17-
MethodTextDocumentPublishDiagnostics ClientMethod = "textDocument/publishDiagnostics" // client notification
18-
MethodWindowLogMessage ClientMethod = "window/logMessage" // client notification
19-
MethodWindowShowMessage ClientMethod = "window/showMessage" // 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
25-
MethodWorkspaceApplyEdit ClientMethod = "workspace/applyEdit" // client request
26-
MethodWorkspaceCodeLensRefresh ClientMethod = "workspace/codeLens/refresh" // client request
27-
MethodWorkspaceConfiguration ClientMethod = "workspace/configuration" // client request
28-
MethodWorkspaceDiagnosticRefresh ClientMethod = "workspace/diagnostic/refresh" // client request
29-
MethodWorkspaceFoldingRangeRefresh ClientMethod = "workspace/foldingRange/refresh" // client request
30-
MethodWorkspaceInlayHintRefresh ClientMethod = "workspace/inlayHint/refresh" // client request
31-
MethodWorkspaceInlineValueRefresh ClientMethod = "workspace/inlineValue/refresh" // client request
32-
MethodWorkspaceSemanticTokensRefresh ClientMethod = "workspace/semanticTokens/refresh" // client request
33-
MethodWorkspaceWorkspaceFolders ClientMethod = "workspace/workspaceFolders" // client request
13+
MethodClientCancelRequest ClientMethod = "$/cancelRequest" // bidirect client notification
14+
MethodClientProgress ClientMethod = "$/progress" // bidirect client notification
15+
MethodLogTrace ClientMethod = "$/logTrace" // client notification
16+
MethodTelemetryEvent ClientMethod = "telemetry/event" // client notification
17+
MethodTextDocumentPublishDiagnostics ClientMethod = "textDocument/publishDiagnostics" // client notification
18+
MethodWindowLogMessage ClientMethod = "window/logMessage" // client notification
19+
MethodWindowShowMessage ClientMethod = "window/showMessage" // 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
25+
MethodWorkspaceApplyEdit ClientMethod = "workspace/applyEdit" // client request
26+
MethodWorkspaceCodeLensRefresh ClientMethod = "workspace/codeLens/refresh" // client request
27+
MethodWorkspaceConfiguration ClientMethod = "workspace/configuration" // client request
28+
MethodWorkspaceDiagnosticRefresh ClientMethod = "workspace/diagnostic/refresh" // client request
29+
MethodWorkspaceFoldingRangeRefresh ClientMethod = "workspace/foldingRange/refresh" // client request
30+
MethodWorkspaceInlayHintRefresh ClientMethod = "workspace/inlayHint/refresh" // client request
31+
MethodWorkspaceInlineValueRefresh ClientMethod = "workspace/inlineValue/refresh" // client request
32+
MethodWorkspaceSemanticTokensRefresh ClientMethod = "workspace/semanticTokens/refresh" // client request
33+
MethodWorkspaceTextDocumentContentRefresh ClientMethod = "workspace/textDocumentContent/refresh" // client request
34+
MethodWorkspaceWorkspaceFolders ClientMethod = "workspace/workspaceFolders" // client request
3435
)
3536

3637
type Client interface {
@@ -105,6 +106,11 @@ type Client interface {
105106
// @since 3.16.0
106107
WorkspaceSemanticTokensRefresh(ctx context.Context) error
107108

109+
// WorkspaceTextDocumentContentRefresh 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.
110+
//
111+
// @since 3.18.0 proposed
112+
WorkspaceTextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) error
113+
108114
// WorkspaceWorkspaceFolders the `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.
109115
WorkspaceWorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error)
110116
}
@@ -192,6 +198,10 @@ func (UnimplementedClient) WorkspaceSemanticTokensRefresh(ctx context.Context) e
192198
return jsonrpc2.ErrInternal
193199
}
194200

201+
func (UnimplementedClient) WorkspaceTextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) error {
202+
return jsonrpc2.ErrInternal
203+
}
204+
195205
func (UnimplementedClient) WorkspaceWorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error) {
196206
return nil, jsonrpc2.ErrInternal
197207
}

0 commit comments

Comments
 (0)