generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
metadatadatabases.go
56 lines (47 loc) · 1.16 KB
/
metadatadatabases.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
44
45
46
47
48
49
50
51
52
53
54
55
56
package schema
import (
"fmt"
"strings"
"google.golang.org/protobuf/proto"
schemapb "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/schema"
)
type MetadataDatabases struct {
Pos Position `parser:"" protobuf:"1,optional"`
Calls []*Ref `parser:"'+' 'database' 'calls' @@ (',' @@)*" protobuf:"2"`
}
var _ Metadata = (*MetadataDatabases)(nil)
func (m *MetadataDatabases) Position() Position { return m.Pos }
func (m *MetadataDatabases) String() string {
out := &strings.Builder{}
fmt.Fprint(out, "+database calls ")
w := 6
for i, call := range m.Calls {
if i > 0 {
fmt.Fprint(out, ", ")
w += 2
}
str := call.String()
if w+len(str) > 70 {
w = 6
fmt.Fprint(out, "\n ")
}
w += len(str)
fmt.Fprint(out, str)
}
fmt.Fprint(out)
return out.String()
}
func (m *MetadataDatabases) schemaChildren() []Node {
out := make([]Node, 0, len(m.Calls))
for _, ref := range m.Calls {
out = append(out, ref)
}
return out
}
func (*MetadataDatabases) schemaMetadata() {}
func (m *MetadataDatabases) ToProto() proto.Message {
return &schemapb.MetadataDatabases{
Pos: posToProto(m.Pos),
Calls: nodeListToProto[*schemapb.Ref](m.Calls),
}
}