Skip to content

Commit c0c30b4

Browse files
committed
Merge remote-tracking branch 'upstream/main' into aeisenberg/run-with-all-data-extensions
2 parents 39e6b27 + 851a42f commit c0c30b4

87 files changed

Lines changed: 213 additions & 7871 deletions

File tree

Some content is hidden

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

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@
4848
"env": {
4949
"LANG": "en-US",
5050
"TZ": "UTC",
51+
52+
// Uncomment to set a custom path to a CodeQL checkout.
53+
// "TEST_CODEQL_PATH": "../codeql",
54+
55+
// Uncomment to set a custom path to a CodeQL CLI executable.
56+
// This is the CodeQL version that will be used in the tests.
57+
// "CLI_PATH": "/path/to/customg/codeql",
58+
5159
// Uncomment to debug integration tests
5260
// "VSCODE_WAIT_FOR_DEBUGGER": "true",
5361
}

extensions/ql-vscode/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@
377377
},
378378
{
379379
"command": "codeQLVariantAnalysisRepositories.openConfigFile",
380-
"title": "Open Database Configuration File",
380+
"title": "Open database configuration file",
381381
"icon": "$(json)"
382382
},
383383
{
@@ -476,7 +476,7 @@
476476
},
477477
{
478478
"command": "codeQLDatabases.setCurrentDatabase",
479-
"title": "Set Current Database"
479+
"title": "Select"
480480
},
481481
{
482482
"command": "codeQLDatabases.removeDatabase",

extensions/ql-vscode/src/databases/ui/db-panel.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ export class DbPanel extends DisposableObject {
254254
"Not a selectable database item. Please select a valid item.",
255255
);
256256
}
257+
258+
// Optimistically update the UI to select the item that the user
259+
// selected to avoid delay in the UI.
260+
this.dataProvider.updateSelectedItem(treeViewItem);
261+
257262
await this.dbManager.setSelectedDbItem(treeViewItem.dbItem);
258263
}
259264

extensions/ql-vscode/src/databases/ui/db-tree-data-provider.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,23 @@ export class DbTreeDataProvider
4848
});
4949
}
5050

