Skip to content

Commit 2b52f37

Browse files
committed
codegen: add some type aliases so that the domain-specific code can avoid referencing the overflow namespace
equivalent of joernio/flatgraph#217
1 parent 0b2fa88 commit 2b52f37

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

codegen/src/main/scala/overflowdb/codegen/CodeGen.scala

+23
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,29 @@ class CodeGen(schema: Schema) {
12591259
val srcFile = nodeType.className + ".scala"
12601260
results.append(baseDir.createChild(srcFile).write(src))
12611261
}
1262+
1263+
1264+
val packageObject = {
1265+
val lastSeparatorIdx = basePackage.lastIndexOf('.')
1266+
val packageParent = basePackage.take(lastSeparatorIdx)
1267+
val packageSimpleName = basePackage.drop(lastSeparatorIdx + 1)
1268+
1269+
s"""package $packageParent
1270+
|
1271+
|package object $packageSimpleName {
1272+
| // some type aliases so that the domain-specific code can avoid referencing the `overflowdb` namespace
1273+
| type DiffGraphBuilder = _root_.overflowdb.BatchedUpdate.DiffGraphBuilder
1274+
|
1275+
| object help {
1276+
| type Doc = _root_.overflowdb.traversal.help.Doc
1277+
| type Traversal = _root_.overflowdb.traversal.help.Traversal
1278+
| type TraversalSource = _root_.overflowdb.traversal.help.TraversalSource
1279+
| }
1280+
|}
1281+
|""".stripMargin
1282+
}
1283+
results.append(baseDir.createChild("package.scala").write(packageObject))
1284+
12621285
results.toSeq
12631286
}
12641287

0 commit comments

Comments
 (0)