Skip to content

Commit 490a08d

Browse files
authored
Revert "QT-676: Made parameter index property optional (#1854)" (#1855)
This reverts commit f989c43.
1 parent f989c43 commit 490a08d

25 files changed

Lines changed: 63 additions & 318 deletions

build.sbt

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

33
// parsed by project/Versions.scala, updated by updateDependencies.sh
4-
val flatgraphVersion = "0.1.32"
4+
val flatgraphVersion = "0.1.31"
55

66
inThisBuild(
77
List(

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/GraphSchema.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ object GraphSchema extends flatgraph.Schema {
789789
nodePropertyDescriptors(1514) = FormalQtyType.StringType // METHOD_PARAMETER_IN.EVALUATION_STRATEGY
790790
nodePropertyDescriptors(1515) = FormalQtyType.QtyOne
791791
nodePropertyDescriptors(2288) = FormalQtyType.IntType // METHOD_PARAMETER_IN.INDEX
792-
nodePropertyDescriptors(2289) = FormalQtyType.QtyOption
792+
nodePropertyDescriptors(2289) = FormalQtyType.QtyOne
793793
nodePropertyDescriptors(2718) = FormalQtyType.BoolType // METHOD_PARAMETER_IN.IS_VARIADIC
794794
nodePropertyDescriptors(2719) = FormalQtyType.QtyOne
795795
nodePropertyDescriptors(3062) = FormalQtyType.IntType // METHOD_PARAMETER_IN.LINE_NUMBER
@@ -813,7 +813,7 @@ object GraphSchema extends flatgraph.Schema {
813813
nodePropertyDescriptors(1516) = FormalQtyType.StringType // METHOD_PARAMETER_OUT.EVALUATION_STRATEGY
814814
nodePropertyDescriptors(1517) = FormalQtyType.QtyOne
815815
nodePropertyDescriptors(2290) = FormalQtyType.IntType // METHOD_PARAMETER_OUT.INDEX
816-
nodePropertyDescriptors(2291) = FormalQtyType.QtyOption
816+
nodePropertyDescriptors(2291) = FormalQtyType.QtyOne
817817
nodePropertyDescriptors(2720) = FormalQtyType.BoolType // METHOD_PARAMETER_OUT.IS_VARIADIC
818818
nodePropertyDescriptors(2721) = FormalQtyType.QtyOne
819819
nodePropertyDescriptors(3064) = FormalQtyType.IntType // METHOD_PARAMETER_OUT.LINE_NUMBER

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/Properties.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ object Properties {
152152
/** Specifies an index, e.g., for a parameter or argument. Explicit parameters are numbered from 1 to N, while index 0
153153
* is reserved for implicit self / this parameter.
154154
*/
155-
val Index = flatgraph.OptionalPropertyKey[Int](kind = 26, name = "INDEX")
155+
val Index = flatgraph.SinglePropertyKey[Int](kind = 26, name = "INDEX", default = -1: Int)
156156

157157
/** The static types a TYPE_DECL inherits from. This property is matched against the FULL_NAME of TYPE nodes and thus
158158
* it is required to have at least one TYPE node for each TYPE_FULL_NAME

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/PropertyDefaults.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ object PropertyDefaults {
1414
val Filename = "<empty>"
1515
val FullName = "<empty>"
1616
val GenericSignature = "<empty>"
17+
val Index = -1: Int
1718
val IsExternal = false
1819
val IsVariadic = false
1920
val Key = "<empty>"

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/accessors/Accessors.scala

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,13 @@ object Accessors {
177177
.getNodePropertyOption[String](node.graph, nodeKind = node.nodeKind, propertyKind = 25, seq = node.seq)
178178
}
179179
final class AccessPropertyIndex(val node: nodes.StoredNode) extends AnyVal {
180-
def index: Option[Int] = flatgraph.Accessors
181-
.getNodePropertyOption[Int](node.graph, nodeKind = node.nodeKind, propertyKind = 26, seq = node.seq)
180+
def index: Int = flatgraph.Accessors.getNodePropertySingle(
181+
node.graph,
182+
nodeKind = node.nodeKind,
183+
propertyKind = 26,
184+
seq = node.seq(),
185+
default = -1: Int
186+
)
182187
}
183188
final class AccessPropertyInheritsFromTypeFullName(val node: nodes.StoredNode) extends AnyVal {
184189
def inheritsFromTypeFullName: IndexedSeq[String] = flatgraph.Accessors
@@ -728,7 +733,7 @@ object Accessors {
728733
case stored: nodes.StoredNode => new AccessPropertyEvaluationStrategy(stored).evaluationStrategy
729734
case newNode: nodes.NewMethodParameterIn => newNode.evaluationStrategy
730735
}
731-
def index: Option[Int] = node match {
736+
def index: Int = node match {
732737
case stored: nodes.StoredNode => new AccessPropertyIndex(stored).index
733738
case newNode: nodes.NewMethodParameterIn => newNode.index
734739
}
@@ -750,7 +755,7 @@ object Accessors {
750755
case stored: nodes.StoredNode => new AccessPropertyEvaluationStrategy(stored).evaluationStrategy
751756
case newNode: nodes.NewMethodParameterOut => newNode.evaluationStrategy
752757
}
753-
def index: Option[Int] = node match {
758+
def index: Int = node match {
754759
case stored: nodes.StoredNode => new AccessPropertyIndex(stored).index
755760
case newNode: nodes.NewMethodParameterOut => newNode.index
756761
}

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodParameterIn.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ trait MethodParameterInBase
3434
val tmpDynamicTypeHintFullName = this.dynamicTypeHintFullName;
3535
if (tmpDynamicTypeHintFullName.nonEmpty) res.put("DYNAMIC_TYPE_HINT_FULL_NAME", tmpDynamicTypeHintFullName)
3636
if (("<empty>": String) != this.evaluationStrategy) res.put("EVALUATION_STRATEGY", this.evaluationStrategy)
37-
this.index.foreach { p => res.put("INDEX", p) }
37+
if ((-1: Int) != this.index) res.put("INDEX", this.index)
3838
if ((false: Boolean) != this.isVariadic) res.put("IS_VARIADIC", this.isVariadic)
3939
this.lineNumber.foreach { p => res.put("LINE_NUMBER", p) }
4040
if (("<empty>": String) != this.name) res.put("NAME", this.name)
@@ -72,8 +72,9 @@ object MethodParameterIn {
7272
* passed by value, that is, a copy is made, 3) `BY_SHARING` the parameter is a pointer/reference and it is shared with
7373
* the caller/callee. While a copy of the pointer is made, a copy of the object that it points to is not made.
7474
*
75-
* ▸ Index (Int); Cardinality `ZeroOrOne` (optional); Specifies an index, e.g., for a parameter or argument. Explicit
76-
* parameters are numbered from 1 to N, while index 0 is reserved for implicit self / this parameter.
75+
* ▸ Index (Int); Cardinality `one` (mandatory with default value `-1`); Specifies an index, e.g., for a parameter or
76+
* argument. Explicit parameters are numbered from 1 to N, while index 0 is reserved for implicit self / this
77+
* parameter.
7778
*
7879
* ▸ IsVariadic (Boolean); Cardinality `one` (mandatory with default value `false`); Specifies whether a parameter is
7980
* the variadic argument handling parameter of a variadic method. Only one parameter of a method is allowed to have

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodParameterOut.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ trait MethodParameterOutBase
2828
if (("<empty>": String) != this.code) res.put("CODE", this.code)
2929
this.columnNumber.foreach { p => res.put("COLUMN_NUMBER", p) }
3030
if (("<empty>": String) != this.evaluationStrategy) res.put("EVALUATION_STRATEGY", this.evaluationStrategy)
31-
this.index.foreach { p => res.put("INDEX", p) }
31+
if ((-1: Int) != this.index) res.put("INDEX", this.index)
3232
if ((false: Boolean) != this.isVariadic) res.put("IS_VARIADIC", this.isVariadic)
3333
this.lineNumber.foreach { p => res.put("LINE_NUMBER", p) }
3434
if (("<empty>": String) != this.name) res.put("NAME", this.name)
@@ -58,8 +58,9 @@ object MethodParameterOut {
5858
* passed by value, that is, a copy is made, 3) `BY_SHARING` the parameter is a pointer/reference and it is shared with
5959
* the caller/callee. While a copy of the pointer is made, a copy of the object that it points to is not made.
6060
*
61-
* ▸ Index (Int); Cardinality `ZeroOrOne` (optional); Specifies an index, e.g., for a parameter or argument. Explicit
62-
* parameters are numbered from 1 to N, while index 0 is reserved for implicit self / this parameter.
61+
* ▸ Index (Int); Cardinality `one` (mandatory with default value `-1`); Specifies an index, e.g., for a parameter or
62+
* argument. Explicit parameters are numbered from 1 to N, while index 0 is reserved for implicit self / this
63+
* parameter.
6364
*
6465
* ▸ IsVariadic (Boolean); Cardinality `one` (mandatory with default value `false`); Specifies whether a parameter is
6566
* the variadic argument handling parameter of a variadic method. Only one parameter of a method is allowed to have

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/NewMethodParameterIn.scala

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,12 +2151,8 @@ object NewMethodParameterIn {
21512151
val nn = newNodes(idx)
21522152
nn match {
21532153
case generated: NewMethodParameterIn =>
2154-
generated.index match {
2155-
case Some(item) =>
2156-
dstCast(offset) = item
2157-
offset += 1
2158-
case _ =>
2159-
}
2154+
dstCast(offset) = generated.index
2155+
offset += 1
21602156
case _ =>
21612157
}
21622158
assert(seq + idx == nn.storedRef.get.seq(), "internal consistency check")
@@ -2403,7 +2399,7 @@ class NewMethodParameterIn
24032399
var columnNumber: Option[Int] = None
24042400
var dynamicTypeHintFullName: IndexedSeq[String] = ArraySeq.empty
24052401
var evaluationStrategy: String = "<empty>": String
2406-
var index: Option[Int] = None
2402+
var index: Int = -1: Int
24072403
var isVariadic: Boolean = false: Boolean
24082404
var lineNumber: Option[Int] = None
24092405
var name: String = "<empty>": String
@@ -2421,8 +2417,7 @@ class NewMethodParameterIn
24212417
this.dynamicTypeHintFullName = value.iterator.to(ArraySeq); this
24222418
}
24232419
def evaluationStrategy(value: String): this.type = { this.evaluationStrategy = value; this }
2424-
def index(value: Int): this.type = { this.index = Option(value); this }
2425-
def index(value: Option[Int]): this.type = { this.index = value; this }
2420+
def index(value: Int): this.type = { this.index = value; this }
24262421
def isVariadic(value: Boolean): this.type = { this.isVariadic = value; this }
24272422
def lineNumber(value: Int): this.type = { this.lineNumber = Option(value); this }
24282423
def lineNumber(value: Option[Int]): this.type = { this.lineNumber = value; this }
@@ -2440,7 +2435,7 @@ class NewMethodParameterIn
24402435
interface.countProperty(this, 9, columnNumber.size)
24412436
interface.countProperty(this, 16, dynamicTypeHintFullName.size)
24422437
interface.countProperty(this, 17, 1)
2443-
interface.countProperty(this, 26, index.size)
2438+
interface.countProperty(this, 26, 1)
24442439
interface.countProperty(this, 31, 1)
24452440
interface.countProperty(this, 35, lineNumber.size)
24462441
interface.countProperty(this, 39, 1)

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/NewMethodParameterOut.scala

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,12 +2095,8 @@ object NewMethodParameterOut {
20952095
val nn = newNodes(idx)
20962096
nn match {
20972097
case generated: NewMethodParameterOut =>
2098-
generated.index match {
2099-
case Some(item) =>
2100-
dstCast(offset) = item
2101-
offset += 1
2102-
case _ =>
2103-
}
2098+
dstCast(offset) = generated.index
2099+
offset += 1
21042100
case _ =>
21052101
}
21062102
assert(seq + idx == nn.storedRef.get.seq(), "internal consistency check")
@@ -2318,7 +2314,7 @@ class NewMethodParameterOut
23182314
var code: String = "<empty>": String
23192315
var columnNumber: Option[Int] = None
23202316
var evaluationStrategy: String = "<empty>": String
2321-
var index: Option[Int] = None
2317+
var index: Int = -1: Int
23222318
var isVariadic: Boolean = false: Boolean
23232319
var lineNumber: Option[Int] = None
23242320
var name: String = "<empty>": String
@@ -2330,8 +2326,7 @@ class NewMethodParameterOut
23302326
def columnNumber(value: Int): this.type = { this.columnNumber = Option(value); this }
23312327
def columnNumber(value: Option[Int]): this.type = { this.columnNumber = value; this }
23322328
def evaluationStrategy(value: String): this.type = { this.evaluationStrategy = value; this }
2333-
def index(value: Int): this.type = { this.index = Option(value); this }
2334-
def index(value: Option[Int]): this.type = { this.index = value; this }
2329+
def index(value: Int): this.type = { this.index = value; this }
23352330
def isVariadic(value: Boolean): this.type = { this.isVariadic = value; this }
23362331
def lineNumber(value: Int): this.type = { this.lineNumber = Option(value); this }
23372332
def lineNumber(value: Option[Int]): this.type = { this.lineNumber = value; this }
@@ -2346,7 +2341,7 @@ class NewMethodParameterOut
23462341
interface.countProperty(this, 8, 1)
23472342
interface.countProperty(this, 9, columnNumber.size)
23482343
interface.countProperty(this, 17, 1)
2349-
interface.countProperty(this, 26, index.size)
2344+
interface.countProperty(this, 26, 1)
23502345
interface.countProperty(this, 31, 1)
23512346
interface.countProperty(this, 35, lineNumber.size)
23522347
interface.countProperty(this, 39, 1)

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/traversals/TraversalAstnodeBase.scala

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,6 @@ final class TraversalAstnodeBase[NodeType <: nodes.AstNodeBase](val traversal: I
8484
val tmp = node.columnNumber; tmp.isDefined && tmp.get == value
8585
}
8686

87-
/** Traverse to nodes where the columnNumber equals the given `value`. If `value` is None, only nodes where
88-
* columnNumber is not set are included.
89-
*/
90-
def columnNumber(value: Option[Int]): Iterator[NodeType] =
91-
value match {
92-
case Some(_val) => columnNumber(_val); case None => traversal.filter { node => node.columnNumber.isEmpty }
93-
}
94-
95-
/** Traverse to nodes where the columnNumber equals the given `value`, or no results if `value` is None.
96-
*/
97-
def columnNumberIfPresent(value: Option[Int]): Iterator[NodeType] =
98-
value match { case Some(_val) => columnNumber(_val); case None => Iterator.empty }
99-
10087
/** Traverse to nodes where the columnNumber equals at least one of the given `values`
10188
*/
10289
def columnNumber(values: Int*): Iterator[NodeType] = {
@@ -161,19 +148,6 @@ final class TraversalAstnodeBase[NodeType <: nodes.AstNodeBase](val traversal: I
161148
val tmp = node.lineNumber; tmp.isDefined && tmp.get == value
162149
}
163150

164-
/** Traverse to nodes where the lineNumber equals the given `value`. If `value` is None, only nodes where lineNumber
165-
* is not set are included.
166-
*/
167-
def lineNumber(value: Option[Int]): Iterator[NodeType] =
168-
value match {
169-
case Some(_val) => lineNumber(_val); case None => traversal.filter { node => node.lineNumber.isEmpty }
170-
}
171-
172-
/** Traverse to nodes where the lineNumber equals the given `value`, or no results if `value` is None.
173-
*/
174-
def lineNumberIfPresent(value: Option[Int]): Iterator[NodeType] =
175-
value match { case Some(_val) => lineNumber(_val); case None => Iterator.empty }
176-
177151
/** Traverse to nodes where the lineNumber equals at least one of the given `values`
178152
*/
179153
def lineNumber(values: Int*): Iterator[NodeType] = {
@@ -238,17 +212,6 @@ final class TraversalAstnodeBase[NodeType <: nodes.AstNodeBase](val traversal: I
238212
val tmp = node.offset; tmp.isDefined && tmp.get == value
239213
}
240214

241-
/** Traverse to nodes where the offset equals the given `value`. If `value` is None, only nodes where offset is not
242-
* set are included.
243-
*/
244-
def offset(value: Option[Int]): Iterator[NodeType] =
245-
value match { case Some(_val) => offset(_val); case None => traversal.filter { node => node.offset.isEmpty } }
246-
247-
/** Traverse to nodes where the offset equals the given `value`, or no results if `value` is None.
248-
*/
249-
def offsetIfPresent(value: Option[Int]): Iterator[NodeType] =
250-
value match { case Some(_val) => offset(_val); case None => Iterator.empty }
251-
252215
/** Traverse to nodes where the offset equals at least one of the given `values`
253216
*/
254217
def offset(values: Int*): Iterator[NodeType] = {
@@ -313,17 +276,6 @@ final class TraversalAstnodeBase[NodeType <: nodes.AstNodeBase](val traversal: I
313276
val tmp = node.offsetEnd; tmp.isDefined && tmp.get == value
314277
}
315278

316-
/** Traverse to nodes where the offsetEnd equals the given `value`. If `value` is None, only nodes where offsetEnd is
317-
* not set are included.
318-
*/
319-
def offsetEnd(value: Option[Int]): Iterator[NodeType] =
320-
value match { case Some(_val) => offsetEnd(_val); case None => traversal.filter { node => node.offsetEnd.isEmpty } }
321-
322-
/** Traverse to nodes where the offsetEnd equals the given `value`, or no results if `value` is None.
323-
*/
324-
def offsetEndIfPresent(value: Option[Int]): Iterator[NodeType] =
325-
value match { case Some(_val) => offsetEnd(_val); case None => Iterator.empty }
326-
327279
/** Traverse to nodes where the offsetEnd equals at least one of the given `values`
328280
*/
329281
def offsetEnd(values: Int*): Iterator[NodeType] = {
@@ -386,11 +338,6 @@ final class TraversalAstnodeBase[NodeType <: nodes.AstNodeBase](val traversal: I
386338
def order(value: Int): Iterator[NodeType] =
387339
traversal.filter { _.order == value }
388340

389-
/** Traverse to nodes where the order equals the given `value`, or no results if `value` is None
390-
*/
391-
def order(value: Option[Int]): Iterator[NodeType] =
392-
value match { case Some(_val) => order(_val); case None => Iterator.empty }
393-
394341
/** Traverse to nodes where the order equals at least one of the given `values`
395342
*/
396343
def order(values: Int*): Iterator[NodeType] = {

0 commit comments

Comments
 (0)