You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Optionally, to see databases containing a specific language and queries written for that language, you can apply a language filter using the language selector.
51
+
52
+
#. To see available language filters, in the sidebar, click the **Language** title bar.
53
+
#. Hover over the language filter you would like to apply, then click **Select**.
:alt:Screenshot of the language selector. The "Select" button for a language filter is outlined in dark orange.
58
+
59
+
Creating a custom query
60
+
------------------------
61
+
62
+
You can generate a query template for a specific language from the queries panel, then write your own code to quickly create a custom query.
63
+
64
+
#. Optionally, to create a custom query in an existing directory, in the sidebar, click the **Queries** title bar to expand the queries panel, then select the desired directory.
65
+
#. In the sidebar, hover over the **Queries** title bar, then click the **Create query** icon.
:alt:Screenshot of the queries panel. The "Create query" icon is outlined in dark orange.
70
+
71
+
#. In the Command Palette, select the target language for your query. If you've chosen not to create your custom query in an existing directory, selecting a language will autogenerate a directory labeled ``codeql-custom-queries-<language>``, where ``<language>`` is the name of the selected language. A query template labeled ``example.ql`` will then be added to the existing or autogenerated directory.
72
+
#. In the template, write your custom query, then save the file. Once your query is finished, you can run it from the queries panel.
73
+
45
74
Running a query
46
75
------------------------
47
76
48
77
The `CodeQL repository <https://github.com/github/codeql>`__ on GitHub contains lots of example queries.
49
-
If you have that folder (or a different CodeQL pack) available in your workspace, you can access existing queries under ``<language>/ql/src/<category>``, for example ``java/ql/src/Likely Bugs``.
78
+
You can access any existing queries in your workspace through the queries panel.
79
+
80
+
#. In the sidebar, to expand the queries panel, click the **Queries** title bar.
81
+
#. To run a query against the selected database, hover over the desired query, then click the **Run local query** icon.
50
82
51
-
#. Open a query (``.ql``) file. It is displayed in the editor, with IntelliSense features such as syntax highlighting and autocomplete suggestions.
52
-
#. Right-click in the query window and select **CodeQL: Run Query on Selected Database**. (Alternatively, run the command from the Command Palette.)
:alt:Screenshot of the mouse pointer hovering over a directory of queries in the queries panel. The "Run local queries" icon is outlined in dark orange.
110
+
111
+
Running a selection of queries
112
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
113
+
64
114
You can run multiple queries with a single command.
65
115
66
116
#. Go to the File Explorer.
@@ -122,6 +172,7 @@ To see the queries that you have run in the current session, open the Query Hist
122
172
123
173
The Query History contains information including the date and time when the query was run, the name of the query, the database on which it was run, and how long it took to run the query.
124
174
To customize the information that is displayed, right-click an entry and select **Rename**.
175
+
You can also filter the Query History view by language using the language selector. For more information, see ":ref:`Filtering databases and queries by language <filtering-databases-and-queries-by-language>`."
125
176
126
177
Click an entry to display the corresponding results in the Query Results view, and double-click
127
178
to display the query itself in the editor (or right-click and select **View Query**).
0 commit comments