Skip to content

Commit d889fa8

Browse files
authored
Merge pull request #20571 from github/ginsbach/MoreAnnotationDocs
document `extensible` and `additional` in QL reference and spec
2 parents 4f833ca + a2d31be commit d889fa8

File tree

3 files changed

+50
-8
lines changed

3 files changed

+50
-8
lines changed

docs/codeql/ql-language-reference/annotations.rst

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,27 @@ own body, or they must inherit from another class that overrides ``isSource``:
9797
// doesn't need to override `isSource`, because it inherits it from ConfigA
9898
}
9999
100+
.. index:: additional
101+
.. _additional:
102+
103+
``additional``
104+
==============
105+
106+
**Available for**: |classes|, |algebraic datatypes|, |type unions|, |non-member predicates|, |modules|, |aliases|, |signatures|
107+
108+
The ``additional`` annotation can be used on declarations in explicit modules.
109+
All declarations that are not required by a module signature in modules that implement |module signatures| must be annotated with ``additional``.
110+
111+
Omitting ``additional`` on such declarations, or using the annotation in any other context, will result in a compiler error.
112+
Other than that, the annotation has no effect.
113+
100114
.. index:: cached
101115
.. _cached:
102116

103117
``cached``
104118
==========
105119

106-
**Available for**: |classes|, |algebraic datatypes|, |characteristic predicates|, |member predicates|, |non-member predicates|, |modules|
120+
**Available for**: |classes|, |algebraic datatypes|, |type unions|, |characteristic predicates|, |member predicates|, |non-member predicates|, |modules|
107121

108122
The ``cached`` annotation indicates that an entity should be evaluated in its entirety and
109123
stored in the evaluation cache. All later references to this entity will use the
@@ -126,7 +140,7 @@ body must also be annotated with ``cached``, otherwise a compiler error is repor
126140
``deprecated``
127141
==============
128142

129-
**Available for**: |classes|, |algebraic datatypes|, |member predicates|, |non-member predicates|, |imports|, |fields|, |modules|, |aliases|
143+
**Available for**: |classes|, |algebraic datatypes|, |type unions|, |member predicates|, |non-member predicates|, |imports|, |fields|, |modules|, |aliases|, |signatures|
130144

131145
The ``deprecated`` annotation is applied to names that are outdated and scheduled for removal
132146
in a future release of QL.
@@ -151,6 +165,16 @@ For example, the name ``DataFlowNode`` is deprecated and has the following QLDoc
151165
152166
This QLDoc comment appears when you use the name ``DataFlowNode`` in a QL editor.
153167

168+
.. index:: extensible
169+
.. _extensible:
170+
171+
``extensible``
172+
==============
173+
174+
**Available for**: |non-member predicates|
175+
176+
The ``extensible`` annotation is used to mark predicates that are populated at evaluation time through data extensions.
177+
154178
.. index:: external
155179
.. _external:
156180

@@ -235,7 +259,7 @@ warning.
235259
``private``
236260
===========
237261

238-
**Available for**: |classes|, |algebraic datatypes|, |member predicates|, |non-member predicates|, |imports|, |fields|, |modules|, |aliases|
262+
**Available for**: |classes|, |algebraic datatypes|, |type unions|, |member predicates|, |non-member predicates|, |imports|, |fields|, |modules|, |aliases|, |signatures|
239263

240264
The ``private`` annotation is used to prevent names from being exported.
241265

@@ -461,7 +485,7 @@ For more information, see ":ref:`monotonic-aggregates`."
461485
Binding sets
462486
============
463487

464-
**Available for**: |classes|, |characteristic predicates|, |member predicates|, |non-member predicates|
488+
**Available for**: |classes|, |characteristic predicates|, |member predicates|, |non-member predicates|, |predicate signatures|, |type signatures|
465489

466490
``bindingset[...]``
467491
-------------------
@@ -490,4 +514,9 @@ The ``bindingset`` annotation takes a comma-separated list of variables.
490514
.. |aliases| replace:: :ref:`aliases <aliases>`
491515
.. |type-aliases| replace:: :ref:`type aliases <type-aliases>`
492516
.. |algebraic datatypes| replace:: :ref:`algebraic datatypes <algebraic-datatypes>`
517+
.. |type unions| replace:: :ref:`type unions <type-unions>`
493518
.. |expressions| replace:: :ref:`expressions <expressions>`
519+
.. |signatures| replace:: :ref:`signatures <signatures>`
520+
.. |predicate signatures| replace:: :ref:`predicate signatures <predicate-signatures>`
521+
.. |type signatures| replace:: :ref:`type signatures <type-signatures>`
522+
.. |module signatures| replace:: :ref:`module signatures <module-signatures>`

docs/codeql/ql-language-reference/ql-language-specification.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Architecture
3636

