Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement proper support for scalar or "discriminated" disjunctions in Go jenny #19

Merged
merged 17 commits into from
Sep 21, 2023
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
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ linters:
- gocognit
- gomnd
- tagliatelle
- nlreturn
# deprecated
- deadcode
- scopelint
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.21

require (
cuelang.org/go v0.5.0
github.com/google/go-cmp v0.5.9
github.com/grafana/codejen v0.0.4-0.20221122220907-a5e7cc5407b3
github.com/grafana/kindsys v0.0.0-20230615185749-1424263c17c7
github.com/grafana/thema v0.0.0-20230628103417-8f63313207a5
Expand All @@ -24,7 +25,6 @@ require (
github.com/emicklei/proto v1.11.2 // indirect
github.com/getsentry/sentry-go v0.22.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
Expand Down
6 changes: 3 additions & 3 deletions internal/ast/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type Assignment struct {
Constraints []TypeConstraint

// Some more context on the what
IntoOptionalField bool
IntoNullableField bool
}

type BuilderGenerator struct {
Expand Down Expand Up @@ -106,7 +106,7 @@ func (generator *BuilderGenerator) structFieldToStaticInitialization(field Struc
Path: field.Name,
Value: field.Type.AsScalar().Value,
ValueType: field.Type,
IntoOptionalField: !field.Required,
IntoNullableField: field.Type.Nullable,
}
}

Expand All @@ -131,7 +131,7 @@ func (generator *BuilderGenerator) structFieldToOption(field StructField) Option
ArgumentName: field.Name,
ValueType: field.Type,
Constraints: constraints,
IntoOptionalField: !field.Required,
IntoNullableField: field.Type.Nullable,
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion internal/ast/compiler/anonymous_enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (pass *AnonymousEnumToExplicitType) processStruct(def ast.StructType) ast.T
})
}

return ast.NewStruct(processedFields)
return ast.NewStruct(processedFields...)
}

func (pass *AnonymousEnumToExplicitType) processAnonymousEnum(parentName string, def ast.EnumType) ast.Type {
Expand Down
Loading