Path: blob/main/src/vs/workbench/api/browser/mainThreadLabelService.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Disposable, DisposableMap } from '../../../base/common/lifecycle.js';6import { ILabelService, ResourceLabelFormatter } from '../../../platform/label/common/label.js';7import { MainContext, MainThreadLabelServiceShape } from '../common/extHost.protocol.js';8import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';910@extHostNamedCustomer(MainContext.MainThreadLabelService)11export class MainThreadLabelService extends Disposable implements MainThreadLabelServiceShape {1213private readonly _resourceLabelFormatters = this._register(new DisposableMap<number>());1415constructor(16_: IExtHostContext,17@ILabelService private readonly _labelService: ILabelService18) {19super();20}2122$registerResourceLabelFormatter(handle: number, formatter: ResourceLabelFormatter): void {23// Dynamicily registered formatters should have priority over those contributed via package.json24formatter.priority = true;25const disposable = this._labelService.registerCachedFormatter(formatter);26this._resourceLabelFormatters.set(handle, disposable);27}2829$unregisterResourceLabelFormatter(handle: number): void {30this._resourceLabelFormatters.deleteAndDispose(handle);31}32}333435