Skip to content

Commit feac82f

Browse files
authored
Merge pull request #2084 from github/koesie10/remove-remote-queries
Remove remaining remote queries code
2 parents 2c81d3c + 6ff8aad commit feac82f

File tree

13 files changed

+43
-455
lines changed

13 files changed

+43
-455
lines changed

extensions/ql-vscode/src/extension.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
languages,
1111
ProgressLocation,
1212
ProgressOptions,
13-
ProviderResult,
1413
QuickPickItem,
1514
Range,
1615
Uri,
@@ -101,14 +100,13 @@ import {
101100
withProgress,
102101
} from "./commandRunner";
103102
import { CodeQlStatusBarHandler } from "./status-bar";
104-
import { URLSearchParams } from "url";
105103
import {
106104
handleDownloadPacks,
107105
handleInstallPackDependencies,
108106
} from "./packaging";
109107
import { HistoryItemLabelProvider } from "./query-history/history-item-label-provider";
110108
import {
111-
exportSelectedRemoteQueryResults,
109+
exportSelectedVariantAnalysisResults,
112110
exportVariantAnalysisResults,
113111
} from "./remote-queries/export-results";
114112
import { EvalLogViewer } from "./eval-log-viewer";
@@ -1077,8 +1075,6 @@ async function activateWithInstalledDistribution(
10771075
),
10781076
);
10791077

