Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use the index for stuff like cpg.method.fullNameExact(a,b,c) #297

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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 @@ -126,10 +126,18 @@ object CodeSnippets {
|/**
| * Traverse to nodes where $nameCamelCase matches one of the elements in `values` exactly.
| * */
|def ${nameCamelCase}Exact(values: $baseType*): Iterator[NodeType] =
| if(values.length == 1) ${nameCamelCase}Exact(values.head) else {
| val valueSet = values.toSet
| traversal.filter{item => valueSet.contains(item.$nameCamelCase)}
|def ${nameCamelCase}Exact(values: $baseType*): Iterator[NodeType] = {
| if(values.length == 1) return ${nameCamelCase}Exact(values.head)
| traversal match {
| case init: flatgraph.misc.InitNodeIterator[flatgraph.GNode @unchecked] if init.isVirgin && init.hasNext =>
| val someNode = init.next
| values.iterator.flatMap { value =>
| flatgraph.Accessors.getWithInverseIndex(someNode.graph, someNode.nodeKind, $propertyId, value).asInstanceOf[Iterator[NodeType]]
| }
| case _ =>
| val valueSet = values.toSet
| traversal.filter{item => valueSet.contains(item.$nameCamelCase)}
| }
| }
|
|/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,19 @@ final class TraversalCallBase[NodeType <: nodes.CallBase](val traversal: Iterato

/** Traverse to nodes where dispatchType matches one of the elements in `values` exactly.
*/
def dispatchTypeExact(values: String*): Iterator[NodeType] =
if (values.length == 1) dispatchTypeExact(values.head)
else {
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.dispatchType) }
def dispatchTypeExact(values: String*): Iterator[NodeType] = {
if (values.length == 1) return dispatchTypeExact(values.head)
traversal match {
case init: flatgraph.misc.InitNodeIterator[flatgraph.GNode @unchecked] if init.isVirgin && init.hasNext =>
val someNode = init.next
values.iterator.flatMap { v =>
flatgraph.Accessors.getWithInverseIndex(someNode.graph, someNode.nodeKind, 0, v).asInstanceOf[Iterator[NodeType]]
}
case _ =>
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.dispatchType) }
}
}

/** Traverse to nodes where dispatchType does not match the regular expression `value`.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,19 @@ final class TraversalCallreprBase[NodeType <: nodes.CallReprBase](val traversal:

/** 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) }
def nameExact(values: String*): Iterator[NodeType] = {
if (values.length == 1) return nameExact(values.head)
traversal match {
case init: flatgraph.misc.InitNodeIterator[flatgraph.GNode @unchecked] if init.isVirgin && init.hasNext =>
val someNode = init.next
values.iterator.flatMap { v =>
flatgraph.Accessors.getWithInverseIndex(someNode.graph, someNode.nodeKind, 1, v).asInstanceOf[Iterator[NodeType]]
}
case _ =>
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.name) }
}
}

/** Traverse to nodes where name does not match the regular expression `value`.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,19 @@ final class TraversalDeclarationBase[NodeType <: nodes.DeclarationBase](val trav

/** 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) }
def nameExact(values: String*): Iterator[NodeType] = {
if (values.length == 1) return nameExact(values.head)
traversal match {
case init: flatgraph.misc.InitNodeIterator[flatgraph.GNode @unchecked] if init.isVirgin && init.hasNext =>
val someNode = init.next
values.iterator.flatMap { v =>
flatgraph.Accessors.getWithInverseIndex(someNode.graph, someNode.nodeKind, 1, v).asInstanceOf[Iterator[NodeType]]
}
case _ =>
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.name) }
}
}

/** Traverse to nodes where name does not match the regular expression `value`.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,19 @@ final class TraversalPropertyDispatchType[NodeType <: nodes.StoredNode & nodes.S

/** Traverse to nodes where dispatchType matches one of the elements in `values` exactly.
*/
def dispatchTypeExact(values: String*): Iterator[NodeType] =
if (values.length == 1) dispatchTypeExact(values.head)
else {
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.dispatchType) }
def dispatchTypeExact(values: String*): Iterator[NodeType] = {
if (values.length == 1) return dispatchTypeExact(values.head)
traversal match {
case init: flatgraph.misc.InitNodeIterator[flatgraph.GNode @unchecked] if init.isVirgin && init.hasNext =>
val someNode = init.next
values.iterator.flatMap { v =>
flatgraph.Accessors.getWithInverseIndex(someNode.graph, someNode.nodeKind, 0, v).asInstanceOf[Iterator[NodeType]]
}
case _ =>
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.dispatchType) }
}
}

/** Traverse to nodes where dispatchType does not match the regular expression `value`.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,19 @@ final class TraversalPropertyName[NodeType <: nodes.StoredNode & nodes.StaticTyp

/** 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) }
def nameExact(values: String*): Iterator[NodeType] = {
if (values.length == 1) return nameExact(values.head)
traversal match {
case init: flatgraph.misc.InitNodeIterator[flatgraph.GNode @unchecked] if init.isVirgin && init.hasNext =>
val someNode = init.next
values.iterator.flatMap { v =>
flatgraph.Accessors.getWithInverseIndex(someNode.graph, someNode.nodeKind, 1, v).asInstanceOf[Iterator[NodeType]]
}
case _ =>
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.name) }
}
}

/** Traverse to nodes where name does not match the regular expression `value`.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,19 @@ final class TraversalNodeaBase[NodeType <: nodes.NodeABase](val traversal: Itera

/** Traverse to nodes where stringMandatory matches one of the elements in `values` exactly.
*/
def stringMandatoryExact(values: String*): Iterator[NodeType] =
if (values.length == 1) stringMandatoryExact(values.head)
else {
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.stringMandatory) }
def stringMandatoryExact(values: String*): Iterator[NodeType] = {
if (values.length == 1) return stringMandatoryExact(values.head)
traversal match {
case init: flatgraph.misc.InitNodeIterator[flatgraph.GNode @unchecked] if init.isVirgin && init.hasNext =>
val someNode = init.next
values.iterator.flatMap { v =>
flatgraph.Accessors.getWithInverseIndex(someNode.graph, someNode.nodeKind, 4, v).asInstanceOf[Iterator[NodeType]]
}
case _ =>
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.stringMandatory) }
}
}

/** Traverse to nodes where stringMandatory does not match the regular expression `value`.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,19 @@ final class TraversalPropertyStringMandatory[NodeType <: nodes.StoredNode & node

/** Traverse to nodes where stringMandatory matches one of the elements in `values` exactly.
*/
def stringMandatoryExact(values: String*): Iterator[NodeType] =
if (values.length == 1) stringMandatoryExact(values.head)
else {
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.stringMandatory) }
def stringMandatoryExact(values: String*): Iterator[NodeType] = {
if (values.length == 1) return stringMandatoryExact(values.head)
traversal match {
case init: flatgraph.misc.InitNodeIterator[flatgraph.GNode @unchecked] if init.isVirgin && init.hasNext =>
val someNode = init.next
values.iterator.flatMap { v =>
flatgraph.Accessors.getWithInverseIndex(someNode.graph, someNode.nodeKind, 4, v).asInstanceOf[Iterator[NodeType]]
}
case _ =>
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.stringMandatory) }
}
}

/** Traverse to nodes where stringMandatory does not match the regular expression `value`.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,19 @@ final class TraversalArtistBase[NodeType <: nodes.ArtistBase](val traversal: Ite

/** 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) }
def nameExact(values: String*): Iterator[NodeType] = {
if (values.length == 1) return nameExact(values.head)
traversal match {
case init: flatgraph.misc.InitNodeIterator[flatgraph.GNode @unchecked] if init.isVirgin && init.hasNext =>
val someNode = init.next
values.iterator.flatMap { v =>
flatgraph.Accessors.getWithInverseIndex(someNode.graph, someNode.nodeKind, 0, v).asInstanceOf[Iterator[NodeType]]
}
case _ =>
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.name) }
}
}

/** Traverse to nodes where name does not match the regular expression `value`.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,19 @@ final class TraversalPropertyName[NodeType <: nodes.StoredNode & nodes.StaticTyp

/** 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) }
def nameExact(values: String*): Iterator[NodeType] = {
if (values.length == 1) return nameExact(values.head)
traversal match {
case init: flatgraph.misc.InitNodeIterator[flatgraph.GNode @unchecked] if init.isVirgin && init.hasNext =>
val someNode = init.next
values.iterator.flatMap { v =>
flatgraph.Accessors.getWithInverseIndex(someNode.graph, someNode.nodeKind, 0, v).asInstanceOf[Iterator[NodeType]]
}
case _ =>
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.name) }
}
}

/** Traverse to nodes where name does not match the regular expression `value`.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,19 @@ final class TraversalSongBase[NodeType <: nodes.SongBase](val traversal: Iterato

/** 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) }
def nameExact(values: String*): Iterator[NodeType] = {
if (values.length == 1) return nameExact(values.head)
traversal match {
case init: flatgraph.misc.InitNodeIterator[flatgraph.GNode @unchecked] if init.isVirgin && init.hasNext =>
val someNode = init.next
values.iterator.flatMap { v =>
flatgraph.Accessors.getWithInverseIndex(someNode.graph, someNode.nodeKind, 0, v).asInstanceOf[Iterator[NodeType]]
}
case _ =>
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.name) }
}
}

/** Traverse to nodes where name does not match the regular expression `value`.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,19 @@ final class TraversalBasenodeBase[NodeType <: nodes.BaseNodeBase](val traversal:

/** 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) }
def nameExact(values: String*): Iterator[NodeType] = {
if (values.length == 1) return nameExact(values.head)
traversal match {
case init: flatgraph.misc.InitNodeIterator[flatgraph.GNode @unchecked] if init.isVirgin && init.hasNext =>
val someNode = init.next
values.iterator.flatMap { v =>
flatgraph.Accessors.getWithInverseIndex(someNode.graph, someNode.nodeKind, 0, v).asInstanceOf[Iterator[NodeType]]
}
case _ =>
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.name) }
}
}

/** Traverse to nodes where name does not match the regular expression `value`.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,19 @@ final class TraversalPropertyName[NodeType <: nodes.StoredNode & nodes.StaticTyp

/** 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) }
def nameExact(values: String*): Iterator[NodeType] = {
if (values.length == 1) return nameExact(values.head)
traversal match {
case init: flatgraph.misc.InitNodeIterator[flatgraph.GNode @unchecked] if init.isVirgin && init.hasNext =>
val someNode = init.next
values.iterator.flatMap { v =>
flatgraph.Accessors.getWithInverseIndex(someNode.graph, someNode.nodeKind, 0, v).asInstanceOf[Iterator[NodeType]]
}
case _ =>
val valueSet = values.toSet
traversal.filter { item => valueSet.contains(item.name) }
}
}

/** Traverse to nodes where name does not match the regular expression `value`.
*/
Expand Down
Loading