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

fix: update type spacing rules #2874

Merged
merged 2 commits into from
Sep 27, 2024
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
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
Loading