Skip to content

Commit abf3bbb

Browse files
author
Sauyon Lee
committed
Add qldoc for public elements
1 parent e7611ab commit abf3bbb

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

java/ql/src/utils/FlowTestCase.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Classes pertaining to test cases themselves.
3+
*/
4+
15
import java
26
private import semmle.code.java.dataflow.internal.DataFlowUtil
37
private import semmle.code.java.dataflow.ExternalFlow

java/ql/src/utils/FlowTestCaseSupportMethods.qll

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Contains predicates and classes relating to support methods for tests, such as the `source()` and `sink()`.
3+
*/
4+
15
import java
26
private import semmle.code.java.dataflow.internal.DataFlowUtil
37
private import semmle.code.java.dataflow.ExternalFlow
@@ -53,22 +57,27 @@ private Content getContent(SummaryComponent component) {
5357
component = SummaryComponent::content(result)
5458
}
5559

60+
/** Contains utility predicates for getting relevant support methods. */
5661
module SupportMethod {
62+
/** Gets a generator method for the content type of the head of the component stack `c`. */
5763
GenMethod genMethodForContent(SummaryComponentStack c) {
5864
result = genMethodFor(any(VoidType v), c)
5965
}
6066

67+
/** Gets a generator method for the type `t` and the content type of the head of the component stack `c`. */
6168
GenMethod genMethodFor(Type t, SummaryComponentStack c) {
6269
result =
6370
min(GenMethod g |
6471
g = min(GenMethod g1 | g1.appliesTo(t, getContent(c.head())) | g1 order by g1.getPriority())
6572
)
6673
}
6774

75+
/** Gets a getter method for the content type of the head of the component stack `c`. */
6876
GetMethod getMethodForContent(SummaryComponentStack c) {
6977
result = getMethodFor(any(VoidType v), c)
7078
}
7179

80+
/** Gets a getter method for the type `t` and the content type of the head of the component stack `c`. */
7281
GetMethod getMethodFor(Type t, SummaryComponentStack c) {
7382
result =
7483
min(GetMethod g |
@@ -77,10 +86,15 @@ module SupportMethod {
7786
}
7887
}
7988

89+
/**
90+
* A support method for tests, such as `source()` or `sink()`.
91+
*/
8092
bindingset[this]
8193
abstract class SupportMethod extends string {
94+
/** Gets an import that is required for this support method. */
8295
string getARequiredImport() { none() }
8396

97+
/** Gets the Java definition of this support method, if one is necessary. */
8498
string getDefinition() { none() }
8599

86100
/** Gets the priority of this support method. Lower priorities are preferred when multiple support methods apply. */
@@ -96,18 +110,27 @@ abstract class SupportMethod extends string {
96110
string getCsvModel() { none() }
97111
}
98112

113+
/**
114+
* The method `source()` which is considered as the source for the flow test.
115+
*/
99116
class SourceMethod extends SupportMethod {
100117
SourceMethod() { this = "source" }
101118

102119
override string getDefinition() { result = "Object source() { return null; }" }
103120
}
104121

122+
/**
123+
* The method `sink()` which is considered as the sink for the flow test.
124+
*/
105125
class SinkMethod extends SupportMethod {
106126
SinkMethod() { this = "sink" }
107127

108128
override string getDefinition() { result = "void sink(Object o) { }" }
109129
}
110130

131+
/**
132+
* A method for getting content from a type.
133+
*/
111134
bindingset[this]
112135
abstract class GetMethod extends SupportMethod {
113136
/**
@@ -245,6 +268,9 @@ private class ArrayGetMethod extends GetMethod {
245268
override string getCall(string arg) { result = "getArrayElement(" + arg + ")" }
246269
}
247270

271+
/**
272+
* A method for generating a type with content.
273+
*/
248274
bindingset[this]
249275
abstract class GenMethod extends SupportMethod {
250276
/**

java/ql/src/utils/FlowTestCaseUtils.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Utility predicates useful for test generation.
3+
*/
4+
15
import java
26
private import semmle.code.java.dataflow.internal.DataFlowUtil
37
private import semmle.code.java.dataflow.FlowSummary

0 commit comments

Comments
 (0)