Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ object PropertyDefaults {
val Filename = "<empty>"
val FullName = "<empty>"
val GenericSignature = "<empty>"
val Index = -1: Int
val IsExternal = false
val IsVariadic = false
val Key = "<empty>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ trait MethodParameterInBase
val tmpDynamicTypeHintFullName = this.dynamicTypeHintFullName;
if (tmpDynamicTypeHintFullName.nonEmpty) res.put("DYNAMIC_TYPE_HINT_FULL_NAME", tmpDynamicTypeHintFullName)
if (("<empty>": 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 (("<empty>": String) != this.name) res.put("NAME", this.name)
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ trait MethodParameterOutBase
if (("<empty>": String) != this.code) res.put("CODE", this.code)
this.columnNumber.foreach { p => res.put("COLUMN_NUMBER", p) }
if (("<empty>": 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 (("<empty>": String) != this.name) res.put("NAME", this.name)
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -2399,7 +2403,7 @@ class NewMethodParameterIn
var columnNumber: Option[Int] = None
var dynamicTypeHintFullName: IndexedSeq[String] = ArraySeq.empty
var evaluationStrategy: String = "<empty>": String
var index: Int = -1: Int
var index: Option[Int] = None
var isVariadic: Boolean = false: Boolean
var lineNumber: Option[Int] = None
var name: String = "<empty>": String
Expand All @@ -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 }
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -2314,7 +2318,7 @@ class NewMethodParameterOut
var code: String = "<empty>": String
var columnNumber: Option[Int] = None
var evaluationStrategy: String = "<empty>": String
var index: Int = -1: Int
var index: Option[Int] = None
var isVariadic: Boolean = false: Boolean
var lineNumber: Option[Int] = None
var name: String = "<empty>": String
Expand All @@ -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 }
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand Down
Loading
Loading