Merge pull request #2192 from github/robertbrignull/export_selected_results_command

Move codeQL.exportSelectedVariantAnalysisResults to query history manager
This commit is contained in:
Robert 2023-03-22 11:41:13 +00:00 коммит произвёл GitHub
Родитель 3240809d11 0983733a67
Коммит 2334e4e7b2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 22 добавлений и 27 удалений

Просмотреть файл

@ -76,6 +76,9 @@ export type QueryHistoryCommands = {
"codeQLQueryHistory.itemClicked": SelectionCommandFunction<QueryHistoryInfo>;
"codeQLQueryHistory.openOnGithub": SelectionCommandFunction<QueryHistoryInfo>;
"codeQLQueryHistory.copyRepoList": SelectionCommandFunction<QueryHistoryInfo>;
// Commands in the command palette
"codeQL.exportSelectedVariantAnalysisResults": () => Promise<void>;
};
// Commands used for the local databases panel

Просмотреть файл

@ -101,7 +101,6 @@ import {
handleInstallPackDependencies,
} from "./packaging";
import { HistoryItemLabelProvider } from "./query-history/history-item-label-provider";
import { exportSelectedVariantAnalysisResults } from "./variant-analysis/export-results";
import { EvalLogViewer } from "./eval-log-viewer";
import { SummaryLanguageSupport } from "./log-insights/summary-language-support";
import { JoinOrderScannerProvider } from "./log-insights/join-order";
@ -892,12 +891,6 @@ async function activateWithInstalledDistribution(
),
);
ctx.subscriptions.push(
commandRunner("codeQL.exportSelectedVariantAnalysisResults", async () => {
await exportSelectedVariantAnalysisResults(variantAnalysisManager, qhm);
}),
);
ctx.subscriptions.push(
commandRunner(
"codeQL.loadVariantAnalysisRepoResults",

Просмотреть файл

@ -271,6 +271,9 @@ export class QueryHistoryManager extends DisposableObject {
"codeQLQueryHistory.itemClicked": this.handleItemClicked.bind(this),
"codeQLQueryHistory.openOnGithub": this.handleOpenOnGithub.bind(this),
"codeQLQueryHistory.copyRepoList": this.handleCopyRepoList.bind(this),
"codeQL.exportSelectedVariantAnalysisResults":
this.exportSelectedVariantAnalysisResults.bind(this),
};
}
@ -1127,6 +1130,22 @@ export class QueryHistoryManager extends DisposableObject {
);
}
/**
* Exports the results of the currently-selected variant analysis.
*/
async exportSelectedVariantAnalysisResults(): Promise<void> {
const queryHistoryItem = this.getCurrentQueryHistoryItem();
if (!queryHistoryItem || queryHistoryItem.t !== "variant-analysis") {
throw new Error(
"No variant analysis results currently open. To open results, click an item in the query history view.",
);
}
await this.variantAnalysisManager.exportResults(
queryHistoryItem.variantAnalysis.id,
);
}
addQuery(item: QueryHistoryInfo) {
this.treeDataProvider.pushQuery(item);
this.updateTreeViewSelectionIfVisible();

Просмотреть файл

@ -16,7 +16,6 @@ import {
} from "../commandRunner";
import { showInformationMessageWithAction } from "../helpers";
import { extLogger } from "../common";
import { QueryHistoryManager } from "../query-history/query-history-manager";
import { createGist } from "./gh-api/gh-api-client";
import {
generateVariantAnalysisMarkdown,
@ -37,25 +36,6 @@ import {
} from "../pure/variant-analysis-filter-sort";
import { Credentials } from "../common/authentication";
/**
* Exports the results of the currently-selected variant analysis.
*/
export async function exportSelectedVariantAnalysisResults(
variantAnalysisManager: VariantAnalysisManager,
queryHistoryManager: QueryHistoryManager,
): Promise<void> {
const queryHistoryItem = queryHistoryManager.getCurrentQueryHistoryItem();
if (!queryHistoryItem || queryHistoryItem.t !== "variant-analysis") {
throw new Error(
"No variant analysis results currently open. To open results, click an item in the query history view.",
);
}
await variantAnalysisManager.exportResults(
queryHistoryItem.variantAnalysis.id,
);
}
const MAX_VARIANT_ANALYSIS_EXPORT_PROGRESS_STEPS = 2;
/**