protocol

package
v2.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package protocol implements the language server protocol.

See: https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md

Index

Constants

View Source
const (
	ErrCaughtPanic = fault.Const("Panic caught")
	ErrStopped     = fault.Const("stopped")
)
View Source
const (
	ParseError       = ErrorCode(-32700)
	InvalidRequest   = ErrorCode(-32600)
	MethodNotFound   = ErrorCode(-32601)
	InvalidParams    = ErrorCode(-32602)
	InternalError    = ErrorCode(-32603)
	ServerErrorStart = ErrorCode(-32099)
	ServerErrorEnd   = ErrorCode(-32000)
)
View Source
const (
	// SeverityError reports an error.
	SeverityError = DiagnosticSeverity(1)

	// SeverityWarning reports a warning.
	SeverityWarning = DiagnosticSeverity(2)

	// SeverityInformation reports an information.
	SeverityInformation = DiagnosticSeverity(3)

	// SeverityHint reports a hint.
	SeverityHint = DiagnosticSeverity(4)
)
View Source
const (
	// SyncNone means documents should not be synced at all.
	SyncNone = TextDocumentSyncKind(0)

	// SyncFull means documents are synced by always sending the full content of
	// the document.
	SyncFull = TextDocumentSyncKind(1)

	// SyncIncremental means documents are synced by sending the full content on
	// open. After that only incremental updates to the document are send.
	SyncIncremental = TextDocumentSyncKind(2)
)
View Source
const (
	// ErrorType represents an error message.
	ErrorType = MessageType(1)

	// WarningType represents a warning message.
	WarningType = MessageType(2)

	// InfoType represents an information message.
	InfoType = MessageType(3)

	// LogType represents a log message.
	LogType = MessageType(4)
)
View Source
const (
	// Created represents a file that created.
	Created = FileChangeType(1)

	// Changed represents a file that got changed.
	Changed = FileChangeType(2)

	// Deleted represents a file that got deleted.
	Deleted = FileChangeType(3)
)
View Source
const (
	Text        = CompletionItemKind(1)
	Method      = CompletionItemKind(2)
	Function    = CompletionItemKind(3)
	Constructor = CompletionItemKind(4)
	Field       = CompletionItemKind(5)
	Variable    = CompletionItemKind(6)
	Class       = CompletionItemKind(7)
	Interface   = CompletionItemKind(8)
	Module      = CompletionItemKind(9)
	Property    = CompletionItemKind(10)
	Unit        = CompletionItemKind(11)
	Value       = CompletionItemKind(12)
	Enum        = CompletionItemKind(13)
	Keyword     = CompletionItemKind(14)
	Snippet     = CompletionItemKind(15)
	Color       = CompletionItemKind(16)
	File        = CompletionItemKind(17)
	Reference   = CompletionItemKind(18)
)
View Source
const (
	// TextHighlight represents a textual occurrance.
	TextHighlight = DocumentHighlightKind(1)

	// ReadHighlight represents read-access of a symbol, like reading a
	// variable.
	ReadHighlight = DocumentHighlightKind(2)

	// WriteHighlight represents write-access of a symbol, like writing to a
	// variable.
	WriteHighlight = DocumentHighlightKind(3)
)
View Source
const (
	KindFile        = SymbolKind(1)
	KindModule      = SymbolKind(2)
	KindNamespace   = SymbolKind(3)
	KindPackage     = SymbolKind(4)
	KindClass       = SymbolKind(5)
	KindMethod      = SymbolKind(6)
	KindProperty    = SymbolKind(7)
	KindField       = SymbolKind(8)
	KindConstructor = SymbolKind(9)
	KindEnum        = SymbolKind(10)
	KindInterface   = SymbolKind(11)
	KindFunction    = SymbolKind(12)
	KindVariable    = SymbolKind(13)
	KindConstant    = SymbolKind(14)
	KindString      = SymbolKind(15)
	KindNumber      = SymbolKind(16)
	KindBoolean     = SymbolKind(17)
	KindArray       = SymbolKind(18)
)

Variables

View Source
var ErrConnectionClosed = fmt.Errorf("Connection closed")

ErrConnectionClosed is returned when attempting to send a message on a closed connection.

Functions

This section is empty.

Types

type CancelNotification

type CancelNotification struct {
	Message

	Params struct {
		// The request to cancel.
		ID interface{} `json:"id"`
	} `json:"params"`
}

CancelNotification is a special notification sent to cancel a request. A request that got canceled still needs to return from the server and send a response back. It can not be left open / hanging. This is in line with the JSON RPC protocol that requires that every request sends a reponse back. In addition it allows for returning paritial results on cancel.

type ClientCapabilities

type ClientCapabilities struct{}

ClientCapabilities are currently empty.

type CodeActionContext

type CodeActionContext struct {
	// An array of diagnostics.
	Diagnostics []Diagnostic `json:"diagnostics"`
}

CodeActionContext contains additional diagnostic information about the context in which a code action is run.

type CodeActionRequest

type CodeActionRequest struct {
	RequestMessageHeader

	Params struct {
		// The document in which the command was invoked.
		TextDocument TextDocumentIdentifier `json:"textDocument"`

		// The range for which the command was invoked.
		Range Range `json:"range"`

		// Context carrying additional information.
		Context CodeActionContext `json:"context"`
	} `json:"params"`
}

CodeActionRequest is a request sent from the client to the server to compute commands for a given text document and range. The request is triggered when the user moves the cursor into an problem marker in the editor or presses the lightbulb associated with a marker.

