Skip to content

Commit

Permalink
refactor(codegen): Port Kotlin codegen package to use plugin types (#…
Browse files Browse the repository at this point in the history
…1416)

In #1406 I ported the Python codegen to the new plugin package. This PR does the same for the Kotlin codegen.
  • Loading branch information
kyleconroy committed Feb 6, 2022
1 parent 6ceb473 commit c8926c2
Show file tree
Hide file tree
Showing 9 changed files with 392 additions and 286 deletions.
3 changes: 0 additions & 3 deletions Makefile
Expand Up @@ -30,9 +30,6 @@ psql:
mysqlsh:
mysqlsh --sql --user root --password mysecretpassword --database dinotest 127.0.0.1:3306

fmt:
go fmt ./...

# $ protoc --version
# libprotoc 3.17.3
# go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/generate.go
Expand Up @@ -196,7 +196,7 @@ func Generate(ctx context.Context, e Env, dir, filename string, stderr io.Writer
files, err = golang.Generate(result, combo)
case sql.Gen.Kotlin != nil:
out = combo.Kotlin.Out
files, err = kotlin.Generate(result, combo)
resp, err = kotlin.Generate(codeGenRequest(result, combo))
case sql.Gen.Python != nil:
out = combo.Python.Out
resp, err = python.Generate(codeGenRequest(result, combo))
Expand Down
9 changes: 9 additions & 0 deletions internal/cmd/shim.go
Expand Up @@ -55,6 +55,7 @@ func pluginSettings(cs config.CombinedSettings) *plugin.Settings {
Overrides: over,
Rename: cs.Rename,
Python: pluginPythonCode(cs.Python),
Kotlin: pluginKotlinCode(cs.Kotlin),
}
}

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

func pluginKotlinCode(s config.SQLKotlin) *plugin.KotlinCode {
return &plugin.KotlinCode{
Out: s.Out,
Package: s.Package,
EmitExactTableNames: s.EmitExactTableNames,
}
}

func pluginCatalog(c *catalog.Catalog) *plugin.Catalog {
var schemas []*plugin.Schema
for _, s := range c.Schemas {
Expand Down

0 comments on commit c8926c2

Please sign in to comment.