Skip to content

Commit b2d0c60

Browse files
committed
Replace hasLocationInfo with getLocation in API::Node
1 parent 58d0671 commit b2d0c60

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

ql/lib/codeql/Locations.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,8 @@ class Location extends @location {
5959
this.getStartLine() = other.getStartLine() and this.getStartColumn() < other.getStartColumn()
6060
}
6161
}
62+
63+
/** An entity representing an empty location. */
64+
class EmptyLocation extends Location {
65+
EmptyLocation() { this.hasLocationInfo("", 0, 0, 0, 0) }
66+
}

ql/lib/codeql/ruby/ApiGraphs.qll

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -140,26 +140,14 @@ module API {
140140
*/
141141
DataFlow::Node getInducingNode() { this = Impl::MkUse(result) }
142142

143-
/**
144-
* Holds if this element is at the specified location.
145-
* The location spans column `startcolumn` of line `startline` to
146-
* column `endcolumn` of line `endline` in file `filepath`.
147-
* For more information, see
148-
* [Locations](https://help.semmle.com/QL/learn-ql/locations.html).
149-
*/
150-
predicate hasLocationInfo(
151-
string filepath, int startline, int startcolumn, int endline, int endcolumn
152-
) {
153-
getInducingNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
143+
/** Gets the location of this node. */
144+
Location getLocation() {
145+
result = this.getInducingNode().getLocation()
154146
or
155147
// For nodes that do not have a meaningful location, `path` is the empty string and all other
156148
// parameters are zero.
157149
not exists(getInducingNode()) and
158-
filepath = "" and
159-
startline = 0 and
160-
startcolumn = 0 and
161-
endline = 0 and
162-
endcolumn = 0
150+
result instanceof EmptyLocation
163151
}
164152

165153
/**

0 commit comments

Comments
 (0)