Skip to content

Commit 6d04840

Browse files
Improved Determinism of NewNode (#237)
* Embed schema into `NewNode` object classes The idea behind this change is to provide the option of allowing frontend developers to catch invalid edge types early on instead of when the `DiffGraph` is atomically merged into the graph. Downstream, during development, we could have a validation flag on `X2Cpg` that would enable checks on `Ast` to validate neighbours as they are being set. * Made the new functions part of the `NewNode` interface and resulting implementations * Reverted Scala 3 imports * Fixed Scala 2 string interpolation by workaround * Including base types in valid neighbour calculations * Unpacking neighbor base types and using US spelling of neighbor * Update codegen/src/main/scala/overflowdb/codegen/CodeGen.scala Co-authored-by: Michael Pollmeier <[email protected]> * Improved determinism of `NewNode` with Sorting --------- Co-authored-by: Michael Pollmeier <[email protected]>
1 parent 7e939a6 commit 6d04840

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1841,7 +1841,7 @@ class CodeGen(schema: Schema) {
18411841
}.mkString(lineSeparator)
18421842

18431843
def neighborEdgeStr(es: Map[String, Set[String]]): String =
1844-
es.map { case (k, vs) => s"$k -> Set(${vs.mkString(", ")})" }.mkString(", ")
1844+
es.toSeq.sortBy(_._1).map { case (k, vs) => s"$k -> Set(${vs.toSeq.sorted.mkString(", ")})" }.mkString(", ")
18451845

18461846
s"""object $classNameNewNode {
18471847
| def apply(): $classNameNewNode = new $classNameNewNode

0 commit comments

Comments
 (0)