@difizen/libro-lsp 0.1.2
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/adapters/adapter.d.ts +255 -0
- package/es/adapters/adapter.d.ts.map +1 -0
- package/es/adapters/adapter.js +647 -0
- package/es/adapters/notebook-adapter.d.ts +150 -0
- package/es/adapters/notebook-adapter.d.ts.map +1 -0
- package/es/adapters/notebook-adapter.js +588 -0
- package/es/adapters/status-message.d.ts +48 -0
- package/es/adapters/status-message.d.ts.map +1 -0
- package/es/adapters/status-message.js +110 -0
- package/es/connection-manager.d.ts +199 -0
- package/es/connection-manager.d.ts.map +1 -0
- package/es/connection-manager.js +685 -0
- package/es/connection.d.ts +149 -0
- package/es/connection.d.ts.map +1 -0
- package/es/connection.js +591 -0
- package/es/extractors/index.d.ts +4 -0
- package/es/extractors/index.d.ts.map +1 -0
- package/es/extractors/index.js +6 -0
- package/es/extractors/manager.d.ts +31 -0
- package/es/extractors/manager.d.ts.map +1 -0
- package/es/extractors/manager.js +90 -0
- package/es/extractors/text-extractor.d.ts +56 -0
- package/es/extractors/text-extractor.d.ts.map +1 -0
- package/es/extractors/text-extractor.js +72 -0
- package/es/extractors/types.d.ts +68 -0
- package/es/extractors/types.d.ts.map +1 -0
- package/es/extractors/types.js +1 -0
- package/es/feature.d.ts +29 -0
- package/es/feature.d.ts.map +1 -0
- package/es/feature.js +85 -0
- package/es/index.d.ts +19 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +21 -0
- package/es/lsp-app-contribution.d.ts +19 -0
- package/es/lsp-app-contribution.d.ts.map +1 -0
- package/es/lsp-app-contribution.js +155 -0
- package/es/lsp-protocol.d.ts +10 -0
- package/es/lsp-protocol.d.ts.map +1 -0
- package/es/lsp-protocol.js +1 -0
- package/es/lsp.d.ts +136 -0
- package/es/lsp.d.ts.map +1 -0
- package/es/lsp.js +141 -0
- package/es/manager.d.ts +142 -0
- package/es/manager.d.ts.map +1 -0
- package/es/manager.js +423 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +21 -0
- package/es/plugin.d.ts +56 -0
- package/es/plugin.d.ts.map +1 -0
- package/es/plugin.js +0 -0
- package/es/positioning.d.ts +66 -0
- package/es/positioning.d.ts.map +1 -0
- package/es/positioning.js +96 -0
- package/es/schema.d.ts +240 -0
- package/es/schema.d.ts.map +1 -0
- package/es/schema.js +0 -0
- package/es/tokens.d.ts +677 -0
- package/es/tokens.d.ts.map +1 -0
- package/es/tokens.js +183 -0
- package/es/utils.d.ts +33 -0
- package/es/utils.d.ts.map +1 -0
- package/es/utils.js +168 -0
- package/es/virtual/document.d.ts +546 -0
- package/es/virtual/document.d.ts.map +1 -0
- package/es/virtual/document.js +1263 -0
- package/es/ws-connection/server-capability-registration.d.ts +19 -0
- package/es/ws-connection/server-capability-registration.d.ts.map +1 -0
- package/es/ws-connection/server-capability-registration.js +51 -0
- package/es/ws-connection/types.d.ts +76 -0
- package/es/ws-connection/types.d.ts.map +1 -0
- package/es/ws-connection/types.js +1 -0
- package/es/ws-connection/ws-connection.d.ts +105 -0
- package/es/ws-connection/ws-connection.d.ts.map +1 -0
- package/es/ws-connection/ws-connection.js +301 -0
- package/package.json +67 -0
- package/src/adapters/adapter.ts +611 -0
- package/src/adapters/notebook-adapter.ts +463 -0
- package/src/adapters/status-message.ts +93 -0
- package/src/connection-manager.ts +626 -0
- package/src/connection.ts +570 -0
- package/src/extractors/index.ts +6 -0
- package/src/extractors/manager.ts +82 -0
- package/src/extractors/text-extractor.ts +94 -0
- package/src/extractors/types.ts +78 -0
- package/src/feature.ts +60 -0
- package/src/index.spec.ts +10 -0
- package/src/index.ts +21 -0
- package/src/lsp-app-contribution.ts +83 -0
- package/src/lsp-protocol.ts +10 -0
- package/src/lsp.ts +160 -0
- package/src/manager.ts +358 -0
- package/src/module.ts +32 -0
- package/src/plugin.ts +62 -0
- package/src/positioning.ts +121 -0
- package/src/schema.ts +249 -0
- package/src/tokens.ts +843 -0
- package/src/utils.ts +109 -0
- package/src/virtual/document.ts +1250 -0
- package/src/ws-connection/server-capability-registration.ts +77 -0
- package/src/ws-connection/types.ts +102 -0
- package/src/ws-connection/ws-connection.ts +320 -0
package/es/connection.js
ADDED
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
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; }
|
|
5
|
+
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); } }
|
|
6
|
+
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); }); }; }
|
|
7
|
+
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); }
|
|
8
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
9
|
+
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); }
|
|
10
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
11
|
+
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); }; }
|
|
12
|
+
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); }
|
|
13
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
14
|
+
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; } }
|
|
15
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
16
|
+
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); }
|
|
17
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
|
+
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); } }
|
|
19
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
20
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
21
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
22
|
+
/* eslint-disable @typescript-eslint/no-parameter-properties */
|
|
23
|
+
/* eslint-disable @typescript-eslint/parameter-properties */
|
|
24
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
25
|
+
/* eslint-disable @typescript-eslint/no-shadow */
|
|
26
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
27
|
+
// Copyright (c) Jupyter Development Team.
|
|
28
|
+
// Distributed under the terms of the Modified BSD License.
|
|
29
|
+
|
|
30
|
+
import { Emitter } from '@difizen/mana-app';
|
|
31
|
+
import { Method } from "./tokens.js";
|
|
32
|
+
import { untilReady } from "./utils.js";
|
|
33
|
+
import { registerServerCapability, unregisterServerCapability } from "./ws-connection/server-capability-registration.js";
|
|
34
|
+
import { LspWsConnection } from "./ws-connection/ws-connection.js";
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Helper class to handle client request
|
|
38
|
+
*/
|
|
39
|
+
var ClientRequestHandler = /*#__PURE__*/function () {
|
|
40
|
+
function ClientRequestHandler(connection, method, emitter) {
|
|
41
|
+
_classCallCheck(this, ClientRequestHandler);
|
|
42
|
+
this.connection = connection;
|
|
43
|
+
this.method = method;
|
|
44
|
+
this.emitter = emitter;
|
|
45
|
+
}
|
|
46
|
+
_createClass(ClientRequestHandler, [{
|
|
47
|
+
key: "request",
|
|
48
|
+
value: function request(params) {
|
|
49
|
+
var _this = this;
|
|
50
|
+
// TODO check if is ready?
|
|
51
|
+
this.emitter.log(MessageKind.clientRequested, {
|
|
52
|
+
method: this.method,
|
|
53
|
+
message: params
|
|
54
|
+
});
|
|
55
|
+
return this.connection.sendRequest(this.method, params).then(function (result) {
|
|
56
|
+
_this.emitter.log(MessageKind.resultForClient, {
|
|
57
|
+
method: _this.method,
|
|
58
|
+
message: params
|
|
59
|
+
});
|
|
60
|
+
return result;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}]);
|
|
64
|
+
return ClientRequestHandler;
|
|
65
|
+
}();
|
|
66
|
+
/**
|
|
67
|
+
* Helper class to handle server responses
|
|
68
|
+
*/
|
|
69
|
+
var ServerRequestHandler = /*#__PURE__*/function () {
|
|
70
|
+
function ServerRequestHandler(connection, method, emitter) {
|
|
71
|
+
_classCallCheck(this, ServerRequestHandler);
|
|
72
|
+
this.connection = connection;
|
|
73
|
+
this.method = method;
|
|
74
|
+
this.emitter = emitter;
|
|
75
|
+
// on request accepts "thenable"
|
|
76
|
+
this.connection.onRequest(method, this._handle.bind(this));
|
|
77
|
+
this._handler = null;
|
|
78
|
+
}
|
|
79
|
+
_createClass(ServerRequestHandler, [{
|
|
80
|
+
key: "setHandler",
|
|
81
|
+
value: function setHandler(handler) {
|
|
82
|
+
this._handler = handler;
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
key: "clearHandler",
|
|
86
|
+
value: function clearHandler() {
|
|
87
|
+
this._handler = null;
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "_handle",
|
|
91
|
+
value: function _handle(request) {
|
|
92
|
+
var _this2 = this;
|
|
93
|
+
this.emitter.log(MessageKind.serverRequested, {
|
|
94
|
+
method: this.method,
|
|
95
|
+
message: request
|
|
96
|
+
});
|
|
97
|
+
if (!this._handler) {
|
|
98
|
+
return new Promise(function () {
|
|
99
|
+
return undefined;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return this._handler(request, this.emitter).then(function (result) {
|
|
103
|
+
_this2.emitter.log(MessageKind.responseForServer, {
|
|
104
|
+
method: _this2.method,
|
|
105
|
+
message: result
|
|
106
|
+
});
|
|
107
|
+
return result;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}]);
|
|
111
|
+
return ServerRequestHandler;
|
|
112
|
+
}();
|
|
113
|
+
export var Provider = {
|
|
114
|
+
TEXT_DOCUMENT_SYNC: 'textDocumentSync',
|
|
115
|
+
COMPLETION: 'completionProvider',
|
|
116
|
+
HOVER: 'hoverProvider',
|
|
117
|
+
SIGNATURE_HELP: 'signatureHelpProvider',
|
|
118
|
+
DECLARATION: 'declarationProvider',
|
|
119
|
+
DEFINITION: 'definitionProvider',
|
|
120
|
+
TYPE_DEFINITION: 'typeDefinitionProvider',
|
|
121
|
+
IMPLEMENTATION: 'implementationProvider',
|
|
122
|
+
REFERENCES: 'referencesProvider',
|
|
123
|
+
DOCUMENT_HIGHLIGHT: 'documentHighlightProvider',
|
|
124
|
+
DOCUMENT_SYMBOL: 'documentSymbolProvider',
|
|
125
|
+
CODE_ACTION: 'codeActionProvider',
|
|
126
|
+
CODE_LENS: 'codeLensProvider',
|
|
127
|
+
DOCUMENT_LINK: 'documentLinkProvider',
|
|
128
|
+
COLOR: 'colorProvider',
|
|
129
|
+
DOCUMENT_FORMATTING: 'documentFormattingProvider',
|
|
130
|
+
DOCUMENT_RANGE_FORMATTING: 'documentRangeFormattingProvider',
|
|
131
|
+
DOCUMENT_ON_TYPE_FORMATTING: 'documentOnTypeFormattingProvider',
|
|
132
|
+
RENAME: 'renameProvider',
|
|
133
|
+
FOLDING_RANGE: 'foldingRangeProvider',
|
|
134
|
+
EXECUTE_COMMAND: 'executeCommandProvider',
|
|
135
|
+
SELECTION_RANGE: 'selectionRangeProvider',
|
|
136
|
+
WORKSPACE_SYMBOL: 'workspaceSymbolProvider',
|
|
137
|
+
WORKSPACE: 'workspace'
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Create a map between the request method and its handler
|
|
141
|
+
*/
|
|
142
|
+
function createMethodMap(methods, handlerFactory) {
|
|
143
|
+
var result = {};
|
|
144
|
+
for (var _i = 0, _Object$values = Object.values(methods); _i < _Object$values.length; _i++) {
|
|
145
|
+
var _method = _Object$values[_i];
|
|
146
|
+
result[_method] = handlerFactory(_method);
|
|
147
|
+
}
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
var MessageKind = /*#__PURE__*/function (MessageKind) {
|
|
151
|
+
MessageKind[MessageKind["clientNotifiedServer"] = 0] = "clientNotifiedServer";
|
|
152
|
+
MessageKind[MessageKind["serverNotifiedClient"] = 1] = "serverNotifiedClient";
|
|
153
|
+
MessageKind[MessageKind["serverRequested"] = 2] = "serverRequested";
|
|
154
|
+
MessageKind[MessageKind["clientRequested"] = 3] = "clientRequested";
|
|
155
|
+
MessageKind[MessageKind["resultForClient"] = 4] = "resultForClient";
|
|
156
|
+
MessageKind[MessageKind["responseForServer"] = 5] = "responseForServer";
|
|
157
|
+
return MessageKind;
|
|
158
|
+
}(MessageKind || {});
|
|
159
|
+
export var LSPConnection = /*#__PURE__*/function (_LspWsConnection) {
|
|
160
|
+
_inherits(LSPConnection, _LspWsConnection);
|
|
161
|
+
var _super = _createSuper(LSPConnection);
|
|
162
|
+
function LSPConnection(options) {
|
|
163
|
+
var _this3;
|
|
164
|
+
_classCallCheck(this, LSPConnection);
|
|
165
|
+
_this3 = _super.call(this, options);
|
|
166
|
+
/**
|
|
167
|
+
* Is the connection is closed manually?
|
|
168
|
+
*/
|
|
169
|
+
_this3._closingManually = false;
|
|
170
|
+
_this3._closeSignal = new Emitter();
|
|
171
|
+
_this3._errorSignal = new Emitter();
|
|
172
|
+
_this3._serverInitialized = new Emitter();
|
|
173
|
+
_this3._options = options;
|
|
174
|
+
_this3.logAllCommunication = false;
|
|
175
|
+
_this3.serverIdentifier = options.serverIdentifier;
|
|
176
|
+
_this3.serverLanguage = options.languageId;
|
|
177
|
+
_this3.documentsToOpen = [];
|
|
178
|
+
_this3.clientNotifications = _this3.constructNotificationHandlers(Method.ClientNotification);
|
|
179
|
+
_this3.serverNotifications = _this3.constructNotificationHandlers(Method.ServerNotification);
|
|
180
|
+
return _this3;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Identifier of the language server
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Language of the language server
|
|
189
|
+
*/
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Notifications comes from the client.
|
|
193
|
+
*/
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Notifications comes from the server.
|
|
197
|
+
*/
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Requests comes from the client.
|
|
201
|
+
*/
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Responses comes from the server.
|
|
205
|
+
*/
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Should log all communication?
|
|
209
|
+
*/
|
|
210
|
+
_createClass(LSPConnection, [{
|
|
211
|
+
key: "capabilities",
|
|
212
|
+
get: function get() {
|
|
213
|
+
return this.serverCapabilities;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Signal emitted when the connection is closed.
|
|
218
|
+
*/
|
|
219
|
+
}, {
|
|
220
|
+
key: "closeSignal",
|
|
221
|
+
get: function get() {
|
|
222
|
+
return this._closeSignal.event;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Signal emitted when the connection receives an error
|
|
227
|
+
* message..
|
|
228
|
+
*/
|
|
229
|
+
}, {
|
|
230
|
+
key: "errorSignal",
|
|
231
|
+
get: function get() {
|
|
232
|
+
return this._errorSignal.event;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Signal emitted when the connection is initialized.
|
|
237
|
+
*/
|
|
238
|
+
}, {
|
|
239
|
+
key: "serverInitialized",
|
|
240
|
+
get: function get() {
|
|
241
|
+
return this._serverInitialized.event;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Dispose the connection.
|
|
246
|
+
*/
|
|
247
|
+
}, {
|
|
248
|
+
key: "dispose",
|
|
249
|
+
value: function dispose() {
|
|
250
|
+
if (this.isDisposed) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
Object.values(this.serverRequests).forEach(function (request) {
|
|
254
|
+
return request.clearHandler();
|
|
255
|
+
});
|
|
256
|
+
this.close();
|
|
257
|
+
_get(_getPrototypeOf(LSPConnection.prototype), "dispose", this).call(this);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Helper to print the logs to logger, for now we are using
|
|
262
|
+
* directly the browser's console.
|
|
263
|
+
*/
|
|
264
|
+
}, {
|
|
265
|
+
key: "log",
|
|
266
|
+
value: function log(kind, message) {
|
|
267
|
+
if (this.logAllCommunication) {
|
|
268
|
+
// eslint-disable-next-line no-console
|
|
269
|
+
console.log(kind, message);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Send the open request to the backend when the server is
|
|
275
|
+
* ready.
|
|
276
|
+
*/
|
|
277
|
+
}, {
|
|
278
|
+
key: "sendOpenWhenReady",
|
|
279
|
+
value: function sendOpenWhenReady(documentInfo) {
|
|
280
|
+
if (this.isReady) {
|
|
281
|
+
this.sendOpen(documentInfo);
|
|
282
|
+
} else {
|
|
283
|
+
this.documentsToOpen.push(documentInfo);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Send the document changes to the server.
|
|
289
|
+
*/
|
|
290
|
+
}, {
|
|
291
|
+
key: "sendSelectiveChange",
|
|
292
|
+
value: function sendSelectiveChange(changeEvent, documentInfo) {
|
|
293
|
+
this._sendChange([changeEvent], documentInfo);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Send all changes to the server.
|
|
298
|
+
*/
|
|
299
|
+
}, {
|
|
300
|
+
key: "sendFullTextChange",
|
|
301
|
+
value: function sendFullTextChange(text, documentInfo) {
|
|
302
|
+
this._sendChange([{
|
|
303
|
+
text: text
|
|
304
|
+
}], documentInfo);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Check if a provider is available in the registered capabilities.
|
|
309
|
+
*/
|
|
310
|
+
}, {
|
|
311
|
+
key: "provides",
|
|
312
|
+
value: function provides(provider) {
|
|
313
|
+
return !!(this.serverCapabilities && this.serverCapabilities[provider]);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Close the connection to the server.
|
|
318
|
+
*/
|
|
319
|
+
}, {
|
|
320
|
+
key: "close",
|
|
321
|
+
value: function close() {
|
|
322
|
+
try {
|
|
323
|
+
this._closingManually = true;
|
|
324
|
+
_get(_getPrototypeOf(LSPConnection.prototype), "close", this).call(this);
|
|
325
|
+
} catch (e) {
|
|
326
|
+
this._closingManually = false;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* initialize a connection over a web socket that speaks the LSP
|
|
332
|
+
*/
|
|
333
|
+
}, {
|
|
334
|
+
key: "connect",
|
|
335
|
+
value: function connect(socket) {
|
|
336
|
+
var _this4 = this;
|
|
337
|
+
_get(_getPrototypeOf(LSPConnection.prototype), "connect", this).call(this, socket);
|
|
338
|
+
untilReady(function () {
|
|
339
|
+
return _this4.isConnected;
|
|
340
|
+
}, -1).then(function () {
|
|
341
|
+
var disposable = _this4.connection.onClose(function () {
|
|
342
|
+
_this4._isConnected = false;
|
|
343
|
+
_this4._closeSignal.fire(_this4._closingManually);
|
|
344
|
+
});
|
|
345
|
+
_this4._disposables.push(disposable);
|
|
346
|
+
return;
|
|
347
|
+
}).catch(function () {
|
|
348
|
+
console.error('Could not connect onClose signal');
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Get send request to the server to get completion results
|
|
354
|
+
* from a completion item
|
|
355
|
+
*/
|
|
356
|
+
}, {
|
|
357
|
+
key: "getCompletionResolve",
|
|
358
|
+
value: function () {
|
|
359
|
+
var _getCompletionResolve = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(completionItem) {
|
|
360
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
361
|
+
while (1) switch (_context.prev = _context.next) {
|
|
362
|
+
case 0:
|
|
363
|
+
if (this.isReady) {
|
|
364
|
+
_context.next = 2;
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
return _context.abrupt("return");
|
|
368
|
+
case 2:
|
|
369
|
+
return _context.abrupt("return", this.connection.sendRequest('completionItem/resolve', completionItem));
|
|
370
|
+
case 3:
|
|
371
|
+
case "end":
|
|
372
|
+
return _context.stop();
|
|
373
|
+
}
|
|
374
|
+
}, _callee, this);
|
|
375
|
+
}));
|
|
376
|
+
function getCompletionResolve(_x) {
|
|
377
|
+
return _getCompletionResolve.apply(this, arguments);
|
|
378
|
+
}
|
|
379
|
+
return getCompletionResolve;
|
|
380
|
+
}()
|
|
381
|
+
/**
|
|
382
|
+
* List of documents waiting to be opened once the connection
|
|
383
|
+
* is ready.
|
|
384
|
+
*/
|
|
385
|
+
}, {
|
|
386
|
+
key: "constructNotificationHandlers",
|
|
387
|
+
value:
|
|
388
|
+
/**
|
|
389
|
+
* Generate the notification handlers
|
|
390
|
+
*/
|
|
391
|
+
function constructNotificationHandlers(methods) {
|
|
392
|
+
var factory = function factory() {
|
|
393
|
+
return new Emitter();
|
|
394
|
+
};
|
|
395
|
+
return createMethodMap(methods, factory);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Generate the client request handler
|
|
400
|
+
*/
|
|
401
|
+
}, {
|
|
402
|
+
key: "constructClientRequestHandler",
|
|
403
|
+
value: function constructClientRequestHandler(methods) {
|
|
404
|
+
var _this5 = this;
|
|
405
|
+
return createMethodMap(methods, function (method) {
|
|
406
|
+
return new ClientRequestHandler(_this5.connection, method, _this5);
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Generate the server response handler
|
|
412
|
+
*/
|
|
413
|
+
}, {
|
|
414
|
+
key: "constructServerRequestHandler",
|
|
415
|
+
value: function constructServerRequestHandler(methods) {
|
|
416
|
+
var _this6 = this;
|
|
417
|
+
return createMethodMap(methods, function (method) {
|
|
418
|
+
return new ServerRequestHandler(_this6.connection, method, _this6);
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Initialization parameters to be sent to the language server.
|
|
424
|
+
* Subclasses can overload this when adding more features.
|
|
425
|
+
*/
|
|
426
|
+
}, {
|
|
427
|
+
key: "initializeParams",
|
|
428
|
+
value: function initializeParams() {
|
|
429
|
+
return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(LSPConnection.prototype), "initializeParams", this).call(this)), {}, {
|
|
430
|
+
capabilities: this._options.capabilities,
|
|
431
|
+
initializationOptions: null,
|
|
432
|
+
processId: null,
|
|
433
|
+
workspaceFolders: null
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Callback called when the server is initialized.
|
|
439
|
+
*/
|
|
440
|
+
}, {
|
|
441
|
+
key: "onServerInitialized",
|
|
442
|
+
value: function onServerInitialized(params) {
|
|
443
|
+
this.afterInitialized();
|
|
444
|
+
_get(_getPrototypeOf(LSPConnection.prototype), "onServerInitialized", this).call(this, params);
|
|
445
|
+
while (this.documentsToOpen.length) {
|
|
446
|
+
this.sendOpen(this.documentsToOpen.pop());
|
|
447
|
+
}
|
|
448
|
+
this._serverInitialized.fire(this.serverCapabilities);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Once the server is initialized, this method generates the
|
|
453
|
+
* client and server handlers
|
|
454
|
+
*/
|
|
455
|
+
}, {
|
|
456
|
+
key: "afterInitialized",
|
|
457
|
+
value: function afterInitialized() {
|
|
458
|
+
var _this7 = this;
|
|
459
|
+
var disposable = this.connection.onError(function (e) {
|
|
460
|
+
return _this7._errorSignal.fire(e);
|
|
461
|
+
});
|
|
462
|
+
this._disposables.push(disposable);
|
|
463
|
+
var _loop = function _loop() {
|
|
464
|
+
var method = _arr[_i2];
|
|
465
|
+
var signal = _this7.serverNotifications[method];
|
|
466
|
+
var disposable = _this7.connection.onNotification(method, function (params) {
|
|
467
|
+
_this7.log(MessageKind.serverNotifiedClient, {
|
|
468
|
+
method: method,
|
|
469
|
+
message: params
|
|
470
|
+
});
|
|
471
|
+
signal.fire(params);
|
|
472
|
+
});
|
|
473
|
+
_this7._disposables.push(disposable);
|
|
474
|
+
};
|
|
475
|
+
for (var _i2 = 0, _arr = Object.values(Method.ServerNotification); _i2 < _arr.length; _i2++) {
|
|
476
|
+
_loop();
|
|
477
|
+
}
|
|
478
|
+
var _loop2 = function _loop2() {
|
|
479
|
+
var method = _arr2[_i3];
|
|
480
|
+
var signal = _this7.clientNotifications[method];
|
|
481
|
+
signal.event(function (params) {
|
|
482
|
+
_this7.log(MessageKind.clientNotifiedServer, {
|
|
483
|
+
method: method,
|
|
484
|
+
message: params
|
|
485
|
+
});
|
|
486
|
+
_this7.connection.sendNotification(method, params).catch(console.error);
|
|
487
|
+
});
|
|
488
|
+
};
|
|
489
|
+
for (var _i3 = 0, _arr2 = Object.values(Method.ClientNotification); _i3 < _arr2.length; _i3++) {
|
|
490
|
+
_loop2();
|
|
491
|
+
}
|
|
492
|
+
this.clientRequests = this.constructClientRequestHandler(Method.ClientRequest);
|
|
493
|
+
this.serverRequests = this.constructServerRequestHandler(Method.ServerRequest);
|
|
494
|
+
this.serverRequests['client/registerCapability'].setHandler( /*#__PURE__*/function () {
|
|
495
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
496
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
497
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
498
|
+
case 0:
|
|
499
|
+
params.registrations.forEach(function (capabilityRegistration) {
|
|
500
|
+
try {
|
|
501
|
+
var updatedCapabilities = registerServerCapability(_this7.serverCapabilities, capabilityRegistration);
|
|
502
|
+
if (updatedCapabilities === null) {
|
|
503
|
+
console.error("Failed to register server capability: ".concat(capabilityRegistration));
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
_this7.serverCapabilities = updatedCapabilities;
|
|
507
|
+
} catch (err) {
|
|
508
|
+
console.error(err);
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
case 1:
|
|
512
|
+
case "end":
|
|
513
|
+
return _context2.stop();
|
|
514
|
+
}
|
|
515
|
+
}, _callee2);
|
|
516
|
+
}));
|
|
517
|
+
return function (_x2) {
|
|
518
|
+
return _ref.apply(this, arguments);
|
|
519
|
+
};
|
|
520
|
+
}());
|
|
521
|
+
this.serverRequests['client/unregisterCapability'].setHandler( /*#__PURE__*/function () {
|
|
522
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
523
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
524
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
525
|
+
case 0:
|
|
526
|
+
params.unregisterations.forEach(function (capabilityUnregistration) {
|
|
527
|
+
_this7.serverCapabilities = unregisterServerCapability(_this7.serverCapabilities, capabilityUnregistration);
|
|
528
|
+
});
|
|
529
|
+
case 1:
|
|
530
|
+
case "end":
|
|
531
|
+
return _context3.stop();
|
|
532
|
+
}
|
|
533
|
+
}, _callee3);
|
|
534
|
+
}));
|
|
535
|
+
return function (_x3) {
|
|
536
|
+
return _ref2.apply(this, arguments);
|
|
537
|
+
};
|
|
538
|
+
}());
|
|
539
|
+
this.serverRequests['workspace/configuration'].setHandler( /*#__PURE__*/function () {
|
|
540
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
541
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
542
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
543
|
+
case 0:
|
|
544
|
+
return _context4.abrupt("return", params.items.map(function (item) {
|
|
545
|
+
// LSP: "If the client can’t provide a configuration setting for a given scope
|
|
546
|
+
// then `null` needs to be present in the returned array."
|
|
547
|
+
|
|
548
|
+
// for now we do not support configuration, but yaml server does not respect
|
|
549
|
+
// client capability so we have a handler just for that
|
|
550
|
+
return null;
|
|
551
|
+
}));
|
|
552
|
+
case 1:
|
|
553
|
+
case "end":
|
|
554
|
+
return _context4.stop();
|
|
555
|
+
}
|
|
556
|
+
}, _callee4);
|
|
557
|
+
}));
|
|
558
|
+
return function (_x4) {
|
|
559
|
+
return _ref3.apply(this, arguments);
|
|
560
|
+
};
|
|
561
|
+
}());
|
|
562
|
+
}
|
|
563
|
+
}, {
|
|
564
|
+
key: "_sendChange",
|
|
565
|
+
value:
|
|
566
|
+
/**
|
|
567
|
+
* Send the document changed data to the server.
|
|
568
|
+
*/
|
|
569
|
+
function _sendChange(changeEvents, documentInfo) {
|
|
570
|
+
if (!this.isReady) {
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
if (documentInfo.uri.length === 0) {
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
if (!this.openedUris.get(documentInfo.uri)) {
|
|
577
|
+
this.sendOpen(documentInfo);
|
|
578
|
+
}
|
|
579
|
+
var textDocumentChange = {
|
|
580
|
+
textDocument: {
|
|
581
|
+
uri: documentInfo.uri,
|
|
582
|
+
version: documentInfo.version
|
|
583
|
+
},
|
|
584
|
+
contentChanges: changeEvents
|
|
585
|
+
};
|
|
586
|
+
this.connection.sendNotification('textDocument/didChange', textDocumentChange).catch(console.error);
|
|
587
|
+
documentInfo.version++;
|
|
588
|
+
}
|
|
589
|
+
}]);
|
|
590
|
+
return LSPConnection;
|
|
591
|
+
}(LspWsConnection);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extractors/index.ts"],"names":[],"mappings":"AAGA,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ILSPCodeExtractorsManager } from '../tokens.js';
|
|
2
|
+
import type { IForeignCodeExtractor } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Manager for the code extractors
|
|
5
|
+
*/
|
|
6
|
+
export declare class CodeExtractorsManager implements ILSPCodeExtractorsManager {
|
|
7
|
+
constructor();
|
|
8
|
+
/**
|
|
9
|
+
* Get the extractors for the input cell type and the main language of
|
|
10
|
+
* the document
|
|
11
|
+
*
|
|
12
|
+
* @param cellType - type of cell
|
|
13
|
+
* @param hostLanguage - main language of the document
|
|
14
|
+
*/
|
|
15
|
+
getExtractors(cellType: string, hostLanguage: string | null): IForeignCodeExtractor[];
|
|
16
|
+
/**
|
|
17
|
+
* Register an extractor to extract foreign code from host documents of specified language.
|
|
18
|
+
*/
|
|
19
|
+
register(extractor: IForeignCodeExtractor, hostLanguage: string | null): void;
|
|
20
|
+
/**
|
|
21
|
+
* The map with key is the type of cell, value is another map between
|
|
22
|
+
* the language of cell and its code extractor.
|
|
23
|
+
*/
|
|
24
|
+
protected _extractorMap: Map<string, Map<string, IForeignCodeExtractor[]>>;
|
|
25
|
+
/**
|
|
26
|
+
* The map with key is the cell type, value is the code extractor associated
|
|
27
|
+
* with this cell type, this is used for the non-code cell types.
|
|
28
|
+
*/
|
|
29
|
+
protected _extractorMapAnyLanguage: Map<string, IForeignCodeExtractor[]>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/extractors/manager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;GAEG;AACH,qBACa,qBAAsB,YAAW,yBAAyB;;IAOrE;;;;;;OAMG;IACH,aAAa,CACX,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GAAG,IAAI,GAC1B,qBAAqB,EAAE;IAY1B;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAyB7E;;;OAGG;IACH,SAAS,CAAC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,EAAE,CAAC,CAAC,CAAC;IAE3E;;;OAGG;IACH,SAAS,CAAC,wBAAwB,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,EAAE,CAAC,CAAC;CAC1E"}
|