Skip to content

Add 'View DFG' command, similar to 'View CFG'#4305

Open
asgerf wants to merge 1 commit intogithub:mainfrom
asgerf:view-dfg-query
Open

Add 'View DFG' command, similar to 'View CFG'#4305
asgerf wants to merge 1 commit intogithub:mainfrom
asgerf:view-dfg-query

Conversation

@asgerf
Copy link
Contributor

@asgerf asgerf commented Feb 18, 2026

Adds a View DFG command alongside the View CFG command:

It behaves the exact same way as View CFG, except the tag it uses to identify the CodeQL query ends with print-dfg instead of print-cfg. (For context, DFG stands for data flow graph, and CFG stands for control flow graph)

Screenshot 2026-02-18 at 13 40 27

Copilot AI review requested due to automatic review settings February 18, 2026 12:44
@asgerf asgerf requested a review from a team as a code owner February 18, 2026 12:44
Comment on lines +46 to +49
const viewGraph = (
provider: TemplatePrintGraphProvider,
title: string,
) => {

Check failure

Code scanning / ESLint

Ensure code is properly formatted, use insertion, deletion, or replacement to obtain desired formatting. Error

Replace ⏎····provider:·TemplatePrintGraphProvider,⏎····title:·string,⏎·· with provider:·TemplatePrintGraphProvider,·title:·string
Comment on lines +85 to +88
const viewDfg = viewGraph(
dfgTemplateProvider,
"Calculating Data Flow Graph",
);

Check failure

Code scanning / ESLint

Ensure code is properly formatted, use insertion, deletion, or replacement to obtain desired formatting. Error

Replace ⏎····dfgTemplateProvider,⏎····"Calculating·Data·Flow·Graph",⏎·· with dfgTemplateProvider,·"Calculating·Data·Flow·Graph"
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new “View DFG” command to the CodeQL VS Code extension, implemented to mirror the existing “View CFG” workflow but selecting a different contextual-query tag (print-dfg).

Changes:

  • Generalize the CFG template provider into a graph template provider parameterized by KeyType (CFG vs DFG).
  • Add PrintDfgQuery key type and tag/name mappings for contextual query resolution.
  • Register new VS Code commands/menu contributions for “View DFG” and wire them into extension activation.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
extensions/ql-vscode/src/language-support/contextual/template-provider.ts Renames/generalizes CFG provider into a graph provider supporting CFG/DFG via injected KeyType/display name.
extensions/ql-vscode/src/language-support/contextual/key-type.ts Adds PrintDfgQuery and maps it to ide-contextual-queries/print-dfg.
extensions/ql-vscode/src/language-support/ast-viewer/ast-cfg-commands.ts Refactors CFG execution into a reusable viewGraph helper and adds DFG command handlers.
extensions/ql-vscode/src/extension.ts Instantiates CFG + DFG graph providers and registers the new commands.
extensions/ql-vscode/src/common/commands.ts Extends AstCfgCommands type with the new DFG command IDs.
extensions/ql-vscode/package.json Adds codeQL.viewDfg* commands and menu/command-palette contributions (canary-gated).
Comments suppressed due to low confidence (1)

extensions/ql-vscode/src/language-support/contextual/template-provider.ts:355

  • These error messages report tag ${this.keyType}, but this.keyType is the enum value (e.g. PrintDfgQuery), not the actual CodeQL query tag string. Consider using tagOfKeyType(this.keyType) (or otherwise including the resolved tag, like ide-contextual-queries/print-dfg) so the guidance is actionable.

Also, "exacly" is misspelled (should be "exactly").

        `Found multiple Print ${this.displayName} queries. Can't continue. Make sure there is exacly one query with the tag ${this.keyType}`,
      );

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +359 to 360
`Did not find any Print ${this.displayName} queries. Can't continue. Make sure there is exacly one query with the tag ${this.keyType}`,
);
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

Same issue here as above: the message uses tag ${this.keyType} (enum value) rather than the actual tag string used for lookup. Using tagOfKeyType(this.keyType) would make the error actionable, and "exacly" should be corrected to "exactly".

This issue also appears on line 354 of the same file.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments