Table of Contents

Class LspServer

Namespace
NMF.AnyText
Assembly
NMF.AnyText.Lsp.dll

Denotes the implementation of an LSP server

public class LspServer : ILspServer
Inheritance
LspServer
Implements
Inherited Members

Constructors

LspServer(JsonRpc, params Grammar[])

Creates a new instance

public LspServer(JsonRpc rpc, params Grammar[] grammars)

Parameters

rpc JsonRpc

the RPC handler

grammars Grammar[]

A collection of grammars

LspServer(JsonRpc, IEnumerable<Grammar>)

Creates a new instance

public LspServer(JsonRpc rpc, IEnumerable<Grammar> grammars)

Parameters

rpc JsonRpc

the RPC handler

grammars IEnumerable<Grammar>

A collection of grammars

Methods

CodeAction(JToken)

Handles the textDocument/codeAction request from the client.

public CodeAction[] CodeAction(JToken arg)

Parameters

arg JToken

The JSON token containing the parameters of the request. (CodeActionParams)

Returns

CodeAction[]

CodeLens(JToken)

Handles the textDocument/codeLens request from the client.

public CodeLens[] CodeLens(JToken arg)

Parameters

arg JToken

The JSON token containing the parameters of the request. (CodeLensParams)

Returns

CodeLens[]

A Array of CodeLens(JToken) objects containing the available CodeLenses of the document.

CodeLensResolve(JToken)

Handles the codeLense/resolve request from the client.

public CodeLens CodeLensResolve(JToken arg)

Parameters

arg JToken

The JSON token containing the parameters of the request. (CodeLens)

Returns

CodeLens

A CodeLens(JToken) object containing the executed CodeLens

DidChange(JToken)

Gets called when the client signals a change

public void DidChange(JToken arg)

Parameters

arg JToken

the parameters of the request

DidClose(JToken)

Gets called when the client closed a document

public void DidClose(JToken arg)

Parameters

arg JToken

the parameters of the request

DidOpen(JToken)

Gets called when the client opened a document

public void DidOpen(JToken arg)

Parameters

arg JToken

the parameters of the request

DidSave(TextDocumentIdentifier, string)

Gets called when the client saved a document

public void DidSave(TextDocumentIdentifier textDocument, string text)

Parameters

textDocument TextDocumentIdentifier

the document to save

text string

the actual text

ExecuteCommand(JToken)

Handles the workspace/ececuteCommand request from the client. This is used to execute an action on the Server.

public void ExecuteCommand(JToken arg)

Parameters

arg JToken

The JSON token containing the parameters of the request. (ExceuteCommandParams)

Exit()

Gets called when the client exits

public void Exit()

Formatting(TextDocumentIdentifier, FormattingOptions)

Handles the textDocument/formatting request from the client.

public TextEdit[] Formatting(TextDocumentIdentifier textDocument, FormattingOptions options)

Parameters

textDocument TextDocumentIdentifier

The identifier of the text document to be formatted.

options FormattingOptions

The formatting options provided by the client, such as indentation and spacing settings.

Returns

TextEdit[]

An array of TextEdit objects representing the formatting changes.

FormattingRange(TextDocumentIdentifier, Range, FormattingOptions)

Handles the textDocument/rangeFormatting request from the client.

public TextEdit[] FormattingRange(TextDocumentIdentifier textDocument, Range range, FormattingOptions options)

Parameters

textDocument TextDocumentIdentifier

The identifier of the text document to be formatted.

range Range

The range within the document that should be formatted.

options FormattingOptions

The formatting options provided by the client, such as indentation and spacing settings.

Returns

TextEdit[]

An array of TextEdit objects representing the formatting changes within the specified range.

HandleCompletion(JToken)

Suggests completions

public CompletionList HandleCompletion(JToken arg)

Parameters

arg JToken

Returns

CompletionList

A completion list

Hover(JToken)

Handles the textDocument/hover request from the client.

public Hover Hover(JToken arg)

Parameters

arg JToken

The JSON token containing the parameters of the request. (TextDocumentHover)

Returns

Hover

Initialize(int?, _InitializeParams_ClientInfo, string, string, Uri, ClientCapabilities, TraceValue, WorkspaceFolder[], object)

Initializes the server

public InitializeResult Initialize(int? processId, _InitializeParams_ClientInfo clientInfo, string locale, string rootPath, Uri rootUri, ClientCapabilities capabilities, TraceValue trace, WorkspaceFolder[] workspaceFolders, object InitializationOptions = null)

Parameters

processId int?
clientInfo _InitializeParams_ClientInfo
locale string

the language

rootPath string
rootUri Uri
capabilities ClientCapabilities

capabilities of the client

trace TraceValue
workspaceFolders WorkspaceFolder[]

workspace folders

InitializationOptions object

options for the initialization

Returns

InitializeResult

Initialized()

Initializes the server

public void Initialized()

ProvideInlayHints(JToken)

Provides Inlay hints for the document

public InlayHint[] ProvideInlayHints(JToken arg)

Parameters

arg JToken

The parameters of the request

Returns

InlayHint[]

A list of inlay hints

QueryDefinition(JToken)

Handles the textDocument/definition request from the client. This is used to retrieve the location of the definition of a symbol in a document.

public LocationLink QueryDefinition(JToken arg)

Parameters

arg JToken

The JSON token containing the parameters of the request. (TextDocumentPositionParams)

Returns

LocationLink

A LspTypes.LocationLink object containing the document and position of the definition of a symbol.

QueryDocumentHighlights(JToken)

Handles the textDocument/documentHighlight request from the client. This is used to retrieve the locations and kinds of all highlights for a literal at a given position in the document.

public DocumentHighlight[] QueryDocumentHighlights(JToken arg)

Parameters

arg JToken

The JSON token containing the parameters of the request. (DocumentHighlightParams)

Returns

DocumentHighlight[]

An array of LspTypes.DocumentHighlight objects containing the range and kind of all matching highlights in the document.

QueryDocumentSymbols(JToken)

Denotes an interface for an LSP server

public DocumentSymbol[] QueryDocumentSymbols(JToken arg)

Parameters

arg JToken

Returns

DocumentSymbol[]

QueryFoldingRanges(JToken)

Handles the textDocument/foldingRange/full request from the client. This is used to retrieve all folding ranges for a document.

public FoldingRange[] QueryFoldingRanges(JToken arg)

Parameters

arg JToken

The JSON token containing the parameters of the request. (FoldingRangeParams)

Returns

FoldingRange[]

An array of FoldingRange objects, each containing details on a folding range in the document.

QueryReferences(JToken)

Handles the textDocument/references request from the client. This is used to retrieve the locations of all references to a symbol in a document.

public Location[] QueryReferences(JToken arg)

Parameters

arg JToken

The JSON token containing the parameters of the request. (ReferenceParams)

Returns

Location[]

An array of LspTypes.Location objects containing the documents and locations of the references to a symbol.

QueryRenameWorkspaceEdit(JToken)

Handles the textDocument/rename request from the client. This is used to determine the locations of a symbol in a workspace to perform a workspace-wide rename.

public WorkspaceEdit QueryRenameWorkspaceEdit(JToken arg)

Parameters

arg JToken

The JSON token containing the parameters of the request. (RenameParams)

Returns

WorkspaceEdit

A LspTypes.WorkspaceEdit object containing the changes to be performed by the client.

QuerySelectionRanges(JToken)

Handles the textDocument/selectionRange request from the client. This is used to retrieve selection ranges at an array of given positions in a document.

public SelectionRange[] QuerySelectionRanges(JToken arg)

Parameters

arg JToken

The JSON token containing the parameters of the request. (SelectionRangeParams)

Returns

SelectionRange[]

An array of SelectionRange objects, each containing details on a selection range in the document corresponding to the received positions.

QuerySemanticTokens(JToken)

Handles the textDocument/semanticTokens/full request from the client. This is used to retrieve all semantic tokens for a document.

public SemanticTokens QuerySemanticTokens(JToken arg)

Parameters

arg JToken

The JSON token containing the parameters of the request. (SemanticTokensParams)

Returns

SemanticTokens

A LspTypes.SemanticTokens object containing the full set of semantic tokens for the document.

QuerySemanticTokensDelta(JToken)

Handles the textDocument/semanticTokens/full/delta request from the client. This is used to retrieve only the changes (delta) in semantic tokens for a document.

public SemanticTokensDelta QuerySemanticTokensDelta(JToken arg)

Parameters

arg JToken

The JSON token containing the parameters of the request. (SemanticTokensDeltaParams)

Returns

SemanticTokensDelta

A LspTypes.SemanticTokensDelta object containing only the delta of semantic tokens for the document.

QuerySemanticTokensRange(JToken)

Handles the textDocument/semanticTokens/full/delta request from the client. This is used to retrieve only the changes (delta) in semantic tokens for a document.

public SemanticTokens QuerySemanticTokensRange(JToken arg)

Parameters

arg JToken

The JSON token containing the parameters of the request. (SemanticTokensDeltaParams)

Returns

SemanticTokens

A LspTypes.SemanticTokensDelta object containing only the delta of semantic tokens for the document.

SendLogMessageAsync(MessageType, string)

Sends a log message to the client.

protected Task SendLogMessageAsync(MessageType type, string message)

Parameters

type MessageType

The type of the message (Info, Warning, Error).

message string

The message content.

Returns

Task

SetTrace(JToken)

Handles the $/setTrace request from the client. This is used to set the trace setting of the server.

public void SetTrace(JToken arg)

Parameters

arg JToken

The JSON token containing the parameters of the request. (SetTraceParams)

ShowDocument(string, Range, bool, bool)

Sends the window/showDocument request to the client.

protected Task ShowDocument(string uri, Range selection = null, bool external = false, bool takeFocus = false)

Parameters

uri string

The URI of the document to show.

selection Range

The optional selection range in the document.

external bool

If true, requests to open the document externally.

takeFocus bool

If true, requests the client to take focus.

Returns

Task

ShowMessageNotify(string, MessageType)

Sends a message notification window/showMessage to the client without expecting a response.

protected Task ShowMessageNotify(string message, MessageType messageType)

Parameters

message string

The message to display.

messageType MessageType

The type of message (Info, Warning, Error, Log).

Returns

Task

ShowMessageRequestAsync(string, MessageType, IEnumerable<string>)

Sends a message request window/showMessageRequest to the client and awaits a response.

protected Task<MessageActionItem> ShowMessageRequestAsync(string message, MessageType messageType, IEnumerable<string> titles)

Parameters

message string

The message to display.

messageType MessageType

The type of message (Info, Warning, Error, Log).

titles IEnumerable<string>

A collection of action button titles the user can choose from.

Returns

Task<MessageActionItem>

The selected LspTypes.MessageActionItem if the client supports the request; otherwise, null.

ShowReferencesNotifyAsync(ParsePosition)

Sends a custom/showReferences notification to the client without expecting a response

protected Task ShowReferencesNotifyAsync(ParsePosition position)

Parameters

position ParsePosition

The position of the symbol in the document to show references for

Returns

Task

Shutdown()

Shuts down the server

public void Shutdown()