Skip to content

Commit 16464d5

Browse files
authored
Merge pull request #2069 from github/koesie10/remove-remote-query-commands
Remove remote queries commands
2 parents e5a48fb + f6d7ddf commit 16464d5

Some content is hidden

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

56 files changed

+30
-5774
lines changed

extensions/ql-vscode/src/extension.ts

Lines changed: 16 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@ import {
44
CancellationTokenSource,
55
commands,
66
Disposable,
7+
env,
78
ExtensionContext,
89
extensions,
910
languages,
1011
ProgressLocation,
1112
ProgressOptions,
13+
ProviderResult,
14+
QuickPickItem,
15+
Range,
1216
Uri,
17+
version as vscodeVersion,
1318
window as Window,
14-
env,
1519
window,
16-
QuickPickItem,
17-
Range,
1820
workspace,
19-
ProviderResult,
20-
version as vscodeVersion,
2121
} from "vscode";
2222
import { LanguageClient } from "vscode-languageclient/node";
23-
import { platform, arch } from "os";
23+
import { arch, platform } from "os";
2424
import { ensureDir } from "fs-extra";
25-
import { join, basename } from "path";
25+
import { basename, join } from "path";
2626
import { dirSync } from "tmp-promise";
2727
import { testExplorerExtensionId, TestHub } from "vscode-test-adapter-api";
28-
import { parse, lt } from "semver";
28+
import { lt, parse } from "semver";
2929

