@codingame/monaco-vscode-markers-service-override 3.2.3 → 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,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 };