Skip to content

minify flatgraph migration: promote neighbor accessors (remove _ prefix) #272

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 17 additions & 3 deletions codegen/src/main/scala/overflowdb/codegen/CodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ class CodeGen(schema: Schema) {
val entireNodeHierarchy: Set[AbstractNodeType] = neighbor.subtypes(schema.allNodeTypes.toSet) ++ (neighbor.extendzRecursively :+ neighbor)
entireNodeHierarchy.map { neighbor =>
val accessorName = adjacentNode.customStepName.getOrElse(
s"_${camelCase(neighbor.name)}Via${edge.className.capitalize}${camelCaseCaps(direction.toString)}"
s"${camelCase(neighbor.name)}Via${edge.className.capitalize}${camelCaseCaps(direction.toString)}"
)
val accessorImpl0 = s"$edgeAccessorName.collectAll[${neighbor.className}]"
val cardinality = adjacentNode.cardinality
Expand All @@ -558,6 +558,10 @@ class CodeGen(schema: Schema) {
| */ ${docAnnotationMaybe(adjacentNode.customStepDoc)}
|def $accessorName: ${fullScalaType(neighbor, cardinality)} =
| $accessorImpl1
|
|@deprecated("please use `$accessorName`", "June 2024")
|def _$accessorName = $accessorName
|
| """.stripMargin
}
}.distinct.mkString(lineSeparator)
Expand Down Expand Up @@ -1013,9 +1017,14 @@ class CodeGen(schema: Schema) {
s"""/** ${neighborNodeInfo.customStepDoc.getOrElse("")}
| * Traverse to ${neighborNodeInfo.neighborNode.name} via ${neighborNodeInfo.edge.name} $direction edge.
| */ ${docAnnotationMaybe(neighborNodeInfo.customStepDoc)}
|def $accessorNameForNode: ${neighborNodeInfo.returnType} = get().$accessorNameForNode""".stripMargin
|def $accessorNameForNode: ${neighborNodeInfo.returnType} = get().$accessorNameForNode
|
|@deprecated("please use `$accessorNameForNode`", "June 2024")
|def _$accessorNameForNode = $accessorNameForNode
|""".stripMargin
}.mkString(lineSeparator)


val neighborNodeClass = neighborInfo.deriveNeighborNodeType.getOrElse(schema.anyNode).className
s"""def $edgeAccessorName: Iterator[$neighborNodeClass] = get().$edgeAccessorName
|override def _$edgeAccessorName = get()._$edgeAccessorName
Expand Down Expand Up @@ -1090,11 +1099,16 @@ class CodeGen(schema: Schema) {
case EdgeType.Cardinality.ZeroOrOne => s"$accessorImpl0.nextOption()"
case _ => accessorImpl0
}
s"def ${accessorName(neighborNodeInfo)}: ${neighborNodeInfo.returnType} = $accessorImpl1"
val accessorNameForNode = accessorName(neighborNodeInfo)
s"""@deprecated("please use `$accessorNameForNode`", "June 2024")
|def _$accessorNameForNode = $accessorNameForNode
|
|def $accessorNameForNode: ${neighborNodeInfo.returnType} = $accessorImpl1""".stripMargin
}.mkString(lineSeparator)

s"""def $edgeAccessorName: Iterator[$neighborType] = createAdjacentNodeScalaIteratorByOffSet[$neighborType]($offsetPosition)
|override def _$edgeAccessorName = createAdjacentNodeScalaIteratorByOffSet[StoredNode]($offsetPosition)
|
|$nodeAccessors
|""".stripMargin
}.mkString(lineSeparator)
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/main/scala/overflowdb/codegen/Helpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object Helpers {
val neighborNodeName = neighborInfoForNode.neighborNode.name
val edgeName = neighborInfoForNode.edge.className
val direction = neighborInfoForNode.direction.toString
s"_${camelCase(neighborNodeName)}Via$edgeName${camelCaseCaps(direction)}"
s"${camelCase(neighborNodeName)}Via$edgeName${camelCaseCaps(direction)}"
}
}

Expand Down
Loading