@@ -14,12 +14,23 @@ predicate multipleCallsToSuperclassMethod(
14
14
meth .getName ( ) = name and
15
15
meth .getScope ( ) = cls and
16
16
locationBefore ( call1 .getLocation ( ) , call2 .getLocation ( ) ) and
17
- calledMulti = getASuperCallTargetFromCall ( cls , meth , call1 , name ) and
18
- calledMulti = getASuperCallTargetFromCall ( cls , meth , call2 , name ) and
17
+ rankedSuperCallByLocation ( 1 , cls , meth , call1 , name , calledMulti ) and
18
+ rankedSuperCallByLocation ( 2 , cls , meth , call2 , name , calledMulti ) and
19
19
nonTrivial ( calledMulti )
20
20
)
21
21
}
22
22
23
+ predicate rankedSuperCallByLocation (
24
+ int i , Class mroBase , Function meth , DataFlow:: MethodCallNode call , string name , Function target
25
+ ) {
26
+ call =
27
+ rank [ i ] ( DataFlow:: MethodCallNode calli |
28
+ target = getASuperCallTargetFromCall ( mroBase , meth , calli , name )
29
+ |
30
+ calli order by calli .getLocation ( ) .getStartLine ( ) , calli .getLocation ( ) .getStartColumn ( )
31
+ )
32
+ }
33
+
23
34
/** Holds if l1 comes before l2, assuming they're in the same file. */
24
35
pragma [ inline]
25
36
private predicate locationBefore ( Location l1 , Location l2 ) {
@@ -176,40 +187,7 @@ Function getPossibleMissingSuper(Class base, Function shouldCall, string name) {
176
187
)
177
188
}
178
189
179
- private module FunctionOption = Option< Function > ;
180
-
181
- /** An optional `Function`. */
182
- class FunctionOption extends FunctionOption:: Option {
183
- /**
184
- * Holds if this element is at the specified location.
185
- * The location spans column `startcolumn` of line `startline` to
186
- * column `endcolumn` of line `endline` in file `filepath`.
187
- * For more information, see
188
- * [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
189
- */
190
- predicate hasLocationInfo (
191
- string filepath , int startline , int startcolumn , int endline , int endcolumn
192
- ) {
193
- this .asSome ( )
194
- .getLocation ( )
195
- .hasLocationInfo ( filepath , startline , startcolumn , endline , endcolumn )
196
- or
197
- this .isNone ( ) and
198
- filepath = "" and
199
- startline = 0 and
200
- startcolumn = 0 and
201
- endline = 0 and
202
- endcolumn = 0
203
- }
204
-
205
- /** Gets the qualified name of this function. */
206
- string getQualifiedName ( ) {
207
- result = this .asSome ( ) .getQualifiedName ( )
208
- or
209
- this .isNone ( ) and
210
- result = ""
211
- }
212
- }
190
+ private class FunctionOption = LocatableOption< Location , Function > :: Option ;
213
191
214
192
/** Gets the result of `getPossibleMissingSuper`, or None if none exists. */
215
193
bindingset [ name]
0 commit comments