type CodeActionResponse

type CodeActionResponse struct {
	ResponseMessageHeader

	Result []Command `json:"result"`

	// Code and message set in case an exception happens during the request.
	Error *ResponseErrorHeader `json:"error,omitempty"`
}

CodeActionResponse is the response to a code action request.

type CodeLens

type CodeLens struct {
	// The range in which this code lens is valid. Should only span a single line.
	Range Range `json:"range"`

	// The command this code lens represents.
	Command *Command `json:"command"`

	// An data entry field that is preserved on a code lens item between
	// a code lens and a code lens resolve request.
	Data interface{} `json:"data"`
}

CodeLens 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 performance reasons the creation of a code lens and resolving should be done to two stages.

type CodeLensOptions

type CodeLensOptions struct {
	// Code lens has a resolve provider as well.
	ResolveProvider bool `json:"resolveProvider"`
}

CodeLensOptions represent code Lens options.

type CodeLensRequest

type CodeLensRequest struct {
	RequestMessageHeader

	Params struct {
		// The document to request code lens for.
		TextDocument TextDocumentIdentifier `json:"textDocument"`
	} `json:"params"`
}

CodeLensRequest is a request sent from the client to the server to compute code lenses for a given text document.

type CodeLensResolveRequest

type CodeLensResolveRequest struct {
	RequestMessageHeader

	Params CodeLens `json:"params"`
}

CodeLensResolveRequest is a request sent from the client to the server to resolve the command for a given code lens item.

type CodeLensResolveResponse

type CodeLensResolveResponse struct {
	ResponseMessageHeader

	Result *CodeLens `json:"result,omitempty"`

	// Code and message set in case an exception happens during the request.
	Error *ResponseErrorHeader `json:"error,omitempty"`
}

CodeLensResolveResponse is the response to a code lens resolve request.

type CodeLensResponse

type CodeLensResponse struct {
	ResponseMessageHeader

	Result []CodeLens `json:"result"`

	// Code and message set in case an exception happens during the request.
	Error *ResponseErrorHeader `json:"error,omitempty"`
}

CodeLensResponse is the response to a code lens request.

type Command

type Command struct {
	// Title of the command, like `save`.
	Title string `json:"title"`

	// The identifier of the actual command handler.
	Command string `json:"command"`

	// Arguments that the command handler should be
	// invoked with.
	Arguments map[string]interface{} `json:"arguments"`
}

Command represents a reference to a command. Provides a title which will be used to represent a command in the UI and, optionally, an array of arguments which will be passed to the command handler function when invoked.

type CompletionItem

type CompletionItem struct {
	// The label of this completion item. By default also the text that is
	// inserted when selecting this completion.
	Label string `json:"label"`

	// The kind of this completion item. Based of the kind an icon is chosen by
	// the editor.
	Kind *CompletionItemKind `json:"kind,omitempty"`

	// A human-readable string with additional information about this item, like
	// type or symbol information.
	Detail *string `json:"detail,omitempty"`

	// A human-readable string that represents a doc-comment.
	Documentation *string `json:"documentation,omitempty"`

	// A string that should be used when comparing this item with other items.
	// When `falsy` the label is used.
	SortText *string `json:"sortText,omitempty"`

	// A string that should be used when filtering a set of completion items.
	// When `falsy` the label is used.
	FilterText *string `json:"filterText,omitempty"`

	// A string that should be inserted a document when selecting this
	// completion. When `falsy` the label is used.
	InsertText *string `json:"insertText,omitempty"`

	// An edit which is applied to a document when selecting
	// this completion. When an edit is provided the value of
	// insertText is ignored.
	TextEdit *TextEdit `json:"textEdit,omitempty"`

	// An data entry field that is preserved on a completion item between
	// a completion and a completion resolve request.
	Data interface{} `json:"data,omitempty"`
}

CompletionItem represents an item to be presented in the editor.

type CompletionItemKind

type CompletionItemKind int

CompletionItemKind is the kind of a completion entry.

type CompletionItemResolveRequest

type CompletionItemResolveRequest struct {
	RequestMessageHeader

	Params CompletionItem `json:"params"`
}

CompletionItemResolveRequest is a request sent from the client to the server to resolve additional information for a given completion item.

type CompletionItemResolveResponse

type CompletionItemResolveResponse struct {
	ResponseMessageHeader

	Result *CompletionItem `json:"result,omitempty"`

	// Code and message set in case an exception happens during the request.
	Error *ResponseErrorHeader `json:"error,omitempty"`
}

CompletionItemResolveResponse is the response to a completion item resolve request.

type CompletionList

type CompletionList struct {
	// This list it not complete. Further typing should result in recomputing
	// this list.
	IsIncomplete bool `json:"isIncomplete"`

	// The completion items.
	Items []CompletionItem `json:"items"`
}

CompletionList represents a collection of CompletionItems to be presented in the editor.

type CompletionOptions

type CompletionOptions struct {
	// The server provides support to resolve additional information for a completion item.
	ResolveProvider bool `json:"resolveProvider"`

	// The characters that trigger completion automatically.
	TriggerCharacters []string `json:"triggerCharacters"`
}

CompletionOptions represent text completion options.

type CompletionRequest

type CompletionRequest struct {
	RequestMessageHeader

	Params TextDocumentPositionParams `json:"params"`
}

