@codingame/monaco-languageclient-wrapper 5.0.0-next.0 → 5.0.0-next.1
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/dist/_virtual/_commonjsHelpers.js +32 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.js +50 -0
- package/dist/_virtual/_vscode.js +4 -0
- package/dist/_virtual/api.js +2 -0
- package/dist/_virtual/api2.js +2 -0
- package/dist/_virtual/api3.js +2 -0
- package/dist/_virtual/async.js +2 -0
- package/dist/_virtual/callHierarchy.js +2 -0
- package/dist/_virtual/cancellation.js +2 -0
- package/dist/_virtual/client.js +2 -0
- package/dist/_virtual/codeAction.js +2 -0
- package/dist/_virtual/codeConverter.js +2 -0
- package/dist/_virtual/codeLens.js +2 -0
- package/dist/_virtual/colorProvider.js +2 -0
- package/dist/_virtual/completion.js +2 -0
- package/dist/_virtual/configuration.js +2 -0
- package/dist/_virtual/connection.js +2 -0
- package/dist/_virtual/connection2.js +2 -0
- package/dist/_virtual/declaration.js +2 -0
- package/dist/_virtual/definition.js +2 -0
- package/dist/_virtual/diagnostic.js +2 -0
- package/dist/_virtual/disposable.js +2 -0
- package/dist/_virtual/documentHighlight.js +2 -0
- package/dist/_virtual/documentLink.js +2 -0
- package/dist/_virtual/documentSymbol.js +2 -0
- package/dist/_virtual/events.js +2 -0
- package/dist/_virtual/executeCommand.js +2 -0
- package/dist/_virtual/features.js +2 -0
- package/dist/_virtual/fileOperations.js +2 -0
- package/dist/_virtual/fileSystemWatcher.js +2 -0
- package/dist/_virtual/foldingRange.js +2 -0
- package/dist/_virtual/formatting.js +2 -0
- package/dist/_virtual/hover.js +2 -0
- package/dist/_virtual/implementation.js +2 -0
- package/dist/_virtual/inlayHint.js +2 -0
- package/dist/_virtual/inlineValue.js +2 -0
- package/dist/_virtual/is.js +2 -0
- package/dist/_virtual/is2.js +2 -0
- package/dist/_virtual/is3.js +2 -0
- package/dist/_virtual/linkedEditingRange.js +2 -0
- package/dist/_virtual/linkedMap.js +2 -0
- package/dist/_virtual/main.js +2 -0
- package/dist/_virtual/main2.js +2 -0
- package/dist/_virtual/main3.js +2 -0
- package/dist/_virtual/main4.js +4 -0
- package/dist/_virtual/messageBuffer.js +2 -0
- package/dist/_virtual/messageReader.js +2 -0
- package/dist/_virtual/messageWriter.js +2 -0
- package/dist/_virtual/messages.js +2 -0
- package/dist/_virtual/messages2.js +2 -0
- package/dist/_virtual/notebook.js +2 -0
- package/dist/_virtual/once.js +2 -0
- package/dist/_virtual/path.js +4 -0
- package/dist/_virtual/progress.js +2 -0
- package/dist/_virtual/progressPart.js +2 -0
- package/dist/_virtual/protocol.callHierarchy.js +2 -0
- package/dist/_virtual/protocol.colorProvider.js +2 -0
- package/dist/_virtual/protocol.configuration.js +2 -0
- package/dist/_virtual/protocol.declaration.js +2 -0
- package/dist/_virtual/protocol.diagnostic.js +2 -0
- package/dist/_virtual/protocol.fileOperations.js +2 -0
- package/dist/_virtual/protocol.foldingRange.js +2 -0
- package/dist/_virtual/protocol.implementation.js +2 -0
- package/dist/_virtual/protocol.inlayHint.js +2 -0
- package/dist/_virtual/protocol.inlineValue.js +2 -0
- package/dist/_virtual/protocol.js +2 -0
- package/dist/_virtual/protocol.linkedEditingRange.js +2 -0
- package/dist/_virtual/protocol.moniker.js +2 -0
- package/dist/_virtual/protocol.notebook.js +2 -0
- package/dist/_virtual/protocol.progress.js +2 -0
- package/dist/_virtual/protocol.selectionRange.js +2 -0
- package/dist/_virtual/protocol.semanticTokens.js +2 -0
- package/dist/_virtual/protocol.showDocument.js +2 -0
- package/dist/_virtual/protocol.typeDefinition.js +2 -0
- package/dist/_virtual/protocol.typeHierarchy.js +2 -0
- package/dist/_virtual/protocol.workspaceFolder.js +2 -0
- package/dist/_virtual/protocolCallHierarchyItem.js +2 -0
- package/dist/_virtual/protocolCodeAction.js +2 -0
- package/dist/_virtual/protocolCodeLens.js +2 -0
- package/dist/_virtual/protocolCompletionItem.js +2 -0
- package/dist/_virtual/protocolConverter.js +2 -0
- package/dist/_virtual/protocolDiagnostic.js +2 -0
- package/dist/_virtual/protocolDocumentLink.js +2 -0
- package/dist/_virtual/protocolInlayHint.js +2 -0
- package/dist/_virtual/protocolTypeHierarchyItem.js +2 -0
- package/dist/_virtual/protocolWorkspaceSymbol.js +2 -0
- package/dist/_virtual/ral.js +2 -0
- package/dist/_virtual/reference.js +2 -0
- package/dist/_virtual/rename.js +2 -0
- package/dist/_virtual/ril.js +2 -0
- package/dist/_virtual/selectionRange.js +2 -0
- package/dist/_virtual/semanticTokens.js +2 -0
- package/dist/_virtual/semaphore.js +2 -0
- package/dist/_virtual/sharedArrayCancellation.js +2 -0
- package/dist/_virtual/signatureHelp.js +2 -0
- package/dist/_virtual/textSynchronization.js +2 -0
- package/dist/_virtual/typeDefinition.js +2 -0
- package/dist/_virtual/typeHierarchy.js +2 -0
- package/dist/_virtual/uuid.js +2 -0
- package/dist/_virtual/workspaceFolder.js +2 -0
- package/dist/_virtual/workspaceSymbol.js +2 -0
- package/dist/extensions/java/commands.js +74 -0
- package/dist/extensions/java/extension.js +13 -0
- package/dist/extensions/java/inlayHintsProvider.js +59 -0
- package/dist/extensions/java/protocol.js +69 -0
- package/dist/{java.js → extensions/java/sourceAction.js} +6 -244
- package/dist/index.d.ts +1 -2
- package/dist/index.js +5 -1
- package/dist/node_modules/balanced-match/index.js +52 -0
- package/dist/node_modules/delay/index.js +46 -0
- package/dist/node_modules/monaco-languageclient/lib/monaco-language-client.js +127 -0
- package/dist/node_modules/once/once.js +44 -0
- package/dist/node_modules/tslib/tslib.es6.js +14 -0
- package/dist/node_modules/vscode-jsonrpc/browser.js +4 -0
- package/dist/node_modules/vscode-jsonrpc/lib/browser/main.js +77 -0
- package/dist/node_modules/vscode-jsonrpc/lib/browser/ril.js +153 -0
- package/dist/node_modules/vscode-jsonrpc/lib/common/api.js +96 -0
- package/dist/node_modules/vscode-jsonrpc/lib/common/cancellation.js +97 -0
- package/dist/node_modules/vscode-jsonrpc/lib/common/connection.js +1180 -0
- package/dist/node_modules/vscode-jsonrpc/lib/common/disposable.js +20 -0
- package/dist/node_modules/vscode-jsonrpc/lib/common/events.js +122 -0
- package/dist/node_modules/vscode-jsonrpc/lib/common/is.js +38 -0
- package/dist/node_modules/vscode-jsonrpc/lib/common/linkedMap.js +388 -0
- package/dist/node_modules/vscode-jsonrpc/lib/common/messageBuffer.js +149 -0
- package/dist/node_modules/vscode-jsonrpc/lib/common/messageReader.js +194 -0
- package/dist/node_modules/vscode-jsonrpc/lib/common/messageWriter.js +123 -0
- package/dist/node_modules/vscode-jsonrpc/lib/common/messages.js +241 -0
- package/dist/node_modules/vscode-jsonrpc/lib/common/ral.js +26 -0
- package/dist/node_modules/vscode-jsonrpc/lib/common/semaphore.js +72 -0
- package/dist/node_modules/vscode-jsonrpc/lib/common/sharedArrayCancellation.js +80 -0
- package/dist/node_modules/vscode-languageclient/lib/browser/main.js +49 -0
- package/dist/node_modules/vscode-languageclient/lib/common/api.js +51 -0
- package/dist/node_modules/vscode-languageclient/lib/common/callHierarchy.js +98 -0
- package/dist/node_modules/vscode-languageclient/lib/common/client.js +1527 -0
- package/dist/node_modules/vscode-languageclient/lib/common/codeAction.js +92 -0
- package/dist/node_modules/vscode-languageclient/lib/common/codeConverter.js +881 -0
- package/dist/node_modules/vscode-languageclient/lib/common/codeLens.js +84 -0
- package/dist/node_modules/vscode-languageclient/lib/common/colorProvider.js +77 -0
- package/dist/node_modules/vscode-languageclient/lib/common/completion.js +105 -0
- package/dist/node_modules/vscode-languageclient/lib/common/configuration.js +214 -0
- package/dist/node_modules/vscode-languageclient/lib/common/declaration.js +59 -0
- package/dist/node_modules/vscode-languageclient/lib/common/definition.js +62 -0
- package/dist/node_modules/vscode-languageclient/lib/common/diagnostic.js +839 -0
- package/dist/node_modules/vscode-languageclient/lib/common/documentHighlight.js +57 -0
- package/dist/node_modules/vscode-languageclient/lib/common/documentLink.js +74 -0
- package/dist/node_modules/vscode-languageclient/lib/common/documentSymbol.js +82 -0
- package/dist/node_modules/vscode-languageclient/lib/common/executeCommand.js +83 -0
- package/dist/node_modules/vscode-languageclient/lib/common/features.js +310 -0
- package/dist/node_modules/vscode-languageclient/lib/common/fileOperations.js +319 -0
- package/dist/node_modules/vscode-languageclient/lib/common/fileSystemWatcher.js +104 -0
- package/dist/node_modules/vscode-languageclient/lib/common/foldingRange.js +66 -0
- package/dist/node_modules/vscode-languageclient/lib/common/formatting.js +165 -0
- package/dist/node_modules/vscode-languageclient/lib/common/hover.js +62 -0
- package/dist/node_modules/vscode-languageclient/lib/common/implementation.js +59 -0
- package/dist/node_modules/vscode-languageclient/lib/common/inlayHint.js +94 -0
- package/dist/node_modules/vscode-languageclient/lib/common/inlineValue.js +73 -0
- package/dist/node_modules/vscode-languageclient/lib/common/linkedEditingRange.js +58 -0
- package/dist/node_modules/vscode-languageclient/lib/common/notebook.js +858 -0
- package/dist/node_modules/vscode-languageclient/lib/common/progress.js +51 -0
- package/dist/node_modules/vscode-languageclient/lib/common/progressPart.js +107 -0
- package/dist/node_modules/vscode-languageclient/lib/common/protocolCallHierarchyItem.js +15 -0
- package/dist/node_modules/vscode-languageclient/lib/common/protocolCodeAction.js +13 -0
- package/dist/node_modules/vscode-languageclient/lib/common/protocolCodeLens.js +12 -0
- package/dist/node_modules/vscode-languageclient/lib/common/protocolCompletionItem.js +12 -0
- package/dist/node_modules/vscode-languageclient/lib/common/protocolConverter.js +1129 -0
- package/dist/node_modules/vscode-languageclient/lib/common/protocolDiagnostic.js +27 -0
- package/dist/node_modules/vscode-languageclient/lib/common/protocolDocumentLink.js +12 -0
- package/dist/node_modules/vscode-languageclient/lib/common/protocolInlayHint.js +12 -0
- package/dist/node_modules/vscode-languageclient/lib/common/protocolTypeHierarchyItem.js +15 -0
- package/dist/node_modules/vscode-languageclient/lib/common/protocolWorkspaceSymbol.js +17 -0
- package/dist/node_modules/vscode-languageclient/lib/common/reference.js +60 -0
- package/dist/node_modules/vscode-languageclient/lib/common/rename.js +112 -0
- package/dist/node_modules/vscode-languageclient/lib/common/selectionRange.js +62 -0
- package/dist/node_modules/vscode-languageclient/lib/common/semanticTokens.js +144 -0
- package/dist/node_modules/vscode-languageclient/lib/common/signatureHelp.js +78 -0
- package/dist/node_modules/vscode-languageclient/lib/common/textSynchronization.js +422 -0
- package/dist/node_modules/vscode-languageclient/lib/common/typeDefinition.js +60 -0
- package/dist/node_modules/vscode-languageclient/lib/common/typeHierarchy.js +97 -0
- package/dist/node_modules/vscode-languageclient/lib/common/utils/async.js +269 -0
- package/dist/node_modules/vscode-languageclient/lib/common/utils/is.js +54 -0
- package/dist/node_modules/vscode-languageclient/lib/common/utils/uuid.js +51 -0
- package/dist/node_modules/vscode-languageclient/lib/common/workspaceFolder.js +154 -0
- package/dist/node_modules/vscode-languageclient/lib/common/workspaceSymbol.js +87 -0
- package/dist/node_modules/vscode-languageclient/node_modules/brace-expansion/index.js +160 -0
- package/dist/node_modules/vscode-languageclient/node_modules/minimatch/lib/path.js +2 -0
- package/dist/node_modules/vscode-languageclient/node_modules/minimatch/minimatch.js +567 -0
- package/dist/node_modules/vscode-languageserver-protocol/browser.js +4 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/browser/main.js +30 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/api.js +43 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/connection.js +14 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/messages.js +43 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.callHierarchy.js +23 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.colorProvider.js +18 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.configuration.js +13 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.declaration.js +13 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.diagnostic.js +42 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.fileOperations.js +42 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.foldingRange.js +13 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.implementation.js +13 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.inlayHint.js +23 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.inlineValue.js +18 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.js +494 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.linkedEditingRange.js +13 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.moniker.js +25 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.notebook.js +185 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.progress.js +28 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.selectionRange.js +13 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.semanticTokens.js +39 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.showDocument.js +13 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.typeDefinition.js +13 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.typeHierarchy.js +23 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.workspaceFolder.js +18 -0
- package/dist/node_modules/vscode-languageserver-protocol/lib/common/utils/is.js +40 -0
- package/dist/node_modules/vscode-languageserver-types/lib/esm/main.js +1583 -0
- package/dist/node_modules/wrappy/wrappy.js +25 -0
- package/dist/src/createLanguageClient.js +107 -0
- package/dist/src/customRequests.js +21 -0
- package/dist/src/extensionConfiguration.js +5 -0
- package/dist/{cobol.js → src/extensions/cobol.js} +3 -2
- package/dist/{csharp.js → src/extensions/csharp.js} +3 -2
- package/dist/src/extensions/java.js +36 -0
- package/dist/{tools.js → src/extensions/tools.js} +2 -2
- package/dist/src/extensions.js +170 -0
- package/dist/src/infrastructure.js +68 -0
- package/dist/src/languageClient.js +308 -0
- package/dist/src/languageClientOptions.js +17 -0
- package/dist/src/services.js +8 -0
- package/dist/src/staticOptions.js +441 -0
- package/package.json +31 -32
- package/stats.html +1 -1
- package/dist/index2.js +0 -17150
|
@@ -0,0 +1,839 @@
|
|
|
1
|
+
import { __exports as diagnostic } from '../../../../_virtual/diagnostic.js';
|
|
2
|
+
import require$$0 from '../../../../_virtual/_vscode.js';
|
|
3
|
+
import { __exports as main } from '../../../../_virtual/main.js';
|
|
4
|
+
import '../../../vscode-languageserver-protocol/lib/browser/main.js';
|
|
5
|
+
import { __exports as features } from '../../../../_virtual/features.js';
|
|
6
|
+
import './features.js';
|
|
7
|
+
import { m as minimatch_1 } from '../../node_modules/minimatch/minimatch.js';
|
|
8
|
+
import { __exports as uuid } from '../../../../_virtual/uuid.js';
|
|
9
|
+
import './utils/uuid.js';
|
|
10
|
+
(function (exports) {
|
|
11
|
+
Object.defineProperty(exports, "__esModule", {
|
|
12
|
+
value: true
|
|
13
|
+
});
|
|
14
|
+
exports.DiagnosticFeature = exports.DiagnosticPullMode = exports.vsdiag = void 0;
|
|
15
|
+
const minimatch = minimatch_1;
|
|
16
|
+
const vscode_1 = require$$0;
|
|
17
|
+
const vscode_languageserver_protocol_1 = main;
|
|
18
|
+
const uuid_1 = uuid;
|
|
19
|
+
const features_1 = features;
|
|
20
|
+
function ensure(target, key) {
|
|
21
|
+
if (target[key] === void 0) {
|
|
22
|
+
target[key] = {};
|
|
23
|
+
}
|
|
24
|
+
return target[key];
|
|
25
|
+
}
|
|
26
|
+
var vsdiag;
|
|
27
|
+
(function (vsdiag) {
|
|
28
|
+
(function (DocumentDiagnosticReportKind) {
|
|
29
|
+
DocumentDiagnosticReportKind["full"] = "full";
|
|
30
|
+
DocumentDiagnosticReportKind["unChanged"] = "unChanged";
|
|
31
|
+
})(vsdiag.DocumentDiagnosticReportKind || (vsdiag.DocumentDiagnosticReportKind = {}));
|
|
32
|
+
})(vsdiag = exports.vsdiag || (exports.vsdiag = {}));
|
|
33
|
+
var DiagnosticPullMode;
|
|
34
|
+
(function (DiagnosticPullMode) {
|
|
35
|
+
DiagnosticPullMode["onType"] = "onType";
|
|
36
|
+
DiagnosticPullMode["onSave"] = "onSave";
|
|
37
|
+
})(DiagnosticPullMode = exports.DiagnosticPullMode || (exports.DiagnosticPullMode = {}));
|
|
38
|
+
var RequestStateKind;
|
|
39
|
+
(function (RequestStateKind) {
|
|
40
|
+
RequestStateKind["active"] = "open";
|
|
41
|
+
RequestStateKind["reschedule"] = "reschedule";
|
|
42
|
+
RequestStateKind["outDated"] = "drop";
|
|
43
|
+
})(RequestStateKind || (RequestStateKind = {}));
|
|
44
|
+
class Tabs {
|
|
45
|
+
constructor() {
|
|
46
|
+
this.open = new Set();
|
|
47
|
+
this._onOpen = new vscode_1.EventEmitter();
|
|
48
|
+
this._onClose = new vscode_1.EventEmitter();
|
|
49
|
+
Tabs.fillTabResources(this.open);
|
|
50
|
+
const openTabsHandler = event => {
|
|
51
|
+
if (event.closed.length === 0 && event.opened.length === 0) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const oldTabs = this.open;
|
|
55
|
+
const currentTabs = new Set();
|
|
56
|
+
Tabs.fillTabResources(currentTabs);
|
|
57
|
+
const closed = new Set();
|
|
58
|
+
const opened = new Set(currentTabs);
|
|
59
|
+
for (const tab of oldTabs.values()) {
|
|
60
|
+
if (currentTabs.has(tab)) {
|
|
61
|
+
opened.delete(tab);
|
|
62
|
+
} else {
|
|
63
|
+
closed.add(tab);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
this.open = currentTabs;
|
|
67
|
+
if (closed.size > 0) {
|
|
68
|
+
const toFire = new Set();
|
|
69
|
+
for (const item of closed) {
|
|
70
|
+
toFire.add(vscode_1.Uri.parse(item));
|
|
71
|
+
}
|
|
72
|
+
this._onClose.fire(toFire);
|
|
73
|
+
}
|
|
74
|
+
if (opened.size > 0) {
|
|
75
|
+
const toFire = new Set();
|
|
76
|
+
for (const item of opened) {
|
|
77
|
+
toFire.add(vscode_1.Uri.parse(item));
|
|
78
|
+
}
|
|
79
|
+
this._onOpen.fire(toFire);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
if (vscode_1.window.tabGroups.onDidChangeTabs !== undefined) {
|
|
83
|
+
this.disposable = vscode_1.window.tabGroups.onDidChangeTabs(openTabsHandler);
|
|
84
|
+
} else {
|
|
85
|
+
this.disposable = {
|
|
86
|
+
dispose: () => {}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
get onClose() {
|
|
91
|
+
return this._onClose.event;
|
|
92
|
+
}
|
|
93
|
+
get onOpen() {
|
|
94
|
+
return this._onOpen.event;
|
|
95
|
+
}
|
|
96
|
+
dispose() {
|
|
97
|
+
this.disposable.dispose();
|
|
98
|
+
}
|
|
99
|
+
isActive(document) {
|
|
100
|
+
var _vscode_1$window$acti, _vscode_1$window$acti2;
|
|
101
|
+
return document instanceof vscode_1.Uri ? ((_vscode_1$window$acti = vscode_1.window.activeTextEditor) === null || _vscode_1$window$acti === void 0 ? void 0 : _vscode_1$window$acti.document.uri) === document : ((_vscode_1$window$acti2 = vscode_1.window.activeTextEditor) === null || _vscode_1$window$acti2 === void 0 ? void 0 : _vscode_1$window$acti2.document) === document;
|
|
102
|
+
}
|
|
103
|
+
isVisible(document) {
|
|
104
|
+
const uri = document instanceof vscode_1.Uri ? document : document.uri;
|
|
105
|
+
return this.open.has(uri.toString());
|
|
106
|
+
}
|
|
107
|
+
getTabResources() {
|
|
108
|
+
const result = new Set();
|
|
109
|
+
Tabs.fillTabResources(new Set(), result);
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
static fillTabResources(strings, uris) {
|
|
113
|
+
const seen = strings !== null && strings !== void 0 ? strings : new Set();
|
|
114
|
+
for (const group of vscode_1.window.tabGroups.all) {
|
|
115
|
+
for (const tab of group.tabs) {
|
|
116
|
+
const input = tab.input;
|
|
117
|
+
let uri;
|
|
118
|
+
if (input instanceof vscode_1.TabInputText) {
|
|
119
|
+
uri = input.uri;
|
|
120
|
+
} else if (input instanceof vscode_1.TabInputTextDiff) {
|
|
121
|
+
uri = input.modified;
|
|
122
|
+
}
|
|
123
|
+
if (uri !== undefined && !seen.has(uri.toString())) {
|
|
124
|
+
seen.add(uri.toString());
|
|
125
|
+
uris !== undefined && uris.add(uri);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
var PullState;
|
|
132
|
+
(function (PullState) {
|
|
133
|
+
PullState[PullState["document"] = 1] = "document";
|
|
134
|
+
PullState[PullState["workspace"] = 2] = "workspace";
|
|
135
|
+
})(PullState || (PullState = {}));
|
|
136
|
+
var DocumentOrUri;
|
|
137
|
+
(function (DocumentOrUri) {
|
|
138
|
+
function asKey(document) {
|
|
139
|
+
return document instanceof vscode_1.Uri ? document.toString() : document.uri.toString();
|
|
140
|
+
}
|
|
141
|
+
DocumentOrUri.asKey = asKey;
|
|
142
|
+
})(DocumentOrUri || (DocumentOrUri = {}));
|
|
143
|
+
class DocumentPullStateTracker {
|
|
144
|
+
constructor() {
|
|
145
|
+
this.documentPullStates = new Map();
|
|
146
|
+
this.workspacePullStates = new Map();
|
|
147
|
+
}
|
|
148
|
+
track(kind, document, arg1) {
|
|
149
|
+
const states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates;
|
|
150
|
+
const [key, uri, version] = document instanceof vscode_1.Uri ? [document.toString(), document, arg1] : [document.uri.toString(), document.uri, document.version];
|
|
151
|
+
let state = states.get(key);
|
|
152
|
+
if (state === undefined) {
|
|
153
|
+
state = {
|
|
154
|
+
document: uri,
|
|
155
|
+
pulledVersion: version,
|
|
156
|
+
resultId: undefined
|
|
157
|
+
};
|
|
158
|
+
states.set(key, state);
|
|
159
|
+
}
|
|
160
|
+
return state;
|
|
161
|
+
}
|
|
162
|
+
update(kind, document, arg1, arg2) {
|
|
163
|
+
const states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates;
|
|
164
|
+
const [key, uri, version, resultId] = document instanceof vscode_1.Uri ? [document.toString(), document, arg1, arg2] : [document.uri.toString(), document.uri, document.version, arg1];
|
|
165
|
+
let state = states.get(key);
|
|
166
|
+
if (state === undefined) {
|
|
167
|
+
state = {
|
|
168
|
+
document: uri,
|
|
169
|
+
pulledVersion: version,
|
|
170
|
+
resultId
|
|
171
|
+
};
|
|
172
|
+
states.set(key, state);
|
|
173
|
+
} else {
|
|
174
|
+
state.pulledVersion = version;
|
|
175
|
+
state.resultId = resultId;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
unTrack(kind, document) {
|
|
179
|
+
const key = DocumentOrUri.asKey(document);
|
|
180
|
+
const states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates;
|
|
181
|
+
states.delete(key);
|
|
182
|
+
}
|
|
183
|
+
tracks(kind, document) {
|
|
184
|
+
const key = DocumentOrUri.asKey(document);
|
|
185
|
+
const states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates;
|
|
186
|
+
return states.has(key);
|
|
187
|
+
}
|
|
188
|
+
getResultId(kind, document) {
|
|
189
|
+
var _states$get;
|
|
190
|
+
const key = DocumentOrUri.asKey(document);
|
|
191
|
+
const states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates;
|
|
192
|
+
return (_states$get = states.get(key)) === null || _states$get === void 0 ? void 0 : _states$get.resultId;
|
|
193
|
+
}
|
|
194
|
+
getAllResultIds() {
|
|
195
|
+
const result = [];
|
|
196
|
+
for (let [uri, value] of this.workspacePullStates) {
|
|
197
|
+
if (this.documentPullStates.has(uri)) {
|
|
198
|
+
value = this.documentPullStates.get(uri);
|
|
199
|
+
}
|
|
200
|
+
if (value.resultId !== undefined) {
|
|
201
|
+
result.push({
|
|
202
|
+
uri,
|
|
203
|
+
value: value.resultId
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
class DiagnosticRequestor {
|
|
211
|
+
constructor(client, tabs, options) {
|
|
212
|
+
this.client = client;
|
|
213
|
+
this.tabs = tabs;
|
|
214
|
+
this.options = options;
|
|
215
|
+
this.isDisposed = false;
|
|
216
|
+
this.onDidChangeDiagnosticsEmitter = new vscode_1.EventEmitter();
|
|
217
|
+
this.provider = this.createProvider();
|
|
218
|
+
this.diagnostics = vscode_1.languages.createDiagnosticCollection(options.identifier);
|
|
219
|
+
this.openRequests = new Map();
|
|
220
|
+
this.documentStates = new DocumentPullStateTracker();
|
|
221
|
+
this.workspaceErrorCounter = 0;
|
|
222
|
+
}
|
|
223
|
+
knows(kind, document) {
|
|
224
|
+
const uri = document instanceof vscode_1.Uri ? document : document.uri;
|
|
225
|
+
return this.documentStates.tracks(kind, document) || this.openRequests.has(uri.toString());
|
|
226
|
+
}
|
|
227
|
+
forget(kind, document) {
|
|
228
|
+
this.documentStates.unTrack(kind, document);
|
|
229
|
+
}
|
|
230
|
+
pull(document, cb) {
|
|
231
|
+
if (this.isDisposed) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const uri = document instanceof vscode_1.Uri ? document : document.uri;
|
|
235
|
+
this.pullAsync(document).then(() => {
|
|
236
|
+
if (cb) {
|
|
237
|
+
cb();
|
|
238
|
+
}
|
|
239
|
+
}, error => {
|
|
240
|
+
this.client.error("Document pull failed for text document ".concat(uri.toString()), error, false);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
async pullAsync(document, version) {
|
|
244
|
+
if (this.isDisposed) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const isUri = document instanceof vscode_1.Uri;
|
|
248
|
+
const uri = isUri ? document : document.uri;
|
|
249
|
+
const key = uri.toString();
|
|
250
|
+
version = isUri ? version : document.version;
|
|
251
|
+
const currentRequestState = this.openRequests.get(key);
|
|
252
|
+
const documentState = isUri ? this.documentStates.track(PullState.document, document, version) : this.documentStates.track(PullState.document, document);
|
|
253
|
+
if (currentRequestState === undefined) {
|
|
254
|
+
var _afterState;
|
|
255
|
+
const tokenSource = new vscode_1.CancellationTokenSource();
|
|
256
|
+
this.openRequests.set(key, {
|
|
257
|
+
state: RequestStateKind.active,
|
|
258
|
+
document: document,
|
|
259
|
+
version: version,
|
|
260
|
+
tokenSource
|
|
261
|
+
});
|
|
262
|
+
let report;
|
|
263
|
+
let afterState;
|
|
264
|
+
try {
|
|
265
|
+
var _await$this$provider$;
|
|
266
|
+
report = (_await$this$provider$ = await this.provider.provideDiagnostics(document, documentState.resultId, tokenSource.token)) !== null && _await$this$provider$ !== void 0 ? _await$this$provider$ : {
|
|
267
|
+
kind: vsdiag.DocumentDiagnosticReportKind.full,
|
|
268
|
+
items: []
|
|
269
|
+
};
|
|
270
|
+
} catch (error) {
|
|
271
|
+
if (error instanceof features_1.LSPCancellationError && vscode_languageserver_protocol_1.DiagnosticServerCancellationData.is(error.data) && error.data.retriggerRequest === false) {
|
|
272
|
+
afterState = {
|
|
273
|
+
state: RequestStateKind.outDated,
|
|
274
|
+
document
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
if (afterState === undefined && error instanceof vscode_1.CancellationError) {
|
|
278
|
+
afterState = {
|
|
279
|
+
state: RequestStateKind.reschedule,
|
|
280
|
+
document
|
|
281
|
+
};
|
|
282
|
+
} else {
|
|
283
|
+
throw error;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
afterState = (_afterState = afterState) !== null && _afterState !== void 0 ? _afterState : this.openRequests.get(key);
|
|
287
|
+
if (afterState === undefined) {
|
|
288
|
+
this.client.error("Lost request state in diagnostic pull model. Clearing diagnostics for ".concat(key));
|
|
289
|
+
this.diagnostics.delete(uri);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
this.openRequests.delete(key);
|
|
293
|
+
if (!this.tabs.isVisible(document)) {
|
|
294
|
+
this.documentStates.unTrack(PullState.document, document);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (afterState.state === RequestStateKind.outDated) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
if (report !== undefined) {
|
|
301
|
+
if (report.kind === vsdiag.DocumentDiagnosticReportKind.full) {
|
|
302
|
+
this.diagnostics.set(uri, report.items);
|
|
303
|
+
}
|
|
304
|
+
documentState.pulledVersion = version;
|
|
305
|
+
documentState.resultId = report.resultId;
|
|
306
|
+
}
|
|
307
|
+
if (afterState.state === RequestStateKind.reschedule) {
|
|
308
|
+
this.pull(document);
|
|
309
|
+
}
|
|
310
|
+
} else {
|
|
311
|
+
if (currentRequestState.state === RequestStateKind.active) {
|
|
312
|
+
currentRequestState.tokenSource.cancel();
|
|
313
|
+
this.openRequests.set(key, {
|
|
314
|
+
state: RequestStateKind.reschedule,
|
|
315
|
+
document: currentRequestState.document
|
|
316
|
+
});
|
|
317
|
+
} else if (currentRequestState.state === RequestStateKind.outDated) {
|
|
318
|
+
this.openRequests.set(key, {
|
|
319
|
+
state: RequestStateKind.reschedule,
|
|
320
|
+
document: currentRequestState.document
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
forgetDocument(document) {
|
|
326
|
+
const uri = document instanceof vscode_1.Uri ? document : document.uri;
|
|
327
|
+
const key = uri.toString();
|
|
328
|
+
const request = this.openRequests.get(key);
|
|
329
|
+
if (this.options.workspaceDiagnostics) {
|
|
330
|
+
if (request !== undefined) {
|
|
331
|
+
this.openRequests.set(key, {
|
|
332
|
+
state: RequestStateKind.reschedule,
|
|
333
|
+
document: document
|
|
334
|
+
});
|
|
335
|
+
} else {
|
|
336
|
+
this.pull(document, () => {
|
|
337
|
+
this.forget(PullState.document, document);
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
} else {
|
|
341
|
+
if (request !== undefined) {
|
|
342
|
+
if (request.state === RequestStateKind.active) {
|
|
343
|
+
request.tokenSource.cancel();
|
|
344
|
+
}
|
|
345
|
+
this.openRequests.set(key, {
|
|
346
|
+
state: RequestStateKind.outDated,
|
|
347
|
+
document: document
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
this.diagnostics.delete(uri);
|
|
351
|
+
this.forget(PullState.document, document);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
pullWorkspace() {
|
|
355
|
+
if (this.isDisposed) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
this.pullWorkspaceAsync().then(() => {
|
|
359
|
+
this.workspaceTimeout = (0, vscode_languageserver_protocol_1.RAL)().timer.setTimeout(() => {
|
|
360
|
+
this.pullWorkspace();
|
|
361
|
+
}, 2000);
|
|
362
|
+
}, error => {
|
|
363
|
+
if (!(error instanceof features_1.LSPCancellationError) && !vscode_languageserver_protocol_1.DiagnosticServerCancellationData.is(error.data)) {
|
|
364
|
+
this.client.error("Workspace diagnostic pull failed.", error, false);
|
|
365
|
+
this.workspaceErrorCounter++;
|
|
366
|
+
}
|
|
367
|
+
if (this.workspaceErrorCounter <= 5) {
|
|
368
|
+
this.workspaceTimeout = (0, vscode_languageserver_protocol_1.RAL)().timer.setTimeout(() => {
|
|
369
|
+
this.pullWorkspace();
|
|
370
|
+
}, 2000);
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
async pullWorkspaceAsync() {
|
|
375
|
+
if (!this.provider.provideWorkspaceDiagnostics || this.isDisposed) {
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (this.workspaceCancellation !== undefined) {
|
|
379
|
+
this.workspaceCancellation.cancel();
|
|
380
|
+
this.workspaceCancellation = undefined;
|
|
381
|
+
}
|
|
382
|
+
this.workspaceCancellation = new vscode_1.CancellationTokenSource();
|
|
383
|
+
const previousResultIds = this.documentStates.getAllResultIds().map(item => {
|
|
384
|
+
return {
|
|
385
|
+
uri: this.client.protocol2CodeConverter.asUri(item.uri),
|
|
386
|
+
value: item.value
|
|
387
|
+
};
|
|
388
|
+
});
|
|
389
|
+
await this.provider.provideWorkspaceDiagnostics(previousResultIds, this.workspaceCancellation.token, chunk => {
|
|
390
|
+
if (!chunk || this.isDisposed) {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
for (const item of chunk.items) {
|
|
394
|
+
var _item$version;
|
|
395
|
+
if (item.kind === vsdiag.DocumentDiagnosticReportKind.full) {
|
|
396
|
+
if (!this.documentStates.tracks(PullState.document, item.uri)) {
|
|
397
|
+
this.diagnostics.set(item.uri, item.items);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
this.documentStates.update(PullState.workspace, item.uri, (_item$version = item.version) !== null && _item$version !== void 0 ? _item$version : undefined, item.resultId);
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
createProvider() {
|
|
405
|
+
const result = {
|
|
406
|
+
onDidChangeDiagnostics: this.onDidChangeDiagnosticsEmitter.event,
|
|
407
|
+
provideDiagnostics: (document, previousResultId, token) => {
|
|
408
|
+
const provideDiagnostics = (document, previousResultId, token) => {
|
|
409
|
+
const params = {
|
|
410
|
+
identifier: this.options.identifier,
|
|
411
|
+
textDocument: {
|
|
412
|
+
uri: this.client.code2ProtocolConverter.asUri(document instanceof vscode_1.Uri ? document : document.uri)
|
|
413
|
+
},
|
|
414
|
+
previousResultId: previousResultId
|
|
415
|
+
};
|
|
416
|
+
if (this.isDisposed === true || !this.client.isRunning()) {
|
|
417
|
+
return {
|
|
418
|
+
kind: vsdiag.DocumentDiagnosticReportKind.full,
|
|
419
|
+
items: []
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
return this.client.sendRequest(vscode_languageserver_protocol_1.DocumentDiagnosticRequest.type, params, token).then(async result => {
|
|
423
|
+
if (result === undefined || result === null || this.isDisposed || token.isCancellationRequested) {
|
|
424
|
+
return {
|
|
425
|
+
kind: vsdiag.DocumentDiagnosticReportKind.full,
|
|
426
|
+
items: []
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
if (result.kind === vscode_languageserver_protocol_1.DocumentDiagnosticReportKind.Full) {
|
|
430
|
+
return {
|
|
431
|
+
kind: vsdiag.DocumentDiagnosticReportKind.full,
|
|
432
|
+
resultId: result.resultId,
|
|
433
|
+
items: await this.client.protocol2CodeConverter.asDiagnostics(result.items, token)
|
|
434
|
+
};
|
|
435
|
+
} else {
|
|
436
|
+
return {
|
|
437
|
+
kind: vsdiag.DocumentDiagnosticReportKind.unChanged,
|
|
438
|
+
resultId: result.resultId
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
}, error => {
|
|
442
|
+
return this.client.handleFailedRequest(vscode_languageserver_protocol_1.DocumentDiagnosticRequest.type, token, error, {
|
|
443
|
+
kind: vsdiag.DocumentDiagnosticReportKind.full,
|
|
444
|
+
items: []
|
|
445
|
+
});
|
|
446
|
+
});
|
|
447
|
+
};
|
|
448
|
+
const middleware = this.client.middleware;
|
|
449
|
+
return middleware.provideDiagnostics ? middleware.provideDiagnostics(document, previousResultId, token, provideDiagnostics) : provideDiagnostics(document, previousResultId, token);
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
if (this.options.workspaceDiagnostics) {
|
|
453
|
+
result.provideWorkspaceDiagnostics = (resultIds, token, resultReporter) => {
|
|
454
|
+
const convertReport = async report => {
|
|
455
|
+
if (report.kind === vscode_languageserver_protocol_1.DocumentDiagnosticReportKind.Full) {
|
|
456
|
+
return {
|
|
457
|
+
kind: vsdiag.DocumentDiagnosticReportKind.full,
|
|
458
|
+
uri: this.client.protocol2CodeConverter.asUri(report.uri),
|
|
459
|
+
resultId: report.resultId,
|
|
460
|
+
version: report.version,
|
|
461
|
+
items: await this.client.protocol2CodeConverter.asDiagnostics(report.items, token)
|
|
462
|
+
};
|
|
463
|
+
} else {
|
|
464
|
+
return {
|
|
465
|
+
kind: vsdiag.DocumentDiagnosticReportKind.unChanged,
|
|
466
|
+
uri: this.client.protocol2CodeConverter.asUri(report.uri),
|
|
467
|
+
resultId: report.resultId,
|
|
468
|
+
version: report.version
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
const convertPreviousResultIds = resultIds => {
|
|
473
|
+
const converted = [];
|
|
474
|
+
for (const item of resultIds) {
|
|
475
|
+
converted.push({
|
|
476
|
+
uri: this.client.code2ProtocolConverter.asUri(item.uri),
|
|
477
|
+
value: item.value
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
return converted;
|
|
481
|
+
};
|
|
482
|
+
const provideDiagnostics = (resultIds, token) => {
|
|
483
|
+
const partialResultToken = (0, uuid_1.generateUuid)();
|
|
484
|
+
const disposable = this.client.onProgress(vscode_languageserver_protocol_1.WorkspaceDiagnosticRequest.partialResult, partialResultToken, async partialResult => {
|
|
485
|
+
if (partialResult === undefined || partialResult === null) {
|
|
486
|
+
resultReporter(null);
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
const converted = {
|
|
490
|
+
items: []
|
|
491
|
+
};
|
|
492
|
+
for (const item of partialResult.items) {
|
|
493
|
+
try {
|
|
494
|
+
converted.items.push(await convertReport(item));
|
|
495
|
+
} catch (error) {
|
|
496
|
+
this.client.error("Converting workspace diagnostics failed.", error);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
resultReporter(converted);
|
|
500
|
+
});
|
|
501
|
+
const params = {
|
|
502
|
+
identifier: this.options.identifier,
|
|
503
|
+
previousResultIds: convertPreviousResultIds(resultIds),
|
|
504
|
+
partialResultToken: partialResultToken
|
|
505
|
+
};
|
|
506
|
+
if (this.isDisposed === true || !this.client.isRunning()) {
|
|
507
|
+
return {
|
|
508
|
+
items: []
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
return this.client.sendRequest(vscode_languageserver_protocol_1.WorkspaceDiagnosticRequest.type, params, token).then(async result => {
|
|
512
|
+
if (token.isCancellationRequested) {
|
|
513
|
+
return {
|
|
514
|
+
items: []
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
const converted = {
|
|
518
|
+
items: []
|
|
519
|
+
};
|
|
520
|
+
for (const item of result.items) {
|
|
521
|
+
converted.items.push(await convertReport(item));
|
|
522
|
+
}
|
|
523
|
+
disposable.dispose();
|
|
524
|
+
resultReporter(converted);
|
|
525
|
+
return {
|
|
526
|
+
items: []
|
|
527
|
+
};
|
|
528
|
+
}, error => {
|
|
529
|
+
disposable.dispose();
|
|
530
|
+
return this.client.handleFailedRequest(vscode_languageserver_protocol_1.DocumentDiagnosticRequest.type, token, error, {
|
|
531
|
+
items: []
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
};
|
|
535
|
+
const middleware = this.client.middleware;
|
|
536
|
+
return middleware.provideWorkspaceDiagnostics ? middleware.provideWorkspaceDiagnostics(resultIds, token, resultReporter, provideDiagnostics) : provideDiagnostics(resultIds, token);
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
return result;
|
|
540
|
+
}
|
|
541
|
+
dispose() {
|
|
542
|
+
var _this$workspaceCancel, _this$workspaceTimeou;
|
|
543
|
+
this.isDisposed = true;
|
|
544
|
+
(_this$workspaceCancel = this.workspaceCancellation) === null || _this$workspaceCancel === void 0 ? void 0 : _this$workspaceCancel.cancel();
|
|
545
|
+
(_this$workspaceTimeou = this.workspaceTimeout) === null || _this$workspaceTimeou === void 0 ? void 0 : _this$workspaceTimeou.dispose();
|
|
546
|
+
for (const [key, request] of this.openRequests) {
|
|
547
|
+
if (request.state === RequestStateKind.active) {
|
|
548
|
+
request.tokenSource.cancel();
|
|
549
|
+
}
|
|
550
|
+
this.openRequests.set(key, {
|
|
551
|
+
state: RequestStateKind.outDated,
|
|
552
|
+
document: request.document
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
this.diagnostics.dispose();
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
class BackgroundScheduler {
|
|
559
|
+
constructor(diagnosticRequestor) {
|
|
560
|
+
this.diagnosticRequestor = diagnosticRequestor;
|
|
561
|
+
this.documents = new vscode_languageserver_protocol_1.LinkedMap();
|
|
562
|
+
this.isDisposed = false;
|
|
563
|
+
}
|
|
564
|
+
add(document) {
|
|
565
|
+
if (this.isDisposed === true) {
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
const key = DocumentOrUri.asKey(document);
|
|
569
|
+
if (this.documents.has(key)) {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
this.documents.set(key, document, vscode_languageserver_protocol_1.Touch.Last);
|
|
573
|
+
this.trigger();
|
|
574
|
+
}
|
|
575
|
+
remove(document) {
|
|
576
|
+
const key = DocumentOrUri.asKey(document);
|
|
577
|
+
this.documents.delete(key);
|
|
578
|
+
if (this.documents.size === 0) {
|
|
579
|
+
this.stop();
|
|
580
|
+
} else if (key === this.endDocumentKey()) {
|
|
581
|
+
this.endDocument = this.documents.last;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
trigger() {
|
|
585
|
+
if (this.isDisposed === true) {
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
if (this.intervalHandle !== undefined) {
|
|
589
|
+
this.endDocument = this.documents.last;
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
this.endDocument = this.documents.last;
|
|
593
|
+
this.intervalHandle = (0, vscode_languageserver_protocol_1.RAL)().timer.setInterval(() => {
|
|
594
|
+
const document = this.documents.first;
|
|
595
|
+
if (document !== undefined) {
|
|
596
|
+
const key = DocumentOrUri.asKey(document);
|
|
597
|
+
this.diagnosticRequestor.pull(document);
|
|
598
|
+
this.documents.set(key, document, vscode_languageserver_protocol_1.Touch.Last);
|
|
599
|
+
if (key === this.endDocumentKey()) {
|
|
600
|
+
this.stop();
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}, 200);
|
|
604
|
+
}
|
|
605
|
+
dispose() {
|
|
606
|
+
this.isDisposed = true;
|
|
607
|
+
this.stop();
|
|
608
|
+
this.documents.clear();
|
|
609
|
+
}
|
|
610
|
+
stop() {
|
|
611
|
+
var _this$intervalHandle;
|
|
612
|
+
(_this$intervalHandle = this.intervalHandle) === null || _this$intervalHandle === void 0 ? void 0 : _this$intervalHandle.dispose();
|
|
613
|
+
this.intervalHandle = undefined;
|
|
614
|
+
this.endDocument = undefined;
|
|
615
|
+
}
|
|
616
|
+
endDocumentKey() {
|
|
617
|
+
return this.endDocument !== undefined ? DocumentOrUri.asKey(this.endDocument) : undefined;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
class DiagnosticFeatureProviderImpl {
|
|
621
|
+
constructor(client, tabs, options) {
|
|
622
|
+
var _client$clientOptions, _vscode_1$window$acti3;
|
|
623
|
+
const diagnosticPullOptions = (_client$clientOptions = client.clientOptions.diagnosticPullOptions) !== null && _client$clientOptions !== void 0 ? _client$clientOptions : {
|
|
624
|
+
onChange: true,
|
|
625
|
+
onSave: false
|
|
626
|
+
};
|
|
627
|
+
const documentSelector = client.protocol2CodeConverter.asDocumentSelector(options.documentSelector);
|
|
628
|
+
const disposables = [];
|
|
629
|
+
const matchResource = resource => {
|
|
630
|
+
const selector = options.documentSelector;
|
|
631
|
+
if (diagnosticPullOptions.match !== undefined) {
|
|
632
|
+
return diagnosticPullOptions.match(selector, resource);
|
|
633
|
+
}
|
|
634
|
+
for (const filter of selector) {
|
|
635
|
+
if (!vscode_languageserver_protocol_1.TextDocumentFilter.is(filter)) {
|
|
636
|
+
continue;
|
|
637
|
+
}
|
|
638
|
+
if (typeof filter === 'string') {
|
|
639
|
+
return false;
|
|
640
|
+
}
|
|
641
|
+
if (filter.language !== undefined && filter.language !== '*') {
|
|
642
|
+
return false;
|
|
643
|
+
}
|
|
644
|
+
if (filter.scheme !== undefined && filter.scheme !== '*' && filter.scheme !== resource.scheme) {
|
|
645
|
+
return false;
|
|
646
|
+
}
|
|
647
|
+
if (filter.pattern !== undefined) {
|
|
648
|
+
const matcher = new minimatch.Minimatch(filter.pattern, {
|
|
649
|
+
noext: true
|
|
650
|
+
});
|
|
651
|
+
if (!matcher.makeRe()) {
|
|
652
|
+
return false;
|
|
653
|
+
}
|
|
654
|
+
if (!matcher.match(resource.fsPath)) {
|
|
655
|
+
return false;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
return true;
|
|
660
|
+
};
|
|
661
|
+
const matches = document => {
|
|
662
|
+
return document instanceof vscode_1.Uri ? matchResource(document) : vscode_1.languages.match(documentSelector, document) > 0 && tabs.isVisible(document);
|
|
663
|
+
};
|
|
664
|
+
const isActiveDocument = document => {
|
|
665
|
+
var _this$activeTextDocum;
|
|
666
|
+
return document instanceof vscode_1.Uri ? ((_this$activeTextDocum = this.activeTextDocument) === null || _this$activeTextDocum === void 0 ? void 0 : _this$activeTextDocum.uri.toString()) === document.toString() : this.activeTextDocument === document;
|
|
667
|
+
};
|
|
668
|
+
this.diagnosticRequestor = new DiagnosticRequestor(client, tabs, options);
|
|
669
|
+
this.backgroundScheduler = new BackgroundScheduler(this.diagnosticRequestor);
|
|
670
|
+
const addToBackgroundIfNeeded = document => {
|
|
671
|
+
if (!matches(document) || !options.interFileDependencies || isActiveDocument(document)) {
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
this.backgroundScheduler.add(document);
|
|
675
|
+
};
|
|
676
|
+
this.activeTextDocument = (_vscode_1$window$acti3 = vscode_1.window.activeTextEditor) === null || _vscode_1$window$acti3 === void 0 ? void 0 : _vscode_1$window$acti3.document;
|
|
677
|
+
vscode_1.window.onDidChangeActiveTextEditor(editor => {
|
|
678
|
+
const oldActive = this.activeTextDocument;
|
|
679
|
+
this.activeTextDocument = editor === null || editor === void 0 ? void 0 : editor.document;
|
|
680
|
+
if (oldActive !== undefined) {
|
|
681
|
+
addToBackgroundIfNeeded(oldActive);
|
|
682
|
+
}
|
|
683
|
+
if (this.activeTextDocument !== undefined) {
|
|
684
|
+
this.backgroundScheduler.remove(this.activeTextDocument);
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
const openFeature = client.getFeature(vscode_languageserver_protocol_1.DidOpenTextDocumentNotification.method);
|
|
688
|
+
disposables.push(openFeature.onNotificationSent(event => {
|
|
689
|
+
const textDocument = event.textDocument;
|
|
690
|
+
if (this.diagnosticRequestor.knows(PullState.document, textDocument)) {
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
if (matches(textDocument)) {
|
|
694
|
+
this.diagnosticRequestor.pull(textDocument, () => {
|
|
695
|
+
addToBackgroundIfNeeded(textDocument);
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
}));
|
|
699
|
+
tabs.onOpen(opened => {
|
|
700
|
+
for (const resource of opened) {
|
|
701
|
+
if (this.diagnosticRequestor.knows(PullState.document, resource)) {
|
|
702
|
+
continue;
|
|
703
|
+
}
|
|
704
|
+
const uriStr = resource.toString();
|
|
705
|
+
let textDocument;
|
|
706
|
+
for (const item of vscode_1.workspace.textDocuments) {
|
|
707
|
+
if (uriStr === item.uri.toString()) {
|
|
708
|
+
textDocument = item;
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
if (textDocument !== undefined && matches(textDocument)) {
|
|
713
|
+
this.diagnosticRequestor.pull(textDocument, () => {
|
|
714
|
+
addToBackgroundIfNeeded(textDocument);
|
|
715
|
+
});
|
|
716
|
+
} else if (matches(resource)) {
|
|
717
|
+
this.diagnosticRequestor.pull(resource, () => {
|
|
718
|
+
addToBackgroundIfNeeded(resource);
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
});
|
|
723
|
+
const pulledTextDocuments = new Set();
|
|
724
|
+
for (const textDocument of vscode_1.workspace.textDocuments) {
|
|
725
|
+
if (matches(textDocument)) {
|
|
726
|
+
this.diagnosticRequestor.pull(textDocument, () => {
|
|
727
|
+
addToBackgroundIfNeeded(textDocument);
|
|
728
|
+
});
|
|
729
|
+
pulledTextDocuments.add(textDocument.uri.toString());
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
if (diagnosticPullOptions.onTabs === true) {
|
|
733
|
+
for (const resource of tabs.getTabResources()) {
|
|
734
|
+
if (!pulledTextDocuments.has(resource.toString()) && matches(resource)) {
|
|
735
|
+
this.diagnosticRequestor.pull(resource, () => {
|
|
736
|
+
addToBackgroundIfNeeded(resource);
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
if (diagnosticPullOptions.onChange === true) {
|
|
742
|
+
const changeFeature = client.getFeature(vscode_languageserver_protocol_1.DidChangeTextDocumentNotification.method);
|
|
743
|
+
disposables.push(changeFeature.onNotificationSent(async event => {
|
|
744
|
+
const textDocument = event.textDocument;
|
|
745
|
+
if ((diagnosticPullOptions.filter === undefined || !diagnosticPullOptions.filter(textDocument, DiagnosticPullMode.onType)) && this.diagnosticRequestor.knows(PullState.document, textDocument)) {
|
|
746
|
+
this.diagnosticRequestor.pull(textDocument, () => {
|
|
747
|
+
this.backgroundScheduler.trigger();
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
}));
|
|
751
|
+
}
|
|
752
|
+
if (diagnosticPullOptions.onSave === true) {
|
|
753
|
+
const saveFeature = client.getFeature(vscode_languageserver_protocol_1.DidSaveTextDocumentNotification.method);
|
|
754
|
+
disposables.push(saveFeature.onNotificationSent(event => {
|
|
755
|
+
const textDocument = event.textDocument;
|
|
756
|
+
if ((diagnosticPullOptions.filter === undefined || !diagnosticPullOptions.filter(textDocument, DiagnosticPullMode.onSave)) && this.diagnosticRequestor.knows(PullState.document, textDocument)) {
|
|
757
|
+
this.diagnosticRequestor.pull(event.textDocument, () => {
|
|
758
|
+
this.backgroundScheduler.trigger();
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
}));
|
|
762
|
+
}
|
|
763
|
+
const closeFeature = client.getFeature(vscode_languageserver_protocol_1.DidCloseTextDocumentNotification.method);
|
|
764
|
+
disposables.push(closeFeature.onNotificationSent(event => {
|
|
765
|
+
this.cleanUpDocument(event.textDocument);
|
|
766
|
+
}));
|
|
767
|
+
tabs.onClose(closed => {
|
|
768
|
+
for (const document of closed) {
|
|
769
|
+
this.cleanUpDocument(document);
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
this.diagnosticRequestor.onDidChangeDiagnosticsEmitter.event(() => {
|
|
773
|
+
for (const textDocument of vscode_1.workspace.textDocuments) {
|
|
774
|
+
if (matches(textDocument)) {
|
|
775
|
+
this.diagnosticRequestor.pull(textDocument);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
if (options.workspaceDiagnostics === true && options.identifier !== 'da348dc5-c30a-4515-9d98-31ff3be38d14') {
|
|
780
|
+
this.diagnosticRequestor.pullWorkspace();
|
|
781
|
+
}
|
|
782
|
+
this.disposable = vscode_1.Disposable.from(...disposables, this.backgroundScheduler, this.diagnosticRequestor);
|
|
783
|
+
}
|
|
784
|
+
get onDidChangeDiagnosticsEmitter() {
|
|
785
|
+
return this.diagnosticRequestor.onDidChangeDiagnosticsEmitter;
|
|
786
|
+
}
|
|
787
|
+
get diagnostics() {
|
|
788
|
+
return this.diagnosticRequestor.provider;
|
|
789
|
+
}
|
|
790
|
+
cleanUpDocument(document) {
|
|
791
|
+
if (this.diagnosticRequestor.knows(PullState.document, document)) {
|
|
792
|
+
this.diagnosticRequestor.forgetDocument(document);
|
|
793
|
+
this.backgroundScheduler.remove(document);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
class DiagnosticFeature extends features_1.TextDocumentLanguageFeature {
|
|
798
|
+
constructor(client) {
|
|
799
|
+
super(client, vscode_languageserver_protocol_1.DocumentDiagnosticRequest.type);
|
|
800
|
+
}
|
|
801
|
+
fillClientCapabilities(capabilities) {
|
|
802
|
+
let capability = ensure(ensure(capabilities, 'textDocument'), 'diagnostic');
|
|
803
|
+
capability.dynamicRegistration = true;
|
|
804
|
+
capability.relatedDocumentSupport = false;
|
|
805
|
+
ensure(ensure(capabilities, 'workspace'), 'diagnostics').refreshSupport = true;
|
|
806
|
+
}
|
|
807
|
+
initialize(capabilities, documentSelector) {
|
|
808
|
+
const client = this._client;
|
|
809
|
+
client.onRequest(vscode_languageserver_protocol_1.DiagnosticRefreshRequest.type, async () => {
|
|
810
|
+
for (const provider of this.getAllProviders()) {
|
|
811
|
+
provider.onDidChangeDiagnosticsEmitter.fire();
|
|
812
|
+
}
|
|
813
|
+
});
|
|
814
|
+
let [id, options] = this.getRegistration(documentSelector, capabilities.diagnosticProvider);
|
|
815
|
+
if (!id || !options) {
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
this.register({
|
|
819
|
+
id: id,
|
|
820
|
+
registerOptions: options
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
dispose() {
|
|
824
|
+
if (this.tabs !== undefined) {
|
|
825
|
+
this.tabs.dispose();
|
|
826
|
+
this.tabs = undefined;
|
|
827
|
+
}
|
|
828
|
+
super.dispose();
|
|
829
|
+
}
|
|
830
|
+
registerLanguageProvider(options) {
|
|
831
|
+
if (this.tabs === undefined) {
|
|
832
|
+
this.tabs = new Tabs();
|
|
833
|
+
}
|
|
834
|
+
const provider = new DiagnosticFeatureProviderImpl(this._client, this.tabs, options);
|
|
835
|
+
return [provider.disposable, provider];
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
exports.DiagnosticFeature = DiagnosticFeature;
|
|
839
|
+
})(diagnostic);
|