33import go
44private import internal.Locations
55
6+ private module DbLocationInput implements LocationClassInputSig {
7+ class Base = TDbLocation ;
8+
9+ predicate locationInfo (
10+ Base b , string filepath , int startline , int startcolumn , int endline , int endcolumn
11+ ) {
12+ exists ( File f |
13+ dbLocationInfo ( b , f , startline , startcolumn , endline , endcolumn ) and
14+ filepath = f .getAbsolutePath ( )
15+ )
16+ }
17+ }
18+
619/**
720 * A location as given by a file, a start line, a start column,
821 * an end line, and an end column.
@@ -11,51 +24,57 @@ private import internal.Locations
1124 *
1225 * For more information about locations see [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
1326 */
14- class DbLocation extends TDbLocation {
27+ final class DbLocation extends LocationClass < DbLocationInput > :: Location {
1528 /** Gets the file for this location. */
1629 File getFile ( ) { dbLocationInfo ( this , result , _, _, _, _) }
30+ }
1731
18- /** Gets the 1-based line number (inclusive) where this location starts. */
19- int getStartLine ( ) { dbLocationInfo ( this , _, result , _, _, _) }
20-
21- /** Gets the 1-based column number (inclusive) where this location starts. */
22- int getStartColumn ( ) { dbLocationInfo ( this , _, _, result , _, _) }
32+ private module DbOrBasicBlockLocationInput implements LocationClassInputSig {
33+ class Base = TDbLocation or TBasicBlockLocation ;
2334
24- /** Gets the 1-based line number (inclusive) where this location ends. */
25- int getEndLine ( ) { dbLocationInfo ( this , _, _, _, result , _) }
35+ predicate locationInfo (
36+ Base b , string filepath , int startline , int startcolumn , int endline , int endcolumn
37+ ) {
38+ DbLocationInput:: locationInfo ( b , filepath , startline , startcolumn , endline , endcolumn )
39+ or
40+ basicBlockLocationInfo ( b , filepath , startline , startcolumn , endline , endcolumn )
41+ }
42+ }
2643
27- /** Gets the 1-based column number (inclusive) where this location ends. */
28- int getEndColumn ( ) { dbLocationInfo ( this , _, _, _, _, result ) }
44+ /**
45+ * A location as given by a file, a start line, a start column,
46+ * an end line, and an end column.
47+ *
48+ * This class is restricted to locations created by the extractor or
49+ * synthesized for basic blocks.
50+ *
51+ * For more information about locations see [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
52+ */
53+ class DbOrBasicBlockLocation = LocationClass< DbOrBasicBlockLocationInput > :: Location ;
2954
30- /** Gets the number of lines covered by this location. */
31- int getNumLines ( ) { result = this . getEndLine ( ) - this . getStartLine ( ) + 1 }
55+ private module LocationInput implements LocationClassInputSig {
56+ class Base = TLocation ;
3257
33- /** Gets a textual representation of this element. */
34- string toString ( ) {
35- exists ( string filepath , int startline , int startcolumn , int endline , int endcolumn |
36- this .hasLocationInfo ( filepath , startline , startcolumn , endline , endcolumn ) and
37- result = filepath + "@" + startline + ":" + startcolumn + ":" + endline + ":" + endcolumn
38- )
39- }
40-
41- /**
42- * Holds if this element is at the specified location.
43- * The location spans column `startcolumn` of line `startline` to
44- * column `endcolumn` of line `endline` in file `filepath`.
45- * For more information, see
46- * [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
47- */
48- predicate hasLocationInfo (
49- string filepath , int startline , int startcolumn , int endline , int endcolumn
58+ predicate locationInfo (
59+ Base b , string filepath , int startline , int startcolumn , int endline , int endcolumn
5060 ) {
51- exists ( File f |
52- dbLocationInfo ( this , f , startline , startcolumn , endline , endcolumn ) and
53- filepath = f . getAbsolutePath ( )
54- )
61+ DbOrBasicBlockLocationInput :: locationInfo ( b , filepath , startline , startcolumn , endline ,
62+ endcolumn )
63+ or
64+ dataFlowNodeLocationInfo ( b , filepath , startline , startcolumn , endline , endcolumn )
5565 }
5666}
5767
58- final class Location = LocationImpl ;
68+ /**
69+ * A location as given by a file, a start line, a start column,
70+ * an end line, and an end column.
71+ *
72+ * For more information about locations see [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
73+ */
74+ final class Location extends LocationClass< LocationInput > :: Location {
75+ /** Gets the file for this location. */
76+ File getFile ( ) { dbLocationInfo ( this , result , _, _, _, _) }
77+ }
5978
6079/** A program element with a location. */
6180class Locatable extends @locatable {
0 commit comments