1080-
registerRemoteQueryTextProvider();
1081-
10821078
// The "runVariantAnalysis" command is internal-only.
10831079
ctx.subscriptions.push(
10841080
commandRunnerWithProgress(
@@ -1177,7 +1173,7 @@ async function activateWithInstalledDistribution(
11771173

11781174
ctx.subscriptions.push(
11791175
commandRunner("codeQL.exportSelectedVariantAnalysisResults", async () => {
1180-
await exportSelectedRemoteQueryResults(qhm);
1176+
await exportSelectedVariantAnalysisResults(qhm);
11811177
}),
11821178
);
11831179

@@ -1613,21 +1609,6 @@ async function initializeLogging(ctx: ExtensionContext): Promise<void> {
16131609

16141610
const checkForUpdatesCommand = "codeQL.checkForUpdatesToCLI";
16151611

1616-
/**
1617-
* This text provider lets us open readonly files in the editor.
1618-
*
1619-
* TODO: Consolidate this with the 'codeql' text provider in query-history-manager.ts.
1620-
*/
1621-
function registerRemoteQueryTextProvider() {
1622-
workspace.registerTextDocumentContentProvider("remote-query", {
1623-
provideTextDocumentContent(uri: Uri): ProviderResult<string> {
1624-
const params = new URLSearchParams(uri.query);
1625-
1626-
return params.get("queryText");
1627-
},
1628-
});
1629-
}
1630-
16311612
const avoidVersionCheck = "avoid-version-check-at-startup";
16321613
const lastVersionChecked = "last-version-checked";
16331614
async function assertVSCodeVersionGreaterThan(

extensions/ql-vscode/src/pure/interface-types.ts

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
import * as sarif from "sarif";
2-
import { AnalysisResults } from "../remote-queries/shared/analysis-result";
3-
import {
4-
AnalysisSummary,
5-
RemoteQueryResult,
6-
} from "../remote-queries/shared/remote-query-result";
72
import {
83
RawResultSet,
94
ResultRow,
@@ -58,13 +53,6 @@ export interface QueryMetadata {
5853
scored?: string;
5954
}
6055

61-
export interface PreviousExecution {
62-
queryName: string;
63-
time: string;
64-
databaseName: string;
65-
durationSeconds: number;
66-
}
67-
6856
export type SarifInterpretationData = {
6957
t: "SarifInterpretationData";
7058
/**
@@ -222,11 +210,6 @@ export interface OpenFileMsg {
222210
filePath: string;
223211
}
224212

225-
export interface OpenVirtualFileMsg {
226-
t: "openVirtualFile";
227-
queryText: string;
228-
}
229-
230213
/**
231214
* Message from the results view to toggle the display of
232215
* query diagnostics.
@@ -353,12 +336,6 @@ export interface SetComparisonsMessage {
353336
readonly databaseUri: string;
354337
}
355338

356-
export enum DiffKind {
357-
Add = "Add",
358-
Remove = "Remove",
359-
Change = "Change",
360-
}
361-
362339
/**
363340
* from is the set of rows that have changes in the "from" query.
364341
* to is the set of rows that have changes in the "to" query.
@@ -407,56 +384,6 @@ export interface ParsedResultSets {
407384
resultSet: ResultSet;
408385
}
409386

410-
export type FromRemoteQueriesMessage =
411-
| ViewLoadedMsg
412-
| RemoteQueryErrorMessage
413-
| OpenFileMsg
414-
| OpenVirtualFileMsg
415-
| RemoteQueryDownloadAnalysisResultsMessage
416-
| RemoteQueryDownloadAllAnalysesResultsMessage
417-
| RemoteQueryExportResultsMessage
418-
| CopyRepoListMessage
419-
| TelemetryMessage;
420-
421-
export type ToRemoteQueriesMessage =
422-
| SetRemoteQueryResultMessage
423-
| SetAnalysesResultsMessage;
424-
425-
export interface SetRemoteQueryResultMessage {
426-
t: "setRemoteQueryResult";
427-
queryResult: RemoteQueryResult;
428-
}
429-
430-
export interface SetAnalysesResultsMessage {
431-
t: "setAnalysesResults";
432-
analysesResults: AnalysisResults[];
433-
}
434-
435-
export interface RemoteQueryErrorMessage {
436-
t: "remoteQueryError";
437-
error: string;
438-
}
439-
440-
export interface RemoteQueryDownloadAnalysisResultsMessage {
441-
t: "remoteQueryDownloadAnalysisResults";
442-
analysisSummary: AnalysisSummary;
443-
}
444-
445-
export interface RemoteQueryDownloadAllAnalysesResultsMessage {
446-
t: "remoteQueryDownloadAllAnalysesResults";
447-
analysisSummaries: AnalysisSummary[];
448-
}
449-
450-
export interface RemoteQueryExportResultsMessage {
451-
t: "remoteQueryExportResults";
452-
queryId: string;
453-
}
454-
455-
export interface CopyRepoListMessage {
456-
t: "copyRepoList";
457-
queryId: string;
458-
}
459-
460387
export interface SetVariantAnalysisMessage {
461388
t: "setVariantAnalysis";
462389
variantAnalysis: VariantAnalysis;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function getRawQueryName(item: QueryHistoryInfo): string {
2222

2323
/**
2424
* Gets an identifier for the query history item which could be
25-
* a local/remote query or a variant analysis. This id isn't guaranteed
25+
* a local query or a variant analysis. This id isn't guaranteed
2626
* to be unique for each item in the query history.
2727
* @param item the history item.
2828
* @returns the id of the query or variant analysis.

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

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -755,14 +755,12 @@ export class QueryHistoryManager extends DisposableObject {
755755
) {
756756
// show original query file on double click
757757
await this.handleOpenQuery(finalSingleItem, [finalSingleItem]);
758-
} else {
758+
} else if (
759+
finalSingleItem.t === "variant-analysis" ||
760+
finalSingleItem.status === QueryStatus.Completed
761+
) {
759762
// show results on single click (if results view is available)
760-
if (
761-
finalSingleItem.t === "variant-analysis" ||
762-
finalSingleItem.status === QueryStatus.Completed
763-
) {
764-
await this.openQueryResults(finalSingleItem);
765-
}
763+
await this.openQueryResults(finalSingleItem);
766764
}
767765
}
768766

@@ -797,6 +795,8 @@ export class QueryHistoryManager extends DisposableObject {
797795
return this.variantAnalysisManager.getVariantAnalysisStorageLocation(
798796
queryHistoryItem.variantAnalysis.id,
799797
);
798+
} else {
799+
assertNever(queryHistoryItem);
800800
}
801801

802802
throw new Error("Unable to get query directory");
@@ -830,6 +830,8 @@ export class QueryHistoryManager extends DisposableObject {
830830
),
831831
"timestamp",
832832
);
833+
} else {
834+
assertNever(finalSingleItem);
833835
}
834836

835837
if (externalFilePath) {
@@ -994,6 +996,8 @@ export class QueryHistoryManager extends DisposableObject {
994996
"codeQL.cancelVariantAnalysis",
995997
item.variantAnalysis.id,
996998
);
999+
} else {
1000+
assertNever(item);
9971001
}
9981002
}
9991003
});
@@ -1185,17 +1189,19 @@ export class QueryHistoryManager extends DisposableObject {
11851189
multiSelect,
11861190
);
11871191

1188-
// Remote queries only
1189-
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
1192+
// Variant analyses only
1193+
if (
1194+
!this.assertSingleQuery(finalMultiSelect) ||
1195+
!finalSingleItem ||
1196+
finalSingleItem.t !== "variant-analysis"
1197+
) {
11901198
return;
11911199
}
11921200

1193-
if (finalSingleItem.t === "variant-analysis") {
1194-
await commands.executeCommand(
1195-
"codeQL.copyVariantAnalysisRepoList",
1196-
finalSingleItem.variantAnalysis.id,
1197-
);
1198-
}
1201+
await commands.executeCommand(
1202+
"codeQL.copyVariantAnalysisRepoList",
1203+
finalSingleItem.variantAnalysis.id,
1204+
);
11991205
}
12001206

12011207
async handleExportResults(
@@ -1207,17 +1213,19 @@ export class QueryHistoryManager extends DisposableObject {
12071213
multiSelect,
12081214
);
12091215

1210-
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
1216+
// Variant analysis only
1217+
if (
1218+
!this.assertSingleQuery(finalMultiSelect) ||
1219+
!finalSingleItem ||
1220+
finalSingleItem.t !== "variant-analysis"
1221+
) {
12111222
return;
12121223
}
12131224

1214-
// Variant analysis only
1215-
if (finalSingleItem.t === "variant-analysis") {
1216-
await commands.executeCommand(
1217-
"codeQL.exportVariantAnalysisResults",
1218-
finalSingleItem.variantAnalysis.id,
1219-
);
1220-
}
1225+
await commands.executeCommand(
1226+
"codeQL.exportVariantAnalysisResults",
1227+
finalSingleItem.variantAnalysis.id,
1228+
);
12211229
}
12221230

12231231
addQuery(item: QueryHistoryInfo) {
@@ -1290,7 +1298,7 @@ the file in the file explorer and dragging it into the workspace.`,
12901298
singleItem: QueryHistoryInfo,
12911299
multiSelect: QueryHistoryInfo[],
12921300
): Promise<CompletedLocalQueryInfo | undefined> {
1293-
// Remote queries cannot be compared
1301+
// Variant analyses cannot be compared
12941302
if (
12951303
singleItem.t !== "local" ||
12961304
multiSelect.some((s) => s.t !== "local") ||

extensions/ql-vscode/src/remote-queries/download-link.ts

Lines changed: 0 additions & 48 deletions
This file was deleted.

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
} from "./markdown-generation";
2222
import { pluralize } from "../pure/word";
2323
import { VariantAnalysisManager } from "./variant-analysis-manager";
24-
import { assertNever } from "../pure/helpers-pure";
2524
import {
2625
VariantAnalysis,
2726
VariantAnalysisScannedRepository,
@@ -35,32 +34,28 @@ import {
3534
import { Credentials } from "../common/authentication";
3635

3736
/**
38-
* Exports the results of the currently-selected remote query or variant analysis.
37+
* Exports the results of the currently-selected variant analysis.
3938
*/
40-
export async function exportSelectedRemoteQueryResults(
39+
export async function exportSelectedVariantAnalysisResults(
4140
queryHistoryManager: QueryHistoryManager,
4241
): Promise<void> {
4342
const queryHistoryItem = queryHistoryManager.getCurrentQueryHistoryItem();
44-
if (!queryHistoryItem || queryHistoryItem.t === "local") {
43+
if (!queryHistoryItem || queryHistoryItem.t !== "variant-analysis") {
4544
throw new Error(
4645
"No variant analysis results currently open. To open results, click an item in the query history view.",
4746
);
4847
}
4948

50-
if (queryHistoryItem.t === "variant-analysis") {
51-
return commands.executeCommand(
52-
"codeQL.exportVariantAnalysisResults",
53-
queryHistoryItem.variantAnalysis.id,
54-
);
55-
} else {
56-
assertNever(queryHistoryItem);
57-
}
49+
return commands.executeCommand(
50+
"codeQL.exportVariantAnalysisResults",
51+
queryHistoryItem.variantAnalysis.id,
52+
);
5853
}
5954

6055
const MAX_VARIANT_ANALYSIS_EXPORT_PROGRESS_STEPS = 2;
6156

6257
/**
63-
* Exports the results of the given or currently-selected remote query.
58+
* Exports the results of the given or currently-selected variant analysis.
6459
* The user is prompted to select the export format.
6560
*/
6661
export async function exportVariantAnalysisResults(

extensions/ql-vscode/src/remote-queries/repository.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

extensions/ql-vscode/src/remote-queries/shared/analysis-failure.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)