CompletionRequest is a request sent from the client to the server to compute completion items at a given cursor position. Completion items are presented in the IntelliSense user interface. If computing complete completion items is expensive, servers can additional provide a handler for the resolve completion item request. This request is send when a completion item is selected in the user interface.

type CompletionResponse

type CompletionResponse struct {
	ResponseMessageHeader

	Result interface{} `json:"result,omitempty"` // CompletionItem[] | CompletionList

	// Code and message set in case an exception happens during the request.
	Error *ResponseErrorHeader `json:"error,omitempty"`
}

CompletionResponse is the response to a completion request.

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

Connection sends and receives messages from the client. Construct a connection with Connect(), and then call Serve() to begin a communication stream.

func NewConnection

func NewConnection(stream io.ReadWriter) *Connection

NewConnection returns a new connection, ready to serve.

func (*Connection) LogMessage

func (c *Connection) LogMessage(ty MessageType, message string) error

LogMessage asks the client to log a particular message.

func (*Connection) PublishDiagnostics

func (c *Connection) PublishDiagnostics(uri string, diagnostics []Diagnostic) error

PublishDiagnostics sends the list of diagnostics for the document with the specified URI to the client.

func (*Connection) Serve

func (c *Connection) Serve(ctx context.Context, server Server) error

Serve listens on the connection for all incomming requests and notifications and dispatches messages to server.

func (*Connection) ShowMessage

func (c *Connection) ShowMessage(ty MessageType, message string) error

ShowMessage asks the client to display a particular message in the user interface.

type Diagnostic

type Diagnostic struct {
	// The range at which the message applies
	Range Range `json:"range"`

	// The diagnostic's severity. Can be omitted. If omitted it is up to the
	// client to interpret diagnostics as error, warning, info or hint.
	Severity DiagnosticSeverity `json:"severity"`

	// The diagnostic's code. Can be omitted.
	Code interface{} `json:"code"` // number | string;

	// A human-readable string describing the source of this
	// diagnostic, e.g. 'typescript' or 'super lint'.
	Source string `json:"source"`

	// The diagnostic's message.
	Message string `json:"message"`
}

Diagnostic represents a diagnostic, such as a compiler error or warning. Diagnostic objects are only valid in the scope of a resource.

type DiagnosticSeverity

type DiagnosticSeverity int

DiagnosticSeverity is an enumerator of severity values.

type DidChangeConfigurationNotification

type DidChangeConfigurationNotification struct {
	NotificationMessageHeader

	Params struct {
		// The actual changed settings
		Settings map[string]interface{} `json:"settings"`
	} `json:"params"`
}

DidChangeConfigurationNotification is a notification sent from the client to the server to signal the change of configuration settings.

type DidChangeTextDocumentNotification

type DidChangeTextDocumentNotification struct {
	NotificationMessageHeader

	Params struct {
		// The document that did change. The version number points
		// to the version after all provided content changes have
		// been applied.
		TextDocument VersionedTextDocumentIdentifier `json:"textDocument"`

		// The actual content changes.
		ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"`
	} `json:"params"`
}

DidChangeTextDocumentNotification is a notification sent from the client to the server to signal changes to a text document. In 2.0 the shape of the params has changed to include proper version numbers and language ids.

type DidChangeWatchedFilesNotification

type DidChangeWatchedFilesNotification struct {
	NotificationMessageHeader

	Params struct {
		// The actual file events.
		Changes []FileEvent `json:"changes"`
	} `json:"params"`
}

DidChangeWatchedFilesNotification is a notification sent from the client to the server when the client detects changes to file watched by the lanaguage client.

type DidCloseTextDocumentNotification

type DidCloseTextDocumentNotification struct {
	NotificationMessageHeader

	Params struct {
		// The document that was closed.
		TextDocument TextDocumentIdentifier `json:"textDocument"`
	} `json:"params"`
}

