Skip to content

Commit a27ca2e

Browse files
committed
Merge remote-tracking branch 'origin/main' into koesie10/base-typed-commands
2 parents e1d5a4d + 297fa2e commit a27ca2e

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

extensions/ql-vscode/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
## [UNRELEASED]
44

5-
- Show data flow paths of a variant analysis in a new tab
6-
- Show labels of entities in exported CSV results [#2170](https://github.com/github/vscode-codeql/pull/2170)
5+
- Show data flow paths of a variant analysis in a new tab. [#2172](https://github.com/github/vscode-codeql/pull/2172) & [#2182](https://github.com/github/vscode-codeql/pull/2182)
6+
- Show labels of entities in exported CSV results. [#2170](https://github.com/github/vscode-codeql/pull/2170)
77

88
## 1.8.0 - 9 March 2023
99

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ export type SingleSelectionCommandFunction<Item> = (
3232
* the implementation in the corresponding `getCommands` function.
3333
*/
3434

35+
// Builtin commands where the implementation is provided by VS Code and not by this extension.
36+
// See https://code.visualstudio.com/api/references/commands
37+
export type BuiltInVsCodeCommands = {
38+
"markdown.showPreviewToSide": (uri: Uri) => Promise<void>;
39+
"workbench.action.reloadWindow": () => Promise<void>;
40+
};
41+
3542
// Base commands not tied directly to a module like e.g. variant analysis.
3643
export type BaseCommands = {
3744
"codeQL.openDocumentation": () => Promise<void>;
@@ -233,7 +240,8 @@ export type MockGitHubApiServerCommands = {
233240
"codeQL.mockGitHubApiServer.unloadScenario": () => Promise<void>;
234241
};
235242

236-
export type AllCommands = BaseCommands &
243+
// All commands where the implementation is provided by this extension.
244+
export type AllExtensionCommands = BaseCommands &
237245
QueryEditorCommands &
238246
ResultsViewCommands &
239247
QueryHistoryCommands &
@@ -248,6 +256,8 @@ export type AllCommands = BaseCommands &
248256
Partial<TestUICommands> &
249257
MockGitHubApiServerCommands;
250258

259+
export type AllCommands = AllExtensionCommands & BuiltInVsCodeCommands;
260+
251261
export type AppCommandManager = CommandManager<AllCommands>;
252262

253263
// Separate command manager because it uses a different logger

extensions/ql-vscode/src/extension.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import "source-map-support/register";
22
import {
33
CancellationToken,
4-
commands,
54
Disposable,
65
env,
76
ExtensionContext,
@@ -111,7 +110,7 @@ import { DbModule } from "./databases/db-module";
111110
import { redactableError } from "./pure/errors";
112111
import { QueryHistoryDirs } from "./query-history/query-history-dirs";
113112
import {
114-
AllCommands,
113+
AllExtensionCommands,
115114
BaseCommands,
116115
QueryServerCommands,
117116
TestUICommands,
@@ -297,6 +296,8 @@ export async function activate(
297296
addUnhandledRejectionListener();
298297
install();
299298

299+
const app = new ExtensionApp(ctx);
300+
300301
const codelensProvider = new QuickEvalCodeLensProvider();
301302
languages.registerCodeLensProvider(
302303
{ scheme: "file", language: "ql" },
@@ -323,6 +324,7 @@ export async function activate(
323324
distributionConfigListener.onDidChangeConfiguration(() =>
324325
installOrUpdateThenTryActivate(
325326
ctx,
327+
app,
326328
distributionManager,
327329
distributionConfigListener,
328330
{
@@ -337,6 +339,7 @@ export async function activate(
337339
commandRunner(checkForUpdatesCommand, () =>
338340
installOrUpdateThenTryActivate(
339341
ctx,
342+
app,
340343
distributionManager,
341344
distributionConfigListener,
342345
{
@@ -356,6 +359,7 @@ export async function activate(
356359

357360
const codeQlExtension = await installOrUpdateThenTryActivate(
358361
ctx,
362+
app,
359363
distributionManager,
360364
distributionConfigListener,
361365
{
@@ -377,6 +381,7 @@ export async function activate(
377381

378382
async function installOrUpdateDistributionWithProgressTitle(
379383
ctx: ExtensionContext,
384+
app: ExtensionApp,
380385
distributionManager: DistributionManager,
381386
progressTitle: string,
382387
config: DistributionUpdateConfig,
@@ -421,7 +426,7 @@ async function installOrUpdateDistributionWithProgressTitle(
421426
"Restart and Upgrade",
422427
)
423428
) {
424-
await commands.executeCommand("workbench.action.reloadWindow");
429+
await app.commands.execute("workbench.action.reloadWindow");
425430
}
426431
} else {
427432
await withProgress(
@@ -448,6 +453,7 @@ async function installOrUpdateDistributionWithProgressTitle(
448453

449454
async function installOrUpdateDistribution(
450455
ctx: ExtensionContext,
456+
app: ExtensionApp,
451457
distributionManager: DistributionManager,
452458
config: DistributionUpdateConfig,
453459
): Promise<void> {
@@ -468,6 +474,7 @@ async function installOrUpdateDistribution(
468474
try {
469475
await installOrUpdateDistributionWithProgressTitle(
470476
ctx,
477+
app,
471478
distributionManager,
472479
messageText,
473480
config,
@@ -553,11 +560,12 @@ async function getDistributionDisplayingDistributionWarnings(
553560

554561
async function installOrUpdateThenTryActivate(
555562
ctx: ExtensionContext,
563+
app: ExtensionApp,
556564
distributionManager: DistributionManager,
557565
distributionConfigListener: DistributionConfigListener,
558566
config: DistributionUpdateConfig,
559567
): Promise<CodeQLExtensionInterface | Record<string, never>> {
560-
await installOrUpdateDistribution(ctx, distributionManager, config);
568+
await installOrUpdateDistribution(ctx, app, distributionManager, config);
561569

562570
try {
563571
await prepareCodeTour();
@@ -577,6 +585,7 @@ async function installOrUpdateThenTryActivate(
577585
) {
578586
extensionInterface = await activateWithInstalledDistribution(
579587
ctx,
588+
app,
580589
distributionManager,
581590
distributionConfigListener,
582591
);
@@ -594,6 +603,7 @@ async function installOrUpdateThenTryActivate(
594603
if (chosenAction === installActionName) {
595604
await installOrUpdateThenTryActivate(
596605
ctx,
606+
app,
597607
distributionManager,
598608
distributionConfigListener,
599609
{
@@ -620,6 +630,7 @@ const PACK_GLOBS = [
620630

621631
async function activateWithInstalledDistribution(
622632
ctx: ExtensionContext,
633+
app: ExtensionApp,
623634
distributionManager: DistributionManager,
624635
distributionConfigListener: DistributionConfigListener,
625636
): Promise<CodeQLExtensionInterface> {
@@ -628,8 +639,6 @@ async function activateWithInstalledDistribution(
628639
// of activation.
629640
errorStubs.forEach((stub) => stub.dispose());
630641

631-
const app = new ExtensionApp(ctx);
632-
633642
void extLogger.log("Initializing configuration listener...");
634643
const qlConfigurationListener =
635644
await QueryServerConfigListener.createQueryServerConfigListener(
@@ -862,7 +871,7 @@ async function activateWithInstalledDistribution(
862871

863872
void extLogger.log("Registering top-level command palette commands.");
864873

865-
const allCommands: AllCommands = {
874+
const allCommands: AllExtensionCommands = {
866875
...getCommands(app, cliServer, qs),
867876
...getQueryEditorCommands({
868877
queryRunner: qs,
@@ -895,7 +904,7 @@ async function activateWithInstalledDistribution(
895904
};
896905

897906
for (const [commandName, command] of Object.entries(allCommands)) {
898-
app.commands.register(commandName as keyof AllCommands, command);
907+
app.commands.register(commandName as keyof AllExtensionCommands, command);
899908
}
900909

901910
const queryServerCommands: QueryServerCommands = {
@@ -948,7 +957,7 @@ async function activateWithInstalledDistribution(
948957
),
949958
);
950959

951-
await commands.executeCommand("codeQLDatabases.removeOrphanedDatabases");
960+
await app.commands.execute("codeQLDatabases.removeOrphanedDatabases");
952961

953962
void extLogger.log("Reading query history");
954963
await qhm.readQueryHistory();

0 commit comments

Comments
 (0)