@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,1442 @@
|
|
|
1
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
2
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
3
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
4
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
5
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
6
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
7
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
8
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
9
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
10
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
11
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
12
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
13
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
14
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
18
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
19
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
21
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
22
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
23
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
24
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
25
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
26
|
+
/* eslint-disable promise/always-return */
|
|
27
|
+
/* eslint-disable promise/catch-or-return */
|
|
28
|
+
/* --------------------------------------------------------------------------------------------
|
|
29
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
30
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
31
|
+
* ------------------------------------------------------------------------------------------ */
|
|
32
|
+
|
|
33
|
+
import { DidOpenTextDocumentNotification, DidChangeTextDocumentNotification, DidSaveTextDocumentNotification, DidCloseTextDocumentNotification, LinkedMap, Touch, RAL, TextDocumentFilter, DiagnosticServerCancellationData, DocumentDiagnosticRequest, DocumentDiagnosticReportKind, WorkspaceDiagnosticRequest, DiagnosticRefreshRequest } from '@difizen/vscode-languageserver-protocol';
|
|
34
|
+
import * as minimatch from 'minimatch';
|
|
35
|
+
import { TextDocumentLanguageFeature, LSPCancellationError } from "./features.js";
|
|
36
|
+
import { generateUuid } from "./utils/uuid.js";
|
|
37
|
+
import { languages as Languages, window as Window, workspace as Workspace, CancellationTokenSource, CancellationError, EventEmitter, Uri, TabInputText, TabInputTextDiff, TabInputCustom, workspace, Disposable } from "./vscodeAdaptor/vscodeAdaptor.js";
|
|
38
|
+
function ensure(target, key) {
|
|
39
|
+
if (target[key] === void 0) {
|
|
40
|
+
target[key] = {};
|
|
41
|
+
}
|
|
42
|
+
return target[key];
|
|
43
|
+
}
|
|
44
|
+
export var vsdiag;
|
|
45
|
+
(function (_vsdiag) {
|
|
46
|
+
var DocumentDiagnosticReportKind = /*#__PURE__*/function (DocumentDiagnosticReportKind) {
|
|
47
|
+
DocumentDiagnosticReportKind["full"] = "full";
|
|
48
|
+
DocumentDiagnosticReportKind["unChanged"] = "unChanged";
|
|
49
|
+
return DocumentDiagnosticReportKind;
|
|
50
|
+
}({});
|
|
51
|
+
_vsdiag.DocumentDiagnosticReportKind = DocumentDiagnosticReportKind;
|
|
52
|
+
})(vsdiag || (vsdiag = {}));
|
|
53
|
+
export var DiagnosticPullMode = /*#__PURE__*/function (DiagnosticPullMode) {
|
|
54
|
+
DiagnosticPullMode["onType"] = "onType";
|
|
55
|
+
DiagnosticPullMode["onSave"] = "onSave";
|
|
56
|
+
return DiagnosticPullMode;
|
|
57
|
+
}({});
|
|
58
|
+
var RequestStateKind = /*#__PURE__*/function (RequestStateKind) {
|
|
59
|
+
RequestStateKind["active"] = "open";
|
|
60
|
+
RequestStateKind["reschedule"] = "reschedule";
|
|
61
|
+
RequestStateKind["outDated"] = "drop";
|
|
62
|
+
return RequestStateKind;
|
|
63
|
+
}(RequestStateKind || {});
|
|
64
|
+
/**
|
|
65
|
+
* Manages the open tabs. We don't directly use the tab API since for
|
|
66
|
+
* diagnostics we need to de-dupe tabs that show the same resources since
|
|
67
|
+
* we pull on the model not the UI.
|
|
68
|
+
*/
|
|
69
|
+
var Tabs = /*#__PURE__*/function () {
|
|
70
|
+
function Tabs() {
|
|
71
|
+
var _this = this;
|
|
72
|
+
_classCallCheck(this, Tabs);
|
|
73
|
+
this.open = new Set();
|
|
74
|
+
this._onOpen = new EventEmitter();
|
|
75
|
+
this._onClose = new EventEmitter();
|
|
76
|
+
Tabs.fillTabResources(this.open);
|
|
77
|
+
var openTabsHandler = function openTabsHandler(event) {
|
|
78
|
+
if (event.closed.length === 0 && event.opened.length === 0) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
var oldTabs = _this.open;
|
|
82
|
+
var currentTabs = new Set();
|
|
83
|
+
Tabs.fillTabResources(currentTabs);
|
|
84
|
+
var closed = new Set();
|
|
85
|
+
var opened = new Set(currentTabs);
|
|
86
|
+
var _iterator = _createForOfIteratorHelper(oldTabs.values()),
|
|
87
|
+
_step;
|
|
88
|
+
try {
|
|
89
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
90
|
+
var tab = _step.value;
|
|
91
|
+
if (currentTabs.has(tab)) {
|
|
92
|
+
opened.delete(tab);
|
|
93
|
+
} else {
|
|
94
|
+
closed.add(tab);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
} catch (err) {
|
|
98
|
+
_iterator.e(err);
|
|
99
|
+
} finally {
|
|
100
|
+
_iterator.f();
|
|
101
|
+
}
|
|
102
|
+
_this.open = currentTabs;
|
|
103
|
+
if (closed.size > 0) {
|
|
104
|
+
var toFire = new Set();
|
|
105
|
+
var _iterator2 = _createForOfIteratorHelper(closed),
|
|
106
|
+
_step2;
|
|
107
|
+
try {
|
|
108
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
109
|
+
var item = _step2.value;
|
|
110
|
+
toFire.add(Uri.parse(item));
|
|
111
|
+
}
|
|
112
|
+
} catch (err) {
|
|
113
|
+
_iterator2.e(err);
|
|
114
|
+
} finally {
|
|
115
|
+
_iterator2.f();
|
|
116
|
+
}
|
|
117
|
+
_this._onClose.fire(toFire);
|
|
118
|
+
}
|
|
119
|
+
if (opened.size > 0) {
|
|
120
|
+
var _toFire = new Set();
|
|
121
|
+
var _iterator3 = _createForOfIteratorHelper(opened),
|
|
122
|
+
_step3;
|
|
123
|
+
try {
|
|
124
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
125
|
+
var _item = _step3.value;
|
|
126
|
+
_toFire.add(Uri.parse(_item));
|
|
127
|
+
}
|
|
128
|
+
} catch (err) {
|
|
129
|
+
_iterator3.e(err);
|
|
130
|
+
} finally {
|
|
131
|
+
_iterator3.f();
|
|
132
|
+
}
|
|
133
|
+
_this._onOpen.fire(_toFire);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
if (Window.tabGroups.onDidChangeTabs !== undefined) {
|
|
137
|
+
this.disposable = Window.tabGroups.onDidChangeTabs(openTabsHandler);
|
|
138
|
+
} else {
|
|
139
|
+
this.disposable = {
|
|
140
|
+
dispose: function dispose() {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
_createClass(Tabs, [{
|
|
147
|
+
key: "onClose",
|
|
148
|
+
get: function get() {
|
|
149
|
+
return this._onClose.event;
|
|
150
|
+
}
|
|
151
|
+
}, {
|
|
152
|
+
key: "onOpen",
|
|
153
|
+
get: function get() {
|
|
154
|
+
return this._onOpen.event;
|
|
155
|
+
}
|
|
156
|
+
}, {
|
|
157
|
+
key: "dispose",
|
|
158
|
+
value: function dispose() {
|
|
159
|
+
this.disposable.dispose();
|
|
160
|
+
}
|
|
161
|
+
}, {
|
|
162
|
+
key: "isActive",
|
|
163
|
+
value: function isActive(document) {
|
|
164
|
+
var _Window$activeTextEdi, _Window$activeTextEdi2;
|
|
165
|
+
return document instanceof Uri ? ((_Window$activeTextEdi = Window.activeTextEditor) === null || _Window$activeTextEdi === void 0 ? void 0 : _Window$activeTextEdi.document.uri) === document : ((_Window$activeTextEdi2 = Window.activeTextEditor) === null || _Window$activeTextEdi2 === void 0 ? void 0 : _Window$activeTextEdi2.document) === document;
|
|
166
|
+
}
|
|
167
|
+
}, {
|
|
168
|
+
key: "isVisible",
|
|
169
|
+
value: function isVisible(document) {
|
|
170
|
+
var uri = document instanceof Uri ? document : document.uri;
|
|
171
|
+
return this.open.has(uri.toString());
|
|
172
|
+
}
|
|
173
|
+
}, {
|
|
174
|
+
key: "getTabResources",
|
|
175
|
+
value: function getTabResources() {
|
|
176
|
+
var result = new Set();
|
|
177
|
+
Tabs.fillTabResources(new Set(), result);
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
180
|
+
}], [{
|
|
181
|
+
key: "fillTabResources",
|
|
182
|
+
value: function fillTabResources(strings, uris) {
|
|
183
|
+
var seen = strings !== null && strings !== void 0 ? strings : new Set();
|
|
184
|
+
var _iterator4 = _createForOfIteratorHelper(Window.tabGroups.all),
|
|
185
|
+
_step4;
|
|
186
|
+
try {
|
|
187
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
188
|
+
var group = _step4.value;
|
|
189
|
+
var _iterator5 = _createForOfIteratorHelper(group.tabs),
|
|
190
|
+
_step5;
|
|
191
|
+
try {
|
|
192
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
193
|
+
var tab = _step5.value;
|
|
194
|
+
var input = tab.input;
|
|
195
|
+
var _uri = void 0;
|
|
196
|
+
if (input instanceof TabInputText) {
|
|
197
|
+
_uri = input.uri;
|
|
198
|
+
} else if (input instanceof TabInputTextDiff) {
|
|
199
|
+
_uri = input.modified;
|
|
200
|
+
} else if (input instanceof TabInputCustom) {
|
|
201
|
+
_uri = input.uri;
|
|
202
|
+
}
|
|
203
|
+
if (_uri !== undefined && !seen.has(_uri.toString())) {
|
|
204
|
+
seen.add(_uri.toString());
|
|
205
|
+
uris !== undefined && uris.add(_uri);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
} catch (err) {
|
|
209
|
+
_iterator5.e(err);
|
|
210
|
+
} finally {
|
|
211
|
+
_iterator5.f();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
} catch (err) {
|
|
215
|
+
_iterator4.e(err);
|
|
216
|
+
} finally {
|
|
217
|
+
_iterator4.f();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}]);
|
|
221
|
+
return Tabs;
|
|
222
|
+
}();
|
|
223
|
+
var PullState = /*#__PURE__*/function (PullState) {
|
|
224
|
+
PullState[PullState["document"] = 1] = "document";
|
|
225
|
+
PullState[PullState["workspace"] = 2] = "workspace";
|
|
226
|
+
return PullState;
|
|
227
|
+
}(PullState || {});
|
|
228
|
+
var DocumentOrUri;
|
|
229
|
+
(function (_DocumentOrUri) {
|
|
230
|
+
function asKey(document) {
|
|
231
|
+
return document instanceof Uri ? document.toString() : document.uri.toString();
|
|
232
|
+
}
|
|
233
|
+
_DocumentOrUri.asKey = asKey;
|
|
234
|
+
})(DocumentOrUri || (DocumentOrUri = {}));
|
|
235
|
+
var DocumentPullStateTracker = /*#__PURE__*/function () {
|
|
236
|
+
function DocumentPullStateTracker() {
|
|
237
|
+
_classCallCheck(this, DocumentPullStateTracker);
|
|
238
|
+
this.documentPullStates = new Map();
|
|
239
|
+
this.workspacePullStates = new Map();
|
|
240
|
+
}
|
|
241
|
+
_createClass(DocumentPullStateTracker, [{
|
|
242
|
+
key: "track",
|
|
243
|
+
value: function track(kind, document, arg1) {
|
|
244
|
+
var states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates;
|
|
245
|
+
var _ref = document instanceof Uri ? [document.toString(), document, arg1] : [document.uri.toString(), document.uri, document.version],
|
|
246
|
+
_ref2 = _slicedToArray(_ref, 3),
|
|
247
|
+
key = _ref2[0],
|
|
248
|
+
uri = _ref2[1],
|
|
249
|
+
version = _ref2[2];
|
|
250
|
+
var state = states.get(key);
|
|
251
|
+
if (state === undefined) {
|
|
252
|
+
state = {
|
|
253
|
+
document: uri,
|
|
254
|
+
pulledVersion: version,
|
|
255
|
+
resultId: undefined
|
|
256
|
+
};
|
|
257
|
+
states.set(key, state);
|
|
258
|
+
}
|
|
259
|
+
return state;
|
|
260
|
+
}
|
|
261
|
+
}, {
|
|
262
|
+
key: "update",
|
|
263
|
+
value: function update(kind, document, arg1, arg2) {
|
|
264
|
+
var states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates;
|
|
265
|
+
var _ref3 = document instanceof Uri ? [document.toString(), document, arg1, arg2] : [document.uri.toString(), document.uri, document.version, arg1],
|
|
266
|
+
_ref4 = _slicedToArray(_ref3, 4),
|
|
267
|
+
key = _ref4[0],
|
|
268
|
+
uri = _ref4[1],
|
|
269
|
+
version = _ref4[2],
|
|
270
|
+
resultId = _ref4[3];
|
|
271
|
+
var state = states.get(key);
|
|
272
|
+
if (state === undefined) {
|
|
273
|
+
state = {
|
|
274
|
+
document: uri,
|
|
275
|
+
pulledVersion: version,
|
|
276
|
+
resultId: resultId
|
|
277
|
+
};
|
|
278
|
+
states.set(key, state);
|
|
279
|
+
} else {
|
|
280
|
+
state.pulledVersion = version;
|
|
281
|
+
state.resultId = resultId;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}, {
|
|
285
|
+
key: "unTrack",
|
|
286
|
+
value: function unTrack(kind, document) {
|
|
287
|
+
var key = DocumentOrUri.asKey(document);
|
|
288
|
+
var states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates;
|
|
289
|
+
states.delete(key);
|
|
290
|
+
}
|
|
291
|
+
}, {
|
|
292
|
+
key: "tracks",
|
|
293
|
+
value: function tracks(kind, document) {
|
|
294
|
+
var key = DocumentOrUri.asKey(document);
|
|
295
|
+
var states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates;
|
|
296
|
+
return states.has(key);
|
|
297
|
+
}
|
|
298
|
+
}, {
|
|
299
|
+
key: "getResultId",
|
|
300
|
+
value: function getResultId(kind, document) {
|
|
301
|
+
var _states$get;
|
|
302
|
+
var key = DocumentOrUri.asKey(document);
|
|
303
|
+
var states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates;
|
|
304
|
+
return (_states$get = states.get(key)) === null || _states$get === void 0 ? void 0 : _states$get.resultId;
|
|
305
|
+
}
|
|
306
|
+
}, {
|
|
307
|
+
key: "getAllResultIds",
|
|
308
|
+
value: function getAllResultIds() {
|
|
309
|
+
var result = [];
|
|
310
|
+
// eslint-disable-next-line prefer-const
|
|
311
|
+
var _iterator6 = _createForOfIteratorHelper(this.workspacePullStates),
|
|
312
|
+
_step6;
|
|
313
|
+
try {
|
|
314
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
315
|
+
var _step6$value = _slicedToArray(_step6.value, 2),
|
|
316
|
+
_uri2 = _step6$value[0],
|
|
317
|
+
value = _step6$value[1];
|
|
318
|
+
if (this.documentPullStates.has(_uri2)) {
|
|
319
|
+
value = this.documentPullStates.get(_uri2);
|
|
320
|
+
}
|
|
321
|
+
if (value.resultId !== undefined) {
|
|
322
|
+
result.push({
|
|
323
|
+
uri: _uri2,
|
|
324
|
+
value: value.resultId
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
} catch (err) {
|
|
329
|
+
_iterator6.e(err);
|
|
330
|
+
} finally {
|
|
331
|
+
_iterator6.f();
|
|
332
|
+
}
|
|
333
|
+
return result;
|
|
334
|
+
}
|
|
335
|
+
}]);
|
|
336
|
+
return DocumentPullStateTracker;
|
|
337
|
+
}();
|
|
338
|
+
var DiagnosticRequestor = /*#__PURE__*/function () {
|
|
339
|
+
function DiagnosticRequestor(client, tabs, options) {
|
|
340
|
+
_classCallCheck(this, DiagnosticRequestor);
|
|
341
|
+
this.client = client;
|
|
342
|
+
this.tabs = tabs;
|
|
343
|
+
this.options = options;
|
|
344
|
+
this.isDisposed = false;
|
|
345
|
+
this.onDidChangeDiagnosticsEmitter = new EventEmitter();
|
|
346
|
+
this.provider = this.createProvider();
|
|
347
|
+
this.diagnostics = Languages.createDiagnosticCollection(options.identifier);
|
|
348
|
+
this.openRequests = new Map();
|
|
349
|
+
this.documentStates = new DocumentPullStateTracker();
|
|
350
|
+
this.workspaceErrorCounter = 0;
|
|
351
|
+
}
|
|
352
|
+
_createClass(DiagnosticRequestor, [{
|
|
353
|
+
key: "knows",
|
|
354
|
+
value: function knows(kind, document) {
|
|
355
|
+
var uri = document instanceof Uri ? document : document.uri;
|
|
356
|
+
return this.documentStates.tracks(kind, document) || this.openRequests.has(uri.toString());
|
|
357
|
+
}
|
|
358
|
+
}, {
|
|
359
|
+
key: "forget",
|
|
360
|
+
value: function forget(kind, document) {
|
|
361
|
+
this.documentStates.unTrack(kind, document);
|
|
362
|
+
}
|
|
363
|
+
}, {
|
|
364
|
+
key: "pull",
|
|
365
|
+
value: function pull(document, cb) {
|
|
366
|
+
var _this2 = this;
|
|
367
|
+
if (this.isDisposed) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
var uri = document instanceof Uri ? document : document.uri;
|
|
371
|
+
this.pullAsync(document).then(function () {
|
|
372
|
+
if (cb) {
|
|
373
|
+
cb();
|
|
374
|
+
}
|
|
375
|
+
}, function (error) {
|
|
376
|
+
_this2.client.error("Document pull failed for text document ".concat(uri.toString()), error, false);
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
}, {
|
|
380
|
+
key: "pullAsync",
|
|
381
|
+
value: function () {
|
|
382
|
+
var _pullAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(document, version) {
|
|
383
|
+
var isUri, uri, key, currentRequestState, documentState, _afterState, tokenSource, report, afterState, _yield$this$provider$;
|
|
384
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
385
|
+
while (1) switch (_context.prev = _context.next) {
|
|
386
|
+
case 0:
|
|
387
|
+
if (!this.isDisposed) {
|
|
388
|
+
_context.next = 2;
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
return _context.abrupt("return");
|
|
392
|
+
case 2:
|
|
393
|
+
isUri = document instanceof Uri;
|
|
394
|
+
uri = isUri ? document : document.uri;
|
|
395
|
+
key = uri.toString();
|
|
396
|
+
version = isUri ? version : document.version;
|
|
397
|
+
currentRequestState = this.openRequests.get(key);
|
|
398
|
+
documentState = isUri ? this.documentStates.track(PullState.document, document, version) : this.documentStates.track(PullState.document, document);
|
|
399
|
+
if (!(currentRequestState === undefined)) {
|
|
400
|
+
_context.next = 49;
|
|
401
|
+
break;
|
|
402
|
+
}
|
|
403
|
+
tokenSource = new CancellationTokenSource();
|
|
404
|
+
this.openRequests.set(key, {
|
|
405
|
+
state: RequestStateKind.active,
|
|
406
|
+
document: document,
|
|
407
|
+
version: version,
|
|
408
|
+
tokenSource: tokenSource
|
|
409
|
+
});
|
|
410
|
+
_context.prev = 11;
|
|
411
|
+
_context.next = 14;
|
|
412
|
+
return this.provider.provideDiagnostics(document, documentState.resultId, tokenSource.token);
|
|
413
|
+
case 14:
|
|
414
|
+
_context.t1 = _yield$this$provider$ = _context.sent;
|
|
415
|
+
_context.t0 = _context.t1 !== null;
|
|
416
|
+
if (!_context.t0) {
|
|
417
|
+
_context.next = 18;
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
_context.t0 = _yield$this$provider$ !== void 0;
|
|
421
|
+
case 18:
|
|
422
|
+
if (!_context.t0) {
|
|
423
|
+
_context.next = 22;
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
_context.t2 = _yield$this$provider$;
|
|
427
|
+
_context.next = 23;
|
|
428
|
+
break;
|
|
429
|
+
case 22:
|
|
430
|
+
_context.t2 = {
|
|
431
|
+
kind: vsdiag.DocumentDiagnosticReportKind.full,
|
|
432
|
+
items: []
|
|
433
|
+
};
|
|
434
|
+
case 23:
|
|
435
|
+
report = _context.t2;
|
|
436
|
+
_context.next = 34;
|
|
437
|
+
break;
|
|
438
|
+
case 26:
|
|
439
|
+
_context.prev = 26;
|
|
440
|
+
_context.t3 = _context["catch"](11);
|
|
441
|
+
if (_context.t3 instanceof LSPCancellationError && DiagnosticServerCancellationData.is(_context.t3.data) && _context.t3.data.retriggerRequest === false) {
|
|
442
|
+
afterState = {
|
|
443
|
+
state: RequestStateKind.outDated,
|
|
444
|
+
document: document
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
if (!(afterState === undefined && _context.t3 instanceof CancellationError)) {
|
|
448
|
+
_context.next = 33;
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
451
|
+
afterState = {
|
|
452
|
+
state: RequestStateKind.reschedule,
|
|
453
|
+
document: document
|
|
454
|
+
};
|
|
455
|
+
_context.next = 34;
|
|
456
|
+
break;
|
|
457
|
+
case 33:
|
|
458
|
+
throw _context.t3;
|
|
459
|
+
case 34:
|
|
460
|
+
afterState = (_afterState = afterState) !== null && _afterState !== void 0 ? _afterState : this.openRequests.get(key);
|
|
461
|
+
if (!(afterState === undefined)) {
|
|
462
|
+
_context.next = 39;
|
|
463
|
+
break;
|
|
464
|
+
}
|
|
465
|
+
// This shouldn't happen. Log it
|
|
466
|
+
this.client.error("Lost request state in diagnostic pull model. Clearing diagnostics for ".concat(key));
|
|
467
|
+
this.diagnostics.delete(uri);
|
|
468
|
+
return _context.abrupt("return");
|
|
469
|
+
case 39:
|
|
470
|
+
this.openRequests.delete(key);
|
|
471
|
+
if (this.tabs.isVisible(document)) {
|
|
472
|
+
_context.next = 43;
|
|
473
|
+
break;
|
|
474
|
+
}
|
|
475
|
+
this.documentStates.unTrack(PullState.document, document);
|
|
476
|
+
return _context.abrupt("return");
|
|
477
|
+
case 43:
|
|
478
|
+
if (!(afterState.state === RequestStateKind.outDated)) {
|
|
479
|
+
_context.next = 45;
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
return _context.abrupt("return");
|
|
483
|
+
case 45:
|
|
484
|
+
// report is only undefined if the request has thrown.
|
|
485
|
+
if (report !== undefined) {
|
|
486
|
+
if (report.kind === vsdiag.DocumentDiagnosticReportKind.full) {
|
|
487
|
+
this.diagnostics.set(uri, report.items);
|
|
488
|
+
}
|
|
489
|
+
documentState.pulledVersion = version;
|
|
490
|
+
documentState.resultId = report.resultId;
|
|
491
|
+
}
|
|
492
|
+
if (afterState.state === RequestStateKind.reschedule) {
|
|
493
|
+
this.pull(document);
|
|
494
|
+
}
|
|
495
|
+
_context.next = 50;
|
|
496
|
+
break;
|
|
497
|
+
case 49:
|
|
498
|
+
if (currentRequestState.state === RequestStateKind.active) {
|
|
499
|
+
// Cancel the current request and reschedule a new one when the old one returned.
|
|
500
|
+
currentRequestState.tokenSource.cancel();
|
|
501
|
+
this.openRequests.set(key, {
|
|
502
|
+
state: RequestStateKind.reschedule,
|
|
503
|
+
document: currentRequestState.document
|
|
504
|
+
});
|
|
505
|
+
} else if (currentRequestState.state === RequestStateKind.outDated) {
|
|
506
|
+
this.openRequests.set(key, {
|
|
507
|
+
state: RequestStateKind.reschedule,
|
|
508
|
+
document: currentRequestState.document
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
case 50:
|
|
512
|
+
case "end":
|
|
513
|
+
return _context.stop();
|
|
514
|
+
}
|
|
515
|
+
}, _callee, this, [[11, 26]]);
|
|
516
|
+
}));
|
|
517
|
+
function pullAsync(_x, _x2) {
|
|
518
|
+
return _pullAsync.apply(this, arguments);
|
|
519
|
+
}
|
|
520
|
+
return pullAsync;
|
|
521
|
+
}()
|
|
522
|
+
}, {
|
|
523
|
+
key: "forgetDocument",
|
|
524
|
+
value: function forgetDocument(document) {
|
|
525
|
+
var _this3 = this;
|
|
526
|
+
var uri = document instanceof Uri ? document : document.uri;
|
|
527
|
+
var key = uri.toString();
|
|
528
|
+
var request = this.openRequests.get(key);
|
|
529
|
+
if (this.options.workspaceDiagnostics) {
|
|
530
|
+
// If we run workspace diagnostic pull a last time for the diagnostics
|
|
531
|
+
// and the rely on getting them from the workspace result.
|
|
532
|
+
if (request !== undefined) {
|
|
533
|
+
this.openRequests.set(key, {
|
|
534
|
+
state: RequestStateKind.reschedule,
|
|
535
|
+
document: document
|
|
536
|
+
});
|
|
537
|
+
} else {
|
|
538
|
+
this.pull(document, function () {
|
|
539
|
+
_this3.forget(PullState.document, document);
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
} else {
|
|
543
|
+
// We have normal pull or inter file dependencies. In this case we
|
|
544
|
+
// clear the diagnostics (to have the same start as after startup).
|
|
545
|
+
// We also cancel outstanding requests.
|
|
546
|
+
if (request !== undefined) {
|
|
547
|
+
if (request.state === RequestStateKind.active) {
|
|
548
|
+
request.tokenSource.cancel();
|
|
549
|
+
}
|
|
550
|
+
this.openRequests.set(key, {
|
|
551
|
+
state: RequestStateKind.outDated,
|
|
552
|
+
document: document
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
this.diagnostics.delete(uri);
|
|
556
|
+
this.forget(PullState.document, document);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}, {
|
|
560
|
+
key: "pullWorkspace",
|
|
561
|
+
value: function pullWorkspace() {
|
|
562
|
+
var _this4 = this;
|
|
563
|
+
if (this.isDisposed) {
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
this.pullWorkspaceAsync().then(function () {
|
|
567
|
+
_this4.workspaceTimeout = RAL().timer.setTimeout(function () {
|
|
568
|
+
_this4.pullWorkspace();
|
|
569
|
+
}, 2000);
|
|
570
|
+
}, function (error) {
|
|
571
|
+
if (!(error instanceof LSPCancellationError) && !DiagnosticServerCancellationData.is(error.data)) {
|
|
572
|
+
_this4.client.error("Workspace diagnostic pull failed.", error, false);
|
|
573
|
+
_this4.workspaceErrorCounter++;
|
|
574
|
+
}
|
|
575
|
+
if (_this4.workspaceErrorCounter <= 5) {
|
|
576
|
+
_this4.workspaceTimeout = RAL().timer.setTimeout(function () {
|
|
577
|
+
_this4.pullWorkspace();
|
|
578
|
+
}, 2000);
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
}, {
|
|
583
|
+
key: "pullWorkspaceAsync",
|
|
584
|
+
value: function () {
|
|
585
|
+
var _pullWorkspaceAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
586
|
+
var _this5 = this;
|
|
587
|
+
var previousResultIds;
|
|
588
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
589
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
590
|
+
case 0:
|
|
591
|
+
if (!(!this.provider.provideWorkspaceDiagnostics || this.isDisposed)) {
|
|
592
|
+
_context2.next = 2;
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
595
|
+
return _context2.abrupt("return");
|
|
596
|
+
case 2:
|
|
597
|
+
if (this.workspaceCancellation !== undefined) {
|
|
598
|
+
this.workspaceCancellation.cancel();
|
|
599
|
+
this.workspaceCancellation = undefined;
|
|
600
|
+
}
|
|
601
|
+
this.workspaceCancellation = new CancellationTokenSource();
|
|
602
|
+
previousResultIds = this.documentStates.getAllResultIds().map(function (item) {
|
|
603
|
+
return {
|
|
604
|
+
uri: _this5.client.protocol2CodeConverter.asUri(item.uri),
|
|
605
|
+
value: item.value
|
|
606
|
+
};
|
|
607
|
+
});
|
|
608
|
+
_context2.next = 7;
|
|
609
|
+
return this.provider.provideWorkspaceDiagnostics(previousResultIds, this.workspaceCancellation.token, function (chunk) {
|
|
610
|
+
if (!chunk || _this5.isDisposed) {
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
var _iterator7 = _createForOfIteratorHelper(chunk.items),
|
|
614
|
+
_step7;
|
|
615
|
+
try {
|
|
616
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
617
|
+
var _item$version;
|
|
618
|
+
var item = _step7.value;
|
|
619
|
+
if (item.kind === vsdiag.DocumentDiagnosticReportKind.full) {
|
|
620
|
+
// Favour document pull result over workspace results. So skip if it is tracked
|
|
621
|
+
// as a document result.
|
|
622
|
+
if (!_this5.documentStates.tracks(PullState.document, item.uri)) {
|
|
623
|
+
_this5.diagnostics.set(item.uri, item.items);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
_this5.documentStates.update(PullState.workspace, item.uri, (_item$version = item.version) !== null && _item$version !== void 0 ? _item$version : undefined, item.resultId);
|
|
627
|
+
}
|
|
628
|
+
} catch (err) {
|
|
629
|
+
_iterator7.e(err);
|
|
630
|
+
} finally {
|
|
631
|
+
_iterator7.f();
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
case 7:
|
|
635
|
+
case "end":
|
|
636
|
+
return _context2.stop();
|
|
637
|
+
}
|
|
638
|
+
}, _callee2, this);
|
|
639
|
+
}));
|
|
640
|
+
function pullWorkspaceAsync() {
|
|
641
|
+
return _pullWorkspaceAsync.apply(this, arguments);
|
|
642
|
+
}
|
|
643
|
+
return pullWorkspaceAsync;
|
|
644
|
+
}()
|
|
645
|
+
}, {
|
|
646
|
+
key: "createProvider",
|
|
647
|
+
value: function createProvider() {
|
|
648
|
+
var _this6 = this;
|
|
649
|
+
var result = {
|
|
650
|
+
onDidChangeDiagnostics: this.onDidChangeDiagnosticsEmitter.event,
|
|
651
|
+
provideDiagnostics: function provideDiagnostics(document, previousResultId, token) {
|
|
652
|
+
var provideDiagnostics = function provideDiagnostics(document, previousResultId, token) {
|
|
653
|
+
var params = {
|
|
654
|
+
identifier: _this6.options.identifier,
|
|
655
|
+
textDocument: {
|
|
656
|
+
uri: _this6.client.code2ProtocolConverter.asUri(document instanceof Uri ? document : document.uri)
|
|
657
|
+
},
|
|
658
|
+
previousResultId: previousResultId
|
|
659
|
+
};
|
|
660
|
+
if (_this6.isDisposed === true || !_this6.client.isRunning()) {
|
|
661
|
+
return {
|
|
662
|
+
kind: vsdiag.DocumentDiagnosticReportKind.full,
|
|
663
|
+
items: []
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
return _this6.client.sendRequest(DocumentDiagnosticRequest.type, params, token).then( /*#__PURE__*/function () {
|
|
667
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(result) {
|
|
668
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
669
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
670
|
+
case 0:
|
|
671
|
+
if (!(result === undefined || result === null || _this6.isDisposed || token.isCancellationRequested)) {
|
|
672
|
+
_context3.next = 2;
|
|
673
|
+
break;
|
|
674
|
+
}
|
|
675
|
+
return _context3.abrupt("return", {
|
|
676
|
+
kind: vsdiag.DocumentDiagnosticReportKind.full,
|
|
677
|
+
items: []
|
|
678
|
+
});
|
|
679
|
+
case 2:
|
|
680
|
+
if (!(result.kind === DocumentDiagnosticReportKind.Full)) {
|
|
681
|
+
_context3.next = 11;
|
|
682
|
+
break;
|
|
683
|
+
}
|
|
684
|
+
_context3.t0 = vsdiag.DocumentDiagnosticReportKind.full;
|
|
685
|
+
_context3.t1 = result.resultId;
|
|
686
|
+
_context3.next = 7;
|
|
687
|
+
return _this6.client.protocol2CodeConverter.asDiagnostics(result.items, token);
|
|
688
|
+
case 7:
|
|
689
|
+
_context3.t2 = _context3.sent;
|
|
690
|
+
return _context3.abrupt("return", {
|
|
691
|
+
kind: _context3.t0,
|
|
692
|
+
resultId: _context3.t1,
|
|
693
|
+
items: _context3.t2
|
|
694
|
+
});
|
|
695
|
+
case 11:
|
|
696
|
+
return _context3.abrupt("return", {
|
|
697
|
+
kind: vsdiag.DocumentDiagnosticReportKind.unChanged,
|
|
698
|
+
resultId: result.resultId
|
|
699
|
+
});
|
|
700
|
+
case 12:
|
|
701
|
+
case "end":
|
|
702
|
+
return _context3.stop();
|
|
703
|
+
}
|
|
704
|
+
}, _callee3);
|
|
705
|
+
}));
|
|
706
|
+
return function (_x3) {
|
|
707
|
+
return _ref5.apply(this, arguments);
|
|
708
|
+
};
|
|
709
|
+
}(), function (error) {
|
|
710
|
+
return _this6.client.handleFailedRequest(DocumentDiagnosticRequest.type, token, error, {
|
|
711
|
+
kind: vsdiag.DocumentDiagnosticReportKind.full,
|
|
712
|
+
items: []
|
|
713
|
+
});
|
|
714
|
+
});
|
|
715
|
+
};
|
|
716
|
+
var middleware = _this6.client.middleware;
|
|
717
|
+
return middleware.provideDiagnostics ? middleware.provideDiagnostics(document, previousResultId, token, provideDiagnostics) : provideDiagnostics(document, previousResultId, token);
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
if (this.options.workspaceDiagnostics) {
|
|
721
|
+
result.provideWorkspaceDiagnostics = function (resultIds, token, resultReporter) {
|
|
722
|
+
var convertReport = /*#__PURE__*/function () {
|
|
723
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(report) {
|
|
724
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
725
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
726
|
+
case 0:
|
|
727
|
+
if (!(report.kind === DocumentDiagnosticReportKind.Full)) {
|
|
728
|
+
_context4.next = 11;
|
|
729
|
+
break;
|
|
730
|
+
}
|
|
731
|
+
_context4.t0 = vsdiag.DocumentDiagnosticReportKind.full;
|
|
732
|
+
_context4.t1 = _this6.client.protocol2CodeConverter.asUri(report.uri);
|
|
733
|
+
_context4.t2 = report.resultId;
|
|
734
|
+
_context4.t3 = report.version;
|
|
735
|
+
_context4.next = 7;
|
|
736
|
+
return _this6.client.protocol2CodeConverter.asDiagnostics(report.items, token);
|
|
737
|
+
case 7:
|
|
738
|
+
_context4.t4 = _context4.sent;
|
|
739
|
+
return _context4.abrupt("return", {
|
|
740
|
+
kind: _context4.t0,
|
|
741
|
+
uri: _context4.t1,
|
|
742
|
+
resultId: _context4.t2,
|
|
743
|
+
version: _context4.t3,
|
|
744
|
+
items: _context4.t4
|
|
745
|
+
});
|
|
746
|
+
case 11:
|
|
747
|
+
return _context4.abrupt("return", {
|
|
748
|
+
kind: vsdiag.DocumentDiagnosticReportKind.unChanged,
|
|
749
|
+
uri: _this6.client.protocol2CodeConverter.asUri(report.uri),
|
|
750
|
+
resultId: report.resultId,
|
|
751
|
+
version: report.version
|
|
752
|
+
});
|
|
753
|
+
case 12:
|
|
754
|
+
case "end":
|
|
755
|
+
return _context4.stop();
|
|
756
|
+
}
|
|
757
|
+
}, _callee4);
|
|
758
|
+
}));
|
|
759
|
+
return function convertReport(_x4) {
|
|
760
|
+
return _ref6.apply(this, arguments);
|
|
761
|
+
};
|
|
762
|
+
}();
|
|
763
|
+
var convertPreviousResultIds = function convertPreviousResultIds(resultIds) {
|
|
764
|
+
var converted = [];
|
|
765
|
+
var _iterator8 = _createForOfIteratorHelper(resultIds),
|
|
766
|
+
_step8;
|
|
767
|
+
try {
|
|
768
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
769
|
+
var item = _step8.value;
|
|
770
|
+
converted.push({
|
|
771
|
+
uri: _this6.client.code2ProtocolConverter.asUri(item.uri),
|
|
772
|
+
value: item.value
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
} catch (err) {
|
|
776
|
+
_iterator8.e(err);
|
|
777
|
+
} finally {
|
|
778
|
+
_iterator8.f();
|
|
779
|
+
}
|
|
780
|
+
return converted;
|
|
781
|
+
};
|
|
782
|
+
var provideDiagnostics = function provideDiagnostics(resultIds, token) {
|
|
783
|
+
var partialResultToken = generateUuid();
|
|
784
|
+
var disposable = _this6.client.onProgress(WorkspaceDiagnosticRequest.partialResult, partialResultToken, /*#__PURE__*/function () {
|
|
785
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(partialResult) {
|
|
786
|
+
var converted, _iterator9, _step9, item;
|
|
787
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
788
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
789
|
+
case 0:
|
|
790
|
+
if (!(partialResult === undefined || partialResult === null)) {
|
|
791
|
+
_context5.next = 3;
|
|
792
|
+
break;
|
|
793
|
+
}
|
|
794
|
+
resultReporter(null);
|
|
795
|
+
return _context5.abrupt("return");
|
|
796
|
+
case 3:
|
|
797
|
+
converted = {
|
|
798
|
+
items: []
|
|
799
|
+
};
|
|
800
|
+
_iterator9 = _createForOfIteratorHelper(partialResult.items);
|
|
801
|
+
_context5.prev = 5;
|
|
802
|
+
_iterator9.s();
|
|
803
|
+
case 7:
|
|
804
|
+
if ((_step9 = _iterator9.n()).done) {
|
|
805
|
+
_context5.next = 22;
|
|
806
|
+
break;
|
|
807
|
+
}
|
|
808
|
+
item = _step9.value;
|
|
809
|
+
_context5.prev = 9;
|
|
810
|
+
_context5.t0 = converted.items;
|
|
811
|
+
_context5.next = 13;
|
|
812
|
+
return convertReport(item);
|
|
813
|
+
case 13:
|
|
814
|
+
_context5.t1 = _context5.sent;
|
|
815
|
+
_context5.t0.push.call(_context5.t0, _context5.t1);
|
|
816
|
+
_context5.next = 20;
|
|
817
|
+
break;
|
|
818
|
+
case 17:
|
|
819
|
+
_context5.prev = 17;
|
|
820
|
+
_context5.t2 = _context5["catch"](9);
|
|
821
|
+
_this6.client.error("Converting workspace diagnostics failed.", _context5.t2);
|
|
822
|
+
case 20:
|
|
823
|
+
_context5.next = 7;
|
|
824
|
+
break;
|
|
825
|
+
case 22:
|
|
826
|
+
_context5.next = 27;
|
|
827
|
+
break;
|
|
828
|
+
case 24:
|
|
829
|
+
_context5.prev = 24;
|
|
830
|
+
_context5.t3 = _context5["catch"](5);
|
|
831
|
+
_iterator9.e(_context5.t3);
|
|
832
|
+
case 27:
|
|
833
|
+
_context5.prev = 27;
|
|
834
|
+
_iterator9.f();
|
|
835
|
+
return _context5.finish(27);
|
|
836
|
+
case 30:
|
|
837
|
+
resultReporter(converted);
|
|
838
|
+
case 31:
|
|
839
|
+
case "end":
|
|
840
|
+
return _context5.stop();
|
|
841
|
+
}
|
|
842
|
+
}, _callee5, null, [[5, 24, 27, 30], [9, 17]]);
|
|
843
|
+
}));
|
|
844
|
+
return function (_x5) {
|
|
845
|
+
return _ref7.apply(this, arguments);
|
|
846
|
+
};
|
|
847
|
+
}());
|
|
848
|
+
var params = {
|
|
849
|
+
identifier: _this6.options.identifier,
|
|
850
|
+
previousResultIds: convertPreviousResultIds(resultIds),
|
|
851
|
+
partialResultToken: partialResultToken
|
|
852
|
+
};
|
|
853
|
+
if (_this6.isDisposed === true || !_this6.client.isRunning()) {
|
|
854
|
+
return {
|
|
855
|
+
items: []
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
return _this6.client.sendRequest(WorkspaceDiagnosticRequest.type, params, token).then( /*#__PURE__*/function () {
|
|
859
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(result) {
|
|
860
|
+
var converted, _iterator10, _step10, item;
|
|
861
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
862
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
863
|
+
case 0:
|
|
864
|
+
if (!token.isCancellationRequested) {
|
|
865
|
+
_context6.next = 2;
|
|
866
|
+
break;
|
|
867
|
+
}
|
|
868
|
+
return _context6.abrupt("return", {
|
|
869
|
+
items: []
|
|
870
|
+
});
|
|
871
|
+
case 2:
|
|
872
|
+
converted = {
|
|
873
|
+
items: []
|
|
874
|
+
};
|
|
875
|
+
_iterator10 = _createForOfIteratorHelper(result.items);
|
|
876
|
+
_context6.prev = 4;
|
|
877
|
+
_iterator10.s();
|
|
878
|
+
case 6:
|
|
879
|
+
if ((_step10 = _iterator10.n()).done) {
|
|
880
|
+
_context6.next = 15;
|
|
881
|
+
break;
|
|
882
|
+
}
|
|
883
|
+
item = _step10.value;
|
|
884
|
+
_context6.t0 = converted.items;
|
|
885
|
+
_context6.next = 11;
|
|
886
|
+
return convertReport(item);
|
|
887
|
+
case 11:
|
|
888
|
+
_context6.t1 = _context6.sent;
|
|
889
|
+
_context6.t0.push.call(_context6.t0, _context6.t1);
|
|
890
|
+
case 13:
|
|
891
|
+
_context6.next = 6;
|
|
892
|
+
break;
|
|
893
|
+
case 15:
|
|
894
|
+
_context6.next = 20;
|
|
895
|
+
break;
|
|
896
|
+
case 17:
|
|
897
|
+
_context6.prev = 17;
|
|
898
|
+
_context6.t2 = _context6["catch"](4);
|
|
899
|
+
_iterator10.e(_context6.t2);
|
|
900
|
+
case 20:
|
|
901
|
+
_context6.prev = 20;
|
|
902
|
+
_iterator10.f();
|
|
903
|
+
return _context6.finish(20);
|
|
904
|
+
case 23:
|
|
905
|
+
disposable.dispose();
|
|
906
|
+
resultReporter(converted);
|
|
907
|
+
return _context6.abrupt("return", {
|
|
908
|
+
items: []
|
|
909
|
+
});
|
|
910
|
+
case 26:
|
|
911
|
+
case "end":
|
|
912
|
+
return _context6.stop();
|
|
913
|
+
}
|
|
914
|
+
}, _callee6, null, [[4, 17, 20, 23]]);
|
|
915
|
+
}));
|
|
916
|
+
return function (_x6) {
|
|
917
|
+
return _ref8.apply(this, arguments);
|
|
918
|
+
};
|
|
919
|
+
}(), function (error) {
|
|
920
|
+
disposable.dispose();
|
|
921
|
+
return _this6.client.handleFailedRequest(DocumentDiagnosticRequest.type, token, error, {
|
|
922
|
+
items: []
|
|
923
|
+
});
|
|
924
|
+
});
|
|
925
|
+
};
|
|
926
|
+
var middleware = _this6.client.middleware;
|
|
927
|
+
return middleware.provideWorkspaceDiagnostics ? middleware.provideWorkspaceDiagnostics(resultIds, token, resultReporter, provideDiagnostics) : provideDiagnostics(resultIds, token, resultReporter);
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
return result;
|
|
931
|
+
}
|
|
932
|
+
}, {
|
|
933
|
+
key: "dispose",
|
|
934
|
+
value: function dispose() {
|
|
935
|
+
var _this$workspaceCancel, _this$workspaceTimeou;
|
|
936
|
+
this.isDisposed = true;
|
|
937
|
+
|
|
938
|
+
// Cancel and clear workspace pull if present.
|
|
939
|
+
(_this$workspaceCancel = this.workspaceCancellation) === null || _this$workspaceCancel === void 0 || _this$workspaceCancel.cancel();
|
|
940
|
+
(_this$workspaceTimeou = this.workspaceTimeout) === null || _this$workspaceTimeou === void 0 || _this$workspaceTimeou.dispose();
|
|
941
|
+
|
|
942
|
+
// Cancel all request and mark open requests as outdated.
|
|
943
|
+
var _iterator11 = _createForOfIteratorHelper(this.openRequests),
|
|
944
|
+
_step11;
|
|
945
|
+
try {
|
|
946
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
947
|
+
var _step11$value = _slicedToArray(_step11.value, 2),
|
|
948
|
+
key = _step11$value[0],
|
|
949
|
+
request = _step11$value[1];
|
|
950
|
+
if (request.state === RequestStateKind.active) {
|
|
951
|
+
request.tokenSource.cancel();
|
|
952
|
+
}
|
|
953
|
+
this.openRequests.set(key, {
|
|
954
|
+
state: RequestStateKind.outDated,
|
|
955
|
+
document: request.document
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
// cleanup old diagnostics
|
|
960
|
+
} catch (err) {
|
|
961
|
+
_iterator11.e(err);
|
|
962
|
+
} finally {
|
|
963
|
+
_iterator11.f();
|
|
964
|
+
}
|
|
965
|
+
this.diagnostics.dispose();
|
|
966
|
+
}
|
|
967
|
+
}]);
|
|
968
|
+
return DiagnosticRequestor;
|
|
969
|
+
}();
|
|
970
|
+
var BackgroundScheduler = /*#__PURE__*/function () {
|
|
971
|
+
// The problem is that there could be outstanding diagnostic requests
|
|
972
|
+
// when we shutdown which when we receive the result will trigger a
|
|
973
|
+
// reschedule. So we remember if the background scheduler got disposed
|
|
974
|
+
// and ignore those re-schedules
|
|
975
|
+
|
|
976
|
+
function BackgroundScheduler(diagnosticRequestor) {
|
|
977
|
+
_classCallCheck(this, BackgroundScheduler);
|
|
978
|
+
this.diagnosticRequestor = diagnosticRequestor;
|
|
979
|
+
this.documents = new LinkedMap();
|
|
980
|
+
this.isDisposed = false;
|
|
981
|
+
}
|
|
982
|
+
_createClass(BackgroundScheduler, [{
|
|
983
|
+
key: "add",
|
|
984
|
+
value: function add(document) {
|
|
985
|
+
if (this.isDisposed === true) {
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
var key = DocumentOrUri.asKey(document);
|
|
989
|
+
if (this.documents.has(key)) {
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
this.documents.set(key, document, Touch.Last);
|
|
993
|
+
this.trigger();
|
|
994
|
+
}
|
|
995
|
+
}, {
|
|
996
|
+
key: "remove",
|
|
997
|
+
value: function remove(document) {
|
|
998
|
+
var key = DocumentOrUri.asKey(document);
|
|
999
|
+
this.documents.delete(key);
|
|
1000
|
+
// No more documents. Stop background activity.
|
|
1001
|
+
if (this.documents.size === 0) {
|
|
1002
|
+
this.stop();
|
|
1003
|
+
} else if (key === this.endDocumentKey()) {
|
|
1004
|
+
// Make sure we have a correct last document. It could have
|
|
1005
|
+
this.endDocument = this.documents.last;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}, {
|
|
1009
|
+
key: "trigger",
|
|
1010
|
+
value: function trigger() {
|
|
1011
|
+
var _this7 = this;
|
|
1012
|
+
if (this.isDisposed === true) {
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
// We have a round running. So simply make sure we run up to the
|
|
1016
|
+
// last document
|
|
1017
|
+
if (this.intervalHandle !== undefined) {
|
|
1018
|
+
this.endDocument = this.documents.last;
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
this.endDocument = this.documents.last;
|
|
1022
|
+
this.intervalHandle = RAL().timer.setInterval(function () {
|
|
1023
|
+
var document = _this7.documents.first;
|
|
1024
|
+
if (document !== undefined) {
|
|
1025
|
+
var key = DocumentOrUri.asKey(document);
|
|
1026
|
+
_this7.diagnosticRequestor.pull(document);
|
|
1027
|
+
_this7.documents.set(key, document, Touch.Last);
|
|
1028
|
+
if (key === _this7.endDocumentKey()) {
|
|
1029
|
+
_this7.stop();
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
}, 200);
|
|
1033
|
+
}
|
|
1034
|
+
}, {
|
|
1035
|
+
key: "dispose",
|
|
1036
|
+
value: function dispose() {
|
|
1037
|
+
this.isDisposed = true;
|
|
1038
|
+
this.stop();
|
|
1039
|
+
this.documents.clear();
|
|
1040
|
+
}
|
|
1041
|
+
}, {
|
|
1042
|
+
key: "stop",
|
|
1043
|
+
value: function stop() {
|
|
1044
|
+
var _this$intervalHandle;
|
|
1045
|
+
(_this$intervalHandle = this.intervalHandle) === null || _this$intervalHandle === void 0 || _this$intervalHandle.dispose();
|
|
1046
|
+
this.intervalHandle = undefined;
|
|
1047
|
+
this.endDocument = undefined;
|
|
1048
|
+
}
|
|
1049
|
+
}, {
|
|
1050
|
+
key: "endDocumentKey",
|
|
1051
|
+
value: function endDocumentKey() {
|
|
1052
|
+
return this.endDocument !== undefined ? DocumentOrUri.asKey(this.endDocument) : undefined;
|
|
1053
|
+
}
|
|
1054
|
+
}]);
|
|
1055
|
+
return BackgroundScheduler;
|
|
1056
|
+
}();
|
|
1057
|
+
var DiagnosticFeatureProviderImpl = /*#__PURE__*/function () {
|
|
1058
|
+
function DiagnosticFeatureProviderImpl(client, tabs, options) {
|
|
1059
|
+
var _client$clientOptions,
|
|
1060
|
+
_this8 = this,
|
|
1061
|
+
_Window$activeTextEdi3;
|
|
1062
|
+
_classCallCheck(this, DiagnosticFeatureProviderImpl);
|
|
1063
|
+
var diagnosticPullOptions = (_client$clientOptions = client.clientOptions.diagnosticPullOptions) !== null && _client$clientOptions !== void 0 ? _client$clientOptions : {
|
|
1064
|
+
onChange: true,
|
|
1065
|
+
onSave: false
|
|
1066
|
+
};
|
|
1067
|
+
var documentSelector = client.protocol2CodeConverter.asDocumentSelector(options.documentSelector);
|
|
1068
|
+
var disposables = [];
|
|
1069
|
+
var matchResource = function matchResource(resource) {
|
|
1070
|
+
var selector = options.documentSelector;
|
|
1071
|
+
if (diagnosticPullOptions.match !== undefined) {
|
|
1072
|
+
return diagnosticPullOptions.match(selector, resource);
|
|
1073
|
+
}
|
|
1074
|
+
var _iterator12 = _createForOfIteratorHelper(selector),
|
|
1075
|
+
_step12;
|
|
1076
|
+
try {
|
|
1077
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
1078
|
+
var _filter = _step12.value;
|
|
1079
|
+
if (!TextDocumentFilter.is(_filter)) {
|
|
1080
|
+
continue;
|
|
1081
|
+
}
|
|
1082
|
+
// The filter is a language id. We can't determine if it matches
|
|
1083
|
+
// so we return false.
|
|
1084
|
+
if (typeof _filter === 'string') {
|
|
1085
|
+
return false;
|
|
1086
|
+
}
|
|
1087
|
+
if (_filter.language !== undefined && _filter.language !== '*') {
|
|
1088
|
+
return false;
|
|
1089
|
+
}
|
|
1090
|
+
if (_filter.scheme !== undefined && _filter.scheme !== '*' && _filter.scheme !== resource.scheme) {
|
|
1091
|
+
return false;
|
|
1092
|
+
}
|
|
1093
|
+
if (_filter.pattern !== undefined) {
|
|
1094
|
+
var matcher = new minimatch.Minimatch(_filter.pattern, {
|
|
1095
|
+
noext: true
|
|
1096
|
+
});
|
|
1097
|
+
if (!matcher.makeRe()) {
|
|
1098
|
+
return false;
|
|
1099
|
+
}
|
|
1100
|
+
if (!matcher.match(resource.fsPath)) {
|
|
1101
|
+
return false;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
} catch (err) {
|
|
1106
|
+
_iterator12.e(err);
|
|
1107
|
+
} finally {
|
|
1108
|
+
_iterator12.f();
|
|
1109
|
+
}
|
|
1110
|
+
return true;
|
|
1111
|
+
};
|
|
1112
|
+
var matches = function matches(document) {
|
|
1113
|
+
return document instanceof Uri ? matchResource(document) : Languages.match(documentSelector, document) > 0 && tabs.isVisible(document);
|
|
1114
|
+
};
|
|
1115
|
+
var isActiveDocument = function isActiveDocument(document) {
|
|
1116
|
+
var _this8$activeTextDocu;
|
|
1117
|
+
return document instanceof Uri ? ((_this8$activeTextDocu = _this8.activeTextDocument) === null || _this8$activeTextDocu === void 0 ? void 0 : _this8$activeTextDocu.uri.toString()) === document.toString() : _this8.activeTextDocument === document;
|
|
1118
|
+
};
|
|
1119
|
+
this.diagnosticRequestor = new DiagnosticRequestor(client, tabs, options);
|
|
1120
|
+
this.backgroundScheduler = new BackgroundScheduler(this.diagnosticRequestor);
|
|
1121
|
+
var addToBackgroundIfNeeded = function addToBackgroundIfNeeded(document) {
|
|
1122
|
+
if (!matches(document) || !options.interFileDependencies || isActiveDocument(document)) {
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
_this8.backgroundScheduler.add(document);
|
|
1126
|
+
};
|
|
1127
|
+
this.activeTextDocument = (_Window$activeTextEdi3 = Window.activeTextEditor) === null || _Window$activeTextEdi3 === void 0 ? void 0 : _Window$activeTextEdi3.document;
|
|
1128
|
+
Window.onDidChangeActiveTextEditor(function (editor) {
|
|
1129
|
+
var oldActive = _this8.activeTextDocument;
|
|
1130
|
+
_this8.activeTextDocument = editor === null || editor === void 0 ? void 0 : editor.document;
|
|
1131
|
+
if (oldActive !== undefined) {
|
|
1132
|
+
addToBackgroundIfNeeded(oldActive);
|
|
1133
|
+
}
|
|
1134
|
+
if (_this8.activeTextDocument !== undefined) {
|
|
1135
|
+
_this8.backgroundScheduler.remove(_this8.activeTextDocument);
|
|
1136
|
+
}
|
|
1137
|
+
});
|
|
1138
|
+
|
|
1139
|
+
// For pull model diagnostics we pull for documents visible in the UI.
|
|
1140
|
+
// From an eventing point of view we still rely on open document events
|
|
1141
|
+
// and filter the documents that are not visible in the UI instead of
|
|
1142
|
+
// listening to Tab events. Major reason is event timing since we need
|
|
1143
|
+
// to ensure that the pull is send after the document open has reached
|
|
1144
|
+
// the server.
|
|
1145
|
+
|
|
1146
|
+
// We always pull on open.
|
|
1147
|
+
var openFeature = client.getFeature(DidOpenTextDocumentNotification.method);
|
|
1148
|
+
disposables.push(openFeature.onNotificationSent(function (event) {
|
|
1149
|
+
var textDocument = event.textDocument;
|
|
1150
|
+
// We already know about this document. This can happen via a tab open.
|
|
1151
|
+
if (_this8.diagnosticRequestor.knows(PullState.document, textDocument)) {
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
if (matches(textDocument)) {
|
|
1155
|
+
_this8.diagnosticRequestor.pull(textDocument, function () {
|
|
1156
|
+
addToBackgroundIfNeeded(textDocument);
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
}));
|
|
1160
|
+
disposables.push(tabs.onOpen(function (opened) {
|
|
1161
|
+
var _iterator13 = _createForOfIteratorHelper(opened),
|
|
1162
|
+
_step13;
|
|
1163
|
+
try {
|
|
1164
|
+
var _loop = function _loop() {
|
|
1165
|
+
var resource = _step13.value;
|
|
1166
|
+
// We already know about this document. This can happen via a document open.
|
|
1167
|
+
if (_this8.diagnosticRequestor.knows(PullState.document, resource)) {
|
|
1168
|
+
return 1; // continue
|
|
1169
|
+
}
|
|
1170
|
+
var uriStr = resource.toString();
|
|
1171
|
+
var textDocument;
|
|
1172
|
+
var _iterator14 = _createForOfIteratorHelper(workspace.textDocuments),
|
|
1173
|
+
_step14;
|
|
1174
|
+
try {
|
|
1175
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
1176
|
+
var item = _step14.value;
|
|
1177
|
+
if (uriStr === item.uri.toString()) {
|
|
1178
|
+
textDocument = item;
|
|
1179
|
+
break;
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
// In VS Code the event timing is as follows:
|
|
1183
|
+
// 1. tab events are fired.
|
|
1184
|
+
// 2. open document events are fired and internal data structures like
|
|
1185
|
+
// workspace.textDocuments and Window.activeTextEditor are updated.
|
|
1186
|
+
//
|
|
1187
|
+
// This means: for newly created tab/editors we don't find the underlying
|
|
1188
|
+
// document yet. So we do nothing an rely on the underlying open document event
|
|
1189
|
+
// to be fired.
|
|
1190
|
+
} catch (err) {
|
|
1191
|
+
_iterator14.e(err);
|
|
1192
|
+
} finally {
|
|
1193
|
+
_iterator14.f();
|
|
1194
|
+
}
|
|
1195
|
+
if (textDocument !== undefined && matches(textDocument)) {
|
|
1196
|
+
_this8.diagnosticRequestor.pull(textDocument, function () {
|
|
1197
|
+
addToBackgroundIfNeeded(textDocument);
|
|
1198
|
+
});
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
1202
|
+
if (_loop()) continue;
|
|
1203
|
+
}
|
|
1204
|
+
} catch (err) {
|
|
1205
|
+
_iterator13.e(err);
|
|
1206
|
+
} finally {
|
|
1207
|
+
_iterator13.f();
|
|
1208
|
+
}
|
|
1209
|
+
}));
|
|
1210
|
+
|
|
1211
|
+
// Pull all diagnostics for documents that are already open
|
|
1212
|
+
var pulledTextDocuments = new Set();
|
|
1213
|
+
var _iterator15 = _createForOfIteratorHelper(Workspace.textDocuments),
|
|
1214
|
+
_step15;
|
|
1215
|
+
try {
|
|
1216
|
+
var _loop3 = function _loop3() {
|
|
1217
|
+
var textDocument = _step15.value;
|
|
1218
|
+
if (matches(textDocument)) {
|
|
1219
|
+
_this8.diagnosticRequestor.pull(textDocument, function () {
|
|
1220
|
+
addToBackgroundIfNeeded(textDocument);
|
|
1221
|
+
});
|
|
1222
|
+
pulledTextDocuments.add(textDocument.uri.toString());
|
|
1223
|
+
}
|
|
1224
|
+
};
|
|
1225
|
+
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
1226
|
+
_loop3();
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
// Pull all tabs if not already pulled as text document
|
|
1230
|
+
} catch (err) {
|
|
1231
|
+
_iterator15.e(err);
|
|
1232
|
+
} finally {
|
|
1233
|
+
_iterator15.f();
|
|
1234
|
+
}
|
|
1235
|
+
if (diagnosticPullOptions.onTabs === true) {
|
|
1236
|
+
var _iterator16 = _createForOfIteratorHelper(tabs.getTabResources()),
|
|
1237
|
+
_step16;
|
|
1238
|
+
try {
|
|
1239
|
+
var _loop2 = function _loop2() {
|
|
1240
|
+
var resource = _step16.value;
|
|
1241
|
+
if (!pulledTextDocuments.has(resource.toString()) && matches(resource)) {
|
|
1242
|
+
_this8.diagnosticRequestor.pull(resource, function () {
|
|
1243
|
+
addToBackgroundIfNeeded(resource);
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
};
|
|
1247
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
1248
|
+
_loop2();
|
|
1249
|
+
}
|
|
1250
|
+
} catch (err) {
|
|
1251
|
+
_iterator16.e(err);
|
|
1252
|
+
} finally {
|
|
1253
|
+
_iterator16.f();
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
// We don't need to pull on tab open since we will receive a document open as well later on
|
|
1258
|
+
// and that event allows us to use a document for a match check which will have a set
|
|
1259
|
+
// language id.
|
|
1260
|
+
|
|
1261
|
+
if (diagnosticPullOptions.onChange === true) {
|
|
1262
|
+
var changeFeature = client.getFeature(DidChangeTextDocumentNotification.method);
|
|
1263
|
+
disposables.push(changeFeature.onNotificationSent( /*#__PURE__*/function () {
|
|
1264
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(event) {
|
|
1265
|
+
var textDocument;
|
|
1266
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
1267
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
1268
|
+
case 0:
|
|
1269
|
+
textDocument = event.textDocument;
|
|
1270
|
+
if ((diagnosticPullOptions.filter === undefined || !diagnosticPullOptions.filter(textDocument, DiagnosticPullMode.onType)) && _this8.diagnosticRequestor.knows(PullState.document, textDocument)) {
|
|
1271
|
+
_this8.diagnosticRequestor.pull(textDocument, function () {
|
|
1272
|
+
_this8.backgroundScheduler.trigger();
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
case 2:
|
|
1276
|
+
case "end":
|
|
1277
|
+
return _context7.stop();
|
|
1278
|
+
}
|
|
1279
|
+
}, _callee7);
|
|
1280
|
+
}));
|
|
1281
|
+
return function (_x7) {
|
|
1282
|
+
return _ref9.apply(this, arguments);
|
|
1283
|
+
};
|
|
1284
|
+
}()));
|
|
1285
|
+
}
|
|
1286
|
+
if (diagnosticPullOptions.onSave === true) {
|
|
1287
|
+
var saveFeature = client.getFeature(DidSaveTextDocumentNotification.method);
|
|
1288
|
+
disposables.push(saveFeature.onNotificationSent(function (event) {
|
|
1289
|
+
var textDocument = event.textDocument;
|
|
1290
|
+
if ((diagnosticPullOptions.filter === undefined || !diagnosticPullOptions.filter(textDocument, DiagnosticPullMode.onSave)) && _this8.diagnosticRequestor.knows(PullState.document, textDocument)) {
|
|
1291
|
+
_this8.diagnosticRequestor.pull(event.textDocument, function () {
|
|
1292
|
+
_this8.backgroundScheduler.trigger();
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
}));
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
// When the document closes clear things up
|
|
1299
|
+
var closeFeature = client.getFeature(DidCloseTextDocumentNotification.method);
|
|
1300
|
+
disposables.push(closeFeature.onNotificationSent(function (event) {
|
|
1301
|
+
_this8.cleanUpDocument(event.textDocument);
|
|
1302
|
+
}));
|
|
1303
|
+
|
|
1304
|
+
// Same when a tabs closes.
|
|
1305
|
+
tabs.onClose(function (closed) {
|
|
1306
|
+
var _iterator17 = _createForOfIteratorHelper(closed),
|
|
1307
|
+
_step17;
|
|
1308
|
+
try {
|
|
1309
|
+
for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
|
|
1310
|
+
var _document = _step17.value;
|
|
1311
|
+
_this8.cleanUpDocument(_document);
|
|
1312
|
+
}
|
|
1313
|
+
} catch (err) {
|
|
1314
|
+
_iterator17.e(err);
|
|
1315
|
+
} finally {
|
|
1316
|
+
_iterator17.f();
|
|
1317
|
+
}
|
|
1318
|
+
});
|
|
1319
|
+
|
|
1320
|
+
// We received a did change from the server.
|
|
1321
|
+
this.diagnosticRequestor.onDidChangeDiagnosticsEmitter.event(function () {
|
|
1322
|
+
var _iterator18 = _createForOfIteratorHelper(Workspace.textDocuments),
|
|
1323
|
+
_step18;
|
|
1324
|
+
try {
|
|
1325
|
+
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
1326
|
+
var _textDocument = _step18.value;
|
|
1327
|
+
if (matches(_textDocument)) {
|
|
1328
|
+
_this8.diagnosticRequestor.pull(_textDocument);
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
} catch (err) {
|
|
1332
|
+
_iterator18.e(err);
|
|
1333
|
+
} finally {
|
|
1334
|
+
_iterator18.f();
|
|
1335
|
+
}
|
|
1336
|
+
});
|
|
1337
|
+
|
|
1338
|
+
// da348dc5-c30a-4515-9d98-31ff3be38d14 is the test UUID to test the middle ware. So don't auto trigger pulls.
|
|
1339
|
+
if (options.workspaceDiagnostics === true && options.identifier !== 'da348dc5-c30a-4515-9d98-31ff3be38d14') {
|
|
1340
|
+
this.diagnosticRequestor.pullWorkspace();
|
|
1341
|
+
}
|
|
1342
|
+
this.disposable = Disposable.from.apply(Disposable, disposables.concat([this.backgroundScheduler, this.diagnosticRequestor]));
|
|
1343
|
+
}
|
|
1344
|
+
_createClass(DiagnosticFeatureProviderImpl, [{
|
|
1345
|
+
key: "onDidChangeDiagnosticsEmitter",
|
|
1346
|
+
get: function get() {
|
|
1347
|
+
return this.diagnosticRequestor.onDidChangeDiagnosticsEmitter;
|
|
1348
|
+
}
|
|
1349
|
+
}, {
|
|
1350
|
+
key: "diagnostics",
|
|
1351
|
+
get: function get() {
|
|
1352
|
+
return this.diagnosticRequestor.provider;
|
|
1353
|
+
}
|
|
1354
|
+
}, {
|
|
1355
|
+
key: "cleanUpDocument",
|
|
1356
|
+
value: function cleanUpDocument(document) {
|
|
1357
|
+
if (this.diagnosticRequestor.knows(PullState.document, document)) {
|
|
1358
|
+
this.diagnosticRequestor.forgetDocument(document);
|
|
1359
|
+
this.backgroundScheduler.remove(document);
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
}]);
|
|
1363
|
+
return DiagnosticFeatureProviderImpl;
|
|
1364
|
+
}();
|
|
1365
|
+
export var DiagnosticFeature = /*#__PURE__*/function (_TextDocumentLanguage) {
|
|
1366
|
+
_inherits(DiagnosticFeature, _TextDocumentLanguage);
|
|
1367
|
+
var _super = _createSuper(DiagnosticFeature);
|
|
1368
|
+
function DiagnosticFeature(client) {
|
|
1369
|
+
_classCallCheck(this, DiagnosticFeature);
|
|
1370
|
+
return _super.call(this, client, DocumentDiagnosticRequest.type);
|
|
1371
|
+
}
|
|
1372
|
+
_createClass(DiagnosticFeature, [{
|
|
1373
|
+
key: "fillClientCapabilities",
|
|
1374
|
+
value: function fillClientCapabilities(capabilities) {
|
|
1375
|
+
var capability = ensure(ensure(capabilities, 'textDocument'), 'diagnostic');
|
|
1376
|
+
capability.dynamicRegistration = true;
|
|
1377
|
+
// We first need to decide how a UI will look with related documents.
|
|
1378
|
+
// An easy implementation would be to only show related diagnostics for
|
|
1379
|
+
// the active editor.
|
|
1380
|
+
capability.relatedDocumentSupport = false;
|
|
1381
|
+
ensure(ensure(capabilities, 'workspace'), 'diagnostics').refreshSupport = true;
|
|
1382
|
+
}
|
|
1383
|
+
}, {
|
|
1384
|
+
key: "initialize",
|
|
1385
|
+
value: function initialize(capabilities, documentSelector) {
|
|
1386
|
+
var _this9 = this;
|
|
1387
|
+
var client = this._client;
|
|
1388
|
+
client.onRequest(DiagnosticRefreshRequest.type, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
1389
|
+
var _iterator19, _step19, provider;
|
|
1390
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
1391
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1392
|
+
case 0:
|
|
1393
|
+
_iterator19 = _createForOfIteratorHelper(_this9.getAllProviders());
|
|
1394
|
+
try {
|
|
1395
|
+
for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
|
|
1396
|
+
provider = _step19.value;
|
|
1397
|
+
provider.onDidChangeDiagnosticsEmitter.fire();
|
|
1398
|
+
}
|
|
1399
|
+
} catch (err) {
|
|
1400
|
+
_iterator19.e(err);
|
|
1401
|
+
} finally {
|
|
1402
|
+
_iterator19.f();
|
|
1403
|
+
}
|
|
1404
|
+
case 2:
|
|
1405
|
+
case "end":
|
|
1406
|
+
return _context8.stop();
|
|
1407
|
+
}
|
|
1408
|
+
}, _callee8);
|
|
1409
|
+
})));
|
|
1410
|
+
var _this$getRegistration = this.getRegistration(documentSelector, capabilities.diagnosticProvider),
|
|
1411
|
+
_this$getRegistration2 = _slicedToArray(_this$getRegistration, 2),
|
|
1412
|
+
id = _this$getRegistration2[0],
|
|
1413
|
+
options = _this$getRegistration2[1];
|
|
1414
|
+
if (!id || !options) {
|
|
1415
|
+
return;
|
|
1416
|
+
}
|
|
1417
|
+
this.register({
|
|
1418
|
+
id: id,
|
|
1419
|
+
registerOptions: options
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
}, {
|
|
1423
|
+
key: "clear",
|
|
1424
|
+
value: function clear() {
|
|
1425
|
+
if (this.tabs !== undefined) {
|
|
1426
|
+
this.tabs.dispose();
|
|
1427
|
+
this.tabs = undefined;
|
|
1428
|
+
}
|
|
1429
|
+
_get(_getPrototypeOf(DiagnosticFeature.prototype), "clear", this).call(this);
|
|
1430
|
+
}
|
|
1431
|
+
}, {
|
|
1432
|
+
key: "registerLanguageProvider",
|
|
1433
|
+
value: function registerLanguageProvider(options) {
|
|
1434
|
+
if (this.tabs === undefined) {
|
|
1435
|
+
this.tabs = new Tabs();
|
|
1436
|
+
}
|
|
1437
|
+
var provider = new DiagnosticFeatureProviderImpl(this._client, this.tabs, options);
|
|
1438
|
+
return [provider.disposable, provider];
|
|
1439
|
+
}
|
|
1440
|
+
}]);
|
|
1441
|
+
return DiagnosticFeature;
|
|
1442
|
+
}(TextDocumentLanguageFeature);
|