Skip to content

Commit f03284b

Browse files
committed
Add ignoredWorkspaceFolder setting
1 parent d8a7dcd commit f03284b

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

extensions/ql-vscode/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [UNRELEASED]
44

5+
- Add `codeQL.runningQueries.ignoredWorkspaceFolders` setting. [#3617](https://github.com/github/vscode-codeql/pull/3617)
6+
57
## 1.13.0 - 1 May 2024
68

79
- Add Ruby support to the CodeQL Model Editor. [#3584](https://github.com/github/vscode-codeql/pull/3584)

extensions/ql-vscode/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@
198198
"maximum": 1024,
199199
"description": "Number of threads for running queries."
200200
},
201+
"codeQL.runningQueries.ignoredWorkspaceFolders": {
202+
"type": "array",
203+
"default": [],
204+
"description": "Workspace folders to ignore."
205+
},
201206
"codeQL.runningQueries.saveCache": {
202207
"type": "boolean",
203208
"default": false,

extensions/ql-vscode/src/common/vscode/workspace-folders.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { dirname, join } from "path";
22
import type { WorkspaceFolder } from "vscode";
33
import { workspace } from "vscode";
4+
import { IGNORED_WORKSPACE_FOLDERS_SETTING } from "../../config";
45

56
/** Returns true if the specified workspace folder is on the file system. */
67
export function isWorkspaceFolderOnDisk(
@@ -9,10 +10,23 @@ export function isWorkspaceFolderOnDisk(
910
return workspaceFolder.uri.scheme === "file";
1011
}
1112

13+
export function isWorkspaceFolderIgnored(
14+
workspaceFolder: WorkspaceFolder,
15+
): boolean {
16+
const ignoredFolders =
17+
IGNORED_WORKSPACE_FOLDERS_SETTING.getValue() as string[];
18+
return ignoredFolders.some((ignoredFolder) =>
19+
workspaceFolder.uri.fsPath.startsWith(ignoredFolder),
20+
);
21+
}
22+
1223
/** Gets all active workspace folders that are on the filesystem. */
1324
export function getOnDiskWorkspaceFoldersObjects() {
1425
const workspaceFolders = workspace.workspaceFolders ?? [];
15-
return workspaceFolders.filter(isWorkspaceFolderOnDisk);
26+
return workspaceFolders.filter(
27+
(f: WorkspaceFolder) =>
28+
isWorkspaceFolderOnDisk(f) && !isWorkspaceFolderIgnored(f),
29+
);
1630
}
1731

1832
/** Gets all active workspace folders that are on the filesystem. */

extensions/ql-vscode/src/config.ts

+4
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ const TIMEOUT_SETTING = new Setting("timeout", RUNNING_QUERIES_SETTING);
230230
const MEMORY_SETTING = new Setting("memory", RUNNING_QUERIES_SETTING);
231231
const DEBUG_SETTING = new Setting("debug", RUNNING_QUERIES_SETTING);
232232
const MAX_PATHS = new Setting("maxPaths", RUNNING_QUERIES_SETTING);
233+
export const IGNORED_WORKSPACE_FOLDERS_SETTING = new Setting(
234+
"ignoredWorkspaceFolders",
235+
RUNNING_QUERIES_SETTING,
236+
);
233237
const RUNNING_TESTS_SETTING = new Setting("runningTests", ROOT_SETTING);
234238
const RESULTS_DISPLAY_SETTING = new Setting("resultsDisplay", ROOT_SETTING);
235239
const USE_EXTENSION_PACKS = new Setting(

0 commit comments

Comments
 (0)