src/vs/platform/label/common/label.ts

75 LOC · 75 covered · 0 uncovered · 1 ranges · 2054 concepts · 1 introducers · 1061 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- label.ts ×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 { Event } from '../../../base/common/event.js';
7 > import { IDisposable } from '../../../base/common/lifecycle.js';
8 > import { URI } from '../../../base/common/uri.js';
9 > import { createDecorator } from '../../instantiation/common/instantiation.js';
10 > import { IWorkspace, ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from '../../workspace/common/workspace.js';
11 >
12 > export const ILabelService = createDecorator<ILabelService>('labelService');
13 >
14 > export interface ILabelService {
15 >
16 > readonly _serviceBrand: undefined;
17 >
18 > /**
19 > * Gets the human readable label for a uri.
20 > * If `relative` is passed returns a label relative to the workspace root that the uri belongs to.
21 > * If `noPrefix` is passed does not tildify the label and also does not prepand the root name for relative labels in a multi root scenario.
22 > * If `separator` is passed, will use that over the defined path separator of the formatter.
23 > * If `appendWorkspaceSuffix` is passed, will append the name of the workspace to the label.
24 > */
25 > getUriLabel(resource: URI, options?: { relative?: boolean; noPrefix?: boolean; separator?: '/' | '\\'; appendWorkspaceSuffix?: boolean }): string;
26 > getUriBasenameLabel(resource: URI): string;
27 > getWorkspaceLabel(workspace: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI | IWorkspace), options?: { verbose: Verbosity }): string;
28 > getHostLabel(scheme: string, authority?: string): string;
29 > getHostTooltip(scheme: string, authority?: string): string | undefined;
30 > getSeparator(scheme: string, authority?: string): '/' | '\\';
31 >
32 > registerFormatter(formatter: ResourceLabelFormatter): IDisposable;
33 > readonly onDidChangeFormatters: Event<IFormatterChangeEvent>;
34 >
35 > /**
36 > * Registers a formatter that's cached for the machine beyond the lifecycle
37 > * of the current window. Disposing the formatter _will not_ remove it from
38 > * the cache.
39 > */
40 > registerCachedFormatter(formatter: ResourceLabelFormatter): IDisposable;
41 > }
42 >
43 > export const enum Verbosity {
44 > SHORT,
45 > MEDIUM,
46 > LONG
47 > }
48 >
49 > export interface IFormatterChangeEvent {
50 > scheme: string;
51 > }
52 >
53 > export interface ResourceLabelFormatter {
54 > scheme: string;
55 > authority?: string;
56 > priority?: boolean;
57 > formatting: ResourceLabelFormatting;
58 > }
59 >
60 > export interface ResourceLabelFormatting {
61 > label: string; // myLabel:/${path}
62 > separator: '/' | '\\' | '';
63 > tildify?: boolean;
64 > normalizeDriveLetter?: boolean;
65 > workspaceSuffix?: string;
66 > workspaceTooltip?: string;
67 > authorityPrefix?: string;
68 > stripPathStartingSeparator?: boolean;
69 > /**
70 > * Number of leading path segments to strip from `${path}` before
71 > * substitution. For example, a value of `2` turns
72 > * `/scheme/authority/rest/of/path` into `/rest/of/path`.
73 > */
74 > stripPathSegments?: number;
75 > }