Skip to main content

此版本的 GitHub Enterprise Server 将于以下日期停止服务 2026-04-09. 即使针对重大安全问题,也不会发布补丁。 为了获得更好的性能、更高的安全性和新功能,请升级到最新版本的 GitHub Enterprise。 如需升级帮助,请联系 GitHub Enterprise 支持

Exploring the structure of your source code

Visualize how your code maps to CodeQL classes in VS Code.

Prerequisites

To view the abstract syntax tree (AST) of a source file, you need to have an appropriate CodeQL query (usually printAST.ql) in your workspace. If you do not have an appropriate query, you can update your copy of the github/codeql repository from the main branch.

注意

Updating your repository may discard your query caches, making your next query runs slower.

Viewing the abstract syntax tree of a source file

  1. Open the "Databases" view in the extension, and right-click the database that you want to explore. Click Add Database Source to Workspace.
  2. Navigate to a CodeQL database's source file in the File Explorer.
  3. Run CodeQL: View AST from the VS Code Command Palette. This runs a CodeQL query over the active file, which may take a few seconds. Once the query is complete, the AST viewer will display the structure of the source file.
  4. To see the nested structure of the source file, click the arrows and expand the nodes. These nodes represent different elements of your code, such as statements and expressions.
  5. To see the source code corresponding to a particular node, click the node in the AST viewer. Similarly, you can click a section of the source code to display the corresponding node.