22 * Contains predicates for converting an arbitrary graph to a set of `typeModel` rows.
33 */
44
5+ private import codeql.util.Location
6+
57/**
68 * Concatenates two access paths, separating them by `.` unless one of them is empty.
79 */
@@ -10,21 +12,20 @@ string join(string x, string y) {
1012 if x = "" or y = "" then result = x + y else result = x + "." + y
1113}
1214
13- signature class NodeSig {
14- /**
15- * Holds if this node is located in file `path` between line `startline`, column `startcol`,
16- * and line `endline`, column `endcol`.
17- */
18- predicate hasLocationInfo ( string path , int startline , int startcol , int endline , int endcol ) ;
15+ private module WithLocation< LocationSig Location> {
16+ signature class NodeSig {
17+ /** Gets the location of this node if it has one. */
18+ Location getLocation ( ) ;
1919
20- /** Gets a string representation of this node. */
21- string toString ( ) ;
20+ /** Gets a string representation of this node. */
21+ string toString ( ) ;
22+ }
2223}
2324
2425/**
2526 * Specifies a graph to export in `GraphExport`.
2627 */
27- signature module GraphExportSig< NodeSig Node> {
28+ signature module GraphExportSig< LocationSig Location , WithLocation < Location > :: NodeSig Node> {
2829 /**
2930 * Holds if an edge `pred -> succ` exist with the access path `path`.
3031 */
@@ -81,7 +82,9 @@ signature module GraphExportSig<NodeSig Node> {
8182/**
8283 * Module for exporting an arbitrary graph as models-as-data rows.
8384 */
84- module GraphExport< NodeSig Node, GraphExportSig< Node > S> {
85+ module GraphExport<
86+ LocationSig Location, WithLocation< Location > :: NodeSig Node, GraphExportSig< Location , Node > S>
87+ {
8588 private import S
8689
8790 private Node getAnExposedNode ( ) {
@@ -163,9 +166,10 @@ module GraphExport<NodeSig Node, GraphExportSig<Node> S> {
163166 node =
164167 rank [ k ] ( RelevantNode n , string path , int startline , int startcol , int endline , int endcol |
165168 isSyntheticallyNamedNode ( n , prefixTypeName ) and
166- n .hasLocationInfo ( path , startline , startcol , endline , endcol )
169+ n .getLocation ( ) . hasLocationInfo ( path , startline , startcol , endline , endcol )
167170 |
168171 // Use location information for an arbitrary ordering
172+ // TODO: improve support for nodes without a location, currently they can cause FNs
169173 n order by path , startline , startcol , endline , endcol
170174 ) and
171175 result = prefixTypeName + "~expr" + k
0 commit comments