Skip to content

Commit 57ff8e7

Browse files
authored
Merge pull request github#6473 from github/sarita-iyer/codeql-packs-vscode
Added article for working with codeQL packs in VS Code
2 parents 1707fb8 + a373ac8 commit 57ff8e7

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

docs/codeql/codeql-for-visual-studio-code/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ The CodeQL extension for Visual Studio Code adds rich language support for CodeQ
3131
<testing-codeql-queries-in-visual-studio-code>`: You can run unit tests for
3232
CodeQL queries using the Visual Studio Code extension.
3333

34+
- :doc:`Working with CodeQL packs in Visual Studio Code
35+
<working-with-codeql-packs-in-visual-studio-code>`: You can view and edit CodeQL packs in Visual Studio Code.
36+
3437
- :doc:`Customizing settings
3538
<customizing-settings>`: You can edit the settings for the
3639
CodeQL extension to suit your needs.
@@ -51,6 +54,7 @@ The CodeQL extension for Visual Studio Code adds rich language support for CodeQ
5154
exploring-the-structure-of-your-source-code
5255
exploring-data-flow-with-path-queries
5356
testing-codeql-queries-in-visual-studio-code
57+
working-with-codeql-packs-in-visual-studio-code
5458
customizing-settings
5559
troubleshooting-codeql-for-visual-studio-code
5660
about-telemetry-in-codeql-for-visual-studio-code
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
:tocdepth: 1
2+
3+
.. _working-with-codeql-packs-in-visual-studio-code:
4+
5+
Working with CodeQL packs in Visual Studio Code
6+
===============================================
7+
8+
.. include:: ../reusables/beta-note-package-management.rst
9+
10+
You can view CodeQL packs and write and edit queries for them in Visual Studio Code.
11+
12+
About CodeQL packs
13+
------------------
14+
CodeQL packs are used to create, share, depend on, and run CodeQL queries and libraries. You can publish your own CodeQL packs and download packs created by others. For more information, see ":ref:`About CodeQL packs <about-codeql-packs>`."
15+
16+
Creating and editing CodeQL packs in Visual Studio Code
17+
-------------------------------------------------------
18+
To create a new CodeQL pack, you will need to use the CodeQL CLI from a terminal, which you can do within Visual Studio Code or outside of it with the ``codeql pack init`` command. Once you create an empty pack, you can edit the ``qlpack.yml`` file or run the ``codeql pack add`` command to add dependencies or change the name or version. For more information, see ":ref:`Creating and working with CodeQL packs <creating-and-working-with-codeql-packs>`."
19+
20+
You can create or edit queries in a CodeQL pack in Visual Studio Code as you would with any CodeQL query, using the standard code editing features such as autocomplete suggestions to find elements to use from the pack's dependencies.
21+
22+
You can then use the CodeQL CLI to publish your pack to share with others. For more information, see ":ref:`Publishing and using CodeQL packs <publishing-and-using-codeql-packs>`."
23+
24+
Viewing CodeQL packs and their dependencies in Visual Studio Code
25+
-----------------------------------------------------------------
26+
Whether you have used the CodeQL CLI to download a CodeQL pack that someone else has created, or created your own, you can open the ``qlpack.yml`` file in the root of a CodeQL pack directory in Visual Studio Code and view the dependencies section to see what libraries the pack depends on.
27+
28+
If you want to understand a query in a CodeQL pack better, you can open the query file and view the code, using the IntelliSense code editing features of Visual Studio Code. For example, if you hover over an element from a library depended on by the pack, Visual Studio Code will resolve it so you can see documentation about the element.
29+
30+
To view the full definition of an element of a query, you can right-click and choose **Go to Definition**. If the library pack is present within the same Visual Studio Code workspace, this will take you to the definition within the workspace. Otherwise it will take you to the definition within your package cache, the shared location where downloaded dependencies are stored, which is in your home directory by default.

0 commit comments

Comments
 (0)