3737
A *QL program* consists of a query module defined in a QL file and a number of library modules defined in QLL files that it imports (see "`Import directives <#import-directives>`__"). The module in the QL file includes one or more queries (see "`Queries <#queries>`__"). A module may also include *import directives* (see "`Import directives <#import-directives>`__"), non-member predicates (see "`Non-member predicates <#non-member-predicates>`__"), class definitions (see "`Classes <#classes>`__"), and module definitions (see "`Modules <#modules>`__").
3838

39-
QL programs are interpreted in the context of a *database* and a *library path* . The database provides a number of definitions: database types (see "`Types <#types>`__"), entities (see "`Values <#values>`__"), built-in predicates (see "`Built-ins <#built-ins>`__"), and the *database content* of built-in predicates and external predicates (see "`Evaluation <#evaluation>`__"). The library path is a sequence of file-system directories that hold QLL files.
39+
QL programs are interpreted in the context of a *database* and a *library path* . The database provides a number of definitions: database types (see "`Types <#types>`__"), entities (see "`Values <#values>`__"), built-in predicates (see "`Built-ins <#built-ins>`__"), and the *database content* of built-in predicates, external predicates, and extensible predicates (see "`Evaluation <#evaluation>`__"). The library path is a sequence of file-system directories that hold QLL files.
4040

4141
A QL program can be *evaluated* (see "`Evaluation <#evaluation>`__") to produce a set of tuples of values (see "`Values <#values>`__").
4242

@@ -935,6 +935,7 @@ When a predicate is a top-level clause in a module, it is called a non-member pr
935935

936936
A valid non-member predicate can be annotated with ``additional``, ``cached``, ``deprecated``, ``extensible``, ``external``, ``transient``, ``private``, and ``query``.
937937
Note, the ``transient`` annotation can only be applied if the non-member predicate is also annotated with ``external``.
938+
Note, the annotations ``extensible`` and ``external`` cannot both be used on the same non-member predicate.
938939

939940
The head of the predicate gives a name, an optional *result type*, and a sequence of variables declarations that are *arguments*:
940941

@@ -952,7 +953,7 @@ The body of a predicate is of one of three forms:
952953

953954
In the first form, with just a semicolon, the predicate is said to not have a body. In the second form, the body of the predicate is the given formula (see "`Formulas <#formulas>`__"). In the third form, the body is a higher-order relation.
954955

955-
A valid non-member predicate must have a body, either a formula or a higher-order relation, unless it is external, in which case it must not have a body.
956+
A valid non-member predicate must have a body, either a formula or a higher-order relation, unless it is external or extensible, in which case it must not have a body.
956957

957958
The typing environment for the body of the formula, if present, maps the variables in the head of the predicate to their associated types. If the predicate has a result type, then the typing environment also maps ``result`` to the result type.
958959

@@ -1053,7 +1054,7 @@ A member predicate ``p`` with enclosing class ``C`` *shadows* a member predicate
10531054

10541055
Member predicates have one or more *root definitions*. If a member predicate overrides no other member predicate, then it is its own root definition. Otherwise, its root definitions are those of any member predicate that it overrides.
10551056

1056-
A valid member predicate must have a body unless it is abstract or external, in which case it must not have a body.
1057+
A valid member predicate must have a body unless it is abstract, in which case it must not have a body.
10571058

10581059
A valid member predicate must override another member predicate if it is annotated override.
10591060

@@ -2180,7 +2181,7 @@ If a QL program has no valid stratification, then the program itself is not vali
21802181
Layer evaluation
21812182
~~~~~~~~~~~~~~~~
21822183

2183-
The store is first initialized with the *database content* of all built-in predicates and external predicates. The database content of a predicate is a set of ordered tuples that are included in the database.
2184+
The store is first initialized with the *database content* of all built-in predicates, external predicates, and extensible predicates. The database content of a predicate is a set of ordered tuples that are included in the database.
21842185

21852186
Each layer of the stratification is *populated* in order. To populate a layer, each predicate in the layer is repeatedly populated until the store stops changing. The way that a predicate is populated is as follows:
21862187

docs/codeql/ql-language-reference/signatures.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ Signatures
1010
Parameterized modules use signatures as a type system for their parameters.
1111
There are three categories of signatures: **predicate signatures**, **type signatures**, and **module signatures**.
1212

13+
.. index:: predicate signature
14+
15+
.. _predicate-signatures:
16+
1317
Predicate signatures
1418
====================
1519

@@ -36,6 +40,10 @@ For example:
3640
3741
signature int operator(int lhs, int rhs);
3842
43+
.. index:: type signature
44+
45+
.. _type-signatures:
46+
3947
Type signatures
4048
===============
4149

@@ -66,6 +74,10 @@ For example:
6674
string toString();
6775
}
6876
77+
.. index:: module signature
78+
79+
.. _module-signatures:
80+
6981
Module signatures
7082
=================
7183

0 commit comments

Comments
 (0)