Skip to content

Commit 088d2fa

Browse files
committed
Fix failing tests
Also: - Address comments in PR - Add changelog note
1 parent 6c92a5b commit 088d2fa

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

extensions/ql-vscode/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [UNRELEASED]
44

5+
- Fix a bug when re-importing test databases that erroneously showed old source code. [#3616](https://github.com/github/vscode-codeql/pull/3616)
6+
57
## 1.13.0 - 1 May 2024
68

79
- Add Ruby support to the CodeQL Model Editor. [#3584](https://github.com/github/vscode-codeql/pull/3584)

extensions/ql-vscode/src/common/vscode/archive-filesystem-provider.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,6 @@ export class ArchiveFileSystemProvider implements FileSystemProvider {
244244

245245
root = new Directory("");
246246

247-
constructor() {}
248-
249247
flushCache(zipPath: string) {
250248
this.archives.delete(zipPath);
251249
}
@@ -363,17 +361,19 @@ export class ArchiveFileSystemProvider implements FileSystemProvider {
363361
*/
364362
export const zipArchiveScheme = "codeql-zip-archive";
365363

366-
export function activate(ctx: ExtensionContext, dbm: DatabaseManager) {
364+
export function activate(ctx: ExtensionContext, dbm?: DatabaseManager) {
367365
const afsp = new ArchiveFileSystemProvider();
368-
ctx.subscriptions.push(
369-
dbm.onDidChangeDatabaseItem(async ({ kind, item: db }) => {
370-
if (kind === DatabaseEventKind.Remove) {
371-
if (db?.sourceArchive) {
372-
afsp.flushCache(db.sourceArchive.fsPath);
366+
if (dbm) {
367+
ctx.subscriptions.push(
368+
dbm.onDidChangeDatabaseItem(async ({ kind, item: db }) => {
369+
if (kind === DatabaseEventKind.Remove) {
370+
if (db?.sourceArchive) {
371+
afsp.flushCache(db.sourceArchive.fsPath);
372+
}
373373
}
374-
}
375-
}),
376-
);
374+
}),
375+
);
376+
}
377377

378378
ctx.subscriptions.push(
379379
// When a file system archive is removed from the workspace, we should

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ export interface DatabaseChangedEvent {
1818
item: DatabaseItem | undefined;
1919
// If true, event handlers should consider the database manager
2020
// to have been fully refreshed. Any state managed by the
21-
/// event handler shouuld be fully refreshed as well.
21+
// event handler shouuld be fully refreshed as well.
2222
fullRefresh: boolean;
2323
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,6 @@ export class DatabaseManager extends DisposableObject {
722722
);
723723
}
724724

725-
// note that we use undefined as the item in order to reset the entire tree
726725
this._onDidChangeDatabaseItem.fire({
727726
item,
728727
kind: DatabaseEventKind.Remove,

extensions/ql-vscode/test/vscode-tests/minimal-workspace/local-queries/local-databases.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ describe("local databases", () => {
140140
},
141141
]);
142142
expect(onDidChangeDatabaseItem).toHaveBeenCalledWith({
143-
item: undefined,
143+
fullRefresh: true,
144+
item: mockDbItem,
144145
kind: DatabaseEventKind.Add,
145146
});
146147

@@ -152,7 +153,8 @@ describe("local databases", () => {
152153
expect((databaseManager as any)._databaseItems).toEqual([]);
153154
expect(updateSpy).toHaveBeenCalledWith("databaseList", []);
154155
expect(onDidChangeDatabaseItem).toHaveBeenCalledWith({
155-
item: undefined,
156+
fullRefresh: true,
157+
item: mockDbItem,
156158
kind: DatabaseEventKind.Remove,
157159
});
158160
});
@@ -175,7 +177,8 @@ describe("local databases", () => {
175177
]);
176178

177179
expect(onDidChangeDatabaseItem).toHaveBeenCalledWith({
178-
item: undefined,
180+
fullRefresh: true,
181+
item: mockDbItem,
179182
kind: DatabaseEventKind.Rename,
180183
});
181184
});
@@ -198,7 +201,8 @@ describe("local databases", () => {
198201
]);
199202

200203
const mockEvent = {
201-
item: undefined,
204+
fullRefresh: true,
205+
item: mockDbItem,
202206
kind: DatabaseEventKind.Add,
203207
};
204208
expect(onDidChangeDatabaseItem).toHaveBeenCalledWith(mockEvent);

0 commit comments

Comments
 (0)