Closed
Description
Issue #384 is about a general graph viewer for QL results. This issue is about a specific graph visualization use case for viewing ASTs. The C/C++ PrintAST
query returns results as @kind graph
. This query will take a root node and return the AST from that root. This is currently only available for C/C++ and a variant is available for Go.
How this feature will be used
- Select a file (potentially we will also allow a user to select a function instead)
- Invoke the Code QL: View AST command
- The extension will run a contextual query and invoke
PrintAST
for the language of the current database. - In a tree viewer in the QL view, the extension will display the results of this query as a tree. All elements should link back to the source code, as well as link to the QL class that gave rise to it.
Implementation
Building off of the current contextual query implementation, we will build a new contextual query that invokes PrintAST.ql
on the selected file. Before this can be implemented, we will need to do the following:
- Create a templatized version of the
PrintAST.ql
so that the selected file can be passed in. See the various implementations oflocalDefinitions.ql
(for example https://github.com/github/codeql/blob/master/javascript/ql/src/localDefinitions.ql). - Refactor
definitions.ts
so that it can handle contextual queries more generically. - Build the TreeViewer itself
- Work with the languages teams so that each language produces its own version of print AST.
Release checklist
- Ship under feature flag. Done in 1.3.2
- Improve error reporting when the
printAst
query is absent. - All languages supported except Python. (Tracking issue for PrintAST queries in supported languages #505)
- Lift feature flag to make generally available.