@difizen/libro-cofine-editor 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 +3 -0
- package/es/editor-contribution.d.ts +10 -0
- package/es/editor-contribution.d.ts.map +1 -0
- package/es/editor-contribution.js +31 -0
- package/es/index.d.ts +7 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +6 -0
- package/es/index.less +32 -0
- package/es/language/lsp/completion-provider.d.ts +13 -0
- package/es/language/lsp/completion-provider.d.ts.map +1 -0
- package/es/language/lsp/completion-provider.js +290 -0
- package/es/language/lsp/diagnostic-provider.d.ts +22 -0
- package/es/language/lsp/diagnostic-provider.d.ts.map +1 -0
- package/es/language/lsp/diagnostic-provider.js +161 -0
- package/es/language/lsp/format-provider.d.ts +9 -0
- package/es/language/lsp/format-provider.d.ts.map +1 -0
- package/es/language/lsp/format-provider.js +139 -0
- package/es/language/lsp/hover-provider.d.ts +8 -0
- package/es/language/lsp/hover-provider.d.ts.map +1 -0
- package/es/language/lsp/hover-provider.js +136 -0
- package/es/language/lsp/language-feature-provider.d.ts +17 -0
- package/es/language/lsp/language-feature-provider.d.ts.map +1 -0
- package/es/language/lsp/language-feature-provider.js +89 -0
- package/es/language/lsp/lsp-contribution.d.ts +25 -0
- package/es/language/lsp/lsp-contribution.d.ts.map +1 -0
- package/es/language/lsp/lsp-contribution.js +213 -0
- package/es/language/lsp/module.d.ts +2 -0
- package/es/language/lsp/module.d.ts.map +1 -0
- package/es/language/lsp/module.js +3 -0
- package/es/language/lsp/semantic-highlight-provider.d.ts +9 -0
- package/es/language/lsp/semantic-highlight-provider.d.ts.map +1 -0
- package/es/language/lsp/semantic-highlight-provider.js +41 -0
- package/es/language/lsp/signature-help-provider.d.ts +8 -0
- package/es/language/lsp/signature-help-provider.d.ts.map +1 -0
- package/es/language/lsp/signature-help-provider.js +108 -0
- package/es/language/lsp/type-concerters.d.ts +7 -0
- package/es/language/lsp/type-concerters.d.ts.map +1 -0
- package/es/language/lsp/type-concerters.js +37 -0
- package/es/language/python/data/MagicPython.tmLanguage.json +4213 -0
- package/es/language/python/data/MagicRegExp.tmLanguage.json +497 -0
- package/es/language/python/data/configurations/python.json +135 -0
- package/es/language/python/data/snippets/python.snippets.json +223 -0
- package/es/language/python/module.d.ts +2 -0
- package/es/language/python/module.d.ts.map +1 -0
- package/es/language/python/module.js +3 -0
- package/es/language/python/python-builtin.d.ts +86 -0
- package/es/language/python/python-builtin.d.ts.map +1 -0
- package/es/language/python/python-builtin.js +569 -0
- package/es/language/python/python-language-feature.d.ts +26 -0
- package/es/language/python/python-language-feature.d.ts.map +1 -0
- package/es/language/python/python-language-feature.js +174 -0
- package/es/language-specs.d.ts +33 -0
- package/es/language-specs.d.ts.map +1 -0
- package/es/language-specs.js +115 -0
- package/es/libro-e2-editor.d.ts +277 -0
- package/es/libro-e2-editor.d.ts.map +1 -0
- package/es/libro-e2-editor.js +720 -0
- package/es/libro-e2-preload.d.ts +5 -0
- package/es/libro-e2-preload.d.ts.map +1 -0
- package/es/libro-e2-preload.js +57 -0
- package/es/libro-sql-api.d.ts +8 -0
- package/es/libro-sql-api.d.ts.map +1 -0
- package/es/libro-sql-api.js +26 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +44 -0
- package/es/placeholder.d.ts +31 -0
- package/es/placeholder.d.ts.map +1 -0
- package/es/placeholder.js +101 -0
- package/es/theme/data/jupyter_dark.json +406 -0
- package/es/theme/data/jupyter_hc_dark.json +385 -0
- package/es/theme/data/jupyter_hc_light.json +386 -0
- package/es/theme/data/jupyter_light.json +386 -0
- package/es/theme/data/libro_dark.json +186 -0
- package/es/theme/data/libro_light.json +170 -0
- package/es/theme/libro-python-theme-contribution.d.ts +6 -0
- package/es/theme/libro-python-theme-contribution.d.ts.map +1 -0
- package/es/theme/libro-python-theme-contribution.js +49 -0
- package/es/theme/module.d.ts +2 -0
- package/es/theme/module.d.ts.map +1 -0
- package/es/theme/module.js +3 -0
- package/es/types.d.ts +10 -0
- package/es/types.d.ts.map +1 -0
- package/es/types.js +3 -0
- package/package.json +67 -0
- package/src/editor-contribution.ts +30 -0
- package/src/index.less +32 -0
- package/src/index.spec.ts +8 -0
- package/src/index.ts +6 -0
- package/src/language/lsp/completion-provider.ts +214 -0
- package/src/language/lsp/diagnostic-provider.ts +148 -0
- package/src/language/lsp/format-provider.ts +87 -0
- package/src/language/lsp/hover-provider.ts +98 -0
- package/src/language/lsp/language-feature-provider.ts +69 -0
- package/src/language/lsp/lsp-contribution.ts +159 -0
- package/src/language/lsp/module.ts +5 -0
- package/src/language/lsp/semantic-highlight-provider.ts +26 -0
- package/src/language/lsp/signature-help-provider.ts +65 -0
- package/src/language/lsp/type-concerters.ts +72 -0
- package/src/language/python/data/MagicPython.tmLanguage.json +4213 -0
- package/src/language/python/data/MagicRegExp.tmLanguage.json +497 -0
- package/src/language/python/data/configurations/python.json +135 -0
- package/src/language/python/data/snippets/python.snippets.json +223 -0
- package/src/language/python/module.ts +5 -0
- package/src/language/python/python-builtin.ts +891 -0
- package/src/language/python/python-language-feature.ts +163 -0
- package/src/language-specs.ts +99 -0
- package/src/libro-e2-editor.ts +922 -0
- package/src/libro-e2-preload.ts +23 -0
- package/src/libro-sql-api.ts +20 -0
- package/src/module.ts +44 -0
- package/src/placeholder.ts +100 -0
- package/src/theme/data/jupyter_dark.json +406 -0
- package/src/theme/data/jupyter_hc_dark.json +385 -0
- package/src/theme/data/jupyter_hc_light.json +386 -0
- package/src/theme/data/jupyter_light.json +386 -0
- package/src/theme/data/libro_dark.json +186 -0
- package/src/theme/data/libro_light.json +170 -0
- package/src/theme/libro-python-theme-contribution.ts +36 -0
- package/src/theme/module.ts +5 -0
- package/src/types.ts +11 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
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; }
|
|
3
|
+
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); } }
|
|
4
|
+
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); }); }; }
|
|
5
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
+
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); } }
|
|
7
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
8
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
9
|
+
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); }
|
|
10
|
+
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); }
|
|
11
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
+
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); }; }
|
|
13
|
+
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); }
|
|
14
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
15
|
+
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; } }
|
|
16
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
17
|
+
import { EditorCellView } from '@difizen/libro-core';
|
|
18
|
+
import * as monaco from '@difizen/monaco-editor-core';
|
|
19
|
+
import { LibroE2Editor } from "../../libro-e2-editor.js";
|
|
20
|
+
import { MonacoRange, MonacoUri } from "../../types.js";
|
|
21
|
+
import { LangaugeFeatureProvider } from "./language-feature-provider.js";
|
|
22
|
+
export var MarkerSeverity = /*#__PURE__*/function (MarkerSeverity) {
|
|
23
|
+
MarkerSeverity[MarkerSeverity["Hint"] = 1] = "Hint";
|
|
24
|
+
MarkerSeverity[MarkerSeverity["Info"] = 2] = "Info";
|
|
25
|
+
MarkerSeverity[MarkerSeverity["Warning"] = 4] = "Warning";
|
|
26
|
+
MarkerSeverity[MarkerSeverity["Error"] = 8] = "Error";
|
|
27
|
+
return MarkerSeverity;
|
|
28
|
+
}({});
|
|
29
|
+
var vererityMap = {
|
|
30
|
+
1: MarkerSeverity.Error,
|
|
31
|
+
2: MarkerSeverity.Warning,
|
|
32
|
+
3: MarkerSeverity.Info,
|
|
33
|
+
4: MarkerSeverity.Hint
|
|
34
|
+
};
|
|
35
|
+
export var DiagnosticProvider = /*#__PURE__*/function (_LangaugeFeatureProvi) {
|
|
36
|
+
_inherits(DiagnosticProvider, _LangaugeFeatureProvi);
|
|
37
|
+
var _super = _createSuper(DiagnosticProvider);
|
|
38
|
+
function DiagnosticProvider(libroService, lspConnection, virtualDocument) {
|
|
39
|
+
var _this;
|
|
40
|
+
_classCallCheck(this, DiagnosticProvider);
|
|
41
|
+
_this = _super.call(this, libroService, lspConnection, virtualDocument);
|
|
42
|
+
_this.diagnosticList = [];
|
|
43
|
+
_this.processDiagnostic();
|
|
44
|
+
return _this;
|
|
45
|
+
}
|
|
46
|
+
_createClass(DiagnosticProvider, [{
|
|
47
|
+
key: "addDiagnostic",
|
|
48
|
+
value: function addDiagnostic(model, marker) {
|
|
49
|
+
if (!this.diagnosticList.some(function (d) {
|
|
50
|
+
return d.model.uri.toString() === model.uri.toString();
|
|
51
|
+
})) {
|
|
52
|
+
this.diagnosticList.push({
|
|
53
|
+
model: model,
|
|
54
|
+
markers: [marker]
|
|
55
|
+
});
|
|
56
|
+
} else {
|
|
57
|
+
var _this$diagnosticList$;
|
|
58
|
+
(_this$diagnosticList$ = this.diagnosticList.find(function (d) {
|
|
59
|
+
return d.model.uri.toString() === model.uri.toString();
|
|
60
|
+
})) === null || _this$diagnosticList$ === void 0 || _this$diagnosticList$.markers.push(marker);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
key: "clearDiagnostic",
|
|
65
|
+
value: function clearDiagnostic() {
|
|
66
|
+
var _this$libroService$ac;
|
|
67
|
+
(_this$libroService$ac = this.libroService.active) === null || _this$libroService$ac === void 0 || _this$libroService$ac.model.cells.forEach(function (item) {
|
|
68
|
+
if (EditorCellView.is(item)) {
|
|
69
|
+
if (item.editor instanceof LibroE2Editor) {
|
|
70
|
+
var _item$editor$monacoEd;
|
|
71
|
+
var model = (_item$editor$monacoEd = item.editor.monacoEditor) === null || _item$editor$monacoEd === void 0 ? void 0 : _item$editor$monacoEd.getModel();
|
|
72
|
+
if (model) {
|
|
73
|
+
monaco.editor.setModelMarkers(model, 'libro-e2', []);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "displayDiagnostic",
|
|
81
|
+
value: function displayDiagnostic() {
|
|
82
|
+
this.clearDiagnostic();
|
|
83
|
+
this.diagnosticList.forEach(function (d) {
|
|
84
|
+
monaco.editor.setModelMarkers(d.model, 'libro-e2', d.markers);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}, {
|
|
88
|
+
key: "processDiagnostic",
|
|
89
|
+
value: function () {
|
|
90
|
+
var _processDiagnostic = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
91
|
+
var _this2 = this;
|
|
92
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
93
|
+
while (1) switch (_context.prev = _context.next) {
|
|
94
|
+
case 0:
|
|
95
|
+
this.lspConnection.serverNotifications['textDocument/publishDiagnostics'].event(function (e) {
|
|
96
|
+
_this2.diagnosticList = [];
|
|
97
|
+
e.diagnostics.forEach(function (diagnostic) {
|
|
98
|
+
var _editor$monacoEditor, _diagnostic$relatedIn;
|
|
99
|
+
var range = diagnostic.range;
|
|
100
|
+
// the diagnostic range must be in current editor
|
|
101
|
+
var editor = _this2.getEditorFromLSPPosition(range);
|
|
102
|
+
if (!editor || editor.getOption('lspEnabled') !== true) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
var model = editor === null || editor === void 0 || (_editor$monacoEditor = editor.monacoEditor) === null || _editor$monacoEditor === void 0 ? void 0 : _editor$monacoEditor.getModel();
|
|
106
|
+
if (!model) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
var editorStart = _this2.virtualDocument.transformVirtualToEditor({
|
|
110
|
+
line: range.start.line,
|
|
111
|
+
ch: range.start.character,
|
|
112
|
+
isVirtual: true
|
|
113
|
+
});
|
|
114
|
+
var editorEnd = _this2.virtualDocument.transformVirtualToEditor({
|
|
115
|
+
line: range.end.line,
|
|
116
|
+
ch: range.end.character,
|
|
117
|
+
isVirtual: true
|
|
118
|
+
});
|
|
119
|
+
if (!editorStart || !editorEnd) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
var markerRange = new MonacoRange(editorStart.line + 1, editorStart.ch, editorEnd.line + 1, editorEnd.ch);
|
|
123
|
+
var marker = {
|
|
124
|
+
source: diagnostic.source,
|
|
125
|
+
tags: diagnostic.tags,
|
|
126
|
+
message: diagnostic.message,
|
|
127
|
+
code: String(diagnostic.code),
|
|
128
|
+
severity: diagnostic.severity ? vererityMap[diagnostic.severity] : monaco.MarkerSeverity.Info,
|
|
129
|
+
relatedInformation: (_diagnostic$relatedIn = diagnostic.relatedInformation) === null || _diagnostic$relatedIn === void 0 ? void 0 : _diagnostic$relatedIn.map(function (item) {
|
|
130
|
+
return {
|
|
131
|
+
message: item.message,
|
|
132
|
+
resource: MonacoUri.parse(item.location.uri),
|
|
133
|
+
startLineNumber: markerRange.startLineNumber,
|
|
134
|
+
startColumn: markerRange.startColumn,
|
|
135
|
+
endLineNumber: markerRange.endLineNumber,
|
|
136
|
+
endColumn: markerRange.endColumn
|
|
137
|
+
};
|
|
138
|
+
}),
|
|
139
|
+
startLineNumber: editorStart.line + 1,
|
|
140
|
+
startColumn: editorStart.ch + 1,
|
|
141
|
+
endLineNumber: editorEnd.line + 1,
|
|
142
|
+
endColumn: editorEnd.ch + 1
|
|
143
|
+
};
|
|
144
|
+
_this2.addDiagnostic(model, marker);
|
|
145
|
+
});
|
|
146
|
+
_this2.displayDiagnostic();
|
|
147
|
+
});
|
|
148
|
+
case 1:
|
|
149
|
+
case "end":
|
|
150
|
+
return _context.stop();
|
|
151
|
+
}
|
|
152
|
+
}, _callee, this);
|
|
153
|
+
}));
|
|
154
|
+
function processDiagnostic() {
|
|
155
|
+
return _processDiagnostic.apply(this, arguments);
|
|
156
|
+
}
|
|
157
|
+
return processDiagnostic;
|
|
158
|
+
}()
|
|
159
|
+
}]);
|
|
160
|
+
return DiagnosticProvider;
|
|
161
|
+
}(LangaugeFeatureProvider);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type monaco from '@difizen/monaco-editor-core';
|
|
2
|
+
import { LangaugeFeatureProvider } from './language-feature-provider.js';
|
|
3
|
+
export declare class FormatProvider extends LangaugeFeatureProvider implements monaco.languages.DocumentFormattingEditProvider, monaco.languages.DocumentRangeFormattingEditProvider {
|
|
4
|
+
displayName: string;
|
|
5
|
+
provideDocumentRangeFormattingEdits: (model: monaco.editor.ITextModel, range: monaco.Range, options: monaco.languages.FormattingOptions, token: monaco.CancellationToken) => Promise<monaco.languages.TextEdit[]>;
|
|
6
|
+
provideDocumentFormattingEdits: (model: monaco.editor.ITextModel, options: monaco.languages.FormattingOptions, token: monaco.CancellationToken) => Promise<monaco.languages.TextEdit[]>;
|
|
7
|
+
formatDocumentByRange: (model: monaco.editor.ITextModel, range: monaco.Range, options: monaco.languages.FormattingOptions, token: monaco.CancellationToken) => Promise<monaco.languages.TextEdit[]>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=format-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-provider.d.ts","sourceRoot":"","sources":["../../../src/language/lsp/format-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AAEtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,qBAAa,cACX,SAAQ,uBACR,YACE,MAAM,CAAC,SAAS,CAAC,8BAA8B,EAC/C,MAAM,CAAC,SAAS,CAAC,mCAAmC;IAEtD,WAAW,SAAqB;IAEhC,mCAAmC,UAC1B,OAAO,MAAM,CAAC,UAAU,SACxB,YAAY,WACV,OAAO,SAAS,CAAC,iBAAiB,SACpC,OAAO,iBAAiB,KAC9B,QAAQ,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC,CAErC;IACF,8BAA8B,UACrB,OAAO,MAAM,CAAC,UAAU,WACtB,OAAO,SAAS,CAAC,iBAAiB,SACpC,OAAO,iBAAiB,KAC9B,QAAQ,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC,CAErC;IAEF,qBAAqB,UACZ,OAAO,MAAM,CAAC,UAAU,SACxB,YAAY,WACV,OAAO,SAAS,CAAC,iBAAiB,SACpC,OAAO,iBAAiB,KAC9B,QAAQ,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC,CAoDrC;CACH"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
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; }
|
|
3
|
+
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); } }
|
|
4
|
+
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); }); }; }
|
|
5
|
+
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); } }
|
|
6
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
7
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
8
|
+
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); }
|
|
9
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
10
|
+
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); }
|
|
11
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
+
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); }; }
|
|
13
|
+
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); }
|
|
14
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
15
|
+
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; } }
|
|
16
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
17
|
+
import { LangaugeFeatureProvider } from "./language-feature-provider.js";
|
|
18
|
+
export var FormatProvider = /*#__PURE__*/function (_LangaugeFeatureProvi) {
|
|
19
|
+
_inherits(FormatProvider, _LangaugeFeatureProvi);
|
|
20
|
+
var _super = _createSuper(FormatProvider);
|
|
21
|
+
function FormatProvider() {
|
|
22
|
+
var _this;
|
|
23
|
+
_classCallCheck(this, FormatProvider);
|
|
24
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
25
|
+
args[_key] = arguments[_key];
|
|
26
|
+
}
|
|
27
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
28
|
+
_this.displayName = 'libro-e2-format';
|
|
29
|
+
_this.provideDocumentRangeFormattingEdits = /*#__PURE__*/function () {
|
|
30
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(model, range, options, token) {
|
|
31
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
32
|
+
while (1) switch (_context.prev = _context.next) {
|
|
33
|
+
case 0:
|
|
34
|
+
return _context.abrupt("return", _this.formatDocumentByRange(model, range, options, token));
|
|
35
|
+
case 1:
|
|
36
|
+
case "end":
|
|
37
|
+
return _context.stop();
|
|
38
|
+
}
|
|
39
|
+
}, _callee);
|
|
40
|
+
}));
|
|
41
|
+
return function (_x, _x2, _x3, _x4) {
|
|
42
|
+
return _ref.apply(this, arguments);
|
|
43
|
+
};
|
|
44
|
+
}();
|
|
45
|
+
_this.provideDocumentFormattingEdits = /*#__PURE__*/function () {
|
|
46
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(model, options, token) {
|
|
47
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
48
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
49
|
+
case 0:
|
|
50
|
+
return _context2.abrupt("return", _this.formatDocumentByRange(model, model.getFullModelRange(), options, token));
|
|
51
|
+
case 1:
|
|
52
|
+
case "end":
|
|
53
|
+
return _context2.stop();
|
|
54
|
+
}
|
|
55
|
+
}, _callee2);
|
|
56
|
+
}));
|
|
57
|
+
return function (_x5, _x6, _x7) {
|
|
58
|
+
return _ref2.apply(this, arguments);
|
|
59
|
+
};
|
|
60
|
+
}();
|
|
61
|
+
_this.formatDocumentByRange = /*#__PURE__*/function () {
|
|
62
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(model, range, options, token) {
|
|
63
|
+
var provider, doc, result, edits;
|
|
64
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
65
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
66
|
+
case 0:
|
|
67
|
+
_context3.next = 2;
|
|
68
|
+
return _this.getProvider(model);
|
|
69
|
+
case 2:
|
|
70
|
+
provider = _context3.sent;
|
|
71
|
+
if (provider) {
|
|
72
|
+
_context3.next = 5;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
return _context3.abrupt("return", []);
|
|
76
|
+
case 5:
|
|
77
|
+
doc = provider.virtualDocument;
|
|
78
|
+
_context3.next = 8;
|
|
79
|
+
return _this.lspConnection.clientRequests['textDocument/rangeFormatting'].request({
|
|
80
|
+
// TODO: range transform
|
|
81
|
+
// TODO: pyright-extend supoport range format
|
|
82
|
+
range: {
|
|
83
|
+
start: {
|
|
84
|
+
line: range.startLineNumber - 1,
|
|
85
|
+
character: range.startColumn - 1
|
|
86
|
+
},
|
|
87
|
+
end: {
|
|
88
|
+
line: range.endLineNumber - 1,
|
|
89
|
+
character: range.endColumn - 1
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
textDocument: {
|
|
93
|
+
uri: doc.documentInfo.uri
|
|
94
|
+
},
|
|
95
|
+
options: {
|
|
96
|
+
insertSpaces: options.insertSpaces,
|
|
97
|
+
tabSize: options.tabSize
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
case 8:
|
|
101
|
+
result = _context3.sent;
|
|
102
|
+
if (!token.isCancellationRequested) {
|
|
103
|
+
_context3.next = 11;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
return _context3.abrupt("return", []);
|
|
107
|
+
case 11:
|
|
108
|
+
if (result) {
|
|
109
|
+
_context3.next = 13;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
return _context3.abrupt("return", []);
|
|
113
|
+
case 13:
|
|
114
|
+
edits = result.map(function (item) {
|
|
115
|
+
return {
|
|
116
|
+
range: {
|
|
117
|
+
startColumn: item.range.start.character + 1,
|
|
118
|
+
startLineNumber: item.range.start.line + 1,
|
|
119
|
+
endColumn: item.range.end.character + 1,
|
|
120
|
+
endLineNumber: item.range.end.line + 1
|
|
121
|
+
},
|
|
122
|
+
text: item.newText
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
return _context3.abrupt("return", edits);
|
|
126
|
+
case 15:
|
|
127
|
+
case "end":
|
|
128
|
+
return _context3.stop();
|
|
129
|
+
}
|
|
130
|
+
}, _callee3);
|
|
131
|
+
}));
|
|
132
|
+
return function (_x8, _x9, _x10, _x11) {
|
|
133
|
+
return _ref3.apply(this, arguments);
|
|
134
|
+
};
|
|
135
|
+
}();
|
|
136
|
+
return _this;
|
|
137
|
+
}
|
|
138
|
+
return _createClass(FormatProvider);
|
|
139
|
+
}(LangaugeFeatureProvider);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type monaco from '@difizen/monaco-editor-core';
|
|
2
|
+
import type * as lsp from 'vscode-languageserver-protocol';
|
|
3
|
+
import { LangaugeFeatureProvider } from './language-feature-provider.js';
|
|
4
|
+
export declare class HoverProvider extends LangaugeFeatureProvider implements monaco.languages.HoverProvider {
|
|
5
|
+
provideHover: (model: monaco.editor.ITextModel, position: monaco.Position, token: monaco.CancellationToken) => Promise<monaco.languages.Hover | undefined>;
|
|
6
|
+
}
|
|
7
|
+
export declare function formatContents(contents: lsp.MarkupContent | lsp.MarkedString | lsp.MarkedString[]): string;
|
|
8
|
+
//# sourceMappingURL=hover-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hover-provider.d.ts","sourceRoot":"","sources":["../../../src/language/lsp/hover-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,KAAK,GAAG,MAAM,gCAAgC,CAAC;AAI3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,qBAAa,aACX,SAAQ,uBACR,YAAW,MAAM,CAAC,SAAS,CAAC,aAAa;IAEzC,YAAY,UACH,OAAO,MAAM,CAAC,UAAU,YACrB,OAAO,QAAQ,SAClB,OAAO,iBAAiB,KAC9B,QAAQ,OAAO,SAAS,CAAC,KAAK,GAAG,SAAS,CAAC,CAqE5C;CACH;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,GAAG,CAAC,aAAa,GAAG,GAAG,CAAC,YAAY,GAAG,GAAG,CAAC,YAAY,EAAE,GAClE,MAAM,CAQR"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
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; }
|
|
3
|
+
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); } }
|
|
4
|
+
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); }); }; }
|
|
5
|
+
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); } }
|
|
6
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
7
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
8
|
+
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); }
|
|
9
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
10
|
+
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); }
|
|
11
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
+
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); }; }
|
|
13
|
+
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); }
|
|
14
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
15
|
+
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; } }
|
|
16
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
17
|
+
import { MonacoRange } from "../../types.js";
|
|
18
|
+
import { LangaugeFeatureProvider } from "./language-feature-provider.js";
|
|
19
|
+
export var HoverProvider = /*#__PURE__*/function (_LangaugeFeatureProvi) {
|
|
20
|
+
_inherits(HoverProvider, _LangaugeFeatureProvi);
|
|
21
|
+
var _super = _createSuper(HoverProvider);
|
|
22
|
+
function HoverProvider() {
|
|
23
|
+
var _this;
|
|
24
|
+
_classCallCheck(this, HoverProvider);
|
|
25
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
26
|
+
args[_key] = arguments[_key];
|
|
27
|
+
}
|
|
28
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
29
|
+
_this.provideHover = /*#__PURE__*/function () {
|
|
30
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(model, position, token) {
|
|
31
|
+
var editor, provider, lspConnection, docEditor, doc, virtualPos, result, contents, range, resultContents, resultRange, editorStart, editorEnd;
|
|
32
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
33
|
+
while (1) switch (_context.prev = _context.next) {
|
|
34
|
+
case 0:
|
|
35
|
+
editor = _this.getEditorByModel(model);
|
|
36
|
+
if (!(!editor || editor.getOption('lspEnabled') !== true)) {
|
|
37
|
+
_context.next = 3;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
return _context.abrupt("return");
|
|
41
|
+
case 3:
|
|
42
|
+
_context.next = 5;
|
|
43
|
+
return _this.getProvider(model);
|
|
44
|
+
case 5:
|
|
45
|
+
provider = _context.sent;
|
|
46
|
+
if (provider) {
|
|
47
|
+
_context.next = 8;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
return _context.abrupt("return");
|
|
51
|
+
case 8:
|
|
52
|
+
lspConnection = provider.lspConnection, docEditor = provider.editor, doc = provider.virtualDocument;
|
|
53
|
+
virtualPos = doc.transformEditorToVirtual(docEditor, {
|
|
54
|
+
line: position.lineNumber - 1,
|
|
55
|
+
// lsp is zero based, monaco is one based
|
|
56
|
+
ch: position.column,
|
|
57
|
+
isEditor: true
|
|
58
|
+
});
|
|
59
|
+
if (virtualPos) {
|
|
60
|
+
_context.next = 12;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
return _context.abrupt("return");
|
|
64
|
+
case 12:
|
|
65
|
+
_context.next = 14;
|
|
66
|
+
return lspConnection.clientRequests['textDocument/hover'].request({
|
|
67
|
+
position: {
|
|
68
|
+
line: virtualPos.line,
|
|
69
|
+
character: virtualPos.ch
|
|
70
|
+
},
|
|
71
|
+
textDocument: {
|
|
72
|
+
uri: doc.documentInfo.uri
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
case 14:
|
|
76
|
+
result = _context.sent;
|
|
77
|
+
if (result) {
|
|
78
|
+
_context.next = 17;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
return _context.abrupt("return");
|
|
82
|
+
case 17:
|
|
83
|
+
contents = result.contents, range = result.range;
|
|
84
|
+
resultContents = [{
|
|
85
|
+
value: formatContents(contents)
|
|
86
|
+
}];
|
|
87
|
+
if (range) {
|
|
88
|
+
editorStart = doc.transformVirtualToEditor({
|
|
89
|
+
line: range.start.line,
|
|
90
|
+
ch: range.start.character,
|
|
91
|
+
isVirtual: true
|
|
92
|
+
});
|
|
93
|
+
editorEnd = doc.transformVirtualToEditor({
|
|
94
|
+
line: range.end.line,
|
|
95
|
+
ch: range.end.character,
|
|
96
|
+
isVirtual: true
|
|
97
|
+
});
|
|
98
|
+
if (editorStart && editorEnd) {
|
|
99
|
+
resultRange = new MonacoRange(editorStart.line + 1, editorStart.ch + 1, editorEnd.line + 1, editorEnd.ch + 1);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (!token.isCancellationRequested) {
|
|
103
|
+
_context.next = 22;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
return _context.abrupt("return");
|
|
107
|
+
case 22:
|
|
108
|
+
return _context.abrupt("return", {
|
|
109
|
+
contents: resultContents,
|
|
110
|
+
range: resultRange
|
|
111
|
+
});
|
|
112
|
+
case 23:
|
|
113
|
+
case "end":
|
|
114
|
+
return _context.stop();
|
|
115
|
+
}
|
|
116
|
+
}, _callee);
|
|
117
|
+
}));
|
|
118
|
+
return function (_x, _x2, _x3) {
|
|
119
|
+
return _ref.apply(this, arguments);
|
|
120
|
+
};
|
|
121
|
+
}();
|
|
122
|
+
return _this;
|
|
123
|
+
}
|
|
124
|
+
return _createClass(HoverProvider);
|
|
125
|
+
}(LangaugeFeatureProvider);
|
|
126
|
+
export function formatContents(contents) {
|
|
127
|
+
if (Array.isArray(contents)) {
|
|
128
|
+
return contents.map(function (c) {
|
|
129
|
+
return formatContents(c) + '\n\n';
|
|
130
|
+
}).join('');
|
|
131
|
+
} else if (typeof contents === 'string') {
|
|
132
|
+
return contents;
|
|
133
|
+
} else {
|
|
134
|
+
return contents.value;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { LibroService } from '@difizen/libro-core';
|
|
2
|
+
import type { LSPProviderResult } from '@difizen/libro-lsp';
|
|
3
|
+
import type { LSPConnection, VirtualDocument } from '@difizen/libro-lsp';
|
|
4
|
+
import type monaco from '@difizen/monaco-editor-core';
|
|
5
|
+
import type * as lsp from 'vscode-languageserver-protocol';
|
|
6
|
+
import { LibroE2Editor } from '../../libro-e2-editor.js';
|
|
7
|
+
export declare class LangaugeFeatureProvider {
|
|
8
|
+
protected libroService: LibroService;
|
|
9
|
+
protected lspProvider?: LSPProviderResult;
|
|
10
|
+
protected lspConnection: LSPConnection;
|
|
11
|
+
virtualDocument: VirtualDocument;
|
|
12
|
+
constructor(libroService: LibroService, lspConnection: LSPConnection, virtualDocument: VirtualDocument);
|
|
13
|
+
protected getEditorByModel(model: monaco.editor.ITextModel): LibroE2Editor | undefined;
|
|
14
|
+
protected getEditorFromLSPPosition(range: lsp.Range): LibroE2Editor | undefined;
|
|
15
|
+
protected getProvider(model: monaco.editor.ITextModel): Promise<LSPProviderResult | undefined>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=language-feature-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-feature-provider.d.ts","sourceRoot":"","sources":["../../../src/language/lsp/language-feature-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,KAAK,GAAG,MAAM,gCAAgC,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,qBAAa,uBAAuB;IAClC,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC;IACrC,SAAS,CAAC,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAC1C,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;IACvC,eAAe,EAAE,eAAe,CAAC;gBAE/B,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,eAAe;IAOlC,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU;IAoB1D,SAAS,CAAC,wBAAwB,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK;cAanC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU;CAW5D"}
|