Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/api/browser/mainThreadLabelService.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Disposable, DisposableMap } from '../../../base/common/lifecycle.js';
7
import { ILabelService, ResourceLabelFormatter } from '../../../platform/label/common/label.js';
8
import { MainContext, MainThreadLabelServiceShape } from '../common/extHost.protocol.js';
9
import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';
10
11
@extHostNamedCustomer(MainContext.MainThreadLabelService)
12
export class MainThreadLabelService extends Disposable implements MainThreadLabelServiceShape {
13
14
private readonly _resourceLabelFormatters = this._register(new DisposableMap<number>());
15
16
constructor(
17
_: IExtHostContext,
18
@ILabelService private readonly _labelService: ILabelService
19
) {
20
super();
21
}
22
23
$registerResourceLabelFormatter(handle: number, formatter: ResourceLabelFormatter): void {
24
// Dynamicily registered formatters should have priority over those contributed via package.json
25
formatter.priority = true;
26
const disposable = this._labelService.registerCachedFormatter(formatter);
27
this._resourceLabelFormatters.set(handle, disposable);
28
}
29
30
$unregisterResourceLabelFormatter(handle: number): void {
31
this._resourceLabelFormatters.deleteAndDispose(handle);
32
}
33
}
34
35