Skip to content

Commit

Permalink
Add ignoredWorkspaceFolder setting
Browse files Browse the repository at this point in the history
  • Loading branch information
gsingh93 committed May 21, 2024
1 parent d8a7dcd commit f03284b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions extensions/ql-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
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.ignoredWorkspaceFolders": {
"type": "array",
"default": [],
"description": "Workspace folders to ignore."
},
"codeQL.runningQueries.saveCache": {
"type": "boolean",
"default": false,
Expand Down
16 changes: 15 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_WORKSPACE_FOLDERS_SETTING } from "../../config";

/** Returns true if the specified workspace folder is on the file system. */
export function isWorkspaceFolderOnDisk(
Expand All @@ -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. */
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_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(
Expand Down

0 comments on commit f03284b

Please sign in to comment.