Skip to content

Commit

Permalink
Add ignoredFolders setting
Browse files Browse the repository at this point in the history
  • Loading branch information
gsingh93 committed May 20, 2024
1 parent d8a7dcd commit 28fd6c3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions extensions/ql-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 14 additions & 1 deletion extensions/ql-vscode/src/common/vscode/workspace-folders.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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. */
Expand Down
4 changes: 4 additions & 0 deletions extensions/ql-vscode/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 28fd6c3

Please sign in to comment.