From c1e3ccfb6cf3f4183f32cd23b40694844a93b11f Mon Sep 17 00:00:00 2001 From: Rasmus Lerchedahl Petersen Date: Mon, 22 Mar 2021 15:07:51 +0100 Subject: [PATCH] Python, doc: Note ephemeral nature of import nodes --- .../using-api-graphs-in-python.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/codeql/codeql-language-guides/using-api-graphs-in-python.rst b/docs/codeql/codeql-language-guides/using-api-graphs-in-python.rst index 219519d6d92..38386f52887 100644 --- a/docs/codeql/codeql-language-guides/using-api-graphs-in-python.rst +++ b/docs/codeql/codeql-language-guides/using-api-graphs-in-python.rst @@ -31,9 +31,9 @@ following snippet demonstrates. ➤ `See this in the query console on LGTM.com `__. -This query only selects the API graph node corresponding to the ``re`` module. To find -where this module is referenced, you can use the ``getAUse`` method. The following query selects -all references to the ``re`` module in the current database. +This query selects the API graph node corresponding to the ``re`` module. This node represent the fact that the ``re`` module has been imported rather than a specific place in the program where the import happens. There will, therefore, be at most one result per file, and it will not have a useful location, so you have to click `Show 1 non-source result` in order to see it. + +To find places in the program where the ``re`` module is referenced, you can use the ``getAUse`` method. The following query selects all references to the ``re`` module in the current database. .. code-block:: ql @@ -102,7 +102,7 @@ where the return value of ``re.compile`` is used: Note that this includes all uses of the result of ``re.compile``, including those reachable via local flow. To get just the *calls* to ``re.compile``, you can use ``getAnImmediateUse`` instead of ``getAUse``. As this is a common occurrence, you can use ``getACall`` instead of -``getReturn`` followed by ``getAnImmediateUse``. +``getReturn`` followed by ``getAnImmediateUse``. ➤ `See this in the query console on LGTM.com `__. @@ -131,7 +131,7 @@ all subclasses of ``View``, you must explicitly include the subclasses of ``Meth result = API::moduleImport("flask").getMember("views").getMember(["View", "MethodView"]).getASubclass*() } - + select viewClass().getAUse() ➤ `See this in the query console on LGTM.com `__.