Skip to content

Commit 2334e4e

Browse files
Merge pull request #2192 from github/robertbrignull/export_selected_results_command
Move codeQL.exportSelectedVariantAnalysisResults to query history manager
2 parents 3240809 + 0983733 commit 2334e4e

File tree

4 files changed

+22
-27
lines changed

4 files changed

+22
-27
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ export type QueryHistoryCommands = {
7676
"codeQLQueryHistory.itemClicked": SelectionCommandFunction<QueryHistoryInfo>;
7777
"codeQLQueryHistory.openOnGithub": SelectionCommandFunction<QueryHistoryInfo>;
7878
"codeQLQueryHistory.copyRepoList": SelectionCommandFunction<QueryHistoryInfo>;
79+
80+
// Commands in the command palette
81+
"codeQL.exportSelectedVariantAnalysisResults": () => Promise<void>;
7982
};
8083

8184
// Commands used for the local databases panel

extensions/ql-vscode/src/extension.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ import {
101101
handleInstallPackDependencies,
102102
} from "./packaging";
103103
import { HistoryItemLabelProvider } from "./query-history/history-item-label-provider";
104-
import { exportSelectedVariantAnalysisResults } from "./variant-analysis/export-results";
105104
import { EvalLogViewer } from "./eval-log-viewer";
106105
import { SummaryLanguageSupport } from "./log-insights/summary-language-support";
107106
import { JoinOrderScannerProvider } from "./log-insights/join-order";
@@ -892,12 +891,6 @@ async function activateWithInstalledDistribution(
892891
),
893892
);
894893

895-
ctx.subscriptions.push(
896-
commandRunner("codeQL.exportSelectedVariantAnalysisResults", async () => {
897-
await exportSelectedVariantAnalysisResults(variantAnalysisManager, qhm);
898-
}),
899-
);
900-
901894
ctx.subscriptions.push(
902895
commandRunner(
903896
"codeQL.loadVariantAnalysisRepoResults",

extensions/ql-vscode/src/query-history/query-history-manager.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ export class QueryHistoryManager extends DisposableObject {
271271
"codeQLQueryHistory.itemClicked": this.handleItemClicked.bind(this),
272272
"codeQLQueryHistory.openOnGithub": this.handleOpenOnGithub.bind(this),
273273
"codeQLQueryHistory.copyRepoList": this.handleCopyRepoList.bind(this),
274+
275+
"codeQL.exportSelectedVariantAnalysisResults":
276+
this.exportSelectedVariantAnalysisResults.bind(this),
274277
};
275278
}
276279

@@ -1127,6 +1130,22 @@ export class QueryHistoryManager extends DisposableObject {
11271130
);
11281131
}
11291132

1133+
/**
1134+
* Exports the results of the currently-selected variant analysis.
1135+
*/
1136+
async exportSelectedVariantAnalysisResults(): Promise<void> {
1137+
const queryHistoryItem = this.getCurrentQueryHistoryItem();
1138+
if (!queryHistoryItem || queryHistoryItem.t !== "variant-analysis") {
1139+
throw new Error(
1140+
"No variant analysis results currently open. To open results, click an item in the query history view.",
1141+
);
1142+
}
1143+
1144+
await this.variantAnalysisManager.exportResults(
1145+
queryHistoryItem.variantAnalysis.id,
1146+
);
1147+
}
1148+
11301149
addQuery(item: QueryHistoryInfo) {
11311150
this.treeDataProvider.pushQuery(item);
11321151
this.updateTreeViewSelectionIfVisible();

extensions/ql-vscode/src/variant-analysis/export-results.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
} from "../commandRunner";
1717
import { showInformationMessageWithAction } from "../helpers";
1818
import { extLogger } from "../common";
19-
import { QueryHistoryManager } from "../query-history/query-history-manager";
2019
import { createGist } from "./gh-api/gh-api-client";
2120
import {
2221
generateVariantAnalysisMarkdown,
@@ -37,25 +36,6 @@ import {
3736
} from "../pure/variant-analysis-filter-sort";
3837
import { Credentials } from "../common/authentication";
3938

40-
/**
41-
* Exports the results of the currently-selected variant analysis.
42-
*/
43-
export async function exportSelectedVariantAnalysisResults(
44-
variantAnalysisManager: VariantAnalysisManager,
45-
queryHistoryManager: QueryHistoryManager,
46-
): Promise<void> {
47-
const queryHistoryItem = queryHistoryManager.getCurrentQueryHistoryItem();
48-
if (!queryHistoryItem || queryHistoryItem.t !== "variant-analysis") {
49-
throw new Error(
50-
"No variant analysis results currently open. To open results, click an item in the query history view.",
51-
);
52-
}
53-
54-
await variantAnalysisManager.exportResults(
55-
queryHistoryItem.variantAnalysis.id,
56-
);
57-
}
58-
5939
const MAX_VARIANT_ANALYSIS_EXPORT_PROGRESS_STEPS = 2;
6040

6141
/**

0 commit comments

Comments
 (0)