Skip to content

Commit 9c79799

Browse files
Merge branch 'main' into yer-a-workspace-query
2 parents 70d533f + ffa643c commit 9c79799

File tree

72 files changed

+8293
-1650
lines changed

Some content is hidden

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

72 files changed

+8293
-1650
lines changed

extensions/ql-vscode/package-lock.json

Lines changed: 5318 additions & 683 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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,7 @@
14611461
"fs-extra": "^11.1.1",
14621462
"immutable": "^4.0.0",
14631463
"js-yaml": "^4.1.0",
1464+
"minimatch": "^9.0.0",
14641465
"minimist": "~1.2.6",
14651466
"msw": "^1.2.0",
14661467
"nanoid": "^3.2.0",
@@ -1497,7 +1498,7 @@
14971498
"@storybook/addon-essentials": "^6.5.17-alpha.0",
14981499
"@storybook/addon-interactions": "^6.5.17-alpha.0",
14991500
"@storybook/addon-links": "^6.5.17-alpha.0",
1500-
"@storybook/builder-webpack5": "^6.5.17-alpha.0",
1501+
"@storybook/builder-webpack5": "^7.0.4",
15011502
"@storybook/manager-webpack5": "^6.5.17-alpha.0",
15021503
"@storybook/react": "^6.5.17-alpha.0",
15031504
"@storybook/testing-library": "^0.0.13",
@@ -1531,7 +1532,7 @@
15311532
"@types/through2": "^2.0.36",
15321533
"@types/tmp": "^0.1.0",
15331534
"@types/unzipper": "~0.10.1",
1534-
"@types/vscode": "^1.59.0",
1535+
"@types/vscode": "^1.67.0",
15351536
"@types/webpack": "^5.28.0",
15361537
"@types/webpack-env": "^1.18.0",
15371538
"@types/xml2js": "~0.4.4",
@@ -1555,7 +1556,7 @@
15551556
"eslint-plugin-react-hooks": "^4.6.0",
15561557
"eslint-plugin-storybook": "^0.6.4",
15571558
"file-loader": "^6.2.0",
1558-
"glob": "^9.3.2",
1559+
"glob": "^10.0.0",
15591560
"gulp": "^4.0.2",
15601561
"gulp-esbuild": "^0.10.5",
15611562
"gulp-replace": "^1.1.3",

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

Lines changed: 73 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,53 @@ import type {
1313
} from "../variant-analysis/shared/variant-analysis";
1414

