Documentation
¶
Overview ¶
Package lsp is a partial Language Server Protocol implementation. WhaleLint provides it's findings through Diagnostics.
Index ¶
- func HandleConnection(connection net.Conn, errC chan error)
- func HandleRequest(w *bufio.Writer, requestBytes []byte) error
- func Initialize(_ interface{}) (interface{}, error)
- func Initialized(_ []byte) (interface{}, error)
- func OnTextOpen(requestBytes []byte) (interface{}, error)
- func PublishDiagnostics(uriAndStageList TextDocumentURIandStageList, w *bufio.Writer)
- func Serve(port int) error
- func Shutdown(_ interface{}) (interface{}, error)
- func Yay(_ []byte) (interface{}, error)
- type CodeDescription
- type Diagnostic
- type DiagnosticRelatedInformation
- type DiagnosticSeverity
- type DiagnosticTag
- type DidChangeTextDocumentParams
- type DocumentURI
- type InitializeResult
- type InnerServerCapabilities
- type Location
- type MethodMapType
- type NotificationHandlerMap
- type Position
- type PublishDiagnosticsParams
- type RPCNotification
- type RPCRequest
- type RPCResponse
- type Range
- type SaveOptions
- type ServerCapabilities
- type ServerInfo
- type TextDocumentContentChangeEvent
- type TextDocumentIdentifier
- type TextDocumentItem
- type TextDocumentSyncKind
- type TextDocumentSyncOptions
- type TextDocumentURIandStageList
- type URI
- type VersionedTextDocumentIdentifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleConnection ¶
func Initialize ¶
func Initialize(_ interface{}) (interface{}, error)
Initialize gives a response with the server capabilities and info.
func Initialized ¶
Initialized is a handler for client's initialized notification
As it does not contain an id, no response is expected.
func OnTextOpen ¶
func PublishDiagnostics ¶
func PublishDiagnostics(uriAndStageList TextDocumentURIandStageList, w *bufio.Writer)
Types ¶
type CodeDescription ¶
type CodeDescription struct { /** * An URI to open with more information about the diagnostic error. */ Href URI `json:"href"` }
*
- Structure to capture a description for an error code. *
- @since 3.16.0 - proposed state.
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,omitempty"` /** * The diagnostic's code, which usually appear in the user interface. */ Code interface{} `json:"code,omitempty"` /** * An optional property to describe the error code. * * @since 3.16.0 - proposed state */ CodeDescription *CodeDescription `json:"codeDescription,omitempty"` /** * A human-readable string describing the source of this * diagnostic, e.g. 'typescript' or 'super lint'. It usually * appears in the user interface. */ Source string `json:"source,omitempty"` /** * The diagnostic's message. It usually appears in the user interface */ Message string `json:"message"` /** * Additional metadata about the diagnostic. * * @since 3.15.0 */ Tags []DiagnosticTag `json:"tags,omitempty"` /** * An array of related diagnostic information, e.g. when symbol-names within * a scope collide all definitions can be marked via this property. */ RelatedInformation []DiagnosticRelatedInformation `json:"relatedInformation,omitempty"` /** * A data entry field that is preserved between a `textDocument/publishDiagnostics` * notification and `textDocument/codeAction` request. * * @since 3.16.0 - proposed state */ Data interface{} `json:"data,omitempty"` }
type DiagnosticRelatedInformation ¶
type DiagnosticRelatedInformation struct { /** * The location of this related diagnostic information. */ Location Location `json:"location"` /** * The message of this related diagnostic information. */ Message string `json:"message"` }
*
- Represents a related message and source code location for a diagnostic. This should be
- used to point to code locations that cause or related to a diagnostics, e.g when duplicating
- a symbol in a scope.
type DiagnosticSeverity ¶
type DiagnosticSeverity float64
*
- The diagnostic's severity.
const ( SeverityError DiagnosticSeverity = 1 SeverityWarning DiagnosticSeverity = 2 SeverityInformation DiagnosticSeverity = 3 SeverityHint DiagnosticSeverity = 4 )
func VSCodeSeverityFromSeverity ¶
func VSCodeSeverityFromSeverity(s RuleSet.Severity) DiagnosticSeverity
VSCodeSeverityFromSeverity convert RuleSet.Severity to VS Code's Severity Go equivalent type.
type DiagnosticTag ¶
type DiagnosticTag float64
*
- The diagnostic tags. *
- @since 3.15.0.
const ( Unnecessary DiagnosticTag = 1 Deprecated DiagnosticTag = 2 )
type DidChangeTextDocumentParams ¶
type DidChangeTextDocumentParams 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. The content changes describe single state changes * to the document. So if there are two content changes c1 (at array index 0) and * c2 (at array index 1) for a document in state S then c1 moves the document from * S to S' and c2 from S' to S”. So c1 is computed on the state S and c2 is computed * on the state S'. * * To mirror the content of a document using change events use the following approach: * - start with the same initial content * - apply the 'textDocument/didChange' notifications in the order you receive them. * - apply the `TextDocumentContentChangeEvent`s in a single notification in the order * you receive them. */ ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"` }
*
- The change text document notification's parameters.
type DocumentURI ¶
type DocumentURI string
*
- A tagging type for string properties that are actually document URIs.
type InitializeResult ¶
type InitializeResult struct { Capabilities ServerCapabilities `json:"capabilities"` ServerInfo ServerInfo `json:"serverInfo,omitempty"` }
type InnerServerCapabilities ¶
type InnerServerCapabilities struct {
TextDocumentSync interface{} `json:"textDocumentSync,omitempty"`
}
*
- Defines the capabilities provided by a language
- server.
type Location ¶
type Location struct { URI DocumentURI `json:"URI"` Range Range `json:"range"` }
*
- Represents a location inside a resource, such as a line
- inside a text file.
type MethodMapType ¶
var (
MethodMap MethodMapType // nolint:gochecknoglobals
)
type NotificationHandlerMap ¶
type Position ¶
type Position struct { /** * Line position in a document (zero-based). * If a line number is greater than the number of lines in a document, it defaults back to the number of lines in * the document. * If a line number is negative, it defaults to 0. */ Line float64 `json:"line"` /** * Character offset on a line in a document (zero-based). Assuming that the line is * represented as a string, the `character` value represents the gap between the * `character` and `character + 1`. * * If the character value is greater than the line length it defaults back to the * line length. * If a line number is negative, it defaults to 0. */ Character float64 `json:"character"` }
*
- Position in a text document expressed as zero-based line and character offset.
- The offsets are based on a UTF-16 string representation. So a string of the form
- `a𐐀b` the character offset of the character `a` is 0, the character offset of `𐐀`
- is 1 and the character offset of b is 3 since `𐐀` is represented using two code
- units in UTF-16. *
- Positions are line end character agnostic. So you can not specify a position that
- denotes `\r|\n` or `\n|` where `|` represents the character offset.
type PublishDiagnosticsParams ¶
type PublishDiagnosticsParams struct { /** * The URI for which diagnostic information is reported. */ URI DocumentURI `json:"uri"` /** * Optional the version number of the document the diagnostics are published for. * * @since 3.15.0 */ Version float64 `json:"version,omitempty"` /** * An array of diagnostic information items. */ Diagnostics []Diagnostic `json:"diagnostics"` }
*
- The publish diagnostic notification's parameters.
type RPCNotification ¶
type RPCNotification struct { Method string `json:"method"` Params interface{} `json:"params"` }
type RPCRequest ¶
type RPCResponse ¶
type RPCResponse struct { ID interface{} `json:"id"` // JSONRpcV string `json:"jsonrpc"` // no need to have/set this fields, as it's constant at the moment. Result interface{} `json:"result"` Err interface{} `json:"error"` }
func (*RPCResponse) MarshalJSON ¶
func (r *RPCResponse) MarshalJSON() ([]byte, error)
type Range ¶
type Range struct { /** * The range's start position */ Start Position `json:"start"` /** * The range's end position. */ End Position `json:"end"` }
func VSCodeRangeFromLocationRange ¶
func VSCodeRangeFromLocationRange(lr RuleSet.LocationRange) Range
VSCodeRangeFromLocationRange converts RuleSet.LocationRange to VS Code's Range Go equivalent type.
type SaveOptions ¶
type SaveOptions struct { /** * The client is supposed to include the content on save. */ IncludeText bool `json:"includeText,omitempty"` }
*
- Save options.
type ServerCapabilities ¶
type ServerCapabilities = struct {
/**
* Defines how text documents are synced. Is either a detailed structure defining each notification or
* for backwards compatibility the TextDocumentSyncKind number.
*/
TextDocumentSync interface{} `json:"textDocumentSync,omitempty"`
}
type ServerInfo ¶
type TextDocumentContentChangeEvent ¶
type TextDocumentContentChangeEvent = struct { /** * The range of the document that changed. */ Range *Range `json:"range,omitempty"` /** * The optional length of the range that got replaced. * * @deprecated use range instead. */ RangeLength uint32 `json:"rangeLength,omitempty"` /** * The new text for the provided range. */ Text string `json:"text"` }
*
- An event describing a change to a text document. If range and rangeLength are omitted
- the new text is considered to be the full content of the document. *
- @deprecated Use the text document from the new vscode-languageserver-textdocument package.
type TextDocumentIdentifier ¶
type TextDocumentIdentifier struct { /** * The text document's URI. */ URI DocumentURI `json:"URI"` }
*
- A literal to identify a text document in the client.
type TextDocumentItem ¶
type TextDocumentItem struct { /** * The text document's URI. */ URI DocumentURI `json:"URI"` /** * The text document's language identifier */ LanguageID string `json:"languageId"` /** * The version number of this document (it will increase after each * change, including undo/redo). */ Version float64 `json:"version"` /** * The content of the opened text document. */ Text string `json:"text"` }
*
- An item to transfer a text document from the client to the
- server.
type TextDocumentSyncKind ¶
type TextDocumentSyncKind float64
const ( None TextDocumentSyncKind = 0 Full TextDocumentSyncKind = 1 Incremental TextDocumentSyncKind = 2 )
type TextDocumentSyncOptions ¶
type TextDocumentSyncOptions struct { /** * Open and close notifications are sent to the server. If omitted open close notification should not * be sent. */ OpenClose bool `json:"openClose,omitempty"` /** * Change notifications are sent to the server. See TextDocumentSyncKind.None, TextDocumentSyncKind.Full * and TextDocumentSyncKind.Incremental. If omitted it defaults to TextDocumentSyncKind.None. */ Change TextDocumentSyncKind `json:"change,omitempty"` /** * If present will save notifications are sent to the server. If omitted the notification should not be * sent. */ WillSave bool `json:"willSave,omitempty"` /** * If present will save wait until requests are sent to the server. If omitted the request should not be * sent. */ WillSaveWaitUntil bool `json:"willSaveWaitUntil,omitempty"` /** * If present save notifications are sent to the server. If omitted the notification should not be * sent. */ Save SaveOptions `json:"save,omitempty"` }
type TextDocumentURIandStageList ¶
type TextDocumentURIandStageList struct { StageList []instructions.Stage URI DocumentURI }
type URI ¶
type URI = string
*
- A tagging type for string properties that are actually URIs *
- @since 3.16.0 - proposed state.
type VersionedTextDocumentIdentifier ¶
type VersionedTextDocumentIdentifier struct { /** * The version number of this document. */ Version int32 `json:"version"` TextDocumentIdentifier }
*
- A text document identifier to denote a specific version of a text document.
Click to show internal directories.
Click to hide internal directories.