Skip to content

add column number to location #1812

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

Merged
merged 1 commit into from
Mar 3, 2025
Merged
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
@@ -668,6 +668,8 @@ object GraphSchema extends flatgraph.Schema {
nodePropertyDescriptors(575) = FormalQtyType.QtyOne
nodePropertyDescriptors(662) = FormalQtyType.StringType // LOCATION.CLASS_SHORT_NAME
nodePropertyDescriptors(663) = FormalQtyType.QtyOne
nodePropertyDescriptors(1014) = FormalQtyType.IntType // LOCATION.COLUMN_NUMBER
nodePropertyDescriptors(1015) = FormalQtyType.QtyOption
nodePropertyDescriptors(1894) = FormalQtyType.StringType // LOCATION.FILENAME
nodePropertyDescriptors(1895) = FormalQtyType.QtyOne
nodePropertyDescriptors(3126) = FormalQtyType.IntType // LOCATION.LINE_NUMBER
@@ -1240,6 +1242,7 @@ object GraphSchema extends flatgraph.Schema {
_newNodeInserters(4708) = nodes.NewLocal.InsertionHelpers.NewNodeInserter_Local_typeFullName
_newNodeInserters(574) = nodes.NewLocation.InsertionHelpers.NewNodeInserter_Location_className
_newNodeInserters(662) = nodes.NewLocation.InsertionHelpers.NewNodeInserter_Location_classShortName
_newNodeInserters(1014) = nodes.NewLocation.InsertionHelpers.NewNodeInserter_Location_columnNumber
_newNodeInserters(1894) = nodes.NewLocation.InsertionHelpers.NewNodeInserter_Location_filename
_newNodeInserters(3126) = nodes.NewLocation.InsertionHelpers.NewNodeInserter_Location_lineNumber
_newNodeInserters(3302) = nodes.NewLocation.InsertionHelpers.NewNodeInserter_Location_methodFullName
@@ -1618,6 +1621,7 @@ object GraphSchema extends flatgraph.Schema {
Set(
"CLASS_NAME",
"CLASS_SHORT_NAME",
"COLUMN_NUMBER",
"FILENAME",
"LINE_NUMBER",
"METHOD_FULL_NAME",
Original file line number Diff line number Diff line change
@@ -492,6 +492,10 @@ object Accessors {
case stored: nodes.StoredNode => new AccessPropertyClassShortName(stored).classShortName
case newNode: nodes.NewLocation => newNode.classShortName
}
def columnNumber: Option[Int] = node match {
case stored: nodes.StoredNode => new AccessPropertyColumnNumber(stored).columnNumber
case newNode: nodes.NewLocation => newNode.columnNumber
}
def filename: String = node match {
case stored: nodes.StoredNode => new AccessPropertyFilename(stored).filename
case newNode: nodes.NewLocation => newNode.filename
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ trait LocationEMT
extends AnyRef
with HasClassNameEMT
with HasClassShortNameEMT
with HasColumnNumberEMT
with HasFilenameEMT
with HasLineNumberEMT
with HasMethodFullNameEMT
@@ -26,6 +27,7 @@ trait LocationBase extends AbstractNode with StaticType[LocationEMT] {
val res = new java.util.HashMap[String, Any]()
if (("<empty>": String) != this.className) res.put("CLASS_NAME", this.className)
if (("<empty>": String) != this.classShortName) res.put("CLASS_SHORT_NAME", this.classShortName)
this.columnNumber.foreach { p => res.put("COLUMN_NUMBER", p) }
if (("<empty>": String) != this.filename) res.put("FILENAME", this.filename)
this.lineNumber.foreach { p => res.put("LINE_NUMBER", p) }
if (("<empty>": String) != this.methodFullName) res.put("METHOD_FULL_NAME", this.methodFullName)
@@ -46,6 +48,10 @@ object Location {

val ClassShortName = "CLASS_SHORT_NAME"

/** This optional fields provides the column number of the program construct represented by the node.
*/
val ColumnNumber = "COLUMN_NUMBER"

/** The path of the source file this node was generated from, relative to the root path in the meta data node. This
* field must be set but may be set to the value `<unknown>` to indicate that no source file can be associated with
* the node, e.g., because the node represents an entity known to exist because it is referenced, but for which the
@@ -75,6 +81,10 @@ object Location {
val ClassName = flatgraph.SinglePropertyKey[String](kind = 6, name = "CLASS_NAME", default = "<empty>")
val ClassShortName = flatgraph.SinglePropertyKey[String](kind = 7, name = "CLASS_SHORT_NAME", default = "<empty>")

/** This optional fields provides the column number of the program construct represented by the node.
*/
val ColumnNumber = flatgraph.OptionalPropertyKey[Int](kind = 11, name = "COLUMN_NUMBER")

/** The path of the source file this node was generated from, relative to the root path in the meta data node. This
* field must be set but may be set to the value `<unknown>` to indicate that no source file can be associated with
* the node, e.g., because the node represents an entity known to exist because it is referenced, but for which the
@@ -116,36 +126,38 @@ class Location(graph_4762: flatgraph.Graph, seq_4762: Int)

override def productElementName(n: Int): String =
n match {
case 0 => "className"
case 1 => "classShortName"
case 2 => "filename"
case 3 => "lineNumber"
case 4 => "methodFullName"
case 5 => "methodShortName"
case 6 => "nodeLabel"
case 7 => "packageName"
case 8 => "symbol"
case 9 => "node"
case _ => ""
case 0 => "className"
case 1 => "classShortName"
case 2 => "columnNumber"
case 3 => "filename"
case 4 => "lineNumber"
case 5 => "methodFullName"
case 6 => "methodShortName"
case 7 => "nodeLabel"
case 8 => "packageName"
case 9 => "symbol"
case 10 => "node"
case _ => ""
}

override def productElement(n: Int): Any =
n match {
case 0 => this.className
case 1 => this.classShortName
case 2 => this.filename
case 3 => this.lineNumber
case 4 => this.methodFullName
case 5 => this.methodShortName
case 6 => this.nodeLabel
case 7 => this.packageName
case 8 => this.symbol
case 9 => this.node
case _ => null
case 0 => this.className
case 1 => this.classShortName
case 2 => this.columnNumber
case 3 => this.filename
case 4 => this.lineNumber
case 5 => this.methodFullName
case 6 => this.methodShortName
case 7 => this.nodeLabel
case 8 => this.packageName
case 9 => this.symbol
case 10 => this.node
case _ => null
}

override def productPrefix = "Location"
override def productArity = 10
override def productArity = 11

override def canEqual(that: Any): Boolean = that != null && that.isInstanceOf[Location]
}
@@ -206,6 +218,35 @@ object NewLocation {
}
}
}
object NewNodeInserter_Location_columnNumber extends flatgraph.NewNodePropertyInsertionHelper {
override def insertNewNodeProperties(
newNodes: mutable.ArrayBuffer[flatgraph.DNode],
dst: AnyRef,
offsets: Array[Int]
): Unit = {
if (newNodes.isEmpty) return
val dstCast = dst.asInstanceOf[Array[Int]]
val seq = newNodes.head.storedRef.get.seq()
var offset = offsets(seq)
var idx = 0
while (idx < newNodes.length) {
val nn = newNodes(idx)
nn match {
case generated: NewLocation =>
generated.columnNumber match {
case Some(item) =>
dstCast(offset) = item
offset += 1
case _ =>
}
case _ =>
}
assert(seq + idx == nn.storedRef.get.seq(), "internal consistency check")
idx += 1
offsets(idx + seq) = offset
}
}
}
object NewNodeInserter_Location_filename extends flatgraph.NewNodePropertyInsertionHelper {
override def insertNewNodeProperties(
newNodes: mutable.ArrayBuffer[flatgraph.DNode],
@@ -433,6 +474,7 @@ class NewLocation extends NewNode(23.toShort) with LocationBase {

var className: String = "<empty>": String
var classShortName: String = "<empty>": String
var columnNumber: Option[Int] = None
var filename: String = "<empty>": String
var lineNumber: Option[Int] = None
var methodFullName: String = "<empty>": String
@@ -443,6 +485,8 @@ class NewLocation extends NewNode(23.toShort) with LocationBase {
var symbol: String = "<empty>": String
def className(value: String): this.type = { this.className = value; this }
def classShortName(value: String): this.type = { this.classShortName = value; this }
def columnNumber(value: Int): this.type = { this.columnNumber = Option(value); this }
def columnNumber(value: Option[Int]): this.type = { this.columnNumber = value; this }
def filename(value: String): this.type = { this.filename = value; this }
def lineNumber(value: Int): this.type = { this.lineNumber = Option(value); this }
def lineNumber(value: Option[Int]): this.type = { this.lineNumber = value; this }
@@ -456,6 +500,7 @@ class NewLocation extends NewNode(23.toShort) with LocationBase {
override def countAndVisitProperties(interface: flatgraph.BatchedUpdateInterface): Unit = {
interface.countProperty(this, 6, 1)
interface.countProperty(this, 7, 1)
interface.countProperty(this, 11, columnNumber.size)
interface.countProperty(this, 21, 1)
interface.countProperty(this, 35, lineNumber.size)
interface.countProperty(this, 37, 1)
@@ -471,6 +516,7 @@ class NewLocation extends NewNode(23.toShort) with LocationBase {
val newInstance = new NewLocation
newInstance.className = this.className
newInstance.classShortName = this.classShortName
newInstance.columnNumber = this.columnNumber
newInstance.filename = this.filename
newInstance.lineNumber = this.lineNumber
newInstance.methodFullName = this.methodFullName
@@ -484,35 +530,37 @@ class NewLocation extends NewNode(23.toShort) with LocationBase {

override def productElementName(n: Int): String =
n match {
case 0 => "className"
case 1 => "classShortName"
case 2 => "filename"
case 3 => "lineNumber"
case 4 => "methodFullName"
case 5 => "methodShortName"
case 6 => "nodeLabel"
case 7 => "packageName"
case 8 => "symbol"
case 9 => "node"
case _ => ""
case 0 => "className"
case 1 => "classShortName"
case 2 => "columnNumber"
case 3 => "filename"
case 4 => "lineNumber"
case 5 => "methodFullName"
case 6 => "methodShortName"
case 7 => "nodeLabel"
case 8 => "packageName"
case 9 => "symbol"
case 10 => "node"
case _ => ""
}

override def productElement(n: Int): Any =
n match {
case 0 => this.className
case 1 => this.classShortName
case 2 => this.filename
case 3 => this.lineNumber
case 4 => this.methodFullName
case 5 => this.methodShortName
case 6 => this.nodeLabel
case 7 => this.packageName
case 8 => this.symbol
case 9 => this.node
case _ => null
case 0 => this.className
case 1 => this.classShortName
case 2 => this.columnNumber
case 3 => this.filename
case 4 => this.lineNumber
case 5 => this.methodFullName
case 6 => this.methodShortName
case 7 => this.nodeLabel
case 8 => this.packageName
case 9 => this.symbol
case 10 => this.node
case _ => null
}

override def productPrefix = "NewLocation"
override def productArity = 10
override def productArity = 11
override def canEqual(that: Any): Boolean = that != null && that.isInstanceOf[NewLocation]
}
Original file line number Diff line number Diff line change
@@ -141,6 +141,70 @@ final class TraversalLocationBase[NodeType <: nodes.LocationBase](val traversal:
traversal.filter { item => matchers.find { _.reset(item.classShortName).matches }.isEmpty }
}

/** Traverse to columnNumber property */
def columnNumber: Iterator[Int] =
traversal.flatMap(_.columnNumber)

/** Traverse to nodes where the columnNumber equals the given `value`
*/
def columnNumber(value: Int): Iterator[NodeType] =
traversal.filter { node =>
val tmp = node.columnNumber; tmp.isDefined && tmp.get == value
}

/** Traverse to nodes where the columnNumber equals at least one of the given `values`
*/
def columnNumber(values: Int*): Iterator[NodeType] = {
val vset = values.toSet
traversal.filter { node =>
val tmp = node.columnNumber; tmp.isDefined && vset.contains(tmp.get)
}
}

/** Traverse to nodes where the columnNumber is not equal to the given `value`
*/
def columnNumberNot(value: Int): Iterator[NodeType] =
traversal.filter { node =>
val tmp = node.columnNumber; tmp.isEmpty || tmp.get != value
}

/** Traverse to nodes where the columnNumber does not equal any one of the given `values`
*/
def columnNumberNot(values: Int*): Iterator[NodeType] = {
val vset = values.toSet
traversal.filter { node =>
val tmp = node.columnNumber; tmp.isEmpty || !vset.contains(tmp.get)
}
}

/** Traverse to nodes where the columnNumber is greater than the given `value`
*/
def columnNumberGt(value: Int): Iterator[NodeType] =
traversal.filter { node =>
val tmp = node.columnNumber; tmp.isDefined && tmp.get > value
}

/** Traverse to nodes where the columnNumber is greater than or equal the given `value`
*/
def columnNumberGte(value: Int): Iterator[NodeType] =
traversal.filter { node =>
val tmp = node.columnNumber; tmp.isDefined && tmp.get >= value
}

/** Traverse to nodes where the columnNumber is less than the given `value`
*/
def columnNumberLt(value: Int): Iterator[NodeType] =
traversal.filter { node =>
val tmp = node.columnNumber; tmp.isDefined && tmp.get < value
}

/** Traverse to nodes where the columnNumber is less than or equal the given `value`
*/
def columnNumberLte(value: Int): Iterator[NodeType] =
traversal.filter { node =>
val tmp = node.columnNumber; tmp.isDefined && tmp.get <= value
}

/** Traverse to filename property */
def filename: Iterator[String] =
traversal.map(_.filename)
Original file line number Diff line number Diff line change
@@ -99,7 +99,8 @@ object TagsAndLocation extends SchemaBase {
className,
classShortName,
nodeLabel,
filename
filename,
columnNumber
)

val tagNodePair: NodeType = builder