From 28fd6c317b8e086bec1ad0ad6c56ba1694def862 Mon Sep 17 00:00:00 2001 From: Gulshan Singh Date: Mon, 20 May 2024 14:32:11 -0700 Subject: [PATCH] Add ignoredFolders setting --- extensions/ql-vscode/package.json | 5 +++++ .../src/common/vscode/workspace-folders.ts | 15 ++++++++++++++- extensions/ql-vscode/src/config.ts | 4 ++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/extensions/ql-vscode/package.json b/extensions/ql-vscode/package.json index 8e6368c0ed1..850cda0340e 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.ignoredFolders": { + "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..392f019167f 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_FOLDERS_SETTING } from "../../config"; /** Returns true if the specified workspace folder is on the file system. */ export function isWorkspaceFolderOnDisk( @@ -9,10 +10,22 @@ export function isWorkspaceFolderOnDisk( return workspaceFolder.uri.scheme === "file"; } +export function isWorkspaceFolderIgnored( + workspaceFolder: WorkspaceFolder, +): boolean { + const ignoredFolders = IGNORED_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..9969dc4aa20 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_FOLDERS_SETTING = new Setting( + "ignoredFolders", + 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(