generated from TBD54566975/tbd-project-template
/
config.go
43 lines (33 loc) 路 1.03 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package schema
import (
"fmt"
"google.golang.org/protobuf/reflect/protoreflect"
schemapb "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/schema"
)
type Config struct {
Pos Position `parser:"" protobuf:"1,optional"`
Name string `parser:"'config' @Ident" protobuf:"2"`
Type Type `parser:"@@" protobuf:"3"`
}
var _ Decl = (*Config)(nil)
var _ Symbol = (*Config)(nil)
func (s *Config) GetName() string { return s.Name }
func (s *Config) Position() Position { return s.Pos }
func (s *Config) String() string { return fmt.Sprintf("config %s %s", s.Name, s.Type) }
func (s *Config) ToProto() protoreflect.ProtoMessage {
return &schemapb.Config{
Pos: posToProto(s.Pos),
Name: s.Name,
Type: typeToProto(s.Type),
}
}
func (s *Config) schemaChildren() []Node { return []Node{s.Type} }
func (s *Config) schemaDecl() {}
func (s *Config) schemaSymbol() {}
func ConfigFromProto(p *schemapb.Config) *Config {
return &Config{
Pos: posFromProto(p.Pos),
Name: p.Name,
Type: typeToSchema(p.Type),
}
}