Skip to content

Commit e946f49

Browse files
[Test gen] Gen methods for Set and Iterator
1 parent 0bff1b4 commit e946f49

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

java/ql/src/utils/FlowTestCaseSupportMethods.qll

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,34 @@ private class ListGenMethod extends GenMethod {
364364
override string getCall(string arg) { result = "List.of(" + arg + ")" }
365365
}
366366

367+
private class SetGenMethod extends GenMethod {
368+
SetGenMethod() { this = "SetGenMethod" }
369+
370+
override predicate appliesTo(Type t, Content c) {
371+
exists(GenericType set | set.hasQualifiedName("java.util", "Set") |
372+
t.getErasure() = set.getErasure()
373+
) and
374+
c instanceof CollectionContent
375+
}
376+
377+
bindingset[arg]
378+
override string getCall(string arg) { result = "Set.of(" + arg + ")" }
379+
}
380+
381+
private class IteratorGenMethod extends GenMethod {
382+
IteratorGenMethod() { this = "IteratorGenMethod" }
383+
384+
override predicate appliesTo(Type t, Content c) {
385+
exists(GenericType set | set.hasQualifiedName("java.util", "Iterator") |
386+
t.getErasure() = set.getErasure()
387+
) and
388+
c instanceof CollectionContent
389+
}
390+
391+
bindingset[arg]
392+
override string getCall(string arg) { result = "List.of(" + arg + ").iterator()" }
393+
}
394+
367395
private class OptionalGenMethod extends GenMethod {
368396
OptionalGenMethod() { this = "optionalgenmethod" }
369397

0 commit comments

Comments
 (0)