@codingame/monaco-vscode-markers-service-override 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,128 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { Extensions as Extensions$1 } from 'vscode/vscode/vs/workbench/common/contributions';
3
- import { MarkerSeverity, IMarkerService } from 'vscode/vscode/vs/platform/markers/common/markers';
4
- import { IDecorationsService } from 'vscode/vscode/vs/workbench/services/decorations/common/decorations';
5
- import { dispose } from 'vscode/vscode/vs/base/common/lifecycle';
6
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
7
- import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
8
- import 'vscode/vscode/vs/platform/theme/common/colorUtils';
9
- import 'vscode/vscode/vs/platform/theme/common/colors/baseColors';
10
- import 'vscode/vscode/vs/platform/theme/common/colors/chartsColors';
11
- import 'vscode/vscode/vs/platform/theme/common/colors/editorColors';
12
- import 'vscode/vscode/vs/platform/theme/common/colors/inputColors';
13
- import { listErrorForeground, listWarningForeground } from 'vscode/vscode/vs/platform/theme/common/colors/listColors';
14
- import 'vscode/vscode/vs/platform/theme/common/colors/menuColors';
15
- import 'vscode/vscode/vs/platform/theme/common/colors/minimapColors';
16
- import 'vscode/vscode/vs/platform/theme/common/colors/miscColors';
17
- import 'vscode/vscode/vs/platform/theme/common/colors/quickpickColors';
18
- import 'vscode/vscode/vs/platform/theme/common/colors/searchColors';
19
- import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
20
- import { Extensions } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
21
-
22
- class MarkersDecorationsProvider {
23
- constructor(_markerService) {
24
- this._markerService = _markerService;
25
- this.label = ( localizeWithPath(
26
- 'vs/workbench/contrib/markers/browser/markersFileDecorations',
27
- 'label',
28
- "Problems"
29
- ));
30
- this.onDidChange = _markerService.onMarkerChanged;
31
- }
32
- provideDecorations(resource) {
33
- const markers = this._markerService.read({
34
- resource,
35
- severities: MarkerSeverity.Error | MarkerSeverity.Warning
36
- });
37
- let first;
38
- for (const marker of markers) {
39
- if (!first || marker.severity > first.severity) {
40
- first = marker;
41
- }
42
- }
43
- if (!first) {
44
- return undefined;
45
- }
46
- return {
47
- weight: 100 * first.severity,
48
- bubble: true,
49
- tooltip: markers.length === 1 ? ( localizeWithPath(
50
- 'vs/workbench/contrib/markers/browser/markersFileDecorations',
51
- 'tooltip.1',
52
- "1 problem in this file"
53
- )) : ( localizeWithPath(
54
- 'vs/workbench/contrib/markers/browser/markersFileDecorations',
55
- 'tooltip.N',
56
- "{0} problems in this file",
57
- markers.length
58
- )),
59
- letter: markers.length < 10 ? ( markers.length.toString()) : '9+',
60
- color: first.severity === MarkerSeverity.Error ? listErrorForeground : listWarningForeground,
61
- };
62
- }
63
- }
64
- let MarkersFileDecorations = class MarkersFileDecorations {
65
- constructor(_markerService, _decorationsService, _configurationService) {
66
- this._markerService = _markerService;
67
- this._decorationsService = _decorationsService;
68
- this._configurationService = _configurationService;
69
- this._disposables = [
70
- this._configurationService.onDidChangeConfiguration(e => {
71
- if (e.affectsConfiguration('problems.visibility')) {
72
- this._updateEnablement();
73
- }
74
- }),
75
- ];
76
- this._updateEnablement();
77
- }
78
- dispose() {
79
- dispose(this._provider);
80
- dispose(this._disposables);
81
- }
82
- _updateEnablement() {
83
- const problem = this._configurationService.getValue('problems.visibility');
84
- if (problem === undefined) {
85
- return;
86
- }
87
- const value = this._configurationService.getValue('problems');
88
- const shouldEnable = (problem && value.decorations.enabled);
89
- if (shouldEnable === this._enabled) {
90
- if (!problem || !value.decorations.enabled) {
91
- this._provider?.dispose();
92
- this._provider = undefined;
93
- }
94
- return;
95
- }
96
- this._enabled = shouldEnable;
97
- if (this._enabled) {
98
- const provider = ( new MarkersDecorationsProvider(this._markerService));
99
- this._provider = this._decorationsService.registerDecorationsProvider(provider);
100
- }
101
- else if (this._provider) {
102
- this._provider.dispose();
103
- }
104
- }
105
- };
106
- MarkersFileDecorations = ( __decorate([
107
- ( __param(0, IMarkerService)),
108
- ( __param(1, IDecorationsService)),
109
- ( __param(2, IConfigurationService))
110
- ], MarkersFileDecorations));
111
- ( Registry.as(Extensions.Configuration)).registerConfiguration({
112
- 'id': 'problems',
113
- 'order': 101,
114
- 'type': 'object',
115
- 'properties': {
116
- 'problems.decorations.enabled': {
117
- 'markdownDescription': ( localizeWithPath(
118
- 'vs/workbench/contrib/markers/browser/markersFileDecorations',
119
- 'markers.showOnFile',
120
- "Show Errors & Warnings on files and folder. Overwritten by `#problems.visibility#` when it is off."
121
- )),
122
- 'type': 'boolean',
123
- 'default': true
124
- }
125
- }
126
- });
127
- ( Registry.as(Extensions$1.Workbench))
128
- .registerWorkbenchContribution(MarkersFileDecorations, 3 );
@@ -1,77 +0,0 @@
1
- import { matchesFuzzy2, matchesFuzzy } from 'vscode/vscode/vs/base/common/filters';
2
- import { getEmptyExpression, splitGlobAware, parse } from 'vscode/vscode/vs/base/common/glob';
3
- import { rtrim, ltrim } from 'vscode/vscode/vs/base/common/strings';
4
- import { relativePath } from 'vscode/vscode/vs/base/common/resources';
5
- import { TernarySearchTree } from 'vscode/vscode/vs/base/common/ternarySearchTree';
6
-
7
- class ResourceGlobMatcher {
8
- constructor(globalExpression, rootExpressions, uriIdentityService) {
9
- this.globalExpression = parse(globalExpression);
10
- this.expressionsByRoot = TernarySearchTree.forUris(uri => uriIdentityService.extUri.ignorePathCasing(uri));
11
- for (const expression of rootExpressions) {
12
- this.expressionsByRoot.set(expression.root, { root: expression.root, expression: parse(expression.expression) });
13
- }
14
- }
15
- matches(resource) {
16
- const rootExpression = this.expressionsByRoot.findSubstr(resource);
17
- if (rootExpression) {
18
- const path = relativePath(rootExpression.root, resource);
19
- if (path && !!rootExpression.expression(path)) {
20
- return true;
21
- }
22
- }
23
- return !!this.globalExpression(resource.path);
24
- }
25
- }
26
- class FilterOptions {
27
- static { this._filter = matchesFuzzy2; }
28
- static { this._messageFilter = matchesFuzzy; }
29
- static EMPTY(uriIdentityService) { return ( new FilterOptions('', [], false, false, false, uriIdentityService)); }
30
- constructor(filter, filesExclude, showWarnings, showErrors, showInfos, uriIdentityService) {
31
- this.filter = filter;
32
- this.showWarnings = false;
33
- this.showErrors = false;
34
- this.showInfos = false;
35
- filter = filter.trim();
36
- this.showWarnings = showWarnings;
37
- this.showErrors = showErrors;
38
- this.showInfos = showInfos;
39
- const filesExcludeByRoot = Array.isArray(filesExclude) ? filesExclude : [];
40
- const excludesExpression = Array.isArray(filesExclude) ? getEmptyExpression() : filesExclude;
41
- for (const { expression } of filesExcludeByRoot) {
42
- for (const pattern of ( Object.keys(expression))) {
43
- if (!pattern.endsWith('/**')) {
44
- expression[`${rtrim(pattern, '/')}/**`] = expression[pattern];
45
- }
46
- }
47
- }
48
- const negate = filter.startsWith('!');
49
- this.textFilter = { text: (negate ? ltrim(filter, '!') : filter).trim(), negate };
50
- const includeExpression = getEmptyExpression();
51
- if (filter) {
52
- const filters = ( splitGlobAware(filter, ',').map(s => s.trim())).filter(s => !!s.length);
53
- for (const f of filters) {
54
- if (f.startsWith('!')) {
55
- const filterText = ltrim(f, '!');
56
- if (filterText) {
57
- this.setPattern(excludesExpression, filterText);
58
- }
59
- }
60
- else {
61
- this.setPattern(includeExpression, f);
62
- }
63
- }
64
- }
65
- this.excludesMatcher = ( new ResourceGlobMatcher(excludesExpression, filesExcludeByRoot, uriIdentityService));
66
- this.includesMatcher = ( new ResourceGlobMatcher(includeExpression, [], uriIdentityService));
67
- }
68
- setPattern(expression, pattern) {
69
- if (pattern[0] === '.') {
70
- pattern = '*' + pattern;
71
- }
72
- expression[`**/${pattern}/**`] = true;
73
- expression[`**/${pattern}`] = true;
74
- }
75
- }
76
-
77
- export { FilterOptions, ResourceGlobMatcher };
@@ -1,202 +0,0 @@
1
- import { basename, extUri } from 'vscode/vscode/vs/base/common/resources';
2
- import { Range } from 'vscode/vscode/vs/editor/common/core/range';
3
- import { MarkerSeverity, IMarkerData } from 'vscode/vscode/vs/platform/markers/common/markers';
4
- import { flatten, isNonEmptyArray } from 'vscode/vscode/vs/base/common/arrays';
5
- import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
6
- import { Emitter } from 'vscode/vscode/vs/base/common/event';
7
- import { Hasher } from 'vscode/vscode/vs/base/common/hash';
8
- import { splitLines } from 'vscode/vscode/vs/base/common/strings';
9
- import { unsupportedSchemas } from 'vscode/vscode/vs/platform/markers/common/markerService';
10
-
11
- function compareMarkersByUri(a, b) {
12
- return extUri.compare(a.resource, b.resource);
13
- }
14
- function compareResourceMarkers(a, b) {
15
- const [firstMarkerOfA] = a.markers;
16
- const [firstMarkerOfB] = b.markers;
17
- let res = 0;
18
- if (firstMarkerOfA && firstMarkerOfB) {
19
- res = MarkerSeverity.compare(firstMarkerOfA.marker.severity, firstMarkerOfB.marker.severity);
20
- }
21
- if (res === 0) {
22
- res = a.path.localeCompare(b.path) || a.name.localeCompare(b.name);
23
- }
24
- return res;
25
- }
26
- class ResourceMarkers {
27
- constructor(id, resource) {
28
- this.id = id;
29
- this.resource = resource;
30
- this._markersMap = ( new ResourceMap());
31
- this._total = 0;
32
- this.path = this.resource.fsPath;
33
- this.name = basename(this.resource);
34
- }
35
- get markers() {
36
- if (!this._cachedMarkers) {
37
- this._cachedMarkers = flatten([...( this._markersMap.values())]).sort(ResourceMarkers._compareMarkers);
38
- }
39
- return this._cachedMarkers;
40
- }
41
- has(uri) {
42
- return ( this._markersMap.has(uri));
43
- }
44
- set(uri, marker) {
45
- this.delete(uri);
46
- if (isNonEmptyArray(marker)) {
47
- this._markersMap.set(uri, marker);
48
- this._total += marker.length;
49
- this._cachedMarkers = undefined;
50
- }
51
- }
52
- delete(uri) {
53
- const array = this._markersMap.get(uri);
54
- if (array) {
55
- this._total -= array.length;
56
- this._cachedMarkers = undefined;
57
- this._markersMap.delete(uri);
58
- }
59
- }
60
- get total() {
61
- return this._total;
62
- }
63
- static _compareMarkers(a, b) {
64
- return MarkerSeverity.compare(a.marker.severity, b.marker.severity)
65
- || extUri.compare(a.resource, b.resource)
66
- || Range.compareRangesUsingStarts(a.marker, b.marker);
67
- }
68
- }
69
- class Marker {
70
- get resource() { return this.marker.resource; }
71
- get range() { return this.marker; }
72
- get lines() {
73
- if (!this._lines) {
74
- this._lines = splitLines(this.marker.message);
75
- }
76
- return this._lines;
77
- }
78
- constructor(id, marker, relatedInformation = []) {
79
- this.id = id;
80
- this.marker = marker;
81
- this.relatedInformation = relatedInformation;
82
- }
83
- toString() {
84
- return JSON.stringify({
85
- ...this.marker,
86
- resource: this.marker.resource.path,
87
- relatedInformation: this.relatedInformation.length ? ( this.relatedInformation.map(r => ({ ...r.raw, resource: r.raw.resource.path }))) : undefined
88
- }, null, '\t');
89
- }
90
- }
91
- class MarkerTableItem extends Marker {
92
- constructor(marker, sourceMatches, codeMatches, messageMatches, fileMatches, ownerMatches) {
93
- super(marker.id, marker.marker, marker.relatedInformation);
94
- this.sourceMatches = sourceMatches;
95
- this.codeMatches = codeMatches;
96
- this.messageMatches = messageMatches;
97
- this.fileMatches = fileMatches;
98
- this.ownerMatches = ownerMatches;
99
- }
100
- }
101
- class RelatedInformation {
102
- constructor(id, marker, raw) {
103
- this.id = id;
104
- this.marker = marker;
105
- this.raw = raw;
106
- }
107
- }
108
- class MarkersModel {
109
- get resourceMarkers() {
110
- if (!this.cachedSortedResources) {
111
- this.cachedSortedResources = [...( this.resourcesByUri.values())].sort(compareResourceMarkers);
112
- }
113
- return this.cachedSortedResources;
114
- }
115
- constructor() {
116
- this.cachedSortedResources = undefined;
117
- this._onDidChange = ( new Emitter());
118
- this.onDidChange = this._onDidChange.event;
119
- this._total = 0;
120
- this.resourcesByUri = ( new Map());
121
- }
122
- reset() {
123
- const removed = ( new Set());
124
- for (const resourceMarker of ( this.resourcesByUri.values())) {
125
- removed.add(resourceMarker);
126
- }
127
- this.resourcesByUri.clear();
128
- this._total = 0;
129
- this._onDidChange.fire({ removed, added: ( new Set()), updated: ( new Set()) });
130
- }
131
- get total() {
132
- return this._total;
133
- }
134
- getResourceMarkers(resource) {
135
- return this.resourcesByUri.get(extUri.getComparisonKey(resource, true)) ?? null;
136
- }
137
- setResourceMarkers(resourcesMarkers) {
138
- const change = { added: ( new Set()), removed: ( new Set()), updated: ( new Set()) };
139
- for (const [resource, rawMarkers] of resourcesMarkers) {
140
- if (( unsupportedSchemas.has(resource.scheme))) {
141
- continue;
142
- }
143
- const key = extUri.getComparisonKey(resource, true);
144
- let resourceMarkers = this.resourcesByUri.get(key);
145
- if (isNonEmptyArray(rawMarkers)) {
146
- if (!resourceMarkers) {
147
- const resourceMarkersId = this.id(( resource.toString()));
148
- resourceMarkers = ( new ResourceMarkers(resourceMarkersId, resource.with({ fragment: null })));
149
- this.resourcesByUri.set(key, resourceMarkers);
150
- change.added.add(resourceMarkers);
151
- }
152
- else {
153
- change.updated.add(resourceMarkers);
154
- }
155
- const markersCountByKey = ( new Map());
156
- const markers = ( rawMarkers.map((rawMarker) => {
157
- const key = IMarkerData.makeKey(rawMarker);
158
- const index = markersCountByKey.get(key) || 0;
159
- markersCountByKey.set(key, index + 1);
160
- const markerId = this.id(resourceMarkers.id, key, index, ( rawMarker.resource.toString()));
161
- let relatedInformation = undefined;
162
- if (rawMarker.relatedInformation) {
163
- relatedInformation = ( rawMarker.relatedInformation.map((r, index) => ( new RelatedInformation(this.id(markerId, ( r.resource.toString()), r.startLineNumber, r.startColumn, r.endLineNumber, r.endColumn, index), rawMarker, r))));
164
- }
165
- return ( new Marker(markerId, rawMarker, relatedInformation));
166
- }));
167
- this._total -= resourceMarkers.total;
168
- resourceMarkers.set(resource, markers);
169
- this._total += resourceMarkers.total;
170
- }
171
- else if (resourceMarkers) {
172
- this._total -= resourceMarkers.total;
173
- resourceMarkers.delete(resource);
174
- this._total += resourceMarkers.total;
175
- if (resourceMarkers.total === 0) {
176
- this.resourcesByUri.delete(key);
177
- change.removed.add(resourceMarkers);
178
- }
179
- else {
180
- change.updated.add(resourceMarkers);
181
- }
182
- }
183
- }
184
- this.cachedSortedResources = undefined;
185
- if (change.added.size || change.removed.size || change.updated.size) {
186
- this._onDidChange.fire(change);
187
- }
188
- }
189
- id(...values) {
190
- const hasher = ( new Hasher());
191
- for (const value of values) {
192
- hasher.hash(value);
193
- }
194
- return `${hasher.value}`;
195
- }
196
- dispose() {
197
- this._onDidChange.dispose();
198
- this.resourcesByUri.clear();
199
- }
200
- }
201
-
202
- export { Marker, MarkerTableItem, MarkersModel, RelatedInformation, ResourceMarkers, compareMarkersByUri };