Merge from vscode 4d91d96e5e121b38d33508cdef17868bab255eae

This commit is contained in:
ADS Merger
2020-06-18 04:32:54 +00:00
committed by AzureDataStudio
parent a971aee5bd
commit 5e7071e466
1002 changed files with 24201 additions and 13193 deletions

View File

@@ -481,14 +481,40 @@ export class TernarySearchTree<K, V> {
}
}
interface ResourceMapKeyFn {
(resource: URI): string;
}
export class ResourceMap<T> implements Map<URI, T> {
private static readonly defaultToKey = (resource: URI) => resource.toString();
readonly [Symbol.toStringTag] = 'ResourceMap';
protected readonly map: Map<string, T>;
private readonly map: Map<string, T>;
private readonly toKey: ResourceMapKeyFn;
constructor(other?: ResourceMap<T>) {
this.map = other ? new Map(other.map) : new Map();
/**
*
* @param toKey Custom uri identity function, e.g use an existing `IExtUri#getComparison`-util
*/
constructor(toKey?: ResourceMapKeyFn);
/**
*
* @param other Another resource which this maps is created from
* @param toKey Custom uri identity function, e.g use an existing `IExtUri#getComparison`-util
*/
constructor(other?: ResourceMap<T>, toKey?: ResourceMapKeyFn);
constructor(mapOrKeyFn?: ResourceMap<T> | ResourceMapKeyFn, toKey?: ResourceMapKeyFn) {
if (mapOrKeyFn instanceof ResourceMap) {
this.map = new Map(mapOrKeyFn.map);
this.toKey = toKey ?? ResourceMap.defaultToKey;
} else {
this.map = new Map();
this.toKey = mapOrKeyFn ?? ResourceMap.defaultToKey;
}
}
set(resource: URI, value: T): this {
@@ -546,10 +572,6 @@ export class ResourceMap<T> implements Map<URI, T> {
yield [URI.parse(item[0]), item[1]];
}
}
private toKey(resource: URI): string {
return resource.toString();
}
}
interface Item<K, V> {