Skip to content

Commit beab320

Browse files
committed
Java: Add more qldoc.
1 parent 5af351e commit beab320

21 files changed

+100
-9
lines changed

java/ql/src/semmle/code/java/Collections.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Provides classes and predicates for reasoning about instances of
3+
* `java.util.Collection` and their methods.
4+
*/
5+
16
import java
27

38
/**
@@ -77,6 +82,7 @@ class CollectionMutator extends CollectionMethod {
7782
class CollectionMutation extends MethodAccess {
7883
CollectionMutation() { this.getMethod() instanceof CollectionMutator }
7984

85+
/** Holds if the result of this call is not immediately discarded. */
8086
predicate resultIsChecked() { not this.getParent() instanceof ExprStmt }
8187
}
8288

java/ql/src/semmle/code/java/Completion.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,27 @@ newtype Completion =
6868
*/
6969
ThrowCompletion(ThrowableType tt)
7070

71+
/** A completion that is either a `NormalCompletion` or a `BooleanCompletion`. */
7172
class NormalOrBooleanCompletion extends Completion {
7273
NormalOrBooleanCompletion() {
7374
this instanceof NormalCompletion or this instanceof BooleanCompletion
7475
}
7576

77+
/** Gets a textual representation of this completion. */
7678
string toString() { result = "completion" }
7779
}
7880

81+
/** Gets the completion `ContinueCompletion(NoLabel())`. */
7982
ContinueCompletion anonymousContinueCompletion() { result = ContinueCompletion(NoLabel()) }
8083

84+
/** Gets the completion `ContinueCompletion(JustLabel(l))`. */
8185
ContinueCompletion labelledContinueCompletion(Label l) { result = ContinueCompletion(JustLabel(l)) }
8286

87+
/** Gets the completion `BreakCompletion(NoLabel())`. */
8388
BreakCompletion anonymousBreakCompletion() { result = BreakCompletion(NoLabel()) }
8489

90+
/** Gets the completion `BreakCompletion(JustLabel(l))`. */
8591
BreakCompletion labelledBreakCompletion(Label l) { result = BreakCompletion(JustLabel(l)) }
8692

87-
/** Gets the completion `booleanCompletion(value, value)`. */
93+
/** Gets the completion `BooleanCompletion(value, value)`. */
8894
Completion basicBooleanCompletion(boolean value) { result = BooleanCompletion(value, value) }

java/ql/src/semmle/code/java/ControlFlowGraph.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class ControlFlowNode extends Top, @exprparent {
113113
result = succ(this, NormalCompletion())
114114
}
115115

116+
/** Gets the basic block that contains this node. */
116117
BasicBlock getBasicBlock() { result.getANode() = this }
117118
}
118119

java/ql/src/semmle/code/java/Expr.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,7 @@ class EqualityTest extends BinaryExpr {
844844
this instanceof NEExpr
845845
}
846846

