forked from microsoft/vscode-java-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestItemDataCache.ts
More file actions
37 lines (30 loc) · 997 Bytes
/
testItemDataCache.ts
File metadata and controls
37 lines (30 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import { TestItem } from 'vscode';
import { TestKind, TestLevel } from '../types';
/**
* A map cache to save the metadata of the test item.
* Use a WeakMap here so the key-value will be automatically collected when
* the actual item is disposed.
*/
class TestItemDataCache {
private cache: WeakMap<TestItem, ITestItemData> = new WeakMap();
public set(item: TestItem, data: ITestItemData): void {
this.cache.set(item, data);
}
public get(item: TestItem): ITestItemData | undefined {
return this.cache.get(item);
}
public delete(item: TestItem): boolean {
return this.cache.delete(item);
}
}
export const dataCache: TestItemDataCache = new TestItemDataCache();
export interface ITestItemData {
jdtHandler: string;
fullName: string;
projectName: string;
testLevel: TestLevel;
testKind: TestKind;
uniqueId?: string;
}