51+
/**
52+
* Updates the selected item and re-renders the tree.
53+
* @param selectedItem The item to select.
54+
*/
55+
public updateSelectedItem(selectedItem: DbTreeViewItem): void {
56+
// Unselect all items
57+
for (const item of this.dbTreeItems) {
58+
item.setAsUnselected();
59+
}
60+
61+
// Select the new item
62+
selectedItem.setAsSelected();
63+
64+
// Re-render the tree
65+
this._onDidChangeTreeData.fire(undefined);
66+
}
67+
5168
/**
5269
* Called when expanding a node (including the root node).
5370
* @param node The node to expand.

extensions/ql-vscode/src/databases/ui/db-tree-view-item.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,19 @@ export class DbTreeViewItem extends vscode.TreeItem {
3636
if (dbItem) {
3737
this.contextValue = getContextValue(dbItem);
3838
if (isSelectableDbItem(dbItem) && dbItem.selected) {
39-
// Define the resource id to drive the UI to render this item as selected.
40-
this.resourceUri = vscode.Uri.parse(SELECTED_DB_ITEM_RESOURCE_URI);
39+
this.setAsSelected();
4140
}
4241
}
4342
}
43+
44+
public setAsSelected(): void {
45+
// Define the resource id to drive the UI to render this item as selected.
46+
this.resourceUri = vscode.Uri.parse(SELECTED_DB_ITEM_RESOURCE_URI);
47+
}
48+
49+
public setAsUnselected(): void {
50+
this.resourceUri = undefined;
51+
}
4452
}
4553

4654
function getContextValue(dbItem: DbItem): string | undefined {

extensions/ql-vscode/src/extension.ts

Lines changed: 21 additions & 80 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 {
@@ -38,7 +38,6 @@ import {
3838
CliConfigListener,
3939
DistributionConfigListener,
4040
isCanary,
41-
isVariantAnalysisLiveResultsEnabled,
4241
joinOrderWarningThreshold,
4342
MAX_QUERIES,
4443
QueryHistoryConfigListener,
@@ -48,10 +47,10 @@ import { install } from "./languageSupport";
4847
import { DatabaseItem, DatabaseManager } from "./databases";
4948
import { DatabaseUI } from "./databases-ui";
5049
import {
51-
TemplateQueryDefinitionProvider,
52-
TemplateQueryReferenceProvider,
5350
TemplatePrintAstProvider,
5451
TemplatePrintCfgProvider,
52+
TemplateQueryDefinitionProvider,
53+
TemplateQueryReferenceProvider,
5554
} from "./contextual/templateProvider";
5655
import {
5756
DEFAULT_DISTRIBUTION_VERSION_RANGE,
@@ -65,22 +64,22 @@ import {
6564
} from "./distribution";
6665
import {
6766
findLanguage,
68-
tmpDirDisposal,
69-
showBinaryChoiceDialog,
7067
showAndLogErrorMessage,
71-
showAndLogWarningMessage,
68+
showAndLogExceptionWithTelemetry,
7269
showAndLogInformationMessage,
70+
showAndLogWarningMessage,
71+
showBinaryChoiceDialog,
7372
showInformationMessageWithAction,
7473
tmpDir,
75-
showAndLogExceptionWithTelemetry,
74+
tmpDirDisposal,
7675
} from "./helpers";
7776
import { asError, assertNever, getErrorMessage } from "./pure/helpers-pure";
7877
import { spawnIdeServer } from "./ide-server";
7978
import { ResultsView } from "./interface";
8079
import { WebviewReveal } from "./interface-utils";
8180
import {
82-
ideServerLogger,
8381
extLogger,
82+
ideServerLogger,
8483
ProgressReporter,
8584
queryServerLogger,
8685
} from "./common";
@@ -98,25 +97,20 @@ import {
9897
commandRunner,
9998
commandRunnerWithProgress,
10099
ProgressCallback,
101-
withProgress,
102100
ProgressUpdate,
101+
withProgress,
103102
} from "./commandRunner";
104103
import { CodeQlStatusBarHandler } from "./status-bar";
105-
106-
import { RemoteQueriesManager } from "./remote-queries/remote-queries-manager";
107-
import { RemoteQueryResult } from "./remote-queries/remote-query-result";
108104
import { URLSearchParams } from "url";
109105
import {
110106
handleDownloadPacks,
111107
handleInstallPackDependencies,
112108
} from "./packaging";
113109
import { HistoryItemLabelProvider } from "./query-history/history-item-label-provider";
114110
import {
115-
exportRemoteQueryResults,
116111
exportSelectedRemoteQueryResults,
117112
exportVariantAnalysisResults,
118113
} from "./remote-queries/export-results";
119-
import { RemoteQuery } from "./remote-queries/remote-query";
120114
import { EvalLogViewer } from "./eval-log-viewer";
121115
import { SummaryLanguageSupport } from "./log-insights/summary-language-support";
122116
import { JoinOrderScannerProvider } from "./log-insights/join-order";
@@ -656,23 +650,11 @@ async function activateWithInstalledDistribution(
656650
),
657651
);
658652

659-
void extLogger.log("Initializing remote queries manager.");
660-
const rqm = new RemoteQueriesManager(
661-
ctx,
662-
app,
663-
cliServer,
664-
queryStorageDir,
665-
extLogger,
666-
);
667-
ctx.subscriptions.push(rqm);
668-
669653
void extLogger.log("Initializing query history.");
670654
const qhm = new QueryHistoryManager(
671-
app,
672655
qs,
673656
dbm,
674657
localQueryResultsView,
675-
rqm,
676658
variantAnalysisManager,
677659
evalLogViewer,
678660
queryStorageDir,
@@ -1112,19 +1094,11 @@ async function activateWithInstalledDistribution(
11121094
message: "Getting credentials",
11131095
});
11141096

1115-
if (isVariantAnalysisLiveResultsEnabled()) {
1116-
await variantAnalysisManager.runVariantAnalysis(
1117-
uri || window.activeTextEditor?.document.uri,
1118-
progress,
1119-
token,
1120-
);
1121-
} else {
1122-
await rqm.runRemoteQuery(
1123-
uri || window.activeTextEditor?.document.uri,
1124-
progress,
1125-
token,
1126-
);
1127-
}
1097+
await variantAnalysisManager.runVariantAnalysis(
1098+
uri || window.activeTextEditor?.document.uri,
1099+
progress,
1100+
token,
1101+
);
11281102
} else {
11291103
throw new Error(
11301104
"Variant analysis requires the CodeQL Canary version to run.",
@@ -1138,21 +1112,6 @@ async function activateWithInstalledDistribution(
11381112
),
11391113
);
11401114

1141-
ctx.subscriptions.push(
1142-
commandRunner(
1143-
"codeQL.monitorRemoteQuery",
1144-
async (queryId: string, query: RemoteQuery, token: CancellationToken) => {
1145-
await rqm.monitorRemoteQuery(queryId, query, token);
1146-
},
1147-
),
1148-
);
1149-
1150-
ctx.subscriptions.push(
1151-
commandRunner("codeQL.copyRepoList", async (queryId: string) => {
1152-
await rqm.copyRemoteQueryRepoListToClipboard(queryId);
1153-
}),
1154-
);
1155-
11561115
ctx.subscriptions.push(
11571116
commandRunner(
11581117
"codeQL.openVariantAnalysisLogs",
@@ -1215,30 +1174,12 @@ async function activateWithInstalledDistribution(
12151174
),
12161175
);
12171176

1218-
ctx.subscriptions.push(
1219-
commandRunner(
1220-
"codeQL.autoDownloadRemoteQueryResults",
1221-
async (queryResult: RemoteQueryResult, token: CancellationToken) => {
1222-
await rqm.autoDownloadRemoteQueryResults(queryResult, token);
1223-
},
1224-
),
1225-
);
1226-
12271177
ctx.subscriptions.push(
12281178
commandRunner("codeQL.exportSelectedVariantAnalysisResults", async () => {
12291179
await exportSelectedRemoteQueryResults(qhm);
12301180
}),
12311181
);
12321182

1233-
ctx.subscriptions.push(
1234-
commandRunner(
1235-
"codeQL.exportRemoteQueryResults",
1236-
async (queryId: string) => {
1237-
await exportRemoteQueryResults(qhm, rqm, queryId, app.credentials);
1238-
},
1239-
),
1240-
);
1241-
12421183
ctx.subscriptions.push(
12431184
commandRunnerWithProgress(
12441185
"codeQL.exportVariantAnalysisResults",

extensions/ql-vscode/src/query-history/history-item-label-provider.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
getRawQueryName,
88
QueryHistoryInfo,
99
} from "./query-history-info";
10-
import { RemoteQueryHistoryItem } from "../remote-queries/remote-query-history-item";
1110
import { VariantAnalysisHistoryItem } from "./variant-analysis-history-item";
1211
import { assertNever } from "../pure/helpers-pure";
1312
import { pluralize } from "../pure/word";
@@ -34,9 +33,6 @@ export class HistoryItemLabelProvider {
3433
case "local":
3534
replacements = this.getLocalInterpolateReplacements(item);
3635
break;
37-
case "remote":
38-
replacements = this.getRemoteInterpolateReplacements(item);
39-
break;
4036
case "variant-analysis":
4137
replacements = this.getVariantAnalysisInterpolateReplacements(item);
4238
break;
@@ -92,25 +88,6 @@ export class HistoryItemLabelProvider {
9288
};
9389
}
9490

95-
private getRemoteInterpolateReplacements(
96-
item: RemoteQueryHistoryItem,
97-
): InterpolateReplacements {
98-
const resultCount = item.resultCount
99-
? `(${pluralize(item.resultCount, "result", "results")})`
100-
: "";
101-
return {
102-
t: new Date(item.remoteQuery.executionStartTime).toLocaleString(
103-
env.language,
104-
),
105-
q: `${item.remoteQuery.queryName} (${item.remoteQuery.language})`,
106-
d: buildRepoLabel(item),
107-
r: resultCount,
108-
s: humanizeQueryStatus(item.status),
109-
f: basename(item.remoteQuery.queryFilePath),
110-
"%": "%",
111-
};
112-
}
113-
11491
private getVariantAnalysisInterpolateReplacements(
11592
item: VariantAnalysisHistoryItem,
11693
): InterpolateReplacements {

extensions/ql-vscode/src/query-history/history-tree-data-provider.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,6 @@ export class HistoryTreeDataProvider
236236
switch (item.t) {
237237
case "local":
238238
return item.initialInfo.start.getTime();
239-
case "remote":
240-
return item.remoteQuery.executionStartTime;
241239
case "variant-analysis":
242240
return item.variantAnalysis.executionStartTime;
243241
default:

0 commit comments

Comments
 (0)