Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
322 changes: 207 additions & 115 deletions gen/j5/ext/v1/ext_j5pb/annotations.pb.go

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions gen/j5/ext/v1/ext_j5pb/annotations_j5.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

781 changes: 424 additions & 357 deletions gen/j5/schema/v1/schema_j5pb/schema.pb.go

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions gen/j5/schema/v1/schema_j5pb/schema_j5.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions internal/bcl/internal/walker/walk_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func (sc *walkContext) setAttribute(path ScopePath, val parser.ASTValue, appendV
func (sc *walkContext) setContainerFromScalar(bs schema.BlockSpec, val parser.ASTValue) error {
ss := bs.ScalarSplit
if ss == nil {
return fmt.Errorf("container %s has no method to set from array", bs.ErrName())
return fmt.Errorf("container %s has no method to set from scalar", bs.ErrName())
}

var setVals []parser.ASTValue
Expand All @@ -301,7 +301,8 @@ func (sc *walkContext) setContainerFromScalar(bs schema.BlockSpec, val parser.AS
} else {
vals, isArray := val.AsArray()
if !isArray {
return fmt.Errorf("container %s requires an array when setting from value, got a scalar", bs.ErrName())
sc.Logf("ScalarSplit with no delimiter requires array, got %#v", val)
return fmt.Errorf("container %s is ScalarSplit with no delimiter, must be set from an array", bs.ErrName())
}
setVals = vals
}
Expand Down
53 changes: 22 additions & 31 deletions internal/gen/j5/registry/v1/registry_spb/build.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions internal/j5s/j5convert/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,37 @@ func buildField(ww *conversionVisitor, node sourcewalk.FieldNode) (*descriptorpb
Pattern: ff.Custom.Pattern,
}

if ff.Custom.Description != "" {
keyExt.PatternInfo = &ext_j5pb.KeyField_PatternInfo{
Description: gl.Ptr(ff.Custom.Description),
}
}

case *schema_j5pb.KeyFormat_Named_:
ref := ff.Named.Ref

typeRef, err := ww.resolveType(&sourcewalk.RefNode{
Source: node.Source,
Ref: ref,
})
if err != nil {
return nil, fmt.Errorf("string format %s: %w", ref, err)
}

if typeRef.StringFormat == nil {
return nil, fmt.Errorf("%s refers to a %s, not a string format", ref, typeRef.debugName())
}

keyExt.Type = &ext_j5pb.KeyField_Pattern{
Pattern: typeRef.StringFormat.Regex,
}
keyExt.PatternInfo = &ext_j5pb.KeyField_PatternInfo{
Name: gl.Ptr(fmt.Sprintf("%s.%s", typeRef.Package, typeRef.Name)),
}
if typeRef.StringFormat.Description != "" {
keyExt.PatternInfo.Description = gl.Ptr(typeRef.StringFormat.Description)
}

case *schema_j5pb.KeyFormat_Informal_:

default:
Expand Down
10 changes: 10 additions & 0 deletions internal/j5s/j5convert/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,16 @@ func (cc *summaryWalker) collectFileRefs(sourceFile *sourcedef_j5pb.SourceFile)
Ref: ref,
})
}

case *schema_j5pb.Field_Key:
if st.Key.Format != nil {
if named := st.Key.Format.GetNamed(); named != nil {
cc.addRef(&sourcewalk.RefNode{
Source: node.Source,
Ref: named.Ref,
})
}
}
}

return nil
Expand Down
11 changes: 11 additions & 0 deletions proto/core/j5/ext/v1/annotations.proto
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,15 @@ message KeyField {
FORMAT_ID62 = 3;
}
j5.schema.v1.EntityRef foreign = 3;

// Set when the pattern is annotated
PatternInfo patternInfo = 10;

message PatternInfo {
// The full type name of a namedPattern.
optional string name = 1;

// Description given either in the namedPattern or inline for custom
optional string description = 2;
}
}
13 changes: 12 additions & 1 deletion proto/core/j5/schema/v1/schema.proto
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ message KeyFormat {
Custom custom = 2;
UUID uuid = 3;
ID62 id62 = 4;
StringFormat format = 5;
Named named = 5;
}

message Informal {}
Expand All @@ -401,6 +401,17 @@ message KeyFormat {
}
message UUID {}
message ID62 {}
message Named {
Ref ref = 1;

option (j5.bcl.v1.block).qualifier.field_name = "ref";

option (j5.bcl.v1.block).scalar_split = {
right_to_left: true
required_fields: [{path: "schema"}]
remainder_field: {path: "package"}
};
}

option (j5.bcl.v1.block).type_select = {
field_name: "."
Expand Down