Skip to content

Commit b9decd8

Browse files
committed
Create QL pack in workspace instead of global storage
We were initially using the storage path of the extension. We'd like to create these QL packs in the workspace instead.
1 parent 22d9487 commit b9decd8

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { ProgressCallback, ProgressUpdate, withProgress } from "./progress";
22
import {
33
CancellationToken,
44
CancellationTokenSource,
5-
ExtensionContext,
65
QuickPickItem,
76
Range,
87
Uri,
@@ -222,7 +221,6 @@ export class LocalQueries extends DisposableObject {
222221
private readonly databaseUI: DatabaseUI,
223222
private readonly localQueryResultsView: ResultsView,
224223
private readonly queryStorageDir: string,
225-
private readonly ctx: ExtensionContext,
226224
) {
227225
super();
228226
}
@@ -385,7 +383,6 @@ export class LocalQueries extends DisposableObject {
385383
const credentials = isCanary() ? this.app.credentials : undefined;
386384
const skeletonQueryWizard = new SkeletonQueryWizard(
387385
this.cliServer,
388-
this.ctx.storageUri?.fsPath,
389386
progress,
390387
credentials,
391388
extLogger,

extensions/ql-vscode/src/skeleton-query.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { join } from "path";
2-
import { CancellationToken, Uri, workspace } from "vscode";
2+
import { CancellationToken, Uri, workspace, window as Window } from "vscode";
33
import { CodeQLCliServer } from "./cli";
44
import { OutputChannelLogger } from "./common";
55
import { Credentials } from "./common/authentication";
@@ -19,6 +19,7 @@ export class SkeletonQueryWizard {
1919
private language: string | undefined;
2020
private folderName: string | undefined;
2121
private fileName = "example.ql";
22+
private storagePath: string | undefined;
2223

2324
QUERY_LANGUAGE_TO_DATABASE_REPO: QueryLanguagesToDatabaseMap = {
2425
csharp: "github/codeql",
@@ -30,13 +31,14 @@ export class SkeletonQueryWizard {
3031

3132
constructor(
3233
private readonly cliServer: CodeQLCliServer,
33-
private readonly storagePath: string | undefined,
3434
private readonly progress: ProgressCallback,
3535
private readonly credentials: Credentials | undefined,
3636
private readonly extLogger: OutputChannelLogger,
3737
private readonly databaseManager: DatabaseManager,
3838
private readonly token: CancellationToken,
39-
) {}
39+
) {
40+
this.storagePath = this.workoutStoragePath();
41+
}
4042

4143
public async execute() {
4244
// show quick pick to choose language
@@ -80,6 +82,18 @@ export class SkeletonQueryWizard {
8082
});
8183
}
8284

85+
private workoutStoragePath() {
86+
const workspaceFolders = workspace.workspaceFolders;
87+
88+
if (!workspaceFolders || workspaceFolders.length === 0) {
89+
throw new Error("No workspace folders found");
90+
}
91+
92+
const firstFolder = workspaceFolders[0];
93+
94+
return firstFolder.uri.path;
95+
}
96+
8397
private async chooseLanguage() {
8498
this.progress({
8599
message: "Choose language",

extensions/ql-vscode/test/vscode-tests/cli-integration/skeleton-query.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { CodeQLCliServer } from "../../../src/cli";
22
import { SkeletonQueryWizard } from "../../../src/skeleton-query";
33
import { mockedObject, mockedQuickPickItem } from "../utils/mocking.helpers";
44
import * as tmp from "tmp";
5-
import { TextDocument, window, workspace } from "vscode";
5+
import { TextDocument, window, workspace, WorkspaceFolder } from "vscode";
66
import { extLogger } from "../../../src/common";
77
import { QlPackGenerator } from "../../../src/qlpack-generator";
88
import * as helpers from "../../../src/helpers";
@@ -99,7 +99,6 @@ describe("SkeletonQueryWizard", () => {
9999

100100
wizard = new SkeletonQueryWizard(
101101
mockCli,
102-
storagePath,
103102
jest.fn(),
104103
credentials,
105104
extLogger,

0 commit comments

Comments
 (0)