Skip to content

Commit c8926c2

Browse files
authored
refactor(codegen): Port Kotlin codegen package to use plugin types (#1416)
In #1406 I ported the Python codegen to the new plugin package. This PR does the same for the Kotlin codegen.
1 parent 6ceb473 commit c8926c2

File tree

9 files changed

+392
-286
lines changed

9 files changed

+392
-286
lines changed

Makefile

-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ psql:
3030
mysqlsh:
3131
mysqlsh --sql --user root --password mysecretpassword --database dinotest 127.0.0.1:3306
3232

33-
fmt:
34-
go fmt ./...
35-
3633
# $ protoc --version
3734
# libprotoc 3.17.3
3835
# go install google.golang.org/protobuf/cmd/protoc-gen-go@latest

internal/cmd/generate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func Generate(ctx context.Context, e Env, dir, filename string, stderr io.Writer
196196
files, err = golang.Generate(result, combo)
197197
case sql.Gen.Kotlin != nil:
198198
out = combo.Kotlin.Out
199-
files, err = kotlin.Generate(result, combo)
199+
resp, err = kotlin.Generate(codeGenRequest(result, combo))
200200
case sql.Gen.Python != nil:
201201
out = combo.Python.Out
202202
resp, err = python.Generate(codeGenRequest(result, combo))

internal/cmd/shim.go

+9
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func pluginSettings(cs config.CombinedSettings) *plugin.Settings {
5555
Overrides: over,
5656
Rename: cs.Rename,
5757
Python: pluginPythonCode(cs.Python),
58+
Kotlin: pluginKotlinCode(cs.Kotlin),
5859
}
5960
}
6061

@@ -75,6 +76,14 @@ func pluginPythonType(pt config.PythonType) *plugin.PythonType {
7576
}
7677
}
7778

79+
func pluginKotlinCode(s config.SQLKotlin) *plugin.KotlinCode {
80+
return &plugin.KotlinCode{
81+
Out: s.Out,
82+
Package: s.Package,
83+
EmitExactTableNames: s.EmitExactTableNames,
84+
}
85+
}
86+
7887
func pluginCatalog(c *catalog.Catalog) *plugin.Catalog {
7988
var schemas []*plugin.Schema
8089
for _, s := range c.Schemas {

0 commit comments

Comments
 (0)