Skip to content

Commit 547e18b

Browse files
committed
Merge remote-tracking branch 'origin/main' into koesie10/remove-remote-queries-react
2 parents c0ffd79 + 7d7a706 commit 547e18b

File tree

60 files changed

+26
-6736
lines changed

Some content is hidden

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

60 files changed

+26
-6736
lines changed

extensions/ql-vscode/src/extension.ts

Lines changed: 16 additions & 65 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,20 @@ import {
9797
commandRunner,
9898
commandRunnerWithProgress,
9999
ProgressCallback,
100-
withProgress,
101100
ProgressUpdate,
101+
withProgress,
102102
} from "./commandRunner";
103103
import { CodeQlStatusBarHandler } from "./status-bar";
104-
105-
import { RemoteQueriesManager } from "./remote-queries/remote-queries-manager";
106-
import { RemoteQueryResult } from "./remote-queries/remote-query-result";
107104
import { URLSearchParams } from "url";
108105
import {
109106
handleDownloadPacks,
110107
handleInstallPackDependencies,
111108
} from "./packaging";
112109
import { HistoryItemLabelProvider } from "./query-history/history-item-label-provider";
113110
import {
114-
exportRemoteQueryResults,
115111
exportSelectedRemoteQueryResults,
116112
exportVariantAnalysisResults,
117113
} from "./remote-queries/export-results";
118-
import { RemoteQuery } from "./remote-queries/remote-query";
119114
import { EvalLogViewer } from "./eval-log-viewer";
120115
import { SummaryLanguageSupport } from "./log-insights/summary-language-support";
121116
import { JoinOrderScannerProvider } from "./log-insights/join-order";
@@ -655,23 +650,12 @@ async function activateWithInstalledDistribution(
655650
),
656651
);
657652

