Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Changing the labels of query history items

The query history **Format** setting controls how the extension lists queries in the query history. By default, each item has a label with the following format::

%q on %d - %s, %r result count [%t]
%q on %d - %s %r [%t]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change: I just spotted that this was out of date.


- ``%q`` is the query name
- ``%d`` is the database name
Expand Down Expand Up @@ -107,6 +107,19 @@ You can also edit the items shown in the Variant Analysis Repositories panel by

You can change the items shown in the panel or add new items by directly editing this file.

Configuring settings for adding databases
------------------------------------------------

To automatically add database source folders to your workspace, you can enable the **Adding Databases > Add Database Source to Workspace** setting.

This setting is disabled by default. You may want to enable the setting if you regularly browse the source code of databases, for example to view the abstract syntax tree of the code. For more information, see ":ref:`Exploring the structure of your source code <exploring-the-structure-of-your-source-code>`."

.. pull-quote:: Note

If you are in a single-folder workspace, adding database source folders will cause the workspace to reload as a multi-root workspace. This may cause query history and database lists to be reset.

Before enabling this setting, we recommend that you save your workspace as a multi-root workspace. For more information, see "`Multi-root Workspaces <https://un5kwkaggy09p37krhzxzd8.julianrbryant.com/docs/editor/multi-root-workspaces>`__" in the Visual Studio Code help.

Configuring settings for testing queries locally
------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,26 @@ CodeQL for Visual Studio Code contains an AST viewer. The viewer consists of a g
Viewing the abstract syntax tree of a source file
--------------------------------------------------

1. Open a source file from a CodeQL database. For example, you can navigate to a source file in the File Explorer.
1. Open the CodeQL Databases view and right-click the database that you want to explore. Click **Add Database Source to Workspace**.

.. image:: ../images/codeql-for-visual-studio-code/add-database-source-to-workspace.png
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've stuck with a dark mode screenshot, for consistency with the rest of this doc.

:width: 350
:alt: Add database source to workspace

2. Navigate to a CodeQL database's source file in the File Explorer.

.. image:: ../images/codeql-for-visual-studio-code/open-source-file.png
:width: 350
:alt: Open a source file

2. Run **CodeQL: View AST** from the Command Palette. This runs a CodeQL query (usually called ``printAST.ql``) over the active file, which may take a few seconds.
3. Run **CodeQL: View AST** from the Command Palette. This runs a CodeQL query (usually called ``printAST.ql``) over the active file, which may take a few seconds.

.. pull-quote:: Note

If you don't have an appropriate ``printAST.ql`` query in your workspace, the **CodeQL: View AST** command won't work. To fix this, you can update your copy of the `CodeQL <https://github.com/github/codeql>`__ repository from ``main``. If you do this, you may need to upgrade your databases. Also, query caches may be discarded and your next query runs could be slower.

3. Once the query has run, the AST viewer displays the structure of the source file.
4. To see the nested structure, click the arrows and expand the nodes.
4. Once the query has run, the AST viewer displays the structure of the source file.
5. To see the nested structure, click the arrows and expand the nodes.

.. image:: ../images/codeql-for-visual-studio-code/explore-ast.png
:alt: Explore the AST
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.