Skip to content

Commit 227c5fa

Browse files
committed
Java: Get location ordering without toString
1 parent efe539e commit 227c5fa

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

java/ql/src/Telemetry/AutomodelApplicationModeExtractNegativeExamples.ql

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @tags internal extract automodel application-mode negative examples
99
*/
1010

11+
private import java
1112
private import AutomodelApplicationModeCharacteristics
1213
private import AutomodelEndpointTypes
1314
private import AutomodelSharedUtil
@@ -19,7 +20,14 @@ bindingset[limit]
1920
Endpoint getSampleForCharacteristic(EndpointCharacteristic c, int limit) {
2021
exists(int n |
2122
result =
22-
rank[n](Endpoint e2 | c.appliesToEndpoint(e2) | e2 order by e2.getLocation().toString()) and
23+
rank[n](Endpoint e, Location loc |
24+
loc = e.getLocation() and c.appliesToEndpoint(e)
25+
|
26+
e
27+
order by
28+
loc.getFile().getAbsolutePath(), loc.getStartLine(), loc.getStartColumn(),
29+
loc.getEndLine(), loc.getEndColumn()
30+
) and
2331
// we order the endpoints by location, but (to avoid bias) we select the indices semi-randomly
2432
n = 1 + (([1 .. limit] * 271) % count(Endpoint e | c.appliesToEndpoint(e)))
2533
)

0 commit comments

Comments
 (0)