Fix failing tests

Also:
- Address comments in PR
- Add changelog note
This commit is contained in:
Andrew Eisenberg
2024-05-22 22:55:59 +00:00
parent 6c92a5b800
commit 088d2fa91e
5 changed files with 22 additions and 17 deletions

View File

@@ -2,6 +2,8 @@
## [UNRELEASED]
- Fix a bug when re-importing test databases that erroneously showed old source code. [#3616](https://github.com/github/vscode-codeql/pull/3616)
## 1.13.0 - 1 May 2024
- Add Ruby support to the CodeQL Model Editor. [#3584](https://github.com/github/vscode-codeql/pull/3584)

View File

@@ -244,8 +244,6 @@ export class ArchiveFileSystemProvider implements FileSystemProvider {
root = new Directory("");
constructor() {}
flushCache(zipPath: string) {
this.archives.delete(zipPath);
}
@@ -363,17 +361,19 @@ export class ArchiveFileSystemProvider implements FileSystemProvider {
*/
export const zipArchiveScheme = "codeql-zip-archive";
export function activate(ctx: ExtensionContext, dbm: DatabaseManager) {
export function activate(ctx: ExtensionContext, dbm?: DatabaseManager) {
const afsp = new ArchiveFileSystemProvider();
ctx.subscriptions.push(
dbm.onDidChangeDatabaseItem(async ({ kind, item: db }) => {
if (kind === DatabaseEventKind.Remove) {
if (db?.sourceArchive) {
afsp.flushCache(db.sourceArchive.fsPath);
if (dbm) {
ctx.subscriptions.push(
dbm.onDidChangeDatabaseItem(async ({ kind, item: db }) => {
if (kind === DatabaseEventKind.Remove) {
if (db?.sourceArchive) {
afsp.flushCache(db.sourceArchive.fsPath);
}
}
}
}),
);
}),
);
}
ctx.subscriptions.push(
// When a file system archive is removed from the workspace, we should

View File

@@ -18,6 +18,6 @@ export interface DatabaseChangedEvent {
item: DatabaseItem | undefined;
// If true, event handlers should consider the database manager
// to have been fully refreshed. Any state managed by the
/// event handler shouuld be fully refreshed as well.
// event handler shouuld be fully refreshed as well.
fullRefresh: boolean;
}

View File

@@ -722,7 +722,6 @@ export class DatabaseManager extends DisposableObject {
);
}
// note that we use undefined as the item in order to reset the entire tree
this._onDidChangeDatabaseItem.fire({
item,
kind: DatabaseEventKind.Remove,

View File

@@ -140,7 +140,8 @@ describe("local databases", () => {
},
]);
expect(onDidChangeDatabaseItem).toHaveBeenCalledWith({
item: undefined,
fullRefresh: true,
item: mockDbItem,
kind: DatabaseEventKind.Add,
});
@@ -152,7 +153,8 @@ describe("local databases", () => {
expect((databaseManager as any)._databaseItems).toEqual([]);
expect(updateSpy).toHaveBeenCalledWith("databaseList", []);
expect(onDidChangeDatabaseItem).toHaveBeenCalledWith({
item: undefined,
fullRefresh: true,
item: mockDbItem,
kind: DatabaseEventKind.Remove,
});
});
@@ -175,7 +177,8 @@ describe("local databases", () => {
]);
expect(onDidChangeDatabaseItem).toHaveBeenCalledWith({
item: undefined,
fullRefresh: true,
item: mockDbItem,
kind: DatabaseEventKind.Rename,
});
});
@@ -198,7 +201,8 @@ describe("local databases", () => {
]);
const mockEvent = {
item: undefined,
fullRefresh: true,
item: mockDbItem,
kind: DatabaseEventKind.Add,
};
expect(onDidChangeDatabaseItem).toHaveBeenCalledWith(mockEvent);