Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions extensions/ql-vscode/src/common/commands.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { CommandManager } from "../packages/commands";
import type { Uri } from "vscode";
import type { DbTreeViewItem } from "../databases/ui/db-tree-view-item";
import type { DatabaseItem } from "../local-databases";
import type { QueryHistoryInfo } from "../query-history/query-history-info";

// A command function matching the signature that VS Code calls when
Expand Down Expand Up @@ -60,6 +61,31 @@ export type QueryHistoryCommands = {
"codeQLQueryHistory.copyRepoList": SelectionCommandFunction<QueryHistoryInfo>;
};

// Commands used for the local databases panel
export type LocalDatabasesCommands = {
"codeQL.setCurrentDatabase": (uri: Uri) => Promise<void>;
"codeQL.setDefaultTourDatabase": () => Promise<void>;
"codeQL.upgradeCurrentDatabase": () => Promise<void>;
"codeQL.clearCache": () => Promise<void>;

"codeQLDatabases.chooseDatabaseFolder": () => Promise<void>;
"codeQLDatabases.chooseDatabaseArchive": () => Promise<void>;
"codeQLDatabases.chooseDatabaseInternet": () => Promise<void>;
"codeQLDatabases.chooseDatabaseGithub": () => Promise<void>;
"codeQLDatabases.setCurrentDatabase": (
databaseItem: DatabaseItem,
) => Promise<void>;
"codeQLDatabases.sortByName": () => Promise<void>;
"codeQLDatabases.sortByDateAdded": () => Promise<void>;
"codeQLDatabases.removeOrphanedDatabases": () => Promise<void>;

"codeQLDatabases.removeDatabase": SelectionCommandFunction<DatabaseItem>;
"codeQLDatabases.upgradeDatabase": SelectionCommandFunction<DatabaseItem>;
"codeQLDatabases.renameDatabase": SelectionCommandFunction<DatabaseItem>;
"codeQLDatabases.openDatabaseFolder": SelectionCommandFunction<DatabaseItem>;
"codeQLDatabases.addDatabaseSource": SelectionCommandFunction<DatabaseItem>;
};

// Commands tied to variant analysis
export type VariantAnalysisCommands = {
"codeQL.openVariantAnalysisLogs": (
Expand All @@ -84,6 +110,7 @@ export type DatabasePanelCommands = {

export type AllCommands = BaseCommands &
QueryHistoryCommands &
LocalDatabasesCommands &
VariantAnalysisCommands &
DatabasePanelCommands;

Expand Down
16 changes: 5 additions & 11 deletions extensions/ql-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { CodeQLCliServer } from "./cli";
import {
CliConfigListener,
DistributionConfigListener,
isCanary,
joinOrderWarningThreshold,
MAX_QUERIES,
QueryHistoryConfigListener,
Expand Down Expand Up @@ -639,7 +638,6 @@ async function activateWithInstalledDistribution(
getContextStoragePath(ctx),
ctx.extensionPath,
);
databaseUI.init();
ctx.subscriptions.push(databaseUI);

void extLogger.log("Initializing evaluator log viewer.");
Expand Down Expand Up @@ -1093,6 +1091,7 @@ async function activateWithInstalledDistribution(
...getCommands(),
...qhm.getCommands(),
...variantAnalysisManager.getCommands(),
...databaseUI.getCommands(),
...dbModule.getCommands(),
};

Expand Down Expand Up @@ -1225,7 +1224,7 @@ async function activateWithInstalledDistribution(
commandRunnerWithProgress(
"codeQL.chooseDatabaseFolder",
(progress: ProgressCallback, token: CancellationToken) =>
databaseUI.handleChooseDatabaseFolder(progress, token),
databaseUI.chooseDatabaseFolder(progress, token),
{
title: "Choose a Database from a Folder",
},
Expand All @@ -1235,7 +1234,7 @@ async function activateWithInstalledDistribution(
commandRunnerWithProgress(
"codeQL.chooseDatabaseArchive",
(progress: ProgressCallback, token: CancellationToken) =>
databaseUI.handleChooseDatabaseArchive(progress, token),
databaseUI.chooseDatabaseArchive(progress, token),
{
title: "Choose a Database from an Archive",
},
Expand All @@ -1245,12 +1244,7 @@ async function activateWithInstalledDistribution(
commandRunnerWithProgress(
"codeQL.chooseDatabaseGithub",
async (progress: ProgressCallback, token: CancellationToken) => {
const credentials = isCanary() ? app.credentials : undefined;
await databaseUI.handleChooseDatabaseGithub(
credentials,
progress,
token,
);
await databaseUI.chooseDatabaseGithub(progress, token);
},
{
title: "Adding database from GitHub",
Expand All @@ -1261,7 +1255,7 @@ async function activateWithInstalledDistribution(
commandRunnerWithProgress(
"codeQL.chooseDatabaseInternet",
(progress: ProgressCallback, token: CancellationToken) =>
databaseUI.handleChooseDatabaseInternet(progress, token),
databaseUI.chooseDatabaseInternet(progress, token),

{
title: "Adding database from URL",
Expand Down
Loading