Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/base/common/hierarchicalKind.ts
3291 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
export class HierarchicalKind {
7
public static readonly sep = '.';
8
9
public static readonly None = new HierarchicalKind('@@none@@'); // Special kind that matches nothing
10
public static readonly Empty = new HierarchicalKind('');
11
12
constructor(
13
public readonly value: string
14
) { }
15
16
public equals(other: HierarchicalKind): boolean {
17
return this.value === other.value;
18
}
19
20
public contains(other: HierarchicalKind): boolean {
21
return this.equals(other) || this.value === '' || other.value.startsWith(this.value + HierarchicalKind.sep);
22
}
23
24
public intersects(other: HierarchicalKind): boolean {
25
return this.contains(other) || other.contains(this);
26
}
27
28
public append(...parts: string[]): HierarchicalKind {
29
return new HierarchicalKind((this.value ? [this.value, ...parts] : parts).join(HierarchicalKind.sep));
30
}
31
}
32
33