Documentation
¶
Overview ¶
Package lsp implements the EDBML language server. It wraps the DBML front end (scanner, parser, check, vet) behind the Language Server Protocol: diagnostics, completion, hover, definition, references, rename and document symbols. One Document per open file holds the parse result, the semantic model and the symbol occurrence index.
Index ¶
- Constants
- type Document
- func (d *Document) Complete(pos protocol.Position) []protocol.CompletionItem
- func (d *Document) Definition(pos protocol.Position) *protocol.Location
- func (d *Document) DocumentSymbols() []protocol.DocumentSymbol
- func (d *Document) FromLSP(pos protocol.Position) int
- func (d *Document) Hover(pos protocol.Position) *protocol.Hover
- func (d *Document) LSPDiagnostics() []protocol.Diagnostic
- func (d *Document) RangeOf(n ast.Node) protocol.Range
- func (d *Document) References(pos protocol.Position, includeDecl bool) []protocol.Location
- func (d *Document) Rename(pos protocol.Position, newName string) (*protocol.WorkspaceEdit, error)
- func (d *Document) ToLSP(p token.Position) protocol.Position
- func (d *Document) Update(text string)
- type Index
- type Occurrence
- type Server
- type SymKind
- type SymbolID
Constants ¶
const Version = "0.1.0"
Version is stamped into the initialize response.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Document ¶
type Document struct {
URI string
Text string
File *ast.File
Info *check.Info
Diags []diag.Diagnostic
Index *Index
// contains filtered or unexported fields
}
Document is one open text document plus everything derived from it.
func NewDocument ¶
NewDocument analyzes text and returns a ready document.
func (*Document) Complete ¶
func (d *Document) Complete(pos protocol.Position) []protocol.CompletionItem
Complete computes completion items for the position.
func (*Document) Definition ¶
Definition returns the location of the declaration of the symbol at pos.
func (*Document) DocumentSymbols ¶
func (d *Document) DocumentSymbols() []protocol.DocumentSymbol
DocumentSymbols builds the outline tree.
func (*Document) LSPDiagnostics ¶
func (d *Document) LSPDiagnostics() []protocol.Diagnostic
LSPDiagnostics converts the front end's diagnostics for publishing.
func (*Document) References ¶
References returns every occurrence of the symbol at pos.
func (*Document) Rename ¶
Rename renames the symbol at pos. Only occurrences spelled like the ident under the cursor are rewritten: renaming a table by its name leaves alias usages alone, and renaming the alias leaves the table name alone.
type Index ¶
type Index struct {
Occs []Occurrence
Tables map[string]*check.TableInfo // canonical key AND alias -> table
Enums map[string]*check.EnumInfo // canonical key -> enum
Partials map[string]*check.PartialInfo
// contains filtered or unexported fields
}
Index is every symbol occurrence in a document, plus resolution maps.
func (*Index) At ¶
func (ix *Index) At(offset int) *Occurrence
At returns the occurrence whose identifier spans the byte offset.
func (*Index) OccurrencesOf ¶
func (ix *Index) OccurrencesOf(id SymbolID) []Occurrence
OccurrencesOf returns all occurrences of a symbol.
type Occurrence ¶
Occurrence is one identifier that denotes a symbol.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server owns the open documents and the protocol handler.
type SymbolID ¶
SymbolID names one symbol. Tables and enums use their canonical "schema.name" key; columns live in a container — "table:<key>" for direct definitions or "partial:<name>" for columns defined in a TablePartial, so every table sharing the partial shares the symbol (a rename edits the partial once). Enum values live in "enum:<key>".