Documentation
¶
Overview ¶
Package genlsp implements a generator that lowers the LSP meta-model (metaModel.json) into Go source for the go.lsp.dev/protocol package.
The data model in this file mirrors metaModel.schema.json (JSON Schema draft-07). The central construct is Type, a discriminated union keyed by "kind"; it is decoded by a hand-written Type.UnmarshalJSON that routes the payload to the fields relevant for that kind.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseTypeName ¶
type BaseTypeName string
BaseTypeName enumerates the names a "base" Type may carry.
const ( BaseURI BaseTypeName = "URI" BaseDocumentURI BaseTypeName = "DocumentUri" BaseInteger BaseTypeName = "integer" BaseUinteger BaseTypeName = "uinteger" BaseDecimal BaseTypeName = "decimal" BaseRegExp BaseTypeName = "RegExp" BaseString BaseTypeName = "string" BaseBoolean BaseTypeName = "boolean" BaseNull BaseTypeName = "null" )
The set of base type names defined by the meta-schema.
type Enumeration ¶
type Enumeration struct {
Name string `json:"name"`
Type EnumerationBaseType `json:"type"`
Values []*EnumerationEntry `json:"values"`
SupportsCustomValues bool `json:"supportsCustomValues"`
Documentation string `json:"documentation"`
Since string `json:"since"`
SinceTags []string `json:"sinceTags"`
Deprecated string `json:"deprecated"`
Proposed bool `json:"proposed"`
}
Enumeration defines an enumeration.
type EnumerationBaseType ¶
type EnumerationBaseType struct {
Kind TypeKind `json:"kind"`
Name BaseTypeName `json:"name"`
}
EnumerationBaseType is the element type of an Enumeration: string, integer or uinteger.
type EnumerationEntry ¶
type EnumerationEntry struct {
Name string `json:"name"`
Value jsontext.Value `json:"value"`
Documentation string `json:"documentation"`
Since string `json:"since"`
SinceTags []string `json:"sinceTags"`
Deprecated string `json:"deprecated"`
Proposed bool `json:"proposed"`
}
EnumerationEntry is a single enumeration value. Value holds the raw JSON token (a string or a number) and is interpreted using the owning Enumeration's base type.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator lowers a MetaModel into Go declarations for the lsp package.
Synthesized declarations (sealed-interface unions, scalar wrappers, inline struct literals, and-merges, named tuple/array wrappers) are accumulated in deterministic registries keyed by a structural signature so that identical shapes are emitted exactly once and regeneration is idempotent.
func NewGenerator ¶
NewGenerator indexes the model and returns a ready generator.
type MessageDirection ¶
type MessageDirection string
MessageDirection indicates in which direction a message is sent.
const ( DirectionClientToServer MessageDirection = "clientToServer" DirectionServerToClient MessageDirection = "serverToClient" DirectionBoth MessageDirection = "both" )
The set of message directions defined by the meta-schema.
type MetaData ¶
type MetaData struct {
Version string `json:"version"`
}
MetaData holds additional meta data of the model.
Note: Version is unreliable (the 3.18 model reports "3.17.0"); never key generation decisions on it.
type MetaModel ¶
type MetaModel struct {
MetaData MetaData `json:"metaData"`
Requests []*Request `json:"requests"`
Notifications []*Notification `json:"notifications"`
Structures []*Structure `json:"structures"`
Enumerations []*Enumeration `json:"enumerations"`
TypeAliases []*TypeAlias `json:"typeAliases"`
}
MetaModel is the root of metaModel.json.
type Notification ¶
type Notification struct {
Method string `json:"method"`
MessageDirection MessageDirection `json:"messageDirection"`
Params Params `json:"params"`
RegistrationOptions *Type `json:"registrationOptions"`
RegistrationMethod string `json:"registrationMethod"`
Documentation string `json:"documentation"`
Since string `json:"since"`
Deprecated string `json:"deprecated"`
Proposed bool `json:"proposed"`
TypeName string `json:"typeName"`
}
Notification represents an LSP notification.
type Params ¶
type Params []*Type
Params is the parameter type(s) of a request or notification. The schema allows either a single Type or an array of Type; both decode to this slice.
func (*Params) UnmarshalJSON ¶
UnmarshalJSON accepts either a single type object or an array of them.
type Property ¶
type Property struct {
Name string `json:"name"`
Type *Type `json:"type"`
Optional bool `json:"optional"`
Documentation string `json:"documentation"`
Since string `json:"since"`
SinceTags []string `json:"sinceTags"`
Deprecated string `json:"deprecated"`
Proposed bool `json:"proposed"`
}
Property is an object property.
type Request ¶
type Request struct {
Method string `json:"method"`
Result *Type `json:"result"`
MessageDirection MessageDirection `json:"messageDirection"`
Params Params `json:"params"`
PartialResult *Type `json:"partialResult"`
RegistrationOptions *Type `json:"registrationOptions"`
RegistrationMethod string `json:"registrationMethod"`
ErrorData *Type `json:"errorData"`
Documentation string `json:"documentation"`
Since string `json:"since"`
Deprecated string `json:"deprecated"`
Proposed bool `json:"proposed"`
TypeName string `json:"typeName"`
}
Request represents an LSP request.
type Structure ¶
type Structure struct {
Name string `json:"name"`
Properties []*Property `json:"properties"`
Extends []*Type `json:"extends"`
Mixins []*Type `json:"mixins"`
Documentation string `json:"documentation"`
Since string `json:"since"`
SinceTags []string `json:"sinceTags"`
Deprecated string `json:"deprecated"`
Proposed bool `json:"proposed"`
}
Structure defines the structure of an object literal.
type StructureLiteral ¶
type StructureLiteral struct {
Properties []*Property `json:"properties"`
Documentation string `json:"documentation"`
Since string `json:"since"`
SinceTags []string `json:"sinceTags"`
Deprecated string `json:"deprecated"`
Proposed bool `json:"proposed"`
}
StructureLiteral is an unnamed object literal (a "literal" Type's value).
type Type ¶
type Type struct {
Kind TypeKind
Name string // base, reference
Element *Type // array
Key *Type // map
Value *Type // map
Items []*Type // and, or, tuple
Literal *StructureLiteral // literal
StringValue string // stringLiteral
IntegerValue int64 // integerLiteral
BooleanValue bool // booleanLiteral
}
Type is a meta-model type. The active fields depend on Kind:
- base: Name
- reference: Name
- array: Element
- map: Key, Value
- and/or/tuple: Items
- literal: Literal
- stringLiteral: StringValue
- integerLiteral: IntegerValue
- booleanLiteral: BooleanValue
func (*Type) UnmarshalJSON ¶
UnmarshalJSON decodes a meta-model type, dispatching on its "kind".
type TypeAlias ¶
type TypeAlias struct {
Name string `json:"name"`
Type *Type `json:"type"`
Documentation string `json:"documentation"`
Since string `json:"since"`
SinceTags []string `json:"sinceTags"`
Deprecated string `json:"deprecated"`
Proposed bool `json:"proposed"`
}
TypeAlias defines a type alias (e.g. Definition = Location | LocationLink).
type TypeKind ¶
type TypeKind string
TypeKind enumerates the discriminator values of Type.
const ( KindBase TypeKind = "base" KindReference TypeKind = "reference" KindArray TypeKind = "array" KindMap TypeKind = "map" KindAnd TypeKind = "and" KindOr TypeKind = "or" KindTuple TypeKind = "tuple" KindLiteral TypeKind = "literal" KindStringLiteral TypeKind = "stringLiteral" KindIntegerLiteral TypeKind = "integerLiteral" KindBooleanLiteral TypeKind = "booleanLiteral" )
The set of Type kinds defined by the meta-schema.