Documentation
¶
Overview ¶
Package lsptools serves the language server's workspace over MCP: the documents under the root, their diagnostics, navigation, editing and rendering, as tools an agent calls instead of an editor.
Index ¶
- func Register(s *mcp.Server, h *Host)
- type ApplyModelEditInput
- type CloseDocumentInput
- type CodeAction
- type CodeActionsResult
- type CompletionItem
- type CompletionResult
- type Diagnostic
- type DiagnosticsInput
- type DiagnosticsResult
- type DocumentState
- type DocumentSymbolsResult
- type FileEdits
- type FormatInput
- type FormatResult
- type Host
- type HoverResult
- type InlayHint
- type InlayHintsResult
- type Location
- type LocationsResult
- type ModelEditResult
- type NoInput
- type OpenDocumentInput
- type PathInput
- type PositionInput
- type Range
- type RangeInput
- type ReferencesInput
- type RenameInput
- type RenderDocumentInput
- type RenderViewInput
- type Signature
- type SignatureHelpResult
- type Symbol
- type TextEdit
- type UpdateDocumentInput
- type WorkspaceEditResult
- type WorkspaceInfo
- type WorkspaceInfoInput
- type WorkspaceSymbol
- type WorkspaceSymbolsInput
- type WorkspaceSymbolsResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApplyModelEditInput ¶
type ApplyModelEditInput struct {
Path string `json:"path" jsonschema:"the document the operations address, absolute or relative to the workspace root"`
Operations []lsp.ModelEditOperation `json:"operations"`
Apply bool `` /* 192-byte string literal not displayed */
}
ApplyModelEditInput carries model-level operations against a document.
type CloseDocumentInput ¶
type CloseDocumentInput struct {
Path string `json:"path" jsonschema:"an open document, absolute or relative to the workspace root"`
}
CloseDocumentInput names the open document to release.
type CodeAction ¶
type CodeAction struct {
Title string `json:"title"`
Kind string `json:"kind,omitempty"`
IsPreferred bool `json:"isPreferred,omitempty"`
Diagnostics []string `json:"diagnostics,omitempty" jsonschema:"messages of the diagnostics the action addresses"`
Changes []FileEdits `json:"changes" jsonschema:"the edits the action makes, per document"`
}
CodeAction is a quick fix or refactoring with its edits.
type CodeActionsResult ¶
type CodeActionsResult struct {
Actions []CodeAction `json:"actions"`
}
CodeActionsResult lists actions.
type CompletionItem ¶
type CompletionItem struct {
Label string `json:"label"`
Kind string `json:"kind,omitempty"`
Detail string `json:"detail,omitempty"`
Documentation string `json:"documentation,omitempty"`
InsertText string `json:"insertText,omitempty" jsonschema:"the text to insert when it differs from the label"`
}
CompletionItem is one completion proposal.
type CompletionResult ¶
type CompletionResult struct {
Items []CompletionItem `json:"items"`
IsIncomplete bool `json:"isIncomplete,omitempty"`
}
CompletionResult lists proposals.
type Diagnostic ¶
type Diagnostic struct {
Path string `json:"path"`
Range Range `json:"range"`
Severity string `json:"severity" jsonschema:"error, warning, info or hint"`
Code string `json:"code,omitempty" jsonschema:"the stable identifier of the check"`
Message string `json:"message"`
Source string `json:"source,omitempty" jsonschema:"the pass that produced the diagnostic"`
}
Diagnostic is one finding of the analysis.
type DiagnosticsInput ¶
type DiagnosticsInput struct {
Path string `` /* 133-byte string literal not displayed */
}
DiagnosticsInput names one document, or none for the whole workspace.
type DiagnosticsResult ¶
type DiagnosticsResult struct {
Diagnostics []Diagnostic `json:"diagnostics"`
Errors int `json:"errors"`
Warnings int `json:"warnings"`
Documents int `json:"documents" jsonschema:"documents analyzed"`
}
DiagnosticsResult lists diagnostics with counts.
type DocumentState ¶
type DocumentState struct {
Path string `json:"path"`
Version int `json:"version" jsonschema:"the buffer's version, incremented by each update"`
Open bool `json:"open" jsonschema:"whether the server now holds an open buffer for the document"`
Diagnostics []Diagnostic `json:"diagnostics" jsonschema:"the diagnostics of the text now held"`
}
DocumentState reports an open document's version and diagnostics after a change.
type DocumentSymbolsResult ¶
type DocumentSymbolsResult struct {
Symbols []Symbol `json:"symbols"`
}
DocumentSymbolsResult is a document's outline.
type FileEdits ¶
type FileEdits struct {
Path string `json:"path"`
Edits []TextEdit `json:"edits" jsonschema:"edits to the document's current text, non-overlapping, in document order"`
}
FileEdits is the edits a change makes to one document.
type FormatInput ¶
type FormatInput struct {
Path string `json:"path" jsonschema:"the document to format, absolute or relative to the workspace root"`
Range *Range `json:"range,omitempty" jsonschema:"format only the lines this range touches; omitted, the whole document"`
Apply bool `` /* 189-byte string literal not displayed */
}
FormatInput names the document, and optionally the lines, to format.
type FormatResult ¶
type FormatResult struct {
Path string `json:"path"`
Edits []TextEdit `json:"edits" jsonschema:"the edits that format the document; empty when it is already formatted"`
Text string `json:"text" jsonschema:"the document's text with the edits applied"`
Applied bool `json:"applied" jsonschema:"whether the text was written to disk"`
}
FormatResult is the formatting of a document.
type Host ¶
type Host struct {
Root string
Server *lsp.Server
Workspace *model.Workspace
// contains filtered or unexported fields
}
Host is the language server the tools call, initialized over the workspace root with no editor attached: the tools are its client.
type HoverResult ¶
type HoverResult struct {
Markdown string `json:"markdown" jsonschema:"the hover text, Markdown; empty when nothing is at the position"`
Range *Range `json:"range,omitempty" jsonschema:"the span the hover applies to"`
}
HoverResult is what hovering a position shows.
type InlayHint ¶
type InlayHint struct {
Position toolkit.Position `json:"position"`
Label string `json:"label"`
Kind string `json:"kind,omitempty" jsonschema:"type or parameter"`
Tooltip string `json:"tooltip,omitempty"`
}
InlayHint is text shown inline without being in the document.
type InlayHintsResult ¶
type InlayHintsResult struct {
Hints []InlayHint `json:"hints"`
}
InlayHintsResult lists hints.
type LocationsResult ¶
type LocationsResult struct {
Locations []Location `json:"locations"`
}
LocationsResult lists locations.
type ModelEditResult ¶
type ModelEditResult struct {
Changes []FileEdits `json:"changes" jsonschema:"the text edits the operations amount to, per document; empty when every operation was refused"`
Refused []lsp.ModelEditRefusal `` /* 149-byte string literal not displayed */
Version int `json:"version" jsonschema:"the version of the document the edits apply to"`
Applied bool `json:"applied" jsonschema:"whether the edits were written to disk"`
}
ModelEditResult is the outcome of apply_model_edit.
type OpenDocumentInput ¶
type OpenDocumentInput struct {
Path string `json:"path" jsonschema:"the document, absolute or relative to the workspace root; it need not exist on disk yet"`
Text string `json:"text" jsonschema:"the full text to hold as the document's content"`
}
OpenDocumentInput names a document and the text to hold open for it.
type PathInput ¶
type PathInput struct {
Path string `` /* 142-byte string literal not displayed */
}
PathInput names a document.
type PositionInput ¶
type PositionInput struct {
Path string `` /* 142-byte string literal not displayed */
Position toolkit.Position `json:"position" jsonschema:"the position (1-based line and character column)"`
}
PositionInput is a document position.
type Range ¶
type Range struct {
Start toolkit.Position `json:"start" jsonschema:"first character of the span (1-based line and column)"`
End toolkit.Position `json:"end" jsonschema:"character after the span (1-based line and column)"`
}
Range is a span of a document in 1-based lines and character columns; End is exclusive, as in the protocol.
type RangeInput ¶
type RangeInput struct {
Path string `json:"path" jsonschema:"the document, absolute or relative to the workspace root"`
Range *Range `json:"range,omitempty" jsonschema:"the lines of interest (1-based); omitted, the whole document"`
}
RangeInput names a range of a document.
type ReferencesInput ¶
type ReferencesInput struct {
PositionInput
IncludeDeclaration bool `json:"includeDeclaration,omitempty" jsonschema:"also list the declaration itself"`
}
ReferencesInput adds whether the declaration counts as a reference.
type RenameInput ¶
type RenameInput struct {
Path string `json:"path" jsonschema:"the document, absolute or relative to the workspace root"`
Position toolkit.Position `json:"position" jsonschema:"a position on the name to rename (1-based line and column)"`
NewName string `json:"newName" jsonschema:"the new name"`
Apply bool `` /* 192-byte string literal not displayed */
}
RenameInput names the symbol at a position and its new name.
type RenderDocumentInput ¶
type RenderDocumentInput struct {
Name string `json:"name" jsonschema:"the qualified name of a document definition (doc def), as documents lists"`
DiagramForm string `` /* 171-byte string literal not displayed */
Show []string `` /* 242-byte string literal not displayed */
LinkTemplate string `` /* 141-byte string literal not displayed */
}
RenderDocumentInput names a document definition to render.
type RenderViewInput ¶
type RenderViewInput struct {
Path string `json:"path" jsonschema:"the document, absolute or relative to the workspace root"`
View string `` /* 299-byte string literal not displayed */
Form string `` /* 188-byte string literal not displayed */
Palette string `` /* 218-byte string literal not displayed */
Style string `` /* 153-byte string literal not displayed */
Ports string `` /* 176-byte string literal not displayed */
Lines string `json:"lines,omitempty" jsonschema:"how dot and plantuml route edges: splines (the default), ortho or polyline"`
Compartments string `` /* 352-byte string literal not displayed */
Show []string `` /* 288-byte string literal not displayed */
Depth int `` /* 219-byte string literal not displayed */
Overlay string `` /* 168-byte string literal not displayed */
LinkTemplate string `` /* 141-byte string literal not displayed */
}
RenderViewInput asks for one rendering of a document's view.
type Signature ¶
type Signature struct {
Label string `json:"label"`
Documentation string `json:"documentation,omitempty"`
Parameters []string `json:"parameters"`
}
Signature is one callable signature.
type SignatureHelpResult ¶
type SignatureHelpResult struct {
Signatures []Signature `json:"signatures"`
ActiveSignature int `json:"activeSignature"`
ActiveParameter int `json:"activeParameter"`
}
SignatureHelpResult describes the call around a position.
type Symbol ¶
type Symbol struct {
Name string `json:"name"`
Kind string `json:"kind" jsonschema:"the LSP symbol kind name (Class, Property, Package, ...)"`
Detail string `json:"detail,omitempty"`
Range Range `json:"range" jsonschema:"the whole declaration"`
SelectionRange Range `json:"selectionRange" jsonschema:"the name"`
Children []Symbol `json:"children,omitempty"`
}
Symbol is an element a document declares, with the elements it owns.
type TextEdit ¶
type TextEdit struct {
Range Range `json:"range"`
NewText string `json:"newText" jsonschema:"the text that replaces the range; empty deletes it"`
}
TextEdit replaces the text of Range with NewText.
type UpdateDocumentInput ¶
type UpdateDocumentInput struct {
Path string `json:"path" jsonschema:"an open document, absolute or relative to the workspace root"`
Text string `json:"text" jsonschema:"the full new text of the document"`
}
UpdateDocumentInput replaces the text of an open document.
type WorkspaceEditResult ¶
type WorkspaceEditResult struct {
Changes []FileEdits `json:"changes" jsonschema:"the edits, per document"`
Applied bool `json:"applied" jsonschema:"whether the edits were written to disk"`
}
WorkspaceEditResult is a change spanning documents.
type WorkspaceInfo ¶
type WorkspaceInfo struct {
Root string `json:"root" jsonschema:"the workspace folder the server indexed"`
Documents []string `json:"documents" jsonschema:"paths of the model documents indexed, the standard library excluded"`
Open []string `json:"open,omitempty" jsonschema:"documents whose text is held open with edits not yet on disk"`
}
WorkspaceInfo describes the workspace the server holds.
type WorkspaceSymbol ¶
type WorkspaceSymbol struct {
Name string `json:"name"`
Kind string `json:"kind"`
Container string `json:"container,omitempty" jsonschema:"the name of the owning element"`
Location Location
}
WorkspaceSymbol is an element matched by name.
type WorkspaceSymbolsInput ¶
type WorkspaceSymbolsInput struct {
Query string `json:"query,omitempty" jsonschema:"case-insensitive substring of the name; empty lists every named element"`
Limit int `json:"limit,omitempty" jsonschema:"at most this many matches; default 200"`
}
WorkspaceSymbolsInput filters symbols by name.
type WorkspaceSymbolsResult ¶
type WorkspaceSymbolsResult struct {
Symbols []WorkspaceSymbol `json:"symbols"`
Total int `json:"total" jsonschema:"matches before the limit"`
}
WorkspaceSymbolsResult lists matches.