3030
import { AstViewer } from "./astViewer";
3131
import {
@@ -47,10 +47,10 @@ import { install } from "./languageSupport";
4747
import { DatabaseItem, DatabaseManager } from "./databases";
4848
import { DatabaseUI } from "./databases-ui";
4949
import {
50-
TemplateQueryDefinitionProvider,
51-
TemplateQueryReferenceProvider,
5250
TemplatePrintAstProvider,
5351
TemplatePrintCfgProvider,
52+
TemplateQueryDefinitionProvider,
53+
TemplateQueryReferenceProvider,
5454
} from "./contextual/templateProvider";
5555
import {
5656
DEFAULT_DISTRIBUTION_VERSION_RANGE,
@@ -64,22 +64,22 @@ import {
6464
} from "./distribution";
6565
import {
6666
findLanguage,
67-
tmpDirDisposal,
68-
showBinaryChoiceDialog,
6967
showAndLogErrorMessage,
70-
showAndLogWarningMessage,
68+
showAndLogExceptionWithTelemetry,
7169
showAndLogInformationMessage,
70+
showAndLogWarningMessage,
71+
showBinaryChoiceDialog,
7272
showInformationMessageWithAction,
7373
tmpDir,
74-
showAndLogExceptionWithTelemetry,
74+
tmpDirDisposal,
7575
} from "./helpers";
7676
import { asError, assertNever, getErrorMessage } from "./pure/helpers-pure";
7777
import { spawnIdeServer } from "./ide-server";
7878
import { ResultsView } from "./interface";
7979
import { WebviewReveal } from "./interface-utils";
8080
import {
81-
ideServerLogger,
8281
extLogger,
82+
ideServerLogger,
8383
ProgressReporter,
8484
queryServerLogger,
8585
} from "./common";
@@ -97,25 +97,22 @@ import {
9797
commandRunner,
9898
commandRunnerWithProgress,
9999
ProgressCallback,
100-
withProgress,
101100
ProgressUpdate,
101+
withProgress,
102102
} from "./commandRunner";
103103
import { CodeQlStatusBarHandler } from "./status-bar";
104104

105105
import { RemoteQueriesManager } from "./remote-queries/remote-queries-manager";
106-
import { RemoteQueryResult } from "./remote-queries/remote-query-result";
107106
import { URLSearchParams } from "url";
108107
import {
109108
handleDownloadPacks,
110109
handleInstallPackDependencies,
111110
} from "./packaging";
112111
import { HistoryItemLabelProvider } from "./query-history/history-item-label-provider";
113112
import {
114-
exportRemoteQueryResults,
115113
exportSelectedRemoteQueryResults,
116114
exportVariantAnalysisResults,
117115
} from "./remote-queries/export-results";
118-
import { RemoteQuery } from "./remote-queries/remote-query";
119116
import { EvalLogViewer } from "./eval-log-viewer";
120117
import { SummaryLanguageSupport } from "./log-insights/summary-language-support";
121118
import { JoinOrderScannerProvider } from "./log-insights/join-order";
@@ -1129,21 +1126,6 @@ async function activateWithInstalledDistribution(
11291126
),
11301127
);
11311128

1132-
ctx.subscriptions.push(
1133-
commandRunner(
1134-
"codeQL.monitorRemoteQuery",
1135-
async (queryId: string, query: RemoteQuery, token: CancellationToken) => {
1136-
await rqm.monitorRemoteQuery(queryId, query, token);
1137-
},
1138-
),
1139-
);
1140-
1141-
ctx.subscriptions.push(
1142-
commandRunner("codeQL.copyRepoList", async (queryId: string) => {
1143-
await rqm.copyRemoteQueryRepoListToClipboard(queryId);
1144-
}),
1145-
);
1146-
11471129
ctx.subscriptions.push(
11481130
commandRunner(
11491131
"codeQL.openVariantAnalysisLogs",
@@ -1206,30 +1188,12 @@ async function activateWithInstalledDistribution(
12061188
),
12071189
);
12081190

1209-
ctx.subscriptions.push(
1210-
commandRunner(
1211-
"codeQL.autoDownloadRemoteQueryResults",
1212-
async (queryResult: RemoteQueryResult, token: CancellationToken) => {
1213-
await rqm.autoDownloadRemoteQueryResults(queryResult, token);
1214-
},
1215-
),
1216-
);
1217-
12181191
ctx.subscriptions.push(
12191192
commandRunner("codeQL.exportSelectedVariantAnalysisResults", async () => {
12201193
await exportSelectedRemoteQueryResults(qhm);
12211194
}),
12221195
);
12231196

1224-
ctx.subscriptions.push(
1225-
commandRunner(
1226-
"codeQL.exportRemoteQueryResults",
1227-
async (queryId: string) => {
1228-
await exportRemoteQueryResults(qhm, rqm, queryId, app.credentials);
1229-
},
1230-
),
1231-
);
1232-
12331197
ctx.subscriptions.push(
12341198
commandRunnerWithProgress(
12351199
"codeQL.exportVariantAnalysisResults",

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

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -539,11 +539,7 @@ export class QueryHistoryManager extends DisposableObject {
539539
await Promise.all(
540540
this.treeDataProvider.allHistory.map(async (item) => {
541541
if (item.t === "remote") {
542-
await this.remoteQueriesManager.rehydrateRemoteQuery(
543-
item.queryId,
544-
item.remoteQuery,
545-
item.status,
546-
);
542+
await this.remoteQueriesManager.rehydrateRemoteQuery(item.queryId);
547543
}
548544
if (item.t === "variant-analysis") {
549545
await this.variantAnalysisManager.rehydrateVariantAnalysis(
@@ -1293,12 +1289,7 @@ export class QueryHistoryManager extends DisposableObject {
12931289
return;
12941290
}
12951291

1296-
if (finalSingleItem.t === "remote") {
1297-
await commands.executeCommand(
1298-
"codeQL.copyRepoList",
1299-
finalSingleItem.queryId,
1300-
);
1301-
} else if (finalSingleItem.t === "variant-analysis") {
1292+
if (finalSingleItem.t === "variant-analysis") {
13021293
await commands.executeCommand(
13031294
"codeQL.copyVariantAnalysisRepoList",
13041295
finalSingleItem.variantAnalysis.id,
@@ -1321,10 +1312,7 @@ export class QueryHistoryManager extends DisposableObject {
13211312

13221313
// Remote queries and variant analysis only
13231314
if (finalSingleItem.t === "remote") {
1324-
await commands.executeCommand(
1325-
"codeQL.exportRemoteQueryResults",
1326-
finalSingleItem.queryId,
1327-
);
1315+
// Do nothing. TODO: Remove this case once remote queries are removed.
13281316
} else if (finalSingleItem.t === "variant-analysis") {
13291317
await commands.executeCommand(
13301318
"codeQL.exportVariantAnalysisResults",

extensions/ql-vscode/src/remote-queries/export-results.ts

Lines changed: 2 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { join } from "path";
22
import { ensureDir, writeFile } from "fs-extra";
33

44
import {
5-
commands,
65
CancellationToken,
6+
commands,
77
Uri,
88
ViewColumn,
99
window,
@@ -14,15 +14,11 @@ import { showInformationMessageWithAction } from "../helpers";
1414
import { extLogger } from "../common";
1515
import { QueryHistoryManager } from "../query-history/query-history-manager";
1616
import { createGist } from "./gh-api/gh-api-client";
17-
import { RemoteQueriesManager } from "./remote-queries-manager";
1817
import {
19-
generateMarkdown,
2018
generateVariantAnalysisMarkdown,
2119
MarkdownFile,
2220
RepositorySummary,
2321
} from "./remote-queries-markdown-generation";
24-
import { RemoteQuery } from "./remote-query";
25-
import { AnalysisResults, sumAnalysesResults } from "./shared/analysis-result";
2622
import { pluralize } from "../pure/word";
2723
import { VariantAnalysisManager } from "./variant-analysis-manager";
2824
import { assertNever } from "../pure/helpers-pure";
@@ -52,10 +48,7 @@ export async function exportSelectedRemoteQueryResults(
5248
}
5349

5450
if (queryHistoryItem.t === "remote") {
55-
return commands.executeCommand(
56-
"codeQL.exportRemoteQueryResults",
57-
queryHistoryItem.queryId,
58-
);
51+
// Do nothing. TODO: Remove this branch once we stop supporting remote queries.
5952
} else if (queryHistoryItem.t === "variant-analysis") {
6053
return commands.executeCommand(
6154
"codeQL.exportVariantAnalysisResults",
@@ -66,73 +59,6 @@ export async function exportSelectedRemoteQueryResults(
6659
}
6760
}
6861

69-
/**
70-
* Exports the results of the given remote query.
71-
* The user is prompted to select the export format.
72-
*/
73-
export async function exportRemoteQueryResults(
74-
queryHistoryManager: QueryHistoryManager,
75-
remoteQueriesManager: RemoteQueriesManager,
76-
queryId: string,
77-
credentials: Credentials,
78-
): Promise<void> {
79-
const queryHistoryItem = queryHistoryManager.getRemoteQueryById(queryId);
80-
if (!queryHistoryItem) {
81-
void extLogger.log(`Could not find query with id ${queryId}`);
82-
throw new Error(
83-
"There was an error when trying to retrieve variant analysis information",
84-
);
85-
}
86-
87-
if (!queryHistoryItem.completed) {
88-
throw new Error("Variant analysis results are not yet available.");
89-
}
90-
91-
void extLogger.log(
92-
`Exporting variant analysis results for query: ${queryHistoryItem.queryId}`,
93-
);
94-
const query = queryHistoryItem.remoteQuery;
95-
const analysesResults = remoteQueriesManager.getAnalysesResults(
96-
queryHistoryItem.queryId,
97-
);
98-
99-
const exportFormat = await determineExportFormat();
100-
if (!exportFormat) {
101-
return;
102-
}
103-
104-
const exportDirectory =
105-
await queryHistoryManager.getQueryHistoryItemDirectory(queryHistoryItem);
106-
const exportedResultsDirectory = join(exportDirectory, "exported-results");
107-
108-
await exportRemoteQueryAnalysisResults(
109-
exportedResultsDirectory,
110-
query,
111-
analysesResults,
112-
exportFormat,
113-
credentials,
114-
);
115-
}
116-
117-
export async function exportRemoteQueryAnalysisResults(
118-
exportedResultsPath: string,
119-
query: RemoteQuery,
120-
analysesResults: AnalysisResults[],
121-
exportFormat: "gist" | "local",
122-
credentials: Credentials,
123-
) {
124-
const description = buildGistDescription(query, analysesResults);
125-
const markdownFiles = generateMarkdown(query, analysesResults, exportFormat);
126-
127-
await exportResults(
128-
exportedResultsPath,
129-
description,
130-
markdownFiles,
131-
exportFormat,
132-
credentials,
133-
);
134-
}
135-
13662
const MAX_VARIANT_ANALYSIS_EXPORT_PROGRESS_STEPS = 2;
13763

13864
/**
@@ -396,22 +322,6 @@ export async function exportToGist(
396322
}
397323
}
398324

399-
/**
400-
* Builds Gist description
401-
* Ex: Empty Block (Go) x results (y repositories)
402-
*/
403-
const buildGistDescription = (
404-
query: RemoteQuery,
405-
analysesResults: AnalysisResults[],
406-
) => {
407-
const resultCount = sumAnalysesResults(analysesResults);
408-
const resultLabel = pluralize(resultCount, "result", "results");
409-
const repositoryLabel = query.repositoryCount
410-
? `(${pluralize(query.repositoryCount, "repository", "repositories")})`
411-
: "";
412-
return `${query.queryName} (${query.language}) ${resultLabel} ${repositoryLabel}`;
413-
};
414-
415325
/**
416326
* Builds Gist description
417327
* Ex: Empty Block (Go) x results (y repositories)

0 commit comments

Comments
 (0)