mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-26 10:16:01 +01:00
don't return duplicates from vscode.extensions.allAcrossExtensionHosts, add ExtensionIdentifierSet fyi @alexdima
This commit is contained in:
@@ -91,7 +91,7 @@ import { ExtHostNotebookEditors } from 'vs/workbench/api/common/extHostNotebookE
|
||||
import { ExtHostNotebookDocuments } from 'vs/workbench/api/common/extHostNotebookDocuments';
|
||||
import { ExtHostInteractive } from 'vs/workbench/api/common/extHostInteractive';
|
||||
import { combinedDisposable } from 'vs/base/common/lifecycle';
|
||||
import { checkProposedApiEnabled, isProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { checkProposedApiEnabled, ExtensionIdentifierSet, isProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { DebugConfigurationProviderTriggerKind } from 'vs/workbench/contrib/debug/common/debug';
|
||||
import { ExtHostNotebookProxyKernels } from 'vs/workbench/api/common/extHostNotebookProxyKernels';
|
||||
|
||||
@@ -419,12 +419,11 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
},
|
||||
get allAcrossExtensionHosts(): vscode.Extension<any>[] {
|
||||
checkProposedApiEnabled(extension, 'extensionsAny');
|
||||
const local = new ExtensionIdentifierSet(extensionInfo.mine.getAllExtensionDescriptions().map(desc => desc.identifier));
|
||||
const result: vscode.Extension<any>[] = [];
|
||||
for (const desc of extensionInfo.mine.getAllExtensionDescriptions()) {
|
||||
result.push(new Extension(extensionService, extension.identifier, desc, extensionKind, false));
|
||||
}
|
||||
for (const desc of extensionInfo.all.getAllExtensionDescriptions()) {
|
||||
result.push(new Extension(extensionService, extension.identifier, desc, extensionKind /* TODO@alexdima THIS IS WRONG */, true));
|
||||
const isFromDifferentExtensionHost = !local.has(desc.identifier);
|
||||
result.push(new Extension(extensionService, extension.identifier, desc, extensionKind /* TODO@alexdima THIS IS WRONG */, isFromDifferentExtensionHost));
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
@@ -283,6 +283,65 @@ export class ExtensionHostExtensions {
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtensionIdentifierSet implements Set<ExtensionIdentifier> {
|
||||
|
||||
readonly [Symbol.toStringTag]: string = 'ExtensionIdentifierSet';
|
||||
|
||||
private readonly _map = new Map<string, ExtensionIdentifier>();
|
||||
private readonly _toKey = ExtensionIdentifier.toKey;
|
||||
|
||||
constructor(values?: Iterable<ExtensionIdentifier>) {
|
||||
if (values) {
|
||||
for (const value of values) {
|
||||
this.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get size(): number {
|
||||
return this._map.size;
|
||||
}
|
||||
|
||||
add(value: ExtensionIdentifier): this {
|
||||
this._map.set(this._toKey(value), value);
|
||||
return this;
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
this._map.clear();
|
||||
}
|
||||
|
||||
delete(value: ExtensionIdentifier): boolean {
|
||||
return this._map.delete(this._toKey(value));
|
||||
}
|
||||
|
||||
has(value: ExtensionIdentifier): boolean {
|
||||
return this._map.has(this._toKey(value));
|
||||
}
|
||||
|
||||
forEach(callbackfn: (value: ExtensionIdentifier, value2: ExtensionIdentifier, set: Set<ExtensionIdentifier>) => void, thisArg?: any): void {
|
||||
this._map.forEach(value => callbackfn.call(thisArg, value, value, this));
|
||||
}
|
||||
|
||||
*entries(): IterableIterator<[ExtensionIdentifier, ExtensionIdentifier]> {
|
||||
for (let [_key, value] of this._map) {
|
||||
yield [value, value];
|
||||
}
|
||||
}
|
||||
|
||||
keys(): IterableIterator<ExtensionIdentifier> {
|
||||
return this._map.values();
|
||||
}
|
||||
|
||||
values(): IterableIterator<ExtensionIdentifier> {
|
||||
return this._map.values();
|
||||
}
|
||||
|
||||
[Symbol.iterator](): IterableIterator<ExtensionIdentifier> {
|
||||
return this._map.values();
|
||||
}
|
||||
}
|
||||
|
||||
export function extensionIdentifiersArrayToSet(extensionIds: ExtensionIdentifier[]): Set<string> {
|
||||
const result = new Set<string>();
|
||||
for (const extensionId of extensionIds) {
|
||||
|
||||
Reference in New Issue
Block a user