@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,1444 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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; } }
|
|
4
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
5
|
+
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); }
|
|
6
|
+
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; }
|
|
7
|
+
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); } }
|
|
8
|
+
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); }); }; }
|
|
9
|
+
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; } } }; }
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
12
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
+
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); } }
|
|
14
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
16
|
+
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); }
|
|
17
|
+
/* eslint-disable no-inner-declarations */
|
|
18
|
+
/* --------------------------------------------------------------------------------------------
|
|
19
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
20
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
21
|
+
* ------------------------------------------------------------------------------------------ */
|
|
22
|
+
|
|
23
|
+
import * as proto from '@difizen/vscode-languageserver-protocol';
|
|
24
|
+
import * as minimatch from 'minimatch';
|
|
25
|
+
import { LibroCellURIScheme } from "../constants.js";
|
|
26
|
+
import * as Is from "./utils/is.js";
|
|
27
|
+
import * as UUID from "./utils/uuid.js";
|
|
28
|
+
import { NotebookCellKind } from "./vscodeAdaptor/vscodeAdaptor.js";
|
|
29
|
+
import { workspace, languages } from "./vscodeAdaptor/vscodeAdaptor.js";
|
|
30
|
+
function ensure(target, key) {
|
|
31
|
+
if (target[key] === void 0) {
|
|
32
|
+
target[key] = {};
|
|
33
|
+
}
|
|
34
|
+
return target[key];
|
|
35
|
+
}
|
|
36
|
+
var Converter;
|
|
37
|
+
(function (_Converter) {
|
|
38
|
+
var c2p;
|
|
39
|
+
(function (_c2p2) {
|
|
40
|
+
function asVersionedNotebookDocumentIdentifier(notebookDocument, base) {
|
|
41
|
+
return {
|
|
42
|
+
version: notebookDocument.version,
|
|
43
|
+
uri: base.asUri(notebookDocument.uri)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
_c2p2.asVersionedNotebookDocumentIdentifier = asVersionedNotebookDocumentIdentifier;
|
|
47
|
+
function asNotebookDocument(notebookDocument, cells, base) {
|
|
48
|
+
var result = proto.NotebookDocument.create(base.asUri(notebookDocument.uri), notebookDocument.notebookType, notebookDocument.version, asNotebookCells(cells, base));
|
|
49
|
+
if (Object.keys(notebookDocument.metadata).length > 0) {
|
|
50
|
+
result.metadata = asMetadata(notebookDocument.metadata);
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
_c2p2.asNotebookDocument = asNotebookDocument;
|
|
55
|
+
function asNotebookCells(cells, base) {
|
|
56
|
+
return cells.map(function (cell) {
|
|
57
|
+
return asNotebookCell(cell, base);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
_c2p2.asNotebookCells = asNotebookCells;
|
|
61
|
+
function asMetadata(metadata) {
|
|
62
|
+
var seen = new Set();
|
|
63
|
+
return deepCopy(seen, metadata);
|
|
64
|
+
}
|
|
65
|
+
_c2p2.asMetadata = asMetadata;
|
|
66
|
+
function asNotebookCell(cell, base) {
|
|
67
|
+
var result = proto.NotebookCell.create(asNotebookCellKind(cell.kind), base.asUri(cell.document.uri));
|
|
68
|
+
if (Object.keys(cell.metadata).length > 0) {
|
|
69
|
+
result.metadata = asMetadata(cell.metadata);
|
|
70
|
+
}
|
|
71
|
+
if (cell.executionSummary !== undefined && Is.number(cell.executionSummary.executionOrder) && Is.boolean(cell.executionSummary.success)) {
|
|
72
|
+
result.executionSummary = {
|
|
73
|
+
executionOrder: cell.executionSummary.executionOrder,
|
|
74
|
+
success: cell.executionSummary.success
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
_c2p2.asNotebookCell = asNotebookCell;
|
|
80
|
+
function asNotebookCellKind(kind) {
|
|
81
|
+
switch (kind) {
|
|
82
|
+
case NotebookCellKind.Markup:
|
|
83
|
+
return proto.NotebookCellKind.Markup;
|
|
84
|
+
case NotebookCellKind.Code:
|
|
85
|
+
return proto.NotebookCellKind.Code;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function deepCopy(seen, value) {
|
|
89
|
+
if (seen.has(value)) {
|
|
90
|
+
throw new Error("Can't deep copy cyclic structures.");
|
|
91
|
+
}
|
|
92
|
+
if (Array.isArray(value)) {
|
|
93
|
+
var result = [];
|
|
94
|
+
var _iterator17 = _createForOfIteratorHelper(value),
|
|
95
|
+
_step17;
|
|
96
|
+
try {
|
|
97
|
+
for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
|
|
98
|
+
var elem = _step17.value;
|
|
99
|
+
if (elem !== null && _typeof(elem) === 'object' || Array.isArray(elem)) {
|
|
100
|
+
result.push(deepCopy(seen, elem));
|
|
101
|
+
} else {
|
|
102
|
+
if (elem instanceof RegExp) {
|
|
103
|
+
throw new Error("Can't transfer regular expressions to the server");
|
|
104
|
+
}
|
|
105
|
+
result.push(elem);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
} catch (err) {
|
|
109
|
+
_iterator17.e(err);
|
|
110
|
+
} finally {
|
|
111
|
+
_iterator17.f();
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
} else {
|
|
115
|
+
var props = Object.keys(value);
|
|
116
|
+
var _result = Object.create(null);
|
|
117
|
+
for (var _i2 = 0, _props = props; _i2 < _props.length; _i2++) {
|
|
118
|
+
var prop = _props[_i2];
|
|
119
|
+
var _elem = value[prop];
|
|
120
|
+
if (_elem !== null && _typeof(_elem) === 'object' || Array.isArray(_elem)) {
|
|
121
|
+
_result[prop] = deepCopy(seen, _elem);
|
|
122
|
+
} else {
|
|
123
|
+
if (_elem instanceof RegExp) {
|
|
124
|
+
throw new Error("Can't transfer regular expressions to the server");
|
|
125
|
+
}
|
|
126
|
+
_result[prop] = _elem;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return _result;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function asTextContentChange(event, base) {
|
|
133
|
+
var params = base.asChangeTextDocumentParams(event, event.document.uri, event.document.version);
|
|
134
|
+
return {
|
|
135
|
+
document: params.textDocument,
|
|
136
|
+
changes: params.contentChanges
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
_c2p2.asTextContentChange = asTextContentChange;
|
|
140
|
+
function asNotebookDocumentChangeEvent(event, base) {
|
|
141
|
+
var result = Object.create(null);
|
|
142
|
+
if (event.metadata) {
|
|
143
|
+
result.metadata = Converter.c2p.asMetadata(event.metadata);
|
|
144
|
+
}
|
|
145
|
+
if (event.cells !== undefined) {
|
|
146
|
+
var _cells3 = Object.create(null);
|
|
147
|
+
var changedCells = event.cells;
|
|
148
|
+
if (changedCells.structure) {
|
|
149
|
+
_cells3.structure = {
|
|
150
|
+
array: {
|
|
151
|
+
start: changedCells.structure.array.start,
|
|
152
|
+
deleteCount: changedCells.structure.array.deleteCount,
|
|
153
|
+
cells: changedCells.structure.array.cells !== undefined ? changedCells.structure.array.cells.map(function (cell) {
|
|
154
|
+
return Converter.c2p.asNotebookCell(cell, base);
|
|
155
|
+
}) : undefined
|
|
156
|
+
},
|
|
157
|
+
didOpen: changedCells.structure.didOpen !== undefined ? changedCells.structure.didOpen.map(function (cell) {
|
|
158
|
+
return base.asOpenTextDocumentParams(cell.document).textDocument;
|
|
159
|
+
}) : undefined,
|
|
160
|
+
didClose: changedCells.structure.didClose !== undefined ? changedCells.structure.didClose.map(function (cell) {
|
|
161
|
+
return base.asCloseTextDocumentParams(cell.document).textDocument;
|
|
162
|
+
}) : undefined
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
if (changedCells.data !== undefined) {
|
|
166
|
+
_cells3.data = changedCells.data.map(function (cell) {
|
|
167
|
+
return Converter.c2p.asNotebookCell(cell, base);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
if (changedCells.textContent !== undefined) {
|
|
171
|
+
_cells3.textContent = changedCells.textContent.map(function (event) {
|
|
172
|
+
return Converter.c2p.asTextContentChange(event, base);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
if (Object.keys(_cells3).length > 0) {
|
|
176
|
+
result.cells = _cells3;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
_c2p2.asNotebookDocumentChangeEvent = asNotebookDocumentChangeEvent;
|
|
182
|
+
})(c2p || (c2p = _Converter.c2p || (_Converter.c2p = {})));
|
|
183
|
+
})(Converter || (Converter = {}));
|
|
184
|
+
var $NotebookCell;
|
|
185
|
+
(function (_$NotebookCell) {
|
|
186
|
+
function computeDiff(originalCells, modifiedCells, compareMetadata) {
|
|
187
|
+
var originalLength = originalCells.length;
|
|
188
|
+
var modifiedLength = modifiedCells.length;
|
|
189
|
+
var startIndex = 0;
|
|
190
|
+
while (startIndex < modifiedLength && startIndex < originalLength && equals(originalCells[startIndex], modifiedCells[startIndex], compareMetadata)) {
|
|
191
|
+
startIndex++;
|
|
192
|
+
}
|
|
193
|
+
if (startIndex < modifiedLength && startIndex < originalLength) {
|
|
194
|
+
var originalEndIndex = originalLength - 1;
|
|
195
|
+
var modifiedEndIndex = modifiedLength - 1;
|
|
196
|
+
while (originalEndIndex >= 0 && modifiedEndIndex >= 0 && equals(originalCells[originalEndIndex], modifiedCells[modifiedEndIndex], compareMetadata)) {
|
|
197
|
+
originalEndIndex--;
|
|
198
|
+
modifiedEndIndex--;
|
|
199
|
+
}
|
|
200
|
+
var deleteCount = originalEndIndex + 1 - startIndex;
|
|
201
|
+
var newCells = startIndex === modifiedEndIndex + 1 ? undefined : modifiedCells.slice(startIndex, modifiedEndIndex + 1);
|
|
202
|
+
return newCells !== undefined ? {
|
|
203
|
+
start: startIndex,
|
|
204
|
+
deleteCount: deleteCount,
|
|
205
|
+
cells: newCells
|
|
206
|
+
} : {
|
|
207
|
+
start: startIndex,
|
|
208
|
+
deleteCount: deleteCount
|
|
209
|
+
};
|
|
210
|
+
} else if (startIndex < modifiedLength) {
|
|
211
|
+
return {
|
|
212
|
+
start: startIndex,
|
|
213
|
+
deleteCount: 0,
|
|
214
|
+
cells: modifiedCells.slice(startIndex)
|
|
215
|
+
};
|
|
216
|
+
} else if (startIndex < originalLength) {
|
|
217
|
+
return {
|
|
218
|
+
start: startIndex,
|
|
219
|
+
deleteCount: originalLength - startIndex
|
|
220
|
+
};
|
|
221
|
+
} else {
|
|
222
|
+
// The two arrays are the same.
|
|
223
|
+
return undefined;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
_$NotebookCell.computeDiff = computeDiff;
|
|
227
|
+
/**
|
|
228
|
+
* We only sync kind, document, execution and metadata to the server. So we only need to compare those.
|
|
229
|
+
*/
|
|
230
|
+
function equals(one, other) {
|
|
231
|
+
var compareMetaData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
232
|
+
if (one.kind !== other.kind || one.document.uri.toString() !== other.document.uri.toString() || one.document.languageId !== other.document.languageId || !equalsExecution(one.executionSummary, other.executionSummary)) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
return !compareMetaData || compareMetaData && equalsMetadata(one.metadata, other.metadata);
|
|
236
|
+
}
|
|
237
|
+
function equalsExecution(one, other) {
|
|
238
|
+
if (one === other) {
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
if (one === undefined || other === undefined) {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
return one.executionOrder === other.executionOrder && one.success === other.success && equalsTiming(one.timing, other.timing);
|
|
245
|
+
}
|
|
246
|
+
function equalsTiming(one, other) {
|
|
247
|
+
if (one === other) {
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
if (one === undefined || other === undefined) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
return one.startTime === other.startTime && one.endTime === other.endTime;
|
|
254
|
+
}
|
|
255
|
+
function equalsMetadata(one, other) {
|
|
256
|
+
if (one === other) {
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
if (one === null || one === undefined || other === null || other === undefined) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
if (_typeof(one) !== _typeof(other)) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
if (_typeof(one) !== 'object') {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
var oneArray = Array.isArray(one);
|
|
269
|
+
var otherArray = Array.isArray(other);
|
|
270
|
+
if (oneArray !== otherArray) {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
if (oneArray && otherArray) {
|
|
274
|
+
if (one.length !== other.length) {
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
for (var i = 0; i < one.length; i++) {
|
|
278
|
+
if (!equalsMetadata(one[i], other[i])) {
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
if (isObjectLiteral(one) && isObjectLiteral(other)) {
|
|
284
|
+
var oneKeys = Object.keys(one);
|
|
285
|
+
var otherKeys = Object.keys(other);
|
|
286
|
+
if (oneKeys.length !== otherKeys.length) {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
oneKeys.sort();
|
|
290
|
+
otherKeys.sort();
|
|
291
|
+
if (!equalsMetadata(oneKeys, otherKeys)) {
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
for (var _i3 = 0; _i3 < oneKeys.length; _i3++) {
|
|
295
|
+
var prop = oneKeys[_i3];
|
|
296
|
+
if (!equalsMetadata(one[prop], other[prop])) {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
function isObjectLiteral(value) {
|
|
305
|
+
return value !== null && _typeof(value) === 'object';
|
|
306
|
+
}
|
|
307
|
+
_$NotebookCell.isObjectLiteral = isObjectLiteral;
|
|
308
|
+
})($NotebookCell || ($NotebookCell = {}));
|
|
309
|
+
var $NotebookDocumentFilter;
|
|
310
|
+
(function (_$NotebookDocumentFilter) {
|
|
311
|
+
function matchNotebook(filter, notebookDocument) {
|
|
312
|
+
if (typeof filter === 'string') {
|
|
313
|
+
return filter === '*' || notebookDocument.notebookType === filter;
|
|
314
|
+
}
|
|
315
|
+
if (filter.notebookType !== undefined && filter.notebookType !== '*' && notebookDocument.notebookType !== filter.notebookType) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
var uri = notebookDocument.uri;
|
|
319
|
+
if (filter.scheme !== undefined && filter.scheme !== '*' && uri.scheme !== filter.scheme) {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
if (filter.pattern !== undefined) {
|
|
323
|
+
var matcher = new minimatch.Minimatch(filter.pattern, {
|
|
324
|
+
noext: true
|
|
325
|
+
});
|
|
326
|
+
if (!matcher.makeRe()) {
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
if (!matcher.match(uri.fsPath)) {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
_$NotebookDocumentFilter.matchNotebook = matchNotebook;
|
|
336
|
+
})($NotebookDocumentFilter || ($NotebookDocumentFilter = {}));
|
|
337
|
+
var $NotebookDocumentSyncOptions;
|
|
338
|
+
(function (_$NotebookDocumentSyncOptions) {
|
|
339
|
+
function asDocumentSelector(options) {
|
|
340
|
+
var selector = options.notebookSelector;
|
|
341
|
+
var result = [];
|
|
342
|
+
var _iterator18 = _createForOfIteratorHelper(selector),
|
|
343
|
+
_step18;
|
|
344
|
+
try {
|
|
345
|
+
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
346
|
+
var _ref5, _element$notebook, _element$notebook2, _element$notebook3;
|
|
347
|
+
var element = _step18.value;
|
|
348
|
+
var notebookType = (_ref5 = typeof element.notebook === 'string' ? element.notebook : (_element$notebook = element.notebook) === null || _element$notebook === void 0 ? void 0 : _element$notebook.notebookType) !== null && _ref5 !== void 0 ? _ref5 : '*';
|
|
349
|
+
var scheme = typeof element.notebook === 'string' ? undefined : (_element$notebook2 = element.notebook) === null || _element$notebook2 === void 0 ? void 0 : _element$notebook2.scheme;
|
|
350
|
+
var pattern = typeof element.notebook === 'string' ? undefined : (_element$notebook3 = element.notebook) === null || _element$notebook3 === void 0 ? void 0 : _element$notebook3.pattern;
|
|
351
|
+
if (element.cells !== undefined) {
|
|
352
|
+
var _iterator19 = _createForOfIteratorHelper(element.cells),
|
|
353
|
+
_step19;
|
|
354
|
+
try {
|
|
355
|
+
for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
|
|
356
|
+
var cell = _step19.value;
|
|
357
|
+
result.push(asDocumentFilter(notebookType, scheme, pattern, cell.language));
|
|
358
|
+
}
|
|
359
|
+
} catch (err) {
|
|
360
|
+
_iterator19.e(err);
|
|
361
|
+
} finally {
|
|
362
|
+
_iterator19.f();
|
|
363
|
+
}
|
|
364
|
+
} else {
|
|
365
|
+
result.push(asDocumentFilter(notebookType, scheme, pattern, undefined));
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
} catch (err) {
|
|
369
|
+
_iterator18.e(err);
|
|
370
|
+
} finally {
|
|
371
|
+
_iterator18.f();
|
|
372
|
+
}
|
|
373
|
+
return result;
|
|
374
|
+
}
|
|
375
|
+
_$NotebookDocumentSyncOptions.asDocumentSelector = asDocumentSelector;
|
|
376
|
+
function asDocumentFilter(notebookType, scheme, pattern, language) {
|
|
377
|
+
return scheme === undefined && pattern === undefined ? {
|
|
378
|
+
notebook: notebookType,
|
|
379
|
+
language: language
|
|
380
|
+
} : {
|
|
381
|
+
notebook: {
|
|
382
|
+
notebookType: notebookType,
|
|
383
|
+
scheme: scheme,
|
|
384
|
+
pattern: pattern
|
|
385
|
+
},
|
|
386
|
+
language: language
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
})($NotebookDocumentSyncOptions || ($NotebookDocumentSyncOptions = {}));
|
|
390
|
+
var SyncInfo;
|
|
391
|
+
(function (_SyncInfo) {
|
|
392
|
+
function create(cells) {
|
|
393
|
+
return {
|
|
394
|
+
cells: cells,
|
|
395
|
+
uris: new Set(cells.map(function (cell) {
|
|
396
|
+
return cell.document.uri.toString();
|
|
397
|
+
}))
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
_SyncInfo.create = create;
|
|
401
|
+
})(SyncInfo || (SyncInfo = {}));
|
|
402
|
+
var NotebookDocumentSyncFeatureProvider = /*#__PURE__*/function () {
|
|
403
|
+
function NotebookDocumentSyncFeatureProvider(client, options) {
|
|
404
|
+
var _this = this;
|
|
405
|
+
_classCallCheck(this, NotebookDocumentSyncFeatureProvider);
|
|
406
|
+
this.client = client;
|
|
407
|
+
this.options = options;
|
|
408
|
+
this.notebookSyncInfo = new Map();
|
|
409
|
+
this.notebookDidOpen = new Set();
|
|
410
|
+
this.disposables = [];
|
|
411
|
+
this.selector = client.protocol2CodeConverter.asDocumentSelector($NotebookDocumentSyncOptions.asDocumentSelector(options));
|
|
412
|
+
|
|
413
|
+
// open
|
|
414
|
+
workspace.onDidOpenNotebookDocument(function (notebookDocument) {
|
|
415
|
+
_this.notebookDidOpen.add(notebookDocument.uri.toString());
|
|
416
|
+
_this.didOpen(notebookDocument);
|
|
417
|
+
}, undefined, this.disposables);
|
|
418
|
+
var _iterator = _createForOfIteratorHelper(workspace.notebookDocuments),
|
|
419
|
+
_step;
|
|
420
|
+
try {
|
|
421
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
422
|
+
var _notebookDocument = _step.value;
|
|
423
|
+
this.notebookDidOpen.add(_notebookDocument.uri.toString());
|
|
424
|
+
this.didOpen(_notebookDocument);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// Notebook document changed.
|
|
428
|
+
} catch (err) {
|
|
429
|
+
_iterator.e(err);
|
|
430
|
+
} finally {
|
|
431
|
+
_iterator.f();
|
|
432
|
+
}
|
|
433
|
+
workspace.onDidChangeNotebookDocument(function (event) {
|
|
434
|
+
return _this.didChangeNotebookDocument(event);
|
|
435
|
+
}, undefined, this.disposables);
|
|
436
|
+
|
|
437
|
+
//save
|
|
438
|
+
if (this.options.save === true) {
|
|
439
|
+
workspace.onDidSaveNotebookDocument(function (notebookDocument) {
|
|
440
|
+
return _this.didSave(notebookDocument);
|
|
441
|
+
}, undefined, this.disposables);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// close
|
|
445
|
+
workspace.onDidCloseNotebookDocument(function (notebookDocument) {
|
|
446
|
+
_this.didClose(notebookDocument);
|
|
447
|
+
_this.notebookDidOpen.delete(notebookDocument.uri.toString());
|
|
448
|
+
}, undefined, this.disposables);
|
|
449
|
+
}
|
|
450
|
+
_createClass(NotebookDocumentSyncFeatureProvider, [{
|
|
451
|
+
key: "getState",
|
|
452
|
+
value: function getState() {
|
|
453
|
+
var _iterator2 = _createForOfIteratorHelper(workspace.notebookDocuments),
|
|
454
|
+
_step2;
|
|
455
|
+
try {
|
|
456
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
457
|
+
var notebook = _step2.value;
|
|
458
|
+
var matchingCells = this.getMatchingCells(notebook);
|
|
459
|
+
if (matchingCells !== undefined) {
|
|
460
|
+
return {
|
|
461
|
+
kind: 'document',
|
|
462
|
+
id: '$internal',
|
|
463
|
+
registrations: true,
|
|
464
|
+
matches: true
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
} catch (err) {
|
|
469
|
+
_iterator2.e(err);
|
|
470
|
+
} finally {
|
|
471
|
+
_iterator2.f();
|
|
472
|
+
}
|
|
473
|
+
return {
|
|
474
|
+
kind: 'document',
|
|
475
|
+
id: '$internal',
|
|
476
|
+
registrations: true,
|
|
477
|
+
matches: false
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
}, {
|
|
481
|
+
key: "mode",
|
|
482
|
+
get: function get() {
|
|
483
|
+
return 'notebook';
|
|
484
|
+
}
|
|
485
|
+
}, {
|
|
486
|
+
key: "handles",
|
|
487
|
+
value: function handles(textDocument) {
|
|
488
|
+
return languages.match(this.selector, textDocument) > 0;
|
|
489
|
+
}
|
|
490
|
+
}, {
|
|
491
|
+
key: "didOpenNotebookCellTextDocument",
|
|
492
|
+
value: function didOpenNotebookCellTextDocument(notebookDocument, cell) {
|
|
493
|
+
if (languages.match(this.selector, cell.document) === 0) {
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
if (!this.notebookDidOpen.has(notebookDocument.uri.toString())) {
|
|
497
|
+
// We have never received an open notification for the notebook document.
|
|
498
|
+
// VS Code guarantees that we first get cell document open and then
|
|
499
|
+
// notebook open. So simply wait for the notebook open.
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
var syncInfo = this.notebookSyncInfo.get(notebookDocument.uri.toString());
|
|
503
|
+
// In VS Code we receive a notebook open before a cell document open.
|
|
504
|
+
// The document and the cell is synced.
|
|
505
|
+
var cellMatches = this.cellMatches(notebookDocument, cell);
|
|
506
|
+
if (syncInfo !== undefined) {
|
|
507
|
+
var cellIsSynced = syncInfo.uris.has(cell.document.uri.toString());
|
|
508
|
+
if (cellMatches && cellIsSynced || !cellMatches && !cellIsSynced) {
|
|
509
|
+
// The cell doesn't match and was not synced or it matches and is synced.
|
|
510
|
+
// In both cases nothing to do.
|
|
511
|
+
//
|
|
512
|
+
// Note that if the language mode of a document changes we remove the
|
|
513
|
+
// cell and add it back to update the language mode on the server side.
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
if (cellMatches) {
|
|
517
|
+
// don't use cells from above since there might be more matching cells in the notebook
|
|
518
|
+
// Since we had a matching cell above we will have matching cells now.
|
|
519
|
+
var matchingCells = this.getMatchingCells(notebookDocument);
|
|
520
|
+
if (matchingCells !== undefined) {
|
|
521
|
+
var _event = this.asNotebookDocumentChangeEvent(notebookDocument, undefined, syncInfo, matchingCells);
|
|
522
|
+
if (_event !== undefined) {
|
|
523
|
+
this.doSendChange(_event, matchingCells).catch(function () {
|
|
524
|
+
/* handled in send change */
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
} else {
|
|
530
|
+
// No sync info. But we have a open event for the notebook document
|
|
531
|
+
// itself. If the cell matches then we need to send an open with
|
|
532
|
+
// exactly that cell.
|
|
533
|
+
if (cellMatches) {
|
|
534
|
+
this.doSendOpen(notebookDocument, [cell]).catch(function () {
|
|
535
|
+
/* handled in open */
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}, {
|
|
541
|
+
key: "didChangeNotebookCellTextDocument",
|
|
542
|
+
value: function didChangeNotebookCellTextDocument(notebookDocument, event) {
|
|
543
|
+
// No match with the selector
|
|
544
|
+
if (languages.match(this.selector, event.document) === 0) {
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
this.doSendChange({
|
|
548
|
+
notebook: notebookDocument,
|
|
549
|
+
cells: {
|
|
550
|
+
textContent: [event]
|
|
551
|
+
}
|
|
552
|
+
}, undefined).catch(function () {
|
|
553
|
+
/* error handled in doSendChange */
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
}, {
|
|
557
|
+
key: "didCloseNotebookCellTextDocument",
|
|
558
|
+
value: function didCloseNotebookCellTextDocument(notebookDocument, cell) {
|
|
559
|
+
var syncInfo = this.notebookSyncInfo.get(notebookDocument.uri.toString());
|
|
560
|
+
if (syncInfo === undefined) {
|
|
561
|
+
// The notebook document got never synced. So it doesn't matter if a cell
|
|
562
|
+
// document closes.
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
var cellUri = cell.document.uri;
|
|
566
|
+
var index = syncInfo.cells.findIndex(function (item) {
|
|
567
|
+
return item.document.uri.toString() === cellUri.toString();
|
|
568
|
+
});
|
|
569
|
+
if (index === -1) {
|
|
570
|
+
// The cell never got synced or it got deleted and we now received the document
|
|
571
|
+
// close event.
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
if (index === 0 && syncInfo.cells.length === 1) {
|
|
575
|
+
// The last cell. Close the notebook document in the server.
|
|
576
|
+
this.doSendClose(notebookDocument, syncInfo.cells).catch(function () {
|
|
577
|
+
/* error handled in doSendClose */
|
|
578
|
+
});
|
|
579
|
+
} else {
|
|
580
|
+
var newCells = syncInfo.cells.slice();
|
|
581
|
+
var deleted = newCells.splice(index, 1);
|
|
582
|
+
this.doSendChange({
|
|
583
|
+
notebook: notebookDocument,
|
|
584
|
+
cells: {
|
|
585
|
+
structure: {
|
|
586
|
+
array: {
|
|
587
|
+
start: index,
|
|
588
|
+
deleteCount: 1
|
|
589
|
+
},
|
|
590
|
+
didClose: deleted
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}, newCells).catch(function () {
|
|
594
|
+
/* error handled in doSendChange */
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}, {
|
|
599
|
+
key: "dispose",
|
|
600
|
+
value: function dispose() {
|
|
601
|
+
var _iterator3 = _createForOfIteratorHelper(this.disposables),
|
|
602
|
+
_step3;
|
|
603
|
+
try {
|
|
604
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
605
|
+
var disposable = _step3.value;
|
|
606
|
+
disposable.dispose();
|
|
607
|
+
}
|
|
608
|
+
} catch (err) {
|
|
609
|
+
_iterator3.e(err);
|
|
610
|
+
} finally {
|
|
611
|
+
_iterator3.f();
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}, {
|
|
615
|
+
key: "didOpen",
|
|
616
|
+
value: function didOpen(notebookDocument) {
|
|
617
|
+
var matchingCells = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getMatchingCells(notebookDocument);
|
|
618
|
+
var syncInfo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.notebookSyncInfo.get(notebookDocument.uri.toString());
|
|
619
|
+
if (syncInfo !== undefined) {
|
|
620
|
+
if (matchingCells !== undefined) {
|
|
621
|
+
var _event2 = this.asNotebookDocumentChangeEvent(notebookDocument, undefined, syncInfo, matchingCells);
|
|
622
|
+
if (_event2 !== undefined) {
|
|
623
|
+
this.doSendChange(_event2, matchingCells).catch(function () {
|
|
624
|
+
/* handled in send change */
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
} else {
|
|
628
|
+
this.doSendClose(notebookDocument, []).catch(function () {
|
|
629
|
+
/* handled in send close */
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
} else {
|
|
633
|
+
// Check if we need to sync the notebook document.
|
|
634
|
+
if (matchingCells === undefined) {
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
this.doSendOpen(notebookDocument, matchingCells).catch(function () {
|
|
638
|
+
/* error handled in doSendOpen */
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}, {
|
|
643
|
+
key: "didChangeNotebookDocument",
|
|
644
|
+
value: function didChangeNotebookDocument(event) {
|
|
645
|
+
var notebookDocument = event.notebook;
|
|
646
|
+
var syncInfo = this.notebookSyncInfo.get(notebookDocument.uri.toString());
|
|
647
|
+
if (syncInfo === undefined) {
|
|
648
|
+
// We have no changes to the cells. Since the notebook wasn't synced
|
|
649
|
+
// it will not be synced now.
|
|
650
|
+
if (event.contentChanges.length === 0) {
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
// Check if we have new matching cells.
|
|
655
|
+
var _cells = this.getMatchingCells(notebookDocument);
|
|
656
|
+
|
|
657
|
+
// No matching cells and the notebook never synced. So still no need
|
|
658
|
+
// to sync it.
|
|
659
|
+
if (_cells === undefined) {
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// Open the notebook document and ignore the rest of the changes
|
|
664
|
+
// this the notebooks will be synced with the correct settings.
|
|
665
|
+
this.didOpen(notebookDocument, _cells, syncInfo);
|
|
666
|
+
} else {
|
|
667
|
+
// The notebook is synced. First check if we have no matching
|
|
668
|
+
// cells anymore and if so close the notebook
|
|
669
|
+
var _cells2 = this.getMatchingCells(notebookDocument);
|
|
670
|
+
if (_cells2 === undefined) {
|
|
671
|
+
this.didClose(notebookDocument, syncInfo);
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
var newEvent = this.asNotebookDocumentChangeEvent(event.notebook, event, syncInfo, _cells2);
|
|
675
|
+
if (newEvent !== undefined) {
|
|
676
|
+
this.doSendChange(newEvent, _cells2).catch(function () {
|
|
677
|
+
/* error handled in doSendChange */
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}, {
|
|
683
|
+
key: "didSave",
|
|
684
|
+
value: function didSave(notebookDocument) {
|
|
685
|
+
var syncInfo = this.notebookSyncInfo.get(notebookDocument.uri.toString());
|
|
686
|
+
if (syncInfo === undefined) {
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
this.doSendSave(notebookDocument).catch(function () {
|
|
690
|
+
/* error handled in doSendSave */
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
}, {
|
|
694
|
+
key: "didClose",
|
|
695
|
+
value: function didClose(notebookDocument) {
|
|
696
|
+
var syncInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.notebookSyncInfo.get(notebookDocument.uri.toString());
|
|
697
|
+
if (syncInfo === undefined) {
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
var syncedCells = notebookDocument.getCells().filter(function (cell) {
|
|
701
|
+
return syncInfo.uris.has(cell.document.uri.toString());
|
|
702
|
+
});
|
|
703
|
+
this.doSendClose(notebookDocument, syncedCells).catch(function () {
|
|
704
|
+
/* error handled in doSendClose */
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
}, {
|
|
708
|
+
key: "sendDidOpenNotebookDocument",
|
|
709
|
+
value: function () {
|
|
710
|
+
var _sendDidOpenNotebookDocument = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(notebookDocument) {
|
|
711
|
+
var cells;
|
|
712
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
713
|
+
while (1) switch (_context.prev = _context.next) {
|
|
714
|
+
case 0:
|
|
715
|
+
cells = this.getMatchingCells(notebookDocument);
|
|
716
|
+
if (!(cells === undefined)) {
|
|
717
|
+
_context.next = 3;
|
|
718
|
+
break;
|
|
719
|
+
}
|
|
720
|
+
return _context.abrupt("return");
|
|
721
|
+
case 3:
|
|
722
|
+
return _context.abrupt("return", this.doSendOpen(notebookDocument, cells));
|
|
723
|
+
case 4:
|
|
724
|
+
case "end":
|
|
725
|
+
return _context.stop();
|
|
726
|
+
}
|
|
727
|
+
}, _callee, this);
|
|
728
|
+
}));
|
|
729
|
+
function sendDidOpenNotebookDocument(_x) {
|
|
730
|
+
return _sendDidOpenNotebookDocument.apply(this, arguments);
|
|
731
|
+
}
|
|
732
|
+
return sendDidOpenNotebookDocument;
|
|
733
|
+
}()
|
|
734
|
+
}, {
|
|
735
|
+
key: "doSendOpen",
|
|
736
|
+
value: function () {
|
|
737
|
+
var _doSendOpen = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(notebookDocument, cells) {
|
|
738
|
+
var _this2 = this,
|
|
739
|
+
_this$client$middlewa;
|
|
740
|
+
var send, middleware;
|
|
741
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
742
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
743
|
+
case 0:
|
|
744
|
+
send = /*#__PURE__*/function () {
|
|
745
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(notebookDocument, cells) {
|
|
746
|
+
var nb, cellDocuments;
|
|
747
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
748
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
749
|
+
case 0:
|
|
750
|
+
nb = Converter.c2p.asNotebookDocument(notebookDocument, cells, _this2.client.code2ProtocolConverter);
|
|
751
|
+
cellDocuments = cells.map(function (cell) {
|
|
752
|
+
return _this2.client.code2ProtocolConverter.asTextDocumentItem(cell.document);
|
|
753
|
+
});
|
|
754
|
+
_context2.prev = 2;
|
|
755
|
+
_context2.next = 5;
|
|
756
|
+
return _this2.client.sendNotification(proto.DidOpenNotebookDocumentNotification.type, {
|
|
757
|
+
notebookDocument: nb,
|
|
758
|
+
cellTextDocuments: cellDocuments
|
|
759
|
+
});
|
|
760
|
+
case 5:
|
|
761
|
+
_context2.next = 11;
|
|
762
|
+
break;
|
|
763
|
+
case 7:
|
|
764
|
+
_context2.prev = 7;
|
|
765
|
+
_context2.t0 = _context2["catch"](2);
|
|
766
|
+
_this2.client.error('Sending DidOpenNotebookDocumentNotification failed', _context2.t0);
|
|
767
|
+
throw _context2.t0;
|
|
768
|
+
case 11:
|
|
769
|
+
case "end":
|
|
770
|
+
return _context2.stop();
|
|
771
|
+
}
|
|
772
|
+
}, _callee2, null, [[2, 7]]);
|
|
773
|
+
}));
|
|
774
|
+
return function send(_x4, _x5) {
|
|
775
|
+
return _ref.apply(this, arguments);
|
|
776
|
+
};
|
|
777
|
+
}();
|
|
778
|
+
middleware = (_this$client$middlewa = this.client.middleware) === null || _this$client$middlewa === void 0 ? void 0 : _this$client$middlewa.notebooks;
|
|
779
|
+
this.notebookSyncInfo.set(notebookDocument.uri.toString(), SyncInfo.create(cells));
|
|
780
|
+
return _context3.abrupt("return", (middleware === null || middleware === void 0 ? void 0 : middleware.didOpen) !== undefined ? middleware.didOpen(notebookDocument, cells, send) : send(notebookDocument, cells));
|
|
781
|
+
case 4:
|
|
782
|
+
case "end":
|
|
783
|
+
return _context3.stop();
|
|
784
|
+
}
|
|
785
|
+
}, _callee3, this);
|
|
786
|
+
}));
|
|
787
|
+
function doSendOpen(_x2, _x3) {
|
|
788
|
+
return _doSendOpen.apply(this, arguments);
|
|
789
|
+
}
|
|
790
|
+
return doSendOpen;
|
|
791
|
+
}()
|
|
792
|
+
}, {
|
|
793
|
+
key: "sendDidChangeNotebookDocument",
|
|
794
|
+
value: function () {
|
|
795
|
+
var _sendDidChangeNotebookDocument = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(event) {
|
|
796
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
797
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
798
|
+
case 0:
|
|
799
|
+
return _context4.abrupt("return", this.doSendChange(event, undefined));
|
|
800
|
+
case 1:
|
|
801
|
+
case "end":
|
|
802
|
+
return _context4.stop();
|
|
803
|
+
}
|
|
804
|
+
}, _callee4, this);
|
|
805
|
+
}));
|
|
806
|
+
function sendDidChangeNotebookDocument(_x6) {
|
|
807
|
+
return _sendDidChangeNotebookDocument.apply(this, arguments);
|
|
808
|
+
}
|
|
809
|
+
return sendDidChangeNotebookDocument;
|
|
810
|
+
}()
|
|
811
|
+
}, {
|
|
812
|
+
key: "doSendChange",
|
|
813
|
+
value: function () {
|
|
814
|
+
var _doSendChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(event) {
|
|
815
|
+
var _this3 = this,
|
|
816
|
+
_this$client$middlewa2,
|
|
817
|
+
_event$cells;
|
|
818
|
+
var cells,
|
|
819
|
+
send,
|
|
820
|
+
middleware,
|
|
821
|
+
_args6 = arguments;
|
|
822
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
823
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
824
|
+
case 0:
|
|
825
|
+
cells = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : this.getMatchingCells(event.notebook);
|
|
826
|
+
send = /*#__PURE__*/function () {
|
|
827
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(event) {
|
|
828
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
829
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
830
|
+
case 0:
|
|
831
|
+
_context5.prev = 0;
|
|
832
|
+
_context5.next = 3;
|
|
833
|
+
return _this3.client.sendNotification(proto.DidChangeNotebookDocumentNotification.type, {
|
|
834
|
+
notebookDocument: Converter.c2p.asVersionedNotebookDocumentIdentifier(event.notebook, _this3.client.code2ProtocolConverter),
|
|
835
|
+
change: Converter.c2p.asNotebookDocumentChangeEvent(event, _this3.client.code2ProtocolConverter)
|
|
836
|
+
});
|
|
837
|
+
case 3:
|
|
838
|
+
_context5.next = 9;
|
|
839
|
+
break;
|
|
840
|
+
case 5:
|
|
841
|
+
_context5.prev = 5;
|
|
842
|
+
_context5.t0 = _context5["catch"](0);
|
|
843
|
+
_this3.client.error('Sending DidChangeNotebookDocumentNotification failed', _context5.t0);
|
|
844
|
+
throw _context5.t0;
|
|
845
|
+
case 9:
|
|
846
|
+
case "end":
|
|
847
|
+
return _context5.stop();
|
|
848
|
+
}
|
|
849
|
+
}, _callee5, null, [[0, 5]]);
|
|
850
|
+
}));
|
|
851
|
+
return function send(_x8) {
|
|
852
|
+
return _ref2.apply(this, arguments);
|
|
853
|
+
};
|
|
854
|
+
}();
|
|
855
|
+
middleware = (_this$client$middlewa2 = this.client.middleware) === null || _this$client$middlewa2 === void 0 ? void 0 : _this$client$middlewa2.notebooks;
|
|
856
|
+
if (((_event$cells = event.cells) === null || _event$cells === void 0 ? void 0 : _event$cells.structure) !== undefined) {
|
|
857
|
+
this.notebookSyncInfo.set(event.notebook.uri.toString(), SyncInfo.create(cells !== null && cells !== void 0 ? cells : []));
|
|
858
|
+
}
|
|
859
|
+
return _context6.abrupt("return", (middleware === null || middleware === void 0 ? void 0 : middleware.didChange) !== undefined ? middleware === null || middleware === void 0 ? void 0 : middleware.didChange(event, send) : send(event));
|
|
860
|
+
case 5:
|
|
861
|
+
case "end":
|
|
862
|
+
return _context6.stop();
|
|
863
|
+
}
|
|
864
|
+
}, _callee6, this);
|
|
865
|
+
}));
|
|
866
|
+
function doSendChange(_x7) {
|
|
867
|
+
return _doSendChange.apply(this, arguments);
|
|
868
|
+
}
|
|
869
|
+
return doSendChange;
|
|
870
|
+
}()
|
|
871
|
+
}, {
|
|
872
|
+
key: "sendDidSaveNotebookDocument",
|
|
873
|
+
value: function () {
|
|
874
|
+
var _sendDidSaveNotebookDocument = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(notebookDocument) {
|
|
875
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
876
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
877
|
+
case 0:
|
|
878
|
+
return _context7.abrupt("return", this.doSendSave(notebookDocument));
|
|
879
|
+
case 1:
|
|
880
|
+
case "end":
|
|
881
|
+
return _context7.stop();
|
|
882
|
+
}
|
|
883
|
+
}, _callee7, this);
|
|
884
|
+
}));
|
|
885
|
+
function sendDidSaveNotebookDocument(_x9) {
|
|
886
|
+
return _sendDidSaveNotebookDocument.apply(this, arguments);
|
|
887
|
+
}
|
|
888
|
+
return sendDidSaveNotebookDocument;
|
|
889
|
+
}()
|
|
890
|
+
}, {
|
|
891
|
+
key: "doSendSave",
|
|
892
|
+
value: function () {
|
|
893
|
+
var _doSendSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(notebookDocument) {
|
|
894
|
+
var _this4 = this,
|
|
895
|
+
_this$client$middlewa3;
|
|
896
|
+
var send, middleware;
|
|
897
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
898
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
899
|
+
case 0:
|
|
900
|
+
send = /*#__PURE__*/function () {
|
|
901
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(notebookDocument) {
|
|
902
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
903
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
904
|
+
case 0:
|
|
905
|
+
_context8.prev = 0;
|
|
906
|
+
_context8.next = 3;
|
|
907
|
+
return _this4.client.sendNotification(proto.DidSaveNotebookDocumentNotification.type, {
|
|
908
|
+
notebookDocument: {
|
|
909
|
+
uri: _this4.client.code2ProtocolConverter.asUri(notebookDocument.uri)
|
|
910
|
+
}
|
|
911
|
+
});
|
|
912
|
+
case 3:
|
|
913
|
+
_context8.next = 9;
|
|
914
|
+
break;
|
|
915
|
+
case 5:
|
|
916
|
+
_context8.prev = 5;
|
|
917
|
+
_context8.t0 = _context8["catch"](0);
|
|
918
|
+
_this4.client.error('Sending DidSaveNotebookDocumentNotification failed', _context8.t0);
|
|
919
|
+
throw _context8.t0;
|
|
920
|
+
case 9:
|
|
921
|
+
case "end":
|
|
922
|
+
return _context8.stop();
|
|
923
|
+
}
|
|
924
|
+
}, _callee8, null, [[0, 5]]);
|
|
925
|
+
}));
|
|
926
|
+
return function send(_x11) {
|
|
927
|
+
return _ref3.apply(this, arguments);
|
|
928
|
+
};
|
|
929
|
+
}();
|
|
930
|
+
middleware = (_this$client$middlewa3 = this.client.middleware) === null || _this$client$middlewa3 === void 0 ? void 0 : _this$client$middlewa3.notebooks;
|
|
931
|
+
return _context9.abrupt("return", (middleware === null || middleware === void 0 ? void 0 : middleware.didSave) !== undefined ? middleware.didSave(notebookDocument, send) : send(notebookDocument));
|
|
932
|
+
case 3:
|
|
933
|
+
case "end":
|
|
934
|
+
return _context9.stop();
|
|
935
|
+
}
|
|
936
|
+
}, _callee9, this);
|
|
937
|
+
}));
|
|
938
|
+
function doSendSave(_x10) {
|
|
939
|
+
return _doSendSave.apply(this, arguments);
|
|
940
|
+
}
|
|
941
|
+
return doSendSave;
|
|
942
|
+
}()
|
|
943
|
+
}, {
|
|
944
|
+
key: "sendDidCloseNotebookDocument",
|
|
945
|
+
value: function () {
|
|
946
|
+
var _sendDidCloseNotebookDocument = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(notebookDocument) {
|
|
947
|
+
var _this$getMatchingCell;
|
|
948
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
949
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
950
|
+
case 0:
|
|
951
|
+
return _context10.abrupt("return", this.doSendClose(notebookDocument, (_this$getMatchingCell = this.getMatchingCells(notebookDocument)) !== null && _this$getMatchingCell !== void 0 ? _this$getMatchingCell : []));
|
|
952
|
+
case 1:
|
|
953
|
+
case "end":
|
|
954
|
+
return _context10.stop();
|
|
955
|
+
}
|
|
956
|
+
}, _callee10, this);
|
|
957
|
+
}));
|
|
958
|
+
function sendDidCloseNotebookDocument(_x12) {
|
|
959
|
+
return _sendDidCloseNotebookDocument.apply(this, arguments);
|
|
960
|
+
}
|
|
961
|
+
return sendDidCloseNotebookDocument;
|
|
962
|
+
}()
|
|
963
|
+
}, {
|
|
964
|
+
key: "doSendClose",
|
|
965
|
+
value: function () {
|
|
966
|
+
var _doSendClose = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(notebookDocument, cells) {
|
|
967
|
+
var _this5 = this,
|
|
968
|
+
_this$client$middlewa4;
|
|
969
|
+
var send, middleware;
|
|
970
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
971
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
972
|
+
case 0:
|
|
973
|
+
send = /*#__PURE__*/function () {
|
|
974
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(notebookDocument, cells) {
|
|
975
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
976
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
977
|
+
case 0:
|
|
978
|
+
_context11.prev = 0;
|
|
979
|
+
_context11.next = 3;
|
|
980
|
+
return _this5.client.sendNotification(proto.DidCloseNotebookDocumentNotification.type, {
|
|
981
|
+
notebookDocument: {
|
|
982
|
+
uri: _this5.client.code2ProtocolConverter.asUri(notebookDocument.uri)
|
|
983
|
+
},
|
|
984
|
+
cellTextDocuments: cells.map(function (cell) {
|
|
985
|
+
return _this5.client.code2ProtocolConverter.asTextDocumentIdentifier(cell.document);
|
|
986
|
+
})
|
|
987
|
+
});
|
|
988
|
+
case 3:
|
|
989
|
+
_context11.next = 9;
|
|
990
|
+
break;
|
|
991
|
+
case 5:
|
|
992
|
+
_context11.prev = 5;
|
|
993
|
+
_context11.t0 = _context11["catch"](0);
|
|
994
|
+
_this5.client.error('Sending DidCloseNotebookDocumentNotification failed', _context11.t0);
|
|
995
|
+
throw _context11.t0;
|
|
996
|
+
case 9:
|
|
997
|
+
case "end":
|
|
998
|
+
return _context11.stop();
|
|
999
|
+
}
|
|
1000
|
+
}, _callee11, null, [[0, 5]]);
|
|
1001
|
+
}));
|
|
1002
|
+
return function send(_x15, _x16) {
|
|
1003
|
+
return _ref4.apply(this, arguments);
|
|
1004
|
+
};
|
|
1005
|
+
}();
|
|
1006
|
+
middleware = (_this$client$middlewa4 = this.client.middleware) === null || _this$client$middlewa4 === void 0 ? void 0 : _this$client$middlewa4.notebooks;
|
|
1007
|
+
this.notebookSyncInfo.delete(notebookDocument.uri.toString());
|
|
1008
|
+
return _context12.abrupt("return", (middleware === null || middleware === void 0 ? void 0 : middleware.didClose) !== undefined ? middleware.didClose(notebookDocument, cells, send) : send(notebookDocument, cells));
|
|
1009
|
+
case 4:
|
|
1010
|
+
case "end":
|
|
1011
|
+
return _context12.stop();
|
|
1012
|
+
}
|
|
1013
|
+
}, _callee12, this);
|
|
1014
|
+
}));
|
|
1015
|
+
function doSendClose(_x13, _x14) {
|
|
1016
|
+
return _doSendClose.apply(this, arguments);
|
|
1017
|
+
}
|
|
1018
|
+
return doSendClose;
|
|
1019
|
+
}()
|
|
1020
|
+
}, {
|
|
1021
|
+
key: "asNotebookDocumentChangeEvent",
|
|
1022
|
+
value: function asNotebookDocumentChangeEvent(notebook, event, syncInfo, matchingCells) {
|
|
1023
|
+
if (event !== undefined && event.notebook !== notebook) {
|
|
1024
|
+
throw new Error('Notebook must be identical');
|
|
1025
|
+
}
|
|
1026
|
+
var result = {
|
|
1027
|
+
notebook: notebook
|
|
1028
|
+
};
|
|
1029
|
+
if ((event === null || event === void 0 ? void 0 : event.metadata) !== undefined) {
|
|
1030
|
+
result.metadata = Converter.c2p.asMetadata(event.metadata);
|
|
1031
|
+
}
|
|
1032
|
+
var matchingCellsSet;
|
|
1033
|
+
if ((event === null || event === void 0 ? void 0 : event.cellChanges) !== undefined && event.cellChanges.length > 0) {
|
|
1034
|
+
var data = [];
|
|
1035
|
+
// Only consider the new matching cells.
|
|
1036
|
+
matchingCellsSet = new Set(matchingCells.map(function (cell) {
|
|
1037
|
+
return cell.document.uri.toString();
|
|
1038
|
+
}));
|
|
1039
|
+
var _iterator4 = _createForOfIteratorHelper(event.cellChanges),
|
|
1040
|
+
_step4;
|
|
1041
|
+
try {
|
|
1042
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
1043
|
+
var cellChange = _step4.value;
|
|
1044
|
+
if (matchingCellsSet.has(cellChange.cell.document.uri.toString()) && (cellChange.executionSummary !== undefined || cellChange.metadata !== undefined)) {
|
|
1045
|
+
data.push(cellChange.cell);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
} catch (err) {
|
|
1049
|
+
_iterator4.e(err);
|
|
1050
|
+
} finally {
|
|
1051
|
+
_iterator4.f();
|
|
1052
|
+
}
|
|
1053
|
+
if (data.length > 0) {
|
|
1054
|
+
var _result$cells;
|
|
1055
|
+
result.cells = (_result$cells = result.cells) !== null && _result$cells !== void 0 ? _result$cells : {};
|
|
1056
|
+
result.cells.data = data;
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
if (((event === null || event === void 0 ? void 0 : event.contentChanges) !== undefined && event.contentChanges.length > 0 || event === undefined) && syncInfo !== undefined && matchingCells !== undefined) {
|
|
1060
|
+
// We still have matching cells. Check if the cell changes
|
|
1061
|
+
// affect the notebook on the server side.
|
|
1062
|
+
var oldCells = syncInfo.cells;
|
|
1063
|
+
var newCells = matchingCells;
|
|
1064
|
+
|
|
1065
|
+
// meta data changes are reported using on the cell itself. So we can ignore comparing
|
|
1066
|
+
// it which has a positive effect on performance.
|
|
1067
|
+
var diff = $NotebookCell.computeDiff(oldCells, newCells, false);
|
|
1068
|
+
var addedCells;
|
|
1069
|
+
var removedCells;
|
|
1070
|
+
if (diff !== undefined) {
|
|
1071
|
+
var _result$cells2;
|
|
1072
|
+
addedCells = diff.cells === undefined ? new Map() : new Map(diff.cells.map(function (cell) {
|
|
1073
|
+
return [cell.document.uri.toString(), cell];
|
|
1074
|
+
}));
|
|
1075
|
+
removedCells = diff.deleteCount === 0 ? new Map() : new Map(oldCells.slice(diff.start, diff.start + diff.deleteCount).map(function (cell) {
|
|
1076
|
+
return [cell.document.uri.toString(), cell];
|
|
1077
|
+
}));
|
|
1078
|
+
|
|
1079
|
+
// Remove the onces that got deleted and inserted again.
|
|
1080
|
+
for (var _i = 0, _Array$from = Array.from(removedCells.keys()); _i < _Array$from.length; _i++) {
|
|
1081
|
+
var _key = _Array$from[_i];
|
|
1082
|
+
if (addedCells.has(_key)) {
|
|
1083
|
+
removedCells.delete(_key);
|
|
1084
|
+
addedCells.delete(_key);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
result.cells = (_result$cells2 = result.cells) !== null && _result$cells2 !== void 0 ? _result$cells2 : {};
|
|
1088
|
+
var didOpen = [];
|
|
1089
|
+
var didClose = [];
|
|
1090
|
+
if (addedCells.size > 0 || removedCells.size > 0) {
|
|
1091
|
+
var _iterator5 = _createForOfIteratorHelper(addedCells.values()),
|
|
1092
|
+
_step5;
|
|
1093
|
+
try {
|
|
1094
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
1095
|
+
var cell = _step5.value;
|
|
1096
|
+
didOpen.push(cell);
|
|
1097
|
+
}
|
|
1098
|
+
} catch (err) {
|
|
1099
|
+
_iterator5.e(err);
|
|
1100
|
+
} finally {
|
|
1101
|
+
_iterator5.f();
|
|
1102
|
+
}
|
|
1103
|
+
var _iterator6 = _createForOfIteratorHelper(removedCells.values()),
|
|
1104
|
+
_step6;
|
|
1105
|
+
try {
|
|
1106
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
1107
|
+
var _cell = _step6.value;
|
|
1108
|
+
didClose.push(_cell);
|
|
1109
|
+
}
|
|
1110
|
+
} catch (err) {
|
|
1111
|
+
_iterator6.e(err);
|
|
1112
|
+
} finally {
|
|
1113
|
+
_iterator6.f();
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
result.cells.structure = {
|
|
1117
|
+
array: diff,
|
|
1118
|
+
didOpen: didOpen,
|
|
1119
|
+
didClose: didClose
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
// The notebook is a property as well.
|
|
1124
|
+
return Object.keys(result).length > 1 ? result : undefined;
|
|
1125
|
+
}
|
|
1126
|
+
}, {
|
|
1127
|
+
key: "getMatchingCells",
|
|
1128
|
+
value: function getMatchingCells(notebookDocument) {
|
|
1129
|
+
var cells = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : notebookDocument.getCells();
|
|
1130
|
+
if (this.options.notebookSelector === undefined) {
|
|
1131
|
+
return undefined;
|
|
1132
|
+
}
|
|
1133
|
+
var _iterator7 = _createForOfIteratorHelper(this.options.notebookSelector),
|
|
1134
|
+
_step7;
|
|
1135
|
+
try {
|
|
1136
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
1137
|
+
var item = _step7.value;
|
|
1138
|
+
if (item.notebook === undefined || $NotebookDocumentFilter.matchNotebook(item.notebook, notebookDocument)) {
|
|
1139
|
+
var filtered = this.filterCells(notebookDocument, cells, item.cells);
|
|
1140
|
+
return filtered.length === 0 ? undefined : filtered;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
} catch (err) {
|
|
1144
|
+
_iterator7.e(err);
|
|
1145
|
+
} finally {
|
|
1146
|
+
_iterator7.f();
|
|
1147
|
+
}
|
|
1148
|
+
return undefined;
|
|
1149
|
+
}
|
|
1150
|
+
}, {
|
|
1151
|
+
key: "cellMatches",
|
|
1152
|
+
value: function cellMatches(notebookDocument, cell) {
|
|
1153
|
+
var cells = this.getMatchingCells(notebookDocument, [cell]);
|
|
1154
|
+
return cells !== undefined && cells[0] === cell;
|
|
1155
|
+
}
|
|
1156
|
+
}, {
|
|
1157
|
+
key: "filterCells",
|
|
1158
|
+
value: function filterCells(notebookDocument, cells, cellSelector) {
|
|
1159
|
+
var _this$client$clientOp;
|
|
1160
|
+
var filtered = cellSelector !== undefined ? cells.filter(function (cell) {
|
|
1161
|
+
var cellLanguage = cell.document.languageId;
|
|
1162
|
+
return cellSelector.some(function (filter) {
|
|
1163
|
+
return filter.language === '*' || cellLanguage === filter.language;
|
|
1164
|
+
});
|
|
1165
|
+
}) : cells;
|
|
1166
|
+
return typeof ((_this$client$clientOp = this.client.clientOptions.notebookDocumentOptions) === null || _this$client$clientOp === void 0 ? void 0 : _this$client$clientOp.filterCells) === 'function' ? this.client.clientOptions.notebookDocumentOptions.filterCells(notebookDocument, filtered) : filtered;
|
|
1167
|
+
}
|
|
1168
|
+
}]);
|
|
1169
|
+
return NotebookDocumentSyncFeatureProvider;
|
|
1170
|
+
}();
|
|
1171
|
+
export var NotebookDocumentSyncFeature = /*#__PURE__*/function () {
|
|
1172
|
+
function NotebookDocumentSyncFeature(client) {
|
|
1173
|
+
var _this6 = this;
|
|
1174
|
+
_classCallCheck(this, NotebookDocumentSyncFeature);
|
|
1175
|
+
this.client = client;
|
|
1176
|
+
this.registrations = new Map();
|
|
1177
|
+
this.registrationType = proto.NotebookDocumentSyncRegistrationType.type;
|
|
1178
|
+
// We don't receive an event for cells where the document changes its language mode
|
|
1179
|
+
// Since we allow servers to filter on the language mode we fire such an event ourselves.
|
|
1180
|
+
workspace.onDidOpenTextDocument(function (textDocument) {
|
|
1181
|
+
if (textDocument.uri.scheme !== NotebookDocumentSyncFeature.CellScheme) {
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
var _this6$findNotebookDo = _this6.findNotebookDocumentAndCell(textDocument),
|
|
1185
|
+
_this6$findNotebookDo2 = _slicedToArray(_this6$findNotebookDo, 2),
|
|
1186
|
+
notebookDocument = _this6$findNotebookDo2[0],
|
|
1187
|
+
notebookCell = _this6$findNotebookDo2[1];
|
|
1188
|
+
if (notebookDocument === undefined || notebookCell === undefined) {
|
|
1189
|
+
return;
|
|
1190
|
+
}
|
|
1191
|
+
var _iterator8 = _createForOfIteratorHelper(_this6.registrations.values()),
|
|
1192
|
+
_step8;
|
|
1193
|
+
try {
|
|
1194
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1195
|
+
var provider = _step8.value;
|
|
1196
|
+
if (provider instanceof NotebookDocumentSyncFeatureProvider) {
|
|
1197
|
+
provider.didOpenNotebookCellTextDocument(notebookDocument, notebookCell);
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
} catch (err) {
|
|
1201
|
+
_iterator8.e(err);
|
|
1202
|
+
} finally {
|
|
1203
|
+
_iterator8.f();
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
workspace.onDidChangeTextDocument(function (event) {
|
|
1207
|
+
if (event.contentChanges.length === 0) {
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
var textDocument = event.document;
|
|
1211
|
+
if (textDocument.uri.scheme !== NotebookDocumentSyncFeature.CellScheme) {
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1214
|
+
var _this6$findNotebookDo3 = _this6.findNotebookDocumentAndCell(textDocument),
|
|
1215
|
+
_this6$findNotebookDo4 = _slicedToArray(_this6$findNotebookDo3, 1),
|
|
1216
|
+
notebookDocument = _this6$findNotebookDo4[0];
|
|
1217
|
+
if (notebookDocument === undefined) {
|
|
1218
|
+
return;
|
|
1219
|
+
}
|
|
1220
|
+
var _iterator9 = _createForOfIteratorHelper(_this6.registrations.values()),
|
|
1221
|
+
_step9;
|
|
1222
|
+
try {
|
|
1223
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1224
|
+
var provider = _step9.value;
|
|
1225
|
+
if (provider instanceof NotebookDocumentSyncFeatureProvider) {
|
|
1226
|
+
provider.didChangeNotebookCellTextDocument(notebookDocument, event);
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
} catch (err) {
|
|
1230
|
+
_iterator9.e(err);
|
|
1231
|
+
} finally {
|
|
1232
|
+
_iterator9.f();
|
|
1233
|
+
}
|
|
1234
|
+
});
|
|
1235
|
+
workspace.onDidCloseTextDocument(function (textDocument) {
|
|
1236
|
+
if (textDocument.uri.scheme !== NotebookDocumentSyncFeature.CellScheme) {
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
// There are two cases when we receive a close for a text document
|
|
1240
|
+
// 1: the cell got removed. This is handled in `onDidChangeNotebookCells`
|
|
1241
|
+
// 2: the language mode of a cell changed. This keeps the URI stable so
|
|
1242
|
+
// we will still find the cell and the notebook document.
|
|
1243
|
+
var _this6$findNotebookDo5 = _this6.findNotebookDocumentAndCell(textDocument),
|
|
1244
|
+
_this6$findNotebookDo6 = _slicedToArray(_this6$findNotebookDo5, 2),
|
|
1245
|
+
notebookDocument = _this6$findNotebookDo6[0],
|
|
1246
|
+
notebookCell = _this6$findNotebookDo6[1];
|
|
1247
|
+
if (notebookDocument === undefined || notebookCell === undefined) {
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
var _iterator10 = _createForOfIteratorHelper(_this6.registrations.values()),
|
|
1251
|
+
_step10;
|
|
1252
|
+
try {
|
|
1253
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
1254
|
+
var provider = _step10.value;
|
|
1255
|
+
if (provider instanceof NotebookDocumentSyncFeatureProvider) {
|
|
1256
|
+
provider.didCloseNotebookCellTextDocument(notebookDocument, notebookCell);
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
} catch (err) {
|
|
1260
|
+
_iterator10.e(err);
|
|
1261
|
+
} finally {
|
|
1262
|
+
_iterator10.f();
|
|
1263
|
+
}
|
|
1264
|
+
});
|
|
1265
|
+
}
|
|
1266
|
+
_createClass(NotebookDocumentSyncFeature, [{
|
|
1267
|
+
key: "getState",
|
|
1268
|
+
value: function getState() {
|
|
1269
|
+
if (this.registrations.size === 0) {
|
|
1270
|
+
return {
|
|
1271
|
+
kind: 'document',
|
|
1272
|
+
id: this.registrationType.method,
|
|
1273
|
+
registrations: false,
|
|
1274
|
+
matches: false
|
|
1275
|
+
};
|
|
1276
|
+
}
|
|
1277
|
+
var _iterator11 = _createForOfIteratorHelper(this.registrations.values()),
|
|
1278
|
+
_step11;
|
|
1279
|
+
try {
|
|
1280
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
1281
|
+
var provider = _step11.value;
|
|
1282
|
+
var state = provider.getState();
|
|
1283
|
+
if (state.kind === 'document' && state.registrations === true && state.matches === true) {
|
|
1284
|
+
return {
|
|
1285
|
+
kind: 'document',
|
|
1286
|
+
id: this.registrationType.method,
|
|
1287
|
+
registrations: true,
|
|
1288
|
+
matches: true
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
} catch (err) {
|
|
1293
|
+
_iterator11.e(err);
|
|
1294
|
+
} finally {
|
|
1295
|
+
_iterator11.f();
|
|
1296
|
+
}
|
|
1297
|
+
return {
|
|
1298
|
+
kind: 'document',
|
|
1299
|
+
id: this.registrationType.method,
|
|
1300
|
+
registrations: true,
|
|
1301
|
+
matches: false
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
}, {
|
|
1305
|
+
key: "fillClientCapabilities",
|
|
1306
|
+
value: function fillClientCapabilities(capabilities) {
|
|
1307
|
+
var synchronization = ensure(ensure(capabilities, 'notebookDocument'), 'synchronization');
|
|
1308
|
+
synchronization.dynamicRegistration = true;
|
|
1309
|
+
synchronization.executionSummarySupport = true;
|
|
1310
|
+
}
|
|
1311
|
+
}, {
|
|
1312
|
+
key: "preInitialize",
|
|
1313
|
+
value: function preInitialize(capabilities) {
|
|
1314
|
+
var options = capabilities.notebookDocumentSync;
|
|
1315
|
+
if (options === undefined) {
|
|
1316
|
+
return;
|
|
1317
|
+
}
|
|
1318
|
+
this.dedicatedChannel = this.client.protocol2CodeConverter.asDocumentSelector($NotebookDocumentSyncOptions.asDocumentSelector(options));
|
|
1319
|
+
}
|
|
1320
|
+
}, {
|
|
1321
|
+
key: "initialize",
|
|
1322
|
+
value: function initialize(capabilities) {
|
|
1323
|
+
var _id;
|
|
1324
|
+
var options = capabilities.notebookDocumentSync;
|
|
1325
|
+
if (options === undefined) {
|
|
1326
|
+
return;
|
|
1327
|
+
}
|
|
1328
|
+
var id = (_id = options.id) !== null && _id !== void 0 ? _id : UUID.generateUuid();
|
|
1329
|
+
this.register({
|
|
1330
|
+
id: id,
|
|
1331
|
+
registerOptions: options
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
}, {
|
|
1335
|
+
key: "register",
|
|
1336
|
+
value: function register(data) {
|
|
1337
|
+
var provider = new NotebookDocumentSyncFeatureProvider(this.client, data.registerOptions);
|
|
1338
|
+
this.registrations.set(data.id, provider);
|
|
1339
|
+
}
|
|
1340
|
+
}, {
|
|
1341
|
+
key: "unregister",
|
|
1342
|
+
value: function unregister(id) {
|
|
1343
|
+
var provider = this.registrations.get(id);
|
|
1344
|
+
if (provider !== undefined) {
|
|
1345
|
+
this.registrations.delete(id);
|
|
1346
|
+
provider.dispose();
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
}, {
|
|
1350
|
+
key: "clear",
|
|
1351
|
+
value: function clear() {
|
|
1352
|
+
var _iterator12 = _createForOfIteratorHelper(this.registrations.values()),
|
|
1353
|
+
_step12;
|
|
1354
|
+
try {
|
|
1355
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
1356
|
+
var provider = _step12.value;
|
|
1357
|
+
provider.dispose();
|
|
1358
|
+
}
|
|
1359
|
+
} catch (err) {
|
|
1360
|
+
_iterator12.e(err);
|
|
1361
|
+
} finally {
|
|
1362
|
+
_iterator12.f();
|
|
1363
|
+
}
|
|
1364
|
+
this.registrations.clear();
|
|
1365
|
+
}
|
|
1366
|
+
}, {
|
|
1367
|
+
key: "handles",
|
|
1368
|
+
value: function handles(textDocument) {
|
|
1369
|
+
if (textDocument.uri.scheme !== NotebookDocumentSyncFeature.CellScheme) {
|
|
1370
|
+
return false;
|
|
1371
|
+
}
|
|
1372
|
+
if (this.dedicatedChannel !== undefined && languages.match(this.dedicatedChannel, textDocument) > 0) {
|
|
1373
|
+
return true;
|
|
1374
|
+
}
|
|
1375
|
+
var _iterator13 = _createForOfIteratorHelper(this.registrations.values()),
|
|
1376
|
+
_step13;
|
|
1377
|
+
try {
|
|
1378
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
1379
|
+
var provider = _step13.value;
|
|
1380
|
+
if (provider.handles(textDocument)) {
|
|
1381
|
+
return true;
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
} catch (err) {
|
|
1385
|
+
_iterator13.e(err);
|
|
1386
|
+
} finally {
|
|
1387
|
+
_iterator13.f();
|
|
1388
|
+
}
|
|
1389
|
+
return false;
|
|
1390
|
+
}
|
|
1391
|
+
}, {
|
|
1392
|
+
key: "getProvider",
|
|
1393
|
+
value: function getProvider(notebookCell) {
|
|
1394
|
+
var _iterator14 = _createForOfIteratorHelper(this.registrations.values()),
|
|
1395
|
+
_step14;
|
|
1396
|
+
try {
|
|
1397
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
1398
|
+
var provider = _step14.value;
|
|
1399
|
+
if (provider.handles(notebookCell.document)) {
|
|
1400
|
+
return provider;
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
} catch (err) {
|
|
1404
|
+
_iterator14.e(err);
|
|
1405
|
+
} finally {
|
|
1406
|
+
_iterator14.f();
|
|
1407
|
+
}
|
|
1408
|
+
return undefined;
|
|
1409
|
+
}
|
|
1410
|
+
}, {
|
|
1411
|
+
key: "findNotebookDocumentAndCell",
|
|
1412
|
+
value: function findNotebookDocumentAndCell(textDocument) {
|
|
1413
|
+
var uri = textDocument.uri.toString();
|
|
1414
|
+
var _iterator15 = _createForOfIteratorHelper(workspace.notebookDocuments),
|
|
1415
|
+
_step15;
|
|
1416
|
+
try {
|
|
1417
|
+
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
1418
|
+
var _notebookDocument2 = _step15.value;
|
|
1419
|
+
var _iterator16 = _createForOfIteratorHelper(_notebookDocument2.getCells()),
|
|
1420
|
+
_step16;
|
|
1421
|
+
try {
|
|
1422
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
1423
|
+
var cell = _step16.value;
|
|
1424
|
+
if (cell.document.uri.toString() === uri) {
|
|
1425
|
+
return [_notebookDocument2, cell];
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
} catch (err) {
|
|
1429
|
+
_iterator16.e(err);
|
|
1430
|
+
} finally {
|
|
1431
|
+
_iterator16.f();
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
} catch (err) {
|
|
1435
|
+
_iterator15.e(err);
|
|
1436
|
+
} finally {
|
|
1437
|
+
_iterator15.f();
|
|
1438
|
+
}
|
|
1439
|
+
return [undefined, undefined];
|
|
1440
|
+
}
|
|
1441
|
+
}]);
|
|
1442
|
+
return NotebookDocumentSyncFeature;
|
|
1443
|
+
}();
|
|
1444
|
+
NotebookDocumentSyncFeature.CellScheme = LibroCellURIScheme;
|