@opensumi/ide-core-common 2.21.13 → 2.22.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.
- package/lib/command.d.ts +15 -5
- package/lib/command.d.ts.map +1 -1
- package/lib/command.js +11 -1
- package/lib/command.js.map +1 -1
- package/lib/const/application.d.ts +6 -1
- package/lib/const/application.d.ts.map +1 -1
- package/lib/const/application.js +8 -3
- package/lib/const/application.js.map +1 -1
- package/lib/declare.d.ts +2 -2
- package/lib/declare.d.ts.map +1 -1
- package/lib/editor.d.ts +4 -0
- package/lib/editor.d.ts.map +1 -1
- package/lib/electron.d.ts +1 -1
- package/lib/electron.d.ts.map +1 -1
- package/lib/event-bus/event-bus-types.d.ts +1 -1
- package/lib/event-bus/event-bus-types.d.ts.map +1 -1
- package/lib/event-bus/event-bus.js.map +1 -1
- package/lib/event-bus/event-decorator.js.map +1 -1
- package/lib/extension.schema.d.ts +1 -1
- package/lib/extension.schema.d.ts.map +1 -1
- package/lib/hash-calculate/WASMInterface.d.ts +2 -2
- package/lib/hash-calculate/WASMInterface.d.ts.map +1 -1
- package/lib/hash-calculate/hash-calculate.js.map +1 -1
- package/lib/hash-calculate/util.d.ts +2 -2
- package/lib/hash-calculate/util.d.ts.map +1 -1
- package/lib/json-schema.d.ts +9 -0
- package/lib/json-schema.d.ts.map +1 -1
- package/lib/keyboard/keymap.d.ts +1 -1
- package/lib/keyboard/keymap.d.ts.map +1 -1
- package/lib/localize.d.ts +1 -1
- package/lib/localize.d.ts.map +1 -1
- package/lib/log.d.ts +2 -2
- package/lib/log.d.ts.map +1 -1
- package/lib/mime.d.ts +6 -6
- package/lib/module.js.map +1 -1
- package/lib/preferences/preference-schema.d.ts +13 -3
- package/lib/preferences/preference-schema.d.ts.map +1 -1
- package/lib/preferences/preference-schema.js +11 -1
- package/lib/preferences/preference-schema.js.map +1 -1
- package/lib/preferences/preference-scope.d.ts +8 -1
- package/lib/preferences/preference-scope.d.ts.map +1 -1
- package/lib/preferences/preference-scope.js +11 -2
- package/lib/preferences/preference-scope.js.map +1 -1
- package/lib/problem-matcher.d.ts +1 -1
- package/lib/problem-matcher.d.ts.map +1 -1
- package/lib/problem-matcher.js.map +1 -1
- package/lib/problem-pattern.d.ts +4 -2
- package/lib/problem-pattern.d.ts.map +1 -1
- package/lib/problem-pattern.js +24 -1
- package/lib/problem-pattern.js.map +1 -1
- package/lib/reference.d.ts +2 -1
- package/lib/reference.d.ts.map +1 -1
- package/lib/reference.js +11 -6
- package/lib/reference.js.map +1 -1
- package/lib/reporter.js.map +1 -1
- package/lib/storage.d.ts +1 -1
- package/lib/storage.d.ts.map +1 -1
- package/lib/storage.js.map +1 -1
- package/lib/task-definition.js.map +1 -1
- package/lib/types/common.d.ts +1 -1
- package/lib/types/common.d.ts.map +1 -1
- package/lib/types/editor.d.ts +2 -2
- package/lib/types/editor.d.ts.map +1 -1
- package/lib/types/file-watch.d.ts +1 -1
- package/lib/types/file-watch.d.ts.map +1 -1
- package/lib/types/markers/markers-manager.d.ts.map +1 -1
- package/lib/types/markers/markers-manager.js +4 -10
- package/lib/types/markers/markers-manager.js.map +1 -1
- package/lib/types/markers/markers.d.ts +2 -0
- package/lib/types/markers/markers.d.ts.map +1 -1
- package/lib/types/markers/markers.js.map +1 -1
- package/package.json +7 -6
- package/src/LifeCyclePhase.ts +6 -0
- package/src/application-error.ts +77 -0
- package/src/application-props.ts +28 -0
- package/src/application.lifecycle.ts +15 -0
- package/src/browser-fs/ensure-dir.ts +46 -0
- package/src/browser-fs/util.ts +52 -0
- package/src/clipboard.ts +31 -0
- package/src/command.ts +726 -0
- package/src/commands/terminal.ts +0 -0
- package/src/comparers.ts +152 -0
- package/src/connection.ts +7 -0
- package/src/const/application.ts +11 -0
- package/src/const/index.ts +1 -0
- package/src/contribution-provider.ts +47 -0
- package/src/credential.ts +21 -0
- package/src/crypto.ts +8 -0
- package/src/declare.ts +3 -0
- package/src/di-helper/domain-helper.ts +48 -0
- package/src/di-helper/index.ts +1 -0
- package/src/editor.ts +6 -0
- package/src/electron.ts +168 -0
- package/src/env.ts +1 -0
- package/src/event-bus/basic-event.ts +3 -0
- package/src/event-bus/event-bus-types.ts +68 -0
- package/src/event-bus/event-bus.ts +57 -0
- package/src/event-bus/event-decorator.ts +32 -0
- package/src/event-bus/index.ts +4 -0
- package/src/extension.schema.ts +16 -0
- package/src/hash-calculate/WASMInterface.ts +266 -0
- package/src/hash-calculate/hash-calculate.ts +53 -0
- package/src/hash-calculate/lockedCreate.ts +17 -0
- package/src/hash-calculate/md5.wasm.json +1 -0
- package/src/hash-calculate/mutex.ts +30 -0
- package/src/hash-calculate/util.ts +190 -0
- package/src/id-generator.ts +15 -0
- package/src/index.ts +39 -0
- package/src/json-schema.ts +80 -0
- package/src/keyboard/index.ts +2 -0
- package/src/keyboard/keyboard-layout-provider.ts +46 -0
- package/src/keyboard/keymap.ts +224 -0
- package/src/line-text.ts +93 -0
- package/src/localize.ts +203 -0
- package/src/log.ts +338 -0
- package/src/markdown.ts +8 -0
- package/src/menu.ts +31 -0
- package/src/mime.ts +8 -0
- package/src/mocks/electron/browserMock.ts +10 -0
- package/src/mocks/electron/ipcRenderer.ts +30 -0
- package/src/module.ts +31 -0
- package/src/network.ts +47 -0
- package/src/node/cli.ts +5 -0
- package/src/node/port.ts +134 -0
- package/src/preferences/index.ts +2 -0
- package/src/preferences/preference-schema.ts +122 -0
- package/src/preferences/preference-scope.ts +65 -0
- package/src/problem-matcher.ts +389 -0
- package/src/problem-pattern.ts +574 -0
- package/src/range.ts +24 -0
- package/src/reference.ts +141 -0
- package/src/reporter.ts +64 -0
- package/src/settings/general.ts +5 -0
- package/src/settings/index.ts +3 -0
- package/src/settings/search.ts +7 -0
- package/src/settings/terminal.ts +9 -0
- package/src/storage.ts +99 -0
- package/src/task-definition.ts +172 -0
- package/src/theme.ts +7 -0
- package/src/types/accessibility.ts +4 -0
- package/src/types/application.ts +14 -0
- package/src/types/authentication.ts +120 -0
- package/src/types/common.ts +14 -0
- package/src/types/dnd.ts +8 -0
- package/src/types/editor.ts +246 -0
- package/src/types/extension.ts +96 -0
- package/src/types/file-watch.ts +100 -0
- package/src/types/file.ts +262 -0
- package/src/types/index.ts +15 -0
- package/src/types/markdown.ts +10 -0
- package/src/types/markers/index.ts +2 -0
- package/src/types/markers/markers-manager.ts +392 -0
- package/src/types/markers/markers.ts +125 -0
- package/src/types/message.ts +6 -0
- package/src/types/reporter.ts +96 -0
- package/src/types/statusbar.ts +6 -0
- package/src/types/string.ts +3 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/ipc.ts +28 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './editor';
|
|
2
|
+
export * from './message';
|
|
3
|
+
export * from './file';
|
|
4
|
+
export * from './markers';
|
|
5
|
+
export * from './extension';
|
|
6
|
+
export * from './reporter';
|
|
7
|
+
export * from './string';
|
|
8
|
+
export * from './dnd';
|
|
9
|
+
export * from './common';
|
|
10
|
+
export * from './application';
|
|
11
|
+
export * from './authentication';
|
|
12
|
+
export * from './accessibility';
|
|
13
|
+
export * from './statusbar';
|
|
14
|
+
export * from './markdown';
|
|
15
|
+
export * from './editor';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UriComponents } from '@opensumi/ide-utils';
|
|
2
|
+
|
|
3
|
+
export interface IMarkdownString {
|
|
4
|
+
value: string;
|
|
5
|
+
isTrusted?: boolean;
|
|
6
|
+
supportThemeIcons?: boolean;
|
|
7
|
+
supportHtml?: boolean;
|
|
8
|
+
baseUri?: UriComponents;
|
|
9
|
+
uris?: { [href: string]: UriComponents };
|
|
10
|
+
}
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import { Injectable } from '@opensumi/di';
|
|
2
|
+
import { Emitter, Event, IDisposable, arrays } from '@opensumi/ide-utils';
|
|
3
|
+
|
|
4
|
+
import { WithEventBus } from '../../event-bus';
|
|
5
|
+
|
|
6
|
+
import { MapMap } from './markers';
|
|
7
|
+
import { IMarker, IMarkerData, MarkerStatistics, MarkerSeverity } from './markers';
|
|
8
|
+
|
|
9
|
+
const { isFalsyOrEmpty } = arrays;
|
|
10
|
+
|
|
11
|
+
export interface IBaseMarkerManager {
|
|
12
|
+
/**
|
|
13
|
+
* 更新markers
|
|
14
|
+
* @param type 类型标识
|
|
15
|
+
* @param uri markers对应的资源
|
|
16
|
+
* @param markers 所有markers
|
|
17
|
+
*/
|
|
18
|
+
updateMarkers(type: string, uri: string, markers: IMarkerData[]);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 清空markers
|
|
22
|
+
* @param type 类型标识
|
|
23
|
+
*/
|
|
24
|
+
clearMarkers(type: string);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 获取所有markers的统计信息
|
|
28
|
+
*/
|
|
29
|
+
getStats(): MarkerStats;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 获得当前所有资源
|
|
33
|
+
*/
|
|
34
|
+
getResources(): string[];
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 获取markers
|
|
38
|
+
*/
|
|
39
|
+
getMarkers(filter: {
|
|
40
|
+
type?: string;
|
|
41
|
+
resource?: string;
|
|
42
|
+
severities?: number;
|
|
43
|
+
take?: number;
|
|
44
|
+
opened?: boolean;
|
|
45
|
+
}): IMarker[];
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* marker变更事件
|
|
49
|
+
*/
|
|
50
|
+
onMarkerChanged: Event<string[]>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 打开编辑器回调
|
|
54
|
+
* @param resource 资源
|
|
55
|
+
*/
|
|
56
|
+
onEditorGroupOpen(resource: string);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 关闭编辑器回调
|
|
60
|
+
* @param resource 资源
|
|
61
|
+
*/
|
|
62
|
+
onEditorGroupClose(resource: string);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export class MarkerStats implements MarkerStatistics, IDisposable {
|
|
66
|
+
public errors = 0;
|
|
67
|
+
public infos = 0;
|
|
68
|
+
public warnings = 0;
|
|
69
|
+
public unknowns = 0;
|
|
70
|
+
|
|
71
|
+
private _data?: { [resource: string]: MarkerStatistics } = Object.create(null);
|
|
72
|
+
private _manager: IBaseMarkerManager;
|
|
73
|
+
private _subscription: IDisposable;
|
|
74
|
+
|
|
75
|
+
constructor(manager: IBaseMarkerManager) {
|
|
76
|
+
this._manager = manager;
|
|
77
|
+
this._subscription = manager.onMarkerChanged(this._update, this);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
dispose(): void {
|
|
81
|
+
this._subscription.dispose();
|
|
82
|
+
this._data = undefined;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private _update(resources: string[]): void {
|
|
86
|
+
if (!this._data) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
for (const resource of resources) {
|
|
91
|
+
const key = resource.toString();
|
|
92
|
+
const oldStats = this._data[key];
|
|
93
|
+
if (oldStats) {
|
|
94
|
+
this._substract(oldStats);
|
|
95
|
+
}
|
|
96
|
+
const newStats = this._resourceStats(resource);
|
|
97
|
+
this._add(newStats);
|
|
98
|
+
this._data[key] = newStats;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private _resourceStats(resource: string): MarkerStatistics {
|
|
103
|
+
const result: MarkerStatistics = { errors: 0, warnings: 0, infos: 0, unknowns: 0 };
|
|
104
|
+
|
|
105
|
+
const markers = this._manager.getMarkers({ resource, opened: true });
|
|
106
|
+
for (const { severity } of markers) {
|
|
107
|
+
if (severity === MarkerSeverity.Error) {
|
|
108
|
+
result.errors += 1;
|
|
109
|
+
} else if (severity === MarkerSeverity.Warning) {
|
|
110
|
+
result.warnings += 1;
|
|
111
|
+
} else if (severity === MarkerSeverity.Info) {
|
|
112
|
+
result.infos += 1;
|
|
113
|
+
} else {
|
|
114
|
+
// Hint
|
|
115
|
+
result.unknowns += 1;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private _substract(op: MarkerStatistics) {
|
|
123
|
+
this.errors -= op.errors;
|
|
124
|
+
this.warnings -= op.warnings;
|
|
125
|
+
this.infos -= op.infos;
|
|
126
|
+
this.unknowns -= op.unknowns;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private _add(op: MarkerStatistics) {
|
|
130
|
+
this.errors += op.errors;
|
|
131
|
+
this.warnings += op.warnings;
|
|
132
|
+
this.infos += op.infos;
|
|
133
|
+
this.unknowns += op.unknowns;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@Injectable()
|
|
138
|
+
export class MarkerManager extends WithEventBus implements IBaseMarkerManager {
|
|
139
|
+
// 所有Marker
|
|
140
|
+
private readonly _byResource: MapMap<IMarker[]> = Object.create(null);
|
|
141
|
+
private readonly _byType: MapMap<IMarker[]> = Object.create(null);
|
|
142
|
+
|
|
143
|
+
private readonly _byResourceCloseCache: MapMap<IMarker[]> = Object.create(null);
|
|
144
|
+
|
|
145
|
+
private readonly _openedResource: Set<string> = new Set();
|
|
146
|
+
|
|
147
|
+
// marker 当前状态
|
|
148
|
+
private _stats: MarkerStats;
|
|
149
|
+
|
|
150
|
+
// marker 变更 事件
|
|
151
|
+
private readonly onMarkerChangedEmitter = new Emitter<string[]>();
|
|
152
|
+
public readonly onMarkerChanged: Event<string[]> = this.onMarkerChangedEmitter.event;
|
|
153
|
+
|
|
154
|
+
constructor() {
|
|
155
|
+
super();
|
|
156
|
+
this.addDispose([(this._stats = new MarkerStats(this)), this.onMarkerChangedEmitter]);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 接受Diagnostics信息,更新marker
|
|
161
|
+
* @param type marker 类型,比如 typescript, eslint等
|
|
162
|
+
* @param uri marker 资源
|
|
163
|
+
* @param rawMarkers 来源于diagnostics的原始marker信息
|
|
164
|
+
*/
|
|
165
|
+
public updateMarkers(type: string, uri: string, rawMarkers: IMarkerData[]) {
|
|
166
|
+
if (isFalsyOrEmpty(rawMarkers)) {
|
|
167
|
+
// remove marker for this (owner,resource)-tuple
|
|
168
|
+
const a = MapMap.remove(this._byResource, uri, type);
|
|
169
|
+
const b = MapMap.remove(this._byType, type, uri);
|
|
170
|
+
if (a !== b) {
|
|
171
|
+
throw new Error('invalid marker service state');
|
|
172
|
+
}
|
|
173
|
+
if (a && b) {
|
|
174
|
+
this.onMarkerChangedEmitter.fire([uri]);
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
// insert marker for this (owner,resource)-tuple
|
|
178
|
+
const markers: IMarkerData[] = [];
|
|
179
|
+
for (const data of rawMarkers) {
|
|
180
|
+
const marker = this.convertToMarker(type, uri, data);
|
|
181
|
+
if (marker) {
|
|
182
|
+
markers.push(marker);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
MapMap.set(this._byResource, uri, type, markers);
|
|
186
|
+
MapMap.set(this._byType, type, uri, markers);
|
|
187
|
+
this.onMarkerChangedEmitter.fire([uri]);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Marker数据类型转换
|
|
193
|
+
* @param type marker类型
|
|
194
|
+
* @param resource 资源uri
|
|
195
|
+
* @param data marker数据
|
|
196
|
+
*/
|
|
197
|
+
private convertToMarker(type: string, resource: string, data: IMarkerData): IMarker | undefined {
|
|
198
|
+
const { message } = data;
|
|
199
|
+
|
|
200
|
+
if (!message) {
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
let { startLineNumber, startColumn, endLineNumber, endColumn } = data;
|
|
205
|
+
|
|
206
|
+
// santize data
|
|
207
|
+
// marker 的 startLineNumber 等是 1-base 的
|
|
208
|
+
startLineNumber = startLineNumber > 0 ? startLineNumber : 1;
|
|
209
|
+
startColumn = startColumn > 0 ? startColumn : 1;
|
|
210
|
+
endLineNumber = endLineNumber >= startLineNumber ? endLineNumber : startLineNumber;
|
|
211
|
+
endColumn = endColumn > 0 ? endColumn : startColumn;
|
|
212
|
+
|
|
213
|
+
return {
|
|
214
|
+
...data,
|
|
215
|
+
resource,
|
|
216
|
+
type,
|
|
217
|
+
message,
|
|
218
|
+
startLineNumber,
|
|
219
|
+
startColumn,
|
|
220
|
+
endLineNumber,
|
|
221
|
+
endColumn,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* 清空特定类型的marker
|
|
227
|
+
* @param type 消息类型
|
|
228
|
+
*/
|
|
229
|
+
public clearMarkers(type: string) {
|
|
230
|
+
const changes: string[] = [];
|
|
231
|
+
const map = this._byType[type];
|
|
232
|
+
|
|
233
|
+
// remove old marker
|
|
234
|
+
if (map) {
|
|
235
|
+
delete this._byType[type];
|
|
236
|
+
// eslint-disable-next-line guard-for-in
|
|
237
|
+
for (const resource in map) {
|
|
238
|
+
const entry = MapMap.get(this._byResource, resource, type);
|
|
239
|
+
if (entry) {
|
|
240
|
+
// remeber what we remove
|
|
241
|
+
const [first] = entry;
|
|
242
|
+
if (first) {
|
|
243
|
+
changes.push(first.resource);
|
|
244
|
+
}
|
|
245
|
+
// actual remove
|
|
246
|
+
MapMap.remove(this._byResource, resource, type);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
this.onMarkerChangedEmitter.fire(changes);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* 清空给定uri的所有marker
|
|
256
|
+
* @param resource 资源uri
|
|
257
|
+
*/
|
|
258
|
+
public clearMarkersOfUri(resource: string) {
|
|
259
|
+
const map = this._byResource[resource];
|
|
260
|
+
if (map) {
|
|
261
|
+
delete this._byResource[resource];
|
|
262
|
+
// eslint-disable-next-line guard-for-in
|
|
263
|
+
for (const type in map) {
|
|
264
|
+
const entry = MapMap.get(this._byType, type, resource);
|
|
265
|
+
if (entry) {
|
|
266
|
+
// actual remove
|
|
267
|
+
MapMap.remove(this._byType, type, resource);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
this.onMarkerChangedEmitter.fire([resource]);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* 根据过滤条件,查询marker列表
|
|
276
|
+
* - type 类型
|
|
277
|
+
* - resource 资源URI
|
|
278
|
+
* - severities 安全等级
|
|
279
|
+
* - take 提取个数
|
|
280
|
+
* - opened 是否过滤打开的
|
|
281
|
+
* @param filter 过滤条件
|
|
282
|
+
*/
|
|
283
|
+
public getMarkers(
|
|
284
|
+
filter: { type?: string; resource?: string; severities?: number; take?: number; opened?: boolean } = Object.create(
|
|
285
|
+
null,
|
|
286
|
+
),
|
|
287
|
+
): IMarker[] {
|
|
288
|
+
const { type, resource, severities, opened } = filter;
|
|
289
|
+
let { take } = filter;
|
|
290
|
+
|
|
291
|
+
if (!take || take < 0) {
|
|
292
|
+
take = -1;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (type && resource) {
|
|
296
|
+
// exactly one owner AND resource
|
|
297
|
+
const data = MapMap.get(this._byResource, resource.toString(), type);
|
|
298
|
+
if (!data) {
|
|
299
|
+
return [];
|
|
300
|
+
} else {
|
|
301
|
+
const result: IMarker[] = [];
|
|
302
|
+
for (const marker of data) {
|
|
303
|
+
if (this.isTargetMarker(marker, severities, opened)) {
|
|
304
|
+
const newLen = result.push(marker);
|
|
305
|
+
if (take > 0 && newLen === take) {
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return result;
|
|
311
|
+
}
|
|
312
|
+
} else if (!type && !resource) {
|
|
313
|
+
// all
|
|
314
|
+
const result: IMarker[] = [];
|
|
315
|
+
// eslint-disable-next-line guard-for-in
|
|
316
|
+
for (const key1 in this._byResource) {
|
|
317
|
+
// eslint-disable-next-line guard-for-in
|
|
318
|
+
for (const key2 in this._byResource[key1]) {
|
|
319
|
+
for (const data of this._byResource[key1][key2]) {
|
|
320
|
+
if (this.isTargetMarker(data, severities, opened)) {
|
|
321
|
+
const newLen = result.push(data);
|
|
322
|
+
if (take > 0 && newLen === take) {
|
|
323
|
+
return result;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return result;
|
|
330
|
+
} else {
|
|
331
|
+
// of one resource OR owner
|
|
332
|
+
const map: { [key: string]: IMarker[] } | undefined = type
|
|
333
|
+
? this._byType[type]
|
|
334
|
+
: resource
|
|
335
|
+
? this._byResource[resource.toString()]
|
|
336
|
+
: undefined;
|
|
337
|
+
|
|
338
|
+
if (!map) {
|
|
339
|
+
return [];
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const result: IMarker[] = [];
|
|
343
|
+
// eslint-disable-next-line guard-for-in
|
|
344
|
+
for (const key in map) {
|
|
345
|
+
for (const data of map[key]) {
|
|
346
|
+
if (this.isTargetMarker(data, severities, opened)) {
|
|
347
|
+
const newLen = result.push(data);
|
|
348
|
+
if (take > 0 && newLen === take) {
|
|
349
|
+
return result;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return result;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
private isTargetMarker(marker: IMarker, severities?: number, visible?: boolean): boolean {
|
|
359
|
+
const isTargetSeverity = severities === undefined || (severities & marker.severity) === marker.severity;
|
|
360
|
+
const isTargetVisible = visible ? this._openedResource.has(marker.resource) : true;
|
|
361
|
+
return isTargetSeverity && isTargetVisible;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
public getResources(): string[] {
|
|
365
|
+
return MapMap.keys(this._byResource);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
public getStats(): MarkerStats {
|
|
369
|
+
return this._stats;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
public onEditorGroupOpen(resource: string) {
|
|
373
|
+
this._openedResource.add(resource);
|
|
374
|
+
const cacheMap = MapMap.removeMap(this._byResourceCloseCache, resource);
|
|
375
|
+
if (cacheMap) {
|
|
376
|
+
MapMap.setMap(this._byResource, resource, cacheMap);
|
|
377
|
+
Object.keys(cacheMap).forEach((type) => {
|
|
378
|
+
MapMap.set(this._byType, type, resource, cacheMap[type]);
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
this.onMarkerChangedEmitter.fire([resource]);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
public onEditorGroupClose(resource: string) {
|
|
385
|
+
this._openedResource.delete(resource);
|
|
386
|
+
const resourceToCache = MapMap.getMap(this._byResource, resource);
|
|
387
|
+
if (resourceToCache) {
|
|
388
|
+
MapMap.setMap(this._byResourceCloseCache, resource, resourceToCache);
|
|
389
|
+
}
|
|
390
|
+
this.clearMarkersOfUri(resource);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { isEmptyObject, URI } from '@opensumi/ide-utils';
|
|
2
|
+
|
|
3
|
+
export interface MapMap<V> {
|
|
4
|
+
[key: string]: { [key: string]: V };
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export namespace MapMap {
|
|
8
|
+
export function get<V>(map: MapMap<V>, key1: string, key2: string): V | undefined {
|
|
9
|
+
if (map[key1]) {
|
|
10
|
+
return map[key1][key2];
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function getMap<V>(map: MapMap<V>, key: string): { [key: string]: V } | undefined {
|
|
16
|
+
return map[key];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function set<V>(map: MapMap<V>, key1: string, key2: string, value: V): void {
|
|
20
|
+
if (!map[key1]) {
|
|
21
|
+
map[key1] = Object.create(null);
|
|
22
|
+
}
|
|
23
|
+
map[key1][key2] = value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function setMap<V>(map: MapMap<V>, key: string, value: { [key: string]: V }): void {
|
|
27
|
+
map[key] = value;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function remove(map: MapMap<any>, key1: string, key2: string): boolean {
|
|
31
|
+
if (map[key1] && map[key1][key2]) {
|
|
32
|
+
delete map[key1][key2];
|
|
33
|
+
if (isEmptyObject(map[key1])) {
|
|
34
|
+
delete map[key1];
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function removeMap<V>(map: MapMap<V>, key: string): { [key: string]: V } | undefined {
|
|
42
|
+
if (map[key]) {
|
|
43
|
+
const result = map[key];
|
|
44
|
+
delete map[key];
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function keys(map: MapMap<any>): string[] {
|
|
51
|
+
const result: string[] = [];
|
|
52
|
+
if (map) {
|
|
53
|
+
// eslint-disable-next-line guard-for-in
|
|
54
|
+
for (const key in map) {
|
|
55
|
+
result.push(key);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Marker的严重程度
|
|
64
|
+
*/
|
|
65
|
+
export enum MarkerSeverity {
|
|
66
|
+
Hint = 1,
|
|
67
|
+
Info = 2,
|
|
68
|
+
Warning = 4,
|
|
69
|
+
Error = 8,
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export namespace MarkerSeverity {
|
|
73
|
+
export function compare(a: MarkerSeverity, b: MarkerSeverity): number {
|
|
74
|
+
return b - a;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const enum MarkerTag {
|
|
79
|
+
Unnecessary = 1,
|
|
80
|
+
Deprecated = 2,
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* diagnosis的相关信息
|
|
85
|
+
*/
|
|
86
|
+
export interface IRelatedInformation {
|
|
87
|
+
resource: string;
|
|
88
|
+
message: string;
|
|
89
|
+
startLineNumber: number;
|
|
90
|
+
startColumn: number;
|
|
91
|
+
endLineNumber: number;
|
|
92
|
+
endColumn: number;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* A structure defining a problem/warning/etc.
|
|
97
|
+
*/
|
|
98
|
+
export interface IMarkerData {
|
|
99
|
+
code?: string;
|
|
100
|
+
codeHref?: URI;
|
|
101
|
+
severity: MarkerSeverity;
|
|
102
|
+
message: string;
|
|
103
|
+
source?: string;
|
|
104
|
+
startLineNumber: number;
|
|
105
|
+
startColumn: number;
|
|
106
|
+
endLineNumber: number;
|
|
107
|
+
endColumn: number;
|
|
108
|
+
relatedInformation?: IRelatedInformation[];
|
|
109
|
+
tags?: MarkerTag[];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface IMarker extends IMarkerData {
|
|
113
|
+
type: string;
|
|
114
|
+
resource: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* marker 信息统计
|
|
119
|
+
*/
|
|
120
|
+
export interface MarkerStatistics {
|
|
121
|
+
errors: number;
|
|
122
|
+
warnings: number;
|
|
123
|
+
infos: number;
|
|
124
|
+
unknowns: number;
|
|
125
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export enum REPORT_NAME {
|
|
2
|
+
ACTIVE_EXTENSION = 'activateExtension',
|
|
3
|
+
RUNTIME_ERROR_EXTENSION = 'runtimeErrorExtension',
|
|
4
|
+
LOAD_EXTENSION_MAIN = 'loadExtensionMain',
|
|
5
|
+
PROVIDE_COMPLETION_ITEMS = 'provideCompletionItems',
|
|
6
|
+
RESOLVE_COMPLETION_ITEM = 'resolveCompletionItem',
|
|
7
|
+
PROVIDE_DOCUMENT_FORMATTING_EDITS = 'provideDocumentFormattingEdits',
|
|
8
|
+
PROVIDE_DOCUMENT_RANGE_FORMATTING_EDITS = 'provideDocumentRangeFormattingEdits',
|
|
9
|
+
EDITOR_REACTIVE = 'editorReactive',
|
|
10
|
+
CHANNEL_RECONNECT = 'channelReconnect',
|
|
11
|
+
MEASURE = 'measure',
|
|
12
|
+
FORMAT_ON_SAVE_TIMEOUT_ERROR = 'formatOnSaveTimeoutError',
|
|
13
|
+
FORMAT_ON_SAVE = 'formatOnSave',
|
|
14
|
+
NOT_FOUND_COMMAND = 'notFoundCommand',
|
|
15
|
+
INSTALL_EXTENSION_ERROR = 'installExtensionError',
|
|
16
|
+
EXTENSION_CRASH = 'extensionCrash',
|
|
17
|
+
EXTENSION_NOT_EXIST = 'extensionNotExist',
|
|
18
|
+
THEME_LOAD = 'themeLoad',
|
|
19
|
+
PROVIDE_HOVER = 'provideHover',
|
|
20
|
+
PROVIDE_DEFINITION = 'provideDefinition',
|
|
21
|
+
PROVIDE_TYPE_DEFINITION = 'provideTypeDefinition',
|
|
22
|
+
PROVIDE_FOLDING_RANGES = 'provideFoldingRanges',
|
|
23
|
+
PROVIDE_DOCUMENT_COLORS = 'provideDocumentColors',
|
|
24
|
+
PROVIDE_COLOR_PRESENTATIONS = 'provideColorPresentations',
|
|
25
|
+
PROVIDE_DOCUMENT_HIGHLIGHTS = 'provideDocumentHighlights',
|
|
26
|
+
PROVIDE_LINKS = 'provideLinks',
|
|
27
|
+
PROVIDE_REFERENCES = 'provideReferences',
|
|
28
|
+
PROVIDE_DOCUMENT_SYMBOLS = 'provideDocumentSymbols',
|
|
29
|
+
PROVIDE_IMPLEMENTATION = 'provideImplementation',
|
|
30
|
+
PROVIDE_CODE_ACTIONS = 'provideCodeActions',
|
|
31
|
+
PROVIDE_RENAME_EDITS = 'provideRenameEdits',
|
|
32
|
+
PROVIDE_SIGNATURE_HELP = 'provideSignatureHelp',
|
|
33
|
+
PROVIDE_CODE_LENSES = 'provideCodeLenses',
|
|
34
|
+
RESOLVE_CODE_LENS = 'resolveCodeLens',
|
|
35
|
+
PROVIDE_ON_TYPE_FORMATTING_EDITS = 'provideOnTypeFormattingEdits',
|
|
36
|
+
PROVIDE_SELECTION_RANGES = 'provideSelectionRanges',
|
|
37
|
+
TERMINAL_MEASURE = 'terminalMeasure',
|
|
38
|
+
SEARCH_MEASURE = 'searchMeasure',
|
|
39
|
+
QUICK_OPEN_MEASURE = 'quickOpenMeasure',
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export enum REPORT_HOST {
|
|
43
|
+
BROWSER = 'browser',
|
|
44
|
+
NODE = 'node',
|
|
45
|
+
WORKER = 'worker',
|
|
46
|
+
EXTENSION = 'extension',
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export enum REPORT_TYPE {
|
|
50
|
+
PERFORMANCE = 'performance',
|
|
51
|
+
POINT = 'point',
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const ReporterMetadata = Symbol('ReporterMetadata');
|
|
55
|
+
export interface ReporterMetadata {
|
|
56
|
+
extensionId?: string;
|
|
57
|
+
extensionVersion?: string;
|
|
58
|
+
host?: REPORT_HOST;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface PointData {
|
|
62
|
+
metadata?: ReporterMetadata;
|
|
63
|
+
extra?: any;
|
|
64
|
+
msg?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface PerformanceData extends PointData {
|
|
68
|
+
duration: number;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ide-framework 调用
|
|
72
|
+
export const IReporterService = Symbol('IReporterService');
|
|
73
|
+
|
|
74
|
+
export interface IReporterTimer {
|
|
75
|
+
timeEnd(msg?: string, extra?: any): number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface IReporterService {
|
|
79
|
+
time(name: REPORT_NAME | string): IReporterTimer;
|
|
80
|
+
point(name: REPORT_NAME | string, msg?: string, extra?: any): void;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 集成方实现
|
|
84
|
+
// 前端和后端各有一套实现
|
|
85
|
+
export const IReporter = Symbol('IReporter');
|
|
86
|
+
|
|
87
|
+
export interface IReporter {
|
|
88
|
+
performance(name: string, data: PerformanceData): void;
|
|
89
|
+
point(name: string, data: PointData): void;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface ReporterProcessMessage {
|
|
93
|
+
reportType: REPORT_TYPE;
|
|
94
|
+
name: string;
|
|
95
|
+
data: PerformanceData | PointData;
|
|
96
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@opensumi/ide-utils';
|
package/src/utils/ipc.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { tmpdir } from 'os';
|
|
2
|
+
import { join, dirname } from 'path';
|
|
3
|
+
|
|
4
|
+
import { ensureDirSync, ensureDir } from 'fs-extra';
|
|
5
|
+
|
|
6
|
+
import { isWindows, uuid } from '@opensumi/ide-utils';
|
|
7
|
+
|
|
8
|
+
export function normalizedIpcHandlerPath(name: string, uuidSuffix = false, ipcPath = tmpdir()) {
|
|
9
|
+
let handler: string;
|
|
10
|
+
if (!isWindows) {
|
|
11
|
+
handler = join(ipcPath, 'sumi-ipc', `sumi-ipc-${name}${uuidSuffix ? uuid() : ''}.sock`);
|
|
12
|
+
ensureDirSync(dirname(handler));
|
|
13
|
+
} else {
|
|
14
|
+
handler = `\\\\.\\pipe\\sumi-ipc-${name}${uuidSuffix ? uuid() : ''}`;
|
|
15
|
+
}
|
|
16
|
+
return handler;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function normalizedIpcHandlerPathAsync(name: string, uuidSuffix = false, ipcPath = tmpdir()) {
|
|
20
|
+
let handler: string;
|
|
21
|
+
if (!isWindows) {
|
|
22
|
+
handler = join(ipcPath, 'sumi-ipc', `sumi-ipc-${name}${uuidSuffix ? uuid() : ''}.sock`);
|
|
23
|
+
await ensureDir(dirname(handler));
|
|
24
|
+
} else {
|
|
25
|
+
handler = `\\\\.\\pipe\\sumi-ipc-${name}${uuidSuffix ? uuid() : ''}`;
|
|
26
|
+
}
|
|
27
|
+
return handler;
|
|
28
|
+
}
|