11/** Provides classes for working with locations and program elements that have locations. */
22
33import go
4+ private import internal.Locations
45
56/**
67 * A location as given by a file, a start line, a start column,
78 * an end line, and an end column.
89 *
10+ * This class is restricted to locations created by the extractor.
11+ *
912 * For more information about locations see [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
1013 */
11- class Location extends @location {
14+ class DbLocation extends TDbLocation {
1215 /** Gets the file for this location. */
13- File getFile ( ) { locations_default ( this , result , _, _, _, _) }
16+ File getFile ( ) { dbLocationInfo ( this , result , _, _, _, _) }
1417
1518 /** Gets the 1-based line number (inclusive) where this location starts. */
16- int getStartLine ( ) { locations_default ( this , _, result , _, _, _) }
19+ int getStartLine ( ) { dbLocationInfo ( this , _, result , _, _, _) }
1720
1821 /** Gets the 1-based column number (inclusive) where this location starts. */
19- int getStartColumn ( ) { locations_default ( this , _, _, result , _, _) }
22+ int getStartColumn ( ) { dbLocationInfo ( this , _, _, result , _, _) }
2023
2124 /** Gets the 1-based line number (inclusive) where this location ends. */
22- int getEndLine ( ) { locations_default ( this , _, _, _, result , _) }
25+ int getEndLine ( ) { dbLocationInfo ( this , _, _, _, result , _) }
2326
2427 /** Gets the 1-based column number (inclusive) where this location ends. */
25- int getEndColumn ( ) { locations_default ( this , _, _, _, _, result ) }
28+ int getEndColumn ( ) { dbLocationInfo ( this , _, _, _, _, result ) }
2629
2730 /** Gets the number of lines covered by this location. */
2831 int getNumLines ( ) { result = this .getEndLine ( ) - this .getStartLine ( ) + 1 }
@@ -46,19 +49,21 @@ class Location extends @location {
4649 string filepath , int startline , int startcolumn , int endline , int endcolumn
4750 ) {
4851 exists ( File f |
49- locations_default ( this , f , startline , startcolumn , endline , endcolumn ) and
52+ dbLocationInfo ( this , f , startline , startcolumn , endline , endcolumn ) and
5053 filepath = f .getAbsolutePath ( )
5154 )
5255 }
5356}
5457
58+ final class Location = LocationImpl ;
59+
5560/** A program element with a location. */
5661class Locatable extends @locatable {
5762 /** Gets the file this program element comes from. */
5863 File getFile ( ) { result = this .getLocation ( ) .getFile ( ) }
5964
6065 /** Gets this element's location. */
61- Location getLocation ( ) { has_location ( this , result ) }
66+ final DbLocation getLocation ( ) { result = getLocatableLocation ( this ) }
6267
6368 /** Gets the number of lines covered by this element. */
6469 int getNumLines ( ) { result = this .getLocation ( ) .getNumLines ( ) }
0 commit comments