@difizen/libro-language-client 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (298) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +0 -0
  3. package/es/common/api.d.ts +38 -0
  4. package/es/common/api.d.ts.map +1 -0
  5. package/es/common/api.js +9 -0
  6. package/es/common/callHierarchy.d.ts +39 -0
  7. package/es/common/callHierarchy.d.ts.map +1 -0
  8. package/es/common/callHierarchy.js +139 -0
  9. package/es/common/client.d.ts +482 -0
  10. package/es/common/client.d.ts.map +1 -0
  11. package/es/common/client.js +2731 -0
  12. package/es/common/codeAction.d.ts +22 -0
  13. package/es/common/codeAction.d.ts.map +1 -0
  14. package/es/common/codeAction.js +149 -0
  15. package/es/common/codeConverter.d.ts +81 -0
  16. package/es/common/codeConverter.d.ts.map +1 -0
  17. package/es/common/codeConverter.js +1040 -0
  18. package/es/common/codeLens.d.ts +26 -0
  19. package/es/common/codeLens.d.ts.map +1 -0
  20. package/es/common/codeLens.js +125 -0
  21. package/es/common/colorProvider.d.ts +27 -0
  22. package/es/common/colorProvider.d.ts.map +1 -0
  23. package/es/common/colorProvider.js +104 -0
  24. package/es/common/completion.d.ts +22 -0
  25. package/es/common/completion.d.ts.map +1 -0
  26. package/es/common/completion.js +130 -0
  27. package/es/common/configuration.d.ts +71 -0
  28. package/es/common/configuration.d.ts.map +1 -0
  29. package/es/common/configuration.js +292 -0
  30. package/es/common/declaration.d.ts +18 -0
  31. package/es/common/declaration.d.ts.map +1 -0
  32. package/es/common/declaration.js +88 -0
  33. package/es/common/definition.d.ts +18 -0
  34. package/es/common/definition.d.ts.map +1 -0
  35. package/es/common/definition.js +80 -0
  36. package/es/common/diagnostic.d.ts +125 -0
  37. package/es/common/diagnostic.d.ts.map +1 -0
  38. package/es/common/diagnostic.js +1442 -0
  39. package/es/common/documentHighlight.d.ts +17 -0
  40. package/es/common/documentHighlight.d.ts.map +1 -0
  41. package/es/common/documentHighlight.js +73 -0
  42. package/es/common/documentLink.d.ts +21 -0
  43. package/es/common/documentLink.d.ts.map +1 -0
  44. package/es/common/documentLink.js +90 -0
  45. package/es/common/documentSymbol.d.ts +20 -0
  46. package/es/common/documentSymbol.d.ts.map +1 -0
  47. package/es/common/documentSymbol.js +134 -0
  48. package/es/common/executeCommand.d.ts +22 -0
  49. package/es/common/executeCommand.d.ts.map +1 -0
  50. package/es/common/executeCommand.js +117 -0
  51. package/es/common/features.d.ts +421 -0
  52. package/es/common/features.d.ts.map +1 -0
  53. package/es/common/features.js +576 -0
  54. package/es/common/fileOperations.d.ts +118 -0
  55. package/es/common/fileOperations.d.ts.map +1 -0
  56. package/es/common/fileOperations.js +705 -0
  57. package/es/common/fileSystemWatcher.d.ts +19 -0
  58. package/es/common/fileSystemWatcher.d.ts.map +1 -0
  59. package/es/common/fileSystemWatcher.js +173 -0
  60. package/es/common/foldingRange.d.ts +22 -0
  61. package/es/common/foldingRange.d.ts.map +1 -0
  62. package/es/common/foldingRange.js +127 -0
  63. package/es/common/formatting.d.ts +41 -0
  64. package/es/common/formatting.d.ts.map +1 -0
  65. package/es/common/formatting.js +233 -0
  66. package/es/common/hover.d.ts +18 -0
  67. package/es/common/hover.d.ts.map +1 -0
  68. package/es/common/hover.js +80 -0
  69. package/es/common/implementation.d.ts +18 -0
  70. package/es/common/implementation.d.ts.map +1 -0
  71. package/es/common/implementation.js +88 -0
  72. package/es/common/inlayHint.d.ts +23 -0
  73. package/es/common/inlayHint.d.ts.map +1 -0
  74. package/es/common/inlayHint.js +187 -0
  75. package/es/common/inlineCompletion.d.ts +20 -0
  76. package/es/common/inlineCompletion.d.ts.map +1 -0
  77. package/es/common/inlineCompletion.js +74 -0
  78. package/es/common/inlineValue.d.ts +21 -0
  79. package/es/common/inlineValue.d.ts.map +1 -0
  80. package/es/common/inlineValue.js +124 -0
  81. package/es/common/linkedEditingRange.d.ts +23 -0
  82. package/es/common/linkedEditingRange.d.ts.map +1 -0
  83. package/es/common/linkedEditingRange.js +94 -0
  84. package/es/common/notebook.d.ts +97 -0
  85. package/es/common/notebook.d.ts.map +1 -0
  86. package/es/common/notebook.js +1444 -0
  87. package/es/common/progress.d.ts +12 -0
  88. package/es/common/progress.d.ts.map +1 -0
  89. package/es/common/progress.js +75 -0
  90. package/es/common/progressPart.d.ts +25 -0
  91. package/es/common/progressPart.d.ts.map +1 -0
  92. package/es/common/progressPart.js +147 -0
  93. package/es/common/protocolCallHierarchyItem.d.ts +9 -0
  94. package/es/common/protocolCallHierarchyItem.d.ts.map +1 -0
  95. package/es/common/protocolCallHierarchyItem.js +34 -0
  96. package/es/common/protocolCodeAction.d.ts +7 -0
  97. package/es/common/protocolCodeAction.d.ts.map +1 -0
  98. package/es/common/protocolCodeAction.js +32 -0
  99. package/es/common/protocolCodeLens.d.ts +7 -0
  100. package/es/common/protocolCodeLens.d.ts.map +1 -0
  101. package/es/common/protocolCodeLens.js +29 -0
  102. package/es/common/protocolCompletionItem.d.ts +13 -0
  103. package/es/common/protocolCompletionItem.d.ts.map +1 -0
  104. package/es/common/protocolCompletionItem.js +29 -0
  105. package/es/common/protocolConverter.d.ts +174 -0
  106. package/es/common/protocolConverter.d.ts.map +1 -0
  107. package/es/common/protocolConverter.js +1982 -0
  108. package/es/common/protocolDiagnostic.d.ts +20 -0
  109. package/es/common/protocolDiagnostic.d.ts.map +1 -0
  110. package/es/common/protocolDiagnostic.js +46 -0
  111. package/es/common/protocolDocumentLink.d.ts +8 -0
  112. package/es/common/protocolDocumentLink.d.ts.map +1 -0
  113. package/es/common/protocolDocumentLink.js +29 -0
  114. package/es/common/protocolInlayHint.d.ts +8 -0
  115. package/es/common/protocolInlayHint.d.ts.map +1 -0
  116. package/es/common/protocolInlayHint.js +29 -0
  117. package/es/common/protocolTypeHierarchyItem.d.ts +9 -0
  118. package/es/common/protocolTypeHierarchyItem.d.ts.map +1 -0
  119. package/es/common/protocolTypeHierarchyItem.js +34 -0
  120. package/es/common/protocolWorkspaceSymbol.d.ts +9 -0
  121. package/es/common/protocolWorkspaceSymbol.d.ts.map +1 -0
  122. package/es/common/protocolWorkspaceSymbol.js +36 -0
  123. package/es/common/reference.d.ts +22 -0
  124. package/es/common/reference.d.ts.map +1 -0
  125. package/es/common/reference.js +78 -0
  126. package/es/common/rename.d.ts +29 -0
  127. package/es/common/rename.d.ts.map +1 -0
  128. package/es/common/rename.js +132 -0
  129. package/es/common/selectionRange.d.ts +18 -0
  130. package/es/common/selectionRange.d.ts.map +1 -0
  131. package/es/common/selectionRange.js +108 -0
  132. package/es/common/semanticTokens.d.ts +36 -0
  133. package/es/common/semanticTokens.d.ts.map +1 -0
  134. package/es/common/semanticTokens.js +226 -0
  135. package/es/common/signatureHelp.d.ts +18 -0
  136. package/es/common/signatureHelp.d.ts.map +1 -0
  137. package/es/common/signatureHelp.js +103 -0
  138. package/es/common/textSynchronization.d.ts +104 -0
  139. package/es/common/textSynchronization.d.ts.map +1 -0
  140. package/es/common/textSynchronization.js +771 -0
  141. package/es/common/typeDefinition.d.ts +18 -0
  142. package/es/common/typeDefinition.d.ts.map +1 -0
  143. package/es/common/typeDefinition.js +89 -0
  144. package/es/common/typeHierarchy.d.ts +33 -0
  145. package/es/common/typeHierarchy.d.ts.map +1 -0
  146. package/es/common/typeHierarchy.js +138 -0
  147. package/es/common/utils/async.d.ts +42 -0
  148. package/es/common/utils/async.d.ts.map +1 -0
  149. package/es/common/utils/async.js +441 -0
  150. package/es/common/utils/is.d.ts +13 -0
  151. package/es/common/utils/is.d.ts.map +1 -0
  152. package/es/common/utils/is.js +52 -0
  153. package/es/common/utils/uuid.d.ts +23 -0
  154. package/es/common/utils/uuid.d.ts.map +1 -0
  155. package/es/common/utils/uuid.js +85 -0
  156. package/es/common/vscodeAdaptor/convertor.d.ts +7 -0
  157. package/es/common/vscodeAdaptor/convertor.d.ts.map +1 -0
  158. package/es/common/vscodeAdaptor/convertor.js +66 -0
  159. package/es/common/vscodeAdaptor/diagnosticCollection.d.ts +33 -0
  160. package/es/common/vscodeAdaptor/diagnosticCollection.d.ts.map +1 -0
  161. package/es/common/vscodeAdaptor/diagnosticCollection.js +310 -0
  162. package/es/common/vscodeAdaptor/extHostTypes.d.ts +1496 -0
  163. package/es/common/vscodeAdaptor/extHostTypes.d.ts.map +1 -0
  164. package/es/common/vscodeAdaptor/extHostTypes.js +3825 -0
  165. package/es/common/vscodeAdaptor/fileWatcher.d.ts +19 -0
  166. package/es/common/vscodeAdaptor/fileWatcher.d.ts.map +1 -0
  167. package/es/common/vscodeAdaptor/fileWatcher.js +45 -0
  168. package/es/common/vscodeAdaptor/hostTypeUtil.d.ts +192 -0
  169. package/es/common/vscodeAdaptor/hostTypeUtil.d.ts.map +1 -0
  170. package/es/common/vscodeAdaptor/hostTypeUtil.js +566 -0
  171. package/es/common/vscodeAdaptor/libro-fs.d.ts +21 -0
  172. package/es/common/vscodeAdaptor/libro-fs.d.ts.map +1 -0
  173. package/es/common/vscodeAdaptor/libro-fs.js +64 -0
  174. package/es/common/vscodeAdaptor/libroWindow.d.ts +21 -0
  175. package/es/common/vscodeAdaptor/libroWindow.d.ts.map +1 -0
  176. package/es/common/vscodeAdaptor/libroWindow.js +75 -0
  177. package/es/common/vscodeAdaptor/libroWorkspace.d.ts +33 -0
  178. package/es/common/vscodeAdaptor/libroWorkspace.d.ts.map +1 -0
  179. package/es/common/vscodeAdaptor/libroWorkspace.js +250 -0
  180. package/es/common/vscodeAdaptor/lspEnv.d.ts +8 -0
  181. package/es/common/vscodeAdaptor/lspEnv.d.ts.map +1 -0
  182. package/es/common/vscodeAdaptor/lspEnv.js +31 -0
  183. package/es/common/vscodeAdaptor/monaco-converter.d.ts +229 -0
  184. package/es/common/vscodeAdaptor/monaco-converter.d.ts.map +1 -0
  185. package/es/common/vscodeAdaptor/monaco-converter.js +1613 -0
  186. package/es/common/vscodeAdaptor/monacoLanguages.d.ts +48 -0
  187. package/es/common/vscodeAdaptor/monacoLanguages.d.ts.map +1 -0
  188. package/es/common/vscodeAdaptor/monacoLanguages.js +484 -0
  189. package/es/common/vscodeAdaptor/services.d.ts +85 -0
  190. package/es/common/vscodeAdaptor/services.d.ts.map +1 -0
  191. package/es/common/vscodeAdaptor/services.js +3 -0
  192. package/es/common/vscodeAdaptor/typings.d.ts +10 -0
  193. package/es/common/vscodeAdaptor/util.d.ts +3 -0
  194. package/es/common/vscodeAdaptor/util.d.ts.map +1 -0
  195. package/es/common/vscodeAdaptor/util.js +6 -0
  196. package/es/common/vscodeAdaptor/vscodeAdaptor.d.ts +77 -0
  197. package/es/common/vscodeAdaptor/vscodeAdaptor.d.ts.map +1 -0
  198. package/es/common/vscodeAdaptor/vscodeAdaptor.js +124 -0
  199. package/es/common/workspaceFolder.d.ts +32 -0
  200. package/es/common/workspaceFolder.d.ts.map +1 -0
  201. package/es/common/workspaceFolder.js +204 -0
  202. package/es/common/workspaceSymbol.d.ts +21 -0
  203. package/es/common/workspaceSymbol.d.ts.map +1 -0
  204. package/es/common/workspaceSymbol.js +101 -0
  205. package/es/constants.d.ts +2 -0
  206. package/es/constants.d.ts.map +1 -0
  207. package/es/constants.js +1 -0
  208. package/es/index.d.ts +6 -0
  209. package/es/index.d.ts.map +1 -0
  210. package/es/index.js +5 -0
  211. package/es/libro-language-client-contribution.d.ts +10 -0
  212. package/es/libro-language-client-contribution.d.ts.map +1 -0
  213. package/es/libro-language-client-contribution.js +143 -0
  214. package/es/libro-language-client-manager.d.ts +34 -0
  215. package/es/libro-language-client-manager.d.ts.map +1 -0
  216. package/es/libro-language-client-manager.js +277 -0
  217. package/es/libro-language-client.d.ts +27 -0
  218. package/es/libro-language-client.d.ts.map +1 -0
  219. package/es/libro-language-client.js +141 -0
  220. package/es/module.d.ts +3 -0
  221. package/es/module.d.ts.map +1 -0
  222. package/es/module.js +13 -0
  223. package/package.json +69 -0
  224. package/src/common/api.ts +155 -0
  225. package/src/common/callHierarchy.ts +269 -0
  226. package/src/common/client.ts +3192 -0
  227. package/src/common/codeAction.ts +237 -0
  228. package/src/common/codeConverter.ts +1409 -0
  229. package/src/common/codeLens.ts +188 -0
  230. package/src/common/colorProvider.ts +192 -0
  231. package/src/common/completion.ts +281 -0
  232. package/src/common/configuration.ts +338 -0
  233. package/src/common/declaration.ts +140 -0
  234. package/src/common/definition.ts +138 -0
  235. package/src/common/diagnostic.ts +1408 -0
  236. package/src/common/documentHighlight.ts +140 -0
  237. package/src/common/documentLink.ts +180 -0
  238. package/src/common/documentSymbol.ts +186 -0
  239. package/src/common/executeCommand.ts +129 -0
  240. package/src/common/features.ts +1157 -0
  241. package/src/common/fileOperations.ts +635 -0
  242. package/src/common/fileSystemWatcher.ts +184 -0
  243. package/src/common/foldingRange.ts +160 -0
  244. package/src/common/formatting.ts +465 -0
  245. package/src/common/hover.ts +133 -0
  246. package/src/common/implementation.ts +142 -0
  247. package/src/common/inlayHint.ts +201 -0
  248. package/src/common/inlineCompletion.ts +160 -0
  249. package/src/common/inlineValue.ts +158 -0
  250. package/src/common/linkedEditingRange.ts +141 -0
  251. package/src/common/notebook.ts +1443 -0
  252. package/src/common/progress.ts +61 -0
  253. package/src/common/progressPart.ts +151 -0
  254. package/src/common/protocolCallHierarchyItem.ts +29 -0
  255. package/src/common/protocolCodeAction.ts +17 -0
  256. package/src/common/protocolCodeLens.ts +15 -0
  257. package/src/common/protocolCompletionItem.ts +22 -0
  258. package/src/common/protocolConverter.ts +2627 -0
  259. package/src/common/protocolDiagnostic.ts +47 -0
  260. package/src/common/protocolDocumentLink.ts +17 -0
  261. package/src/common/protocolInlayHint.ts +21 -0
  262. package/src/common/protocolTypeHierarchyItem.ts +29 -0
  263. package/src/common/protocolWorkspaceSymbol.ts +39 -0
  264. package/src/common/reference.ts +144 -0
  265. package/src/common/rename.ts +230 -0
  266. package/src/common/selectionRange.ts +136 -0
  267. package/src/common/semanticTokens.ts +383 -0
  268. package/src/common/signatureHelp.ts +170 -0
  269. package/src/common/textSynchronization.ts +819 -0
  270. package/src/common/typeDefinition.ts +146 -0
  271. package/src/common/typeHierarchy.ts +248 -0
  272. package/src/common/utils/async.ts +354 -0
  273. package/src/common/utils/is.ts +63 -0
  274. package/src/common/utils/uuid.ts +136 -0
  275. package/src/common/vscodeAdaptor/convertor.ts +73 -0
  276. package/src/common/vscodeAdaptor/diagnosticCollection.ts +238 -0
  277. package/src/common/vscodeAdaptor/extHostTypes.ts +4498 -0
  278. package/src/common/vscodeAdaptor/fileWatcher.ts +36 -0
  279. package/src/common/vscodeAdaptor/hostTypeUtil.ts +539 -0
  280. package/src/common/vscodeAdaptor/libro-fs.ts +51 -0
  281. package/src/common/vscodeAdaptor/libroWindow.ts +85 -0
  282. package/src/common/vscodeAdaptor/libroWorkspace.ts +261 -0
  283. package/src/common/vscodeAdaptor/lspEnv.ts +16 -0
  284. package/src/common/vscodeAdaptor/monaco-converter.ts +1800 -0
  285. package/src/common/vscodeAdaptor/monacoLanguages.ts +511 -0
  286. package/src/common/vscodeAdaptor/services.ts +278 -0
  287. package/src/common/vscodeAdaptor/typings.d.ts +10 -0
  288. package/src/common/vscodeAdaptor/util.ts +7 -0
  289. package/src/common/vscodeAdaptor/vscodeAdaptor.ts +122 -0
  290. package/src/common/workspaceFolder.ts +236 -0
  291. package/src/common/workspaceSymbol.ts +166 -0
  292. package/src/constants.ts +1 -0
  293. package/src/index.spec.ts +7 -0
  294. package/src/index.ts +5 -0
  295. package/src/libro-language-client-contribution.ts +49 -0
  296. package/src/libro-language-client-manager.ts +131 -0
  297. package/src/libro-language-client.ts +100 -0
  298. package/src/module.ts +19 -0
