Skip to content

Commit 7c0b8f5

Browse files
authored
Merge pull request github#3622 from aschackmull/mergeback-124
Mergeback rc/1.24 -> master
2 parents e444bcc + 9afbd5b commit 7c0b8f5

14 files changed

+41
-31
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
We welcome contributions to our CodeQL libraries and queries. Got an idea for a new check, or how to improve an existing query? Then please go ahead and open a pull request! Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE).
44

5-
There is lots of useful documentation to help you write queries, ranging from information about query file structure to tutorials for specific target languages. For more information on the documentation available, see [Writing CodeQL queries](https://help.semmle.com/QL/learn-ql/writing-queries/writing-queries.html) on [help.semmle.com](https://help.semmle.com).
5+
There is lots of useful documentation to help you write queries, ranging from information about query file structure to tutorials for specific target languages. For more information on the documentation available, see [CodeQL queries](https://help.semmle.com/QL/learn-ql/writing-queries/writing-queries.html) on [help.semmle.com](https://help.semmle.com).
66

77

88
## Submitting a new experimental query
@@ -32,7 +32,7 @@ If you have an idea for a query that you would like to share with other CodeQL u
3232

3333
For details, see the [guide on query metadata](docs/query-metadata-style-guide.md).
3434

35-
Make sure the `select` statement is compatible with the query `@kind`. See [Introduction to query files](https://help.semmle.com/QL/learn-ql/writing-queries/introduction-to-queries.html#select-clause) on help.semmle.com.
35+
Make sure the `select` statement is compatible with the query `@kind`. See [About CodeQL queries](https://help.semmle.com/QL/learn-ql/writing-queries/introduction-to-queries.html#select-clause) on help.semmle.com.
3636

3737
3. **Formatting**
3838

docs/language/learn-ql/java/ast-class-reference.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
Classes for working with Java code
2-
==================================
1+
Abstract syntax tree classes for working with Java programs
2+
===========================================================
33

4-
CodeQL has a large selection of classes for working with Java statements and expressions.
4+
CodeQL has a large selection of classes for representing the abstract syntax tree of Java programs.
5+
6+
.. include:: ../../reusables/abstract-syntax-tree.rst
57

68
.. _Expr: https://help.semmle.com/qldoc/java/semmle/code/java/Expr.qll/type.Expr$Expr.html
79
.. _Stmt: https://help.semmle.com/qldoc/java/semmle/code/java/Statement.qll/type.Statement$Stmt.html

docs/language/learn-ql/java/expressions-statements.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ If ``l`` is bigger than 2\ :sup:`31`\ - 1 (the largest positive value of type ``
2626

2727
All primitive numeric types have a maximum value, beyond which they will wrap around to their lowest possible value (called an "overflow"). For ``int``, this maximum value is 2\ :sup:`31`\ - 1. Type ``long`` can accommodate larger values up to a maximum of 2\ :sup:`63`\ - 1. In this example, this means that ``l`` can take on a value that is higher than the maximum for type ``int``; ``i`` will never be able to reach this value, instead overflowing and returning to a low value.
2828

29-
We're going to develop a query that finds code that looks like it might exhibit this kind of behavior. We'll be using several of the standard library classes for representing statements and functions. For a full list, see :doc:`Classes for working with Java code <ast-class-reference>`.
29+
We're going to develop a query that finds code that looks like it might exhibit this kind of behavior. We'll be using several of the standard library classes for representing statements and functions. For a full list, see :doc:`Abstract syntax tree classes for working with Java programs <ast-class-reference>`.
3030

3131
Initial query
3232
-------------

docs/language/learn-ql/java/introduce-libraries-java.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ Class ``Variable`` represents a variable `in the Java sense <http://docs.oracle.
210210
Abstract syntax tree
211211
--------------------
212212

213-
Classes in this category represent abstract syntax tree (AST) nodes, that is, statements (class ``Stmt``) and expressions (class ``Expr``). For a full list of expression and statement types available in the standard QL library, see :doc:`Classes for working with Java code <ast-class-reference>`.
213+
Classes in this category represent abstract syntax tree (AST) nodes, that is, statements (class ``Stmt``) and expressions (class ``Expr``). For a full list of expression and statement types available in the standard QL library, see :doc:`Abstract syntax tree classes for working with Java programs <ast-class-reference>`.
214214

215215
Both ``Expr`` and ``Stmt`` provide member predicates for exploring the abstract syntax tree of a program:
216216

docs/language/learn-ql/java/ql-for-java.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ Experiment and learn how to write effective and efficient queries for CodeQL dat
3434

3535
- :doc:`Working with source locations <source-locations>`: You can use the location of entities within Java code to look for potential errors. Locations allow you to deduce the presence, or absence, of white space which, in some cases, may indicate a problem.
3636

37-
- :doc:`Classes for working with Java code <ast-class-reference>`: CodeQL has a large selection of classes for working with Java statements and expressions.
37+
- :doc:`Abstract syntax tree classes for working with Java programs <ast-class-reference>`: CodeQL has a large selection of classes for representing the abstract syntax tree of Java programs.
3838

docs/language/learn-ql/java/types-class-hierarchy.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ To identify these cases, we can create two CodeQL classes that represent, respec
114114
class CollectionToArrayCall extends MethodAccess {
115115
CollectionToArrayCall() {
116116
exists(CollectionToArray m |
117-
this.getMethod().getSourceDeclaration().overrides*(m)
117+
this.getMethod().getSourceDeclaration().overridesOrInstantiates*(m)
118118
)
119119
}
120120
@@ -124,7 +124,7 @@ To identify these cases, we can create two CodeQL classes that represent, respec
124124
}
125125
}
126126
127-
Notice the use of ``getSourceDeclaration`` and ``overrides`` in the constructor of ``CollectionToArrayCall``: we want to find calls to ``Collection.toArray`` and to any method that overrides it, as well as any parameterized instances of these methods. In our example above, for instance, the call ``l.toArray`` resolves to method ``toArray`` in the raw class ``ArrayList``. Its source declaration is method\ ``toArray`` in the generic class ``ArrayList``, which overrides ``AbstractCollection.toArray``, which in turn overrides ``Collection.toArray``.
127+
Notice the use of ``getSourceDeclaration`` and ``overridesOrInstantiates`` in the constructor of ``CollectionToArrayCall``: we want to find calls to ``Collection.toArray`` and to any method that overrides it, as well as any parameterized instances of these methods. In our example above, for instance, the call ``l.toArray`` resolves to method ``toArray`` in the raw class ``ArrayList``. Its source declaration is ``toArray`` in the generic class ``ArrayList<T>``, which overrides ``AbstractCollection<T>.toArray``, which in turn overrides ``Collection<T>.toArray``, which is an instantiation of ``Collection.toArray`` (since the type parameter ``T`` in the overridden method belongs to ``ArrayList`` and is an instantiation of the type parameter belonging to ``Collection``).
128128

129129
Using these new classes we can extend our query to exclude calls to ``toArray`` on an argument of type ``A[]`` which are then cast to ``A[]``:
130130

docs/language/learn-ql/javascript/ast-class-reference.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
Abstract syntax tree classes for JavaScript and TypeScript
2-
==========================================================
1+
Abstract syntax tree classes for working with JavaScript and TypeScript programs
2+
================================================================================
33

4-
CodeQL has a large selection of classes for working with JavaScript and TypeScript statements and expressions.
4+
CodeQL has a large selection of classes for representing the abstract syntax tree of JavaScript and TypeScript programs.
5+
6+
.. include:: ../../reusables/abstract-syntax-tree.rst
57

68
Statement classes
79
-----------------

docs/language/learn-ql/javascript/dataflow-cheat-sheet.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Files
142142
AST nodes
143143
---------
144144

145-
See also: :doc:`Abstract syntax tree classes for JavaScript and TypeScript <ast-class-reference>`.
145+
See also: :doc:`Abstract syntax tree classes for working with JavaScript and TypeScript programs <ast-class-reference>`.
146146

147147
Conversion between DataFlow and AST nodes:
148148

docs/language/learn-ql/javascript/ql-for-javascript.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ Experiment and learn how to write effective and efficient queries for CodeQL dat
2626

2727
- :doc:`Using type tracking for API modeling <type-tracking>`: You can track data through an API by creating a model using the CodeQL type-tracking library for JavaScript.
2828

29-
- :doc:`Abstract syntax tree classes for JavaScript and TypeScript <ast-class-reference>`: CodeQL has a large selection of classes for working with JavaScript and TypeScript statements and expressions.
29+
- :doc:`Abstract syntax tree classes for working with JavaScript and TypeScript programs <ast-class-reference>`: CodeQL has a large selection of classes for representing the abstract syntax tree of JavaScript and TypeScript programs.
3030

3131
- :doc:`Data flow cheat sheet for JavaScript <dataflow-cheat-sheet>`: This article describes parts of the JavaScript libraries commonly used for variant analysis and in data flow queries.

docs/language/ql-handbook/modules.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,12 @@ Query modules
8080
A query module is defined by a ``.ql`` file. It can contain any of the elements listed
8181
in :ref:`module-bodies` below.
8282

83-
The difference is that a query module must have at least one query in its
84-
:ref:`namespace <namespaces>`. This is usually a :ref:`select clause <select-clauses>`,
85-
but can also be a :ref:`query predicate <query-predicates>`.
83+
Query modules are slightly different from other modules:
84+
85+
- A query module can't be imported.
86+
- A query module must have at least one query in its
87+
:ref:`namespace <namespaces>`. This is usually a :ref:`select clause <select-clauses>`,
88+
but can also be a :ref:`query predicate <query-predicates>`.
8689

8790
For example:
8891

0 commit comments

Comments
 (0)