mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Rust: add Locatable::hasLocationInfo
This commit is contained in:
@@ -25,14 +25,7 @@ module Impl {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this element is at the specified location.
|
||||
* The location spans column `startcolumn` of line `startline` to
|
||||
* column `endcolumn` of line `endline` in file `filepath`.
|
||||
* For more information, see
|
||||
* [Providing locations in CodeQL queries](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
|
||||
*/
|
||||
predicate hasLocationInfo(
|
||||
override predicate hasLocationInfo(
|
||||
string filepath, int startline, int startcolumn, int endline, int endcolumn
|
||||
) {
|
||||
argument.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
|
||||
|
||||
@@ -19,15 +19,26 @@ module Impl {
|
||||
final Location getLocation() {
|
||||
exists(Raw::Locatable raw |
|
||||
raw = Synth::convertLocatableToRaw(this) and
|
||||
(
|
||||
locatable_locations(raw, result)
|
||||
or
|
||||
not exists(Location loc | locatable_locations(raw, loc)) and
|
||||
result instanceof EmptyLocation
|
||||
)
|
||||
locatable_locations(raw, result)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this element is at the specified location.
|
||||
* The location spans column `startcolumn` of line `startline` to
|
||||
* column `endcolumn` of line `endline` in file `filepath`.
|
||||
* For more information, see
|
||||
* [Providing locations in CodeQL queries](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
|
||||
*/
|
||||
predicate hasLocationInfo(
|
||||
string filepath, int startline, int startcolumn, int endline, int endcolumn
|
||||
) {
|
||||
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
|
||||
or
|
||||
not exists(this.getLocation()) and
|
||||
any(EmptyLocation e).hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the primary file where this element occurs.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user