Skip to content

Commit 68c41d3

Browse files
Merge branch 'main' into robertbrignull/countSuccessfulRepos
2 parents b5ad37a + 29d0483 commit 68c41d3

File tree

120 files changed

+2715
-2237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+2715
-2237
lines changed

docs/test-plan.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,10 @@ This requires running a MRVA query and seeing the results view.
258258
2. When the file does not exist
259259
7. Can open query text
260260
8. Can sort repos
261-
1. By name
262-
2. By results
263-
3. By stars
264-
4. By last updated
261+
1. Alphabetically
262+
2. By number of results
263+
3. By popularity
264+
4. By most recent commit
265265
9. Can filter repos
266266
10. Shows correct statistics
267267
1. Total number of results

extensions/ql-vscode/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
## [UNRELEASED]
44

5+
## 1.8.3 - 26 April 2023
6+
7+
- Added ability to filter repositories for a variant analysis to only those that have results [#2343](https://github.com/github/vscode-codeql/pull/2343)
58
- Add new configuration option to allow downloading databases from http, non-secure servers. [#2332](https://github.com/github/vscode-codeql/pull/2332)
9+
- Remove title actions from the query history panel that depended on history items being selected. [#2350](https://github.com/github/vscode-codeql/pull/2350)
610

711
## 1.8.2 - 12 April 2023
812

extensions/ql-vscode/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions/ql-vscode/package.json

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "CodeQL for Visual Studio Code",
55
"author": "GitHub",
66
"private": true,
7-
"version": "1.8.3",
7+
"version": "1.8.4",
88
"publisher": "GitHub",
99
"license": "MIT",
1010
"icon": "media/VS-marketplace-CodeQL-icon.png",
@@ -340,6 +340,12 @@
340340
"type": "boolean",
341341
"default": false,
342342
"description": "Allow database to be downloaded via HTTP. Warning: enabling this option will allow downloading from insecure servers."
343+
},
344+
"codeQL.createQuery.folder": {
345+
"type": "string",
346+
"default": "",
347+
"patternErrorMessage": "Please enter a valid folder",
348+
"markdownDescription": "The name of the folder where we want to create queries and query packs via the \"CodeQL: Create Query\" command. The folder should exist."
343349
}
344350
}
345351
},
@@ -627,11 +633,6 @@
627633
"command": "codeQL.checkForUpdatesToCLI",
628634
"title": "CodeQL: Check for CLI Updates"
629635
},
630-
{
631-
"command": "codeQLQueryHistory.openQueryTitleMenu",
632-
"title": "View Query",
633-
"icon": "$(edit)"
634-
},
635636
{
636637
"command": "codeQLQueryHistory.openQueryContextMenu",
637638
"title": "View Query",
@@ -642,11 +643,6 @@
642643
"title": "Open Query Results",
643644
"icon": "$(preview)"
644645
},
645-
{
646-
"command": "codeQLQueryHistory.removeHistoryItemTitleMenu",
647-
"title": "Delete",
648-
"icon": "$(trash)"
649-
},
650646
{
651647
"command": "codeQLQueryHistory.removeHistoryItemContextMenu",
652648
"title": "Delete",
@@ -847,21 +843,6 @@
847843
"when": "view == codeQLDatabases",
848844
"group": "navigation"
849845
},
850-
{
851-
"command": "codeQLQueryHistory.openQueryTitleMenu",
852-
"when": "view == codeQLQueryHistory",
853-
"group": "navigation"
854-
},
855-
{
856-
"command": "codeQLQueryHistory.itemClicked",
857-
"when": "view == codeQLQueryHistory",
858-
"group": "navigation"
859-
},
860-
{
861-
"command": "codeQLQueryHistory.removeHistoryItemTitleMenu",
862-
"when": "view == codeQLQueryHistory",
863-
"group": "navigation"
864-
},
865846
{
866847
"command": "codeQLQueryHistory.sortByName",
867848
"when": "view == codeQLQueryHistory",
@@ -1304,18 +1285,10 @@
13041285
"command": "codeQLDatabases.upgradeDatabase",
13051286
"when": "false"
13061287
},
1307-
{
1308-
"command": "codeQLQueryHistory.openQueryTitleMenu",
1309-
"when": "false"
1310-
},
13111288
{
13121289
"command": "codeQLQueryHistory.openQueryContextMenu",
13131290
"when": "false"
13141291
},
1315-
{
1316-
"command": "codeQLQueryHistory.removeHistoryItemTitleMenu",
1317-
"when": "false"
1318-
},
13191292
{
13201293
"command": "codeQLQueryHistory.removeHistoryItemContextMenu",
13211294
"when": "false"
@@ -1446,7 +1419,7 @@
14461419
},
14471420
{
14481421
"command": "codeQL.createQuery",
1449-
"when": "config.codeQL.canary"
1422+
"when": "config.codeQL.codespacesTemplate"
14501423
},
14511424
{
14521425
"command": "codeQLTests.acceptOutputContextTestItem",

extensions/ql-vscode/src/cli.ts

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ export type OnLineCallback = (
171171
line: string,
172172
) => Promise<string | undefined> | string | undefined;
173173

174+
type VersionChangedListener = (newVersion: SemVer | undefined) => void;
175+
174176
/**
175177
* This class manages a cli server started by `codeql execute cli-server` to
176178
* run commands without the overhead of starting a new java
@@ -188,7 +190,9 @@ export class CodeQLCliServer implements Disposable {
188190
nullBuffer: Buffer;
189191

190192
/** Version of current cli, lazily computed by the `getVersion()` method */
191-
private _version: Promise<SemVer> | undefined;
193+
private _version: SemVer | undefined;
194+
195+
private _versionChangedListeners: VersionChangedListener[] = [];
192196

193197
/**
194198
* The languages supported by the current version of the CLI, computed by `getSupportedLanguages()`.
@@ -1417,15 +1421,36 @@ export class CodeQLCliServer implements Disposable {
14171421

14181422
public async getVersion() {
14191423
if (!this._version) {
1420-
this._version = this.refreshVersion();
1421-
// this._version is only undefined upon config change, so we reset CLI-based context key only when necessary.
1422-
await this.app.commands.execute(
1423-
"setContext",
1424-
"codeql.supportsEvalLog",
1425-
await this.cliConstraints.supportsPerQueryEvalLog(),
1426-
);
1424+
try {
1425+
const newVersion = await this.refreshVersion();
1426+
this._version = newVersion;
1427+
this._versionChangedListeners.forEach((listener) =>
1428+
listener(newVersion),
1429+
);
1430+
1431+
// this._version is only undefined upon config change, so we reset CLI-based context key only when necessary.
1432+
await this.app.commands.execute(
1433+
"setContext",
1434+
"codeql.supportsEvalLog",
1435+
newVersion.compare(
1436+
CliVersionConstraint.CLI_VERSION_WITH_PER_QUERY_EVAL_LOG,
1437+
) >= 0,
1438+
);
1439+
} catch (e) {
1440+
this._versionChangedListeners.forEach((listener) =>
1441+
listener(undefined),
1442+
);
1443+
throw e;
1444+
}
1445+
}
1446+
return this._version;
1447+
}
1448+
1449+
public addVersionChangedListener(listener: VersionChangedListener) {
1450+
if (this._version) {
1451+
listener(this._version);
14271452
}
1428-
return await this._version;
1453+
this._versionChangedListeners.push(listener);
14291454
}
14301455

14311456
private async refreshVersion() {

extensions/ql-vscode/src/common/commands.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { CommandManager } from "../packages/commands";
22
import type { Uri, Range, TextDocumentShowOptions } from "vscode";
3-
import type { AstItem } from "../astViewer";
3+
import type { AstItem } from "../language-support";
44
import type { DbTreeViewItem } from "../databases/ui/db-tree-view-item";
5-
import type { DatabaseItem } from "../local-databases";
5+
import type { DatabaseItem } from "../databases/local-databases";
66
import type { QueryHistoryInfo } from "../query-history/query-history-info";
77
import type { RepositoriesFilterSortStateWithIds } from "../pure/variant-analysis-filter-sort";
88
import type { TestTreeNode } from "../test-tree-node";
@@ -13,21 +13,6 @@ import type {
1313
} from "../variant-analysis/shared/variant-analysis";
1414
import type { QLDebugConfiguration } from "../debugger/debug-configuration";
1515

16-
// A command function matching the signature that VS Code calls when
17-
// a command is invoked from the title bar of a TreeView with
18-
// canSelectMany set to true.
19-
//
20-
// It is possible to get any combination of singleItem and multiSelect
21-
// to be undefined. This is because it is possible to click a title bar
22-
// option without interacting with any individual items first, or even
23-
// when there are no items present at all.
24-
// If both singleItem and multiSelect are defined, then singleItem will
25-
// be contained within multiSelect.
26-
export type TreeViewTitleMultiSelectionCommandFunction<Item> = (
27-
singleItem: Item | undefined,
28-
multiSelect: Item[] | undefined,
29-
) => Promise<void>;
30-
3116
// A command function matching the signature that VS Code calls when
3217
// a command is invoked from a context menu on a TreeView with
3318
// canSelectMany set to true.
@@ -176,9 +161,7 @@ export type QueryHistoryCommands = {
176161
"codeQLQueryHistory.sortByCount": () => Promise<void>;
177162

178163
// Commands in the context menu or in the hover menu
179-
"codeQLQueryHistory.openQueryTitleMenu": TreeViewTitleMultiSelectionCommandFunction<QueryHistoryInfo>;
180164
"codeQLQueryHistory.openQueryContextMenu": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
181-
"codeQLQueryHistory.removeHistoryItemTitleMenu": TreeViewTitleMultiSelectionCommandFunction<QueryHistoryInfo>;
182165
"codeQLQueryHistory.removeHistoryItemContextMenu": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
183166
"codeQLQueryHistory.removeHistoryItemContextInline": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
184167
"codeQLQueryHistory.renameItem": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
@@ -195,7 +178,7 @@ export type QueryHistoryCommands = {
195178
"codeQLQueryHistory.viewCsvAlerts": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
196179
"codeQLQueryHistory.viewSarifAlerts": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
197180
"codeQLQueryHistory.viewDil": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
198-
"codeQLQueryHistory.itemClicked": TreeViewTitleMultiSelectionCommandFunction<QueryHistoryInfo>;
181+
"codeQLQueryHistory.itemClicked": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
199182
"codeQLQueryHistory.openOnGithub": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
200183
"codeQLQueryHistory.copyRepoList": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
201184

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { showAndLogErrorMessage } from "../helpers";
2+
import {
3+
ExplorerSelectionCommandFunction,
4+
TreeViewContextMultiSelectionCommandFunction,
5+
TreeViewContextSingleSelectionCommandFunction,
6+
} from "./commands";
7+
8+
// A hack to match types that are not an array, which is useful to help avoid
9+
// misusing createSingleSelectionCommand, e.g. where T accidentally gets instantiated
10+
// as DatabaseItem[] instead of DatabaseItem.
11+
type NotArray = object & { length?: never };
12+
13+
// A way to get the type system to help assert that one type is a supertype of another.
14+
type CreateSupertypeOf<Super, Sub extends Super> = Sub;
15+
16+
// This asserts that SelectionCommand is assignable to all of the different types of
17+
// SelectionCommand defined in commands.ts. The intention is the output from the helpers
18+
// in this file can be used with any of the select command types and can handle any of
19+
// the inputs.
20+
type SelectionCommand<T extends NotArray> = CreateSupertypeOf<
21+
TreeViewContextMultiSelectionCommandFunction<T> &
22+
TreeViewContextSingleSelectionCommandFunction<T> &
23+
ExplorerSelectionCommandFunction<T>,
24+
(singleItem: T, multiSelect?: T[] | undefined) => Promise<void>
25+
>;
26+
27+
export function createSingleSelectionCommand<T extends NotArray>(
28+
f: (argument: T) => Promise<void>,
29+
itemName: string,
30+
): SelectionCommand<T> {
31+
return async (singleItem, multiSelect) => {
32+
if (multiSelect === undefined || multiSelect.length === 1) {
33+
return f(singleItem);
34+
} else {
35+
void showAndLogErrorMessage(`Please select a single ${itemName}.`);
36+
return;
37+
}
38+
};
39+
}
40+
41+
export function createMultiSelectionCommand<T extends NotArray>(
42+
f: (argument: T[]) => Promise<void>,
43+
): SelectionCommand<T> {
44+
return async (singleItem, multiSelect) => {
45+
if (multiSelect !== undefined && multiSelect.length > 0) {
46+
return f(multiSelect);
47+
} else {
48+
return f([singleItem]);
49+
}
50+
};
51+
}

extensions/ql-vscode/src/compare/compare-view.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from "../pure/interface-types";
88
import { Logger } from "../common";
99
import { CodeQLCliServer } from "../cli";
10-
import { DatabaseManager } from "../local-databases";
10+
import { DatabaseManager } from "../databases/local-databases";
1111
import { jumpToLocation } from "../interface-utils";
1212
import {
1313
transformBqrsResultSet,

extensions/ql-vscode/src/config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,3 +619,19 @@ export const ALLOW_HTTP_SETTING = new Setting(
619619
export function allowHttp(): boolean {
620620
return ALLOW_HTTP_SETTING.getValue<boolean>() || false;
621621
}
622+
623+
/**
624+
* The name of the folder where we want to create skeleton wizard QL packs.
625+
**/
626+
const SKELETON_WIZARD_FOLDER = new Setting(
627+
"folder",
628+
new Setting("createQuery", ROOT_SETTING),
629+
);
630+
631+
export function getSkeletonWizardFolder(): string | undefined {
632+
return SKELETON_WIZARD_FOLDER.getValue<string>() || undefined;
633+
}
634+
635+
export async function setSkeletonWizardFolder(folder: string | undefined) {
636+
await SKELETON_WIZARD_FOLDER.updateValue(folder, ConfigurationTarget.Global);
637+
}

extensions/ql-vscode/src/data-extensions-editor/data-extensions-editor-module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { ExtensionContext } from "vscode";
22
import { DataExtensionsEditorView } from "./data-extensions-editor-view";
33
import { DataExtensionsEditorCommands } from "../common/commands";
44
import { CliVersionConstraint, CodeQLCliServer } from "../cli";
5-
import { QueryRunner } from "../queryRunner";
6-
import { DatabaseManager } from "../local-databases";
5+
import { QueryRunner } from "../query-server";
6+
import { DatabaseManager } from "../databases/local-databases";
77
import { ensureDir } from "fs-extra";
88
import { join } from "path";
99
import { App } from "../common/app";

0 commit comments

Comments
 (0)