Add a consistency query

This commit is contained in:
Ian Lynagh
2021-07-29 14:42:20 +01:00
parent 03d5646c19
commit b2acb7d7a1

View File

@@ -0,0 +1,21 @@
import java
// Locations should either be :0:0:0:0 locations (UnknownLocation, or
// a whole file), or all 4 fields should be positive.
Location badLocation() {
[result.getStartLine(), result.getEndLine(), result.getStartColumn(), result.getEndColumn()] != 0 and
[result.getStartLine(), result.getEndLine(), result.getStartColumn(), result.getEndColumn()] < 1
}
// The start should not be after the end.
Location backwardsLocation() {
result.getStartLine() > result.getEndLine()
or
result.getStartLine() = result.getEndLine() and
result.getStartColumn() > result.getEndColumn()
}
from Location l
where l = badLocation() or l = backwardsLocation()
select l