Skip to content

Commit

Permalink
fix: update type spacing rules (#2874)
Browse files Browse the repository at this point in the history
Fixes: #2803

Also fixed a separate issue where one of the decl types configured for
the filter had the wrong display name.
  • Loading branch information
deniseli authored Sep 27, 2024
1 parent 67f2db1 commit 102c6ee
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 16 deletions.
4 changes: 1 addition & 3 deletions backend/schema/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ func (m *Module) String() string {
reflect.TypeOf(&Database{}): {gapWithinType: false},
reflect.TypeOf(&Topic{}): {gapWithinType: false},
reflect.TypeOf(&Subscription{}): {gapWithinType: false, skipGapAfterTypes: []reflect.Type{reflect.TypeOf(&Topic{})}},
reflect.TypeOf(&Enum{}): {gapWithinType: true},
reflect.TypeOf(&Data{}): {gapWithinType: true},
reflect.TypeOf(&Verb{}): {gapWithinType: true},
reflect.TypeOf(&TypeAlias{}): {gapWithinType: false},
}

lastTypePrinted := optional.None[reflect.Type]()
Expand Down
4 changes: 2 additions & 2 deletions frontend/console/src/features/modules/schema/schema.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const declTypeMultiselectOpts = [
},
{
key: 'secret',
displayName: 'FSM',
displayName: 'Secret',
},
{
key: 'subscription',
Expand All @@ -51,7 +51,7 @@ export const declTypeMultiselectOpts = [
]

// Keep these in sync with backend/schema/module.go#L86-L95
const skipNewLineDeclTypes = ['config', 'secret', 'database', 'topic', 'subscription']
const skipNewLineDeclTypes = ['config', 'secret', 'database', 'topic', 'subscription', 'typealias']
const skipGapAfterTypes: { [key: string]: string[] } = {
secret: ['config'],
subscription: ['topic'],
Expand Down
3 changes: 0 additions & 3 deletions go-runtime/schema/schema_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,8 @@ module test {
subscription subscription test.topic
typealias Alias {{.TypeName}}
typealias EqualAlias {{.TypeName}}
export typealias ExportedAlias {{.TypeName}}
export typealias ExportedEqualAlias {{.TypeName}}
{{.ValueEnum}}{{.TypeEnum}}
data Data {
Expand Down
8 changes: 0 additions & 8 deletions go-runtime/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,20 +197,15 @@ func TestExtractModuleSchemaTwo(t *testing.T) {
expected := `module two {
typealias BackoffAlias Any
+typemap go "github.com/jpillora/backoff.Backoff"
typealias ExplicitAliasAlias Any
+typemap kotlin "com.foo.bar.NonFTLType"
+typemap go "github.com/TBD54566975/ftl/go-runtime/schema/testdata.lib.NonFTLType"
typealias ExplicitAliasType Any
+typemap kotlin "com.foo.bar.NonFTLType"
+typemap go "github.com/TBD54566975/ftl/go-runtime/schema/testdata.lib.NonFTLType"
typealias PaymentState String
typealias TransitiveAliasAlias Any
+typemap go "github.com/TBD54566975/ftl/go-runtime/schema/testdata.lib.NonFTLType"
typealias TransitiveAliasType Any
+typemap go "github.com/TBD54566975/ftl/go-runtime/schema/testdata.lib.NonFTLType"
Expand Down Expand Up @@ -356,12 +351,9 @@ func TestExtractModuleSchemaNamedTypes(t *testing.T) {
actual := schema.Normalise(r.Module)
expected := `module named {
typealias DoubleAliasedUser named.InternalUser
// ID testing if typealias before struct works
export typealias Id String
typealias InternalUser named.User
// Name testing if typealias after struct works
export typealias Name String
Expand Down

0 comments on commit 102c6ee

Please sign in to comment.