847+
/** Gets a boolean indicating whether this is `==` (true) or `!=` (false). */
847848
boolean polarity() {
848849
result = true and this instanceof EQExpr
849850
or

java/ql/src/semmle/code/java/Maps.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Provides classes and predicates for reasoning about instances of
3+
* `java.util.Map` and their methods.
4+
*/
5+
16
import java
27
import Collections
38

@@ -47,6 +52,7 @@ class MapSizeMethod extends MapMethod {
4752
class MapMutation extends MethodAccess {
4853
MapMutation() { this.getMethod() instanceof MapMutator }
4954

55+
/** Holds if the result of this call is not immediately discarded. */
5056
predicate resultIsChecked() { not this.getParent() instanceof ExprStmt }
5157
}
5258

@@ -72,7 +78,9 @@ class FreshMap extends ClassInstanceExpr {
7278
class MapPutCall extends MethodAccess {
7379
MapPutCall() { getCallee().(MapMethod).hasName("put") }
7480

81+
/** Gets the key argument of this call. */
7582
Expr getKey() { result = getArgument(0) }
7683

84+
/** Gets the value argument of this call. */
7785
Expr getValue() { result = getArgument(1) }
7886
}

java/ql/src/semmle/code/java/Reflection.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import JDKAnnotations
77
import Serializability
88
import semmle.code.java.dataflow.DefUse
99

10+
/** Holds if `f` is a field that may be read by reflection. */
1011
predicate reflectivelyRead(Field f) {
1112
f instanceof SerializableField or
1213
f.getAnAnnotation() instanceof ReflectiveAccessAnnotation or
1314
referencedInXmlFile(f)
1415
}
1516

17+
/** Holds if `f` is a field that may be written by reflection. */
1618
predicate reflectivelyWritten(Field f) {
1719
f instanceof DeserializableField or
1820
f.getAnAnnotation() instanceof ReflectiveAccessAnnotation or
@@ -360,6 +362,7 @@ class ReflectiveFieldAccess extends ClassMethodAccess {
360362
this.getCallee().hasName("getDeclaredField")
361363
}
362364

365+
/** Gets the field accessed by this call. */
363366
Field inferAccessedField() {
364367
(
365368
if this.getCallee().hasName("getDeclaredField")

java/ql/src/semmle/code/java/StringFormat.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ private newtype TFmtSyntax =
8080

8181
/** A syntax for format strings. */
8282
class FmtSyntax extends TFmtSyntax {
83+
/** Gets a textual representation of this format string syntax. */
8384
string toString() {
8485
result = "printf (%) syntax" and this = TFmtPrintf()
8586
or
@@ -130,6 +131,7 @@ class FormattingCall extends Call {
130131
formatWrapper(this.getCallee(), result, _)
131132
}
132133

134+
/** Gets the format string syntax used by this call. */
133135
FmtSyntax getSyntax() {
134136
this.getCallee() instanceof StringFormatMethod and result = TFmtPrintf()
135137
or
@@ -146,6 +148,7 @@ class FormattingCall extends Call {
146148
)
147149
}
148150

151+
/** Holds if this uses the "logger ({})" format syntax and the last argument is a `Throwable`. */
149152
predicate hasTrailingThrowableArgument() {
150153
getSyntax() = TFmtLogger() and
151154
getLastArg().getType().(RefType).getASourceSupertype*() instanceof TypeThrowable

java/ql/src/semmle/code/java/Type.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,10 +637,12 @@ class IntersectionType extends RefType, @class {
637637

638638
private RefType superInterface() { implInterface(this, result) }
639639

640+
/** Gets a textual representation of this type that includes all the intersected types. */
640641
string getLongName() {
641642
result = superType().toString() + concat(" & " + superInterface().toString())
642643
}
643644

645+
/** Gets the first bound of this intersection type. */
644646
RefType getFirstBound() { extendsReftype(this, result) }
645647
}
646648

java/ql/src/semmle/code/java/controlflow/Guards.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Provides classes and predicates for reasoning about guards and the control
3+
* flow elements controlled by those guards.
4+
*/
5+
16
import java
27
private import semmle.code.java.controlflow.Dominance
38
private import semmle.code.java.controlflow.internal.GuardsLogic

java/ql/src/semmle/code/java/dataflow/Bound.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Provides classes for representing abstract bounds for use in, for example, range analysis.
3+
*/
4+
15
import java
26
private import SSA
37
private import RangeUtils
@@ -14,6 +18,7 @@ private newtype TBound =
1418
* A bound that may be inferred for an expression plus/minus an integer delta.
1519
*/
1620
abstract class Bound extends TBound {
21+
/** Gets a textual representation of this bound. */
1722
abstract string toString();
1823

1924
/** Gets an expression that equals this bound plus `delta`. */
@@ -22,6 +27,13 @@ abstract class Bound extends TBound {
2227
/** Gets an expression that equals this bound. */
2328
Expr getExpr() { result = getExpr(0) }
2429

30+
/**
31+
* Holds if this element is at the specified ___location.
32+
* The ___location spans column `sc` of line `sl` to
33+
* column `ec` of line `el` in file `path`.
34+
* For more information, see
35+
* [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
36+
*/
2537
predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
2638
path = "" and sl = 0 and sc = 0 and el = 0 and ec = 0
2739
}

0 commit comments

Comments
 (0)