io.shiftleft.codepropertygraph.generated.traversals.TraversalBindingBase.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of codepropertygraph-domain-classes_3 Show documentation
Show all versions of codepropertygraph-domain-classes_3 Show documentation
codepropertygraph-domain-classes
package io.shiftleft.codepropertygraph.generated.traversals
import io.shiftleft.codepropertygraph.generated.nodes
import io.shiftleft.codepropertygraph.generated.accessors.languagebootstrap.*
final class TraversalBindingBase[NodeType <: nodes.BindingBase](val traversal: Iterator[NodeType]) extends AnyVal {
/** Traverse to methodFullName property */
def methodFullName: Iterator[String] =
traversal.map(_.methodFullName)
/** Traverse to nodes where the methodFullName matches the regular expression `value`
*/
def methodFullName(pattern: String): Iterator[NodeType] =
if (!flatgraph.misc.Regex.isRegex(pattern)) {
methodFullNameExact(pattern)
} else {
val matcher = flatgraph.misc.Regex.multilineMatcher(pattern)
traversal.filter { item => matcher.reset(item.methodFullName).matches }
}
/** Traverse to nodes where the methodFullName matches at least one of the regular expressions in `values`
*/
def methodFullName(patterns: String*): Iterator[NodeType] = {
val matchers = patterns.map(flatgraph.misc.Regex.multilineMatcher)
traversal.filter { item => matchers.exists { _.reset(item.methodFullName).matches } }
}
/** Traverse to nodes where methodFullName matches `value` exactly.
*/
def methodFullNameExact(value: String): Iterator[NodeType] = traversal match {
case init: flatgraph.misc.InitNodeIterator[flatgraph.GNode @unchecked] if init.isVirgin && init.hasNext =>
val someNode = init.next
flatgraph.Accessors
.getWithInverseIndex(someNode.graph, someNode.nodeKind, 36, value)
.asInstanceOf[Iterator[NodeType]]
case _ => traversal.filter { _.methodFullName == value }
}
/** Traverse to nodes where methodFullName matches one of the elements in `values` exactly.
*/
def methodFullNameExact(values: String*): Iterator[NodeType] =
if (values.length == 1) methodFullNameExact(values.head)
else {
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.methodFullName) }
}
/** Traverse to nodes where methodFullName does not match the regular expression `value`.
*/
def methodFullNameNot(pattern: String): Iterator[NodeType] = {
if (!flatgraph.misc.Regex.isRegex(pattern)) {
traversal.filter { node => node.methodFullName != pattern }
} else {
val matcher = flatgraph.misc.Regex.multilineMatcher(pattern)
traversal.filterNot { item => matcher.reset(item.methodFullName).matches }
}
}
/** Traverse to nodes where methodFullName does not match any of the regular expressions in `values`.
*/
def methodFullNameNot(patterns: String*): Iterator[NodeType] = {
val matchers = patterns.map(flatgraph.misc.Regex.multilineMatcher)
traversal.filter { item => matchers.find { _.reset(item.methodFullName).matches }.isEmpty }
}
/** Traverse to name property */
def name: Iterator[String] =
traversal.map(_.name)
/** Traverse to nodes where the name matches the regular expression `value`
*/
def name(pattern: String): Iterator[NodeType] =
if (!flatgraph.misc.Regex.isRegex(pattern)) {
nameExact(pattern)
} else {
val matcher = flatgraph.misc.Regex.multilineMatcher(pattern)
traversal.filter { item => matcher.reset(item.name).matches }
}
/** Traverse to nodes where the name matches at least one of the regular expressions in `values`
*/
def name(patterns: String*): Iterator[NodeType] = {
val matchers = patterns.map(flatgraph.misc.Regex.multilineMatcher)
traversal.filter { item => matchers.exists { _.reset(item.name).matches } }
}
/** Traverse to nodes where name matches `value` exactly.
*/
def nameExact(value: String): Iterator[NodeType] = traversal match {
case init: flatgraph.misc.InitNodeIterator[flatgraph.GNode @unchecked] if init.isVirgin && init.hasNext =>
val someNode = init.next
flatgraph.Accessors
.getWithInverseIndex(someNode.graph, someNode.nodeKind, 39, value)
.asInstanceOf[Iterator[NodeType]]
case _ => traversal.filter { _.name == value }
}
/** Traverse to nodes where name matches one of the elements in `values` exactly.
*/
def nameExact(values: String*): Iterator[NodeType] =
if (values.length == 1) nameExact(values.head)
else {
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.name) }
}
/** Traverse to nodes where name does not match the regular expression `value`.
*/
def nameNot(pattern: String): Iterator[NodeType] = {
if (!flatgraph.misc.Regex.isRegex(pattern)) {
traversal.filter { node => node.name != pattern }
} else {
val matcher = flatgraph.misc.Regex.multilineMatcher(pattern)
traversal.filterNot { item => matcher.reset(item.name).matches }
}
}
/** Traverse to nodes where name does not match any of the regular expressions in `values`.
*/
def nameNot(patterns: String*): Iterator[NodeType] = {
val matchers = patterns.map(flatgraph.misc.Regex.multilineMatcher)
traversal.filter { item => matchers.find { _.reset(item.name).matches }.isEmpty }
}
/** Traverse to signature property */
def signature: Iterator[String] =
traversal.map(_.signature)
/** Traverse to nodes where the signature matches the regular expression `value`
*/
def signature(pattern: String): Iterator[NodeType] =
if (!flatgraph.misc.Regex.isRegex(pattern)) {
signatureExact(pattern)
} else {
val matcher = flatgraph.misc.Regex.multilineMatcher(pattern)
traversal.filter { item => matcher.reset(item.signature).matches }
}
/** Traverse to nodes where the signature matches at least one of the regular expressions in `values`
*/
def signature(patterns: String*): Iterator[NodeType] = {
val matchers = patterns.map(flatgraph.misc.Regex.multilineMatcher)
traversal.filter { item => matchers.exists { _.reset(item.signature).matches } }
}
/** Traverse to nodes where signature matches `value` exactly.
*/
def signatureExact(value: String): Iterator[NodeType] = traversal match {
case init: flatgraph.misc.InitNodeIterator[flatgraph.GNode @unchecked] if init.isVirgin && init.hasNext =>
val someNode = init.next
flatgraph.Accessors
.getWithInverseIndex(someNode.graph, someNode.nodeKind, 49, value)
.asInstanceOf[Iterator[NodeType]]
case _ => traversal.filter { _.signature == value }
}
/** Traverse to nodes where signature matches one of the elements in `values` exactly.
*/
def signatureExact(values: String*): Iterator[NodeType] =
if (values.length == 1) signatureExact(values.head)
else {
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.signature) }
}
/** Traverse to nodes where signature does not match the regular expression `value`.
*/
def signatureNot(pattern: String): Iterator[NodeType] = {
if (!flatgraph.misc.Regex.isRegex(pattern)) {
traversal.filter { node => node.signature != pattern }
} else {
val matcher = flatgraph.misc.Regex.multilineMatcher(pattern)
traversal.filterNot { item => matcher.reset(item.signature).matches }
}
}
/** Traverse to nodes where signature does not match any of the regular expressions in `values`.
*/
def signatureNot(patterns: String*): Iterator[NodeType] = {
val matchers = patterns.map(flatgraph.misc.Regex.multilineMatcher)
traversal.filter { item => matchers.find { _.reset(item.signature).matches }.isEmpty }
}
}