Skip to content

Commit

Permalink
chore(deps): bump go.einride.tech/sage from 0.264.0 to 0.272.0 in /.sage
Browse files Browse the repository at this point in the history
Bumps [go.einride.tech/sage](https://github.com/einride/sage) from 0.264.0 to 0.272.0.
- [Release notes](https://github.com/einride/sage/releases)
- [Commits](einride/sage@v0.264.0...v0.272.0)

---
updated-dependencies:
- dependency-name: go.einride.tech/sage
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
  • Loading branch information
dependabot[bot] authored and quoral committed Mar 4, 2024
1 parent b5bce22 commit 47dc1ad
Show file tree
Hide file tree
Showing 22 changed files with 105 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .sage/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module sage

go 1.19

require go.einride.tech/sage v0.264.0
require go.einride.tech/sage v0.272.0
4 changes: 2 additions & 2 deletions .sage/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
go.einride.tech/sage v0.264.0 h1:NuEefbHh89txKXhVLcn70y1M2dY+eJw9cjLeousZefs=
go.einride.tech/sage v0.264.0/go.mod h1:EzV5uciFX7/2ho8EKB5K9JghOfXIxlzs694b+Tkl5GQ=
go.einride.tech/sage v0.272.0 h1:NxK2zVtsYJn9Wwp//Tz5gmQsiVwT0uXLkau5WJnnXR8=
go.einride.tech/sage v0.272.0/go.mod h1:EzV5uciFX7/2ho8EKB5K9JghOfXIxlzs694b+Tkl5GQ=
26 changes: 13 additions & 13 deletions cmd/protoc-gen-go-aip/internal/genaip/resourcename.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ type resourceNameCodeGenerator struct {
}

func (r resourceNameCodeGenerator) GenerateCode(g *protogen.GeneratedFile) error {
if len(r.resource.Pattern) == 0 {
if len(r.resource.GetPattern()) == 0 {
return nil
}
hasMultiPattern := len(r.resource.Pattern) > 1
hasFutureMultiPattern := r.resource.History == annotations.ResourceDescriptor_FUTURE_MULTI_PATTERN
hasMultiPattern := len(r.resource.GetPattern()) > 1
hasFutureMultiPattern := r.resource.GetHistory() == annotations.ResourceDescriptor_FUTURE_MULTI_PATTERN
// Generate multi-pattern interface and parse methods if we have multiple patterns now or in the future.
if hasMultiPattern || hasFutureMultiPattern {
if err := r.generateMultiPatternInterface(g); err != nil {
Expand All @@ -35,7 +35,7 @@ func (r resourceNameCodeGenerator) GenerateCode(g *protogen.GeneratedFile) error
}

// Generate the single-pattern struct unless we explicitly only want multi-patterns from the start.
firstPattern := r.resource.Pattern[0]
firstPattern := r.resource.GetPattern()[0]
shouldGenerateSinglePatternStruct := !hasFutureMultiPattern
firstSinglePatternStructName := r.SinglePatternStructName()
if shouldGenerateSinglePatternStruct {
Expand All @@ -59,7 +59,7 @@ func (r resourceNameCodeGenerator) GenerateCode(g *protogen.GeneratedFile) error
}
}
// Generate multi-pattern structs for all but the first pattern.
for _, pattern := range r.resource.Pattern[1:] {
for _, pattern := range r.resource.GetPattern()[1:] {
if err := r.generatePatternStruct(g, pattern, r.MultiPatternStructName(pattern)); err != nil {
return err
}
Expand Down Expand Up @@ -136,7 +136,7 @@ func (r *resourceNameCodeGenerator) generateParentConstructorMethod(
parent *annotations.ResourceDescriptor,
) error {
var parentPattern string
for _, parentCandidate := range parent.Pattern {
for _, parentCandidate := range parent.GetPattern() {
if resourcename.HasParent(pattern, parentCandidate) {
parentPattern = parentCandidate
break
Expand Down Expand Up @@ -193,7 +193,7 @@ func (r *resourceNameCodeGenerator) generateParentMethod(
parent *annotations.ResourceDescriptor,
) error {
var parentPattern string
for _, parentCandidate := range parent.Pattern {
for _, parentCandidate := range parent.GetPattern() {
if resourcename.HasParent(pattern, parentCandidate) {
parentPattern = parentCandidate
break
Expand Down Expand Up @@ -370,7 +370,7 @@ func (r *resourceNameCodeGenerator) generateMultiPatternParseMethod(g *protogen.
g.P()
g.P("func Parse", r.MultiPatternInterfaceName(), "(name string) (", r.MultiPatternInterfaceName(), ", error) {")
g.P("switch {")
for _, pattern := range r.resource.Pattern {
for _, pattern := range r.resource.GetPattern() {
g.P("case ", resourcenameMatch, "(", strconv.Quote(pattern), ", name):")
g.P("var result ", r.MultiPatternStructName(pattern))
g.P("return &result, result.UnmarshalString(name)")
Expand All @@ -383,14 +383,14 @@ func (r *resourceNameCodeGenerator) generateMultiPatternParseMethod(g *protogen.
}

func (r *resourceNameCodeGenerator) SinglePatternStructName() string {
return aipreflect.ResourceType(r.resource.Type).Type() + "ResourceName"
return aipreflect.ResourceType(r.resource.GetType()).Type() + "ResourceName"
}

func (r *resourceNameCodeGenerator) StructName(pattern string) string {
if r.resource.History == annotations.ResourceDescriptor_FUTURE_MULTI_PATTERN || len(r.resource.Pattern) > 1 {
if r.resource.GetHistory() == annotations.ResourceDescriptor_FUTURE_MULTI_PATTERN || len(r.resource.GetPattern()) > 1 {
return r.MultiPatternStructName(pattern)
}
if r.resource.Pattern[0] == pattern {
if r.resource.GetPattern()[0] == pattern {
return r.SinglePatternStructName()
}
return r.MultiPatternStructName(pattern)
Expand All @@ -401,7 +401,7 @@ func (r *resourceNameCodeGenerator) MultiPatternStructName(pattern string) strin
var sc resourcename.Scanner
sc.Init(pattern)
for sc.Scan() {
if !sc.Segment().IsVariable() && string(sc.Segment().Literal()) != r.resource.Plural {
if !sc.Segment().IsVariable() && string(sc.Segment().Literal()) != r.resource.GetPlural() {
_, _ = result.WriteString(strcase.UpperCamelCase(string(sc.Segment().Literal())))
}
}
Expand All @@ -410,5 +410,5 @@ func (r *resourceNameCodeGenerator) MultiPatternStructName(pattern string) strin
}

func (r *resourceNameCodeGenerator) MultiPatternInterfaceName() string {
return aipreflect.ResourceType(r.resource.Type).Type() + "MultiPatternResourceName"
return aipreflect.ResourceType(r.resource.GetType()).Type() + "MultiPatternResourceName"
}
2 changes: 1 addition & 1 deletion fieldbehavior/fieldbehavior.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func clearFieldsWithBehaviors(m proto.Message, behaviorsToClear ...annotations.F
rangeFieldsWithBehaviors(m, func(
m protoreflect.Message,
f protoreflect.FieldDescriptor,
v protoreflect.Value,
_ protoreflect.Value,
behaviors []annotations.FieldBehavior,
) bool {
if hasAnyBehavior(behaviors, behaviorsToClear) {
Expand Down
6 changes: 3 additions & 3 deletions fieldbehavior/fieldbehavior_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ func TestClearFields(t *testing.T) {
DisplayName: "site one", // has REQUIRED field_behavior; should not be cleared.
}
ClearFields(site, annotations.FieldBehavior_OUTPUT_ONLY)
assert.Equal(t, site.CreateTime, (*timestamppb.Timestamp)(nil))
assert.Equal(t, site.DisplayName, "site one")
assert.Equal(t, site.Name, "site1")
assert.Equal(t, site.GetCreateTime(), (*timestamppb.Timestamp)(nil))
assert.Equal(t, site.GetDisplayName(), "site one")
assert.Equal(t, site.GetName(), "site1")
})
}

Expand Down
2 changes: 1 addition & 1 deletion fieldbehavior/immutable.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func validateImmutableFields(m protoreflect.Message, mask *fieldmaskpb.FieldMask
continue
}
var mapErr error
value.Map().Range(func(key protoreflect.MapKey, value protoreflect.Value) bool {
value.Map().Range(func(_ protoreflect.MapKey, value protoreflect.Value) bool {
if err := validateImmutableFields(value.Message(), mask, currPath); err != nil {
mapErr = err
return false
Expand Down
2 changes: 1 addition & 1 deletion fieldbehavior/required.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func validateRequiredFields(reflectMessage protoreflect.Message, mask *fieldmask
continue
}
var mapErr error
value.Map().Range(func(key protoreflect.MapKey, value protoreflect.Value) bool {
value.Map().Range(func(_ protoreflect.MapKey, value protoreflect.Value) bool {
if err := validateRequiredFields(value.Message(), mask, currPath); err != nil {
mapErr = err
return false
Expand Down
58 changes: 29 additions & 29 deletions filtering/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (c *Checker) Init(exp *expr.Expr, sourceInfo *expr.SourceInfo, declarations
expr: exp,
declarations: declarations,
sourceInfo: sourceInfo,
typeMap: make(map[int64]*expr.Type, len(sourceInfo.Positions)),
typeMap: make(map[int64]*expr.Type, len(sourceInfo.GetPositions())),
}
}

Expand All @@ -46,9 +46,9 @@ func (c *Checker) checkExpr(e *expr.Expr) error {
if e == nil {
return nil
}
switch e.ExprKind.(type) {
switch e.GetExprKind().(type) {
case *expr.Expr_ConstExpr:
switch e.GetConstExpr().ConstantKind.(type) {
switch e.GetConstExpr().GetConstantKind().(type) {
case *expr.Constant_BoolValue:
return c.checkBoolLiteral(e)
case *expr.Constant_DoubleValue:
Expand Down Expand Up @@ -95,17 +95,17 @@ func (c *Checker) checkSelectExpr(e *expr.Expr) (err error) {
}
}
selectExpr := e.GetSelectExpr()
if selectExpr.Operand == nil {
if selectExpr.GetOperand() == nil {
return c.errorf(e, "missing operand")
}
if err := c.checkExpr(selectExpr.Operand); err != nil {
if err := c.checkExpr(selectExpr.GetOperand()); err != nil {
return err
}
operandType, ok := c.getType(selectExpr.Operand)
operandType, ok := c.getType(selectExpr.GetOperand())
if !ok {
return c.errorf(e, "failed to get operand type")
}
switch operandType.TypeKind.(type) {
switch operandType.GetTypeKind().(type) {
case *expr.Type_MapType_:
return c.setType(e, operandType.GetMapType().GetValueType())
default:
Expand All @@ -125,9 +125,9 @@ func (c *Checker) checkCallExpr(e *expr.Expr) (err error) {
return err
}
}
functionDeclaration, ok := c.declarations.LookupFunction(callExpr.Function)
functionDeclaration, ok := c.declarations.LookupFunction(callExpr.GetFunction())
if !ok {
return c.errorf(e, "undeclared function '%s'", callExpr.Function)
return c.errorf(e, "undeclared function '%s'", callExpr.GetFunction())
}
functionOverload, err := c.resolveCallExprFunctionOverload(e, functionDeclaration)
if err != nil {
Expand All @@ -136,7 +136,7 @@ func (c *Checker) checkCallExpr(e *expr.Expr) (err error) {
if err := c.checkCallExprBuiltinFunctionOverloads(e, functionOverload); err != nil {
return err
}
return c.setType(e, functionOverload.ResultType)
return c.setType(e, functionOverload.GetResultType())
}

func (c *Checker) resolveCallExprFunctionOverload(
Expand All @@ -145,15 +145,15 @@ func (c *Checker) resolveCallExprFunctionOverload(
) (*expr.Decl_FunctionDecl_Overload, error) {
callExpr := e.GetCallExpr()
for _, overload := range functionDeclaration.GetFunction().GetOverloads() {
if len(callExpr.GetArgs()) != len(overload.Params) {
if len(callExpr.GetArgs()) != len(overload.GetParams()) {
continue
}
if len(overload.TypeParams) == 0 {
if len(overload.GetTypeParams()) == 0 {
allTypesMatch := true
for i, param := range overload.Params {
argType, ok := c.getType(callExpr.Args[i])
for i, param := range overload.GetParams() {
argType, ok := c.getType(callExpr.GetArgs()[i])
if !ok {
return nil, c.errorf(callExpr.Args[i], "unknown type")
return nil, c.errorf(callExpr.GetArgs()[i], "unknown type")
}
if !proto.Equal(argType, param) {
allTypesMatch = false
Expand Down Expand Up @@ -183,17 +183,17 @@ func (c *Checker) checkCallExprBuiltinFunctionOverloads(
functionOverload *expr.Decl_FunctionDecl_Overload,
) error {
callExpr := e.GetCallExpr()
switch functionOverload.OverloadId {
switch functionOverload.GetOverloadId() {
case FunctionOverloadTimestampString:
if constExpr := callExpr.Args[0].GetConstExpr(); constExpr != nil {
if constExpr := callExpr.GetArgs()[0].GetConstExpr(); constExpr != nil {
if _, err := time.Parse(time.RFC3339, constExpr.GetStringValue()); err != nil {
return c.errorf(callExpr.Args[0], "invalid timestamp. Should be in RFC3339 format")
return c.errorf(callExpr.GetArgs()[0], "invalid timestamp. Should be in RFC3339 format")
}
}
case FunctionOverloadDurationString:
if constExpr := callExpr.Args[0].GetConstExpr(); constExpr != nil {
if constExpr := callExpr.GetArgs()[0].GetConstExpr(); constExpr != nil {
if _, err := time.ParseDuration(constExpr.GetStringValue()); err != nil {
return c.errorf(callExpr.Args[0], "invalid duration")
return c.errorf(callExpr.GetArgs()[0], "invalid duration")
}
}
case FunctionOverloadLessThanTimestampString,
Expand All @@ -202,9 +202,9 @@ func (c *Checker) checkCallExprBuiltinFunctionOverloads(
FunctionOverloadGreaterEqualsTimestampString,
FunctionOverloadEqualsTimestampString,
FunctionOverloadNotEqualsTimestampString:
if constExpr := callExpr.Args[1].GetConstExpr(); constExpr != nil {
if constExpr := callExpr.GetArgs()[1].GetConstExpr(); constExpr != nil {
if _, err := time.Parse(time.RFC3339, constExpr.GetStringValue()); err != nil {
return c.errorf(callExpr.Args[0], "invalid timestamp. Should be in RFC3339 format")
return c.errorf(callExpr.GetArgs()[0], "invalid timestamp. Should be in RFC3339 format")
}
}
}
Expand Down Expand Up @@ -243,34 +243,34 @@ func (c *Checker) wrapf(err error, _ *expr.Expr, format string, args ...interfac
}

func (c *Checker) setType(e *expr.Expr, t *expr.Type) error {
if existingT, ok := c.typeMap[e.Id]; ok && !proto.Equal(t, existingT) {
if existingT, ok := c.typeMap[e.GetId()]; ok && !proto.Equal(t, existingT) {
return c.errorf(e, "type conflict between %s and %s", t, existingT)
}
c.typeMap[e.Id] = t
c.typeMap[e.GetId()] = t
return nil
}

func (c *Checker) getType(e *expr.Expr) (*expr.Type, bool) {
t, ok := c.typeMap[e.Id]
t, ok := c.typeMap[e.GetId()]
if !ok {
return nil, false
}
return t, true
}

func toQualifiedName(e *expr.Expr) (string, bool) {
switch kind := e.ExprKind.(type) {
switch kind := e.GetExprKind().(type) {
case *expr.Expr_IdentExpr:
return kind.IdentExpr.GetName(), true
case *expr.Expr_SelectExpr:
if kind.SelectExpr.TestOnly {
if kind.SelectExpr.GetTestOnly() {
return "", false
}
parent, ok := toQualifiedName(kind.SelectExpr.Operand)
parent, ok := toQualifiedName(kind.SelectExpr.GetOperand())
if !ok {
return "", false
}
return parent + "." + kind.SelectExpr.Field, true
return parent + "." + kind.SelectExpr.GetField(), true
default:
return "", false
}
Expand Down
2 changes: 1 addition & 1 deletion filtering/checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ func TestChecker(t *testing.T) {
}
assert.NilError(t, err)
var checker Checker
checker.Init(parsedExpr.Expr, parsedExpr.SourceInfo, declarations)
checker.Init(parsedExpr.GetExpr(), parsedExpr.GetSourceInfo(), declarations)
checkedExpr, err := checker.Check()
if tt.errorContains != "" {
assert.ErrorContains(t, err, tt.errorContains)
Expand Down
6 changes: 3 additions & 3 deletions filtering/declarations.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ func (d *Declarations) declareFunction(name string, overloads ...*expr.Decl_Func
NewOverloadLoop:
for _, newOverload := range overloads {
for _, existingOverload := range function.GetOverloads() {
if newOverload.OverloadId == existingOverload.OverloadId {
if newOverload.GetOverloadId() == existingOverload.GetOverloadId() {
if !proto.Equal(newOverload, existingOverload) {
return fmt.Errorf("redeclaration of overload %s", existingOverload.OverloadId)
return fmt.Errorf("redeclaration of overload %s", existingOverload.GetOverloadId())
}
continue NewOverloadLoop
}
Expand All @@ -208,7 +208,7 @@ NewOverloadLoop:
}

func (d *Declarations) declare(decl *expr.Decl) error {
switch decl.DeclKind.(type) {
switch decl.GetDeclKind().(type) {
case *expr.Decl_Function:
return d.declareFunction(decl.GetName(), decl.GetFunction().GetOverloads()...)
case *expr.Decl_Ident:
Expand Down
6 changes: 3 additions & 3 deletions filtering/exprs/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func MatchAnyString(value *string) Matcher {
if cons == nil {
return false
}
if _, ok := cons.ConstantKind.(*expr.Constant_StringValue); !ok {
if _, ok := cons.GetConstantKind().(*expr.Constant_StringValue); !ok {
return false
}
*value = cons.GetStringValue()
Expand All @@ -50,7 +50,7 @@ func MatchAnyFloat(value *float64) Matcher {
if cons == nil {
return false
}
if _, ok := cons.ConstantKind.(*expr.Constant_DoubleValue); !ok {
if _, ok := cons.GetConstantKind().(*expr.Constant_DoubleValue); !ok {
return false
}
*value = cons.GetDoubleValue()
Expand All @@ -75,7 +75,7 @@ func MatchAnyInt(value *int64) Matcher {
if cons == nil {
return false
}
if _, ok := cons.ConstantKind.(*expr.Constant_Int64Value); !ok {
if _, ok := cons.GetConstantKind().(*expr.Constant_Int64Value); !ok {
return false
}
*value = cons.GetInt64Value()
Expand Down
Loading

0 comments on commit 47dc1ad

Please sign in to comment.