Use label service (#149001)

* Use labelService #148410

* Fix unit tests for search using label service
This commit is contained in:
Rob Lourens
2022-06-07 18:07:19 -07:00
committed by GitHub
parent 907cc3e3d8
commit 45818d7c31
4 changed files with 95 additions and 34 deletions

View File

@@ -0,0 +1,41 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Emitter, Event } from 'vs/base/common/event';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { basename, normalize } from 'vs/base/common/path';
import { URI } from 'vs/base/common/uri';
import { IFormatterChangeEvent, ILabelService, ResourceLabelFormatter } from 'vs/platform/label/common/label';
import { IWorkspace, IWorkspaceIdentifier } from 'vs/platform/workspace/common/workspace';
export class MockLabelService implements ILabelService {
_serviceBrand: undefined;
registerCachedFormatter(formatter: ResourceLabelFormatter): IDisposable {
throw new Error('Method not implemented.');
}
getUriLabel(resource: URI, options?: { relative?: boolean | undefined; noPrefix?: boolean | undefined }): string {
return normalize(resource.fsPath);
}
getUriBasenameLabel(resource: URI): string {
return basename(resource.fsPath);
}
getWorkspaceLabel(workspace: URI | IWorkspaceIdentifier | IWorkspace, options?: { verbose: boolean }): string {
return '';
}
getHostLabel(scheme: string, authority?: string): string {
return '';
}
public getHostTooltip(): string | undefined {
return '';
}
getSeparator(scheme: string, authority?: string): '/' | '\\' {
return '/';
}
registerFormatter(formatter: ResourceLabelFormatter): IDisposable {
return Disposable.None;
}
onDidChangeFormatters: Event<IFormatterChangeEvent> = new Emitter<IFormatterChangeEvent>().event;
}