@@ -37,15 +37,17 @@ You can express certain values directly in QL, such as numbers, booleans, and st
3737 possibly starting with a minus sign (``- ``).
3838 For example:
3939
40- .. code-block :: ql
40+ .. code-block :: ql
4141
4242 0
4343 42
4444 -2048
4545
4646 - :ref: `Float <float >` literals: These are sequences of decimal digits separated by a dot
4747 (``. ``), possibly starting with a minus sign (``- ``).
48- For example::
48+ For example:
49+
50+ .. code-block :: ql
4951
5052 2.0
5153 123.456
@@ -56,7 +58,7 @@ You can express certain values directly in QL, such as numbers, booleans, and st
5658 characters represent themselves, but there are a few characters that you need to "escape"
5759 with a backslash. The following are examples of string literals:
5860
59- .. code-block :: ql
61+ .. code-block :: ql
6062
6163 "hello"
6264 "They said, \"Please escape quotation marks!\""
@@ -135,7 +137,7 @@ In the following example, the class ``C`` inherits two definitions of the predic
135137``getANumber() ``—one from ``A `` and one from ``B ``.
136138Instead of overriding both definitions, it uses the definition from ``B ``.
137139
138- ::
140+ .. code-block :: ql
139141
140142 class A extends int {
141143 A() { this = 1 }
@@ -213,7 +215,7 @@ The following aggregates are available in QL:
213215 For example, the following aggregation returns the number of files that have more than
214216 ``500 `` lines:
215217
216- .. code-block :: ql
218+ .. code-block :: ql
217219
218220 count(File f | f.getTotalNumberOfLines() > 500 | f)
219221
@@ -229,15 +231,15 @@ The following aggregates are available in QL:
229231 For example, the following aggregation returns the name of the ``.js `` file (or files) with the
230232 largest number of lines:
231233
232- .. code-block :: ql
234+ .. code-block :: ql
233235
234236 max(File f | f.getExtension() = "js" | f.getBaseName() order by f.getTotalNumberOfLines())
235237
236238 The following aggregation returns the minimum string ``s `` out of the three strings mentioned
237239 below, that is, the string that comes first in the lexicographic ordering of all the possible
238240 values of ``s ``. (In this case, it returns ``"De Morgan" ``.)
239241
240- ::
242+ .. code-block :: ql
241243
242244 min(string s | s = "Tarski" or s = "Dedekind" or s = "De Morgan" | s)
243245
@@ -249,7 +251,9 @@ The following aggregates are available in QL:
249251 returns no values. In other words, it evaluates to the empty set.
250252
251253 For example, the following aggregation returns the average of the integers ``0 ``, ``1 ``,
252- ``2 ``, and ``3 ``::
254+ ``2 ``, and ``3 ``:
255+
256+ .. code-block :: ql
253257
254258 avg(int i | i = [0 .. 3] | i)
255259
@@ -260,7 +264,9 @@ The following aggregates are available in QL:
260264 If there are no possible assignments to the aggregation variables that satisfy the formula, then the sum is ``0 ``.
261265
262266 For example, the following aggregation returns the sum of ``i * j `` for all possible values
263- of ``i `` and ``j ``::
267+ of ``i `` and ``j ``:
268+
269+ .. code-block :: ql
264270
265271 sum(int i, int j | i = [0 .. 2] and j = [3 .. 5] | i * j)
266272
@@ -274,14 +280,16 @@ The following aggregates are available in QL:
274280 For example, the following aggregation returns the string ``"3210" ``, that is, the
275281 concatenation of the strings ``"0" ``, ``"1" ``, ``"2" ``, and ``"3" `` in descending order:
276282
277- .. code-block :: ql
283+ .. code-block :: ql
278284
279285 concat(int i | i = [0 .. 3] | i.toString() order by i desc)
280286
281287 The ``concat `` aggregate can also take a second expression, separated from the first one by
282288 a comma. This second expression is inserted as a separator between each concatenated value.
283289
284- For example, the following aggregation returns ``"0|1|2|3"``::
290+ For example, the following aggregation returns ``"0|1|2|3" ``:
291+
292+ .. code-block :: ql
285293
286294 concat(int i | i = [0 .. 3] | i.toString(), "|")
287295
@@ -294,7 +302,9 @@ The following aggregates are available in QL:
294302
295303 For example, the following aggregation returns the value that is ranked 4th out of all the
296304 possible values. In this case, ``8 `` is the 4th integer in the range from ``5 `` through
297- ``15 ``::
305+ ``15 ``:
306+
307+ .. code-block :: ql
298308
299309 rank[4](int i | i = [5 .. 15] | i)
300310
@@ -317,7 +327,9 @@ The following aggregates are available in QL:
317327
318328 For example, the following query returns the positive integers ``1 ``, ``2 ``, ``3 ``, ``4 ``, ``5 ``.
319329 For negative integers ``x ``, the expressions ``x `` and ``x.abs() `` have different values, so the
320- value for ``y `` in the aggregate expression is not uniquely determined. ::
330+ value for ``y `` in the aggregate expression is not uniquely determined.
331+
332+ .. code-block :: ql
321333
322334 from int x
323335 where x in [-5 .. 5] and x != 0
@@ -394,48 +406,54 @@ aggregation in a simpler form:
394406 then you can omit the ``<variable declarations> `` and ``<formula> `` parts and write it
395407 as follows:
396408
397- .. code-block :: ql
409+ .. code-block :: ql
398410
399411 <aggregate>(<expression>)
400412
401413 For example, the following aggregations determine how many times the letter ``l `` occurs in
402- string ``"hello"``. These forms are equivalent::
414+ string ``"hello" ``. These forms are equivalent:
415+
416+ .. code-block :: ql
403417
404418 count(int i | i = "hello".indexOf("l") | i)
405419 count("hello".indexOf("l"))
406420
407- #. If there only one aggregation variable, you can omit the ``<expression> `` part instead.
421+ #. If there is only one aggregation variable, you can omit the ``<expression> `` part instead.
408422 In this case, the expression is considered to be the aggregation variable itself.
409- For example, the following aggregations are equivalent::
410-
423+ For example, the following aggregations are equivalent:
424+
425+ .. code-block :: ql
426+
411427 avg(int i | i = [0 .. 3] | i)
412428 avg(int i | i = [0 .. 3])
413429
414430 #. As a special case, you can omit the ``<expression> `` part from ``count `` even if there is more
415431 than one aggregation variable. In such a case, it counts the number of distinct tuples of
416432 aggregation variables that satisfy the formula. In other words, the expression part is
417- considered to be the constant ``1 ``. For example, the following aggregations are equivalent::
418-
433+ considered to be the constant ``1 ``. For example, the following aggregations are equivalent:
434+
435+ .. code-block :: ql
436+
419437 count(int i, int j | i in [1 .. 3] and j in [1 .. 3] | 1)
420438 count(int i, int j | i in [1 .. 3] and j in [1 .. 3])
421439
422440 #. You can omit the ``<formula> `` part, but in that case you should include two vertical bars:
423441
424- .. code-block :: ql
442+ .. code-block :: ql
425443
426444 <aggregate>(<variable declarations> | | <expression>)
427445
428446 This is useful if you don't want to restrict the aggregation variables any further.
429447 For example, the following aggregation returns the maximum number of lines across all files:
430448
431- .. code-block :: ql
449+ .. code-block :: ql
432450
433451 max(File f | | f.getTotalNumberOfLines())
434452
435453 #. Finally, you can also omit both the ``<formula> `` and ``<expression> `` parts. For example,
436454 the following aggregations are equivalent ways to count the number of files in a database:
437455
438- .. code-block :: ql
456+ .. code-block :: ql
439457
440458 count(File f | any() | 1)
441459 count(File f | | 1)
@@ -638,7 +656,9 @@ is exactly equivalent to ``((Foo)x)``.
638656Casts are useful if you want to call a :ref: `member predicate <member-predicates >` that is only defined for a more
639657specific type. For example, the following query selects Java
640658`classes <https://codeql.github.com/codeql-standard-libraries/java/semmle/code/java/Type.qll/type.Type$Class.html >`_
641- that have a direct supertype called "List"::
659+ that have a direct supertype called "List":
660+
661+ .. code-block :: ql
642662
643663 import java
644664
@@ -669,7 +689,9 @@ Unlike other expressions, a don't-care expression does not have a type. In pract
669689means that ``_ `` doesn't have any :ref: `member predicates <member-predicates >`, so you can't
670690call ``_.somePredicate() ``.
671691
672- For example, the following query selects all the characters in the string ``"hello" ``::
692+ For example, the following query selects all the characters in the string ``"hello" ``:
693+
694+ .. code-block :: ql
673695
674696 from string s
675697 where s = "hello".charAt(_)
0 commit comments