Skip to content

codegen: add some type aliases so that the domain-specific code can avoid referencing the overflow namespace #275

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

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Changes from 1 commit
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
23 changes: 23 additions & 0 deletions codegen/src/main/scala/overflowdb/codegen/CodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,29 @@ class CodeGen(schema: Schema) {
val srcFile = nodeType.className + ".scala"
results.append(baseDir.createChild(srcFile).write(src))
}


val packageObject = {
val lastSeparatorIdx = basePackage.lastIndexOf('.')
val packageParent = basePackage.take(lastSeparatorIdx)
val packageSimpleName = basePackage.drop(lastSeparatorIdx + 1)

s"""package $packageParent
|
|package object $packageSimpleName {
| // some type aliases so that the domain-specific code can avoid referencing the `overflowdb` namespace
| type DiffGraphBuilder = _root_.overflowdb.BatchedUpdate.DiffGraphBuilder
|
| object help {
| type Doc = _root_.overflowdb.traversal.help.Doc
| type Traversal = _root_.overflowdb.traversal.help.Traversal
| type TraversalSource = _root_.overflowdb.traversal.help.TraversalSource
| }
|}
|""".stripMargin
}
results.append(baseDir.createChild("package.scala").write(packageObject))

results.toSeq
}

Expand Down
Loading