@@ -0,0 +1,1040 @@
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 _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
6
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
+ /* --------------------------------------------------------------------------------------------
9
+ * Copyright (c) Microsoft Corporation. All rights reserved.
10
+ * Licensed under the MIT License. See License.txt in the project root for license information.
11
+ * ------------------------------------------------------------------------------------------ */
12
+
13
+ import * as proto from '@difizen/vscode-languageserver-protocol';
14
+ import ProtocolCallHierarchyItem from "./protocolCallHierarchyItem.js";
15
+ import ProtocolCodeAction from "./protocolCodeAction.js";
16
+ import ProtocolCodeLens from "./protocolCodeLens.js";
17
+ import ProtocolCompletionItem from "./protocolCompletionItem.js";
18
+ import { DiagnosticCode } from "./protocolDiagnostic.js";
19
+ import { ProtocolDiagnostic } from "./protocolDiagnostic.js";
20
+ import ProtocolDocumentLink from "./protocolDocumentLink.js";
21
+ import ProtocolInlayHint from "./protocolInlayHint.js";
22
+ import ProtocolTypeHierarchyItem from "./protocolTypeHierarchyItem.js";
23
+ import WorkspaceSymbol from "./protocolWorkspaceSymbol.js";
24
+ import * as async from "./utils/async.js";
25
+ import * as Is from "./utils/is.js";
26
+ import { SymbolKind, TextDocumentSaveReason, DiagnosticSeverity, DiagnosticTag } from "./vscodeAdaptor/vscodeAdaptor.js";
27
+ import { CompletionTriggerKind } from "./vscodeAdaptor/vscodeAdaptor.js";
28
+ import { SignatureHelpTriggerKind } from "./vscodeAdaptor/vscodeAdaptor.js";
29
+ import { CompletionItemTag, SnippetString } from "./vscodeAdaptor/vscodeAdaptor.js";
30
+ import { CodeActionTriggerKind } from "./vscodeAdaptor/vscodeAdaptor.js";
31
+ import { InlineCompletionTriggerKind } from "./vscodeAdaptor/vscodeAdaptor.js";
32
+ var InsertReplaceRange;
33
+ (function (_InsertReplaceRange) {
34
+ function is(value) {
35
+ var candidate = value;
36
+ return candidate && !!candidate.inserting && !!candidate.replacing;
37
+ }
38
+ _InsertReplaceRange.is = is;
39
+ })(InsertReplaceRange || (InsertReplaceRange = {}));
40
+ export function createConverter(uriConverter) {
41
+ var nullConverter = function nullConverter(value) {
42
+ return value.toString();
43
+ };
44
+ var _uriConverter = uriConverter || nullConverter;
45
+ function asUri(value) {
46
+ return _uriConverter(value);
47
+ }
48
+ function asTextDocumentIdentifier(textDocument) {
49
+ return {
50
+ uri: _uriConverter(textDocument.uri)
51
+ };
52
+ }
53
+ function asTextDocumentItem(textDocument) {
54
+ return {
55
+ uri: _uriConverter(textDocument.uri),
56
+ languageId: textDocument.languageId,
57
+ version: textDocument.version,
58
+ text: textDocument.getText()
59
+ };
60
+ }
61
+ function asVersionedTextDocumentIdentifier(textDocument) {
62
+ return {
63
+ uri: _uriConverter(textDocument.uri),
64
+ version: textDocument.version
65
+ };
66
+ }
67
+ function asOpenTextDocumentParams(textDocument) {
68
+ return {
69
+ textDocument: asTextDocumentItem(textDocument)
70
+ };
71
+ }
72
+ function isTextDocumentChangeEvent(value) {
73
+ var candidate = value;
74
+ return !!candidate.document && !!candidate.contentChanges;
75
+ }
76
+ function isTextDocument(value) {
77
+ var candidate = value;
78
+ return !!candidate.uri && !!candidate.version;
79
+ }
80
+ function asChangeTextDocumentParams(arg0, arg1, arg2) {
81
+ if (isTextDocument(arg0)) {
82
+ var result = {
83
+ textDocument: {
84
+ uri: _uriConverter(arg0.uri),
85
+ version: arg0.version
86
+ },
87
+ contentChanges: [{
88
+ text: arg0.getText()
89
+ }]
90
+ };
91
+ return result;
92
+ } else if (isTextDocumentChangeEvent(arg0)) {
93
+ var _uri = arg1;
94
+ var _version = arg2;
95
+ var _result = {
96
+ textDocument: {
97
+ uri: _uriConverter(_uri),
98
+ version: _version
99
+ },
100
+ contentChanges: arg0.contentChanges.map(function (change) {
101
+ var range = change.range;
102
+ return {
103
+ range: {
104
+ start: {
105
+ line: range.start.line,
106
+ character: range.start.character
107
+ },
108
+ end: {
109
+ line: range.end.line,
110
+ character: range.end.character
111
+ }
112
+ },
113
+ rangeLength: change.rangeLength,
114
+ text: change.text
115
+ };
116
+ })
117
+ };
118
+ return _result;
119
+ } else {
120
+ throw Error('Unsupported text document change parameter');
121
+ }
122
+ }
123
+ function asCloseTextDocumentParams(textDocument) {
124
+ return {
125
+ textDocument: asTextDocumentIdentifier(textDocument)
126
+ };
127
+ }
128
+ function asSaveTextDocumentParams(textDocument) {
129
+ var includeContent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
130
+ var result = {
131
+ textDocument: asTextDocumentIdentifier(textDocument)
132
+ };
133
+ if (includeContent) {
134
+ result.text = textDocument.getText();
135
+ }
136
+ return result;
137
+ }
138
+ function asTextDocumentSaveReason(reason) {
139
+ switch (reason) {
140
+ case TextDocumentSaveReason.Manual:
141
+ return proto.TextDocumentSaveReason.Manual;
142
+ case TextDocumentSaveReason.AfterDelay:
143
+ return proto.TextDocumentSaveReason.AfterDelay;
144
+ case TextDocumentSaveReason.FocusOut:
145
+ return proto.TextDocumentSaveReason.FocusOut;
146
+ }
147
+ return proto.TextDocumentSaveReason.Manual;
148
+ }
149
+ function asWillSaveTextDocumentParams(event) {
150
+ return {
151
+ textDocument: asTextDocumentIdentifier(event.document),
152
+ reason: asTextDocumentSaveReason(event.reason)
153
+ };
154
+ }
155
+ function asDidCreateFilesParams(event) {
156
+ return {
157
+ files: event.files.map(function (fileUri) {
158
+ return {
159
+ uri: _uriConverter(fileUri)
160
+ };
161
+ })
162
+ };
163
+ }
164
+ function asDidRenameFilesParams(event) {
165
+ return {
166
+ files: event.files.map(function (file) {
167
+ return {
168
+ oldUri: _uriConverter(file.oldUri),
169
+ newUri: _uriConverter(file.newUri)
170
+ };
171
+ })
172
+ };
173
+ }
174
+ function asDidDeleteFilesParams(event) {
175
+ return {
176
+ files: event.files.map(function (fileUri) {
177
+ return {
178
+ uri: _uriConverter(fileUri)
179
+ };
180
+ })
181
+ };
182
+ }
183
+ function asWillCreateFilesParams(event) {
184
+ return {
185
+ files: event.files.map(function (fileUri) {
186
+ return {
187
+ uri: _uriConverter(fileUri)
188
+ };
189
+ })
190
+ };
191
+ }
192
+ function asWillRenameFilesParams(event) {
193
+ return {
194
+ files: event.files.map(function (file) {
195
+ return {
196
+ oldUri: _uriConverter(file.oldUri),
197
+ newUri: _uriConverter(file.newUri)
198
+ };
199
+ })
200
+ };
201
+ }
202
+ function asWillDeleteFilesParams(event) {
203
+ return {
204
+ files: event.files.map(function (fileUri) {
205
+ return {
206
+ uri: _uriConverter(fileUri)
207
+ };
208
+ })
209
+ };
210
+ }
211
+ function asTextDocumentPositionParams(textDocument, position) {
212
+ return {
213
+ textDocument: asTextDocumentIdentifier(textDocument),
214
+ position: asWorkerPosition(position)
215
+ };
216
+ }
217
+ function asCompletionTriggerKind(triggerKind) {
218
+ switch (triggerKind) {
219
+ case CompletionTriggerKind.TriggerCharacter:
220
+ return proto.CompletionTriggerKind.TriggerCharacter;
221
+ case CompletionTriggerKind.TriggerForIncompleteCompletions:
222
+ return proto.CompletionTriggerKind.TriggerForIncompleteCompletions;
223
+ default:
224
+ return proto.CompletionTriggerKind.Invoked;
225
+ }
226
+ }
227
+ function asCompletionParams(textDocument, position, context) {
228
+ return {
229
+ textDocument: asTextDocumentIdentifier(textDocument),
230
+ position: asWorkerPosition(position),
231
+ context: {
232
+ triggerKind: asCompletionTriggerKind(context.triggerKind),
233
+ triggerCharacter: context.triggerCharacter
234
+ }
235
+ };
236
+ }
237
+ function asSignatureHelpTriggerKind(triggerKind) {
238
+ switch (triggerKind) {
239
+ case SignatureHelpTriggerKind.Invoke:
240
+ return proto.SignatureHelpTriggerKind.Invoked;
241
+ case SignatureHelpTriggerKind.TriggerCharacter:
242
+ return proto.SignatureHelpTriggerKind.TriggerCharacter;
243
+ case SignatureHelpTriggerKind.ContentChange:
244
+ return proto.SignatureHelpTriggerKind.ContentChange;
245
+ }
246
+ }
247
+ function asParameterInformation(value) {
248
+ // We leave the documentation out on purpose since it usually adds no
249
+ // value for the server.
250
+ return {
251
+ label: value.label
252
+ };
253
+ }
254
+ function asParameterInformations(values) {
255
+ return values.map(asParameterInformation);
256
+ }
257
+ function asSignatureInformation(value) {
258
+ // We leave the documentation out on purpose since it usually adds no
259
+ // value for the server.
260
+ return {
261
+ label: value.label,
262
+ parameters: asParameterInformations(value.parameters)
263
+ };
264
+ }
265
+ function asSignatureInformations(values) {
266
+ return values.map(asSignatureInformation);
267
+ }
268
+ function asSignatureHelp(value) {
269
+ if (value === undefined) {
270
+ return value;
271
+ }
272
+ return {
273
+ signatures: asSignatureInformations(value.signatures),
274
+ activeSignature: value.activeSignature,
275
+ activeParameter: value.activeParameter
276
+ };
277
+ }
278
+ function asSignatureHelpParams(textDocument, position, context) {
279
+ return {
280
+ textDocument: asTextDocumentIdentifier(textDocument),
281
+ position: asWorkerPosition(position),
282
+ context: {
283
+ isRetrigger: context.isRetrigger,
284
+ triggerCharacter: context.triggerCharacter,
285
+ triggerKind: asSignatureHelpTriggerKind(context.triggerKind),
286
+ activeSignatureHelp: asSignatureHelp(context.activeSignatureHelp)
287
+ }
288
+ };
289
+ }
290
+ function asWorkerPosition(position) {
291
+ return {
292
+ line: position.line,
293
+ character: position.character
294
+ };
295
+ }
296
+ function asPosition(value) {
297
+ if (value === undefined || value === null) {
298
+ return value;
299
+ }
300
+ return {
301
+ line: value.line > proto.uinteger.MAX_VALUE ? proto.uinteger.MAX_VALUE : value.line,
302
+ character: value.character > proto.uinteger.MAX_VALUE ? proto.uinteger.MAX_VALUE : value.character
303
+ };
304
+ }
305
+ function asPositions(values, token) {
306
+ return async.map(values, asPosition, token);
307
+ }
308
+ function asPositionsSync(values) {
309
+ return values.map(asPosition);
310
+ }
311
+ function asRange(value) {
312
+ if (value === undefined || value === null) {
313
+ return value;
314
+ }
315
+ return {
316
+ start: asPosition(value.start),
317
+ end: asPosition(value.end)
318
+ };
319
+ }
320
+ function asRanges(values) {
321
+ return values.map(asRange);
322
+ }
323
+ function asLocation(value) {
324
+ if (value === undefined || value === null) {
325
+ return value;
326
+ }
327
+ return proto.Location.create(asUri(value.uri), asRange(value.range));
328
+ }
329
+ function asDiagnosticSeverity(value) {
330
+ switch (value) {
331
+ case DiagnosticSeverity.Error:
332
+ return proto.DiagnosticSeverity.Error;
333
+ case DiagnosticSeverity.Warning:
334
+ return proto.DiagnosticSeverity.Warning;
335
+ case DiagnosticSeverity.Information:
336
+ return proto.DiagnosticSeverity.Information;
337
+ case DiagnosticSeverity.Hint:
338
+ return proto.DiagnosticSeverity.Hint;
339
+ }
340
+ }
341
+ function asDiagnosticTags(tags) {
342
+ if (!tags) {
343
+ return undefined;
344
+ }
345
+ var result = [];
346
+ var _iterator = _createForOfIteratorHelper(tags),
347
+ _step;
348
+ try {
349
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
350
+ var tag = _step.value;
351
+ var converted = asDiagnosticTag(tag);
352
+ if (converted !== undefined) {
353
+ result.push(converted);
354
+ }
355
+ }
356
+ } catch (err) {
357
+ _iterator.e(err);
358
+ } finally {
359
+ _iterator.f();
360
+ }
361
+ return result.length > 0 ? result : undefined;
362
+ }
363
+ function asDiagnosticTag(tag) {
364
+ switch (tag) {
365
+ case DiagnosticTag.Unnecessary:
366
+ return proto.DiagnosticTag.Unnecessary;
367
+ case DiagnosticTag.Deprecated:
368
+ return proto.DiagnosticTag.Deprecated;
369
+ default:
370
+ return undefined;
371
+ }
372
+ }
373
+ function asRelatedInformation(item) {
374
+ return {
375
+ message: item.message,
376
+ location: asLocation(item.location)
377
+ };
378
+ }
379
+ function asRelatedInformations(items) {
380
+ return items.map(asRelatedInformation);
381
+ }
382
+ function asDiagnosticCode(value) {
383
+ if (value === undefined || value === null) {
384
+ return undefined;
385
+ }
386
+ if (Is.number(value) || Is.string(value)) {
387
+ return value;
388
+ }
389
+ return {
390
+ value: value.value,
391
+ target: asUri(value.target)
392
+ };
393
+ }
394
+ function asDiagnostic(item) {
395
+ var result = proto.Diagnostic.create(asRange(item.range), item.message);
396
+ var protocolDiagnostic = item instanceof ProtocolDiagnostic ? item : undefined;
397
+ if (protocolDiagnostic !== undefined && protocolDiagnostic.data !== undefined) {
398
+ result.data = protocolDiagnostic.data;
399
+ }
400
+ var code = asDiagnosticCode(item.code);
401
+ if (DiagnosticCode.is(code)) {
402
+ if (protocolDiagnostic !== undefined && protocolDiagnostic.hasDiagnosticCode) {
403
+ result.code = code;
404
+ } else {
405
+ result.code = code.value;
406
+ result.codeDescription = {
407
+ href: code.target
408
+ };
409
+ }
410
+ } else {
411
+ result.code = code;
412
+ }
413
+ if (Is.number(item.severity)) {
414
+ result.severity = asDiagnosticSeverity(item.severity);
415
+ }
416
+ if (Array.isArray(item.tags)) {
417
+ result.tags = asDiagnosticTags(item.tags);
418
+ }
419
+ if (item.relatedInformation) {
420
+ result.relatedInformation = asRelatedInformations(item.relatedInformation);
421
+ }
422
+ if (item.source) {
423
+ result.source = item.source;
424
+ }
425
+ return result;
426
+ }
427
+ function asDiagnostics(items, token) {
428
+ if (items === undefined || items === null) {
429
+ return items;
430
+ }
431
+ return async.map(items, asDiagnostic, token);
432
+ }
433
+ function asDiagnosticsSync(items) {
434
+ if (items === undefined || items === null) {
435
+ return items;
436
+ }
437
+ return items.map(asDiagnostic);
438
+ }
439
+ function asDocumentation(format, documentation) {
440
+ switch (format) {
441
+ case '$string':
442
+ return documentation;
443
+ case proto.MarkupKind.PlainText:
444
+ return {
445
+ kind: format,
446
+ value: documentation
447
+ };
448
+ case proto.MarkupKind.Markdown:
449
+ return {
450
+ kind: format,
451
+ value: documentation.value
452
+ };
453
+ default:
454
+ return "Unsupported Markup content received. Kind is: ".concat(format);
455
+ }
456
+ }
457
+ function asCompletionItemTag(tag) {
458
+ switch (tag) {
459
+ case CompletionItemTag.Deprecated:
460
+ return proto.CompletionItemTag.Deprecated;
461
+ }
462
+ return undefined;
463
+ }
464
+ function asCompletionItemTags(tags) {
465
+ if (tags === undefined) {
466
+ return tags;
467
+ }
468
+ var result = [];
469
+ var _iterator2 = _createForOfIteratorHelper(tags),
470
+ _step2;
471
+ try {
472
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
473
+ var tag = _step2.value;
474
+ var converted = asCompletionItemTag(tag);
475
+ if (converted !== undefined) {
476
+ result.push(converted);
477
+ }
478
+ }
479
+ } catch (err) {
480
+ _iterator2.e(err);
481
+ } finally {
482
+ _iterator2.f();
483
+ }
484
+ return result;
485
+ }
486
+ function asCompletionItemKind(value, original) {
487
+ if (original !== undefined) {
488
+ return original;
489
+ }
490
+ return value + 1;
491
+ }
492
+ function asCompletionItem(item) {
493
+ var labelDetailsSupport = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
494
+ var label;
495
+ var labelDetails;
496
+ if (Is.string(item.label)) {
497
+ label = item.label;
498
+ } else {
499
+ label = item.label.label;
500
+ if (labelDetailsSupport && (item.label.detail !== undefined || item.label.description !== undefined)) {
501
+ labelDetails = {
502
+ detail: item.label.detail,
503
+ description: item.label.description
504
+ };
505
+ }
506
+ }
507
+ var result = {
508
+ label: label
509
+ };
510
+ if (labelDetails !== undefined) {
511
+ result.labelDetails = labelDetails;
512
+ }
513
+ var protocolItem = item instanceof ProtocolCompletionItem ? item : undefined;
514
+ if (item.detail) {
515
+ result.detail = item.detail;
516
+ }
517
+ // We only send items back we created. So this can't be something else than
518
+ // a string right now.
519
+ if (item.documentation) {
520
+ if (!protocolItem || protocolItem.documentationFormat === '$string') {
521
+ result.documentation = item.documentation;
522
+ } else {
523
+ result.documentation = asDocumentation(protocolItem.documentationFormat, item.documentation);
524
+ }
525
+ }
526
+ if (item.filterText) {
527
+ result.filterText = item.filterText;
528
+ }
529
+ fillPrimaryInsertText(result, item);
530
+ if (Is.number(item.kind)) {
531
+ result.kind = asCompletionItemKind(item.kind, protocolItem && protocolItem.originalItemKind);
532
+ }
533
+ if (item.sortText) {
534
+ result.sortText = item.sortText;
535
+ }
536
+ if (item.additionalTextEdits) {
537
+ result.additionalTextEdits = asTextEdits(item.additionalTextEdits);
538
+ }
539
+ if (item.commitCharacters) {
540
+ result.commitCharacters = item.commitCharacters.slice();
541
+ }
542
+ if (item.command) {
543
+ result.command = asCommand(item.command);
544
+ }
545
+ if (item.preselect === true || item.preselect === false) {
546
+ result.preselect = item.preselect;
547
+ }
548
+ var tags = asCompletionItemTags(item.tags);
549
+ if (protocolItem) {
550
+ if (protocolItem.data !== undefined) {
551
+ result.data = protocolItem.data;
552
+ }
553
+ if (protocolItem.deprecated === true || protocolItem.deprecated === false) {
554
+ if (protocolItem.deprecated === true && tags !== undefined && tags.length > 0) {
555
+ var index = tags.indexOf(CompletionItemTag.Deprecated);
556
+ if (index !== -1) {
557
+ tags.splice(index, 1);
558
+ }
559
+ }
560
+ result.deprecated = protocolItem.deprecated;
561
+ }
562
+ if (protocolItem.insertTextMode !== undefined) {
563
+ result.insertTextMode = protocolItem.insertTextMode;
564
+ }
565
+ }
566
+ if (tags !== undefined && tags.length > 0) {
567
+ result.tags = tags;
568
+ }
569
+ if (result.insertTextMode === undefined && item.keepWhitespace === true) {
570
+ result.insertTextMode = proto.InsertTextMode.adjustIndentation;
571
+ }
572
+ return result;
573
+ }
574
+ function fillPrimaryInsertText(target, source) {
575
+ var format = proto.InsertTextFormat.PlainText;
576
+ var text = undefined;
577
+ var range = undefined;
578
+ if (source.textEdit) {
579
+ text = source.textEdit.newText;
580
+ range = source.textEdit.range;
581
+ } else if (source.insertText instanceof SnippetString) {
582
+ format = proto.InsertTextFormat.Snippet;
583
+ text = source.insertText.value;
584
+ } else {
585
+ text = source.insertText;
586
+ }
587
+ if (source.range) {
588
+ range = source.range;
589
+ }
590
+ target.insertTextFormat = format;
591
+ if (source.fromEdit && text !== undefined && range !== undefined) {
592
+ target.textEdit = asCompletionTextEdit(text, range);
593
+ } else {
594
+ target.insertText = text;
595
+ }
596
+ }
597
+ function asCompletionTextEdit(newText, range) {
598
+ if (InsertReplaceRange.is(range)) {
599
+ return proto.InsertReplaceEdit.create(newText, asRange(range.inserting), asRange(range.replacing));
600
+ } else {
601
+ return {
602
+ newText: newText,
603
+ range: asRange(range)
604
+ };
605
+ }
606
+ }
607
+ function asTextEdit(edit) {
608
+ return {
609
+ range: asRange(edit.range),
610
+ newText: edit.newText
611
+ };
612
+ }
613
+ function asTextEdits(edits) {
614
+ if (edits === undefined || edits === null) {
615
+ return edits;
616
+ }
617
+ return edits.map(asTextEdit);
618
+ }
619
+ function asSymbolKind(item) {
620
+ if (item <= SymbolKind.TypeParameter) {
621
+ // Symbol kind is one based in the protocol and zero based in
622
+ return item + 1;
623
+ }
624
+ return proto.SymbolKind.Property;
625
+ }
626
+ function asSymbolTag(item) {
627
+ return item;
628
+ }
629
+ function asSymbolTags(items) {
630
+ return items.map(asSymbolTag);
631
+ }
632
+ function asReferenceParams(textDocument, position, options) {
633
+ return {
634
+ textDocument: asTextDocumentIdentifier(textDocument),
635
+ position: asWorkerPosition(position),
636
+ context: {
637
+ includeDeclaration: options.includeDeclaration
638
+ }
639
+ };
640
+ }
641
+ function asCodeAction(_x, _x2) {
642
+ return _asCodeAction.apply(this, arguments);
643
+ }
644
+ function _asCodeAction() {
645
+ _asCodeAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(item, token) {
646
+ var result;
647
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
648
+ while (1) switch (_context.prev = _context.next) {
649
+ case 0:
650
+ result = proto.CodeAction.create(item.title);
651
+ if (item instanceof ProtocolCodeAction && item.data !== undefined) {
652
+ result.data = item.data;
653
+ }
654
+ if (item.kind !== undefined) {
655
+ result.kind = asCodeActionKind(item.kind);
656
+ }
657
+ if (!(item.diagnostics !== undefined)) {
658
+ _context.next = 7;
659
+ break;
660
+ }
661
+ _context.next = 6;
662
+ return asDiagnostics(item.diagnostics, token);
663
+ case 6:
664
+ result.diagnostics = _context.sent;
665
+ case 7:
666
+ if (!(item.edit !== undefined)) {
667
+ _context.next = 9;
668
+ break;
669
+ }
670
+ throw new Error("VS Code code actions can only be converted to a protocol code action without an edit.");
671
+ case 9:
672
+ if (item.command !== undefined) {
673
+ result.command = asCommand(item.command);
674
+ }
675
+ if (item.isPreferred !== undefined) {
676
+ result.isPreferred = item.isPreferred;
677
+ }
678
+ if (item.disabled !== undefined) {
679
+ result.disabled = {
680
+ reason: item.disabled.reason
681
+ };
682
+ }
683
+ return _context.abrupt("return", result);
684
+ case 13:
685
+ case "end":
686
+ return _context.stop();
687
+ }
688
+ }, _callee);
689
+ }));
690
+ return _asCodeAction.apply(this, arguments);
691
+ }
692
+ function asCodeActionSync(item) {
693
+ var result = proto.CodeAction.create(item.title);
694
+ if (item instanceof ProtocolCodeAction && item.data !== undefined) {
695
+ result.data = item.data;
696
+ }
697
+ if (item.kind !== undefined) {
698
+ result.kind = asCodeActionKind(item.kind);
699
+ }
700
+ if (item.diagnostics !== undefined) {
701
+ result.diagnostics = asDiagnosticsSync(item.diagnostics);
702
+ }
703
+ if (item.edit !== undefined) {
704
+ throw new Error("VS Code code actions can only be converted to a protocol code action without an edit.");
705
+ }
706
+ if (item.command !== undefined) {
707
+ result.command = asCommand(item.command);
708
+ }
709
+ if (item.isPreferred !== undefined) {
710
+ result.isPreferred = item.isPreferred;
711
+ }
712
+ if (item.disabled !== undefined) {
713
+ result.disabled = {
714
+ reason: item.disabled.reason
715
+ };
716
+ }
717
+ return result;
718
+ }
719
+ function asCodeActionContext(_x3, _x4) {
720
+ return _asCodeActionContext.apply(this, arguments);
721
+ }
722
+ function _asCodeActionContext() {
723
+ _asCodeActionContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(context, token) {
724
+ var only;
725
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
726
+ while (1) switch (_context2.prev = _context2.next) {
727
+ case 0:
728
+ if (!(context === undefined || context === null)) {
729
+ _context2.next = 2;
730
+ break;
731
+ }
732
+ return _context2.abrupt("return", context);
733
+ case 2:
734
+ if (context.only && Is.string(context.only.value)) {
735
+ only = [context.only.value];
736
+ }
737
+ _context2.t0 = proto.CodeActionContext;
738
+ _context2.next = 6;
739
+ return asDiagnostics(context.diagnostics, token);
740
+ case 6:
741
+ _context2.t1 = _context2.sent;
742
+ _context2.t2 = only;
743
+ _context2.t3 = asCodeActionTriggerKind(context.triggerKind);
744
+ return _context2.abrupt("return", _context2.t0.create.call(_context2.t0, _context2.t1, _context2.t2, _context2.t3));
745
+ case 10:
746
+ case "end":
747
+ return _context2.stop();
748
+ }
749
+ }, _callee2);
750
+ }));
751
+ return _asCodeActionContext.apply(this, arguments);
752
+ }
753
+ function asCodeActionContextSync(context) {
754
+ if (context === undefined || context === null) {
755
+ return context;
756
+ }
757
+ var only;
758
+ if (context.only && Is.string(context.only.value)) {
759
+ only = [context.only.value];
760
+ }
761
+ return proto.CodeActionContext.create(asDiagnosticsSync(context.diagnostics), only, asCodeActionTriggerKind(context.triggerKind));
762
+ }
763
+ function asCodeActionTriggerKind(kind) {
764
+ switch (kind) {
765
+ case CodeActionTriggerKind.Invoke:
766
+ return proto.CodeActionTriggerKind.Invoked;
767
+ case CodeActionTriggerKind.Automatic:
768
+ return proto.CodeActionTriggerKind.Automatic;
769
+ default:
770
+ return undefined;
771
+ }
772
+ }
773
+ function asCodeActionKind(item) {
774
+ if (item === undefined || item === null) {
775
+ return undefined;
776
+ }
777
+ return item.value;
778
+ }
779
+ function asInlineValueContext(context) {
780
+ return proto.InlineValueContext.create(context.frameId, asRange(context.stoppedLocation));
781
+ }
782
+ function asInlineCompletionParams(document, position, context) {
783
+ return {
784
+ textDocument: asTextDocumentIdentifier(document),
785
+ position: asPosition(position),
786
+ context: asInlineCompletionContext(context)
787
+ };
788
+ }
789
+ function asInlineCompletionContext(context) {
790
+ return {
791
+ triggerKind: asInlineCompletionTriggerKind(context.triggerKind),
792
+ selectedCompletionInfo: asSelectedCompletionInfo(context.selectedCompletionInfo)
793
+ };
794
+ }
795
+ function asInlineCompletionTriggerKind(kind) {
796
+ switch (kind) {
797
+ case InlineCompletionTriggerKind.Invoke:
798
+ return proto.InlineCompletionTriggerKind.Invoked;
799
+ case InlineCompletionTriggerKind.Automatic:
800
+ return proto.InlineCompletionTriggerKind.Automatic;
801
+ }
802
+ }
803
+ function asSelectedCompletionInfo(info) {
804
+ if (info === undefined || info === null) {
805
+ return undefined;
806
+ }
807
+ return {
808
+ range: asRange(info.range),
809
+ text: info.text
810
+ };
811
+ }
812
+ function asCommand(item) {
813
+ var result = proto.Command.create(item.title, item.command);
814
+ if (item.tooltip) {
815
+ result.tooltip = item.tooltip;
816
+ }
817
+ if (item.arguments) {
818
+ result.arguments = item.arguments;
819
+ }
820
+ return result;
821
+ }
822
+ function asCodeLens(item) {
823
+ var result = proto.CodeLens.create(asRange(item.range));
824
+ if (item.command) {
825
+ result.command = asCommand(item.command);
826
+ }
827
+ if (item instanceof ProtocolCodeLens) {
828
+ if (item.data) {
829
+ result.data = item.data;
830
+ }
831
+ }
832
+ return result;
833
+ }
834
+ function asFormattingOptions(options, fileOptions) {
835
+ var result = {
836
+ tabSize: options.tabSize,
837
+ insertSpaces: options.insertSpaces
838
+ };
839
+ if (fileOptions.trimTrailingWhitespace) {
840
+ result.trimTrailingWhitespace = true;
841
+ }
842
+ if (fileOptions.trimFinalNewlines) {
843
+ result.trimFinalNewlines = true;
844
+ }
845
+ if (fileOptions.insertFinalNewline) {
846
+ result.insertFinalNewline = true;
847
+ }
848
+ return result;
849
+ }
850
+ function asDocumentSymbolParams(textDocument) {
851
+ return {
852
+ textDocument: asTextDocumentIdentifier(textDocument)
853
+ };
854
+ }
855
+ function asCodeLensParams(textDocument) {
856
+ return {
857
+ textDocument: asTextDocumentIdentifier(textDocument)
858
+ };
859
+ }
860
+ function asDocumentLink(item) {
861
+ var result = proto.DocumentLink.create(asRange(item.range));
862
+ if (item.target) {
863
+ result.target = asUri(item.target);
864
+ }
865
+ if (item.tooltip !== undefined) {
866
+ result.tooltip = item.tooltip;
867
+ }
868
+ var protocolItem = item instanceof ProtocolDocumentLink ? item : undefined;
869
+ if (protocolItem && protocolItem.data) {
870
+ result.data = protocolItem.data;
871
+ }
872
+ return result;
873
+ }
874
+ function asDocumentLinkParams(textDocument) {
875
+ return {
876
+ textDocument: asTextDocumentIdentifier(textDocument)
877
+ };
878
+ }
879
+ function asCallHierarchyItem(value) {
880
+ var result = {
881
+ name: value.name,
882
+ kind: asSymbolKind(value.kind),
883
+ uri: asUri(value.uri),
884
+ range: asRange(value.range),
885
+ selectionRange: asRange(value.selectionRange)
886
+ };
887
+ if (value.detail !== undefined && value.detail.length > 0) {
888
+ result.detail = value.detail;
889
+ }
890
+ if (value.tags !== undefined) {
891
+ result.tags = asSymbolTags(value.tags);
892
+ }
893
+ if (value instanceof ProtocolCallHierarchyItem && value.data !== undefined) {
894
+ result.data = value.data;
895
+ }
896
+ return result;
897
+ }
898
+ function asTypeHierarchyItem(value) {
899
+ var result = {
900
+ name: value.name,
901
+ kind: asSymbolKind(value.kind),
902
+ uri: asUri(value.uri),
903
+ range: asRange(value.range),
904
+ selectionRange: asRange(value.selectionRange)
905
+ };
906
+ if (value.detail !== undefined && value.detail.length > 0) {
907
+ result.detail = value.detail;
908
+ }
909
+ if (value.tags !== undefined) {
910
+ result.tags = asSymbolTags(value.tags);
911
+ }
912
+ if (value instanceof ProtocolTypeHierarchyItem && value.data !== undefined) {
913
+ result.data = value.data;
914
+ }
915
+ return result;
916
+ }
917
+ function asWorkspaceSymbol(item) {
918
+ var result = item instanceof WorkspaceSymbol ? {
919
+ name: item.name,
920
+ kind: asSymbolKind(item.kind),
921
+ location: item.hasRange ? asLocation(item.location) : {
922
+ uri: _uriConverter(item.location.uri)
923
+ },
924
+ data: item.data
925
+ } : {
926
+ name: item.name,
927
+ kind: asSymbolKind(item.kind),
928
+ location: asLocation(item.location)
929
+ };
930
+ if (item.tags !== undefined) {
931
+ result.tags = asSymbolTags(item.tags);
932
+ }
933
+ if (item.containerName !== '') {
934
+ result.containerName = item.containerName;
935
+ }
936
+ return result;
937
+ }
938
+ function asInlayHint(item) {
939
+ var label = typeof item.label === 'string' ? item.label : item.label.map(asInlayHintLabelPart);
940
+ var result = proto.InlayHint.create(asPosition(item.position), label);
941
+ if (item.kind !== undefined) {
942
+ result.kind = item.kind;
943
+ }
944
+ if (item.textEdits !== undefined) {
945
+ result.textEdits = asTextEdits(item.textEdits);
946
+ }
947
+ if (item.tooltip !== undefined) {
948
+ result.tooltip = asTooltip(item.tooltip);
949
+ }
950
+ if (item.paddingLeft !== undefined) {
951
+ result.paddingLeft = item.paddingLeft;
952
+ }
953
+ if (item.paddingRight !== undefined) {
954
+ result.paddingRight = item.paddingRight;
955
+ }
956
+ if (item instanceof ProtocolInlayHint && item.data !== undefined) {
957
+ result.data = item.data;
958
+ }
959
+ return result;
960
+ }
961
+ function asInlayHintLabelPart(item) {
962
+ var result = proto.InlayHintLabelPart.create(item.value);
963
+ if (item.location !== undefined) {
964
+ result.location = asLocation(item.location);
965
+ }
966
+ if (item.command !== undefined) {
967
+ result.command = asCommand(item.command);
968
+ }
969
+ if (item.tooltip !== undefined) {
970
+ result.tooltip = asTooltip(item.tooltip);
971
+ }
972
+ return result;
973
+ }
974
+ function asTooltip(value) {
975
+ if (typeof value === 'string') {
976
+ return value;
977
+ }
978
+ var result = {
979
+ kind: proto.MarkupKind.Markdown,
980
+ value: value.value
981
+ };
982
+ return result;
983
+ }
984
+ return {
985
+ asUri: asUri,
986
+ asTextDocumentIdentifier: asTextDocumentIdentifier,
987
+ asTextDocumentItem: asTextDocumentItem,
988
+ asVersionedTextDocumentIdentifier: asVersionedTextDocumentIdentifier,
989
+ asOpenTextDocumentParams: asOpenTextDocumentParams,
990
+ asChangeTextDocumentParams: asChangeTextDocumentParams,
991
+ asCloseTextDocumentParams: asCloseTextDocumentParams,
992
+ asSaveTextDocumentParams: asSaveTextDocumentParams,
993
+ asWillSaveTextDocumentParams: asWillSaveTextDocumentParams,
994
+ asDidCreateFilesParams: asDidCreateFilesParams,
995
+ asDidRenameFilesParams: asDidRenameFilesParams,
996
+ asDidDeleteFilesParams: asDidDeleteFilesParams,
997
+ asWillCreateFilesParams: asWillCreateFilesParams,
998
+ asWillRenameFilesParams: asWillRenameFilesParams,
999
+ asWillDeleteFilesParams: asWillDeleteFilesParams,
1000
+ asTextDocumentPositionParams: asTextDocumentPositionParams,
1001
+ asCompletionParams: asCompletionParams,
1002
+ asSignatureHelpParams: asSignatureHelpParams,
1003
+ asWorkerPosition: asWorkerPosition,
1004
+ asRange: asRange,
1005
+ asRanges: asRanges,
1006
+ asPosition: asPosition,
1007
+ asPositions: asPositions,
1008
+ asPositionsSync: asPositionsSync,
1009
+ asLocation: asLocation,
1010
+ asDiagnosticSeverity: asDiagnosticSeverity,
1011
+ asDiagnosticTag: asDiagnosticTag,
1012
+ asDiagnostic: asDiagnostic,
1013
+ asDiagnostics: asDiagnostics,
1014
+ asDiagnosticsSync: asDiagnosticsSync,
1015
+ asCompletionItem: asCompletionItem,
1016
+ asTextEdit: asTextEdit,
1017
+ asSymbolKind: asSymbolKind,
1018
+ asSymbolTag: asSymbolTag,
1019
+ asSymbolTags: asSymbolTags,
1020
+ asReferenceParams: asReferenceParams,
1021
+ asCodeAction: asCodeAction,
1022
+ asCodeActionSync: asCodeActionSync,
1023
+ asCodeActionContext: asCodeActionContext,
1024
+ asCodeActionContextSync: asCodeActionContextSync,
1025
+ asInlineValueContext: asInlineValueContext,
1026
+ asCommand: asCommand,
1027
+ asCodeLens: asCodeLens,
1028
+ asFormattingOptions: asFormattingOptions,
1029
+ asDocumentSymbolParams: asDocumentSymbolParams,
1030
+ asCodeLensParams: asCodeLensParams,
1031
+ asDocumentLink: asDocumentLink,
1032
+ asDocumentLinkParams: asDocumentLinkParams,
1033
+ asCallHierarchyItem: asCallHierarchyItem,
1034
+ asTypeHierarchyItem: asTypeHierarchyItem,
1035
+ asInlayHint: asInlayHint,
1036
+ asWorkspaceSymbol: asWorkspaceSymbol,
1037
+ asInlineCompletionParams: asInlineCompletionParams,
1038
+ asInlineCompletionContext: asInlineCompletionContext
1039
+ };
1040
+ }