Skip to content

Commit

Permalink
Separate the extension namespaces for extending Cpg and Step class. (#…
Browse files Browse the repository at this point in the history
…160)

This became necessary because we otherwise ended up with the Step
extension methods as method on the Cpg class. Since this does not make
sense it did not compile but was suggest in code completion and more
important it ended up in the docs.
  • Loading branch information
ml86 committed May 9, 2019
1 parent 42545c9 commit 714221f
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 9 deletions.
Expand Up @@ -4,7 +4,6 @@ import gremlin.scala._
import io.shiftleft.codepropertygraph.generated.nodes
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
import shapeless.HNil
import io.shiftleft.queryprimitives.steps.ext

object Cpg {

Expand Down Expand Up @@ -36,11 +35,10 @@ object Cpg {
@param graph the underlying graph. An empty graph is created if this parameter is omitted.
*/
class Cpg(val graph: Graph = Cpg.emptyGraph)
extends ext.Enrichable
with ext.queryprimitives.Enrichable
extends ext.queryprimitives.Enrichable
with ext.queryprimitivesext.Enrichable
with ext.securityprofile.Enrichable
with ext.semanticcpg.Enrichable
with ext.dataflowengine.Enrichable {
with ext.semanticcpg.Enrichable {

/**
The underlying graph.
Expand Down
@@ -1,4 +1,4 @@
package io.shiftleft.queryprimitives.steps.ext.queryprimitives
package io.shiftleft.codepropertygraph.ext.queryprimitives

/** Sole purpose of this trait is to allow to enrich ('pimp') this DSL without the need of additional
* imports a la `import x.y.z.Implicits._`. We're making use of the fact that package objects of
Expand Down
@@ -0,0 +1,11 @@
package io.shiftleft.codepropertygraph.ext.queryprimitivesext

/** Sole purpose of this trait is to allow to enrich ('pimp') this DSL without the need of additional
* imports a la `import x.y.z.Implicits._`. We're making use of the fact that package objects of
* inherited traits are automatically part of implicit scope. This way, these extensions also show
* up in scaladoc.
*
* Important: this project should *not* define anything in the `ext` package object. If it does,
* it will be shadowed by enriching libraries.
*/
trait Enrichable {}
@@ -0,0 +1,11 @@
package io.shiftleft.codepropertygraph.ext.securityprofile

/** Sole purpose of this trait is to allow to enrich ('pimp') this DSL without the need of additional
* imports a la `import x.y.z.Implicits._`. We're making use of the fact that package objects of
* inherited traits are automatically part of implicit scope. This way, these extensions also show
* up in scaladoc.
*
* Important: this project should *not* define anything in the `ext` package object. If it does,
* it will be shadowed by enriching libraries.
*/
trait Enrichable {}
@@ -0,0 +1,11 @@
package io.shiftleft.codepropertygraph.ext.semanticcpg

/** Sole purpose of this trait is to allow to enrich ('pimp') this DSL without the need of additional
* imports a la `import x.y.z.Implicits._`. We're making use of the fact that package objects of
* inherited traits are automatically part of implicit scope. This way, these extensions also show
* up in scaladoc.
*
* Important: this project should *not* define anything in the `ext` package object. If it does,
* it will be shadowed by enriching libraries.
*/
trait Enrichable {}
@@ -1,10 +1,10 @@
package io.shiftleft.queryprimitives.steps.ext
package io.shiftleft.codepropertygraph.ext

import io.shiftleft.codepropertygraph.Cpg
import io.shiftleft.queryprimitives.steps.starters.NodeTypeStarters

package object queryprimitives {

implicit def toNodeTypeStarters(cpg: Cpg): NodeTypeStarters =
new NodeTypeStarters(cpg)

}
Expand Up @@ -22,7 +22,6 @@ import shapeless.ops.product.ToHList
*/
class Steps[NodeType, Labels <: HList](val raw: GremlinScala.Aux[NodeType, Labels])
extends ext.Enrichable
with ext.queryprimitives.Enrichable
with ext.securityprofile.Enrichable
with ext.semanticcpg.Enrichable
with ext.dataflowengine.Enrichable {
Expand Down

0 comments on commit 714221f

Please sign in to comment.