@difizen/libro-language-client 0.1.18
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/LICENSE +21 -0
- package/README.md +0 -0
- package/es/common/api.d.ts +38 -0
- package/es/common/api.d.ts.map +1 -0
- package/es/common/api.js +9 -0
- package/es/common/callHierarchy.d.ts +39 -0
- package/es/common/callHierarchy.d.ts.map +1 -0
- package/es/common/callHierarchy.js +139 -0
- package/es/common/client.d.ts +482 -0
- package/es/common/client.d.ts.map +1 -0
- package/es/common/client.js +2731 -0
- package/es/common/codeAction.d.ts +22 -0
- package/es/common/codeAction.d.ts.map +1 -0
- package/es/common/codeAction.js +149 -0
- package/es/common/codeConverter.d.ts +81 -0
- package/es/common/codeConverter.d.ts.map +1 -0
- package/es/common/codeConverter.js +1040 -0
- package/es/common/codeLens.d.ts +26 -0
- package/es/common/codeLens.d.ts.map +1 -0
- package/es/common/codeLens.js +125 -0
- package/es/common/colorProvider.d.ts +27 -0
- package/es/common/colorProvider.d.ts.map +1 -0
- package/es/common/colorProvider.js +104 -0
- package/es/common/completion.d.ts +22 -0
- package/es/common/completion.d.ts.map +1 -0
- package/es/common/completion.js +130 -0
- package/es/common/configuration.d.ts +71 -0
- package/es/common/configuration.d.ts.map +1 -0
- package/es/common/configuration.js +292 -0
- package/es/common/declaration.d.ts +18 -0
- package/es/common/declaration.d.ts.map +1 -0
- package/es/common/declaration.js +88 -0
- package/es/common/definition.d.ts +18 -0
- package/es/common/definition.d.ts.map +1 -0
- package/es/common/definition.js +80 -0
- package/es/common/diagnostic.d.ts +125 -0
- package/es/common/diagnostic.d.ts.map +1 -0
- package/es/common/diagnostic.js +1442 -0
- package/es/common/documentHighlight.d.ts +17 -0
- package/es/common/documentHighlight.d.ts.map +1 -0
- package/es/common/documentHighlight.js +73 -0
- package/es/common/documentLink.d.ts +21 -0
- package/es/common/documentLink.d.ts.map +1 -0
- package/es/common/documentLink.js +90 -0
- package/es/common/documentSymbol.d.ts +20 -0
- package/es/common/documentSymbol.d.ts.map +1 -0
- package/es/common/documentSymbol.js +134 -0
- package/es/common/executeCommand.d.ts +22 -0
- package/es/common/executeCommand.d.ts.map +1 -0
- package/es/common/executeCommand.js +117 -0
- package/es/common/features.d.ts +421 -0
- package/es/common/features.d.ts.map +1 -0
- package/es/common/features.js +576 -0
- package/es/common/fileOperations.d.ts +118 -0
- package/es/common/fileOperations.d.ts.map +1 -0
- package/es/common/fileOperations.js +705 -0
- package/es/common/fileSystemWatcher.d.ts +19 -0
- package/es/common/fileSystemWatcher.d.ts.map +1 -0
- package/es/common/fileSystemWatcher.js +173 -0
- package/es/common/foldingRange.d.ts +22 -0
- package/es/common/foldingRange.d.ts.map +1 -0
- package/es/common/foldingRange.js +127 -0
- package/es/common/formatting.d.ts +41 -0
- package/es/common/formatting.d.ts.map +1 -0
- package/es/common/formatting.js +233 -0
- package/es/common/hover.d.ts +18 -0
- package/es/common/hover.d.ts.map +1 -0
- package/es/common/hover.js +80 -0
- package/es/common/implementation.d.ts +18 -0
- package/es/common/implementation.d.ts.map +1 -0
- package/es/common/implementation.js +88 -0
- package/es/common/inlayHint.d.ts +23 -0
- package/es/common/inlayHint.d.ts.map +1 -0
- package/es/common/inlayHint.js +187 -0
- package/es/common/inlineCompletion.d.ts +20 -0
- package/es/common/inlineCompletion.d.ts.map +1 -0
- package/es/common/inlineCompletion.js +74 -0
- package/es/common/inlineValue.d.ts +21 -0
- package/es/common/inlineValue.d.ts.map +1 -0
- package/es/common/inlineValue.js +124 -0
- package/es/common/linkedEditingRange.d.ts +23 -0
- package/es/common/linkedEditingRange.d.ts.map +1 -0
- package/es/common/linkedEditingRange.js +94 -0
- package/es/common/notebook.d.ts +97 -0
- package/es/common/notebook.d.ts.map +1 -0
- package/es/common/notebook.js +1444 -0
- package/es/common/progress.d.ts +12 -0
- package/es/common/progress.d.ts.map +1 -0
- package/es/common/progress.js +75 -0
- package/es/common/progressPart.d.ts +25 -0
- package/es/common/progressPart.d.ts.map +1 -0
- package/es/common/progressPart.js +147 -0
- package/es/common/protocolCallHierarchyItem.d.ts +9 -0
- package/es/common/protocolCallHierarchyItem.d.ts.map +1 -0
- package/es/common/protocolCallHierarchyItem.js +34 -0
- package/es/common/protocolCodeAction.d.ts +7 -0
- package/es/common/protocolCodeAction.d.ts.map +1 -0
- package/es/common/protocolCodeAction.js +32 -0
- package/es/common/protocolCodeLens.d.ts +7 -0
- package/es/common/protocolCodeLens.d.ts.map +1 -0
- package/es/common/protocolCodeLens.js +29 -0
- package/es/common/protocolCompletionItem.d.ts +13 -0
- package/es/common/protocolCompletionItem.d.ts.map +1 -0
- package/es/common/protocolCompletionItem.js +29 -0
- package/es/common/protocolConverter.d.ts +174 -0
- package/es/common/protocolConverter.d.ts.map +1 -0
- package/es/common/protocolConverter.js +1982 -0
- package/es/common/protocolDiagnostic.d.ts +20 -0
- package/es/common/protocolDiagnostic.d.ts.map +1 -0
- package/es/common/protocolDiagnostic.js +46 -0
- package/es/common/protocolDocumentLink.d.ts +8 -0
- package/es/common/protocolDocumentLink.d.ts.map +1 -0
- package/es/common/protocolDocumentLink.js +29 -0
- package/es/common/protocolInlayHint.d.ts +8 -0
- package/es/common/protocolInlayHint.d.ts.map +1 -0
- package/es/common/protocolInlayHint.js +29 -0
- package/es/common/protocolTypeHierarchyItem.d.ts +9 -0
- package/es/common/protocolTypeHierarchyItem.d.ts.map +1 -0
- package/es/common/protocolTypeHierarchyItem.js +34 -0
- package/es/common/protocolWorkspaceSymbol.d.ts +9 -0
- package/es/common/protocolWorkspaceSymbol.d.ts.map +1 -0
- package/es/common/protocolWorkspaceSymbol.js +36 -0
- package/es/common/reference.d.ts +22 -0
- package/es/common/reference.d.ts.map +1 -0
- package/es/common/reference.js +78 -0
- package/es/common/rename.d.ts +29 -0
- package/es/common/rename.d.ts.map +1 -0
- package/es/common/rename.js +132 -0
- package/es/common/selectionRange.d.ts +18 -0
- package/es/common/selectionRange.d.ts.map +1 -0
- package/es/common/selectionRange.js +108 -0
- package/es/common/semanticTokens.d.ts +36 -0
- package/es/common/semanticTokens.d.ts.map +1 -0
- package/es/common/semanticTokens.js +226 -0
- package/es/common/signatureHelp.d.ts +18 -0
- package/es/common/signatureHelp.d.ts.map +1 -0
- package/es/common/signatureHelp.js +103 -0
- package/es/common/textSynchronization.d.ts +104 -0
- package/es/common/textSynchronization.d.ts.map +1 -0
- package/es/common/textSynchronization.js +771 -0
- package/es/common/typeDefinition.d.ts +18 -0
- package/es/common/typeDefinition.d.ts.map +1 -0
- package/es/common/typeDefinition.js +89 -0
- package/es/common/typeHierarchy.d.ts +33 -0
- package/es/common/typeHierarchy.d.ts.map +1 -0
- package/es/common/typeHierarchy.js +138 -0
- package/es/common/utils/async.d.ts +42 -0
- package/es/common/utils/async.d.ts.map +1 -0
- package/es/common/utils/async.js +441 -0
- package/es/common/utils/is.d.ts +13 -0
- package/es/common/utils/is.d.ts.map +1 -0
- package/es/common/utils/is.js +52 -0
- package/es/common/utils/uuid.d.ts +23 -0
- package/es/common/utils/uuid.d.ts.map +1 -0
- package/es/common/utils/uuid.js +85 -0
- package/es/common/vscodeAdaptor/convertor.d.ts +7 -0
- package/es/common/vscodeAdaptor/convertor.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/convertor.js +66 -0
- package/es/common/vscodeAdaptor/diagnosticCollection.d.ts +33 -0
- package/es/common/vscodeAdaptor/diagnosticCollection.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/diagnosticCollection.js +310 -0
- package/es/common/vscodeAdaptor/extHostTypes.d.ts +1496 -0
- package/es/common/vscodeAdaptor/extHostTypes.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/extHostTypes.js +3825 -0
- package/es/common/vscodeAdaptor/fileWatcher.d.ts +19 -0
- package/es/common/vscodeAdaptor/fileWatcher.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/fileWatcher.js +45 -0
- package/es/common/vscodeAdaptor/hostTypeUtil.d.ts +192 -0
- package/es/common/vscodeAdaptor/hostTypeUtil.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/hostTypeUtil.js +566 -0
- package/es/common/vscodeAdaptor/libro-fs.d.ts +21 -0
- package/es/common/vscodeAdaptor/libro-fs.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/libro-fs.js +64 -0
- package/es/common/vscodeAdaptor/libroWindow.d.ts +21 -0
- package/es/common/vscodeAdaptor/libroWindow.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/libroWindow.js +75 -0
- package/es/common/vscodeAdaptor/libroWorkspace.d.ts +33 -0
- package/es/common/vscodeAdaptor/libroWorkspace.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/libroWorkspace.js +250 -0
- package/es/common/vscodeAdaptor/lspEnv.d.ts +8 -0
- package/es/common/vscodeAdaptor/lspEnv.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/lspEnv.js +31 -0
- package/es/common/vscodeAdaptor/monaco-converter.d.ts +229 -0
- package/es/common/vscodeAdaptor/monaco-converter.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/monaco-converter.js +1613 -0
- package/es/common/vscodeAdaptor/monacoLanguages.d.ts +48 -0
- package/es/common/vscodeAdaptor/monacoLanguages.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/monacoLanguages.js +484 -0
- package/es/common/vscodeAdaptor/services.d.ts +85 -0
- package/es/common/vscodeAdaptor/services.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/services.js +3 -0
- package/es/common/vscodeAdaptor/typings.d.ts +10 -0
- package/es/common/vscodeAdaptor/util.d.ts +3 -0
- package/es/common/vscodeAdaptor/util.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/util.js +6 -0
- package/es/common/vscodeAdaptor/vscodeAdaptor.d.ts +77 -0
- package/es/common/vscodeAdaptor/vscodeAdaptor.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/vscodeAdaptor.js +124 -0
- package/es/common/workspaceFolder.d.ts +32 -0
- package/es/common/workspaceFolder.d.ts.map +1 -0
- package/es/common/workspaceFolder.js +204 -0
- package/es/common/workspaceSymbol.d.ts +21 -0
- package/es/common/workspaceSymbol.d.ts.map +1 -0
- package/es/common/workspaceSymbol.js +101 -0
- package/es/constants.d.ts +2 -0
- package/es/constants.d.ts.map +1 -0
- package/es/constants.js +1 -0
- package/es/index.d.ts +6 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +5 -0
- package/es/libro-language-client-contribution.d.ts +10 -0
- package/es/libro-language-client-contribution.d.ts.map +1 -0
- package/es/libro-language-client-contribution.js +143 -0
- package/es/libro-language-client-manager.d.ts +34 -0
- package/es/libro-language-client-manager.d.ts.map +1 -0
- package/es/libro-language-client-manager.js +277 -0
- package/es/libro-language-client.d.ts +27 -0
- package/es/libro-language-client.d.ts.map +1 -0
- package/es/libro-language-client.js +141 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +13 -0
- package/package.json +69 -0
- package/src/common/api.ts +155 -0
- package/src/common/callHierarchy.ts +269 -0
- package/src/common/client.ts +3192 -0
- package/src/common/codeAction.ts +237 -0
- package/src/common/codeConverter.ts +1409 -0
- package/src/common/codeLens.ts +188 -0
- package/src/common/colorProvider.ts +192 -0
- package/src/common/completion.ts +281 -0
- package/src/common/configuration.ts +338 -0
- package/src/common/declaration.ts +140 -0
- package/src/common/definition.ts +138 -0
- package/src/common/diagnostic.ts +1408 -0
- package/src/common/documentHighlight.ts +140 -0
- package/src/common/documentLink.ts +180 -0
- package/src/common/documentSymbol.ts +186 -0
- package/src/common/executeCommand.ts +129 -0
- package/src/common/features.ts +1157 -0
- package/src/common/fileOperations.ts +635 -0
- package/src/common/fileSystemWatcher.ts +184 -0
- package/src/common/foldingRange.ts +160 -0
- package/src/common/formatting.ts +465 -0
- package/src/common/hover.ts +133 -0
- package/src/common/implementation.ts +142 -0
- package/src/common/inlayHint.ts +201 -0
- package/src/common/inlineCompletion.ts +160 -0
- package/src/common/inlineValue.ts +158 -0
- package/src/common/linkedEditingRange.ts +141 -0
- package/src/common/notebook.ts +1443 -0
- package/src/common/progress.ts +61 -0
- package/src/common/progressPart.ts +151 -0
- package/src/common/protocolCallHierarchyItem.ts +29 -0
- package/src/common/protocolCodeAction.ts +17 -0
- package/src/common/protocolCodeLens.ts +15 -0
- package/src/common/protocolCompletionItem.ts +22 -0
- package/src/common/protocolConverter.ts +2627 -0
- package/src/common/protocolDiagnostic.ts +47 -0
- package/src/common/protocolDocumentLink.ts +17 -0
- package/src/common/protocolInlayHint.ts +21 -0
- package/src/common/protocolTypeHierarchyItem.ts +29 -0
- package/src/common/protocolWorkspaceSymbol.ts +39 -0
- package/src/common/reference.ts +144 -0
- package/src/common/rename.ts +230 -0
- package/src/common/selectionRange.ts +136 -0
- package/src/common/semanticTokens.ts +383 -0
- package/src/common/signatureHelp.ts +170 -0
- package/src/common/textSynchronization.ts +819 -0
- package/src/common/typeDefinition.ts +146 -0
- package/src/common/typeHierarchy.ts +248 -0
- package/src/common/utils/async.ts +354 -0
- package/src/common/utils/is.ts +63 -0
- package/src/common/utils/uuid.ts +136 -0
- package/src/common/vscodeAdaptor/convertor.ts +73 -0
- package/src/common/vscodeAdaptor/diagnosticCollection.ts +238 -0
- package/src/common/vscodeAdaptor/extHostTypes.ts +4498 -0
- package/src/common/vscodeAdaptor/fileWatcher.ts +36 -0
- package/src/common/vscodeAdaptor/hostTypeUtil.ts +539 -0
- package/src/common/vscodeAdaptor/libro-fs.ts +51 -0
- package/src/common/vscodeAdaptor/libroWindow.ts +85 -0
- package/src/common/vscodeAdaptor/libroWorkspace.ts +261 -0
- package/src/common/vscodeAdaptor/lspEnv.ts +16 -0
- package/src/common/vscodeAdaptor/monaco-converter.ts +1800 -0
- package/src/common/vscodeAdaptor/monacoLanguages.ts +511 -0
- package/src/common/vscodeAdaptor/services.ts +278 -0
- package/src/common/vscodeAdaptor/typings.d.ts +10 -0
- package/src/common/vscodeAdaptor/util.ts +7 -0
- package/src/common/vscodeAdaptor/vscodeAdaptor.ts +122 -0
- package/src/common/workspaceFolder.ts +236 -0
- package/src/common/workspaceSymbol.ts +166 -0
- package/src/constants.ts +1 -0
- package/src/index.spec.ts +7 -0
- package/src/index.ts +5 -0
- package/src/libro-language-client-contribution.ts +49 -0
- package/src/libro-language-client-manager.ts +131 -0
- package/src/libro-language-client.ts +100 -0
- package/src/module.ts +19 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { MarkerSeverity } from '@difizen/monaco-editor-core';
|
|
2
|
+
import * as monaco from '@difizen/monaco-editor-core';
|
|
3
|
+
import type { editor } from '@difizen/monaco-editor-core';
|
|
4
|
+
import type { DiagnosticCollection } from 'vscode';
|
|
5
|
+
import type { Diagnostic, Uri } from 'vscode';
|
|
6
|
+
import { URI } from 'vscode-uri';
|
|
7
|
+
|
|
8
|
+
import * as c2p from '../codeConverter.js';
|
|
9
|
+
import { generateUuid } from '../utils/uuid.js';
|
|
10
|
+
|
|
11
|
+
import { ResourceMap } from './hostTypeUtil.js';
|
|
12
|
+
import { ProtocolToMonacoConverter } from './monaco-converter.js';
|
|
13
|
+
import { DiagnosticSeverity, EventEmitter } from './vscodeAdaptor.js';
|
|
14
|
+
|
|
15
|
+
export class LibroDiagnosticCollection implements DiagnosticCollection {
|
|
16
|
+
#onDidChangeDiagnostics = new EventEmitter<Uri[]>();
|
|
17
|
+
readonly onDidChangeDiagnostics = this.#onDidChangeDiagnostics.event;
|
|
18
|
+
|
|
19
|
+
private readonly _maxDiagnosticsPerFile: number = 1000;
|
|
20
|
+
private readonly _maxDiagnosticsTotal: number = 1.1 * this._maxDiagnosticsPerFile;
|
|
21
|
+
protected readonly c2p: c2p.Converter = c2p.createConverter();
|
|
22
|
+
protected readonly p2m: ProtocolToMonacoConverter = new ProtocolToMonacoConverter(
|
|
23
|
+
monaco,
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
name: string;
|
|
27
|
+
constructor(name?: string) {
|
|
28
|
+
this.name = name ?? `libro-marker-${generateUuid()}`;
|
|
29
|
+
}
|
|
30
|
+
readonly #data: ResourceMap<Diagnostic[]> = new ResourceMap();
|
|
31
|
+
private _isDisposed = false;
|
|
32
|
+
set(uri: Uri, diagnostics: ReadonlyArray<Diagnostic>): void;
|
|
33
|
+
set(entries: ReadonlyArray<[Uri, ReadonlyArray<Diagnostic>]>): void;
|
|
34
|
+
set(
|
|
35
|
+
first: Uri | ReadonlyArray<[Uri, ReadonlyArray<Diagnostic>]>,
|
|
36
|
+
diagnostics?: ReadonlyArray<Diagnostic>,
|
|
37
|
+
) {
|
|
38
|
+
if (!first) {
|
|
39
|
+
// this set-call is a clear-call
|
|
40
|
+
this.clear();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// the actual implementation for #set
|
|
45
|
+
|
|
46
|
+
this._checkDisposed();
|
|
47
|
+
let toSync: Uri[] = [];
|
|
48
|
+
|
|
49
|
+
if (URI.isUri(first)) {
|
|
50
|
+
if (!diagnostics) {
|
|
51
|
+
// remove this entry
|
|
52
|
+
this.delete(first);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// update single row
|
|
57
|
+
this.#data.set(first, diagnostics.slice());
|
|
58
|
+
toSync = [first];
|
|
59
|
+
} else if (Array.isArray(first)) {
|
|
60
|
+
// update many rows
|
|
61
|
+
toSync = [];
|
|
62
|
+
let lastUri: Uri | undefined;
|
|
63
|
+
|
|
64
|
+
// ensure stable-sort
|
|
65
|
+
first = [...first].sort(LibroDiagnosticCollection._compareIndexedTuplesByUri);
|
|
66
|
+
|
|
67
|
+
for (const tuple of first) {
|
|
68
|
+
const [uri, diagnostics] = tuple;
|
|
69
|
+
if (!lastUri || uri.toString() !== lastUri.toString()) {
|
|
70
|
+
if (lastUri && this.#data.get(lastUri)!.length === 0) {
|
|
71
|
+
this.#data.delete(lastUri);
|
|
72
|
+
}
|
|
73
|
+
lastUri = uri;
|
|
74
|
+
toSync.push(uri);
|
|
75
|
+
this.#data.set(uri, []);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!diagnostics) {
|
|
79
|
+
// [Uri, undefined] means clear this
|
|
80
|
+
const currentDiagnostics = this.#data.get(uri);
|
|
81
|
+
if (currentDiagnostics) {
|
|
82
|
+
currentDiagnostics.length = 0;
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
const currentDiagnostics = this.#data.get(uri);
|
|
86
|
+
currentDiagnostics?.push(...diagnostics);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// send event for extensions
|
|
92
|
+
this.#onDidChangeDiagnostics.fire(toSync);
|
|
93
|
+
|
|
94
|
+
// // compute change and send to main side
|
|
95
|
+
// if (!this.#proxy) {
|
|
96
|
+
// return;
|
|
97
|
+
// }
|
|
98
|
+
const entries: [URI, editor.IMarkerData[]][] = [];
|
|
99
|
+
let totalMarkerCount = 0;
|
|
100
|
+
for (const uri of toSync) {
|
|
101
|
+
let marker: editor.IMarkerData[] = [];
|
|
102
|
+
const diagnostics = this.#data.get(uri);
|
|
103
|
+
if (diagnostics) {
|
|
104
|
+
// no more than N diagnostics per file
|
|
105
|
+
if (diagnostics.length > this._maxDiagnosticsPerFile) {
|
|
106
|
+
marker = [];
|
|
107
|
+
const order = [
|
|
108
|
+
DiagnosticSeverity.Error,
|
|
109
|
+
DiagnosticSeverity.Warning,
|
|
110
|
+
DiagnosticSeverity.Information,
|
|
111
|
+
DiagnosticSeverity.Hint,
|
|
112
|
+
];
|
|
113
|
+
orderLoop: for (let i = 0; i < 4; i++) {
|
|
114
|
+
for (const diagnostic of diagnostics) {
|
|
115
|
+
if (diagnostic.severity === order[i]) {
|
|
116
|
+
const diag = this.p2m.asDiagnostic(this.c2p.asDiagnostic(diagnostic));
|
|
117
|
+
const len = marker.push(diag);
|
|
118
|
+
if (len === this._maxDiagnosticsPerFile) {
|
|
119
|
+
break orderLoop;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// add 'signal' marker for showing omitted errors/warnings
|
|
126
|
+
marker.push({
|
|
127
|
+
severity: MarkerSeverity.Info,
|
|
128
|
+
message: `Not showing ${diagnostics.length - this._maxDiagnosticsPerFile} further errors and warnings.`,
|
|
129
|
+
startLineNumber: marker[marker.length - 1].startLineNumber,
|
|
130
|
+
startColumn: marker[marker.length - 1].startColumn,
|
|
131
|
+
endLineNumber: marker[marker.length - 1].endLineNumber,
|
|
132
|
+
endColumn: marker[marker.length - 1].endColumn,
|
|
133
|
+
});
|
|
134
|
+
} else {
|
|
135
|
+
marker = diagnostics.map((diag) => {
|
|
136
|
+
const mark = this.p2m.asDiagnostic(this.c2p.asDiagnostic(diag));
|
|
137
|
+
return mark;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
entries.push([uri, marker]);
|
|
143
|
+
|
|
144
|
+
// update monaco
|
|
145
|
+
this.updateModelMarkers(uri, marker);
|
|
146
|
+
|
|
147
|
+
totalMarkerCount += marker.length;
|
|
148
|
+
if (totalMarkerCount > this._maxDiagnosticsTotal) {
|
|
149
|
+
// ignore markers that are above the limit
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
delete(uri: Uri): void {
|
|
156
|
+
this._checkDisposed();
|
|
157
|
+
this.#onDidChangeDiagnostics.fire([uri]);
|
|
158
|
+
this.#data.delete(uri);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
clear(): void {
|
|
162
|
+
this._checkDisposed();
|
|
163
|
+
this.#onDidChangeDiagnostics.fire([...this.#data.keys()]);
|
|
164
|
+
this.#data.clear();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
forEach(
|
|
168
|
+
callback: (
|
|
169
|
+
uri: URI,
|
|
170
|
+
diagnostics: ReadonlyArray<Diagnostic>,
|
|
171
|
+
collection: DiagnosticCollection,
|
|
172
|
+
) => any,
|
|
173
|
+
thisArg?: any,
|
|
174
|
+
): void {
|
|
175
|
+
this._checkDisposed();
|
|
176
|
+
for (const [uri, values] of this) {
|
|
177
|
+
callback.call(thisArg, uri, values, this);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
*[Symbol.iterator](): IterableIterator<
|
|
182
|
+
[uri: Uri, diagnostics: readonly Diagnostic[]]
|
|
183
|
+
> {
|
|
184
|
+
this._checkDisposed();
|
|
185
|
+
for (const uri of this.#data.keys()) {
|
|
186
|
+
yield [uri, this.get(uri)];
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
get(uri: URI): ReadonlyArray<Diagnostic> {
|
|
191
|
+
this._checkDisposed();
|
|
192
|
+
const result = this.#data.get(uri);
|
|
193
|
+
if (Array.isArray(result)) {
|
|
194
|
+
return Object.freeze(result.slice(0));
|
|
195
|
+
}
|
|
196
|
+
return [];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
has(uri: URI): boolean {
|
|
200
|
+
this._checkDisposed();
|
|
201
|
+
return Array.isArray(this.#data.get(uri));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
private _checkDisposed() {
|
|
205
|
+
if (this._isDisposed) {
|
|
206
|
+
throw new Error('illegal state - object is disposed');
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
private static _compareIndexedTuplesByUri(
|
|
211
|
+
a: [Uri, readonly Diagnostic[]],
|
|
212
|
+
b: [Uri, readonly Diagnostic[]],
|
|
213
|
+
): number {
|
|
214
|
+
if (a[0].toString() < b[0].toString()) {
|
|
215
|
+
return -1;
|
|
216
|
+
} else if (a[0].toString() > b[0].toString()) {
|
|
217
|
+
return 1;
|
|
218
|
+
} else {
|
|
219
|
+
return 0;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
updateModelMarkers(uri: Uri, markers: editor.IMarkerData[]): void {
|
|
224
|
+
const model = monaco.editor.getModel(uri);
|
|
225
|
+
if (model) {
|
|
226
|
+
monaco.editor.setModelMarkers(model, this.name, []);
|
|
227
|
+
monaco.editor.setModelMarkers(model, this.name, markers);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
dispose(): void {
|
|
232
|
+
if (!this._isDisposed) {
|
|
233
|
+
this.#onDidChangeDiagnostics.fire([...this.#data.keys()]);
|
|
234
|
+
this.#data.clear();
|
|
235
|
+
this._isDisposed = true;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|