Documentation
¶
Overview ¶
Package lsp owns Glippy's bounded JSON-RPC editor protocol surface.
Index ¶
- func Serve(ctx context.Context, input io.Reader, output io.Writer, backend Backend) error
- type Analysis
- type Backend
- type CodeAction
- type Diagnostic
- type Document
- type Related
- type Severity
- type WithheldFix
- type WorkspaceAnalysis
- type WorkspaceBackend
- type WorkspaceFileBackend
- type WorkspaceFileChanges
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Analysis ¶
type Analysis struct {
File *source.File
Diagnostics []Diagnostic
State any
}
Analysis binds editor findings and backend state to one immutable source.
type Backend ¶
type Backend interface {
Analyze(context.Context, Document) (Analysis, error)
CodeActions(context.Context, Document, Analysis, source.Range) ([]CodeAction, error)
Format(context.Context, Document) ([]byte, error)
}
Backend reuses Glippy's formatter, analyzer, and fix transaction contracts. Implementations must stop promptly when an operation context is canceled. Serve serializes analysis to bound memory, so a backend that ignores cancellation violates this contract and can delay the latest snapshot.
type CodeAction ¶
type CodeAction struct {
Title string
Kind string
Preferred bool
DiagnosticCode string
DiagnosticRange source.Range
DiagnosticSeverity Severity
DiagnosticMessage string
DiagnosticDocumentationURI string
DiagnosticWithheldFixes []WithheldFix
NewText []byte
}
CodeAction is one validated whole-document replacement.
type Diagnostic ¶
type Diagnostic struct {
Range source.Range
Severity Severity
Code string
DocumentationURI string
Message string
Related []Related
WithheldFixes []WithheldFix
}
Diagnostic is one editor-facing finding over physical UTF-8 byte ranges.
type WithheldFix ¶
type WithheldFix struct {
Name string `json:"name"`
Reason string `json:"reason"`
Message string `json:"message"`
}
WithheldFix is one rule-declared fix that could not be offered safely for the current source.
type WorkspaceAnalysis ¶
WorkspaceAnalysis binds one backend result to the exact document snapshot that produced it.
type WorkspaceBackend ¶
type WorkspaceBackend interface {
AnalyzeWorkspace(context.Context, []Document) ([]WorkspaceAnalysis, error)
}
WorkspaceBackend analyzes one immutable snapshot of every editor-owned buffer. Backends that do not need workspace state may implement Backend alone. AnalyzeWorkspace has the same prompt-cancellation requirement as Backend.Analyze.
type WorkspaceFileBackend ¶
type WorkspaceFileBackend interface {
WorkspaceFilesChanged(context.Context, WorkspaceFileChanges) error
}
WorkspaceFileBackend invalidates persistent workspace state after editor filesystem notifications.
type WorkspaceFileChanges ¶
WorkspaceFileChanges describes one persistent-workspace invalidation. Paths are absolute, cleaned, sorted, and unique. InvalidateAll is exclusive with Paths and discards every cached workspace result.