1
1
/** Provides classes for working with locations and program elements that have locations. */
2
2
3
3
import go
4
- private import internal.Locations
5
4
6
5
/**
7
6
* A location as given by a file, a start line, a start column,
@@ -11,21 +10,21 @@ private import internal.Locations
11
10
*
12
11
* For more information about locations see [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
13
12
*/
14
- class DbLocation extends TDbLocation {
13
+ class Location extends @location {
15
14
/** Gets the file for this location. */
16
- File getFile ( ) { dbLocationInfo ( this , result , _, _, _, _) }
15
+ File getFile ( ) { locations_default ( this , result , _, _, _, _) }
17
16
18
17
/** Gets the 1-based line number (inclusive) where this location starts. */
19
- int getStartLine ( ) { dbLocationInfo ( this , _, result , _, _, _) }
18
+ int getStartLine ( ) { locations_default ( this , _, result , _, _, _) }
20
19
21
20
/** Gets the 1-based column number (inclusive) where this location starts. */
22
- int getStartColumn ( ) { dbLocationInfo ( this , _, _, result , _, _) }
21
+ int getStartColumn ( ) { locations_default ( this , _, _, result , _, _) }
23
22
24
23
/** Gets the 1-based line number (inclusive) where this location ends. */
25
- int getEndLine ( ) { dbLocationInfo ( this , _, _, _, result , _) }
24
+ int getEndLine ( ) { locations_default ( this , _, _, _, result , _) }
26
25
27
26
/** Gets the 1-based column number (inclusive) where this location ends. */
28
- int getEndColumn ( ) { dbLocationInfo ( this , _, _, _, _, result ) }
27
+ int getEndColumn ( ) { locations_default ( this , _, _, _, _, result ) }
29
28
30
29
/** Gets the number of lines covered by this location. */
31
30
int getNumLines ( ) { result = this .getEndLine ( ) - this .getStartLine ( ) + 1 }
@@ -48,22 +47,22 @@ class DbLocation extends TDbLocation {
48
47
predicate hasLocationInfo (
49
48
string filepath , int startline , int startcolumn , int endline , int endcolumn
50
49
) {
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 ) |
53
51
filepath = f .getAbsolutePath ( )
54
52
)
55
53
}
56
54
}
57
55
58
- final class Location = LocationImpl ;
59
-
60
56
/** A program element with a location. */
61
57
class Locatable extends @locatable {
62
58
/** Gets the file this program element comes from. */
63
59
File getFile ( ) { result = this .getLocation ( ) .getFile ( ) }
64
60
65
61
/** 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
+ }
67
66
68
67
/** Gets the number of lines covered by this element. */
69
68
int getNumLines ( ) { result = this .getLocation ( ) .getNumLines ( ) }
0 commit comments