11/** Provides classes for working with locations and program elements that have locations. */
22
33import go
4- private import internal.Locations
54
65/**
76 * A location as given by a file, a start line, a start column,
@@ -11,21 +10,21 @@ private import internal.Locations
1110 *
1211 * For more information about locations see [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
1312 */
14- class DbLocation extends TDbLocation {
13+ class Location extends @location {
1514 /** Gets the file for this location. */
16- File getFile ( ) { dbLocationInfo ( this , result , _, _, _, _) }
15+ File getFile ( ) { locations_default ( this , result , _, _, _, _) }
1716
1817 /** Gets the 1-based line number (inclusive) where this location starts. */
19- int getStartLine ( ) { dbLocationInfo ( this , _, result , _, _, _) }
18+ int getStartLine ( ) { locations_default ( this , _, result , _, _, _) }
2019
2120 /** Gets the 1-based column number (inclusive) where this location starts. */
22- int getStartColumn ( ) { dbLocationInfo ( this , _, _, result , _, _) }
21+ int getStartColumn ( ) { locations_default ( this , _, _, result , _, _) }
2322
2423 /** Gets the 1-based line number (inclusive) where this location ends. */
25- int getEndLine ( ) { dbLocationInfo ( this , _, _, _, result , _) }
24+ int getEndLine ( ) { locations_default ( this , _, _, _, result , _) }
2625
2726 /** Gets the 1-based column number (inclusive) where this location ends. */
28- int getEndColumn ( ) { dbLocationInfo ( this , _, _, _, _, result ) }
27+ int getEndColumn ( ) { locations_default ( this , _, _, _, _, result ) }
2928
3029 /** Gets the number of lines covered by this location. */
3130 int getNumLines ( ) { result = this .getEndLine ( ) - this .getStartLine ( ) + 1 }
@@ -48,22 +47,22 @@ class DbLocation extends TDbLocation {
4847 predicate hasLocationInfo (
4948 string filepath , int startline , int startcolumn , int endline , int endcolumn
5049 ) {
51- exists ( File f |
52- dbLocationInfo ( this , f , startline , startcolumn , endline , endcolumn ) and
50+ exists ( File f | locations_default ( this , f , startline , startcolumn , endline , endcolumn ) |
5351 filepath = f .getAbsolutePath ( )
5452 )
5553 }
5654}
5755
58- final class Location = LocationImpl ;
59-
6056/** A program element with a location. */
6157class Locatable extends @locatable {
6258 /** Gets the file this program element comes from. */
6359 File getFile ( ) { result = this .getLocation ( ) .getFile ( ) }
6460
6561 /** Gets this element's location. */
66- final DbLocation getLocation ( ) { result = getLocatableLocation ( this ) }
62+ final Location getLocation ( ) {
63+ has_location ( this , result ) or
64+ xmllocations ( this , result )
65+ }
6766
6867 /** Gets the number of lines covered by this element. */
6968 int getNumLines ( ) { result = this .getLocation ( ) .getNumLines ( ) }
0 commit comments