diff --git a/client.go b/client.go index 969c7fe..060ae15 100644 --- a/client.go +++ b/client.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/doc.go b/doc.go new file mode 100644 index 0000000..82bb9fd --- /dev/null +++ b/doc.go @@ -0,0 +1,8 @@ +// +// Copyright 2024 Cristian Maglie. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. +// + +// Package lsp is an implementation of a Language Server Protocol handler. +package lsp diff --git a/go.mod b/go.mod index 6144ba6..b705d33 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module go.bug.st/lsp -go 1.15 +go 1.22 require ( github.com/arduino/go-paths-helper v1.6.1 @@ -8,3 +8,9 @@ require ( github.com/stretchr/testify v1.6.1 go.bug.st/json v1.15.6 ) + +require ( + github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect +) diff --git a/jsonrpc/doc.go b/jsonrpc/doc.go new file mode 100644 index 0000000..ba3d59f --- /dev/null +++ b/jsonrpc/doc.go @@ -0,0 +1,8 @@ +// +// Copyright 2024 Cristian Maglie. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. +// + +// Package jsonrpc is an implementation of a Language Server Protocol JSON-RPC protocol. +package jsonrpc diff --git a/jsonrpc/jsonrpc_connection.go b/jsonrpc/jsonrpc_connection.go index ad0c99e..cb0df53 100644 --- a/jsonrpc/jsonrpc_connection.go +++ b/jsonrpc/jsonrpc_connection.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // @@ -236,14 +236,14 @@ func (c *Connection) Close() { func (c *Connection) SendRequest(ctx context.Context, method string, params json.RawMessage) (json.RawMessage, *ResponseError, error) { id := fmt.Sprintf("%d", atomic.AddUint64(&c.lastOutRequestsIndex, 1)) - encodedId, err := json.Marshal(id) + encodedID, err := json.Marshal(id) if err != nil { // should never happen... panic("internal error creating RequestMessage") } req := RequestMessage{ JSONRPC: "2.0", - ID: encodedId, + ID: encodedID, Method: method, Params: params, } diff --git a/jsonrpc/jsonrpc_protocol.go b/jsonrpc/jsonrpc_protocol.go index 4abb1d9..4f523fd 100644 --- a/jsonrpc/jsonrpc_protocol.go +++ b/jsonrpc/jsonrpc_protocol.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/jsonrpc/jsonrpc_test.go b/jsonrpc/jsonrpc_test.go index 25d6075..0c732a0 100644 --- a/jsonrpc/jsonrpc_test.go +++ b/jsonrpc/jsonrpc_test.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/jsonrpc/logger.go b/jsonrpc/logger.go index 7939c9c..ac38d5f 100644 --- a/jsonrpc/logger.go +++ b/jsonrpc/logger.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/lsp_basic.go b/lsp_basic.go index 4346f6f..5e51f4d 100644 --- a/lsp_basic.go +++ b/lsp_basic.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // @@ -260,7 +260,7 @@ func (p WorkDoneProgressEnd) String() string { return res } -// General parameters to register for a capability. +// Registration General parameters to register for a capability. type Registration struct { // The id used to register the request. The id can be used to deregister // the request again. @@ -277,7 +277,7 @@ type RegistrationParams struct { Registrations []Registration `json:"registrations,required"` } -// General parameters to unregister a capability. +// Unregistration General parameters to unregister a capability. type Unregistration struct { // The id used to unregister the request or notification. Usually an id // provided during the register request. diff --git a/lsp_basic_test.go b/lsp_basic_test.go index dc8fff4..ccc0480 100644 --- a/lsp_basic_test.go +++ b/lsp_basic_test.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // @@ -23,7 +23,7 @@ func TestDecodingProgressReports(t *testing.T) { Percentage: &perc, } - beginJson := `{ + beginJSON := `{ "cancellable" : true, "kind" : "begin", "message" : "mesg", @@ -32,13 +32,13 @@ func TestDecodingProgressReports(t *testing.T) { }` beginData, err := json.Marshal(beginParam) require.NoError(t, err) - require.JSONEq(t, beginJson, string(beginData)) + require.JSONEq(t, beginJSON, string(beginData)) - err = json.Unmarshal([]byte(beginJson), &beginParam) + err = json.Unmarshal([]byte(beginJSON), &beginParam) require.NoError(t, err) } { - begin_json := `{ + beginJSON := `{ "token": "aaaa10292992929287172", "value": { "kind": "begin", @@ -46,7 +46,7 @@ func TestDecodingProgressReports(t *testing.T) { "cancellable": true } }` - r, err := DecodeServerNotificationParams("$/progress", json.RawMessage([]byte(begin_json))) + r, err := DecodeServerNotificationParams("$/progress", json.RawMessage([]byte(beginJSON))) require.NoError(t, err) require.IsType(t, &ProgressParams{}, r) pp := r.(*ProgressParams) @@ -62,7 +62,7 @@ func TestDecodingProgressReports(t *testing.T) { Percentage: &perc, } - reportJson := `{ + reportJSON := `{ "cancellable" : true, "kind" : "report", "message" : "mesg", @@ -70,13 +70,13 @@ func TestDecodingProgressReports(t *testing.T) { }` reportData, err := json.Marshal(reportParam) require.NoError(t, err) - require.JSONEq(t, reportJson, string(reportData)) + require.JSONEq(t, reportJSON, string(reportData)) - err = json.Unmarshal([]byte(reportJson), &reportParam) + err = json.Unmarshal([]byte(reportJSON), &reportParam) require.NoError(t, err) } { - report_json := `{ + reportJSON := `{ "token": "aaaa10292992929287172", "value": { "kind": "report", @@ -84,7 +84,7 @@ func TestDecodingProgressReports(t *testing.T) { "cancellable": true } }` - r, err := DecodeServerNotificationParams("$/progress", json.RawMessage([]byte(report_json))) + r, err := DecodeServerNotificationParams("$/progress", json.RawMessage([]byte(reportJSON))) require.NoError(t, err) require.IsType(t, &ProgressParams{}, r) pp := r.(*ProgressParams) @@ -97,26 +97,26 @@ func TestDecodingProgressReports(t *testing.T) { Message: "mesg", } - endJson := `{ + endJSON := `{ "kind" : "end", "message" : "mesg" }` endData, err := json.Marshal(endParam) require.NoError(t, err) - require.JSONEq(t, endJson, string(endData)) + require.JSONEq(t, endJSON, string(endData)) - err = json.Unmarshal([]byte(endJson), &endParam) + err = json.Unmarshal([]byte(endJSON), &endParam) require.NoError(t, err) } { - end_json := `{ + endJSON := `{ "token": "aaaa10292992929287172", "value": { "kind": "end", "message": "bye" } }` - r, err := DecodeServerNotificationParams("$/progress", json.RawMessage([]byte(end_json))) + r, err := DecodeServerNotificationParams("$/progress", json.RawMessage([]byte(endJSON))) require.NoError(t, err) require.IsType(t, &ProgressParams{}, r) pp := r.(*ProgressParams) diff --git a/lsp_capabilities_client.go b/lsp_capabilities_client.go index 390f186..121bf5b 100644 --- a/lsp_capabilities_client.go +++ b/lsp_capabilities_client.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // @@ -186,32 +186,32 @@ type WorkspaceEditClientCapabilities struct { type ResourceOperationKind string -// ResourceOperationKindCreate: Supports creating new files and folders. +// ResourceOperationKindCreate Supports creating new files and folders. const ResourceOperationKindCreate = ResourceOperationKind("create") -// ResourceOperationKindRename: Supports renaming existing files and folders. +// ResourceOperationKindRename Supports renaming existing files and folders. const ResourceOperationKindRename = ResourceOperationKind("rename") -// ResourceOperationKindDelete: Supports deleting existing files and folders. +// ResourceOperationKindDelete Supports deleting existing files and folders. const ResourceOperationKindDelete = ResourceOperationKind("delete") type FailureHandlingKind string -// FailureHandlingKindAbort: Applying the workspace change is simply aborted if one of the changes +// FailureHandlingKindAbort Applying the workspace change is simply aborted if one of the changes // provided fails. All operations executed before the failing operation // stay executed. const FailureHandlingKindAbort FailureHandlingKind = "abort" -// FailureHandlingKindTransactional: All operations are executed transactional. That means they either all +// FailureHandlingKindTransactional All operations are executed transactional. That means they either all // succeed or no changes at all are applied to the workspace. const FailureHandlingKindTransactional FailureHandlingKind = "transactional" -// FailureHandlingKindTextOnlyTransactional: If the workspace edit contains only textual file changes they are +// FailureHandlingKindTextOnlyTransactional If the workspace edit contains only textual file changes they are // executed transactional. If resource changes (create, rename or delete // file) are part of the change the failure handling strategy is abort. const FailureHandlingKindTextOnlyTransactional FailureHandlingKind = "textOnlyTransactional" -// FailureHandlingKindUndo: The client tries to undo the operations already executed. But there is no +// FailureHandlingKindUndo The client tries to undo the operations already executed. But there is no // guarantee that this is succeeding. const FailureHandlingKindUndo FailureHandlingKind = "undo" @@ -587,35 +587,35 @@ type CompletionKindCapabilities struct { type MarkupKind string -// Plain text is supported as a content format +// MarkupKindPlainText Plain text is supported as a content format const MarkupKindPlainText MarkupKind = "plaintext" -// Markdown is supported as a content format +// MarkupKindMarkdown Markdown is supported as a content format const MarkupKindMarkdown MarkupKind = "markdown" -// Completion item tags are extra annotations that tweak the rendering of a +// CompletionItemTag Completion item tags are extra annotations that tweak the rendering of a // completion item. // // @since 3.15.0 type CompletionItemTag int -// Render a completion as obsolete, usually using a strike-out. +// CompletionItemTagDeprecated Render a completion as obsolete, usually using a strike-out. const CompletionItemTagDeprecated CompletionItemTag = 1 -// How whitespace and indentation is handled during completion +// InsertTextMode How whitespace and indentation is handled during completion // item insertion. // // @since 3.16.0 type InsertTextMode int -// The insertion or replace strings is taken as it is. If the +// InsertTextModeAsIs The insertion or replace strings is taken as it is. If the // value is multi line the lines below the cursor will be // inserted using the indentation defined in the string value. // The client will not apply any kind of adjustments to the // string. const InsertTextModeAsIs InsertTextMode = 1 -// The editor adjusts leading whitespace of new lines so that +// InsertTextModeAdjustIndentation The editor adjusts leading whitespace of new lines so that // they match the indentation up to the cursor of the line for // which the item is accepted. // @@ -624,7 +624,7 @@ const InsertTextModeAsIs InsertTextMode = 1 // following lines inserted will be indented using 2 tabs as well. const InsertTextModeAdjustIndentation InsertTextMode = 2 -// The kind of a completion entry. +// CompletionItemKind The kind of a completion entry. type CompletionItemKind int const CompletionItemKindText CompletionItemKind = 1 @@ -1134,7 +1134,7 @@ type MonikerClientCapabilities struct { DynamicRegistration bool `json:"dynamicRegistration,omitempty"` } -// The kind of a code action. +// CodeActionKind The kind of a code action. // // Kinds are a hierarchical list of identifiers separated by `.`, // e.g. `"refactor.extract.function"`. @@ -1143,16 +1143,16 @@ type MonikerClientCapabilities struct { // to the server during initialization. type CodeActionKind string -// Empty kind. +// CodeActionKindEmpty Empty kind. const CodeActionKindEmpty CodeActionKind = "" -// Base kind for quickfix actions: "quickfix". +// CodeActionKindQuickFix Base kind for quickfix actions: "quickfix". const CodeActionKindQuickFix CodeActionKind = "quickfix" -// Base kind for refactoring actions: "refactor". +// CodeActionKindRefactor Base kind for refactoring actions: "refactor". const CodeActionKindRefactor CodeActionKind = "refactor" -// Base kind for refactoring extraction actions: "refactor.extract". +// CodeActionKindRefactorExtract Base kind for refactoring extraction actions: "refactor.extract". // // Example extract actions: // @@ -1163,7 +1163,7 @@ const CodeActionKindRefactor CodeActionKind = "refactor" // - ... const CodeActionKindRefactorExtract CodeActionKind = "refactor.extract" -// Base kind for refactoring inline actions: "refactor.inline". +// CodeActionKindRefactorInline Base kind for refactoring inline actions: "refactor.inline". // // Example inline actions: // @@ -1173,7 +1173,7 @@ const CodeActionKindRefactorExtract CodeActionKind = "refactor.extract" // - ... const CodeActionKindRefactorInline CodeActionKind = "refactor.inline" -// Base kind for refactoring rewrite actions: "refactor.rewrite". +// CodeActionKindRefactorRewrite Base kind for refactoring rewrite actions: "refactor.rewrite". // // Example rewrite actions: // @@ -1185,16 +1185,16 @@ const CodeActionKindRefactorInline CodeActionKind = "refactor.inline" // - ... const CodeActionKindRefactorRewrite CodeActionKind = "refactor.rewrite" -// Base kind for source actions: `source`. +// CodeActionKindSource Base kind for source actions: `source`. // // Source code actions apply to the entire file. const CodeActionKindSource CodeActionKind = "source" -// Base kind for an organize imports source action: +// CodeActionKindSourceOrganizeImports Base kind for an organize imports source action: // `source.organizeImports`. const CodeActionKindSourceOrganizeImports CodeActionKind = "source.organizeImports" -// Base kind for a "fix all" source action: `source.fixAll`. +// CodeActionKindSourceFixAll Base kind for a "fix all" source action: `source.fixAll`. // // "Fix all" actions automatically fix errors that have a clear fix that // do not require user input. They should not suppress errors or perform @@ -1205,7 +1205,7 @@ const CodeActionKindSourceFixAll CodeActionKind = "source.fixAll" type PrepareSupportDefaultBehavior int -// The client's default behavior is to select the identifier +// PrepareSupportDefaultBehaviorIdentifier The client's default behavior is to select the identifier // according the to language's syntax rule. const PrepareSupportDefaultBehaviorIdentifier = 1 @@ -1213,7 +1213,7 @@ type TokenFormat string const TokenFormatRelative TokenFormat = "relative" -// Show message request client capabilities +// ShowMessageRequestClientCapabilities Show message request client capabilities type ShowMessageRequestClientCapabilities struct { // Capabilities specific to the `MessageActionItem` type. MessageActionItem struct { @@ -1225,7 +1225,7 @@ type ShowMessageRequestClientCapabilities struct { } `json:"messageActionItem"` } -// Client capabilities for the show document request. +// ShowDocumentClientCapabilities Client capabilities for the show document request. // // @since 3.16.0 type ShowDocumentClientCapabilities struct { @@ -1234,7 +1234,7 @@ type ShowDocumentClientCapabilities struct { Support bool `json:"support"` } -// Client capabilities specific to regular expressions. +// RegularExpressionsClientCapabilities Client capabilities specific to regular expressions. type RegularExpressionsClientCapabilities struct { // The engine's name. Engine string `json:"engine,required"` @@ -1243,7 +1243,7 @@ type RegularExpressionsClientCapabilities struct { Version string `json:"version,omitempty"` } -// Client capabilities specific to the used markdown parser. +// MarkdownClientCapabilities Client capabilities specific to the used markdown parser. // // @since 3.16.0 type MarkdownClientCapabilities struct { @@ -1262,7 +1262,7 @@ type DocumentLinkParams struct { TextDocument TextDocumentIdentifier `json:"textDocument,required"` } -// A document link is a range in a text document that links to an internal or +// DocumentLink A document link is a range in a text document that links to an internal or // external resource, like another text document or a web site. type DocumentLink struct { // The range this link applies to. @@ -1301,7 +1301,7 @@ type ColorInformation struct { Color Color `json:"color,required"` } -// Represents a color in RGBA space. +// Color Represents a color in RGBA space. type Color struct { // The red component of this color in the range [0-1]. Red float64 `json:"red,required"` diff --git a/lsp_capabilities_server.go b/lsp_capabilities_server.go index 4d1f995..2540ea0 100644 --- a/lsp_capabilities_server.go +++ b/lsp_capabilities_server.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // @@ -298,7 +298,7 @@ type SignatureHelpOptions struct { RetriggerCharacters []string `json:"retriggerCharacters,omitempty"` } -// boolean|DeclarationOptions|DeclarationRegistrationOptions +// DeclarationOptions boolean|DeclarationOptions|DeclarationRegistrationOptions type DeclarationOptions struct { *WorkDoneProgressOptions *StaticRegistrationOptions @@ -323,7 +323,7 @@ func (s *DeclarationOptions) UnmarshalJSON(data []byte) error { return fmt.Errorf("expected boolean or DeclarationOptions") } -// General text document registration options. +// TextDocumentRegistrationOptions General text document registration options. type TextDocumentRegistrationOptions struct { // A document selector to identify the scope of the registration. If set to // null the document selector provided on the client side will be used. @@ -355,14 +355,14 @@ type DocumentFilter struct { Pattern string `json:"pattern,omitempty"` } -// Static registration options to be returned in the initialize request. +// StaticRegistrationOptions Static registration options to be returned in the initialize request. type StaticRegistrationOptions struct { // The id used to register the request. The id can be used to deregister // the request again. See also Registration#id. ID string `json:"id,omitempty"` } -//boolean|DefinitionOptions +// DefinitionOptions boolean|DefinitionOptions type DefinitionOptions struct { *WorkDoneProgressOptions } @@ -385,7 +385,7 @@ func (s *DefinitionOptions) UnmarshalJSON(data []byte) error { return fmt.Errorf("expected boolean or DefinitionOptions") } -// boolean | TypeDefinitionOptions | TypeDefinitionRegistrationOptions +// TypeDefinitionOptions boolean | TypeDefinitionOptions | TypeDefinitionRegistrationOptions type TypeDefinitionOptions struct { *WorkDoneProgressOptions *TextDocumentRegistrationOptions @@ -410,7 +410,7 @@ func (s *TypeDefinitionOptions) UnmarshalJSON(data []byte) error { return fmt.Errorf("expected boolean or TypeDefinitionOptions") } -// boolean | ImplementationOptions | ImplementationRegistrationOptions +// ImplementationOptions boolean | ImplementationOptions | ImplementationRegistrationOptions type ImplementationOptions struct { *WorkDoneProgressOptions *TextDocumentRegistrationOptions @@ -435,7 +435,7 @@ func (s *ImplementationOptions) UnmarshalJSON(data []byte) error { return fmt.Errorf("expected boolean or ImplementationOptions") } -// boolean | ReferenceOptions +// ReferenceOptions boolean | ReferenceOptions type ReferenceOptions struct { *WorkDoneProgressOptions } @@ -458,7 +458,7 @@ func (s *ReferenceOptions) UnmarshalJSON(data []byte) error { return fmt.Errorf("expected boolean or ReferenceOptions") } -// boolean | DocumentHighlightOptions +// DocumentHighlightOptions boolean | DocumentHighlightOptions type DocumentHighlightOptions struct { *WorkDoneProgressOptions } @@ -481,7 +481,7 @@ func (s *DocumentHighlightOptions) UnmarshalJSON(data []byte) error { return fmt.Errorf("expected boolean or DocumentHighlightOptions") } -// boolean | DocumentSymbolOptions +// DocumentSymbolOptions boolean | DocumentSymbolOptions type DocumentSymbolOptions struct { *WorkDoneProgressOptions @@ -510,7 +510,7 @@ func (s *DocumentSymbolOptions) UnmarshalJSON(data []byte) error { return fmt.Errorf("expected boolean or DocumentSymbolOptions") } -// boolean | CodeActionOptions +// CodeActionOptions boolean | CodeActionOptions type CodeActionOptions struct { *WorkDoneProgressOptions @@ -559,7 +559,7 @@ type DocumentLinkOptions struct { ResolveProvider bool `json:"resolveProvider,omitempty"` } -// boolean | DocumentColorOptions | DocumentColorRegistrationOptions +// DocumentColorOptions boolean | DocumentColorOptions | DocumentColorRegistrationOptions type DocumentColorOptions struct { *WorkDoneProgressOptions *TextDocumentRegistrationOptions @@ -584,7 +584,7 @@ func (s *DocumentColorOptions) UnmarshalJSON(data []byte) error { return fmt.Errorf("expected boolean or DocumentColorOptions") } -// boolean | DocumentFormattingOptions +// DocumentFormattingOptions boolean | DocumentFormattingOptions type DocumentFormattingOptions struct { *WorkDoneProgressOptions } @@ -607,7 +607,7 @@ func (s *DocumentFormattingOptions) UnmarshalJSON(data []byte) error { return fmt.Errorf("expected boolean or DocumentFormattingOptions") } -// boolean | DocumentFormattingOptions +// DocumentRangeFormattingOptions boolean | DocumentFormattingOptions type DocumentRangeFormattingOptions struct { *WorkDoneProgressOptions } @@ -638,7 +638,7 @@ type DocumentOnTypeFormattingOptions struct { MoreTriggerCharacter []string `json:"moreTriggerCharacter,omitempty"` } -// boolean | RenameOptions +// RenameOptions boolean | RenameOptions type RenameOptions struct { *WorkDoneProgressOptions @@ -664,7 +664,7 @@ func (s *RenameOptions) UnmarshalJSON(data []byte) error { return fmt.Errorf("expected boolean or RenameOptions") } -// boolean | FoldingRangeOptions | FoldingRangeRegistrationOptions +// FoldingRangeOptions boolean | FoldingRangeOptions | FoldingRangeRegistrationOptions type FoldingRangeOptions struct { *WorkDoneProgressOptions *TextDocumentRegistrationOptions @@ -696,7 +696,7 @@ type ExecuteCommandOptions struct { Commands []string `json:"commands"` } -// boolean | SelectionRangeOptions | SelectionRangeRegistrationOptions +// SelectionRangeOptions boolean | SelectionRangeOptions | SelectionRangeRegistrationOptions type SelectionRangeOptions struct { *WorkDoneProgressOptions *TextDocumentRegistrationOptions @@ -721,7 +721,7 @@ func (s *SelectionRangeOptions) UnmarshalJSON(data []byte) error { return fmt.Errorf("expected boolean or SelectionRangeOptions") } -// boolean | LinkedEditingRangeOptions | LinkedEditingRangeRegistrationOptions +// LinkedEditingRangeOptions boolean | LinkedEditingRangeOptions | LinkedEditingRangeRegistrationOptions type LinkedEditingRangeOptions struct { *WorkDoneProgressOptions *TextDocumentRegistrationOptions @@ -746,7 +746,7 @@ func (s *LinkedEditingRangeOptions) UnmarshalJSON(data []byte) error { return fmt.Errorf("expected boolean or LinkedEditingRangeOptions") } -// boolean | CallHierarchyOptions | CallHierarchyRegistrationOptions +// CallHierarchyOptions boolean | CallHierarchyOptions | CallHierarchyRegistrationOptions type CallHierarchyOptions struct { *WorkDoneProgressOptions *TextDocumentRegistrationOptions @@ -817,7 +817,7 @@ type SemanticTokensLegend struct { TokenModifiers []string `json:"tokenModifiers"` } -// boolean | MonikerOptions | MonikerRegistrationOptions is defined as follows: +// MonikerOptions boolean | MonikerOptions | MonikerRegistrationOptions is defined as follows: type MonikerOptions struct { *WorkDoneProgressOptions *TextDocumentRegistrationOptions @@ -849,7 +849,7 @@ type WorkspaceSymbolRegistrationOptions struct { *WorkspaceSymbolOptions } -// boolean | WorkspaceSymbolOptions where WorkspaceSymbolOptions is defined as follows: +// UnmarshalJSON boolean | WorkspaceSymbolOptions where WorkspaceSymbolOptions is defined as follows: func (s *WorkspaceSymbolOptions) UnmarshalJSON(data []byte) error { save := false if err := json.Unmarshal(data, &save); err == nil { @@ -882,7 +882,7 @@ type WorkspaceFoldersServerCapabilities struct { ChangeNotifications json.RawMessage `json:"changeNotifications,omitempty"` } -// The options to register for file operations. +// FileOperationRegistrationOptions The options to register for file operations. // // @since 3.16.0 type FileOperationRegistrationOptions struct { @@ -890,7 +890,7 @@ type FileOperationRegistrationOptions struct { Filters []FileOperationFilter `json:"filters"` } -// A filter to describe in which file operation requests or notifications +// FileOperationFilter A filter to describe in which file operation requests or notifications // the server is interested in. // // @since 3.16.0 @@ -902,7 +902,7 @@ type FileOperationFilter struct { Pattern FileOperationPattern `json:"pattern"` } -// A pattern to describe in which file operation requests or notifications +// FileOperationPattern A pattern to describe in which file operation requests or notifications // the server is interested in. // // @since 3.16.0 @@ -929,19 +929,19 @@ type FileOperationPattern struct { Options *FileOperationPatternOptions `json:"options,omitempty"` } -// A pattern kind describing if a glob pattern matches a file a folder or +// FileOperationPatternKind A pattern kind describing if a glob pattern matches a file a folder or // both. // // @since 3.16.0 type FileOperationPatternKind string -// The pattern matches a file only. +// FileOperationPatternKindFile The pattern matches a file only. const FileOperationPatternKindFile FileOperationPatternKind = "file" -// The pattern matches a folder only. +// FileOperationPatternKindFolder The pattern matches a folder only. const FileOperationPatternKindFolder FileOperationPatternKind = "folder" -// Matching options for the file operation pattern. +// FileOperationPatternOptions Matching options for the file operation pattern. // // @since 3.16.0 type FileOperationPatternOptions struct { diff --git a/lsp_capabilities_server_test.go b/lsp_capabilities_server_test.go index 7c7f019..d9fb9b7 100644 --- a/lsp_capabilities_server_test.go +++ b/lsp_capabilities_server_test.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/lsp_diagnostics.go b/lsp_diagnostics.go index f5181b3..d0873fe 100644 --- a/lsp_diagnostics.go +++ b/lsp_diagnostics.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // @@ -96,7 +96,7 @@ func (ds DiagnosticSeverity) String() string { } } -// The diagnostic tags. +// DiagnosticTag The diagnostic tags. // // @since 3.15.0 type DiagnosticTag int @@ -112,7 +112,7 @@ const DiagnosticTagUnnecessary DiagnosticTag = 1 // Clients are allowed to rendered diagnostics with this tag strike through. const DiagnosticTagDeprecated DiagnosticTag = 2 -// Represents a related message and source code location for a diagnostic. +// DiagnosticRelatedInformation Represents a related message and source code location for a diagnostic. // This should be used to point to code locations that cause or are related to // a diagnostics, e.g when duplicating a symbol in a scope. type DiagnosticRelatedInformation struct { diff --git a/lsp_general.go b/lsp_general.go index 7660af9..8db54f8 100644 --- a/lsp_general.go +++ b/lsp_general.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // @@ -105,7 +105,7 @@ type InitializeResultServerInfo struct { Version string `json:"version,omitempty"` } -// If the protocol version provided by the client can't be handled by the +// InitializeErrorUnknownProtocolVersion If the protocol version provided by the client can't be handled by the // server. // // @deprecated This initialize error got replaced by client capabilities. @@ -148,7 +148,7 @@ type ConfigurationParams struct { type ConfigurationItem struct { // The scope to get the configuration section for. - ScopeUri DocumentURI `json:"scopeUri,omitempty"` + ScopeURI DocumentURI `json:"scopeUri,omitempty"` // The configuration section asked for. Section string `json:"section,omitempty"` diff --git a/lsp_general_test.go b/lsp_general_test.go index 627f6cb..cfbc358 100644 --- a/lsp_general_test.go +++ b/lsp_general_test.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/lsp_language.go b/lsp_language.go index b56b9bf..b5f5d0b 100644 --- a/lsp_language.go +++ b/lsp_language.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // @@ -33,7 +33,7 @@ func (t TextDocumentPositionParams) String() string { return t.TextDocument.String() + ":" + t.Position.String() } -// Contains additional information about the context in which a completion +// CompletionContext Contains additional information about the context in which a completion // request is triggered. type CompletionContext struct { // How the completion was triggered. @@ -45,22 +45,22 @@ type CompletionContext struct { TriggerCharacter string `json:"triggerCharacter,omitempty"` } -// How a completion was triggered +// CompletionTriggerKind How a completion was triggered type CompletionTriggerKind int -// Completion was triggered by typing an identifier (24x7 code +// CompletionTriggerKindInvoked Completion was triggered by typing an identifier (24x7 code // complete), manual invocation (e.g Ctrl+Space) or via API. const CompletionTriggerKindInvoked CompletionTriggerKind = 1 -// Completion was triggered by a trigger character specified by +// CompletionTriggerKindTriggerCharacter Completion was triggered by a trigger character specified by // the `triggerCharacters` properties of the // `CompletionRegistrationOptions`. const CompletionTriggerKindTriggerCharacter CompletionTriggerKind = 2 -// Completion was re-triggered as the current completion list is incomplete. +// CompletionTriggerKindTriggerForIncompleteCompletions Completion was re-triggered as the current completion list is incomplete. const CompletionTriggerKindTriggerForIncompleteCompletions CompletionTriggerKind = 3 -// Params for the CodeActionRequest +// CodeActionParams Params for the CodeActionRequest type CodeActionParams struct { *WorkDoneProgressParams *PartialResultParams @@ -75,7 +75,7 @@ type CodeActionParams struct { Context CodeActionContext `json:"context,required"` } -// Contains additional diagnostic information about the context in which +// CodeActionContext Contains additional diagnostic information about the context in which // a code action is run. type CodeActionContext struct { // An array of diagnostics known on the client side overlapping the range @@ -93,7 +93,7 @@ type CodeActionContext struct { Only []CodeActionKind `json:"only,omitempty"` } -// Structure to capture a description for an error code. +// CodeDescription Structure to capture a description for an error code. // // @since 3.16.0 type CodeDescription struct { @@ -181,7 +181,7 @@ type SignatureHelpParams struct { Context *SignatureHelpContext `json:"context,omitempty"` } -// Additional information about the context in which a signature help request +// SignatureHelpContext Additional information about the context in which a signature help request // was triggered. // // @since 3.15.0 @@ -209,22 +209,22 @@ type SignatureHelpContext struct { ActiveSignatureHelp *SignatureHelp `json:"activeSignatureHelp,omitempty"` } -// How a signature help was triggered. +// SignatureHelpTriggerKind How a signature help was triggered. // // @since 3.15.0 type SignatureHelpTriggerKind int -// Signature help was invoked manually by the user or by a command. +// SignatureHelpTriggerKindInvoked Signature help was invoked manually by the user or by a command. const SignatureHelpTriggerKindInvoked SignatureHelpTriggerKind = 1 -// Signature help was triggered by a trigger character. +// SignatureHelpTriggerKindTriggerCharacter Signature help was triggered by a trigger character. const SignatureHelpTriggerKindTriggerCharacter SignatureHelpTriggerKind = 2 -// Signature help was triggered by the cursor moving or by the document +// SignatureHelpTriggerKindContentChange Signature help was triggered by the cursor moving or by the document // content changing. const SignatureHelpTriggerKindContentChange SignatureHelpTriggerKind = 3 -// Signature help represents the signature of something +// SignatureHelp Signature help represents the signature of something // callable. There can be multiple signature but only one // active and only one active parameter. type SignatureHelp struct { @@ -253,7 +253,7 @@ type SignatureHelp struct { ActiveParameter *int `json:"activeParameter,omitempty"` } -// Represents the signature of something callable. A signature +// 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. type SignatureInformation struct { @@ -276,7 +276,7 @@ type SignatureInformation struct { ActiveParameter *int `json:"activeParameter,omitempty"` } -// Represents a parameter of a callable-signature. A parameter can +// ParameterInformation Represents a parameter of a callable-signature. A parameter can // have a label and a doc-comment. type ParameterInformation struct { // The label of this parameter information. @@ -348,7 +348,7 @@ type DocumentOnTypeFormattingParams struct { Options FormattingOptions `json:"options,required"` } -// Represents a collection of [completion items](#CompletionItem) to be +// CompletionList Represents a collection of [completion items](#CompletionItem) to be // presented in the editor. type CompletionList struct { // This list is not complete. Further typing should result in recomputing @@ -492,7 +492,7 @@ type CompletionItem struct { Data json.RawMessage `json:"data,omitempty"` } -// Additional details for a completion item label. +// CompletionItemLabelDetails Additional details for a completion item label. // // @since 3.17.0 - proposed state type CompletionItemLabelDetails struct { @@ -507,14 +507,14 @@ type CompletionItemLabelDetails struct { Description string `json:"description,omitempty"` } -// Defines whether the insert text in a completion item should be interpreted as +// InsertTextFormat Defines whether the insert text in a completion item should be interpreted as // plain text or a snippet. type InsertTextFormat int -// The primary text to be inserted is treated as a plain string. +// InsertTextFormatPlainText The primary text to be inserted is treated as a plain string. const InsertTextFormatPlainText InsertTextFormat = 1 -// The primary text to be inserted is treated as a snippet. +// InsertTextFormatSnippet The primary text to be inserted is treated as a snippet. // // A snippet can define tab stops and placeholders with `$1`, `$2` // and `${3:foo}`. `$0` defines the final tab stop, it defaults to @@ -532,7 +532,7 @@ type TextEdit struct { NewText string `json:"newText,required"` } -// A special text edit to provide an insert and a replace operation. +// InsertReplaceEdit A special text edit to provide an insert and a replace operation. // // @since 3.16.0 type InsertReplaceEdit struct { @@ -558,7 +558,7 @@ type Command struct { Arguments []json.RawMessage `json:"arguments,omitempty"` } -// A code action represents a change that can be performed in code, e.g. to fix +// CodeAction A code action represents a change that can be performed in code, e.g. to fix // a problem or to refactor code. // // A CodeAction must set either `edit` and/or a `command`. If both are supplied, @@ -666,7 +666,7 @@ type WorkspaceEdit struct { ChangeAnnotations map[string]ChangeAnnotation `json:"changeAnnotations,omitempty"` } -// Additional information that describes document changes. +// ChangeAnnotation Additional information that describes document changes. // // @since 3.16.0 type ChangeAnnotation struct { @@ -683,7 +683,7 @@ type ChangeAnnotation struct { Description string `json:"description,omitempty"` } -// The result of a hover request. +// Hover The result of a hover request. type Hover struct { // The hover's content Contents MarkupContent `json:"contents,required"` @@ -712,7 +712,7 @@ type MarkedString struct { Value string `json:"value,required"` } -// type MarkedString = string | { language: string; value: string }; +// UnmarshalJSON type MarkedString = string | { language: string; value: string }; func (ms *MarkedString) UnmarshalJSON(data []byte) error { var s string if err := json.Unmarshal(data, &s); err == nil { @@ -737,7 +737,7 @@ func (ms MarkedString) MarshalJSON() ([]byte, error) { return json.Marshal(__(ms)) } -// A `MarkupContent` literal represents a string value which content is +// MarkupContent A `MarkupContent` literal represents a string value which content is // interpreted base on its kind flag. Currently the protocol supports // `plaintext` and `markdown` as markup kinds. // @@ -747,16 +747,18 @@ func (ms MarkedString) MarshalJSON() ([]byte, error) { // Here is an example how such a string can be constructed using // JavaScript / TypeScript: // ```typescript -// let markdown: MarkdownContent = { -// kind: MarkupKind.Markdown, -// value: [ -// '# Header', -// 'Some text', -// '```typescript', -// 'someCode();', -// '```' -// ].join('\n') -// }; +// +// let markdown: MarkdownContent = { +// kind: MarkupKind.Markdown, +// value: [ +// '# Header', +// 'Some text', +// '```typescript', +// 'someCode();', +// '```' +// ].join('\n') +// }; +// // ``` // // Please Note* that clients might sanitize the return markdown. A client could @@ -769,7 +771,7 @@ type MarkupContent struct { Value string `json:"value,required"` } -// Represents programming constructs like variables, classes, interfaces etc. +// DocumentSymbol Represents programming constructs like variables, classes, interfaces etc. // that appear in a document. Document symbols can be hierarchical and they // have two ranges: one that encloses its definition and one that points to its // most interesting range, e.g. the range of an identifier. @@ -810,7 +812,7 @@ type DocumentSymbol struct { Children []DocumentSymbol `json:"children,omitempty"` } -// Represents information about programming constructs like variables, classes, +// SymbolInformation Represents information about programming constructs like variables, classes, // interfaces etc. type SymbolInformation struct { // The name of this symbol. @@ -847,7 +849,7 @@ type SymbolInformation struct { ContainerName string `json:"containerName,omitempty"` } -// The parameters of a Workspace Symbol Request. +// WorkspaceSymbolParams The parameters of a Workspace Symbol Request. type WorkspaceSymbolParams struct { *WorkDoneProgressParams *PartialResultParams @@ -857,7 +859,7 @@ type WorkspaceSymbolParams struct { Query string `json:"query,required"` } -// The parameters sent in notifications/requests for user-initiated creation +// CreateFilesParams The parameters sent in notifications/requests for user-initiated creation // of files. // // @since 3.16.0 @@ -866,7 +868,7 @@ type CreateFilesParams struct { Files []FileCreate `json:"files,required"` } -// Represents information on a file/folder create. +// FileCreate Represents information on a file/folder create. // // @since 3.16.0 type FileCreate struct { @@ -874,7 +876,7 @@ type FileCreate struct { URI string `json:"uri,required"` } -// The parameters sent in notifications/requests for user-initiated renames +// RenameFilesParams The parameters sent in notifications/requests for user-initiated renames // of files. // // @since 3.16.0 @@ -884,18 +886,18 @@ type RenameFilesParams struct { Files []FileRename `json:"files,required"` } -// Represents information on a file/folder rename. +// FileRename Represents information on a file/folder rename. // // @since 3.16.0 type FileRename struct { // A file:// URI for the original location of the file/folder being renamed. - OldUri string `json:"oldUri,required"` + OldURI string `json:"oldUri,required"` // A file:// URI for the new location of the file/folder being renamed. - NewUri string `json:"newUri,required"` + NewURI string `json:"newUri,required"` } -// The parameters sent in notifications/requests for user-initiated deletes +// DeleteFilesParams The parameters sent in notifications/requests for user-initiated deletes // of files. // // @since 3.16.0 @@ -904,12 +906,12 @@ type DeleteFilesParams struct { Files []FileDelete `json:"files,required"` } -// Represents information on a file/folder delete. +// FileDelete Represents information on a file/folder delete. // // @since 3.16.0 type FileDelete struct { // A file:// URI for the location of the file/folder being deleted. - Uri string `json:"uri,required"` + URI string `json:"uri,required"` } type CodeLensParams struct { @@ -920,7 +922,7 @@ type CodeLensParams struct { TextDocument TextDocumentIdentifier `json:"textDocument,required"` } -// A code lens represents a command that should be shown along with +// CodeLens A code lens represents a command that should be shown along with // source text, like the number of references, a way to run tests, etc. // // A code lens is _unresolved_ when no command is associated to it. For @@ -951,19 +953,19 @@ type FoldingRangeParams struct { RextDocument TextDocumentIdentifier `json:"textDocument,required"` } -// Enum of known range kinds +// FoldingRangeKind Enum of known range kinds type FoldingRangeKind string -// Folding range for a comment +// FoldingRangeKindComment Folding range for a comment const FoldingRangeKindComment FoldingRangeKind = "comment" -// Folding range for a imports or includes +// FoldingRangeKindImports Folding range for a imports or includes const FoldingRangeKindImports FoldingRangeKind = "imports" -// Folding range for a region (e.g. `#region`) +// FoldingRangeKindRegion Folding range for a region (e.g. `#region`) const FoldingRangeKindRegion FoldingRangeKind = "region" -// Represents a folding range. To be valid, start and end line must be bigger +// FoldingRange Represents a folding range. To be valid, start and end line must be bigger // than zero and smaller than the number of lines in the document. Clients // are free to ignore invalid ranges. type FoldingRange struct { @@ -1162,34 +1164,34 @@ type MonikerParams struct { *PartialResultParams } -// Moniker uniqueness level to define scope of the moniker. +// UniquenessLevel Moniker uniqueness level to define scope of the moniker. type UniquenessLevel string -// The moniker is only unique inside a document +// UniquenessLevelDocument The moniker is only unique inside a document const UniquenessLevelDocument UniquenessLevel = "document" -// The moniker is unique inside a project for which a dump got created +// UniquenessLevelProject The moniker is unique inside a project for which a dump got created const UniquenessLevelProject UniquenessLevel = "project" -// The moniker is unique inside the group to which a project belongs +// UniquenessLevelGroup The moniker is unique inside the group to which a project belongs const UniquenessLevelGroup UniquenessLevel = "group" -// The moniker is unique inside the moniker scheme. +// UniquenessLevelScheme The moniker is unique inside the moniker scheme. const UniquenessLevelScheme UniquenessLevel = "scheme" -// The moniker is globally unique +// UniquenessLevelGlobal The moniker is globally unique const UniquenessLevelGlobal UniquenessLevel = "global" -// The moniker kind. +// MonikerKind The moniker kind. type MonikerKind string -// The moniker represent a symbol that is imported into a project +// MonikerKindImport The moniker represent a symbol that is imported into a project const MonikerKindImport MonikerKind = "import" -// The moniker represents a symbol that is exported from a project +// MonikerKindExport The moniker represents a symbol that is exported from a project const MonikerKindExport MonikerKind = "export" -// The moniker represents a symbol that is local to a project (e.g. a local +// MonikerKindLocal 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, ...) const MonikerKindLocal MonikerKind = "local" diff --git a/lsp_msg_convert.go b/lsp_msg_convert.go index 8a1a2f0..8888171 100644 --- a/lsp_msg_convert.go +++ b/lsp_msg_convert.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // @@ -10,11 +10,8 @@ import ( "go.bug.st/json" ) -// ___ REQUEST -// \ -// /___/ -// \ -func DecodeClientRequestParams(method string, req json.RawMessage) (interface{}, error) { +// DecodeClientRequestParams parse a CLIENT-REQUEST (↩) +func DecodeClientRequestParams(method string, req json.RawMessage) (any, error) { switch method { case "initialize": var res InitializeParams @@ -148,10 +145,7 @@ func DecodeClientRequestParams(method string, req json.RawMessage) (interface{}, } } -// ___ -// \ -// /___/ RESPONSE -// \ +// DecodeServerResponseResult parse a SERVER-RESPONSE to a CLIENT-REQUEST (↩) func DecodeServerResponseResult(method string, resp json.RawMessage) (interface{}, error) { switch method { case "initialize": @@ -465,10 +459,7 @@ func DecodeServerResponseResult(method string, resp json.RawMessage) (interface{ } } -// ___ REQUEST -// / -// \___\ -// / +// DecodeServerRequestParams parse a SERVER-REQUEST (↪) func DecodeServerRequestParams(method string, req json.RawMessage) (interface{}, error) { switch method { case "window/showMessageRequest": @@ -501,10 +492,7 @@ func DecodeServerRequestParams(method string, req json.RawMessage) (interface{}, } } -// ___ -// / -// \___\ RESPONSE -// / +// DecodeClientResponseResult parse a CLIENT-RESPONSE to a SERVER-REQUEST (↪) func DecodeClientResponseResult(method string, resp json.RawMessage) (interface{}, error) { switch method { case "window/showMessageRequest": @@ -544,8 +532,7 @@ func DecodeClientResponseResult(method string, resp json.RawMessage) (interface{ } } -// ____\ NOTIFICATION -// / +// DecodeClientNotificationParams parse a CLIENT-NOTIFICATION (→) func DecodeClientNotificationParams(method string, req json.RawMessage) (interface{}, error) { switch method { case "$/progress": @@ -602,8 +589,7 @@ func DecodeClientNotificationParams(method string, req json.RawMessage) (interfa } } -// NOTIFICATION /___ -// \ +// DecodeServerNotificationParams parse a SERVER-NOTIFICATION (←) func DecodeServerNotificationParams(method string, req json.RawMessage) (interface{}, error) { switch method { case "$/progress": diff --git a/lsp_position.go b/lsp_position.go index ffaeae6..ae7855d 100644 --- a/lsp_position.go +++ b/lsp_position.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // @@ -69,7 +69,7 @@ type LocationLink struct { OriginSelectionRange *Range `json:"originSelectionRange,omitempty"` // The target resource identifier of this link. - TargetUri DocumentURI `json:"targetUri,required"` + TargetURI DocumentURI `json:"targetUri,required"` // The full target range of this link. If the target for example is a symbol // then target range is the range enclosing this symbol not including @@ -83,7 +83,7 @@ type LocationLink struct { TargetSelectionRange Range `json:"targetSelectionRange,required"` } -// A document highlight is a range inside a text document which deserves +// DocumentHighlight A document highlight is a range inside a text document which deserves // special attention. Usually a document highlight is visualized by changing // the background color of its range. type DocumentHighlight struct { @@ -94,14 +94,14 @@ type DocumentHighlight struct { Kind DocumentHighlightKind `json:"kind,omitempty"` } -// A document highlight kind. +// DocumentHighlightKind A document highlight kind. type DocumentHighlightKind int -// A textual occurrence. +// DocumentHighlightKindText A textual occurrence. const DocumentHighlightKindText DocumentHighlightKind = 1 -// Read-access of a symbol, like reading a variable. +// DocumentHighlightKindRead Read-access of a symbol, like reading a variable. const DocumentHighlightKindRead DocumentHighlightKind = 2 -// Write-access of a symbol, like writing to a variable. +// DocumentHighlightKindWrite Write-access of a symbol, like writing to a variable. const DocumentHighlightKindWrite DocumentHighlightKind = 3 diff --git a/lsp_sumtypes.go b/lsp_sumtypes.go index a76a6db..2e8ff06 100644 --- a/lsp_sumtypes.go +++ b/lsp_sumtypes.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/lsp_sumtypes_test.go b/lsp_sumtypes_test.go index 5731cc7..3f2c4a6 100644 --- a/lsp_sumtypes_test.go +++ b/lsp_sumtypes_test.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // @@ -14,8 +14,8 @@ import ( ) func TestSumTypes(t *testing.T) { - com_json := "{\"title\":\"command_title\",\"command\":\"command\"}" - ca_json := "{\"title\":\"codeaction_title\",\"kind\":\"quickfix\",\"isPreferred\":true,\"command\":{\"title\":\"command_title\",\"command\":\"command\"}}" + comJSON := "{\"title\":\"command_title\",\"command\":\"command\"}" + caJSON := "{\"title\":\"codeaction_title\",\"kind\":\"quickfix\",\"isPreferred\":true,\"command\":{\"title\":\"command_title\",\"command\":\"command\"}}" { var c CommandOrCodeAction @@ -25,7 +25,7 @@ func TestSumTypes(t *testing.T) { }) data, err := json.Marshal(c) require.NoError(t, err) - require.Equal(t, com_json, string(data)) + require.Equal(t, comJSON, string(data)) } { var c CommandOrCodeAction @@ -40,12 +40,12 @@ func TestSumTypes(t *testing.T) { }) data, err := json.Marshal(c) require.NoError(t, err) - require.Equal(t, ca_json, string(data)) + require.Equal(t, caJSON, string(data)) } { var c CommandOrCodeAction - err := json.Unmarshal([]byte(com_json), &c) + err := json.Unmarshal([]byte(comJSON), &c) require.NoError(t, err) res := c.Get() require.IsType(t, Command{}, res) @@ -53,7 +53,7 @@ func TestSumTypes(t *testing.T) { } { var c CommandOrCodeAction - err := json.Unmarshal([]byte(ca_json), &c) + err := json.Unmarshal([]byte(caJSON), &c) require.NoError(t, err) res := c.Get() require.IsType(t, CodeAction{}, res) @@ -62,7 +62,7 @@ func TestSumTypes(t *testing.T) { // Let's try an array of CommandOrCodeActions... { - jsonIn := json.RawMessage("[" + ca_json + "," + com_json + "," + ca_json + "," + ca_json + "," + com_json + "]") + jsonIn := json.RawMessage("[" + caJSON + "," + comJSON + "," + caJSON + "," + caJSON + "," + comJSON + "]") res, err := DecodeServerResponseResult("textDocument/codeAction", jsonIn) require.NoError(t, err) require.IsType(t, []CommandOrCodeAction{}, res) diff --git a/lsp_text_synchronization.go b/lsp_text_synchronization.go index fb15a80..a532efc 100644 --- a/lsp_text_synchronization.go +++ b/lsp_text_synchronization.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // @@ -66,7 +66,7 @@ func (v VersionedTextDocumentIdentifier) String() string { return fmt.Sprintf("%s@%d", v.TextDocumentIdentifier, v.Version) } -// An event describing a change to a text document. If range and rangeLength are +// TextDocumentContentChangeEvent 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. type TextDocumentContentChangeEvent struct { // The range of the document that changed. @@ -131,7 +131,7 @@ type RenameParams struct { NewName string `json:"newName,required"` } -// The parameters send in a will save text document notification. +// WillSaveTextDocumentParams The parameters send in a will save text document notification. type WillSaveTextDocumentParams struct { // The document that will be saved. RextDocument TextDocumentIdentifier `json:"textDocument,required"` @@ -140,15 +140,15 @@ type WillSaveTextDocumentParams struct { Reason TextDocumentSaveReason `json:"reason,required"` } -// Represents reasons why a text document is saved. +// TextDocumentSaveReason Represents reasons why a text document is saved. type TextDocumentSaveReason int -// Manually triggered, e.g. by the user pressing save, by starting +// TextDocumentSaveReasonManual Manually triggered, e.g. by the user pressing save, by starting // debugging, or by an API call. const TextDocumentSaveReasonManual TextDocumentSaveReason = 1 -// Automatic after a delay. +// TextDocumentSaveReasonAfterDelay Automatic after a delay. const TextDocumentSaveReasonAfterDelay TextDocumentSaveReason = 2 -// When the editor lost focus. +// TextDocumentSaveReasonFocusOut When the editor lost focus. const TextDocumentSaveReasonFocusOut TextDocumentSaveReason = 3 diff --git a/lsp_unimplemented.go b/lsp_unimplemented.go index 26382ec..76277f3 100644 --- a/lsp_unimplemented.go +++ b/lsp_unimplemented.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/lsp_window.go b/lsp_window.go index 7f66627..c5fa275 100644 --- a/lsp_window.go +++ b/lsp_window.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // @@ -16,16 +16,16 @@ type ShowMessageParams struct { type MessageType int -// An error message. +// MessageTypeError An error message. const MessageTypeError MessageType = 1 -// A warning message. +// MessageTypeWarning A warning message. const MessageTypeWarning MessageType = 2 -// An information message. +// MessageTypeInfo An information message. const MessageTypeInfo MessageType = 3 -// A log message. +// MessageTypeLog A log message. const MessageTypeLog MessageType = 4 type ShowMessageRequestParams struct { @@ -44,7 +44,7 @@ type MessageActionItem struct { Title string `json:"title,required"` } -// Params to show a document. +// ShowDocumentParams Params to show a document. // // @since 3.16.0 type ShowDocumentParams struct { @@ -69,7 +69,7 @@ type ShowDocumentParams struct { Selection Range `json:"selection,omitempty"` } -// The result of an show document request. +// ShowDocumentResult The result of an show document request. // // @since 3.16.0 type ShowDocumentResult struct { diff --git a/lsp_workspace.go b/lsp_workspace.go index 4f633f9..7580e85 100644 --- a/lsp_workspace.go +++ b/lsp_workspace.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // @@ -13,7 +13,7 @@ type DidChangeWatchedFilesParams struct { Changes []FileEvent `json:"changes,required"` } -// An event describing a file change. +// FileEvent An event describing a file change. type FileEvent struct { // The file's URI. URI DocumentURI `json:"uri,required"` @@ -63,7 +63,7 @@ type DidChangeWorkspaceFoldersParams struct { Event WorkspaceFoldersChangeEvent `json:"event,required"` } -// The workspace folder change event. +// WorkspaceFoldersChangeEvent The workspace folder change event. type WorkspaceFoldersChangeEvent struct { // The array of added workspace folders Added []WorkspaceFolder `json:"added,required"` diff --git a/server.go b/server.go index 75b3f95..4cb99eb 100644 --- a/server.go +++ b/server.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // @@ -96,7 +96,7 @@ type Server struct { // CustomNotification is a function type for incoming custom notifications callbacks type CustomNotification func(logger jsonrpc.FunctionLogger, req json.RawMessage) -// CustomNotification is a function type for incoming custom requests callbacks +// CustomRequest is a function type for incoming custom requests callbacks type CustomRequest func(ctx context.Context, logger jsonrpc.FunctionLogger, req json.RawMessage) (res interface{}, err *jsonrpc.ResponseError) func NewServer(in io.Reader, out io.Writer, handler ClientMessagesHandler) *Server { diff --git a/staticcheck.conf b/staticcheck.conf new file mode 100644 index 0000000..7eca56b --- /dev/null +++ b/staticcheck.conf @@ -0,0 +1 @@ +checks = ["all", "-SA5008"] diff --git a/textedits/textedits.go b/textedits/textedits.go index be5b6c1..04d04e0 100644 --- a/textedits/textedits.go +++ b/textedits/textedits.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/textedits/textutils_test.go b/textedits/textutils_test.go index 57e8ec2..24447f9 100644 --- a/textedits/textutils_test.go +++ b/textedits/textutils_test.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/uri.go b/uri.go index d88ed5e..8b419b7 100644 --- a/uri.go +++ b/uri.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/uri_test.go b/uri_test.go index 5503d96..9f09281 100644 --- a/uri_test.go +++ b/uri_test.go @@ -1,5 +1,5 @@ // -// Copyright 2021 Cristian Maglie. All rights reserved. +// Copyright 2024 Cristian Maglie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // @@ -107,7 +107,3 @@ func TestNotInoFromSourceMapper(t *testing.T) { func windowsToSlash(path string) string { return strings.ReplaceAll(path, `\`, "/") } - -func windowsFromSlash(path string) string { - return strings.ReplaceAll(path, "/", `\`) -}