Skip to content

Commit 2d8c690

Browse files
authored
Merge branch 'main' into simpler-location-url
2 parents 788eb2b + e9552df commit 2d8c690

File tree

20 files changed

+389
-33
lines changed

20 files changed

+389
-33
lines changed

extensions/ql-vscode/package.json

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"activationEvents": [
3737
"onLanguage:ql",
3838
"onLanguage:ql-summary",
39+
"onView:codeQLQueries",
3940
"onView:codeQLDatabases",
4041
"onView:codeQLVariantAnalysisRepositories",
4142
"onView:codeQLQueryHistory",
@@ -476,6 +477,14 @@
476477
"command": "codeQL.previewQueryHelp",
477478
"title": "CodeQL: Preview Query Help"
478479
},
480+
{
481+
"command": "codeQL.previewQueryHelpContextExplorer",
482+
"title": "CodeQL: Preview Query Help"
483+
},
484+
{
485+
"command": "codeQL.previewQueryHelpContextEditor",
486+
"title": "CodeQL: Preview Query Help"
487+
},
479488
{
480489
"command": "codeQL.quickQuery",
481490
"title": "CodeQL: Quick Query"
@@ -828,6 +837,11 @@
828837
"title": "CodeQL: Go to QL Code",
829838
"enablement": "codeql.hasQLSource"
830839
},
840+
{
841+
"command": "codeQL.gotoQLContextEditor",
842+
"title": "CodeQL: Go to QL Code",
843+
"enablement": "codeql.hasQLSource"
844+
},
831845
{
832846
"command": "codeQL.openDataExtensionsEditor",
833847
"title": "CodeQL: Open Data Extensions Editor"
@@ -1117,7 +1131,7 @@
11171131
"when": "resourceExtname == .qlref"
11181132
},
11191133
{
1120-
"command": "codeQL.previewQueryHelp",
1134+
"command": "codeQL.previewQueryHelpContextExplorer",
11211135
"group": "9_qlCommands",
11221136
"when": "resourceExtname == .qhelp && isWorkspaceTrusted"
11231137
}
@@ -1203,6 +1217,14 @@
12031217
"command": "codeQL.previewQueryHelp",
12041218
"when": "resourceExtname == .qhelp && isWorkspaceTrusted"
12051219
},
1220+
{
1221+
"command": "codeQL.previewQueryHelpContextEditor",
1222+
"when": "false"
1223+
},
1224+
{
1225+
"command": "codeQL.previewQueryHelpContextExplorer",
1226+
"when": "false"
1227+
},
12061228
{
12071229
"command": "codeQL.setCurrentDatabase",
12081230
"when": "false"
@@ -1466,6 +1488,10 @@
14661488
{
14671489
"command": "codeQLTests.acceptOutputContextTestItem",
14681490
"when": "false"
1491+
},
1492+
{
1493+
"command": "codeQL.gotoQLContextEditor",
1494+
"when": "false"
14691495
}
14701496
],
14711497
"editor/context": [
@@ -1510,11 +1536,11 @@
15101536
"when": "resourceExtname == .qlref"
15111537
},
15121538
{
1513-
"command": "codeQL.previewQueryHelp",
1539+
"command": "codeQL.previewQueryHelpContextEditor",
15141540
"when": "resourceExtname == .qhelp && isWorkspaceTrusted"
15151541
},
15161542
{
1517-
"command": "codeQL.gotoQL",
1543+
"command": "codeQL.gotoQLContextEditor",
15181544
"when": "editorLangId == ql-summary && config.codeQL.canary"
15191545
}
15201546
]
@@ -1530,6 +1556,11 @@
15301556
},
15311557
"views": {
15321558
"ql-container": [
1559+
{
1560+
"id": "codeQLQueries",
1561+
"name": "Queries",
1562+
"when": "config.codeQL.canary && config.codeQL.queriesPanel"
1563+
},
15331564
{
15341565
"id": "codeQLDatabases",
15351566
"name": "Databases"

extensions/ql-vscode/src/codeql-cli/cli.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,10 +1525,23 @@ export function spawnServer(
15251525
);
15261526
}
15271527

1528+
let lastStdout: any = undefined;
1529+
child.stdout!.on("data", (data) => {
1530+
lastStdout = data;
1531+
});
15281532
// Set up event listeners.
1529-
child.on("close", (code) =>
1530-
logger.log(`Child process exited with code ${code}`),
1531-
);
1533+
child.on("close", async (code, signal) => {
1534+
if (code !== null)
1535+
void logger.log(`Child process exited with code ${code}`);
1536+
if (signal)
1537+
void logger.log(
1538+
`Child process exited due to receipt of signal ${signal}`,
1539+
);
1540+
// If the process exited abnormally, log the last stdout message,
1541+
// It may be from the jvm.
1542+
if (code !== 0 && lastStdout !== undefined)
1543+
void logger.log(`Last stdout was "${lastStdout.toString()}"`);
1544+
});
15321545
child.stderr!.on("data", stderrListener);
15331546
if (stdoutListener !== undefined) {
15341547
child.stdout!.on("data", stdoutListener);

extensions/ql-vscode/src/codeql-cli/distribution.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { pathExists, mkdtemp, createWriteStream, remove } from "fs-extra";
33
import { tmpdir } from "os";
44
import { delimiter, dirname, join } from "path";
55
import * as semver from "semver";
6-
import { parse } from "url";
6+
import { URL } from "url";
77
import { ExtensionContext, Event } from "vscode";
88
import { DistributionConfig } from "../config";
99
import {
@@ -505,7 +505,7 @@ class ExtensionSpecificDistributionManager {
505505
0,
506506
) || "";
507507
return join(
508-
this.extensionContext.globalStoragePath,
508+
this.extensionContext.globalStorageUri.fsPath,
509509
ExtensionSpecificDistributionManager._currentDistributionFolderBaseName +
510510
distributionFolderIndex,
511511
);
@@ -670,7 +670,7 @@ export class ReleasesApiConsumer {
670670
redirectUrl &&
671671
redirectCount < ReleasesApiConsumer._maxRedirects
672672
) {
673-
const parsedRedirectUrl = parse(redirectUrl);
673+
const parsedRedirectUrl = new URL(redirectUrl);
674674
if (parsedRedirectUrl.protocol !== "https:") {
675675
throw new Error("Encountered a non-https redirect, rejecting");
676676
}

extensions/ql-vscode/src/common/commands.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ export type QueryEditorCommands = {
115115
selectedQuery: Uri,
116116
) => Promise<void>;
117117
"codeQL.previewQueryHelp": (selectedQuery: Uri) => Promise<void>;
118+
"codeQL.previewQueryHelpContextEditor": (selectedQuery: Uri) => Promise<void>;
119+
"codeQL.previewQueryHelpContextExplorer": (
120+
selectedQuery: Uri,
121+
) => Promise<void>;
118122
};
119123

120124
// Commands used for running local queries
@@ -299,6 +303,7 @@ export type EvalLogViewerCommands = {
299303

300304
export type SummaryLanguageSupportCommands = {
301305
"codeQL.gotoQL": () => Promise<void>;
306+
"codeQL.gotoQLContextEditor": () => Promise<void>;
302307
};
303308

304309
export type TestUICommands = {

extensions/ql-vscode/src/query-testing/discovery.ts renamed to extensions/ql-vscode/src/common/discovery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DisposableObject } from "../pure/disposable-object";
2-
import { extLogger } from "../common";
2+
import { extLogger } from "./logging/vscode/loggers";
33
import { getErrorMessage } from "../pure/helpers-pure";
44

55
/**

extensions/ql-vscode/src/config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,3 +702,12 @@ export function getAutogenerateQlPacks(): AutogenerateQLPacks {
702702
export async function setAutogenerateQlPacks(choice: AutogenerateQLPacks) {
703703
await AUTOGENERATE_QL_PACKS.updateValue(choice, ConfigurationTarget.Global);
704704
}
705+
706+
/**
707+
* A flag indicating whether to show the queries panel in the QL view container.
708+
*/
709+
const QUERIES_PANEL = new Setting("queriesPanel", ROOT_SETTING);
710+
711+
export function showQueriesPanel(): boolean {
712+
return !!QUERIES_PANEL.getValue<boolean>();
713+
}

extensions/ql-vscode/src/databases/local-databases.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { DisposableObject } from "../pure/disposable-object";
2424
import { Logger, extLogger } from "../common";
2525
import { asError, getErrorMessage } from "../pure/helpers-pure";
2626
import { QueryRunner } from "../query-server";
27-
import { pathsEqual } from "../pure/files";
27+
import { containsPath, pathsEqual } from "../pure/files";
2828
import { redactableError } from "../pure/errors";
2929
import {
3030
getAutogenerateQlPacks,
@@ -1152,12 +1152,9 @@ export class DatabaseManager extends DisposableObject {
11521152
}
11531153

11541154
private isExtensionControlledLocation(uri: vscode.Uri) {
1155-
const storagePath = this.ctx.storagePath || this.ctx.globalStoragePath;
1156-
// the uri.fsPath function on windows returns a lowercase drive letter,
1157-
// but storagePath will have an uppercase drive letter. Be sure to compare
1158-
// URIs to URIs only
1159-
if (storagePath) {
1160-
return uri.fsPath.startsWith(vscode.Uri.file(storagePath).fsPath);
1155+
const storageUri = this.ctx.storageUri || this.ctx.globalStorageUri;
1156+
if (storageUri) {
1157+
return containsPath(storageUri.fsPath, uri.fsPath, process.platform);
11611158
}
11621159
return false;
11631160
}

extensions/ql-vscode/src/extension.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ import { TestManager } from "./query-testing/test-manager";
125125
import { TestRunner } from "./query-testing/test-runner";
126126
import { TestManagerBase } from "./query-testing/test-manager-base";
127127
import { NewQueryRunner, QueryRunner, QueryServerClient } from "./query-server";
128+
import { QueriesModule } from "./queries-panel/queries-module";
128129

129130
/**
130131
* extension.ts
@@ -732,6 +733,8 @@ async function activateWithInstalledDistribution(
732733
);
733734
ctx.subscriptions.push(databaseUI);
734735

736+
QueriesModule.initialize(app);
737+
735738
void extLogger.log("Initializing evaluator log viewer.");
736739
const evalLogViewer = new EvalLogViewer();
737740
ctx.subscriptions.push(evalLogViewer);

extensions/ql-vscode/src/language-support/query-editor.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ export function getQueryEditorCommands({
3838
qhelpTmpDir,
3939
selectedQuery,
4040
),
41+
"codeQL.previewQueryHelpContextEditor": async (selectedQuery: Uri) =>
42+
await previewQueryHelp(
43+
commandManager,
44+
cliServer,
45+
qhelpTmpDir,
46+
selectedQuery,
47+
),
48+
"codeQL.previewQueryHelpContextExplorer": async (selectedQuery: Uri) =>
49+
await previewQueryHelp(
50+
commandManager,
51+
cliServer,
52+
qhelpTmpDir,
53+
selectedQuery,
54+
),
4155
};
4256
}
4357

extensions/ql-vscode/src/log-insights/summary-language-support.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export class SummaryLanguageSupport extends DisposableObject {
7878
public getCommands(): SummaryLanguageSupportCommands {
7979
return {
8080
"codeQL.gotoQL": this.handleGotoQL.bind(this),
81+
"codeQL.gotoQLContextEditor": this.handleGotoQL.bind(this),
8182
};
8283
}
8384

0 commit comments

Comments
 (0)