658-
void extLogger.log("Initializing remote queries manager.");
659-
const rqm = new RemoteQueriesManager(
660-
ctx,
661-
app,
662-
cliServer,
663-
queryStorageDir,
664-
extLogger,
665-
);
666-
ctx.subscriptions.push(rqm);
667-
668653
void extLogger.log("Initializing query history.");
669654
const qhm = new QueryHistoryManager(
670655
app,
671656
qs,
672657
dbm,
673658
localQueryResultsView,
674-
rqm,
675659
variantAnalysisManager,
676660
evalLogViewer,
677661
queryStorageDir,
@@ -1129,21 +1113,6 @@ async function activateWithInstalledDistribution(
11291113
),
11301114
);
11311115

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-
11471116
ctx.subscriptions.push(
11481117
commandRunner(
11491118
"codeQL.openVariantAnalysisLogs",
@@ -1206,30 +1175,12 @@ async function activateWithInstalledDistribution(
12061175
),
12071176
);
12081177

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-
12181178
ctx.subscriptions.push(
12191179
commandRunner("codeQL.exportSelectedVariantAnalysisResults", async () => {
12201180
await exportSelectedRemoteQueryResults(qhm);
12211181
}),
12221182
);
12231183

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-
12331184
ctx.subscriptions.push(
12341185
commandRunnerWithProgress(
12351186
"codeQL.exportVariantAnalysisResults",

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

Lines changed: 6 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ import { pathExists } from "fs-extra";
5454
import { CliVersionConstraint } from "../cli";
5555
import { HistoryItemLabelProvider } from "./history-item-label-provider";
5656
import { cancelRemoteQuery } from "../remote-queries/gh-api/gh-actions-api-client";
57-
import { RemoteQueriesManager } from "../remote-queries/remote-queries-manager";
5857
import { RemoteQueryHistoryItem } from "../remote-queries/remote-query-history-item";
5958
import { ResultsView } from "../interface";
6059
import { WebviewReveal } from "../interface-utils";
@@ -142,7 +141,6 @@ export class QueryHistoryManager extends DisposableObject {
142141
private readonly qs: QueryRunner,
143142
private readonly dbm: DatabaseManager,
144143
private readonly localQueriesResultsView: ResultsView,
145-
private readonly remoteQueriesManager: RemoteQueriesManager,
146144
private readonly variantAnalysisManager: VariantAnalysisManager,
147145
private readonly evalLogViewer: EvalLogViewer,
148146
private readonly queryStorageDir: string,
@@ -372,7 +370,6 @@ export class QueryHistoryManager extends DisposableObject {
372370
);
373371

374372
this.registerQueryHistoryScrubber(queryHistoryConfigListener, this, ctx);
375-
this.registerToRemoteQueriesEvents();
376373
this.registerToVariantAnalysisEvents();
377374
}
378375

@@ -477,57 +474,6 @@ export class QueryHistoryManager extends DisposableObject {
477474
this.push(variantAnalysisRemovedSubscription);
478475
}
479476

480-
private registerToRemoteQueriesEvents() {
481-
const queryAddedSubscription = this.remoteQueriesManager.onRemoteQueryAdded(
482-
async (event) => {
483-
this.addQuery({
484-
t: "remote",
485-
status: QueryStatus.InProgress,
486-
completed: false,
487-
queryId: event.queryId,
488-
remoteQuery: event.query,
489-
});
490-
491-
await this.refreshTreeView();
492-
},
493-
);
494-
495-
const queryRemovedSubscription =
496-
this.remoteQueriesManager.onRemoteQueryRemoved(async (event) => {
497-
const item = this.treeDataProvider.allHistory.find(
498-
(i) => i.t === "remote" && i.queryId === event.queryId,
499-
);
500-
if (item) {
501-
await this.removeRemoteQuery(item as RemoteQueryHistoryItem);
502-
}
503-
});
504-
505-
const queryStatusUpdateSubscription =
506-
this.remoteQueriesManager.onRemoteQueryStatusUpdate(async (event) => {
507-
const item = this.treeDataProvider.allHistory.find(
508-
(i) => i.t === "remote" && i.queryId === event.queryId,
509-
);
510-
if (item) {
511-
const remoteQueryHistoryItem = item as RemoteQueryHistoryItem;
512-
remoteQueryHistoryItem.status = event.status;
513-
remoteQueryHistoryItem.failureReason = event.failureReason;
514-
remoteQueryHistoryItem.resultCount = event.resultCount;
515-
if (event.status === QueryStatus.Completed) {
516-
remoteQueryHistoryItem.completed = true;
517-
}
518-
await this.refreshTreeView();
519-
} else {
520-
void extLogger.log(
521-
"Variant analysis status update event received for unknown variant analysis",
522-
);
523-
}
524-
});
525-
526-
this.push(queryAddedSubscription);
527-
this.push(queryRemovedSubscription);
528-
this.push(queryStatusUpdateSubscription);
529-
}
530-
531477
async readQueryHistory(): Promise<void> {
532478
void extLogger.log(
533479
`Reading cached query history from '${this.queryMetadataStorageLocation}'.`,
@@ -538,13 +484,6 @@ export class QueryHistoryManager extends DisposableObject {
538484
this.treeDataProvider.allHistory = history;
539485
await Promise.all(
540486
this.treeDataProvider.allHistory.map(async (item) => {
541-
if (item.t === "remote") {
542-
await this.remoteQueriesManager.rehydrateRemoteQuery(
543-
item.queryId,
544-
item.remoteQuery,
545-
item.status,
546-
);
547-
}
548487
if (item.t === "variant-analysis") {
549488
await this.variantAnalysisManager.rehydrateVariantAnalysis(
550489
item.variantAnalysis,
@@ -657,7 +596,7 @@ export class QueryHistoryManager extends DisposableObject {
657596
await item.completedQuery?.query.deleteQuery();
658597
}
659598
} else if (item.t === "remote") {
660-
await this.removeRemoteQuery(item);
599+
// Do nothing. TODO: Remove once remote queries are no longer supported.
661600
} else if (item.t === "variant-analysis") {
662601
await this.removeVariantAnalysis(item);
663602
} else {
@@ -674,20 +613,6 @@ export class QueryHistoryManager extends DisposableObject {
674613
}
675614
}
676615

677-
private async removeRemoteQuery(item: RemoteQueryHistoryItem): Promise<void> {
678-
// Remote queries can be removed locally, but not remotely.
679-
// The user must cancel the query on GitHub Actions explicitly.
680-
this.treeDataProvider.remove(item);
681-
void extLogger.log(`Deleted ${this.labelProvider.getLabel(item)}.`);
682-
if (item.status === QueryStatus.InProgress) {
683-
void extLogger.log(
684-
"The variant analysis is still running on GitHub Actions. To cancel there, you must go to the workflow run in your browser.",
685-
);
686-
}
687-
688-
await this.remoteQueriesManager.removeRemoteQuery(item.queryId);
689-
}
690-
691616
private async removeVariantAnalysis(
692617
item: VariantAnalysisHistoryItem,
693618
): Promise<void> {
@@ -1293,12 +1218,7 @@ export class QueryHistoryManager extends DisposableObject {
12931218
return;
12941219
}
12951220

1296-
if (finalSingleItem.t === "remote") {
1297-
await commands.executeCommand(
1298-
"codeQL.copyRepoList",
1299-
finalSingleItem.queryId,
1300-
);
1301-
} else if (finalSingleItem.t === "variant-analysis") {
1221+
if (finalSingleItem.t === "variant-analysis") {
13021222
await commands.executeCommand(
13031223
"codeQL.copyVariantAnalysisRepoList",
13041224
finalSingleItem.variantAnalysis.id,
@@ -1321,10 +1241,7 @@ export class QueryHistoryManager extends DisposableObject {
13211241

13221242
// Remote queries and variant analysis only
13231243
if (finalSingleItem.t === "remote") {
1324-
await commands.executeCommand(
1325-
"codeQL.exportRemoteQueryResults",
1326-
finalSingleItem.queryId,
1327-
);
1244+
// Do nothing. TODO: Remove this case once remote queries are removed.
13281245
} else if (finalSingleItem.t === "variant-analysis") {
13291246
await commands.executeCommand(
13301247
"codeQL.exportVariantAnalysisResults",
@@ -1559,9 +1476,11 @@ the file in the file explorer and dragging it into the workspace.`,
15591476
false,
15601477
);
15611478
} else if (item.t === "remote") {
1562-
await this.remoteQueriesManager.openRemoteQueryResults(item.queryId);
1479+
// Do nothing. TODO: Remove when remote queries is no longer supported.
15631480
} else if (item.t === "variant-analysis") {
15641481
await this.variantAnalysisManager.showView(item.variantAnalysis.id);
1482+
} else {
1483+
assertNever(item);
15651484
}
15661485
}
15671486
}

0 commit comments

Comments
 (0)