Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
a3306da
Implement CodeQL debug adapter
Mar 27, 2023
055bfcd
Add extension packs to debug configuration
Mar 30, 2023
e2017c7
Support `extensionPacks` debug configuration
Mar 30, 2023
65b0cb4
Merge remote-tracking branch 'origin/dbartol/local-queries-commands' …
Mar 30, 2023
d489d0e
QuickEval
Apr 4, 2023
d0c405a
QuickEval and other debug commands
Apr 5, 2023
f182f42
Merge remote-tracking branch 'origin/main' into dbartol/debug-adapter…
Apr 6, 2023
61df133
Merge remote-tracking branch 'origin/koesie10/fix-result-view-selecte…
Apr 6, 2023
0a0a9c6
Fix bad merge
Apr 6, 2023
7dfa52b
Debugger tests
Apr 10, 2023
19e083e
Use type-safe VSCode commands
Apr 11, 2023
1cbfd01
Fix `determineSelectedQuery` tests
Apr 11, 2023
e8f39fe
Merge remote-tracking branch 'origin/main' into dbartol/debug-adapter
Apr 11, 2023
809c86f
Remove unused command
Apr 12, 2023
d14c844
Relax linting for debug configuration variable commands
Apr 12, 2023
60bf56d
Extend query runner test timeouts to 30s (from 20s)
Apr 12, 2023
785f009
Merge remote-tracking branch 'origin/main' into dbartol/debug-adapter
Apr 13, 2023
9344499
Merge remote-tracking branch 'origin/main' into dbartol/debug-adapter
Apr 13, 2023
a0a3af2
Remove unused commands
Apr 14, 2023
2da6895
Rework debug query evaluation code to avoid lots of state-dependent p…
Apr 14, 2023
22679b8
Update extensions/ql-vscode/src/local-databases.ts
Apr 14, 2023
6efdd11
Use preferred cast style
Apr 14, 2023
d3b118b
Update extensions/ql-vscode/src/debugger/debug-configuration.ts
Apr 14, 2023
30b9d7e
Merge branch 'dbartol/debug-adapter' of https://github.com/github/vsc…
Apr 14, 2023
59dcea6
Add comment about disposal of debug adapter tracker
Apr 14, 2023
60fd868
Remove unused code
Apr 14, 2023
95dda2b
Update extensions/ql-vscode/src/run-queries-shared.ts
Apr 14, 2023
14a4247
Update extensions/ql-vscode/test/vscode-tests/cli-integration/debug-c…
Apr 14, 2023
6fa7757
Merge branch 'dbartol/debug-adapter' of https://github.com/github/vsc…
Apr 14, 2023
03ceb73
Update extensions/ql-vscode/src/common/commands.ts
Apr 14, 2023
ce2fecd
Don't await `showAndLog...`
Apr 14, 2023
d1b5ab6
Merge branch 'dbartol/debug-adapter' of https://github.com/github/vsc…
Apr 14, 2023
55644d5
Simplify nested ternaries
Apr 14, 2023
ad2c065
Better error message UI for bad debug configuration
Apr 14, 2023
aa9ca6e
Remove unused code
Apr 14, 2023
103e397
Move debugger tests into subdirectory
Apr 14, 2023
7602d8e
Merge remote-tracking branch 'origin/main' into dbartol/debug-adapter
Apr 14, 2023
74c3db7
Fix crash in `codeql.debugQuery` when run from command palette
Apr 14, 2023
a151ade
Stop sending debug events after forcible disconnection
Apr 14, 2023
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
31 changes: 31 additions & 0 deletions extensions/ql-vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 122 additions & 2 deletions extensions/ql-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,48 @@
"editor.wordBasedSuggestions": false
}
},
"debuggers": [
{
"type": "codeql",
"label": "CodeQL Debugger",
"languages": [
"ql"
],
"configurationAttributes": {
"launch": {
"properties": {
"query": {
"type": "string",
"description": "Path to query file (.ql)",
"default": "${file}"
},
"database": {
"type": "string",
"description": "Path to the target database"
},
"additionalPacks": {
"type": [
"array",
"string"
],
"description": "Additional folders to search for library packs. Defaults to searching all workspace folders."
},
"extensionPacks": {
"type": [
"array",
"string"
],
"description": "Names of extension packs to include in the evaluation. These are resolved from the locations specified in `additionalPacks`."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also resolved from the package cache.

}
}
}
},
"variables": {
"currentDatabase": "codeQL.getCurrentDatabase",
"currentQuery": "codeQL.getCurrentQuery"
}
}
],
"jsonValidation": [
{
"fileMatch": "GitHub.vscode-codeql/databases.json",
Expand Down Expand Up @@ -309,6 +351,30 @@
"command": "codeQL.runQueryContextEditor",
"title": "CodeQL: Run Query on Selected Database"
},
{
"command": "codeQL.debugQuery",
"title": "CodeQL: Debug Query"
},
{
"command": "codeQL.debugQueryContextEditor",
"title": "CodeQL: Debug Query"
},
{
"command": "codeQL.startDebuggingSelection",
"title": "CodeQL: Debug Selection"
},
{
"command": "codeQL.startDebuggingSelectionContextEditor",
"title": "CodeQL: Debug Selection"
},
{
"command": "codeQL.continueDebuggingSelection",
"title": "CodeQL: Debug Selection"
},
{
"command": "codeQL.continueDebuggingSelectionContextEditor",
"title": "CodeQL: Debug Selection"
},
{
"command": "codeQL.runQueryOnMultipleDatabases",
"title": "CodeQL: Run Query on Multiple Databases"
Expand Down Expand Up @@ -448,6 +514,14 @@
"command": "codeQL.setCurrentDatabase",
"title": "CodeQL: Set Current Database"
},
{
"command": "codeQL.getCurrentDatabase",
"title": "CodeQL: Get Current Database"
},
{
"command": "codeQL.getCurrentQuery",
"title": "CodeQL: Get Current Query"
},
{
"command": "codeQL.viewAst",
"title": "CodeQL: View AST"
Expand Down Expand Up @@ -1022,6 +1096,30 @@
"command": "codeQL.runQueryContextEditor",
"when": "false"
},
{
"command": "codeQL.debugQuery",
"when": "config.codeQL.canary && editorLangId == ql && resourceExtname == .ql && !inDebugMode"
},
{
"command": "codeQL.debugQueryContextEditor",
"when": "false"
},
{
"command": "codeQL.startDebuggingSelection",
"when": "config.codeQL.canary && editorLangId == ql && debugState == inactive && debugConfigurationType == codeql"
},
{
"command": "codeQL.startDebuggingSelectionContextEditor",
"when": "false"
},
{
"command": "codeQL.continueDebuggingSelection",
"when": "config.codeQL.canary && editorLangId == ql && debugState == stopped && debugType == codeql"
},
{
"command": "codeQL.continueDebuggingSelectionContextEditor",
"when": "false"
},
{
"command": "codeQL.runQueryOnMultipleDatabases",
"when": "resourceLangId == ql && resourceExtname == .ql"
Expand Down Expand Up @@ -1070,6 +1168,14 @@
"command": "codeQL.setCurrentDatabase",
"when": "false"
},
{
"command": "codeQL.getCurrentDatabase",
"when": "false"
},
{
"command": "codeQL.getCurrentQuery",
"when": "false"
},
{
"command": "codeQL.viewAst",
"when": "resourceScheme == codeql-zip-archive"
Expand Down Expand Up @@ -1330,7 +1436,7 @@
"editor/context": [
{
"command": "codeQL.runQueryContextEditor",
"when": "editorLangId == ql && resourceExtname == .ql"
"when": "editorLangId == ql && resourceExtname == .ql && !inDebugMode"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This?

Suggested change
"when": "editorLangId == ql && resourceExtname == .ql && !inDebugMode"
"when": "config.codeQL.canary && editorLangId == ql && resourceExtname == .ql && !inDebugMode"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is an existing command, so wouldn't we still want to keep this available?

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.

Yeah, that's the existing "CodeQL: Run Query" command. I just changed the when clause to disable it when we're already debugging. Otherwise, the user is likely to select "Run Query", which will run the query outside the debugger and without debug context, rather than just "Continue".

Once we have the basic debugger support merged, we'll have to take a careful look at the UX around the commands, configuration, etc. What I've got now is intended to be the easiest-to-implement way to enable the new features, not necessarily the best UX.

},
{
"command": "codeQL.runQueryOnMultipleDatabasesContextEditor",
Expand All @@ -1350,7 +1456,19 @@
},
{
"command": "codeQL.quickEvalContextEditor",
"when": "editorLangId == ql"
"when": "editorLangId == ql && debugState == inactive"
},
{
"command": "codeQL.debugQueryContextEditor",
"when": "config.codeQL.canary && editorLangId == ql && resourceExtname == .ql && !inDebugMode"
},
{
"command": "codeQL.startDebuggingSelectionContextEditor",
"when": "config.codeQL.canary && editorLangId == ql && debugState == inactive && debugConfigurationType == codeql"
},
{
"command": "codeQL.continueDebuggingSelectionContextEditor",
"when": "config.codeQL.canary && editorLangId == ql && debugState == stopped && debugType == codeql"
},
{
"command": "codeQL.openReferencedFileContextEditor",
Expand Down Expand Up @@ -1451,6 +1569,8 @@
"@octokit/plugin-retry": "^3.0.9",
"@octokit/rest": "^19.0.4",
"@vscode/codicons": "^0.0.31",
"@vscode/debugadapter": "^1.59.0",
"@vscode/debugprotocol": "^1.59.0",
"@vscode/webview-ui-toolkit": "^1.0.1",
"ajv": "^8.11.0",
"child-process-promise": "^2.2.1",
Expand Down
23 changes: 23 additions & 0 deletions extensions/ql-vscode/src/common/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {
VariantAnalysisScannedRepository,
VariantAnalysisScannedRepositoryResult,
} from "../variant-analysis/shared/variant-analysis";
import type { QLDebugConfiguration } from "../debugger/debug-configuration";

// A command function matching the signature that VS Code calls when
// a command is invoked from the title bar of a TreeView with
Expand Down Expand Up @@ -87,6 +88,15 @@ export type BuiltInVsCodeCommands = {
) => Promise<void>;
"vscode.open": (uri: Uri) => Promise<void>;
"vscode.openFolder": (uri: Uri) => Promise<void>;
// We type the `config` property specifically as a CodeQL debug configuration, since that's the
// only kinds we specify anyway.
"workbench.action.debug.start": (options?: {
config?: Partial<QLDebugConfiguration>;
noDebug?: boolean;
}) => Promise<void>;
"workbench.action.debug.stepInto": () => Promise<void>;
"workbench.action.debug.stepOver": () => Promise<void>;
"workbench.action.debug.stepOut": () => Promise<void>;
};

// Commands that are available before the extension is fully activated.
Expand Down Expand Up @@ -134,9 +144,20 @@ export type LocalQueryCommands = {
"codeQL.quickEvalContextEditor": (uri: Uri) => Promise<void>;
"codeQL.codeLensQuickEval": (uri: Uri, range: Range) => Promise<void>;
"codeQL.quickQuery": () => Promise<void>;
"codeQL.getCurrentQuery": () => Promise<string>;
"codeQL.createQuery": () => Promise<void>;
};

// Debugger commands
export type DebuggerCommands = {
"codeQL.debugQuery": (uri: Uri | undefined) => Promise<void>;
"codeQL.debugQueryContextEditor": (uri: Uri) => Promise<void>;
"codeQL.startDebuggingSelection": () => Promise<void>;
"codeQL.startDebuggingSelectionContextEditor": () => Promise<void>;
"codeQL.continueDebuggingSelection": () => Promise<void>;
"codeQL.continueDebuggingSelectionContextEditor": () => Promise<void>;
};

export type ResultsViewCommands = {
"codeQLQueryResults.up": () => Promise<void>;
"codeQLQueryResults.down": () => Promise<void>;
Expand Down Expand Up @@ -219,6 +240,7 @@ export type LocalDatabasesCommands = {

// Internal commands
"codeQLDatabases.removeOrphanedDatabases": () => Promise<void>;
"codeQL.getCurrentDatabase": () => Promise<string | undefined>;
};

// Commands tied to variant analysis
Expand Down Expand Up @@ -314,6 +336,7 @@ export type AllExtensionCommands = BaseCommands &
ResultsViewCommands &
QueryHistoryCommands &
LocalDatabasesCommands &
DebuggerCommands &
VariantAnalysisCommands &
DatabasePanelCommands &
AstCfgCommands &
Expand Down
Loading