From cb9a05d61d7eb2fe20df863feaec5088dfdce3bf Mon Sep 17 00:00:00 2001 From: Louis van der Walt Date: Mon, 11 May 2026 10:41:56 +0200 Subject: [PATCH] Made method parameter prameter optional --- .../generated/GraphSchema.scala | 4 +-- .../generated/Properties.scala | 2 +- .../generated/PropertyDefaults.scala | 1 - .../generated/accessors/Accessors.scala | 13 +++---- .../generated/nodes/MethodParameterIn.scala | 7 ++-- .../generated/nodes/MethodParameterOut.scala | 7 ++-- .../nodes/NewMethodParameterIn.scala | 15 +++++--- .../nodes/NewMethodParameterOut.scala | 15 +++++--- .../TraversalMethodparameterinBase.scala | 36 +++++++++++++------ .../TraversalMethodparameteroutBase.scala | 36 +++++++++++++------ .../traversals/TraversalPropertyIndex.scala | 36 +++++++++++++------ .../codepropertygraph/schema/Base.scala | 1 - 12 files changed, 111 insertions(+), 62 deletions(-) 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/TraversalMethodparameterinBase.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalMethodparameterinBase.scala index 27deac755..793348ae3 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,67 @@ 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 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..37fd27ac3 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,67 @@ 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 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/TraversalPropertyIndex.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalPropertyIndex.scala index bd910af0a..5c28909b9 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,66 @@ 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 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/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