1515
// A command function matching the signature that VS Code calls when
16-
// a command on a selection is invoked.
17-
export type SelectionCommandFunction<Item> = (
16+
// a command is invoked from the title bar of a TreeView with
17+
// canSelectMany set to true.
18+
//
19+
// It is possible to get any combination of singleItem and multiSelect
20+
// to be undefined. This is because it is possible to click a title bar
21+
// option without interacting with any individual items first, or even
22+
// when there are no items present at all.
23+
// If both singleItem and multiSelect are defined, then singleItem will
24+
// be contained within multiSelect.
25+
export type TreeViewTitleMultiSelectionCommandFunction<Item> = (
26+
singleItem: Item | undefined,
27+
multiSelect: Item[] | undefined,
28+
) => Promise<void>;
29+
30+
// A command function matching the signature that VS Code calls when
31+
// a command is invoked from a context menu on a TreeView with
32+
// canSelectMany set to true.
33+
//
34+
// singleItem will always be defined and corresponds to the item that
35+
// was hovered or right-clicked. If precisely one item was selected then
36+
// multiSelect will be undefined. If more than one item is selected then
37+
// multiSelect will contain all selected items, including singleItem.
38+
export type TreeViewContextMultiSelectionCommandFunction<Item> = (
1839
singleItem: Item,
19-
multiSelect: Item[],
40+
multiSelect: Item[] | undefined,
2041
) => Promise<void>;
2142

2243
// A command function matching the signature that VS Code calls when
23-
// a command on a selection is invoked when canSelectMany is false.
24-
export type SingleSelectionCommandFunction<Item> = (
44+
// a command is invoked from a context menu on a TreeView with
45+
// canSelectMany set to false.
46+
//
47+
// It is guaranteed that precisely one item will be selected.
48+
export type TreeViewContextSingleSelectionCommandFunction<Item> = (
2549
singleItem: Item,
2650
) => Promise<void>;
2751

52+
// A command function matching the signature that VS Code calls when
53+
// a command is invoked from a context menu on the file explorer.
54+
//
55+
// singleItem corresponds to the item that was right-clicked.
56+
// multiSelect will always been defined and non-empty and contains
57+
// all selected items, including singleItem.
58+
export type ExplorerSelectionCommandFunction<Item> = (
59+
singleItem: Item,
60+
multiSelect: Item[],
61+
) => Promise<void>;
62+
2863
/**
2964
* Contains type definitions for all commands used by the extension.
3065
*
@@ -94,7 +129,7 @@ export type LocalQueryCommands = {
94129
"codeQL.runQueryOnMultipleDatabasesContextEditor": (
95130
uri?: Uri,
96131
) => Promise<void>;
97-
"codeQL.runQueries": SelectionCommandFunction<Uri>;
132+
"codeQL.runQueries": ExplorerSelectionCommandFunction<Uri>;
98133
"codeQL.quickEval": (uri: Uri) => Promise<void>;
99134
"codeQL.quickEvalContextEditor": (uri: Uri) => Promise<void>;
100135
"codeQL.codeLensQuickEval": (uri: Uri, range: Range) => Promise<void>;
@@ -119,28 +154,28 @@ export type QueryHistoryCommands = {
119154
"codeQLQueryHistory.sortByCount": () => Promise<void>;
120155

121156
// Commands in the context menu or in the hover menu
122-
"codeQLQueryHistory.openQueryTitleMenu": SelectionCommandFunction<QueryHistoryInfo>;
123-
"codeQLQueryHistory.openQueryContextMenu": SelectionCommandFunction<QueryHistoryInfo>;
124-
"codeQLQueryHistory.removeHistoryItemTitleMenu": SelectionCommandFunction<QueryHistoryInfo>;
125-
"codeQLQueryHistory.removeHistoryItemContextMenu": SelectionCommandFunction<QueryHistoryInfo>;
126-
"codeQLQueryHistory.removeHistoryItemContextInline": SelectionCommandFunction<QueryHistoryInfo>;
127-
"codeQLQueryHistory.renameItem": SelectionCommandFunction<QueryHistoryInfo>;
128-
"codeQLQueryHistory.compareWith": SelectionCommandFunction<QueryHistoryInfo>;
129-
"codeQLQueryHistory.showEvalLog": SelectionCommandFunction<QueryHistoryInfo>;
130-
"codeQLQueryHistory.showEvalLogSummary": SelectionCommandFunction<QueryHistoryInfo>;
131-
"codeQLQueryHistory.showEvalLogViewer": SelectionCommandFunction<QueryHistoryInfo>;
132-
"codeQLQueryHistory.showQueryLog": SelectionCommandFunction<QueryHistoryInfo>;
133-
"codeQLQueryHistory.showQueryText": SelectionCommandFunction<QueryHistoryInfo>;
134-
"codeQLQueryHistory.openQueryDirectory": SelectionCommandFunction<QueryHistoryInfo>;
135-
"codeQLQueryHistory.cancel": SelectionCommandFunction<QueryHistoryInfo>;
136-
"codeQLQueryHistory.exportResults": SelectionCommandFunction<QueryHistoryInfo>;
137-
"codeQLQueryHistory.viewCsvResults": SelectionCommandFunction<QueryHistoryInfo>;
138-
"codeQLQueryHistory.viewCsvAlerts": SelectionCommandFunction<QueryHistoryInfo>;
139-
"codeQLQueryHistory.viewSarifAlerts": SelectionCommandFunction<QueryHistoryInfo>;
140-
"codeQLQueryHistory.viewDil": SelectionCommandFunction<QueryHistoryInfo>;
141-
"codeQLQueryHistory.itemClicked": SelectionCommandFunction<QueryHistoryInfo>;
142-
"codeQLQueryHistory.openOnGithub": SelectionCommandFunction<QueryHistoryInfo>;
143-
"codeQLQueryHistory.copyRepoList": SelectionCommandFunction<QueryHistoryInfo>;
157+
"codeQLQueryHistory.openQueryTitleMenu": TreeViewTitleMultiSelectionCommandFunction<QueryHistoryInfo>;
158+
"codeQLQueryHistory.openQueryContextMenu": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
159+
"codeQLQueryHistory.removeHistoryItemTitleMenu": TreeViewTitleMultiSelectionCommandFunction<QueryHistoryInfo>;
160+
"codeQLQueryHistory.removeHistoryItemContextMenu": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
161+
"codeQLQueryHistory.removeHistoryItemContextInline": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
162+
"codeQLQueryHistory.renameItem": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
163+
"codeQLQueryHistory.compareWith": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
164+
"codeQLQueryHistory.showEvalLog": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
165+
"codeQLQueryHistory.showEvalLogSummary": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
166+
"codeQLQueryHistory.showEvalLogViewer": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
167+
"codeQLQueryHistory.showQueryLog": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
168+
"codeQLQueryHistory.showQueryText": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
169+
"codeQLQueryHistory.openQueryDirectory": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
170+
"codeQLQueryHistory.cancel": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
171+
"codeQLQueryHistory.exportResults": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
172+
"codeQLQueryHistory.viewCsvResults": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
173+
"codeQLQueryHistory.viewCsvAlerts": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
174+
"codeQLQueryHistory.viewSarifAlerts": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
175+
"codeQLQueryHistory.viewDil": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
176+
"codeQLQueryHistory.itemClicked": TreeViewTitleMultiSelectionCommandFunction<QueryHistoryInfo>;
177+
"codeQLQueryHistory.openOnGithub": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
178+
"codeQLQueryHistory.copyRepoList": TreeViewContextMultiSelectionCommandFunction<QueryHistoryInfo>;
144179

145180
// Commands in the command palette
146181
"codeQL.exportSelectedVariantAnalysisResults": () => Promise<void>;
@@ -173,11 +208,11 @@ export type LocalDatabasesCommands = {
173208
) => Promise<void>;
174209

175210
// Database panel selection commands
176-
"codeQLDatabases.removeDatabase": SelectionCommandFunction<DatabaseItem>;
177-
"codeQLDatabases.upgradeDatabase": SelectionCommandFunction<DatabaseItem>;
178-
"codeQLDatabases.renameDatabase": SelectionCommandFunction<DatabaseItem>;
179-
"codeQLDatabases.openDatabaseFolder": SelectionCommandFunction<DatabaseItem>;
180-
"codeQLDatabases.addDatabaseSource": SelectionCommandFunction<DatabaseItem>;
211+
"codeQLDatabases.removeDatabase": TreeViewContextMultiSelectionCommandFunction<DatabaseItem>;
212+
"codeQLDatabases.upgradeDatabase": TreeViewContextMultiSelectionCommandFunction<DatabaseItem>;
213+
"codeQLDatabases.renameDatabase": TreeViewContextMultiSelectionCommandFunction<DatabaseItem>;
214+
"codeQLDatabases.openDatabaseFolder": TreeViewContextMultiSelectionCommandFunction<DatabaseItem>;
215+
"codeQLDatabases.addDatabaseSource": TreeViewContextMultiSelectionCommandFunction<DatabaseItem>;
181216

182217
// Codespace template commands
183218
"codeQL.setDefaultTourDatabase": () => Promise<void>;
@@ -222,11 +257,11 @@ export type DatabasePanelCommands = {
222257
"codeQLVariantAnalysisRepositories.addNewList": () => Promise<void>;
223258
"codeQLVariantAnalysisRepositories.setupControllerRepository": () => Promise<void>;
224259

225-
"codeQLVariantAnalysisRepositories.setSelectedItem": SingleSelectionCommandFunction<DbTreeViewItem>;
226-
"codeQLVariantAnalysisRepositories.setSelectedItemContextMenu": SingleSelectionCommandFunction<DbTreeViewItem>;
227-
"codeQLVariantAnalysisRepositories.openOnGitHubContextMenu": SingleSelectionCommandFunction<DbTreeViewItem>;
228-
"codeQLVariantAnalysisRepositories.renameItemContextMenu": SingleSelectionCommandFunction<DbTreeViewItem>;
229-
"codeQLVariantAnalysisRepositories.removeItemContextMenu": SingleSelectionCommandFunction<DbTreeViewItem>;
260+
"codeQLVariantAnalysisRepositories.setSelectedItem": TreeViewContextSingleSelectionCommandFunction<DbTreeViewItem>;
261+
"codeQLVariantAnalysisRepositories.setSelectedItemContextMenu": TreeViewContextSingleSelectionCommandFunction<DbTreeViewItem>;
262+
"codeQLVariantAnalysisRepositories.openOnGitHubContextMenu": TreeViewContextSingleSelectionCommandFunction<DbTreeViewItem>;
263+
"codeQLVariantAnalysisRepositories.renameItemContextMenu": TreeViewContextSingleSelectionCommandFunction<DbTreeViewItem>;
264+
"codeQLVariantAnalysisRepositories.removeItemContextMenu": TreeViewContextSingleSelectionCommandFunction<DbTreeViewItem>;
230265
};
231266

232267
export type AstCfgCommands = {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class DataExtensionsEditorModule {
5353
return {
5454
"codeQL.openDataExtensionsEditor": async () =>
5555
withProgress(
56-
async (progress) => {
56+
async (progress, token) => {
5757
const db = this.databaseManager.currentDatabaseItem;
5858
if (!db) {
5959
void showAndLogErrorMessage("No database selected");
@@ -69,7 +69,9 @@ export class DataExtensionsEditorModule {
6969

7070
const modelFile = await pickExtensionPackModelFile(
7171
this.cliServer,
72+
db,
7273
progress,
74+
token,
7375
);
7476
if (!modelFile) {
7577
return;

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import {
1414
import { ProgressUpdate } from "../progress";
1515
import { QueryRunner } from "../queryRunner";
1616
import {
17+
showAndLogErrorMessage,
1718
showAndLogExceptionWithTelemetry,
18-
showAndLogWarningMessage,
1919
} from "../helpers";
2020
import { extLogger } from "../common";
21-
import { readFile, writeFile } from "fs-extra";
21+
import { outputFile, readFile } from "fs-extra";
2222
import { load as loadYaml } from "js-yaml";
2323
import { DatabaseItem, DatabaseManager } from "../local-databases";
2424
import { CodeQLCliServer } from "../cli";
@@ -150,7 +150,7 @@ export class DataExtensionsEditorView extends AbstractWebview<
150150
): Promise<void> {
151151
const yaml = createDataExtensionYaml(externalApiUsages, modeledMethods);
152152

153-
await writeFile(this.modelFilename, yaml);
153+
await outputFile(this.modelFilename, yaml);
154154

155155
void extLogger.log(`Saved data extension YAML to ${this.modelFilename}`);
156156
}
@@ -166,7 +166,9 @@ export class DataExtensionsEditorView extends AbstractWebview<
166166
const existingModeledMethods = loadDataExtensionYaml(data);
167167

168168
if (!existingModeledMethods) {
169-
void showAndLogWarningMessage("Failed to parse data extension YAML.");
169+
void showAndLogErrorMessage(
170+
`Failed to parse data extension YAML ${this.modelFilename}.`,
171+
);
170172
return;
171173
}
172174

@@ -175,7 +177,11 @@ export class DataExtensionsEditorView extends AbstractWebview<
175177
modeledMethods: existingModeledMethods,
176178
});
177179
} catch (e: unknown) {
178-
void extLogger.log(`Unable to read data extension YAML: ${e}`);
180+
void showAndLogErrorMessage(
181+
`Unable to read data extension YAML ${
182+
this.modelFilename
183+
}: ${getErrorMessage(e)}`,
184+
);
179185
}
180186
}
181187

@@ -188,7 +194,6 @@ export class DataExtensionsEditorView extends AbstractWebview<
188194
queryRunner: this.queryRunner,
189195
databaseItem: this.databaseItem,
190196
queryStorageDir: this.queryStorageDir,
191-
logger: extLogger,
192197
progress: (progressUpdate: ProgressUpdate) => {
193198
void this.showProgress(progressUpdate, 1500);
194199
},
@@ -208,7 +213,6 @@ export class DataExtensionsEditorView extends AbstractWebview<
208213
const bqrsChunk = await readQueryResults({
209214
cliServer: this.cliServer,
210215
bqrsPath: queryResult.outputDir.bqrsPath,
211-
logger: extLogger,
212216
});
213217
if (!bqrsChunk) {
214218
await this.clearProgress();
@@ -233,7 +237,7 @@ export class DataExtensionsEditorView extends AbstractWebview<
233237
void showAndLogExceptionWithTelemetry(
234238
redactableError(
235239
asError(err),
236-
)`Failed to load external APi usages: ${getErrorMessage(err)}`,
240+
)`Failed to load external API usages: ${getErrorMessage(err)}`,
237241
);
238242
}
239243
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"type": "object",
3+
"properties": {
4+
"extensions": {
5+
"type": "array",
6+
"items": {
7+
"type": "object",
8+
"required": ["addsTo", "data"],
9+
"properties": {
10+
"addsTo": {
11+
"type": "object",
12+
"required": ["pack", "extensible"],
13+
"properties": {
14+
"pack": {
15+
"type": "string"
16+
},
17+
"extensible": {
18+
"type": "string"
19+
}
20+
}
21+
},
22+
"data": {
23+
"type": "array",
24+
"items": {
25+
"type": "array",
26+
"items": {
27+
"oneOf": [
28+
{
29+
"type": "string"
30+
},
31+
{
32+
"type": "boolean"
33+
},
34+
{
35+
"type": "number"
36+
}
37+
]
38+
}
39+
}
40+
}
41+
}
42+
}
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)