Documentation
¶
Overview ¶
Package plugin is the wire protocol a TDL backend speaks, and the SDK for writing one.
Writing a backend ¶
A backend implements Backend. A plugin's main is Serve and nothing else:
func main() {
if err := plugin.Serve(myBackend{}); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
Build it as tdl-gen-<name> and put it on PATH.
What a request contains ¶
The prelude's declarations (string, List, Option, and the rest) are in the model untagged; filter by the filename in a declaration's position.
A node carries the directives of every target block, each naming its target; keep your own with Directives. A directive expanded from a class names that class.
`tdl ir --format json` shows what a model contains.
Returning files ¶
A backend returns contents, and tdl writes them. Paths are relative to Request.Out; an absolute one, or one climbing out with "..", is refused and nothing is written. A problem with the model belongs in Response diagnostics, not in an error from Backend.Generate.
What a plugin will not see ¶
The declaration-level directives of a dependency's target blocks; only their block-scope directives arrive, on the dependency's import. And class-scoped directives on types that satisfy a class only through a conditional instance: a directive on Auditable reaches Audited and not the Page<Audited> that satisfies Auditable through an instance.
Importing ¶
A backend that also reads its target language back into a model, for `tdl import`, implements Importer and sets Reverse in its description. tdl then shakes hands in Mode_MODE_IMPORT and sends ImportRequest messages instead of Request ones. A warning about a fact the conversion loses carries a code, such as "lossy.collection", which the user can silence; docs/design/reverse.md lists them.
The wire ¶
Messages are protobuf, framed with a varint length prefix, in both directions over one connection. tdl sends a Handshake first and a plugin answers with a HandshakeReply, refusing a version it does not support. Conn is the codec.
Example (Backend) ¶
A plugin's main is Serve and nothing else.
package main
import (
"context"
"fmt"
"strings"
"github.com/unstoppablemango/tdl/ir"
"github.com/unstoppablemango/tdl/plugin"
)
// shout is a complete backend: it declares what it understands and turns
// a model into files.
type shout struct{}
func (shout) Describe() plugin.Description {
return plugin.Description{
Name: "shout",
Version: "1.0.0",
Directives: []*plugin.DirectiveSpec{{
Name: "as",
MinArgs: 1,
MaxArgs: 1,
ArgKinds: []ir.LiteralKind{ir.LiteralKind_LITERAL_KIND_STRING},
}},
}
}
func (shout) Generate(_ context.Context, req *plugin.Request) (*plugin.Response, error) {
var b strings.Builder
for _, decl := range req.GetModel().GetDecls() {
name := decl.GetMeta().GetName()
// Keep only this target's directives.
for _, d := range plugin.Directives(req.GetTarget(), decl.GetDirectives()) {
if d.GetName() == "as" && len(d.GetArgs()) == 1 {
name = d.GetArgs()[0].GetText()
}
}
fmt.Fprintln(&b, strings.ToUpper(name))
}
return &plugin.Response{
Files: []*plugin.File{{Path: "shouted.txt", Content: []byte(b.String())}},
}, nil
}
// A plugin's main is Serve and nothing else.
func main() {
model := &ir.Model{
Decls: []*ir.Decl{
{Meta: &ir.Meta{Name: "Order"}},
{
Meta: &ir.Meta{Name: "Customer"},
Directives: []*ir.Directive{{Name: "as", Target: "shout", Args: []*ir.Literal{{Text: "buyer"}}}},
},
},
}
resp, err := shout{}.Generate(context.Background(), &plugin.Request{
Target: "shout",
Model: model,
})
if err != nil {
panic(err)
}
fmt.Print(string(resp.GetFiles()[0].GetContent()))
}
Output: ORDER BUYER
Index ¶
- Constants
- Variables
- func Directives(target string, all []*ir.Directive) []*ir.Directive
- func Serve(b Backend) error
- func ServeConn(ctx context.Context, b Backend, conn *Conn) error
- type Analysis
- type Backend
- type Conn
- type ConstraintView
- func (*ConstraintView) Descriptor() ([]byte, []int)deprecated
- func (x *ConstraintView) GetLength() *ir.Range
- func (x *ConstraintView) GetProblem() string
- func (x *ConstraintView) GetRe2() bool
- func (x *ConstraintView) GetSource() string
- func (*ConstraintView) ProtoMessage()
- func (x *ConstraintView) ProtoReflect() protoreflect.Message
- func (x *ConstraintView) Reset()
- func (x *ConstraintView) String() string
- type DeclView
- func (*DeclView) Descriptor() ([]byte, []int)deprecated
- func (x *DeclView) GetConstraints() []*ConstraintView
- func (x *DeclView) GetDiscriminant() string
- func (x *DeclView) GetFielded() bool
- func (x *DeclView) GetFields() []*MemberView
- func (x *DeclView) GetOwn() bool
- func (x *DeclView) GetReferences() []*ir.ID
- func (x *DeclView) GetUnderlying() *ir.ID
- func (x *DeclView) GetVariants() []*MemberView
- func (x *DeclView) GetWords() []string
- func (*DeclView) ProtoMessage()
- func (x *DeclView) ProtoReflect() protoreflect.Message
- func (x *DeclView) Reset()
- func (x *DeclView) String() string
- type Description
- type Diagnostic
- func (*Diagnostic) Descriptor() ([]byte, []int)deprecated
- func (x *Diagnostic) GetCode() string
- func (x *Diagnostic) GetMessage() string
- func (x *Diagnostic) GetPosition() *ir.Position
- func (x *Diagnostic) GetSeverity() Severity
- func (*Diagnostic) ProtoMessage()
- func (x *Diagnostic) ProtoReflect() protoreflect.Message
- func (x *Diagnostic) Reset()
- func (x *Diagnostic) String() string
- type DirectiveSpec
- func (*DirectiveSpec) Descriptor() ([]byte, []int)deprecated
- func (x *DirectiveSpec) GetArgKinds() []ir.LiteralKind
- func (x *DirectiveSpec) GetMaxArgs() int32
- func (x *DirectiveSpec) GetMinArgs() int32
- func (x *DirectiveSpec) GetName() string
- func (x *DirectiveSpec) GetPlacements() []Placement
- func (x *DirectiveSpec) GetRepeatable() bool
- func (x *DirectiveSpec) GetValues() []string
- func (*DirectiveSpec) ProtoMessage()
- func (x *DirectiveSpec) ProtoReflect() protoreflect.Message
- func (x *DirectiveSpec) Reset()
- func (x *DirectiveSpec) String() string
- type Features
- type File
- type Form
- type Handshake
- func (*Handshake) Descriptor() ([]byte, []int)deprecated
- func (x *Handshake) GetFramingVersion() int32
- func (x *Handshake) GetIrVersion() string
- func (x *Handshake) GetMode() Mode
- func (x *Handshake) GetWatch() bool
- func (*Handshake) ProtoMessage()
- func (x *Handshake) ProtoReflect() protoreflect.Message
- func (x *Handshake) Reset()
- func (x *Handshake) String() string
- type HandshakeReply
- func (*HandshakeReply) Descriptor() ([]byte, []int)deprecated
- func (x *HandshakeReply) GetAccepted() bool
- func (x *HandshakeReply) GetDirectives() []*DirectiveSpec
- func (x *HandshakeReply) GetFeatures() *Features
- func (x *HandshakeReply) GetName() string
- func (x *HandshakeReply) GetNumbering() *Numbering
- func (x *HandshakeReply) GetRefusal() string
- func (x *HandshakeReply) GetVersion() string
- func (*HandshakeReply) ProtoMessage()
- func (x *HandshakeReply) ProtoReflect() protoreflect.Message
- func (x *HandshakeReply) Reset()
- func (x *HandshakeReply) String() string
- type ImportRequest
- func (*ImportRequest) Descriptor() ([]byte, []int)deprecated
- func (x *ImportRequest) GetAllowLossy() []string
- func (x *ImportRequest) GetFiles() []*File
- func (x *ImportRequest) GetTarget() string
- func (*ImportRequest) ProtoMessage()
- func (x *ImportRequest) ProtoReflect() protoreflect.Message
- func (x *ImportRequest) Reset()
- func (x *ImportRequest) String() string
- type ImportResponse
- func (*ImportResponse) Descriptor() ([]byte, []int)deprecated
- func (x *ImportResponse) GetDiagnostics() []*Diagnostic
- func (x *ImportResponse) GetModel() *ir.Model
- func (*ImportResponse) ProtoMessage()
- func (x *ImportResponse) ProtoReflect() protoreflect.Message
- func (x *ImportResponse) Reset()
- func (x *ImportResponse) String() string
- type Importer
- type MemberView
- func (*MemberView) Descriptor() ([]byte, []int)deprecated
- func (x *MemberView) GetConstraints() []*ConstraintView
- func (x *MemberView) GetFields() []*MemberView
- func (x *MemberView) GetInlined() []int64
- func (x *MemberView) GetNumber() int64
- func (x *MemberView) GetWords() []string
- func (*MemberView) ProtoMessage()
- func (x *MemberView) ProtoReflect() protoreflect.Message
- func (x *MemberView) Reset()
- func (x *MemberView) String() string
- type Mode
- type NumberRule
- type Numbering
- func (*Numbering) Descriptor() ([]byte, []int)deprecated
- func (x *Numbering) GetFields() *NumberRule
- func (x *Numbering) GetInline() string
- func (x *Numbering) GetReserve() string
- func (x *Numbering) GetValues() *NumberRule
- func (*Numbering) ProtoMessage()
- func (x *Numbering) ProtoReflect() protoreflect.Message
- func (x *Numbering) Reset()
- func (x *Numbering) String() string
- type Placement
- type Refusal
- func (*Refusal) Descriptor() ([]byte, []int)deprecated
- func (x *Refusal) GetPosition() *ir.Position
- func (x *Refusal) GetReason() Refusal_Reason
- func (x *Refusal) GetSubject() string
- func (*Refusal) ProtoMessage()
- func (x *Refusal) ProtoReflect() protoreflect.Message
- func (x *Refusal) Reset()
- func (x *Refusal) String() string
- type Refusal_Reason
- func (Refusal_Reason) Descriptor() protoreflect.EnumDescriptor
- func (x Refusal_Reason) Enum() *Refusal_Reason
- func (Refusal_Reason) EnumDescriptor() ([]byte, []int)deprecated
- func (x Refusal_Reason) Number() protoreflect.EnumNumber
- func (x Refusal_Reason) String() string
- func (Refusal_Reason) Type() protoreflect.EnumType
- type Request
- func (*Request) Descriptor() ([]byte, []int)deprecated
- func (x *Request) GetAnalysis() *Analysis
- func (x *Request) GetDryRun() bool
- func (x *Request) GetModel() *ir.Model
- func (x *Request) GetOut() string
- func (x *Request) GetTarget() string
- func (*Request) ProtoMessage()
- func (x *Request) ProtoReflect() protoreflect.Message
- func (x *Request) Reset()
- func (x *Request) String() string
- type Response
- func (*Response) Descriptor() ([]byte, []int)deprecated
- func (x *Response) GetDiagnostics() []*Diagnostic
- func (x *Response) GetFiles() []*File
- func (x *Response) GetPost() []string
- func (*Response) ProtoMessage()
- func (x *Response) ProtoReflect() protoreflect.Message
- func (x *Response) Reset()
- func (x *Response) String() string
- type Severity
- type TypeView
- func (*TypeView) Descriptor() ([]byte, []int)deprecated
- func (x *TypeView) GetDecl() *ir.ID
- func (x *TypeView) GetElem() *ir.ID
- func (x *TypeView) GetExtern() *ir.ID
- func (x *TypeView) GetForm() Form
- func (x *TypeView) GetId() *ir.ID
- func (x *TypeView) GetKey() *ir.ID
- func (x *TypeView) GetName() string
- func (x *TypeView) GetReferences() []*ir.ID
- func (x *TypeView) GetRefusal() *Refusal
- func (*TypeView) ProtoMessage()
- func (x *TypeView) ProtoReflect() protoreflect.Message
- func (x *TypeView) Reset()
- func (x *TypeView) String() string
Examples ¶
Constants ¶
const ( OnBlock = Placement_PLACEMENT_BLOCK OnDecl = Placement_PLACEMENT_DECL OnField = Placement_PLACEMENT_FIELD OnVariant = Placement_PLACEMENT_VARIANT OnExtern = Placement_PLACEMENT_EXTERN )
Short names for the placements a DirectiveSpec lists.
const FramingVersion = 1
FramingVersion is the wire framing this package implements: a varint byte count followed by the encoded message.
const IRVersion = "tdl.ir.v1"
IRVersion is the protobuf package the model is encoded with.
const MaxMessageSize = 64 << 20
MaxMessageSize bounds a single message. A length prefix over it is refused before anything is allocated.
Variables ¶
var ( Mode_name = map[int32]string{ 0: "MODE_UNSPECIFIED", 1: "MODE_IMPORT", } Mode_value = map[string]int32{ "MODE_UNSPECIFIED": 0, "MODE_IMPORT": 1, } )
Enum value maps for Mode.
var ( Placement_name = map[int32]string{ 0: "PLACEMENT_UNSPECIFIED", 1: "PLACEMENT_BLOCK", 2: "PLACEMENT_DECL", 3: "PLACEMENT_FIELD", 4: "PLACEMENT_VARIANT", 5: "PLACEMENT_EXTERN", } Placement_value = map[string]int32{ "PLACEMENT_UNSPECIFIED": 0, "PLACEMENT_BLOCK": 1, "PLACEMENT_DECL": 2, "PLACEMENT_FIELD": 3, "PLACEMENT_VARIANT": 4, "PLACEMENT_EXTERN": 5, } )
Enum value maps for Placement.
var ( Form_name = map[int32]string{ 0: "FORM_UNSPECIFIED", 1: "FORM_PRIMITIVE", 2: "FORM_LIST", 3: "FORM_SET", 4: "FORM_MAP", 5: "FORM_OPTION", 6: "FORM_NULLABLE", 7: "FORM_NAMED", 8: "FORM_EXTERN", 9: "FORM_PARAM", 10: "FORM_UNIT", } Form_value = map[string]int32{ "FORM_UNSPECIFIED": 0, "FORM_PRIMITIVE": 1, "FORM_LIST": 2, "FORM_SET": 3, "FORM_MAP": 4, "FORM_OPTION": 5, "FORM_NULLABLE": 6, "FORM_NAMED": 7, "FORM_EXTERN": 8, "FORM_PARAM": 9, "FORM_UNIT": 10, } )
Enum value maps for Form.
var ( Severity_name = map[int32]string{ 0: "SEVERITY_UNSPECIFIED", 1: "SEVERITY_ERROR", 2: "SEVERITY_WARNING", } Severity_value = map[string]int32{ "SEVERITY_UNSPECIFIED": 0, "SEVERITY_ERROR": 1, "SEVERITY_WARNING": 2, } )
Enum value maps for Severity.
var ( Refusal_Reason_name = map[int32]string{ 0: "REASON_UNSPECIFIED", 1: "REASON_UNRESOLVED", 2: "REASON_PARAM", 3: "REASON_UNIT", 4: "REASON_CLASS", 5: "REASON_UNIT_DECL", 6: "REASON_TYPE_ARGS", 7: "REASON_MISSING_ARG", } Refusal_Reason_value = map[string]int32{ "REASON_UNSPECIFIED": 0, "REASON_UNRESOLVED": 1, "REASON_PARAM": 2, "REASON_UNIT": 3, "REASON_CLASS": 4, "REASON_UNIT_DECL": 5, "REASON_TYPE_ARGS": 6, "REASON_MISSING_ARG": 7, } )
Enum value maps for Refusal_Reason.
var ErrTooLarge = errors.New("plugin: message exceeds the maximum size")
ErrTooLarge is returned when a length prefix exceeds MaxMessageSize.
var File_tdl_plugin_v1_plugin_proto protoreflect.FileDescriptor
Functions ¶
func Directives ¶
Directives returns the directives in all that belong to target. A request from tdl carries only its target's directives, so this matters for a model built some other way, where a node carries every target block's.
Types ¶
type Analysis ¶ added in v0.4.10
type Analysis struct {
Types []*TypeView `protobuf:"bytes,1,rep,name=types" json:"types,omitempty"` // indexed like Model.types
Decls []*DeclView `protobuf:"bytes,2,rep,name=decls" json:"decls,omitempty"` // indexed like Model.decls
// contains filtered or unexported fields
}
Analysis holds facts about a model that are the same for every backend serving one target: each type reference resolved to the prelude's shapes, and what each declaration names. See docs/design/plugin-sdk.md.
func (*Analysis) Descriptor
deprecated
added in
v0.4.10
func (*Analysis) ProtoMessage ¶ added in v0.4.10
func (*Analysis) ProtoMessage()
func (*Analysis) ProtoReflect ¶ added in v0.4.10
func (x *Analysis) ProtoReflect() protoreflect.Message
type Backend ¶
type Backend interface {
// Describe reports what this backend is and what directives it
// understands. tdl checks a target block against them before
// generating.
Describe() Description
// Generate returns the files for one request. It returns an error only
// when it cannot produce a response at all; a problem with the model
// belongs in Response.diagnostics.
Generate(ctx context.Context, req *Request) (*Response, error)
}
Backend turns a resolved model into files, in process or served as a plugin by Serve.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is one end of a plugin connection. It is not safe for concurrent use.
func (*Conn) Recv ¶
Recv reads one message into m. A stream that ends between messages returns io.EOF; one that ends part way through a message returns io.ErrUnexpectedEOF.
type ConstraintView ¶ added in v0.4.12
type ConstraintView struct {
// source is the constraint as TDL writes it: `length(1..64)`.
Source string `protobuf:"bytes,1,opt,name=source" json:"source,omitempty"`
// length is a `length` constraint's bounds, inclusive. An integer
// argument is both ends, and a range leaves an open end unset. It is
// unset when problem is.
Length *ir.Range `protobuf:"bytes,2,opt,name=length" json:"length,omitempty"`
// re2 is set on a `matches` constraint whose pattern RE2 reads, which a
// target whose engine accepts every RE2 pattern with the same meaning
// reads too. A pattern RE2 refuses may still suit a target with another
// engine, so it is not a problem.
Re2 bool `protobuf:"varint,3,opt,name=re2" json:"re2,omitempty"`
// problem says why tdl could not read the constraint, such as a length
// that can never hold. tdl reports it as an error before generating.
Problem string `protobuf:"bytes,4,opt,name=problem" json:"problem,omitempty"`
// contains filtered or unexported fields
}
ConstraintView is what tdl reads from one constraint.
func (*ConstraintView) Descriptor
deprecated
added in
v0.4.12
func (*ConstraintView) Descriptor() ([]byte, []int)
Deprecated: Use ConstraintView.ProtoReflect.Descriptor instead.
func (*ConstraintView) GetLength ¶ added in v0.4.12
func (x *ConstraintView) GetLength() *ir.Range
func (*ConstraintView) GetProblem ¶ added in v0.4.12
func (x *ConstraintView) GetProblem() string
func (*ConstraintView) GetRe2 ¶ added in v0.4.12
func (x *ConstraintView) GetRe2() bool
func (*ConstraintView) GetSource ¶ added in v0.4.12
func (x *ConstraintView) GetSource() string
func (*ConstraintView) ProtoMessage ¶ added in v0.4.12
func (*ConstraintView) ProtoMessage()
func (*ConstraintView) ProtoReflect ¶ added in v0.4.12
func (x *ConstraintView) ProtoReflect() protoreflect.Message
func (*ConstraintView) Reset ¶ added in v0.4.12
func (x *ConstraintView) Reset()
func (*ConstraintView) String ¶ added in v0.4.12
func (x *ConstraintView) String() string
type DeclView ¶ added in v0.4.10
type DeclView struct {
// own is false for a declaration the embedded prelude supplies.
Own bool `protobuf:"varint,1,opt,name=own" json:"own,omitempty"`
// references are the declarations this one names through its fields,
// its variants' fields, a newtype's base, an alias's target, and their
// type arguments, with aliases expanded, in the order they are first
// named. A declaration naming itself is included.
References []*ir.ID `protobuf:"bytes,2,rep,name=references" json:"references,omitempty"`
// fielded is set on an enum with a variant carrying fields, making it a
// sum type rather than a plain enum.
Fielded bool `protobuf:"varint,3,opt,name=fielded" json:"fielded,omitempty"`
// discriminant is the property naming an enum's variant on the JSON
// wire: the enum's `discriminant` directive, else the target block's,
// else "kind".
Discriminant string `protobuf:"bytes,4,opt,name=discriminant" json:"discriminant,omitempty"`
// underlying is the type at the end of a newtype's chain of newtypes,
// unset when the chain wraps itself or reaches a refused type.
Underlying *ir.ID `protobuf:"bytes,5,opt,name=underlying" json:"underlying,omitempty"`
// words are the last segment of the name split into the words a case
// style joins: `userID` is user and ID, `HTTPServer` is HTTP and Server.
Words []string `protobuf:"bytes,6,rep,name=words" json:"words,omitempty"`
// fields are a structure's fields, in the order Structure.fields lists them.
Fields []*MemberView `protobuf:"bytes,7,rep,name=fields" json:"fields,omitempty"`
// variants are an enum's variants, in the order Enum.variants lists them.
Variants []*MemberView `protobuf:"bytes,8,rep,name=variants" json:"variants,omitempty"`
// constraints are a newtype's, in the order Newtype.value_constraints
// lists them.
Constraints []*ConstraintView `protobuf:"bytes,9,rep,name=constraints" json:"constraints,omitempty"`
// contains filtered or unexported fields
}
DeclView is one entry of the declaration table, as one target sees it.
func (*DeclView) Descriptor
deprecated
added in
v0.4.10
func (*DeclView) GetConstraints ¶ added in v0.4.12
func (x *DeclView) GetConstraints() []*ConstraintView
func (*DeclView) GetDiscriminant ¶ added in v0.4.10
func (*DeclView) GetFielded ¶ added in v0.4.10
func (*DeclView) GetFields ¶ added in v0.4.10
func (x *DeclView) GetFields() []*MemberView
func (*DeclView) GetReferences ¶ added in v0.4.10
func (*DeclView) GetUnderlying ¶ added in v0.4.10
func (*DeclView) GetVariants ¶ added in v0.4.10
func (x *DeclView) GetVariants() []*MemberView
func (*DeclView) ProtoMessage ¶ added in v0.4.10
func (*DeclView) ProtoMessage()
func (*DeclView) ProtoReflect ¶ added in v0.4.10
func (x *DeclView) ProtoReflect() protoreflect.Message
type Description ¶
type Description struct {
Name string
Version string
Directives []*DirectiveSpec
Reuse bool
// Reverse says the backend is an [Importer].
Reverse bool
// Numbering is how the backend numbers fields and variants, or nil
// for a backend that does not.
Numbering *Numbering
}
Description is what a backend says about itself.
func (Description) Reply ¶
func (d Description) Reply() *HandshakeReply
Reply turns a description into the handshake reply that carries it.
type Diagnostic ¶
type Diagnostic struct {
Severity Severity `protobuf:"varint,1,opt,name=severity,enum=tdl.plugin.v1.Severity" json:"severity,omitempty"`
Message string `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"`
Position *ir.Position `protobuf:"bytes,3,opt,name=position" json:"position,omitempty"`
// code names the kind of problem, such as "lossy.collection". A warning
// a user can silence carries one; see docs/design/reverse.md.
Code string `protobuf:"bytes,4,opt,name=code" json:"code,omitempty"`
// contains filtered or unexported fields
}
Diagnostic is a problem a backend found.
It carries a position rather than a node ID, because an ID alone does not say which table it indexes.
func (*Diagnostic) Descriptor
deprecated
func (*Diagnostic) Descriptor() ([]byte, []int)
Deprecated: Use Diagnostic.ProtoReflect.Descriptor instead.
func (*Diagnostic) GetCode ¶ added in v0.3.5
func (x *Diagnostic) GetCode() string
func (*Diagnostic) GetMessage ¶
func (x *Diagnostic) GetMessage() string
func (*Diagnostic) GetPosition ¶
func (x *Diagnostic) GetPosition() *ir.Position
func (*Diagnostic) GetSeverity ¶
func (x *Diagnostic) GetSeverity() Severity
func (*Diagnostic) ProtoMessage ¶
func (*Diagnostic) ProtoMessage()
func (*Diagnostic) ProtoReflect ¶
func (x *Diagnostic) ProtoReflect() protoreflect.Message
func (*Diagnostic) Reset ¶
func (x *Diagnostic) Reset()
func (*Diagnostic) String ¶
func (x *Diagnostic) String() string
type DirectiveSpec ¶
type DirectiveSpec struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
MinArgs int32 `protobuf:"varint,2,opt,name=min_args,json=minArgs" json:"min_args,omitempty"`
// max_args is the largest number of arguments accepted, or -1 for any
// number.
MaxArgs int32 `protobuf:"varint,3,opt,name=max_args,json=maxArgs" json:"max_args,omitempty"`
// arg_kinds constrains each argument by position. An empty list accepts
// any kind, and a list shorter than the argument count constrains only
// the arguments it covers.
ArgKinds []ir.LiteralKind `protobuf:"varint,4,rep,packed,name=arg_kinds,json=argKinds,enum=tdl.ir.v1.LiteralKind" json:"arg_kinds,omitempty"`
// repeatable says several entries of this directive at the same
// specificity all reach the backend in source order. Otherwise they are
// an error.
Repeatable bool `protobuf:"varint,5,opt,name=repeatable" json:"repeatable,omitempty"`
// placements are where the directive may be written. An empty list
// accepts it anywhere. A directive accepted on a declaration is also
// accepted on an extern, which is a declaration another package owns.
Placements []Placement `protobuf:"varint,6,rep,packed,name=placements,enum=tdl.plugin.v1.Placement" json:"placements,omitempty"`
// values are what the first argument may be. An empty list accepts any
// value.
Values []string `protobuf:"bytes,7,rep,name=values" json:"values,omitempty"`
// contains filtered or unexported fields
}
DirectiveSpec is the shape of one directive a backend accepts.
A directive in a target block that no spec declares is a warning and is passed through anyway.
func (*DirectiveSpec) Descriptor
deprecated
func (*DirectiveSpec) Descriptor() ([]byte, []int)
Deprecated: Use DirectiveSpec.ProtoReflect.Descriptor instead.
func (*DirectiveSpec) GetArgKinds ¶
func (x *DirectiveSpec) GetArgKinds() []ir.LiteralKind
func (*DirectiveSpec) GetMaxArgs ¶
func (x *DirectiveSpec) GetMaxArgs() int32
func (*DirectiveSpec) GetMinArgs ¶
func (x *DirectiveSpec) GetMinArgs() int32
func (*DirectiveSpec) GetName ¶
func (x *DirectiveSpec) GetName() string
func (*DirectiveSpec) GetPlacements ¶ added in v0.4.11
func (x *DirectiveSpec) GetPlacements() []Placement
func (*DirectiveSpec) GetRepeatable ¶ added in v0.2.10
func (x *DirectiveSpec) GetRepeatable() bool
func (*DirectiveSpec) GetValues ¶ added in v0.4.11
func (x *DirectiveSpec) GetValues() []string
func (*DirectiveSpec) ProtoMessage ¶
func (*DirectiveSpec) ProtoMessage()
func (*DirectiveSpec) ProtoReflect ¶
func (x *DirectiveSpec) ProtoReflect() protoreflect.Message
func (*DirectiveSpec) Reset ¶
func (x *DirectiveSpec) Reset()
func (*DirectiveSpec) String ¶
func (x *DirectiveSpec) String() string
type Features ¶
type Features struct {
// reuse says the plugin can serve more than one request on a
// connection. It must treat each as independent.
Reuse bool `protobuf:"varint,1,opt,name=reuse" json:"reuse,omitempty"`
// reverse says the plugin answers MODE_IMPORT, reading its target
// language back into a model.
Reverse bool `protobuf:"varint,2,opt,name=reverse" json:"reverse,omitempty"`
// contains filtered or unexported fields
}
Features are the optional parts of the protocol a backend supports.
func (*Features) Descriptor
deprecated
func (*Features) GetReverse ¶ added in v0.3.5
func (*Features) ProtoMessage ¶
func (*Features) ProtoMessage()
func (*Features) ProtoReflect ¶
func (x *Features) ProtoReflect() protoreflect.Message
type File ¶
type File struct {
Path string `protobuf:"bytes,1,opt,name=path" json:"path,omitempty"`
Content []byte `protobuf:"bytes,2,opt,name=content" json:"content,omitempty"`
// contains filtered or unexported fields
}
File is one generated file, with a path relative to Request.out. An absolute path, or one containing "..", is an error and nothing is written.
func (*File) Descriptor
deprecated
func (*File) GetContent ¶
func (*File) ProtoMessage ¶
func (*File) ProtoMessage()
func (*File) ProtoReflect ¶
func (x *File) ProtoReflect() protoreflect.Message
type Form ¶ added in v0.4.10
type Form int32
Form is which of the prelude's shapes a type resolves to. The shapes are matched by the prelude's spellings, as lowering matches them, so a replaced prelude reaches every plugin the same way.
const ( Form_FORM_UNSPECIFIED Form = 0 // FORM_PRIMITIVE is a primitive that is not a collection; name says which. Form_FORM_PRIMITIVE Form = 1 Form_FORM_LIST Form = 2 Form_FORM_SET Form = 3 // FORM_MAP has a key and a value; elem is the value. Form_FORM_MAP Form = 4 // FORM_OPTION is `T?`. Form_FORM_OPTION Form = 5 // FORM_NULLABLE is `T | null`. Form_FORM_NULLABLE Form = 6 // FORM_NAMED is a declaration: a struct, an enum, a newtype, a class, or // a unit. Form_FORM_NAMED Form = 7 // FORM_EXTERN is a declaration in another package. Form_FORM_EXTERN Form = 8 // FORM_PARAM is a use of a type parameter; name is the parameter's. Form_FORM_PARAM Form = 9 // FORM_UNIT is a unit of measure. Form_FORM_UNIT Form = 10 )
func (Form) Descriptor ¶ added in v0.4.10
func (Form) Descriptor() protoreflect.EnumDescriptor
func (Form) EnumDescriptor
deprecated
added in
v0.4.10
func (Form) Number ¶ added in v0.4.10
func (x Form) Number() protoreflect.EnumNumber
func (Form) Type ¶ added in v0.4.10
func (Form) Type() protoreflect.EnumType
type Handshake ¶
type Handshake struct {
// framing_version is the wire framing this connection uses. Version 1 is
// a varint length prefix followed by an encoded message, in both
// directions.
FramingVersion int32 `protobuf:"varint,1,opt,name=framing_version,json=framingVersion" json:"framing_version,omitempty"`
// ir_version is the protobuf package the model is encoded with, such as
// "tdl.ir.v1". Within a version, field numbers are never reused and new
// fields are additive.
IrVersion string `protobuf:"bytes,2,opt,name=ir_version,json=irVersion" json:"ir_version,omitempty"`
// watch says this connection may serve more than one request.
Watch bool `protobuf:"varint,3,opt,name=watch" json:"watch,omitempty"`
// mode says which requests follow: Request, or ImportRequest under
// MODE_IMPORT.
Mode Mode `protobuf:"varint,4,opt,name=mode,enum=tdl.plugin.v1.Mode" json:"mode,omitempty"`
// contains filtered or unexported fields
}
Handshake is what tdl sends first, before any request.
A plugin that cannot read what is coming refuses here instead of ignoring fields it does not know and emitting wrong code.
func (*Handshake) Descriptor
deprecated
func (*Handshake) GetFramingVersion ¶
func (*Handshake) GetIrVersion ¶
func (*Handshake) ProtoMessage ¶
func (*Handshake) ProtoMessage()
func (*Handshake) ProtoReflect ¶
func (x *Handshake) ProtoReflect() protoreflect.Message
type HandshakeReply ¶
type HandshakeReply struct {
Accepted bool `protobuf:"varint,1,opt,name=accepted" json:"accepted,omitempty"`
// refusal says what the plugin needed, when accepted is false. It should
// name both versions.
Refusal string `protobuf:"bytes,2,opt,name=refusal" json:"refusal,omitempty"`
Name string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"`
Version string `protobuf:"bytes,4,opt,name=version" json:"version,omitempty"`
// directives are what this backend understands. tdl checks the target
// block against them before generating.
Directives []*DirectiveSpec `protobuf:"bytes,5,rep,name=directives" json:"directives,omitempty"`
Features *Features `protobuf:"bytes,6,opt,name=features" json:"features,omitempty"`
// numbering is how this backend numbers fields and variants, for a wire
// format that identifies them by number. tdl numbers every member and
// reports a pin the rules refuse before generating. A backend that does
// not number leaves it unset and receives no numbers.
Numbering *Numbering `protobuf:"bytes,7,opt,name=numbering" json:"numbering,omitempty"`
// contains filtered or unexported fields
}
HandshakeReply is the plugin's answer.
func (*HandshakeReply) Descriptor
deprecated
func (*HandshakeReply) Descriptor() ([]byte, []int)
Deprecated: Use HandshakeReply.ProtoReflect.Descriptor instead.
func (*HandshakeReply) GetAccepted ¶
func (x *HandshakeReply) GetAccepted() bool
func (*HandshakeReply) GetDirectives ¶
func (x *HandshakeReply) GetDirectives() []*DirectiveSpec
func (*HandshakeReply) GetFeatures ¶
func (x *HandshakeReply) GetFeatures() *Features
func (*HandshakeReply) GetName ¶
func (x *HandshakeReply) GetName() string
func (*HandshakeReply) GetNumbering ¶ added in v0.4.12
func (x *HandshakeReply) GetNumbering() *Numbering
func (*HandshakeReply) GetRefusal ¶
func (x *HandshakeReply) GetRefusal() string
func (*HandshakeReply) GetVersion ¶
func (x *HandshakeReply) GetVersion() string
func (*HandshakeReply) ProtoMessage ¶
func (*HandshakeReply) ProtoMessage()
func (*HandshakeReply) ProtoReflect ¶
func (x *HandshakeReply) ProtoReflect() protoreflect.Message
func (*HandshakeReply) Reset ¶
func (x *HandshakeReply) Reset()
func (*HandshakeReply) String ¶
func (x *HandshakeReply) String() string
type ImportRequest ¶ added in v0.3.5
type ImportRequest struct {
// target names the backend's language, as in Request.target. Directives
// the backend writes into the model's target blocks name it.
Target string `protobuf:"bytes,1,opt,name=target" json:"target,omitempty"`
// files are the source files to read, with the paths the user gave.
Files []*File `protobuf:"bytes,2,rep,name=files" json:"files,omitempty"`
// allow_lossy are the loss codes the user allowed. tdl drops warnings
// carrying them, so a backend may skip the work of finding them; ignoring
// the list is correct.
AllowLossy []string `protobuf:"bytes,3,rep,name=allow_lossy,json=allowLossy" json:"allow_lossy,omitempty"`
// contains filtered or unexported fields
}
ImportRequest is everything a reverse backend needs to read one set of source files back into a model.
func (*ImportRequest) Descriptor
deprecated
added in
v0.3.5
func (*ImportRequest) Descriptor() ([]byte, []int)
Deprecated: Use ImportRequest.ProtoReflect.Descriptor instead.
func (*ImportRequest) GetAllowLossy ¶ added in v0.3.5
func (x *ImportRequest) GetAllowLossy() []string
func (*ImportRequest) GetFiles ¶ added in v0.3.5
func (x *ImportRequest) GetFiles() []*File
func (*ImportRequest) GetTarget ¶ added in v0.3.5
func (x *ImportRequest) GetTarget() string
func (*ImportRequest) ProtoMessage ¶ added in v0.3.5
func (*ImportRequest) ProtoMessage()
func (*ImportRequest) ProtoReflect ¶ added in v0.3.5
func (x *ImportRequest) ProtoReflect() protoreflect.Message
func (*ImportRequest) Reset ¶ added in v0.3.5
func (x *ImportRequest) Reset()
func (*ImportRequest) String ¶ added in v0.3.5
func (x *ImportRequest) String() string
type ImportResponse ¶ added in v0.3.5
type ImportResponse struct {
// model holds the declarations read, in the shape lowering produces.
// tdl prints only the declarations not positioned in the prelude.
Model *ir.Model `protobuf:"bytes,1,opt,name=model" json:"model,omitempty"`
Diagnostics []*Diagnostic `protobuf:"bytes,2,rep,name=diagnostics" json:"diagnostics,omitempty"`
// contains filtered or unexported fields
}
ImportResponse is what a reverse backend returns: a model, which tdl turns into TDL source and lowers again before writing it.
func (*ImportResponse) Descriptor
deprecated
added in
v0.3.5
func (*ImportResponse) Descriptor() ([]byte, []int)
Deprecated: Use ImportResponse.ProtoReflect.Descriptor instead.
func (*ImportResponse) GetDiagnostics ¶ added in v0.3.5
func (x *ImportResponse) GetDiagnostics() []*Diagnostic
func (*ImportResponse) GetModel ¶ added in v0.3.5
func (x *ImportResponse) GetModel() *ir.Model
func (*ImportResponse) ProtoMessage ¶ added in v0.3.5
func (*ImportResponse) ProtoMessage()
func (*ImportResponse) ProtoReflect ¶ added in v0.3.5
func (x *ImportResponse) ProtoReflect() protoreflect.Message
func (*ImportResponse) Reset ¶ added in v0.3.5
func (x *ImportResponse) Reset()
func (*ImportResponse) String ¶ added in v0.3.5
func (x *ImportResponse) String() string
type Importer ¶ added in v0.3.5
type Importer interface {
Backend
// Import returns the model the request's files describe. It returns an
// error only when it cannot produce a response at all; a problem with
// the files belongs in ImportResponse.diagnostics.
Import(ctx context.Context, req *ImportRequest) (*ImportResponse, error)
}
Importer is a backend that also reads its target language back into a model, for `tdl import`. A backend implementing it declares Reverse in its description.
type MemberView ¶ added in v0.4.10
type MemberView struct {
// words are the name split as DeclView.words splits it.
Words []string `protobuf:"bytes,1,rep,name=words" json:"words,omitempty"`
// fields are a variant's fields.
Fields []*MemberView `protobuf:"bytes,2,rep,name=fields" json:"fields,omitempty"`
// number is the member's wire number under the backend's Numbering, or
// 0 when the backend declares none. A field carrying the inline
// directive takes no number.
Number int64 `protobuf:"varint,3,opt,name=number" json:"number,omitempty"`
// inlined are the numbers of the variants an inlined field's enum
// contributes to this space, in the order Enum.variants lists them.
Inlined []int64 `protobuf:"varint,4,rep,packed,name=inlined" json:"inlined,omitempty"`
// constraints are a field's, in the order Field.constraints lists them.
Constraints []*ConstraintView `protobuf:"bytes,5,rep,name=constraints" json:"constraints,omitempty"`
// contains filtered or unexported fields
}
MemberView is a field or a variant.
func (*MemberView) Descriptor
deprecated
added in
v0.4.10
func (*MemberView) Descriptor() ([]byte, []int)
Deprecated: Use MemberView.ProtoReflect.Descriptor instead.
func (*MemberView) GetConstraints ¶ added in v0.4.12
func (x *MemberView) GetConstraints() []*ConstraintView
func (*MemberView) GetFields ¶ added in v0.4.10
func (x *MemberView) GetFields() []*MemberView
func (*MemberView) GetInlined ¶ added in v0.4.12
func (x *MemberView) GetInlined() []int64
func (*MemberView) GetNumber ¶ added in v0.4.12
func (x *MemberView) GetNumber() int64
func (*MemberView) GetWords ¶ added in v0.4.10
func (x *MemberView) GetWords() []string
func (*MemberView) ProtoMessage ¶ added in v0.4.10
func (*MemberView) ProtoMessage()
func (*MemberView) ProtoReflect ¶ added in v0.4.10
func (x *MemberView) ProtoReflect() protoreflect.Message
func (*MemberView) Reset ¶ added in v0.4.10
func (x *MemberView) Reset()
func (*MemberView) String ¶ added in v0.4.10
func (x *MemberView) String() string
type Mode ¶ added in v0.3.5
type Mode int32
Mode is the direction of a connection.
const ( // MODE_UNSPECIFIED generates: it reads a model and writes the target // language. It is what a host sent before import mode existed. Mode_MODE_UNSPECIFIED Mode = 0 // MODE_IMPORT reads the target language and writes a model. The host // sends it only to a plugin whose reply declared Features.reverse. Mode_MODE_IMPORT Mode = 1 )
func (Mode) Descriptor ¶ added in v0.3.5
func (Mode) Descriptor() protoreflect.EnumDescriptor
func (Mode) EnumDescriptor
deprecated
added in
v0.3.5
func (Mode) Number ¶ added in v0.3.5
func (x Mode) Number() protoreflect.EnumNumber
func (Mode) Type ¶ added in v0.3.5
func (Mode) Type() protoreflect.EnumType
type NumberRule ¶ added in v0.4.12
type NumberRule struct {
// max is the largest number.
Max int64 `protobuf:"varint,1,opt,name=max" json:"max,omitempty"`
// reserved are inclusive ranges no member may take.
Reserved []*ir.Range `protobuf:"bytes,2,rep,name=reserved" json:"reserved,omitempty"`
// contains filtered or unexported fields
}
NumberRule is what one number space allows.
func (*NumberRule) Descriptor
deprecated
added in
v0.4.12
func (*NumberRule) Descriptor() ([]byte, []int)
Deprecated: Use NumberRule.ProtoReflect.Descriptor instead.
func (*NumberRule) GetMax ¶ added in v0.4.12
func (x *NumberRule) GetMax() int64
func (*NumberRule) GetReserved ¶ added in v0.4.12
func (x *NumberRule) GetReserved() []*ir.Range
func (*NumberRule) ProtoMessage ¶ added in v0.4.12
func (*NumberRule) ProtoMessage()
func (*NumberRule) ProtoReflect ¶ added in v0.4.12
func (x *NumberRule) ProtoReflect() protoreflect.Message
func (*NumberRule) Reset ¶ added in v0.4.12
func (x *NumberRule) Reset()
func (*NumberRule) String ¶ added in v0.4.12
func (x *NumberRule) String() string
type Numbering ¶ added in v0.4.12
type Numbering struct {
// fields covers a structure's fields, a fielded enum's variants, and a
// variant's fields.
Fields *NumberRule `protobuf:"bytes,1,opt,name=fields" json:"fields,omitempty"`
// values covers the variants of an enum whose variants carry no fields.
Values *NumberRule `protobuf:"bytes,2,opt,name=values" json:"values,omitempty"`
// reserve names a declaration directive whose integer arguments are
// numbers the structure's fields may not take: allocation passes over
// them, and a pin on one is refused. Its other arguments are ignored.
Reserve string `protobuf:"bytes,3,opt,name=reserve" json:"reserve,omitempty"`
// inline names a field directive that numbers the variants of the
// field's enum in the field's own space, in place of the field.
Inline string `protobuf:"bytes,4,opt,name=inline" json:"inline,omitempty"`
// contains filtered or unexported fields
}
Numbering is the rules a backend numbers members by. Numbers start at 1; a `number` directive pins one, and each other member, in declaration order, takes the lowest number no pin or earlier member holds and the rules allow.
func (*Numbering) Descriptor
deprecated
added in
v0.4.12
func (*Numbering) GetFields ¶ added in v0.4.12
func (x *Numbering) GetFields() *NumberRule
func (*Numbering) GetReserve ¶ added in v0.4.12
func (*Numbering) GetValues ¶ added in v0.4.12
func (x *Numbering) GetValues() *NumberRule
func (*Numbering) ProtoMessage ¶ added in v0.4.12
func (*Numbering) ProtoMessage()
func (*Numbering) ProtoReflect ¶ added in v0.4.12
func (x *Numbering) ProtoReflect() protoreflect.Message
type Placement ¶ added in v0.4.11
type Placement int32
Placement is a kind of node a directive lands on.
const ( Placement_PLACEMENT_UNSPECIFIED Placement = 0 // The target block itself. Placement_PLACEMENT_BLOCK Placement = 1 Placement_PLACEMENT_DECL Placement = 2 // A field of a declaration or of a variant. Placement_PLACEMENT_FIELD Placement = 3 Placement_PLACEMENT_VARIANT Placement = 4 Placement_PLACEMENT_EXTERN Placement = 5 )
func On ¶ added in v0.4.11
On lists placements for a DirectiveSpec.
func OnMembers ¶ added in v0.4.11
func OnMembers() []Placement
OnMembers is where a name for a declaration, a field, or a variant goes.
func (Placement) Descriptor ¶ added in v0.4.11
func (Placement) Descriptor() protoreflect.EnumDescriptor
func (Placement) EnumDescriptor
deprecated
added in
v0.4.11
func (Placement) Number ¶ added in v0.4.11
func (x Placement) Number() protoreflect.EnumNumber
func (Placement) Type ¶ added in v0.4.11
func (Placement) Type() protoreflect.EnumType
type Refusal ¶ added in v0.4.10
type Refusal struct {
Reason Refusal_Reason `protobuf:"varint,1,opt,name=reason,enum=tdl.plugin.v1.Refusal_Reason" json:"reason,omitempty"`
// subject is the name the message is about: the declaration, the type
// parameter, or the constructor that did not resolve.
Subject string `protobuf:"bytes,2,opt,name=subject" json:"subject,omitempty"`
Position *ir.Position `protobuf:"bytes,3,opt,name=position" json:"position,omitempty"`
// contains filtered or unexported fields
}
Refusal says why a type is one no schema backend writes. Each backend words the message, since some name the target language.
func (*Refusal) Descriptor
deprecated
added in
v0.4.10
func (*Refusal) GetPosition ¶ added in v0.4.10
func (*Refusal) GetReason ¶ added in v0.4.10
func (x *Refusal) GetReason() Refusal_Reason
func (*Refusal) GetSubject ¶ added in v0.4.10
func (*Refusal) ProtoMessage ¶ added in v0.4.10
func (*Refusal) ProtoMessage()
func (*Refusal) ProtoReflect ¶ added in v0.4.10
func (x *Refusal) ProtoReflect() protoreflect.Message
type Refusal_Reason ¶ added in v0.4.10
type Refusal_Reason int32
const ( Refusal_REASON_UNSPECIFIED Refusal_Reason = 0 // REASON_UNRESOLVED is a constructor naming no declaration. Refusal_REASON_UNRESOLVED Refusal_Reason = 1 // REASON_PARAM is a type parameter. Refusal_REASON_PARAM Refusal_Reason = 2 // REASON_UNIT is a unit of measure used as a type. Refusal_REASON_UNIT Refusal_Reason = 3 // REASON_CLASS is a class used as a type. Refusal_REASON_CLASS Refusal_Reason = 4 // REASON_UNIT_DECL is a declared unit used as a type. Refusal_REASON_UNIT_DECL Refusal_Reason = 5 // REASON_TYPE_ARGS is a declaration applied to type arguments. Refusal_REASON_TYPE_ARGS Refusal_Reason = 6 // REASON_MISSING_ARG is a list, set, or map missing a type argument. // The arguments before it are still set. Refusal_REASON_MISSING_ARG Refusal_Reason = 7 )
func (Refusal_Reason) Descriptor ¶ added in v0.4.10
func (Refusal_Reason) Descriptor() protoreflect.EnumDescriptor
func (Refusal_Reason) Enum ¶ added in v0.4.10
func (x Refusal_Reason) Enum() *Refusal_Reason
func (Refusal_Reason) EnumDescriptor
deprecated
added in
v0.4.10
func (Refusal_Reason) EnumDescriptor() ([]byte, []int)
Deprecated: Use Refusal_Reason.Descriptor instead.
func (Refusal_Reason) Number ¶ added in v0.4.10
func (x Refusal_Reason) Number() protoreflect.EnumNumber
func (Refusal_Reason) String ¶ added in v0.4.10
func (x Refusal_Reason) String() string
func (Refusal_Reason) Type ¶ added in v0.4.10
func (Refusal_Reason) Type() protoreflect.EnumType
type Request ¶
type Request struct {
// target names the block being served. A backend keeps the directives
// tagged with this name.
Target string `protobuf:"bytes,1,opt,name=target" json:"target,omitempty"`
// model is one package, with the prelude's declarations merged into it.
Model *ir.Model `protobuf:"bytes,2,opt,name=model" json:"model,omitempty"`
// out is the directory the response's paths are relative to.
Out string `protobuf:"bytes,3,opt,name=out" json:"out,omitempty"`
// dry_run says tdl will diff the response against disk rather than
// write it. A backend may skip work that cannot affect the files; ignoring
// the flag is correct.
DryRun bool `protobuf:"varint,4,opt,name=dry_run,json=dryRun" json:"dry_run,omitempty"`
// analysis is what tdl derives from the model for this target, so a
// plugin in any language reads it rather than computing it.
Analysis *Analysis `protobuf:"bytes,5,opt,name=analysis" json:"analysis,omitempty"`
// contains filtered or unexported fields
}
Request is everything a backend needs for one generation. Nothing travels in argv or environment variables.
func (*Request) Descriptor
deprecated
func (*Request) GetAnalysis ¶ added in v0.4.10
func (*Request) ProtoMessage ¶
func (*Request) ProtoMessage()
func (*Request) ProtoReflect ¶
func (x *Request) ProtoReflect() protoreflect.Message
type Response ¶
type Response struct {
Files []*File `protobuf:"bytes,1,rep,name=files" json:"files,omitempty"`
// post names commands to run over the written files, by name only. The
// project decides what a name maps to; a name it has not declared is
// skipped with a warning.
Post []string `protobuf:"bytes,2,rep,name=post" json:"post,omitempty"`
Diagnostics []*Diagnostic `protobuf:"bytes,3,rep,name=diagnostics" json:"diagnostics,omitempty"`
// contains filtered or unexported fields
}
Response is what a backend returns: file contents, which tdl writes, so tdl enforces path confinement, --verify, and --clean.
func (*Response) Descriptor
deprecated
func (*Response) GetDiagnostics ¶
func (x *Response) GetDiagnostics() []*Diagnostic
func (*Response) ProtoMessage ¶
func (*Response) ProtoMessage()
func (*Response) ProtoReflect ¶
func (x *Response) ProtoReflect() protoreflect.Message
type Severity ¶
type Severity int32
Severity is how much a diagnostic matters.
func (Severity) Descriptor ¶
func (Severity) Descriptor() protoreflect.EnumDescriptor
func (Severity) EnumDescriptor
deprecated
func (Severity) Number ¶
func (x Severity) Number() protoreflect.EnumNumber
func (Severity) Type ¶
func (Severity) Type() protoreflect.EnumType
type TypeView ¶ added in v0.4.10
type TypeView struct {
Form Form `protobuf:"varint,1,opt,name=form,enum=tdl.plugin.v1.Form" json:"form,omitempty"`
// id is this entry after alias expansion: the entry itself unless its
// constructor is an alias.
Id *ir.ID `protobuf:"bytes,2,opt,name=id" json:"id,omitempty"`
// name is the primitive's name, or the type parameter's.
Name string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"`
// elem is the element of a list or a set, the value of a map, and what
// an option or a nullable wraps.
Elem *ir.ID `protobuf:"bytes,4,opt,name=elem" json:"elem,omitempty"`
// key is the key of a map.
Key *ir.ID `protobuf:"bytes,5,opt,name=key" json:"key,omitempty"`
// decl is the declaration, for FORM_NAMED; it indexes Model.decls.
Decl *ir.ID `protobuf:"bytes,6,opt,name=decl" json:"decl,omitempty"`
// extern indexes Model.externs, for FORM_EXTERN.
Extern *ir.ID `protobuf:"bytes,7,opt,name=extern" json:"extern,omitempty"`
// refusal is set when this type is one no schema backend writes. A
// backend with generics or units reads the form and may ignore it. A
// refusal of an element or a key is on that entry, not this one.
Refusal *Refusal `protobuf:"bytes,8,opt,name=refusal" json:"refusal,omitempty"`
// references are the declarations this type names, through its
// arguments, with aliases expanded, in the order they are first named.
References []*ir.ID `protobuf:"bytes,9,rep,name=references" json:"references,omitempty"`
// contains filtered or unexported fields
}
TypeView is one entry of the type table, resolved.
An entry whose constructor is an alias is described as the type the alias expands to, and id names that entry. elem and key are expanded the same way.
func (*TypeView) Descriptor
deprecated
added in
v0.4.10
func (*TypeView) GetReferences ¶ added in v0.4.10
func (*TypeView) GetRefusal ¶ added in v0.4.10
func (*TypeView) ProtoMessage ¶ added in v0.4.10
func (*TypeView) ProtoMessage()
func (*TypeView) ProtoReflect ¶ added in v0.4.10
func (x *TypeView) ProtoReflect() protoreflect.Message