Skip to content

Commit fcf9dab

Browse files
authored
upgrade codegen and adapt (type alias) (#1776)
* upgrade codegen * adapt type alias * upgrade codegen
1 parent b9373b8 commit fcf9dab

5 files changed

Lines changed: 21 additions & 12 deletions

File tree

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name := "codepropertygraph"
22

33
// parsed by project/Versions.scala, updated by updateDependencies.sh
44
val overflowdbVersion = "1.192"
5-
val overflowdbCodegenVersion = "2.110"
5+
val overflowdbCodegenVersion = "2.112"
66

77
inThisBuild(
88
List(

codepropertygraph/src/main/scala/io/shiftleft/passes/CpgPass.scala

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ package io.shiftleft.passes
22

33
import com.google.protobuf.GeneratedMessageV3
44
import io.shiftleft.SerializedCpg
5-
import io.shiftleft.codepropertygraph.generated.Cpg
5+
import io.shiftleft.codepropertygraph.generated.{Cpg, DiffGraphBuilder}
66
import org.slf4j.{Logger, LoggerFactory, MDC}
7-
import overflowdb.BatchedUpdate
87

98
import java.util.function.{BiConsumer, Supplier}
109
import scala.annotation.nowarn
@@ -19,11 +18,11 @@ import scala.util.{Failure, Success, Try}
1918
abstract class CpgPass(cpg: Cpg, outName: String = "", keyPool: Option[KeyPool] = None)
2019
extends ForkJoinParallelCpgPass[AnyRef](cpg, outName, keyPool) {
2120

22-
def run(builder: overflowdb.BatchedUpdate.DiffGraphBuilder): Unit
21+
def run(builder: DiffGraphBuilder): Unit
2322

2423
final override def generateParts(): Array[? <: AnyRef] = Array[AnyRef](null)
2524

26-
final override def runOnPart(builder: overflowdb.BatchedUpdate.DiffGraphBuilder, part: AnyRef): Unit =
25+
final override def runOnPart(builder: DiffGraphBuilder, part: AnyRef): Unit =
2726
run(builder)
2827

2928
override def isParallel: Boolean = false
@@ -109,7 +108,7 @@ abstract class ForkJoinParallelCpgPass[T <: AnyRef](
109108
* hierarchy.
110109
*/
111110
abstract class NewStyleCpgPassBase[T <: AnyRef] extends CpgPassBase {
112-
type DiffGraphBuilder = overflowdb.BatchedUpdate.DiffGraphBuilder
111+
type DiffGraphBuilder = io.shiftleft.codepropertygraph.generated.DiffGraphBuilder
113112
// generate Array of parts that can be processed in parallel
114113
def generateParts(): Array[? <: AnyRef]
115114
// setup large data structures, acquire external resources
@@ -123,7 +122,7 @@ abstract class NewStyleCpgPassBase[T <: AnyRef] extends CpgPassBase {
123122

124123
override def createAndApply(): Unit = createApplySerializeAndStore(null)
125124

126-
override def runWithBuilder(externalBuilder: BatchedUpdate.DiffGraphBuilder): Int = {
125+
override def runWithBuilder(externalBuilder: DiffGraphBuilder): Int = {
127126
try {
128127
init()
129128
val parts = generateParts()
@@ -185,12 +184,12 @@ trait CpgPassBase {
185184
* 1), where nParts is either the number of parallel parts, or the number of iterarator elements in case of legacy
186185
* passes. Includes init() and finish() logic.
187186
*/
188-
def runWithBuilder(builder: overflowdb.BatchedUpdate.DiffGraphBuilder): Int
187+
def runWithBuilder(builder: DiffGraphBuilder): Int
189188

190189
/** Wraps runWithBuilder with logging, and swallows raised exceptions. Use with caution -- API is unstable. A return
191190
* value of -1 indicates failure, otherwise the return value of runWithBuilder is passed through.
192191
*/
193-
def runWithBuilderLogged(builder: overflowdb.BatchedUpdate.DiffGraphBuilder): Int = {
192+
def runWithBuilderLogged(builder: DiffGraphBuilder): Int = {
194193
baseLogger.info(s"Start of pass: $name")
195194
val nanoStart = System.nanoTime()
196195
val size0 = builder.size()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package io.shiftleft.codepropertygraph
2+
3+
package object generated {
4+
// some type aliases so that the domain-specific code can avoid referencing the `overflowdb` namespace
5+
6+
object help {
7+
type Doc = _root_.overflowdb.traversal.help.Doc
8+
type Traversal = _root_.overflowdb.traversal.help.Traversal
9+
type TraversalSource = _root_.overflowdb.traversal.help.TraversalSource
10+
}
11+
}

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ addSbtPlugin("com.github.sbt" % "sbt-findbugs" % "2.0.0")
44
addSbtPlugin("io.shiftleft" % "sbt-ci-release-early" % "2.0.18")
55
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")
66
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.5")
7-
addSbtPlugin("io.shiftleft" % "sbt-overflowdb" % "2.106")
7+
addSbtPlugin("io.shiftleft" % "sbt-overflowdb" % "2.112")
88

schema/build.sbt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name := "codepropertygraph-schema"
22

3-
// TODO change back to io.shiftleft after official releases are fixed, this is only temporary!
4-
libraryDependencies += "com.michaelpollmeier" %% "overflowdb-codegen" % Versions.overflowdbCodegen
3+
libraryDependencies += "io.shiftleft" %% "overflowdb-codegen" % Versions.overflowdbCodegen
54

65
lazy val generatedSrcDir = settingKey[File]("root for generated sources - we want to check those in")
76
enablePlugins(OdbCodegenSbtPlugin)

0 commit comments

Comments
 (0)