1
>
/*---------------------------------------------------------------------------------------------
markers.ts
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 Severity from '../../../base/common/severity.js';
9
>
import { URI } from '../../../base/common/uri.js';
10
>
import { localize } from '../../../nls.js';
11
>
import { createDecorator } from '../../instantiation/common/instantiation.js';
12
>
13
>
export interface IMarkerReadOptions {
14
>
owner?: string;
15
>
resource?: URI;
16
>
severities?: number;
17
>
take?: number;
18
>
ignoreResourceFilters?: boolean;
19
>
}
20
>
21
>
export interface IMarkerService {
22
>
readonly _serviceBrand: undefined;
23
>
24
>
getStatistics(): MarkerStatistics;
25
>
26
>
changeOne(owner: string, resource: URI, markers: IMarkerData[]): void;
27
>
28
>
changeAll(owner: string, data: IResourceMarker[]): void;
29
>
30
>
remove(owner: string, resources: URI[]): void;
31
>
32
>
read(filter?: IMarkerReadOptions): IMarker[];
33
>
34
>
installResourceFilter(resource: URI, reason: string): IDisposable;
35
>
36
>
readonly onMarkerChanged: Event<readonly URI[]>;
37
>
}
38
>
39
>
/**
40
>
*
41
>
*/
42
>
export interface IRelatedInformation {
43
>
resource: URI;
44
>
message: string;
45
>
startLineNumber: number;
46
>
startColumn: number;
47
>
endLineNumber: number;
48
>
endColumn: number;
49
>
}
50
>
51
>
export const enum MarkerTag {
52
>
Unnecessary = 1,
53
>
Deprecated = 2
54
>
}
55
>
56
>
export enum MarkerSeverity {
57
>
Hint = 1,
58
>
Info = 2,
59
>
Warning = 4,
60
>
Error = 8,
61
>
}
62
>
63
>
export namespace MarkerSeverity {
64
>
65
>
export function compare(a: MarkerSeverity, b: MarkerSeverity): number {
66
return b - a;
67
}
69
>
const _displayStrings: { [value: number]: string } = Object.create(null);
70
>
_displayStrings[MarkerSeverity.Error] = localize('sev.error', "Error");
71
>
_displayStrings[MarkerSeverity.Warning] = localize('sev.warning', "Warning");
72
>
_displayStrings[MarkerSeverity.Info] = localize('sev.info', "Info");
73
>
74
>
export function toString(a: MarkerSeverity): string {
75
return _displayStrings[a] || '';
76
}
78
>
const _displayStringsPlural: { [value: number]: string } = Object.create(null);
79
>
_displayStringsPlural[MarkerSeverity.Error] = localize('sev.errors', "Errors");
80
>
_displayStringsPlural[MarkerSeverity.Warning] = localize('sev.warnings', "Warnings");
81
>
_displayStringsPlural[MarkerSeverity.Info] = localize('sev.infos', "Infos");
82
>
83
>
export function toStringPlural(a: MarkerSeverity): string {
84
return _displayStringsPlural[a] || '';
85
}
87
>
export function fromSeverity(severity: Severity): MarkerSeverity {
88
switch (severity) {
89
case Severity.Error: return MarkerSeverity.Error;