internal/lsp: update lsp protocol stubs to match LSP 3.16 revisions

Upgrades to bring gopls up to date with the latest LSP protocol
specifications. There are two new RPCs, Moniker, and ResolveCodeAction,
and a new field CodeDescription in Diagnostic.

This CL also includes the tiny change to helper.go to cope with
_s in function declarations.

Change-Id: I1a0dcb57adc48510f2a0ed97cf18aa4719648822
Reviewed-on: https://go-review.googlesource.com/c/tools/+/265117
Run-TryBot: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Peter Weinberger <pjw@google.com>
This commit is contained in:
Peter Weinbergr 2020-10-26 11:18:54 -04:00 committed by Peter Weinberger
parent e84cfc6dd5
commit 8dabb74018
7 changed files with 367 additions and 88 deletions

View File

@ -281,10 +281,10 @@ func (c *connection) initialize(ctx context.Context, options func(*source.Option
ContentFormat: []protocol.MarkupKind{opts.PreferredContentFormat},
}
params.Capabilities.TextDocument.DocumentSymbol.HierarchicalDocumentSymbolSupport = opts.HierarchicalDocumentSymbolSupport
params.Capabilities.TextDocument.SemanticTokens = &protocol.SemanticTokensClientCapabilities{}
params.Capabilities.TextDocument.SemanticTokens = protocol.SemanticTokensClientCapabilities{}
params.Capabilities.TextDocument.SemanticTokens.Formats = []string{"relative"}
params.Capabilities.TextDocument.SemanticTokens.Requests.Range = true
params.Capabilities.TextDocument.SemanticTokens.Requests.Full.Delta = true
params.Capabilities.TextDocument.SemanticTokens.Requests.Full = true
params.Capabilities.TextDocument.SemanticTokens.TokenTypes = lsp.SemanticTypes()
params.Capabilities.TextDocument.SemanticTokens.TokenModifiers = lsp.SemanticModifiers()
params.InitializationOptions = map[string]interface{}{

View File

@ -72,7 +72,11 @@ func output() {
cm = ", "
}
t.Param += fmt.Sprintf("%s%s %s", cm, t.paramnames[i], p)
t.Invoke += fmt.Sprintf("%s%s", cm, t.paramnames[i])
this := t.paramnames[i]
if this == "_" {
this = "nil"
}
t.Invoke += fmt.Sprintf("%s%s", cm, this)
}
if len(t.Results) > 1 {
t.Result = "("

View File

@ -2,8 +2,8 @@ package protocol
// Package protocol contains data types and code for LSP jsonrpcs
// generated automatically from vscode-languageserver-node
// commit: 60a5a7825e6f54f57917091f394fd8db7d1724bc
// last fetched Thu Sep 10 2020 09:21:57 GMT-0400 (Eastern Daylight Time)
// commit: 901fd40345060d159f07d234bbc967966a929a34
// last fetched Mon Oct 26 2020 09:10:42 GMT-0400 (Eastern Daylight Time)
// Code generated (see typescript/README.md) DO NOT EDIT.

View File

@ -1,7 +1,7 @@
// Package protocol contains data types and code for LSP jsonrpcs
// generated automatically from vscode-languageserver-node
// commit: 60a5a7825e6f54f57917091f394fd8db7d1724bc
// last fetched Thu Sep 10 2020 09:21:57 GMT-0400 (Eastern Daylight Time)
// commit: 901fd40345060d159f07d234bbc967966a929a34
// last fetched Mon Oct 26 2020 09:10:42 GMT-0400 (Eastern Daylight Time)
package protocol
// Code generated (see typescript/README.md) DO NOT EDIT.
@ -122,6 +122,11 @@ type CallHierarchyItem struct {
* Must be contained by the [`range`](#CallHierarchyItem.range).
*/
SelectionRange Range `json:"selectionRange"`
/**
* A data entry field that is preserved between a call hierarchy prepare and
* incoming calls or outgoing calls requests.
*/
Data interface{} `json:"data,omitempty"`
}
/**
@ -219,8 +224,8 @@ type ClientCapabilities = struct {
*/
Window interface{} `json:"window,omitempty"`
/**
* Whether client supports handling progress notifications. If set servers are allowed to
* report in `workDoneProgress` property in the request specific server capabilities.
* Whether client supports server initiated progress using the
* `window/workDoneProgress/create` request.
*
* Since 3.15.0
*/
@ -263,6 +268,31 @@ type CodeAction struct {
* @since 3.15.0
*/
IsPreferred bool `json:"isPreferred,omitempty"`
/**
* Marks that the code action cannot currently be applied.
*
* Clients should follow the following guidelines regarding disabled code actions:
*
* - Disabled code actions are not shown in automatic [lightbulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action)
* code action menu.
*
* - Disabled actions are shown as faded out in the code action menu when the user request a more specific type
* of code action, such as refactorings.
*
* - If the user has a [keybinding](https://code.visualstudio.com/docs/editor/refactoring#_keybindings-for-code-actions)
* that auto applies a code action and only a disabled code actions are returned, the client should show the user an
* error message with `reason` in the editor.
*
* @since 3.16.0
*/
Disabled struct {
/**
* Human readable description of why the code action is currently disabled.
*
* This is displayed in the code actions UI.
*/
Reason string `json:"reason"`
} `json:"disabled,omitempty"`
/**
* The workspace edit this code action performs.
*/
@ -273,6 +303,13 @@ type CodeAction struct {
* executed and then the command.
*/
Command *Command `json:"command,omitempty"`
/**
* A data entry field that is preserved on a code action between
* a `textDocument/codeAction` and a `codeAction/resolve` request.
*
* @since 3.16.0 - proposed state
*/
Data interface{} `json:"data,omitempty"`
}
/**
@ -307,9 +344,36 @@ type CodeActionClientCapabilities struct {
} `json:"codeActionLiteralSupport,omitempty"`
/**
* Whether code action supports the `isPreferred` property.
*
* @since 3.15.0
*/
IsPreferredSupport bool `json:"isPreferredSupport,omitempty"`
/**
* Whether code action supports the `disabled` property.
*
* @since 3.16.0 - proposed state
*/
DisabledSupport bool `json:"disabledSupport,omitempty"`
/**
* Whether code action supports the `data` property which is
* preserved between a `textDocument/codeAction` and a
* `codeAction/resolve` request.
*
* @since 3.16.0 - proposed state
*/
DataSupport bool `json:"dataSupport,omitempty"`
/**
* Whether the client support resolving additional code action
* properties via a separate `codeAction/resolve` request.
*
* @since 3.16.0 - proposed state
*/
ResolveSupport struct {
/**
* The properties that a client can resolve lazily.
*/
Properties []string `json:"properties"`
} `json:"resolveSupport,omitempty"`
}
/**
@ -350,6 +414,13 @@ type CodeActionOptions struct {
* may list out every specific kind they provide.
*/
CodeActionKinds []CodeActionKind `json:"codeActionKinds,omitempty"`
/**
* The server provides support to resolve additional
* information for a code action.
*
* @since 3.16.0
*/
ResolveProvider bool `json:"resolveProvider,omitempty"`
WorkDoneProgressOptions
}
@ -373,6 +444,18 @@ type CodeActionParams struct {
PartialResultParams
}
/**
* Structure to capture a description for an error code.
*
* @since 3.16.0 - proposed state
*/
type CodeDescription struct {
/**
* An URI to open with more information about the diagnostic error.
*/
Href URI `json:"href"`
}
/**
* A code lens represents a [command](#Command) that should be shown along with
* source text, like the number of references, a way to run tests, etc.
@ -585,16 +668,22 @@ type CompletionClientCapabilities struct {
* Client support insert replace edit to control different behavior if a
* completion item is inserted in the text or should replace text.
*
* @since 3.16.0 - Proposed state
* @since 3.16.0 - proposed state
*/
InsertReplaceSupport bool `json:"insertReplaceSupport,omitempty"`
/**
* Client supports to resolve `additionalTextEdits` in the `completionItem/resolve`
* request. So servers can postpone computing them.
* Indicates which properties a client can resolve lazily on a completion
* item. Before version 3.16.0 only the predefined properties `documentation`
* and `details` could be resolved lazily.
*
* @since 3.16.0 - Proposed state
* @since 3.16.0 - proposed state
*/
ResolveAdditionalTextEditsSupport bool `json:"resolveAdditionalTextEditsSupport,omitempty"`
ResolveSupport struct {
/**
* The properties that a client can resolve lazily.
*/
Properties []string `json:"properties"`
} `json:"resolveSupport,omitempty"`
} `json:"completionItem,omitempty"`
CompletionItemKind struct {
/**
@ -722,7 +811,7 @@ type CompletionItem struct {
* *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.
*
* @since 3.16.0 additional type `InsertReplaceEdit` - Proposed state
* @since 3.16.0 additional type `InsertReplaceEdit` - proposed state
*/
TextEdit *TextEdit/*TextEdit | InsertReplaceEdit*/ `json:"textEdit,omitempty"`
/**
@ -1041,10 +1130,14 @@ type Diagnostic struct {
Severity DiagnosticSeverity `json:"severity,omitempty"`
/**
* The diagnostic's code, which usually appear in the user interface.
*
* @since 3.16.0 Support for `DiagnosticCode` - Proposed state
*/
Code interface{}/* float64 | string | DiagnosticCode*/ `json:"code,omitempty"`
Code interface{}/*number | string*/ `json:"code,omitempty"`
/**
* An optional property to describe the error code.
*
* @since 3.16.0 - proposed state
*/
CodeDescription CodeDescription `json:"codeDescription,omitempty"`
/**
* A human-readable string describing the source of this
* diagnostic, e.g. 'typescript' or 'super lint'. It usually
@ -1066,22 +1159,13 @@ type Diagnostic struct {
* a scope collide all definitions can be marked via this property.
*/
RelatedInformation []DiagnosticRelatedInformation `json:"relatedInformation,omitempty"`
}
/**
* Structure to capture more complex diagnostic codes.
*
* @since 3.16.0 - Proposed state
*/
type DiagnosticCode struct {
/**
* The actual code
* A data entry field that is preserved between a `textDocument/publishDiagnostics`
* notification and `textDocument/codeAction` request.
*
* @since 3.16.0 - proposed state
*/
Value string/*string | number*/ `json:"value"`
/**
* A target URI to open with more information about the diagnostic error.
*/
Target URI `json:"target"`
Data interface{} `json:"data,omitempty"`
}
/**
@ -1545,7 +1629,7 @@ type DocumentSymbol struct {
/**
* Tags for this completion item.
*
* @since 3.16.0 - Proposed state
* @since 3.16.0 - proposed state
*/
Tags []SymbolTag `json:"tags,omitempty"`
/**
@ -1556,13 +1640,13 @@ type DocumentSymbol struct {
Deprecated bool `json:"deprecated,omitempty"`
/**
* The range enclosing this symbol not including leading/trailing whitespace but everything else
* like comments. This information is typically used to determine if the clients cursor is
* like comments. This information is typically used to determine if the the clients cursor is
* inside the symbol to reveal in the symbol in the UI.
*/
Range Range `json:"range"`
/**
* The range that should be selected and revealed when this symbol is being picked, e.g the name of a function.
* Must be contained by the `range`.
* Must be contained by the the `range`.
*/
SelectionRange Range `json:"selectionRange"`
/**
@ -1604,7 +1688,7 @@ type DocumentSymbolClientCapabilities struct {
* `DocumentSymbol` if `hierarchicalDocumentSymbolSupport` is set to true.
* Clients supporting tags have to handle unknown tags gracefully.
*
* @since 3.16.0 - Proposed state
* @since 3.16.0 - proposed state
*/
TagSupport struct {
/**
@ -1612,12 +1696,26 @@ type DocumentSymbolClientCapabilities struct {
*/
ValueSet []SymbolTag `json:"valueSet"`
} `json:"tagSupport,omitempty"`
/**
* The client supports an additional label presented in the UI when
* registering a document symbol provider.
*
* @since 3.16.0
*/
LabelSupport bool `json:"labelSupport,omitempty"`
}
/**
* Provider options for a [DocumentSymbolRequest](#DocumentSymbolRequest).
*/
type DocumentSymbolOptions struct {
/**
* A human-readable string that is shown when multiple outlines trees
* are shown for the same document.
*
* @since 3.16.0 - proposed state
*/
Label string `json:"label,omitempty"`
WorkDoneProgressOptions
}
@ -2114,13 +2212,13 @@ type InnerServerCapabilities struct {
/**
* The server provides Call Hierarchy support.
*
* @since 3.16.0 - Proposed state
* @since 3.16.0 - proposed state
*/
CallHierarchyProvider interface{}/* bool | CallHierarchyOptions | CallHierarchyRegistrationOptions*/ `json:"callHierarchyProvider,omitempty"`
/**
* The server provides semantic tokens support.
*
* @since 3.16.0 - Proposed state
* @since 3.16.0 - proposed state
*/
SemanticTokensProvider interface{}/*SemanticTokensOptions | SemanticTokensRegistrationOptions*/ `json:"semanticTokensProvider,omitempty"`
/**
@ -2132,7 +2230,7 @@ type InnerServerCapabilities struct {
/**
* A special text edit to provide an insert and a replace operation.
*
* @since 3.16.0 - Proposed state
* @since 3.16.0 - proposed state
*/
type InsertReplaceEdit struct {
/**
@ -2188,7 +2286,7 @@ type LocationLink struct {
TargetRange Range `json:"targetRange"`
/**
* The range that should be selected and revealed when this link is being followed, e.g the name of a function.
* Must be contained by the `targetRange`. See also `DocumentSymbol#range`
* Must be contained by the the `targetRange`. See also `DocumentSymbol#range`
*/
TargetSelectionRange Range `json:"targetSelectionRange"`
}
@ -2284,6 +2382,44 @@ type MessageActionItem struct {
*/
type MessageType float64
/**
* Moniker definition to match LSIF 0.5 moniker definition.
*
* @since 3.16.0
*/
type Moniker struct {
/**
* The scheme of the moniker. For example tsc or .Net
*/
Scheme string `json:"scheme"`
/**
* The identifier of the moniker. The value is opaque in LSIF however
* schema owners are allowed to define the structure if they want.
*/
Identifier string `json:"identifier"`
/**
* The scope in which the moniker is unique
*/
Unique UniquenessLevel `json:"unique"`
/**
* The moniker kind if known.
*/
Kind MonikerKind `json:"kind,omitempty"`
}
/**
* The moniker kind.
*
* @since 3.16.0
*/
type MonikerKind string
type MonikerParams struct {
TextDocumentPositionParams
WorkDoneProgressParams
PartialResultParams
}
/**
* Represents a parameter of a callable-signature. A parameter can
* have a label and a doc-comment.
@ -2390,11 +2526,19 @@ type PublishDiagnosticsClientCapabilities struct {
*/
VersionSupport bool `json:"versionSupport,omitempty"`
/**
* Clients support complex diagnostic codes (e.g. code and target URI).
* Client supports a codeDescription property
*
* @since 3.16.0 - Proposed state
* @since 3.16.0 - proposed state
*/
ComplexDiagnosticCodeSupport bool `json:"complexDiagnosticCodeSupport,omitempty"`
CodeDescriptionSupport bool `json:"codeDescriptionSupport,omitempty"`
/**
* Whether code action supports the `data` property which is
* preserved between a `textDocument/publishDiagnostics` and
* `textDocument/codeAction` request.
*
* @since 3.16.0 - proposed state
*/
DataSupport bool `json:"dataSupport,omitempty"`
}
/**
@ -2676,6 +2820,45 @@ type SemanticTokens struct {
Data []float64 `json:"data"`
}
/**
* @since 3.16.0 - Proposed state
*/
type SemanticTokensClientCapabilities struct {
/**
* Whether implementation supports dynamic registration. If this is set to `true`
* the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`
* return value for the corresponding server capability as well.
*/
DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
/**
* Which requests the client supports and might send to the server
*/
Requests struct {
/**
* The client will send the `textDocument/semanticTokens/range` request if
* the server provides a corresponding handler.
*/
Range bool/*boolean | { }*/ `json:"range,omitempty"`
/**
* The client will send the `textDocument/semanticTokens/full` request if
* the server provides a corresponding handler.
*/
Full interface{}/*boolean | <elided struct>*/ `json:"full,omitempty"`
} `json:"requests"`
/**
* The token types that the client supports.
*/
TokenTypes []string `json:"tokenTypes"`
/**
* The token modifiers that the client supports.
*/
TokenModifiers []string `json:"tokenModifiers"`
/**
* The formats the clients supports.
*/
Formats []TokenFormat `json:"formats"`
}
/**
* @since 3.16.0 - Proposed state
*/
@ -2752,7 +2935,7 @@ type SemanticTokensOptions struct {
/**
* Server supports providing semantic tokens for a full document.
*/
Full bool/*boolean | <elided struct>*/ `json:"full,omitempty"`
Full interface{}/*boolean | <elided struct>*/ `json:"full,omitempty"`
WorkDoneProgressOptions
}
@ -2793,6 +2976,16 @@ type SemanticTokensRegistrationOptions struct {
StaticRegistrationOptions
}
type SemanticTokensWorkspaceClientCapabilities struct {
/**
* Whether the client implementation supports a refresh request send from the server
* to the client. This is useful if a server detects a project wide configuration change
* which requires a re-calculation of all semantic tokens provided by the server issuing
* the request.
*/
RefreshSupport bool `json:"refreshSupport,omitempty"`
}
type ServerCapabilities = struct {
/**
* Defines how text documents are synced. Is either a detailed structure defining each notification or
@ -2894,13 +3087,13 @@ type ServerCapabilities = struct {
/**
* The server provides Call Hierarchy support.
*
* @since 3.16.0 - Proposed state
* @since 3.16.0 - proposed state
*/
CallHierarchyProvider interface{}/* bool | CallHierarchyOptions | CallHierarchyRegistrationOptions*/ `json:"callHierarchyProvider,omitempty"`
/**
* The server provides semantic tokens support.
*
* @since 3.16.0 - Proposed state
* @since 3.16.0 - proposed state
*/
SemanticTokensProvider interface{}/*SemanticTokensOptions | SemanticTokensRegistrationOptions*/ `json:"semanticTokensProvider,omitempty"`
/**
@ -3149,7 +3342,7 @@ type SymbolInformation struct {
/**
* Tags for this completion item.
*
* @since 3.16.0 - Proposed state
* @since 3.16.0 - proposed state
*/
Tags []SymbolTag `json:"tags,omitempty"`
/**
@ -3289,23 +3482,28 @@ type TextDocumentClientCapabilities struct {
*/
SelectionRange SelectionRangeClientCapabilities `json:"selectionRange,omitempty"`
/**
* Capabilities specific to `textDocument/publishDiagnostics`.
* Capabilities specific to `textDocument/publishDiagnostics` notification.
*/
PublishDiagnostics PublishDiagnosticsClientCapabilities `json:"publishDiagnostics,omitempty"`
/**
* Capabilities specific to the `textDocument/callHierarchy`.
* Capabilities specific to the various call hierarchy requests.
*
* @since 3.16.0
*/
CallHierarchy CallHierarchyClientCapabilities `json:"callHierarchy,omitempty"`
// missing in source, generated
SemanticTokens *SemanticTokensClientCapabilities `json:"semanticTokens,omitempty"`
/**
* Capabilities specific to the various semantic token requsts.
*
* @since 3.16.0 - Proposed state
*/
SemanticTokens SemanticTokensClientCapabilities `json:"semanticTokens,omitempty"`
}
/**
* An event describing a change to a text document. If range and rangeLength are omitted
* the new text is considered to be the full content of the document.
*
* @deprecated Use the text document from the new vscode-languageserver-textdocument package.
*/
type TextDocumentContentChangeEvent = struct {
/**
@ -3477,6 +3675,8 @@ type TextEdit struct {
NewText string `json:"newText"`
}
type TokenFormat = string
type TraceValues = string /*'off' | 'messages' | 'verbose'*/
/**
@ -3516,10 +3716,17 @@ type TypeDefinitionRegistrationOptions struct {
/**
* A tagging type for string properties that are actually URIs
*
* @since 3.16.0 - Proposed state
* @since 3.16.0 - proposed state
*/
type URI = string
/**
* Moniker uniqueness level to define scope of the moniker.
*
* @since 3.16.0
*/
type UniquenessLevel string
/**
* General parameters to unregister a request or notification.
*/
@ -3617,8 +3824,8 @@ type WorkDoneProgressClientCapabilities struct {
*/
Window struct {
/**
* Whether client supports handling progress notifications. If set servers are allowed to
* report in `workDoneProgress` property in the request specific server capabilities.
* Whether client supports server initiated progress using the
* `window/workDoneProgress/create` request.
*
* Since 3.15.0
*/
@ -3711,6 +3918,13 @@ type WorkspaceClientCapabilities struct {
* Capabilities specific to the `workspace/executeCommand` request.
*/
ExecuteCommand ExecuteCommandClientCapabilities `json:"executeCommand,omitempty"`
/**
* Capabilities specific to the semantic token requsts scoped to the
* workspace.
*
* @since 3.16.0 - proposed state.
*/
SemanticTokens SemanticTokensWorkspaceClientCapabilities `json:"semanticTokens,omitempty"`
}
/**
@ -3834,7 +4048,7 @@ type WorkspaceSymbolClientCapabilities struct {
* The client supports tags on `SymbolInformation`.
* Clients supporting tags have to handle unknown tags gracefully.
*
* @since 3.16.0 - Proposed state
* @since 3.16.0 - proposed state
*/
TagSupport struct {
/**
@ -3864,20 +4078,6 @@ type WorkspaceSymbolParams struct {
PartialResultParams
}
// generated
type SemanticTokensClientCapabilities struct {
TokenModifiers []string
Formats []string
Requests struct {
Range bool
Full struct {
Delta bool
}
}
DynamicRegistration bool
TokenTypes []string
}
const (
/**
* Empty kind.
@ -4158,6 +4358,19 @@ const (
*/
Log MessageType = 4
/**
* The moniker represent a symbol that is imported into a project
*/
Import MonikerKind = "import"
/**
* The moniker represents a symbol that is exported from a project
*/
Export MonikerKind = "export"
/**
* The moniker represents a symbol that is local to a project (e.g. a local
* variable of a function, a class not visible outside the project, ...)
*/
Local MonikerKind = "local"
/**
* Supports creating new files and folders.
*/
@ -4253,6 +4466,26 @@ const (
*/
Incremental TextDocumentSyncKind = 2
/**
* The moniker is only unique inside a document
*/
Document UniquenessLevel = "document"
/**
* The moniker is unique inside a project for which a dump got created
*/
Project UniquenessLevel = "project"
/**
* The moniker is unique inside the group to which a project belongs
*/
Group UniquenessLevel = "group"
/**
* The moniker is unique inside the moniker scheme.
*/
Scheme UniquenessLevel = "scheme"
/**
* The moniker is globally unique
*/
Global UniquenessLevel = "global"
/**
* Interested in create events.
*/

View File

@ -2,8 +2,8 @@ package protocol
// Package protocol contains data types and code for LSP jsonrpcs
// generated automatically from vscode-languageserver-node
// commit: 60a5a7825e6f54f57917091f394fd8db7d1724bc
// last fetched Thu Sep 10 2020 09:21:57 GMT-0400 (Eastern Daylight Time)
// commit: 901fd40345060d159f07d234bbc967966a929a34
// last fetched Mon Oct 26 2020 09:10:42 GMT-0400 (Eastern Daylight Time)
// Code generated (see typescript/README.md) DO NOT EDIT.
@ -18,7 +18,6 @@ import (
type Server interface {
DidChangeWorkspaceFolders(context.Context, *DidChangeWorkspaceFoldersParams) error
WorkDoneProgressCancel(context.Context, *WorkDoneProgressCancelParams) error
SemanticTokensRefresh(context.Context) error
Initialized(context.Context, *InitializedParams) error
Exit(context.Context) error
DidChangeConfiguration(context.Context, *DidChangeConfigurationParams) error
@ -43,6 +42,7 @@ type Server interface {
SemanticTokensFull(context.Context, *SemanticTokensParams) (*SemanticTokens /*SemanticTokens | null*/, error)
SemanticTokensFullDelta(context.Context, *SemanticTokensDeltaParams) (interface{} /* SemanticTokens | SemanticTokensDelta | nil*/, error)
SemanticTokensRange(context.Context, *SemanticTokensRangeParams) (*SemanticTokens /*SemanticTokens | null*/, error)
SemanticTokensRefresh(context.Context) error
Initialize(context.Context, *ParamInitialize) (*InitializeResult, error)
Shutdown(context.Context) error
WillSaveWaitUntil(context.Context, *WillSaveTextDocumentParams) ([]TextEdit /*TextEdit[] | null*/, error)
@ -55,6 +55,7 @@ type Server interface {
DocumentHighlight(context.Context, *DocumentHighlightParams) ([]DocumentHighlight /*DocumentHighlight[] | null*/, error)
DocumentSymbol(context.Context, *DocumentSymbolParams) ([]interface{} /*SymbolInformation[] | DocumentSymbol[] | null*/, error)
CodeAction(context.Context, *CodeActionParams) ([]CodeAction /*(Command | CodeAction)[] | null*/, error)
ResolveCodeAction(context.Context, *CodeAction) (*CodeAction, error)
Symbol(context.Context, *WorkspaceSymbolParams) ([]SymbolInformation /*SymbolInformation[] | null*/, error)
CodeLens(context.Context, *CodeLensParams) ([]CodeLens /*CodeLens[] | null*/, error)
ResolveCodeLens(context.Context, *CodeLens) (*CodeLens, error)
@ -66,6 +67,7 @@ type Server interface {
Rename(context.Context, *RenameParams) (*WorkspaceEdit /*WorkspaceEdit | null*/, error)
PrepareRename(context.Context, *PrepareRenameParams) (*Range /*Range | { range: Range, placeholder: string } | { defaultBehavior: boolean } | null*/, error)
ExecuteCommand(context.Context, *ExecuteCommandParams) (interface{} /*any | null*/, error)
Moniker(context.Context, *MonikerParams) ([]Moniker /*Moniker[] | null*/, error)
NonstandardRequest(ctx context.Context, method string, params interface{}) (interface{}, error)
}
@ -85,9 +87,6 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier,
}
err := server.WorkDoneProgressCancel(ctx, &params)
return true, reply(ctx, nil, err)
case "workspace/semanticTokens/refresh": // notif
err := server.SemanticTokensRefresh(ctx)
return true, reply(ctx, nil, err)
case "initialized": // notif
var params InitializedParams
if err := json.Unmarshal(r.Params(), &params); err != nil {
@ -252,6 +251,12 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier,
}
resp, err := server.SemanticTokensRange(ctx, &params)
return true, reply(ctx, resp, err)
case "workspace/semanticTokens/refresh": // req
if len(r.Params()) > 0 {
return true, reply(ctx, nil, errors.Errorf("%w: expected no params", jsonrpc2.ErrInvalidParams))
}
err := server.SemanticTokensRefresh(ctx)
return true, reply(ctx, nil, err)
case "initialize": // req
var params ParamInitialize
if err := json.Unmarshal(r.Params(), &params); err != nil {
@ -335,6 +340,13 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier,
}
resp, err := server.CodeAction(ctx, &params)
return true, reply(ctx, resp, err)
case "codeAction/resolve": // req
var params CodeAction
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
}
resp, err := server.ResolveCodeAction(ctx, &params)
return true, reply(ctx, resp, err)
case "workspace/symbol": // req
var params WorkspaceSymbolParams
if err := json.Unmarshal(r.Params(), &params); err != nil {
@ -412,6 +424,13 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier,
}
resp, err := server.ExecuteCommand(ctx, &params)
return true, reply(ctx, resp, err)
case "textDocument/moniker": // req
var params MonikerParams
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
}
resp, err := server.Moniker(ctx, &params)
return true, reply(ctx, resp, err)
default:
return false, nil
@ -426,10 +445,6 @@ func (s *serverDispatcher) WorkDoneProgressCancel(ctx context.Context, params *W
return s.Conn.Notify(ctx, "window/workDoneProgress/cancel", params)
}
func (s *serverDispatcher) SemanticTokensRefresh(ctx context.Context) error {
return s.Conn.Notify(ctx, "workspace/semanticTokens/refresh", nil)
}
func (s *serverDispatcher) Initialized(ctx context.Context, params *InitializedParams) error {
return s.Conn.Notify(ctx, "initialized", params)
}
@ -577,6 +592,10 @@ func (s *serverDispatcher) SemanticTokensRange(ctx context.Context, params *Sema
return result, nil
}
func (s *serverDispatcher) SemanticTokensRefresh(ctx context.Context) error {
return Call(ctx, s.Conn, "workspace/semanticTokens/refresh", nil, nil)
}
func (s *serverDispatcher) Initialize(ctx context.Context, params *ParamInitialize) (*InitializeResult, error) {
var result *InitializeResult
if err := Call(ctx, s.Conn, "initialize", params, &result); err != nil {
@ -669,6 +688,14 @@ func (s *serverDispatcher) CodeAction(ctx context.Context, params *CodeActionPar
return result, nil
}
func (s *serverDispatcher) ResolveCodeAction(ctx context.Context, params *CodeAction) (*CodeAction, error) {
var result *CodeAction
if err := Call(ctx, s.Conn, "codeAction/resolve", params, &result); err != nil {
return nil, err
}
return result, nil
}
func (s *serverDispatcher) Symbol(ctx context.Context, params *WorkspaceSymbolParams) ([]SymbolInformation /*SymbolInformation[] | null*/, error) {
var result []SymbolInformation /*SymbolInformation[] | null*/
if err := Call(ctx, s.Conn, "workspace/symbol", params, &result); err != nil {
@ -757,6 +784,14 @@ func (s *serverDispatcher) ExecuteCommand(ctx context.Context, params *ExecuteCo
return result, nil
}
func (s *serverDispatcher) Moniker(ctx context.Context, params *MonikerParams) ([]Moniker /*Moniker[] | null*/, error) {
var result []Moniker /*Moniker[] | null*/
if err := Call(ctx, s.Conn, "textDocument/moniker", params, &result); err != nil {
return nil, err
}
return result, nil
}
func (s *serverDispatcher) NonstandardRequest(ctx context.Context, method string, params interface{}) (interface{}, error) {
var result interface{}
if err := Call(ctx, s.Conn, method, params, &result); err != nil {

View File

@ -36,8 +36,8 @@ func (s *Server) DidChange(ctx context.Context, params *protocol.DidChangeTextDo
return s.didChange(ctx, params)
}
func (s *Server) DidChangeConfiguration(ctx context.Context, changed *protocol.DidChangeConfigurationParams) error {
return s.didChangeConfiguration(ctx, changed)
func (s *Server) DidChangeConfiguration(ctx context.Context, _ *protocol.DidChangeConfigurationParams) error {
return s.didChangeConfiguration(ctx, nil)
}
func (s *Server) DidChangeWatchedFiles(ctx context.Context, params *protocol.DidChangeWatchedFilesParams) error {
@ -116,6 +116,10 @@ func (s *Server) LogTrace(context.Context, *protocol.LogTraceParams) error {
return notImplemented("LogTrace")
}
func (s *Server) Moniker(context.Context, *protocol.MonikerParams) ([]protocol.Moniker, error) {
return nil, notImplemented("Moniker")
}
func (s *Server) NonstandardRequest(ctx context.Context, method string, params interface{}) (interface{}, error) {
return s.nonstandardRequest(ctx, method, params)
}
@ -152,6 +156,10 @@ func (s *Server) Resolve(context.Context, *protocol.CompletionItem) (*protocol.C
return nil, notImplemented("Resolve")
}
func (s *Server) ResolveCodeAction(context.Context, *protocol.CodeAction) (*protocol.CodeAction, error) {
return nil, notImplemented("ResolveCodeAction")
}
func (s *Server) ResolveCodeLens(context.Context, *protocol.CodeLens) (*protocol.CodeLens, error) {
return nil, notImplemented("ResolveCodeLens")
}

View File

@ -538,12 +538,11 @@ func (o *Options) ForClientCapabilities(caps protocol.ClientCapabilities) {
// Check if the client supports hierarchical document symbols.
o.HierarchicalDocumentSymbolSupport = caps.TextDocument.DocumentSymbol.HierarchicalDocumentSymbolSupport
// Check if the client supports semantic tokens
if c := caps.TextDocument.SemanticTokens; c != nil {
o.SemanticTypes = c.TokenTypes
o.SemanticMods = c.TokenModifiers
// we don't need Requests, as we support full functionality
// we don't need Formats, as there is only one, for now
}
o.SemanticTypes = caps.TextDocument.SemanticTokens.TokenTypes
o.SemanticMods = caps.TextDocument.SemanticTokens.TokenModifiers
// we don't need Requests, as we support full functionality
// we don't need Formats, as there is only one, for now
}
func (o *Options) Clone() *Options {