diff --git a/build.sbt b/build.sbt index e9805771b..293880a71 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ name := "codepropertygraph" // parsed by project/Versions.scala, updated by updateDependencies.sh -val flatgraphVersion = "0.1.31" +val flatgraphVersion = "0.1.32" inThisBuild( List( diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/GraphSchema.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/GraphSchema.scala index d213f35c8..b54abea53 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/GraphSchema.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/GraphSchema.scala @@ -789,7 +789,7 @@ object GraphSchema extends flatgraph.Schema { nodePropertyDescriptors(1514) = FormalQtyType.StringType // METHOD_PARAMETER_IN.EVALUATION_STRATEGY nodePropertyDescriptors(1515) = FormalQtyType.QtyOne nodePropertyDescriptors(2288) = FormalQtyType.IntType // METHOD_PARAMETER_IN.INDEX - nodePropertyDescriptors(2289) = FormalQtyType.QtyOne + nodePropertyDescriptors(2289) = FormalQtyType.QtyOption nodePropertyDescriptors(2718) = FormalQtyType.BoolType // METHOD_PARAMETER_IN.IS_VARIADIC nodePropertyDescriptors(2719) = FormalQtyType.QtyOne nodePropertyDescriptors(3062) = FormalQtyType.IntType // METHOD_PARAMETER_IN.LINE_NUMBER @@ -813,7 +813,7 @@ object GraphSchema extends flatgraph.Schema { nodePropertyDescriptors(1516) = FormalQtyType.StringType // METHOD_PARAMETER_OUT.EVALUATION_STRATEGY nodePropertyDescriptors(1517) = FormalQtyType.QtyOne nodePropertyDescriptors(2290) = FormalQtyType.IntType // METHOD_PARAMETER_OUT.INDEX - nodePropertyDescriptors(2291) = FormalQtyType.QtyOne + nodePropertyDescriptors(2291) = FormalQtyType.QtyOption nodePropertyDescriptors(2720) = FormalQtyType.BoolType // METHOD_PARAMETER_OUT.IS_VARIADIC nodePropertyDescriptors(2721) = FormalQtyType.QtyOne nodePropertyDescriptors(3064) = FormalQtyType.IntType // METHOD_PARAMETER_OUT.LINE_NUMBER diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/Properties.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/Properties.scala index 0ac593be6..a8a2cf81d 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/Properties.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/Properties.scala @@ -152,7 +152,7 @@ object Properties { /** Specifies an index, e.g., for a parameter or argument. Explicit parameters are numbered from 1 to N, while index 0 * is reserved for implicit self / this parameter. */ - val Index = flatgraph.SinglePropertyKey[Int](kind = 26, name = "INDEX", default = -1: Int) + val Index = flatgraph.OptionalPropertyKey[Int](kind = 26, name = "INDEX") /** The static types a TYPE_DECL inherits from. This property is matched against the FULL_NAME of TYPE nodes and thus * it is required to have at least one TYPE node for each TYPE_FULL_NAME diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/PropertyDefaults.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/PropertyDefaults.scala index 56a894a24..6184f99c7 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/PropertyDefaults.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/PropertyDefaults.scala @@ -14,7 +14,6 @@ object PropertyDefaults { val Filename = "" val FullName = "" val GenericSignature = "" - val Index = -1: Int val IsExternal = false val IsVariadic = false val Key = "" diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/accessors/Accessors.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/accessors/Accessors.scala index f55d5fde2..d42bce825 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/accessors/Accessors.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/accessors/Accessors.scala @@ -177,13 +177,8 @@ object Accessors { .getNodePropertyOption[String](node.graph, nodeKind = node.nodeKind, propertyKind = 25, seq = node.seq) } final class AccessPropertyIndex(val node: nodes.StoredNode) extends AnyVal { - def index: Int = flatgraph.Accessors.getNodePropertySingle( - node.graph, - nodeKind = node.nodeKind, - propertyKind = 26, - seq = node.seq(), - default = -1: Int - ) + def index: Option[Int] = flatgraph.Accessors + .getNodePropertyOption[Int](node.graph, nodeKind = node.nodeKind, propertyKind = 26, seq = node.seq) } final class AccessPropertyInheritsFromTypeFullName(val node: nodes.StoredNode) extends AnyVal { def inheritsFromTypeFullName: IndexedSeq[String] = flatgraph.Accessors @@ -733,7 +728,7 @@ object Accessors { case stored: nodes.StoredNode => new AccessPropertyEvaluationStrategy(stored).evaluationStrategy case newNode: nodes.NewMethodParameterIn => newNode.evaluationStrategy } - def index: Int = node match { + def index: Option[Int] = node match { case stored: nodes.StoredNode => new AccessPropertyIndex(stored).index case newNode: nodes.NewMethodParameterIn => newNode.index } @@ -755,7 +750,7 @@ object Accessors { case stored: nodes.StoredNode => new AccessPropertyEvaluationStrategy(stored).evaluationStrategy case newNode: nodes.NewMethodParameterOut => newNode.evaluationStrategy } - def index: Int = node match { + def index: Option[Int] = node match { case stored: nodes.StoredNode => new AccessPropertyIndex(stored).index case newNode: nodes.NewMethodParameterOut => newNode.index } diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodParameterIn.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodParameterIn.scala index 3b84ba223..f17d4109e 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodParameterIn.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodParameterIn.scala @@ -34,7 +34,7 @@ trait MethodParameterInBase val tmpDynamicTypeHintFullName = this.dynamicTypeHintFullName; if (tmpDynamicTypeHintFullName.nonEmpty) res.put("DYNAMIC_TYPE_HINT_FULL_NAME", tmpDynamicTypeHintFullName) if (("": String) != this.evaluationStrategy) res.put("EVALUATION_STRATEGY", this.evaluationStrategy) - if ((-1: Int) != this.index) res.put("INDEX", this.index) + this.index.foreach { p => res.put("INDEX", p) } if ((false: Boolean) != this.isVariadic) res.put("IS_VARIADIC", this.isVariadic) this.lineNumber.foreach { p => res.put("LINE_NUMBER", p) } if (("": String) != this.name) res.put("NAME", this.name) @@ -72,9 +72,8 @@ object MethodParameterIn { * passed by value, that is, a copy is made, 3) `BY_SHARING` the parameter is a pointer/reference and it is shared with * the caller/callee. While a copy of the pointer is made, a copy of the object that it points to is not made. * - * ▸ Index (Int); Cardinality `one` (mandatory with default value `-1`); Specifies an index, e.g., for a parameter or - * argument. Explicit parameters are numbered from 1 to N, while index 0 is reserved for implicit self / this - * parameter. + * ▸ Index (Int); Cardinality `ZeroOrOne` (optional); Specifies an index, e.g., for a parameter or argument. Explicit + * parameters are numbered from 1 to N, while index 0 is reserved for implicit self / this parameter. * * ▸ IsVariadic (Boolean); Cardinality `one` (mandatory with default value `false`); Specifies whether a parameter is * the variadic argument handling parameter of a variadic method. Only one parameter of a method is allowed to have diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodParameterOut.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodParameterOut.scala index a9be28c74..84e8a63b5 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodParameterOut.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodParameterOut.scala @@ -28,7 +28,7 @@ trait MethodParameterOutBase if (("": String) != this.code) res.put("CODE", this.code) this.columnNumber.foreach { p => res.put("COLUMN_NUMBER", p) } if (("": String) != this.evaluationStrategy) res.put("EVALUATION_STRATEGY", this.evaluationStrategy) - if ((-1: Int) != this.index) res.put("INDEX", this.index) + this.index.foreach { p => res.put("INDEX", p) } if ((false: Boolean) != this.isVariadic) res.put("IS_VARIADIC", this.isVariadic) this.lineNumber.foreach { p => res.put("LINE_NUMBER", p) } if (("": String) != this.name) res.put("NAME", this.name) @@ -58,9 +58,8 @@ object MethodParameterOut { * passed by value, that is, a copy is made, 3) `BY_SHARING` the parameter is a pointer/reference and it is shared with * the caller/callee. While a copy of the pointer is made, a copy of the object that it points to is not made. * - * ▸ Index (Int); Cardinality `one` (mandatory with default value `-1`); Specifies an index, e.g., for a parameter or - * argument. Explicit parameters are numbered from 1 to N, while index 0 is reserved for implicit self / this - * parameter. + * ▸ Index (Int); Cardinality `ZeroOrOne` (optional); Specifies an index, e.g., for a parameter or argument. Explicit + * parameters are numbered from 1 to N, while index 0 is reserved for implicit self / this parameter. * * ▸ IsVariadic (Boolean); Cardinality `one` (mandatory with default value `false`); Specifies whether a parameter is * the variadic argument handling parameter of a variadic method. Only one parameter of a method is allowed to have diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/NewMethodParameterIn.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/NewMethodParameterIn.scala index 83cfd88c0..8878b4695 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/NewMethodParameterIn.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/NewMethodParameterIn.scala @@ -2151,8 +2151,12 @@ object NewMethodParameterIn { val nn = newNodes(idx) nn match { case generated: NewMethodParameterIn => - dstCast(offset) = generated.index - offset += 1 + generated.index match { + case Some(item) => + dstCast(offset) = item + offset += 1 + case _ => + } case _ => } assert(seq + idx == nn.storedRef.get.seq(), "internal consistency check") @@ -2399,7 +2403,7 @@ class NewMethodParameterIn var columnNumber: Option[Int] = None var dynamicTypeHintFullName: IndexedSeq[String] = ArraySeq.empty var evaluationStrategy: String = "": String - var index: Int = -1: Int + var index: Option[Int] = None var isVariadic: Boolean = false: Boolean var lineNumber: Option[Int] = None var name: String = "": String @@ -2417,7 +2421,8 @@ class NewMethodParameterIn this.dynamicTypeHintFullName = value.iterator.to(ArraySeq); this } def evaluationStrategy(value: String): this.type = { this.evaluationStrategy = value; this } - def index(value: Int): this.type = { this.index = value; this } + def index(value: Int): this.type = { this.index = Option(value); this } + def index(value: Option[Int]): this.type = { this.index = value; this } def isVariadic(value: Boolean): this.type = { this.isVariadic = value; this } def lineNumber(value: Int): this.type = { this.lineNumber = Option(value); this } def lineNumber(value: Option[Int]): this.type = { this.lineNumber = value; this } @@ -2435,7 +2440,7 @@ class NewMethodParameterIn interface.countProperty(this, 9, columnNumber.size) interface.countProperty(this, 16, dynamicTypeHintFullName.size) interface.countProperty(this, 17, 1) - interface.countProperty(this, 26, 1) + interface.countProperty(this, 26, index.size) interface.countProperty(this, 31, 1) interface.countProperty(this, 35, lineNumber.size) interface.countProperty(this, 39, 1) diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/NewMethodParameterOut.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/NewMethodParameterOut.scala index 6eea4e4ad..33d0cf29f 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/NewMethodParameterOut.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/NewMethodParameterOut.scala @@ -2095,8 +2095,12 @@ object NewMethodParameterOut { val nn = newNodes(idx) nn match { case generated: NewMethodParameterOut => - dstCast(offset) = generated.index - offset += 1 + generated.index match { + case Some(item) => + dstCast(offset) = item + offset += 1 + case _ => + } case _ => } assert(seq + idx == nn.storedRef.get.seq(), "internal consistency check") @@ -2314,7 +2318,7 @@ class NewMethodParameterOut var code: String = "": String var columnNumber: Option[Int] = None var evaluationStrategy: String = "": String - var index: Int = -1: Int + var index: Option[Int] = None var isVariadic: Boolean = false: Boolean var lineNumber: Option[Int] = None var name: String = "": String @@ -2326,7 +2330,8 @@ class NewMethodParameterOut def columnNumber(value: Int): this.type = { this.columnNumber = Option(value); this } def columnNumber(value: Option[Int]): this.type = { this.columnNumber = value; this } def evaluationStrategy(value: String): this.type = { this.evaluationStrategy = value; this } - def index(value: Int): this.type = { this.index = value; this } + def index(value: Int): this.type = { this.index = Option(value); this } + def index(value: Option[Int]): this.type = { this.index = value; this } def isVariadic(value: Boolean): this.type = { this.isVariadic = value; this } def lineNumber(value: Int): this.type = { this.lineNumber = Option(value); this } def lineNumber(value: Option[Int]): this.type = { this.lineNumber = value; this } @@ -2341,7 +2346,7 @@ class NewMethodParameterOut interface.countProperty(this, 8, 1) interface.countProperty(this, 9, columnNumber.size) interface.countProperty(this, 17, 1) - interface.countProperty(this, 26, 1) + interface.countProperty(this, 26, index.size) interface.countProperty(this, 31, 1) interface.countProperty(this, 35, lineNumber.size) interface.countProperty(this, 39, 1) diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalAstnodeBase.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalAstnodeBase.scala index 9b0e1200e..649c4ae60 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalAstnodeBase.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalAstnodeBase.scala @@ -84,6 +84,19 @@ final class TraversalAstnodeBase[NodeType <: nodes.AstNodeBase](val traversal: I val tmp = node.columnNumber; tmp.isDefined && tmp.get == value } + /** Traverse to nodes where the columnNumber equals the given `value`. If `value` is None, only nodes where + * columnNumber is not set are included. + */ + def columnNumber(value: Option[Int]): Iterator[NodeType] = + value match { + case Some(_val) => columnNumber(_val); case None => traversal.filter { node => node.columnNumber.isEmpty } + } + + /** Traverse to nodes where the columnNumber equals the given `value`, or no results if `value` is None. + */ + def columnNumberIfPresent(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => columnNumber(_val); case None => Iterator.empty } + /** Traverse to nodes where the columnNumber equals at least one of the given `values` */ def columnNumber(values: Int*): Iterator[NodeType] = { @@ -148,6 +161,19 @@ final class TraversalAstnodeBase[NodeType <: nodes.AstNodeBase](val traversal: I val tmp = node.lineNumber; tmp.isDefined && tmp.get == value } + /** Traverse to nodes where the lineNumber equals the given `value`. If `value` is None, only nodes where lineNumber + * is not set are included. + */ + def lineNumber(value: Option[Int]): Iterator[NodeType] = + value match { + case Some(_val) => lineNumber(_val); case None => traversal.filter { node => node.lineNumber.isEmpty } + } + + /** Traverse to nodes where the lineNumber equals the given `value`, or no results if `value` is None. + */ + def lineNumberIfPresent(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => lineNumber(_val); case None => Iterator.empty } + /** Traverse to nodes where the lineNumber equals at least one of the given `values` */ def lineNumber(values: Int*): Iterator[NodeType] = { @@ -212,6 +238,17 @@ final class TraversalAstnodeBase[NodeType <: nodes.AstNodeBase](val traversal: I val tmp = node.offset; tmp.isDefined && tmp.get == value } + /** Traverse to nodes where the offset equals the given `value`. If `value` is None, only nodes where offset is not + * set are included. + */ + def offset(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => offset(_val); case None => traversal.filter { node => node.offset.isEmpty } } + + /** Traverse to nodes where the offset equals the given `value`, or no results if `value` is None. + */ + def offsetIfPresent(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => offset(_val); case None => Iterator.empty } + /** Traverse to nodes where the offset equals at least one of the given `values` */ def offset(values: Int*): Iterator[NodeType] = { @@ -276,6 +313,17 @@ final class TraversalAstnodeBase[NodeType <: nodes.AstNodeBase](val traversal: I val tmp = node.offsetEnd; tmp.isDefined && tmp.get == value } + /** Traverse to nodes where the offsetEnd equals the given `value`. If `value` is None, only nodes where offsetEnd is + * not set are included. + */ + def offsetEnd(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => offsetEnd(_val); case None => traversal.filter { node => node.offsetEnd.isEmpty } } + + /** Traverse to nodes where the offsetEnd equals the given `value`, or no results if `value` is None. + */ + def offsetEndIfPresent(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => offsetEnd(_val); case None => Iterator.empty } + /** Traverse to nodes where the offsetEnd equals at least one of the given `values` */ def offsetEnd(values: Int*): Iterator[NodeType] = { @@ -338,6 +386,11 @@ final class TraversalAstnodeBase[NodeType <: nodes.AstNodeBase](val traversal: I def order(value: Int): Iterator[NodeType] = traversal.filter { _.order == value } + /** Traverse to nodes where the order equals the given `value`, or no results if `value` is None + */ + def order(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => order(_val); case None => Iterator.empty } + /** Traverse to nodes where the order equals at least one of the given `values` */ def order(values: Int*): Iterator[NodeType] = { diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalExpressionBase.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalExpressionBase.scala index a273d810d..f08a66d9f 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalExpressionBase.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalExpressionBase.scala @@ -15,6 +15,11 @@ final class TraversalExpressionBase[NodeType <: nodes.ExpressionBase](val traver def argumentIndex(value: Int): Iterator[NodeType] = traversal.filter { _.argumentIndex == value } + /** Traverse to nodes where the argumentIndex equals the given `value`, or no results if `value` is None + */ + def argumentIndex(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => argumentIndex(_val); case None => Iterator.empty } + /** Traverse to nodes where the argumentIndex equals at least one of the given `values` */ def argumentIndex(values: Int*): Iterator[NodeType] = { diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalJumptargetBase.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalJumptargetBase.scala index a95d2cb8f..2f3da05e2 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalJumptargetBase.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalJumptargetBase.scala @@ -15,6 +15,11 @@ final class TraversalJumptargetBase[NodeType <: nodes.JumpTargetBase](val traver def argumentIndex(value: Int): Iterator[NodeType] = traversal.filter { _.argumentIndex == value } + /** Traverse to nodes where the argumentIndex equals the given `value`, or no results if `value` is None + */ + def argumentIndex(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => argumentIndex(_val); case None => Iterator.empty } + /** Traverse to nodes where the argumentIndex equals at least one of the given `values` */ def argumentIndex(values: Int*): Iterator[NodeType] = { diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalMethodBase.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalMethodBase.scala index 695decf2b..562c5aa48 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalMethodBase.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalMethodBase.scala @@ -152,6 +152,19 @@ final class TraversalMethodBase[NodeType <: nodes.MethodBase](val traversal: Ite val tmp = node.columnNumberEnd; tmp.isDefined && tmp.get == value } + /** Traverse to nodes where the columnNumberEnd equals the given `value`. If `value` is None, only nodes where + * columnNumberEnd is not set are included. + */ + def columnNumberEnd(value: Option[Int]): Iterator[NodeType] = + value match { + case Some(_val) => columnNumberEnd(_val); case None => traversal.filter { node => node.columnNumberEnd.isEmpty } + } + + /** Traverse to nodes where the columnNumberEnd equals the given `value`, or no results if `value` is None. + */ + def columnNumberEndIfPresent(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => columnNumberEnd(_val); case None => Iterator.empty } + /** Traverse to nodes where the columnNumberEnd equals at least one of the given `values` */ def columnNumberEnd(values: Int*): Iterator[NodeType] = { @@ -502,6 +515,19 @@ final class TraversalMethodBase[NodeType <: nodes.MethodBase](val traversal: Ite val tmp = node.lineNumberEnd; tmp.isDefined && tmp.get == value } + /** Traverse to nodes where the lineNumberEnd equals the given `value`. If `value` is None, only nodes where + * lineNumberEnd is not set are included. + */ + def lineNumberEnd(value: Option[Int]): Iterator[NodeType] = + value match { + case Some(_val) => lineNumberEnd(_val); case None => traversal.filter { node => node.lineNumberEnd.isEmpty } + } + + /** Traverse to nodes where the lineNumberEnd equals the given `value`, or no results if `value` is None. + */ + def lineNumberEndIfPresent(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => lineNumberEnd(_val); case None => Iterator.empty } + /** Traverse to nodes where the lineNumberEnd equals at least one of the given `values` */ def lineNumberEnd(values: Int*): Iterator[NodeType] = { diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalMethodparameterinBase.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalMethodparameterinBase.scala index 27deac755..e29153717 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalMethodparameterinBase.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalMethodparameterinBase.scala @@ -153,51 +153,78 @@ final class TraversalMethodparameterinBase[NodeType <: nodes.MethodParameterInBa /** Traverse to index property */ def index: Iterator[Int] = - traversal.map(_.index) + traversal.flatMap(_.index) /** Traverse to nodes where the index equals the given `value` */ def index(value: Int): Iterator[NodeType] = - traversal.filter { _.index == value } + traversal.filter { node => + val tmp = node.index; tmp.isDefined && tmp.get == value + } + + /** Traverse to nodes where the index equals the given `value`. If `value` is None, only nodes where index is not set + * are included. + */ + def index(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => index(_val); case None => traversal.filter { node => node.index.isEmpty } } + + /** Traverse to nodes where the index equals the given `value`, or no results if `value` is None. + */ + def indexIfPresent(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => index(_val); case None => Iterator.empty } /** Traverse to nodes where the index equals at least one of the given `values` */ def index(values: Int*): Iterator[NodeType] = { val vset = values.toSet - traversal.filter { node => vset.contains(node.index) } + traversal.filter { node => + val tmp = node.index; tmp.isDefined && vset.contains(tmp.get) + } } /** Traverse to nodes where the index is not equal to the given `value` */ def indexNot(value: Int): Iterator[NodeType] = - traversal.filter { _.index != value } + traversal.filter { node => + val tmp = node.index; tmp.isEmpty || tmp.get != value + } - /** Traverse to nodes where the index is not equal to any of the given `values` + /** Traverse to nodes where the index does not equal any one of the given `values` */ def indexNot(values: Int*): Iterator[NodeType] = { val vset = values.toSet - traversal.filter { node => !vset.contains(node.index) } + traversal.filter { node => + val tmp = node.index; tmp.isEmpty || !vset.contains(tmp.get) + } } /** Traverse to nodes where the index is greater than the given `value` */ def indexGt(value: Int): Iterator[NodeType] = - traversal.filter { _.index > value } + traversal.filter { node => + val tmp = node.index; tmp.isDefined && tmp.get > value + } /** Traverse to nodes where the index is greater than or equal the given `value` */ def indexGte(value: Int): Iterator[NodeType] = - traversal.filter { _.index >= value } + traversal.filter { node => + val tmp = node.index; tmp.isDefined && tmp.get >= value + } /** Traverse to nodes where the index is less than the given `value` */ def indexLt(value: Int): Iterator[NodeType] = - traversal.filter { _.index < value } + traversal.filter { node => + val tmp = node.index; tmp.isDefined && tmp.get < value + } /** Traverse to nodes where the index is less than or equal the given `value` */ def indexLte(value: Int): Iterator[NodeType] = - traversal.filter { _.index <= value } + traversal.filter { node => + val tmp = node.index; tmp.isDefined && tmp.get <= value + } /** Traverse to isVariadic property */ def isVariadic: Iterator[Boolean] = diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalMethodparameteroutBase.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalMethodparameteroutBase.scala index 94ed8f7c7..99a7f50f7 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalMethodparameteroutBase.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalMethodparameteroutBase.scala @@ -76,51 +76,78 @@ final class TraversalMethodparameteroutBase[NodeType <: nodes.MethodParameterOut /** Traverse to index property */ def index: Iterator[Int] = - traversal.map(_.index) + traversal.flatMap(_.index) /** Traverse to nodes where the index equals the given `value` */ def index(value: Int): Iterator[NodeType] = - traversal.filter { _.index == value } + traversal.filter { node => + val tmp = node.index; tmp.isDefined && tmp.get == value + } + + /** Traverse to nodes where the index equals the given `value`. If `value` is None, only nodes where index is not set + * are included. + */ + def index(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => index(_val); case None => traversal.filter { node => node.index.isEmpty } } + + /** Traverse to nodes where the index equals the given `value`, or no results if `value` is None. + */ + def indexIfPresent(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => index(_val); case None => Iterator.empty } /** Traverse to nodes where the index equals at least one of the given `values` */ def index(values: Int*): Iterator[NodeType] = { val vset = values.toSet - traversal.filter { node => vset.contains(node.index) } + traversal.filter { node => + val tmp = node.index; tmp.isDefined && vset.contains(tmp.get) + } } /** Traverse to nodes where the index is not equal to the given `value` */ def indexNot(value: Int): Iterator[NodeType] = - traversal.filter { _.index != value } + traversal.filter { node => + val tmp = node.index; tmp.isEmpty || tmp.get != value + } - /** Traverse to nodes where the index is not equal to any of the given `values` + /** Traverse to nodes where the index does not equal any one of the given `values` */ def indexNot(values: Int*): Iterator[NodeType] = { val vset = values.toSet - traversal.filter { node => !vset.contains(node.index) } + traversal.filter { node => + val tmp = node.index; tmp.isEmpty || !vset.contains(tmp.get) + } } /** Traverse to nodes where the index is greater than the given `value` */ def indexGt(value: Int): Iterator[NodeType] = - traversal.filter { _.index > value } + traversal.filter { node => + val tmp = node.index; tmp.isDefined && tmp.get > value + } /** Traverse to nodes where the index is greater than or equal the given `value` */ def indexGte(value: Int): Iterator[NodeType] = - traversal.filter { _.index >= value } + traversal.filter { node => + val tmp = node.index; tmp.isDefined && tmp.get >= value + } /** Traverse to nodes where the index is less than the given `value` */ def indexLt(value: Int): Iterator[NodeType] = - traversal.filter { _.index < value } + traversal.filter { node => + val tmp = node.index; tmp.isDefined && tmp.get < value + } /** Traverse to nodes where the index is less than or equal the given `value` */ def indexLte(value: Int): Iterator[NodeType] = - traversal.filter { _.index <= value } + traversal.filter { node => + val tmp = node.index; tmp.isDefined && tmp.get <= value + } /** Traverse to isVariadic property */ def isVariadic: Iterator[Boolean] = diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyArgumentIndex.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyArgumentIndex.scala index ad03b6999..9e26684f8 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyArgumentIndex.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyArgumentIndex.scala @@ -16,6 +16,11 @@ final class TraversalPropertyArgumentIndex[NodeType <: nodes.StoredNode & nodes. def argumentIndex(value: Int): Iterator[NodeType] = traversal.filter { _.argumentIndex == value } + /** Traverse to nodes where the argumentIndex equals the given `value`, or no results if `value` is None + */ + def argumentIndex(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => argumentIndex(_val); case None => Iterator.empty } + /** Traverse to nodes where the argumentIndex equals at least one of the given `values` */ def argumentIndex(values: Int*): Iterator[NodeType] = { diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyColumnNumber.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyColumnNumber.scala index 1515469ee..56e839f56 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyColumnNumber.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyColumnNumber.scala @@ -18,6 +18,19 @@ final class TraversalPropertyColumnNumber[NodeType <: nodes.StoredNode & nodes.S val tmp = node.columnNumber; tmp.isDefined && tmp.get == value } + /** Traverse to nodes where the columnNumber equals the given `value`. If `value` is None, only nodes where + * columnNumber is not set are included. + */ + def columnNumber(value: Option[Int]): Iterator[NodeType] = + value match { + case Some(_val) => columnNumber(_val); case None => traversal.filter { node => node.columnNumber.isEmpty } + } + + /** Traverse to nodes where the columnNumber equals the given `value`, or no results if `value` is None. + */ + def columnNumberIfPresent(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => columnNumber(_val); case None => Iterator.empty } + /** Traverse to nodes where the columnNumber equals at least one of the given `values` */ def columnNumber(values: Int*): Iterator[NodeType] = { diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyColumnNumberEnd.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyColumnNumberEnd.scala index 0b85562b9..0657ee5bc 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyColumnNumberEnd.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyColumnNumberEnd.scala @@ -19,6 +19,19 @@ final class TraversalPropertyColumnNumberEnd[ val tmp = node.columnNumberEnd; tmp.isDefined && tmp.get == value } + /** Traverse to nodes where the columnNumberEnd equals the given `value`. If `value` is None, only nodes where + * columnNumberEnd is not set are included. + */ + def columnNumberEnd(value: Option[Int]): Iterator[NodeType] = + value match { + case Some(_val) => columnNumberEnd(_val); case None => traversal.filter { node => node.columnNumberEnd.isEmpty } + } + + /** Traverse to nodes where the columnNumberEnd equals the given `value`, or no results if `value` is None. + */ + def columnNumberEndIfPresent(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => columnNumberEnd(_val); case None => Iterator.empty } + /** Traverse to nodes where the columnNumberEnd equals at least one of the given `values` */ def columnNumberEnd(values: Int*): Iterator[NodeType] = { diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyIndex.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyIndex.scala index bd910af0a..0b1615e5b 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyIndex.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyIndex.scala @@ -9,50 +9,77 @@ final class TraversalPropertyIndex[NodeType <: nodes.StoredNode & nodes.StaticTy /** Traverse to index property */ def index: Iterator[Int] = - traversal.map(_.index) + traversal.flatMap(_.index) /** Traverse to nodes where the index equals the given `value` */ def index(value: Int): Iterator[NodeType] = - traversal.filter { _.index == value } + traversal.filter { node => + val tmp = node.index; tmp.isDefined && tmp.get == value + } + + /** Traverse to nodes where the index equals the given `value`. If `value` is None, only nodes where index is not set + * are included. + */ + def index(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => index(_val); case None => traversal.filter { node => node.index.isEmpty } } + + /** Traverse to nodes where the index equals the given `value`, or no results if `value` is None. + */ + def indexIfPresent(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => index(_val); case None => Iterator.empty } /** Traverse to nodes where the index equals at least one of the given `values` */ def index(values: Int*): Iterator[NodeType] = { val vset = values.toSet - traversal.filter { node => vset.contains(node.index) } + traversal.filter { node => + val tmp = node.index; tmp.isDefined && vset.contains(tmp.get) + } } /** Traverse to nodes where the index is not equal to the given `value` */ def indexNot(value: Int): Iterator[NodeType] = - traversal.filter { _.index != value } + traversal.filter { node => + val tmp = node.index; tmp.isEmpty || tmp.get != value + } - /** Traverse to nodes where the index is not equal to any of the given `values` + /** Traverse to nodes where the index does not equal any one of the given `values` */ def indexNot(values: Int*): Iterator[NodeType] = { val vset = values.toSet - traversal.filter { node => !vset.contains(node.index) } + traversal.filter { node => + val tmp = node.index; tmp.isEmpty || !vset.contains(tmp.get) + } } /** Traverse to nodes where the index is greater than the given `value` */ def indexGt(value: Int): Iterator[NodeType] = - traversal.filter { _.index > value } + traversal.filter { node => + val tmp = node.index; tmp.isDefined && tmp.get > value + } /** Traverse to nodes where the index is greater than or equal the given `value` */ def indexGte(value: Int): Iterator[NodeType] = - traversal.filter { _.index >= value } + traversal.filter { node => + val tmp = node.index; tmp.isDefined && tmp.get >= value + } /** Traverse to nodes where the index is less than the given `value` */ def indexLt(value: Int): Iterator[NodeType] = - traversal.filter { _.index < value } + traversal.filter { node => + val tmp = node.index; tmp.isDefined && tmp.get < value + } /** Traverse to nodes where the index is less than or equal the given `value` */ def indexLte(value: Int): Iterator[NodeType] = - traversal.filter { _.index <= value } + traversal.filter { node => + val tmp = node.index; tmp.isDefined && tmp.get <= value + } } diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyLineNumber.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyLineNumber.scala index 8278e70cf..35ddc7039 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyLineNumber.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyLineNumber.scala @@ -18,6 +18,19 @@ final class TraversalPropertyLineNumber[NodeType <: nodes.StoredNode & nodes.Sta val tmp = node.lineNumber; tmp.isDefined && tmp.get == value } + /** Traverse to nodes where the lineNumber equals the given `value`. If `value` is None, only nodes where lineNumber + * is not set are included. + */ + def lineNumber(value: Option[Int]): Iterator[NodeType] = + value match { + case Some(_val) => lineNumber(_val); case None => traversal.filter { node => node.lineNumber.isEmpty } + } + + /** Traverse to nodes where the lineNumber equals the given `value`, or no results if `value` is None. + */ + def lineNumberIfPresent(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => lineNumber(_val); case None => Iterator.empty } + /** Traverse to nodes where the lineNumber equals at least one of the given `values` */ def lineNumber(values: Int*): Iterator[NodeType] = { diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyLineNumberEnd.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyLineNumberEnd.scala index 5fc5533b6..2b75d18e6 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyLineNumberEnd.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyLineNumberEnd.scala @@ -18,6 +18,19 @@ final class TraversalPropertyLineNumberEnd[NodeType <: nodes.StoredNode & nodes. val tmp = node.lineNumberEnd; tmp.isDefined && tmp.get == value } + /** Traverse to nodes where the lineNumberEnd equals the given `value`. If `value` is None, only nodes where + * lineNumberEnd is not set are included. + */ + def lineNumberEnd(value: Option[Int]): Iterator[NodeType] = + value match { + case Some(_val) => lineNumberEnd(_val); case None => traversal.filter { node => node.lineNumberEnd.isEmpty } + } + + /** Traverse to nodes where the lineNumberEnd equals the given `value`, or no results if `value` is None. + */ + def lineNumberEndIfPresent(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => lineNumberEnd(_val); case None => Iterator.empty } + /** Traverse to nodes where the lineNumberEnd equals at least one of the given `values` */ def lineNumberEnd(values: Int*): Iterator[NodeType] = { diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyOffset.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyOffset.scala index 2f6097027..a8a30d5c7 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyOffset.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyOffset.scala @@ -18,6 +18,17 @@ final class TraversalPropertyOffset[NodeType <: nodes.StoredNode & nodes.StaticT val tmp = node.offset; tmp.isDefined && tmp.get == value } + /** Traverse to nodes where the offset equals the given `value`. If `value` is None, only nodes where offset is not + * set are included. + */ + def offset(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => offset(_val); case None => traversal.filter { node => node.offset.isEmpty } } + + /** Traverse to nodes where the offset equals the given `value`, or no results if `value` is None. + */ + def offsetIfPresent(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => offset(_val); case None => Iterator.empty } + /** Traverse to nodes where the offset equals at least one of the given `values` */ def offset(values: Int*): Iterator[NodeType] = { diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyOffsetEnd.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyOffsetEnd.scala index 57291c7d1..ef51197b3 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyOffsetEnd.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyOffsetEnd.scala @@ -18,6 +18,17 @@ final class TraversalPropertyOffsetEnd[NodeType <: nodes.StoredNode & nodes.Stat val tmp = node.offsetEnd; tmp.isDefined && tmp.get == value } + /** Traverse to nodes where the offsetEnd equals the given `value`. If `value` is None, only nodes where offsetEnd is + * not set are included. + */ + def offsetEnd(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => offsetEnd(_val); case None => traversal.filter { node => node.offsetEnd.isEmpty } } + + /** Traverse to nodes where the offsetEnd equals the given `value`, or no results if `value` is None. + */ + def offsetEndIfPresent(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => offsetEnd(_val); case None => Iterator.empty } + /** Traverse to nodes where the offsetEnd equals at least one of the given `values` */ def offsetEnd(values: Int*): Iterator[NodeType] = { diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyOrder.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyOrder.scala index e0305796f..6a8737f83 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyOrder.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyOrder.scala @@ -16,6 +16,11 @@ final class TraversalPropertyOrder[NodeType <: nodes.StoredNode & nodes.StaticTy def order(value: Int): Iterator[NodeType] = traversal.filter { _.order == value } + /** Traverse to nodes where the order equals the given `value`, or no results if `value` is None + */ + def order(value: Option[Int]): Iterator[NodeType] = + value match { case Some(_val) => order(_val); case None => Iterator.empty } + /** Traverse to nodes where the order equals at least one of the given `values` */ def order(values: Int*): Iterator[NodeType] = { diff --git a/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/Base.scala b/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/Base.scala index d2ea1fddf..ee3cbb0ef 100644 --- a/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/Base.scala +++ b/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/Base.scala @@ -73,7 +73,6 @@ object Base extends SchemaBase { | self / this parameter. |""".stripMargin ) - .mandatory(PropertyDefaults.Int) .protoId(ProtoIds.Index) val name = builder