diff --git a/extensions/ql-vscode/CHANGELOG.md b/extensions/ql-vscode/CHANGELOG.md index 4ff96f90f03..d9f20b56e09 100644 --- a/extensions/ql-vscode/CHANGELOG.md +++ b/extensions/ql-vscode/CHANGELOG.md @@ -2,6 +2,8 @@ ## [UNRELEASED] +- Add `codeQL.runningQueries.ignoredWorkspaceFolders` setting. [#3617](https://github.com/github/vscode-codeql/pull/3617) + ## 1.13.0 - 1 May 2024 - Add Ruby support to the CodeQL Model Editor. [#3584](https://github.com/github/vscode-codeql/pull/3584) diff --git a/extensions/ql-vscode/package.json b/extensions/ql-vscode/package.json index 8e6368c0ed1..ea7637e9f1f 100644 --- a/extensions/ql-vscode/package.json +++ b/extensions/ql-vscode/package.json @@ -198,6 +198,11 @@ "maximum": 1024, "description": "Number of threads for running queries." }, + "codeQL.runningQueries.ignoredWorkspaceFolders": { + "type": "array", + "default": [], + "description": "Workspace folders to ignore." + }, "codeQL.runningQueries.saveCache": { "type": "boolean", "default": false, diff --git a/extensions/ql-vscode/src/common/vscode/workspace-folders.ts b/extensions/ql-vscode/src/common/vscode/workspace-folders.ts index 5f5f926f233..8e8a1352a89 100644 --- a/extensions/ql-vscode/src/common/vscode/workspace-folders.ts +++ b/extensions/ql-vscode/src/common/vscode/workspace-folders.ts @@ -1,6 +1,7 @@ import { dirname, join } from "path"; import type { WorkspaceFolder } from "vscode"; import { workspace } from "vscode"; +import { IGNORED_WORKSPACE_FOLDERS_SETTING } from "../../config"; /** Returns true if the specified workspace folder is on the file system. */ export function isWorkspaceFolderOnDisk( @@ -9,10 +10,23 @@ export function isWorkspaceFolderOnDisk( return workspaceFolder.uri.scheme === "file"; } +export function isWorkspaceFolderIgnored( + workspaceFolder: WorkspaceFolder, +): boolean { + const ignoredFolders = + IGNORED_WORKSPACE_FOLDERS_SETTING.getValue() as string[]; + return ignoredFolders.some((ignoredFolder) => + workspaceFolder.uri.fsPath.startsWith(ignoredFolder), + ); +} + /** Gets all active workspace folders that are on the filesystem. */ export function getOnDiskWorkspaceFoldersObjects() { const workspaceFolders = workspace.workspaceFolders ?? []; - return workspaceFolders.filter(isWorkspaceFolderOnDisk); + return workspaceFolders.filter( + (f: WorkspaceFolder) => + isWorkspaceFolderOnDisk(f) && !isWorkspaceFolderIgnored(f), + ); } /** Gets all active workspace folders that are on the filesystem. */ diff --git a/extensions/ql-vscode/src/config.ts b/extensions/ql-vscode/src/config.ts index 82807531f75..aae1735ca0b 100644 --- a/extensions/ql-vscode/src/config.ts +++ b/extensions/ql-vscode/src/config.ts @@ -230,6 +230,10 @@ const TIMEOUT_SETTING = new Setting("timeout", RUNNING_QUERIES_SETTING); const MEMORY_SETTING = new Setting("memory", RUNNING_QUERIES_SETTING); const DEBUG_SETTING = new Setting("debug", RUNNING_QUERIES_SETTING); const MAX_PATHS = new Setting("maxPaths", RUNNING_QUERIES_SETTING); +export const IGNORED_WORKSPACE_FOLDERS_SETTING = new Setting( + "ignoredWorkspaceFolders", + RUNNING_QUERIES_SETTING, +); const RUNNING_TESTS_SETTING = new Setting("runningTests", ROOT_SETTING); const RESULTS_DISPLAY_SETTING = new Setting("resultsDisplay", ROOT_SETTING); const USE_EXTENSION_PACKS = new Setting(