DidCloseTextDocumentNotification is a notification sent from the client to the server when the document got closed in the client. The document's truth now exists where the document's URI points to (e.g. if the document's URI is a file URI the truth now exists on disk).

type DidOpenTextDocumentNotification

type DidOpenTextDocumentNotification struct {
	NotificationMessageHeader

	Params struct {
		// The document that was opened.
		TextDocument TextDocumentItem `json:"textDocument"`
	} `json:"params"`
}

DidOpenTextDocumentNotification is a notification sent from the client to the server to signal newly opened text documents. The document's truth is now managed by the client and the server must not try to read the document's truth using the document's URI.

type DidSaveTextDocumentNotification

type DidSaveTextDocumentNotification struct {
	NotificationMessageHeader

	Params struct {
		// The document that was saved.
		TextDocument TextDocumentIdentifier `json:"textDocument"`
	} `json:"params"`
}

DidSaveTextDocumentNotification is a notification sent from the client to the server when the document for saved in the clinet.

type DocumentFormattingRequest

type DocumentFormattingRequest struct {
	RequestMessageHeader

	Params struct {
		// The document to format.
		TextDocument TextDocumentIdentifier `json:"textDocument"`

		// The format options
		Options FormattingOptions `json:"options"`
	} `json:"params"`
}

DocumentFormattingRequest is a request sent from the client to the server to format a whole document.

type DocumentFormattingResponse

type DocumentFormattingResponse struct {
	ResponseMessageHeader

	Result []TextEdit `json:"result"`

	// Code and message set in case an exception happens during the request.
	Error *ResponseErrorHeader `json:"error,omitempty"`
}

DocumentFormattingResponse is the response to a document formatting request.

type DocumentHighlight

type DocumentHighlight struct {
	// The range this highlight applies to.
	Range Range `json:"range"`

	// The highlight kind, default is DocumentHighlightKind.Text.
	Kind *DocumentHighlightKind `json:"kind"`
}

DocumentHighlight 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 DocumentHighlightKind

type DocumentHighlightKind int

DocumentHighlightKind is a document highlight kind enumerator.

type DocumentHighlightRequest

type DocumentHighlightRequest struct {
	RequestMessageHeader

	Params TextDocumentPositionParams `json:"params"`
}

DocumentHighlightRequest is a request sent from the client to the server to to resolve document highlights for a given text document position.

type DocumentHighlightResponse

type DocumentHighlightResponse struct {
	ResponseMessageHeader

	// The list of document highlights.
	Result []DocumentHighlight `json:"result"`

	// Code and message set in case an exception happens during the request.
	Error *ResponseErrorHeader `json:"error,omitempty"`
}

DocumentHighlightResponse is the response to a document highlight request.

type DocumentOnTypeFormattingOptions

type DocumentOnTypeFormattingOptions struct {
	// A character on which formatting should be triggered, like `}`.
	FirstTriggerCharacter string `json:"firstTriggerCharacter"`

	// More trigger characters.
	MoreTriggerCharacter []string `json:"moreTriggerCharacter"`
}

DocumentOnTypeFormattingOptions represents formatting on type options

type DocumentOnTypeFormattingRequest

type DocumentOnTypeFormattingRequest struct {
	RequestMessageHeader

	Params struct {
		// The document to format.
		TextDocument TextDocumentIdentifier `json:"textDocument"`

		// The position at which this request was send.
		Position Position `json:"position"`

		// The character that has been typed.
		Character string `json:"ch"`

		// The format options
		Options FormattingOptions `json:"options"`
	} `json:"params"`
}

DocumentOnTypeFormattingRequest is a request sent from the client to the server to format parts of the document during typing.

type DocumentOnTypeFormattingResponse

type DocumentOnTypeFormattingResponse struct {
	ResponseMessageHeader

	Result []TextEdit `json:"result"`

	// Code and message set in case an exception happens during the request.
	Error *ResponseErrorHeader `json:"error,omitempty"`
}

DocumentOnTypeFormattingResponse is the response to a document on-type formatting request.

type DocumentRangeFormattingRequest

type DocumentRangeFormattingRequest struct {
	RequestMessageHeader

	Params struct {
		// The document to format.
		TextDocument TextDocumentIdentifier `json:"textDocument"`

		// The range to format
		Range Range `json:"range"`

		// The format options
		Options FormattingOptions `json:"options"`
	} `json:"params"`
}

DocumentRangeFormattingRequest is a request sent from the client to the server to format a given range in a document.

type DocumentRangeFormattingResponse

type DocumentRangeFormattingResponse struct {
	ResponseMessageHeader

	Result []TextEdit `json:"result"`

	// Code and message set in case an exception happens during the request.
	Error *ResponseErrorHeader `json:"error,omitempty"`
}

DocumentRangeFormattingResponse is the response to a document formatting range request.

type DocumentSymbolRequest

type DocumentSymbolRequest struct {
	RequestMessageHeader

	Params struct {
		// The text document.
		TextDocument TextDocumentIdentifier `json:"textDocument"`
	} `json:"params"`
}

DocumentSymbolRequest is a request sent from the client to the server to list all symbols found in a given text document.

type DocumentSymbolResponse

type DocumentSymbolResponse struct {
	ResponseMessageHeader

	Result []SymbolInformation `json:"result"`

	// Code and message set in case an exception happens during the request.
	Error *ResponseErrorHeader `json:"error,omitempty"`
}

DocumentSymbolResponse is the response to a document symbol request.

type ErrUnknownMethod

type ErrUnknownMethod struct {
	Method string
}

ErrUnknownMethod is an error returned when decoding an unknown method type.

func (ErrUnknownMethod) Error

func (e ErrUnknownMethod) Error() string

type Error

type Error struct {
	Code    ErrorCode
	Message string
}

Error is an error that can be returned by any of the Server methods. It can contain additional metadata that should be sent to the client.

func (Error) Error

func (e Error) Error() string

type ErrorCode

type ErrorCode int

ErrorCode represents the list of errors returned in a ResponseError.

type ExitNotification

type ExitNotification struct {
	NotificationMessageHeader
}

ExitNotification is a notification sent from the server to the client to ask the server to exit its process.

type FileChangeType

type FileChangeType int

FileChangeType is an enumerator of file events.

type FileEvent

type FileEvent struct {
	// The file's uri.
	URI string `json:"uri"`

	// The change type.
	Type FileChangeType `json:"type"`
}

FileEvent describes a file change event.

type FindReferencesRequest

type FindReferencesRequest struct {
	RequestMessageHeader

	Params struct {
		TextDocumentPositionParams

		Context struct {
			// Include the declaration of the current symbol.
			IncludeDeclaration bool `json:"includeDeclaration"`
		} `json:"context"`
	} `json:"params"`
}

FindReferencesRequest is a request sent from the client to the server to resolve project-wide references for the symbol denoted by the given text document position.

type FindReferencesResponse

type FindReferencesResponse struct {
	ResponseMessageHeader

	// TODO: Is this correct?
	Result interface{} `json:"result,omitempty"` //  Location | Location[]

	// Code and message set in case an exception happens during the request.
	Error *ResponseErrorHeader `json:"error,omitempty"`
}

FindReferencesResponse is the response to a find references request.

type FormattingOptions

type FormattingOptions struct {
	// Size of a tab in spaces.
	TabSize int `json:"tabSize"`

	// Prefer spaces over tabs.
	InsertSpaces bool `json:"insertSpaces"`
}

FormattingOptions describes what options formatting should use.

type GotoDefinitionRequest

type GotoDefinitionRequest struct {
	RequestMessageHeader

	Params TextDocumentPositionParams `json:"params"`
}

GotoDefinitionRequest is a request sent from the client to the server to resolve the defintion location of a symbol at a given text document position.

type GotoDefinitionResponse

type GotoDefinitionResponse struct {
	ResponseMessageHeader

	Result interface{} `json:"result,omitempty"` //  Location | Location[]

	// Code and message set in case an exception happens during the request.
	Error *ResponseErrorHeader `json:"error,omitempty"`
}

GotoDefinitionResponse is the response to a goto defintion request.

type HoverRequest

type HoverRequest struct {
	RequestMessageHeader

	Params TextDocumentPositionParams `json:"params"`
}

HoverRequest is a request sent from the client to the server to request hover information at a given text document position.

type HoverResponse

type HoverResponse struct {
	ResponseMessageHeader

	Result struct {
		// The hover's content
		Contents interface{} `json:"contents"` // MarkedString | []MarkedString

		// An optional range
		Range *Range `json:"range"`
	} `json:"result"`

	// Code and message set in case an exception happens during the request.
	Error *ResponseErrorHeader `json:"error,omitempty"`
}

HoverResponse is the response to a hover request.

type InitializeRequest

type InitializeRequest struct {
	RequestMessageHeader

	Params struct {
		// The process Id of the parent process that started the server.
		ProcessID int `json:"processId"`

		// The rootPath of the workspace. Is null if no folder is open.
		RootPath string `json:"rootPath"`

		// The capabilities provided by the client (editor)
		Capabilities ClientCapabilities `json:"capabilities"`
	} `json:"params"`
}

InitializeRequest represents an 'initialize' request. The initialize request is send from the client to the server.

type InitializeResponse

type InitializeResponse struct {
	ResponseMessageHeader

	// The result of the request.
	Result *struct {
		// The capabilities the language server provides.
		Capabilities ServerCapabilities `json:"capabilities"`
	} `json:"result,omitempty"`

	Error *struct {
		ResponseErrorHeader

		Data struct {
			// Indicates whether the client should retry to send the
			// initilize request after showing the message provided
			// in the ResponseError.
			Retry bool `json:"retry"`
		} `json:"data"`
	} `json:"error,omitempty"`
}

InitializeResponse is the result of an 'initialize' request.

type Location

type Location struct {
	URI   string `json:"uri"`
	Range Range  `json:"range"`
}

Location represents a location inside a resource, such as a line inside a text file.

type LogMessageNotification

type LogMessageNotification struct {
	NotificationMessageHeader

	Params struct {
		// The message type.
		Type MessageType `json:"type"`

		// The actual message.
		Message string `json:"message"`
	} `json:"params"`
}

LogMessageNotification is a notification sent from the server to the client to ask the client to log a particular message.

type MarkedString

type MarkedString struct {
	// The language of the string.
	Language string `json:"language"`

	// The string value.
	Value string `json:"value"`
}

MarkedString is a string of a specified language

type Message

type Message struct {
	// The language server protocol always uses "2.0" as the jsonrpc version.
	JSONRPC string `json:"jsonrpc"`
}

Message is a general message as defined by JSON-RPC.

type MessageActionItem

type MessageActionItem struct {
	// A short title like 'Retry', 'Open Log' etc.
	Title string `json:"title"`
}

MessageActionItem represents a single action that can be performed in a ShowMessageRequest.

type MessageType

type MessageType int

MessageType is an enumerator of message types that can be shown to the user.

type NotificationMessageHeader

type NotificationMessageHeader struct {
	Message

	// The method to be invoked.
	Method string `json:"method"`
}

NotificationMessageHeader is the common part to all notifications. A processed notification message must not send a response back. They work like events.

type ParameterInformation

type ParameterInformation struct {
	// The label of this signature. Will be shown in the UI.
	Label string `json:"label"`

	// he human-readable doc-comment of this signature.
	// Will be shown in the UI but can be omitted.
	Documentation *string `json:"documentation,omitempty"`
}

ParameterInformation represents a parameter of a callable-signature. A parameter can have a label and a doc-comment.

type Position

type Position struct {
	// Line position in a document (zero-based).
	Line int `json:"line"`

	// Column offset on a line in a document (zero-based).
	Column int `json:"character"`
}

Position is a position in a text document expressed as zero-based line and character offset.

type PublishDiagnosticsNotification

type PublishDiagnosticsNotification struct {
	NotificationMessageHeader

	Params struct {
		// The URI for which diagnostic information is reported.
		URI string `json:"uri"`

		// An array of diagnostic information items.
		Diagnostics []Diagnostic `json:"diagnostics"`
	} `json:"params"`
}

PublishDiagnosticsNotification is a notification sent from the server to the client to signal results of validation runs.

type Range

type Range struct {
	// The position of the first character in the range.
	Start Position `json:"start"`

	// One past the last character in the range.
	End Position `json:"end"`
}

Range is a range in a text document expressed as start and end positions.

type RenameRequest

type RenameRequest struct {
	RequestMessageHeader

	Params struct {
		// The document holding the symbol of reference.
		TextDocument TextDocumentIdentifier `json:"textDocument"`

		// The position at which this request was send.
		Position Position `json:"position"`

		// The new name of the symbol. If the given name is not valid the
		// request must return a ResponseError with an appropriate message set.
		NewName string `json:"newName"`
	} `json:"params"`
}

RenameRequest is a request sent from the client to the server to do a workspace wide rename of a symbol.

type RenameResponse

type RenameResponse struct {
	ResponseMessageHeader

	Result *WorkspaceEdit `json:"result"`

	// Code and message set in case an exception happens during the request.
	Error *ResponseErrorHeader `json:"error,omitempty"`
}

RenameResponse is the response to a rename request.

type Request

type Request interface {
	// RequestID returns the identifier of the request.
	RequestID() interface{}
}

Request is the interface implemented by all request types.

type RequestMessageHeader

type RequestMessageHeader struct {
	Message

	// The request id.
	ID interface{} `json:"id"` // number | string

	// The method to be invoked.
	Method string `json:"method"`
}

RequestMessageHeader is the common part of all request messages.

func (RequestMessageHeader) RequestID

func (h RequestMessageHeader) RequestID() interface{}

RequestID returns the identifier of the request.

type ResponseErrorHeader

type ResponseErrorHeader struct {
	// A number indicating the error type that occured.
	Code ErrorCode `json:"code"`

	// A string providing a short decription of the error.
	Message string `json:"message"`
}

ResponseErrorHeader is the common part of all errors that can be returned as part of a response.

type ResponseMessageHeader

type ResponseMessageHeader struct {
	Message

	// The request identifier that this is a response to.
	ID interface{} `json:"id"` // number | string
}

ResponseMessageHeader is the common part of all response messages.

type Server

type Server interface {
	// Initialize is a request to initialize the server.
	// processID is the parent process that started the server.
	// rootPath is the root path of the workspace - it is null if no folder is open.
	// capabilities are the capabilities of the client.
	Initialize(ctx context.Context, processID int, rootPath string) (ServerCapabilities, error)

	// Shutdown is a request to shutdown the server, but not exit.
	Shutdown(ctx context.Context) error

	// Completion is a request for completion items as the given cursor
	// position. If computing complete completion items is expensive,
	// servers can additional provide a handler for the resolve completion item
	// request. This request is send when a completion item is selected in the
	// user interface.
	// uri is the document identifier.
	// pos is the position in the document to complete.
	Completion(ctx context.Context, uri TextDocumentIdentifier, pos Position) (CompletionList, error)

	// CompletionItemResolve is a request to resolve additional information on
	// the completion item.
	// item is the completion item to resolve additional information.
	CompletionItemResolve(ctx context.Context, item CompletionItem) (CompletionItem, error)

	// Hover is a request for hover information as the given position.
	// uri is the document identifier.
	// pos is the position in the document to get hover information for.
	Hover(ctx context.Context, uri TextDocumentIdentifier, position Position) ([]MarkedString, *Range, error)

	// SignatureHelp is a request for function signature information at the given position.
	// uri is the document identifier.
	// pos is the position in the document to get signature information for.
	SignatureHelp(ctx context.Context, uri TextDocumentIdentifier, position Position) (sigs []SignatureInformation, activeSig *int, activeParam *int, err error)

	// GotoDefinition is a request to resolve the definition location(s) of the
	// symbol at the given position.
	// uri is the document identifier.
	// pos is the position in the document of the symbol.
	GotoDefinition(ctx context.Context, uri TextDocumentIdentifier, position Position) ([]Location, error)

	// FindReferences is a request to resolve project-wide reference
	// location(s) for the symbol at the given position.
	// uri is the document identifier.
	// pos is the position in the document of the symbol.
	FindReferences(ctx context.Context, uri TextDocumentIdentifier, position Position, includeDecl bool) ([]Location, error)

	// DocumentHighlights is a request to resolve document highlights at the
	// given position.
	// uri is the document identifier.
	// pos is the position in the document to get highlight information.
	DocumentHighlights(ctx context.Context, uri TextDocumentIdentifier, position Position) ([]DocumentHighlight, error)

	// DocumentSymbols is a request to list all the symbols for the given
	// document.
	// uri is the document identifier to get symbols for.
	DocumentSymbols(ctx context.Context, doc TextDocumentIdentifier) ([]SymbolInformation, error)

	// WorkspaceSymbols is a request to list all the project-wide symbols that
	// match the query string.
	WorkspaceSymbols(ctx context.Context, query string) ([]SymbolInformation, error)

	// CodeAction is a request to compute commands for the given text document
	// and range. The request is triggered when the user moves the cursor into
	// an problem marker in the editor or presses the lightbulb associated with
	// a marker.
	// doc is the document to compute commands for.
	// rng is the range in the document.
	// context holds additional information about the request.
	CodeAction(ctx context.Context, doc TextDocumentIdentifier, rng Range, context CodeActionContext) ([]Command, error)

	// CodeLens is a request to compute code-lenses for a given text document.
	// doc is the document to compute code-lenses for.
	CodeLens(ctx context.Context, doc TextDocumentIdentifier) ([]CodeLens, error)

	// CodeLensResolve is a request to resolve the command for a given code
	// lens item.
	CodeLensResolve(ctx context.Context, codelens CodeLens) (CodeLens, error)

	// DocumentFormatting is a request to format the entire document.
	// doc is the document to format.
	// opts are the formatting options.
	DocumentFormatting(ctx context.Context, doc TextDocumentIdentifier, opts FormattingOptions) ([]TextEdit, error)

	// DocumentRangeFormatting is a request to format the given range in a
	// document.
	// doc is the document to format.
	// rng is the range to format.
	// opts are the formatting options.
	DocumentRangeFormatting(ctx context.Context, doc TextDocumentIdentifier, rng Range, opts FormattingOptions) ([]TextEdit, error)

	// DocumentOnTypeFormatting is a request to format parts of the document
	// during typing.
	// doc is the document to format.
	// pos is the position at which the character was typed.
	// char is the character that was typed.
	// ops are the formatting options.
	DocumentOnTypeFormatting(ctx context.Context, doc TextDocumentIdentifier, pos Position, char string, opts FormattingOptions) ([]TextEdit, error)

	// Rename is a request to perform a workspace-wide rename of a symbol.
	// doc is the document holding the symbol of reference.
	// pos is the position of the symbol.
	// newName is the new name of the symbol.
	Rename(ctx context.Context, doc TextDocumentIdentifier, pos Position, newName string) (WorkspaceEdit, error)

	// OnExit is a request for the server to exit its process.
	OnExit(ctx context.Context) error

	// OnChangeConfiguration is a notification that the configuration settings
	// have changed.
	OnChangeConfiguration(ctx context.Context, settings map[string]interface{})

	// OnOpenTextDocument is a notification that signals when a document is
	// opened. The document's truth is now managed by the client and the
	// server must not try to read the document's truth using the document's
	// URI.
	OnOpenTextDocument(ctx context.Context, item TextDocumentItem)

	// OnChangeTextDocument is a notification that signals changes to a text
	// document.
	OnChangeTextDocument(ctx context.Context, item VersionedTextDocumentIdentifier, changes []TextDocumentContentChangeEvent)

	// OnCloseTextDocument is a notification that signals when a document is
	// closed.
	OnCloseTextDocument(ctx context.Context, item TextDocumentIdentifier)

	// OnSaveTextDocument is a notification that signals when a document is
	// saved.
	OnSaveTextDocument(ctx context.Context, item TextDocumentIdentifier)

	// OnChangeWatchedFiles is a notification that signals changes to files
	// watched by the lanaguage client.
	OnChangeWatchedFiles(ctx context.Context, changes []FileEvent)
}

Server is the interface implemented by language servers.

type ServerCapabilities

type ServerCapabilities struct {
	// Defines how text documents are synced.
	TextDocumentSync TextDocumentSyncKind `json:"textDocumentSync"`

	// The server provides hover support.
	HoverProvider bool `json:"hoverProvider"`

	// The server provides completion support.
	CompletionProvider CompletionOptions `json:"completionProvider"`

	// The server provides signature help support.
	SignatureHelpProvider SignatureHelpOptions `json:"signatureHelpProvider"`

	// The server provides goto definition support.
	DefinitionProvider bool `json:"definitionProvider"`

	// The server provides find references support.
	ReferencesProvider bool `json:"referencesProvider"`

	// The server provides document highlight support.
	DocumentHighlightProvider bool `json:"documentHighlightProvider"`

	// The server provides document symbol support.
	DocumentSymbolProvider bool `json:"documentSymbolProvider"`

	// The server provides workspace symbol support.
	WorkspaceSymbolProvider bool `json:"workspaceSymbolProvider"`

	// The server provides code actions.
	CodeActionProvider bool `json:"codeActionProvider"`

	// The server provides code lens.
	CodeLensProvider *CodeLensOptions `json:"codeLensProvider"`

	// The server provides document formatting.
	DocumentFormattingProvider bool `json:"documentFormattingProvider"`

	// The server provides document range formatting.
	DocumentRangeFormattingProvider bool `json:"documentRangeFormattingProvider"`

	// The server provides document formatting on typing.
	DocumentOnTypeFormattingProvider *DocumentOnTypeFormattingOptions `json:"documentOnTypeFormattingProvider"`

	// The server provides rename support.
	RenameProvider bool `json:"renameProvider"`
}

ServerCapabilities represents the capabilities of the language server.

type ShowMessageNotification

type ShowMessageNotification struct {
	NotificationMessageHeader

	Params struct {
		// The message type.
		Type MessageType `json:"type"`

		// The actual message
		Message string `json:"message"`
	} `json:"params"`
}

ShowMessageNotification is a notification sent from the server to the client to ask the client to display a particular message in the user interface.

type ShowMessageRequest

type ShowMessageRequest struct {
	RequestMessageHeader

	Params struct {
		// The message type.
		Type MessageType `json:"type"`

		// The actual message
		Message string `json:"message"`

		// The message action items to present.
		Actions []MessageActionItem `json:"actions"`
	} `json:"params"`
}

ShowMessageRequest is a request sent from the server to client to ask the client to display a particular message in the user interface. In addition to the show message notification the request allows to pass actions and to wait for an answer from the client.

type ShowMessageResponse

type ShowMessageResponse struct {
	ResponseMessageHeader

	// Always nil, but needs to be present.
	Result *struct{} `json:"result"`

	// Code and message set in case an exception happens during the request.
	Error *ResponseErrorHeader `json:"error,omitempty"`
}

ShowMessageResponse is the response to a show message request.

type ShutdownRequest

type ShutdownRequest struct {
	RequestMessageHeader
}

ShutdownRequest represents the 'shutdown' request. The 'shutdown' request is sent from the client to the server. It asks the server to shutdown, but to not exit (otherwise the response might not be delivered correctly to the client). There is a separate exit notification that asks the server to exit.

type ShutdownResponse

type ShutdownResponse struct {
	ResponseMessageHeader

	// Always nil, but needs to be present.
	Result *struct{} `json:"result"`

	// Code and message set in case an exception happens during the request.
	Error *ResponseErrorHeader `json:"error,omitempty"`
}

ShutdownResponse is the response to a shutdown request.

type SignatureHelpOptions

type SignatureHelpOptions struct {
	// The characters that trigger signature help automatically.
	TriggerCharacters []string `json:"triggerCharacters"`
}

SignatureHelpOptions represents signature help options.

type SignatureHelpRequest

type SignatureHelpRequest struct {
	RequestMessageHeader

	Params TextDocumentPositionParams `json:"params"`
}

SignatureHelpRequest is the request is sent from the client to the server to request signature information at a given cursor position.

type SignatureHelpResponse

type SignatureHelpResponse struct {
	ResponseMessageHeader

	// Represents the signature of something callable. There can be multiple
	// signatures but only one active and only one active parameter.
	Result *struct {
		// One or more signatures.
		Signatures []SignatureInformation `json:"signatures"`

		// The active signature.
		ActiveSignature *int `json:"activeSignature,omitempty"`

		// The active parameter of the active signature.
		ActiveParameter *int `json:"activeParameter,omitempty"`
	} `json:"result,omitempty"`

	// Code and message set in case an exception happens during the request.
	Error *ResponseErrorHeader `json:"error,omitempty"`
}

SignatureHelpResponse is the response to a signature help request.

type SignatureInformation

type SignatureInformation struct {
	// The label of this signature. Will be shown in the UI.
	Label string `json:"label"`

	// The human-readable doc-comment of this signature. Will be shown
	// in the UI but can be omitted.
	Documentation *string `json:"documentation,omitempty"`

	// The parameters of this signature.
	Parameters []ParameterInformation `json:"parameters"`
}

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 SymbolInformation

type SymbolInformation struct {
	// The name of this symbol.
	Name string `json:"name"`

	// The kind of this symbol.
	Kind SymbolKind `json:"kind"`

	// The location of this symbol.
	Location Location `json:"location"`

	// The name of the symbol containing this symbol.
	ContainerName *string `json:"containerName"`
}

SymbolInformation represents information about programming constructs like variables, classes, interfaces etc.

type SymbolKind

type SymbolKind int

SymbolKind is an enumerator of symbol kinds.

type TextDocumentContentChangeEvent

type TextDocumentContentChangeEvent struct {
	// The range of the document that changed.
	Range *Range `json:"range"`

	// The length of the range that got replaced.
	RangeLength *int `json:"rangeLength"`

	// The new text of the document.
	Text string `json:"text"`
}

TextDocumentContentChangeEvent is 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 TextDocumentIdentifier

type TextDocumentIdentifier struct {
	// The text document's identifier.
	URI string `json:"uri"`
}

TextDocumentIdentifier identifies a document using an URI.

type TextDocumentItem

type TextDocumentItem struct {
	// The text document's identifier.
	URI string `json:"uri"`

	// The text document's language identifier
	LanguageID string `json:"languageId"`

	// The version number of this document (it will strictly increase after each
	// change, including undo/redo).
	Version int `json:"version"`

	// The content of the opened  text document.
	Text string `json:"text"`
}

TextDocumentItem is an item to transfer a text document from the client to the server.

type TextDocumentPositionParams

type TextDocumentPositionParams struct {
	// The text document's URI.
	Document TextDocumentIdentifier `json:"textDocument"`

	// The position inside the text document.
	Position Position `json:"position"`
}

TextDocumentPositionParams is a parameter literal used in requests to pass a text document and a position inside that document.

type TextDocumentSyncKind

type TextDocumentSyncKind int

TextDocumentSyncKind Defines how the host (editor) should sync document changes to the language server.

type TextEdit

type TextEdit struct {
	// The range of the text document to be manipulated. To insert
	// text into a document create a range where start === end.
	Range Range `json:"range"`

	// The string to be inserted. For delete operations use an
	// empty string.
	NewText string `json:"newText"`
}

TextEdit is a textual edit applicable to a text document.

type VersionedTextDocumentIdentifier

type VersionedTextDocumentIdentifier struct {
	// The text document's URI.
	URI string `json:"uri"`

	// The version number of this document.
	Version int `json:"version"`
}

VersionedTextDocumentIdentifier is an identifier to denote a specific version of a text document.

type WorkspaceEdit

type WorkspaceEdit struct {
	// Holds changes to existing resources.
	Changes interface{} `json:"changes"` // { [uri: string]: TextEdit[]; };
}

WorkspaceEdit represents changes to many resources managed in the workspace.

type WorkspaceSymbolRequest

type WorkspaceSymbolRequest struct {
	RequestMessageHeader

	Params struct {
		// A non-empty query string
		Query string `json:"query"`
	} `json:"params"`
}

WorkspaceSymbolRequest is a request sent from the client to the server to list project-wide symbols matching the query string.

type WorkspaceSymbolResponse

type WorkspaceSymbolResponse struct {
	ResponseMessageHeader

	Result []SymbolInformation `json:"result"`

	// Code and message set in case an exception happens during the request.
	Error *ResponseErrorHeader `json:"error,omitempty"`
}

WorkspaceSymbolResponse is the response to a workspace symbol request.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL