@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,1613 @@
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
5
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
6
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
10
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
+ 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); }
12
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
13
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
14
+ 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; }
15
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16
+ 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); } }
17
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
19
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
+ /* eslint-disable @typescript-eslint/no-empty-function */
21
+ /* eslint-disable @typescript-eslint/ban-types */
22
+ /* --------------------------------------------------------------------------------------------
23
+ * Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
24
+ * Licensed under the MIT License. See License.txt in the project root for license information.
25
+ * ------------------------------------------------------------------------------------------ */
26
+
27
+ import * as ls from '@difizen/vscode-languageserver-protocol';
28
+ import { CompletionTriggerKind, InsertTextFormat, Diagnostic, CompletionItemKind, LocationLink, DocumentHighlightKind, CodeActionContext, DiagnosticSeverity, Command, CodeLens, DocumentLink, MarkupContent, FoldingRangeKind, MarkupKind, SymbolKind, DocumentSymbol, SignatureHelpTriggerKind, AnnotatedTextEdit, InlayHint } from '@difizen/vscode-languageserver-protocol';
29
+ import * as Is from "./hostTypeUtil.js";
30
+ export var ProtocolDocumentLink;
31
+ (function (_ProtocolDocumentLink) {
32
+ function is(item) {
33
+ return !!item && 'data' in item;
34
+ }
35
+ _ProtocolDocumentLink.is = is;
36
+ })(ProtocolDocumentLink || (ProtocolDocumentLink = {}));
37
+ export var ProtocolCodeLens;
38
+ (function (_ProtocolCodeLens) {
39
+ function is(item) {
40
+ return !!item && 'data' in item;
41
+ }
42
+ _ProtocolCodeLens.is = is;
43
+ })(ProtocolCodeLens || (ProtocolCodeLens = {}));
44
+ export var ProtocolCompletionItem;
45
+ (function (_ProtocolCompletionItem) {
46
+ function is(item) {
47
+ return !!item && 'data' in item;
48
+ }
49
+ _ProtocolCompletionItem.is = is;
50
+ })(ProtocolCompletionItem || (ProtocolCompletionItem = {}));
51
+ export var ProtocolCodeAction;
52
+ (function (_ProtocolCodeAction) {
53
+ function is(item) {
54
+ return !!item && 'data' in item;
55
+ }
56
+ _ProtocolCodeAction.is = is;
57
+ })(ProtocolCodeAction || (ProtocolCodeAction = {}));
58
+ export var ProtocolInlayHint;
59
+ (function (_ProtocolInlayHint) {
60
+ function is(item) {
61
+ return !!item && 'data' in item;
62
+ }
63
+ _ProtocolInlayHint.is = is;
64
+ })(ProtocolInlayHint || (ProtocolInlayHint = {}));
65
+ function isRangeReplace(v) {
66
+ return v.insert !== undefined;
67
+ }
68
+ export var MonacoToProtocolConverter = /*#__PURE__*/function () {
69
+ function MonacoToProtocolConverter(_monaco) {
70
+ _classCallCheck(this, MonacoToProtocolConverter);
71
+ this._monaco = _monaco;
72
+ }
73
+ _createClass(MonacoToProtocolConverter, [{
74
+ key: "asPosition",
75
+ value: function asPosition(lineNumber, column) {
76
+ var line = lineNumber === undefined || lineNumber === null ? undefined : lineNumber - 1;
77
+ var character = column === undefined || column === null ? undefined : column - 1;
78
+ return {
79
+ line: line,
80
+ character: character
81
+ };
82
+ }
83
+ }, {
84
+ key: "asRange",
85
+ value: function asRange(range) {
86
+ if (range === undefined) {
87
+ return undefined;
88
+ }
89
+ if (range === null) {
90
+ return null;
91
+ }
92
+ if (isRangeReplace(range)) {
93
+ return this.asRange(range.insert);
94
+ } else {
95
+ var start = this.asPosition(range.startLineNumber, range.startColumn);
96
+ var end = this.asPosition(range.endLineNumber, range.endColumn);
97
+ return {
98
+ start: start,
99
+ end: end
100
+ };
101
+ }
102
+ }
103
+ }, {
104
+ key: "asLocation",
105
+ value: function asLocation(item) {
106
+ if (!item) {
107
+ return undefined;
108
+ }
109
+ var uri = item.uri.toString();
110
+ var range = this.asRange(item.range);
111
+ return {
112
+ uri: uri,
113
+ range: range
114
+ };
115
+ }
116
+ }, {
117
+ key: "asTextDocumentIdentifier",
118
+ value: function asTextDocumentIdentifier(model) {
119
+ return {
120
+ uri: model.uri.toString()
121
+ };
122
+ }
123
+ }, {
124
+ key: "asTextDocumentPositionParams",
125
+ value: function asTextDocumentPositionParams(model, position) {
126
+ return {
127
+ textDocument: this.asTextDocumentIdentifier(model),
128
+ position: this.asPosition(position.lineNumber, position.column)
129
+ };
130
+ }
131
+ }, {
132
+ key: "asCompletionParams",
133
+ value: function asCompletionParams(model, position, context) {
134
+ return Object.assign(this.asTextDocumentPositionParams(model, position), {
135
+ context: this.asCompletionContext(context)
136
+ });
137
+ }
138
+ }, {
139
+ key: "asCompletionContext",
140
+ value: function asCompletionContext(context) {
141
+ return {
142
+ triggerKind: this.asCompletionTriggerKind(context.triggerKind),
143
+ triggerCharacter: context.triggerCharacter
144
+ };
145
+ }
146
+ }, {
147
+ key: "asSignatureHelpContext",
148
+ value: function asSignatureHelpContext(context) {
149
+ return {
150
+ triggerKind: this.asSignatureHelpTriggerKind(context.triggerKind),
151
+ triggerCharacter: context.triggerCharacter,
152
+ isRetrigger: context.isRetrigger,
153
+ activeSignatureHelp: this.asSignatureHelp(context.activeSignatureHelp)
154
+ };
155
+ }
156
+ }, {
157
+ key: "asSignatureHelp",
158
+ value: function asSignatureHelp(signatureHelp) {
159
+ var _this = this;
160
+ if (signatureHelp === undefined) {
161
+ return undefined;
162
+ }
163
+ return {
164
+ signatures: signatureHelp.signatures.map(function (signatureInfo) {
165
+ return _this.asSignatureInformation(signatureInfo);
166
+ }),
167
+ activeParameter: signatureHelp.activeParameter,
168
+ activeSignature: signatureHelp.activeSignature
169
+ };
170
+ }
171
+ }, {
172
+ key: "asSignatureInformation",
173
+ value: function asSignatureInformation(signatureInformation) {
174
+ var _this2 = this;
175
+ return {
176
+ documentation: this.asMarkupContent(signatureInformation.documentation),
177
+ label: signatureInformation.label,
178
+ parameters: signatureInformation.parameters.map(function (paramInfo) {
179
+ return _this2.asParameterInformation(paramInfo);
180
+ }),
181
+ activeParameter: signatureInformation.activeParameter
182
+ };
183
+ }
184
+ }, {
185
+ key: "asParameterInformation",
186
+ value: function asParameterInformation(parameterInformation) {
187
+ return {
188
+ documentation: this.asMarkupContent(parameterInformation.documentation),
189
+ label: parameterInformation.label
190
+ };
191
+ }
192
+ }, {
193
+ key: "asMarkupContent",
194
+ value: function asMarkupContent(markupContent) {
195
+ if (markupContent === undefined) {
196
+ return undefined;
197
+ }
198
+ if (typeof markupContent === 'string') {
199
+ return markupContent;
200
+ }
201
+ return {
202
+ kind: MarkupKind.Markdown,
203
+ value: markupContent.value
204
+ };
205
+ }
206
+ }, {
207
+ key: "asSignatureHelpTriggerKind",
208
+ value: function asSignatureHelpTriggerKind(triggerKind) {
209
+ switch (triggerKind) {
210
+ case this._monaco.languages.SignatureHelpTriggerKind.ContentChange:
211
+ return SignatureHelpTriggerKind.ContentChange;
212
+ case this._monaco.languages.SignatureHelpTriggerKind.TriggerCharacter:
213
+ return SignatureHelpTriggerKind.TriggerCharacter;
214
+ default:
215
+ return SignatureHelpTriggerKind.Invoked;
216
+ }
217
+ }
218
+ }, {
219
+ key: "asCompletionTriggerKind",
220
+ value: function asCompletionTriggerKind(triggerKind) {
221
+ switch (triggerKind) {
222
+ case this._monaco.languages.CompletionTriggerKind.TriggerCharacter:
223
+ return CompletionTriggerKind.TriggerCharacter;
224
+ case this._monaco.languages.CompletionTriggerKind.TriggerForIncompleteCompletions:
225
+ return CompletionTriggerKind.TriggerForIncompleteCompletions;
226
+ default:
227
+ return CompletionTriggerKind.Invoked;
228
+ }
229
+ }
230
+ }, {
231
+ key: "asCompletionItem",
232
+ value: function asCompletionItem(item) {
233
+ var result = {
234
+ label: item.label
235
+ };
236
+ var protocolItem = ProtocolCompletionItem.is(item) ? item : undefined;
237
+ if (item.detail) {
238
+ result.detail = item.detail;
239
+ }
240
+ if (item.documentation) {
241
+ if (typeof item.documentation === 'string') {
242
+ result.documentation = item.documentation;
243
+ } else {
244
+ var _protocolItem$documen;
245
+ result.documentation = this.asDocumentation((_protocolItem$documen = protocolItem === null || protocolItem === void 0 ? void 0 : protocolItem.documentationFormat) !== null && _protocolItem$documen !== void 0 ? _protocolItem$documen : MarkupKind.Markdown, item.documentation);
246
+ }
247
+ }
248
+ if (item.filterText) {
249
+ result.filterText = item.filterText;
250
+ }
251
+ this.fillPrimaryInsertText(result, item);
252
+ if (Is.isNumber(item.kind)) {
253
+ result.kind = this.asCompletionItemKind(item.kind, protocolItem && protocolItem.originalItemKind);
254
+ }
255
+ if (item.sortText) {
256
+ result.sortText = item.sortText;
257
+ }
258
+ if (item.additionalTextEdits) {
259
+ result.additionalTextEdits = this.asTextEdits(item.additionalTextEdits);
260
+ }
261
+ if (item.command) {
262
+ result.command = this.asCommand(item.command);
263
+ }
264
+ if (item.commitCharacters) {
265
+ result.commitCharacters = item.commitCharacters.slice();
266
+ }
267
+ if (item.command) {
268
+ result.command = this.asCommand(item.command);
269
+ }
270
+ if (item.preselect === true || item.preselect === false) {
271
+ result.preselect = item.preselect;
272
+ }
273
+ if (protocolItem) {
274
+ if (protocolItem.data !== undefined) {
275
+ result.data = protocolItem.data;
276
+ }
277
+ if (protocolItem.deprecated === true || protocolItem.deprecated === false) {
278
+ result.deprecated = protocolItem.deprecated;
279
+ }
280
+ }
281
+ if (item.tags) {
282
+ var _item$tags;
283
+ result.tags = (_item$tags = item.tags) === null || _item$tags === void 0 ? void 0 : _item$tags.slice();
284
+ }
285
+ return result;
286
+ }
287
+ }, {
288
+ key: "asCompletionItemKind",
289
+ value: function asCompletionItemKind(value, original) {
290
+ if (original !== undefined) {
291
+ return original;
292
+ }
293
+ switch (value) {
294
+ case this._monaco.languages.CompletionItemKind.Method:
295
+ return CompletionItemKind.Method;
296
+ case this._monaco.languages.CompletionItemKind.Function:
297
+ return CompletionItemKind.Function;
298
+ case this._monaco.languages.CompletionItemKind.Constructor:
299
+ return CompletionItemKind.Constructor;
300
+ case this._monaco.languages.CompletionItemKind.Field:
301
+ return CompletionItemKind.Field;
302
+ case this._monaco.languages.CompletionItemKind.Variable:
303
+ return CompletionItemKind.Variable;
304
+ case this._monaco.languages.CompletionItemKind.Class:
305
+ return CompletionItemKind.Class;
306
+ case this._monaco.languages.CompletionItemKind.Struct:
307
+ return CompletionItemKind.Struct;
308
+ case this._monaco.languages.CompletionItemKind.Interface:
309
+ return CompletionItemKind.Interface;
310
+ case this._monaco.languages.CompletionItemKind.Module:
311
+ return CompletionItemKind.Module;
312
+ case this._monaco.languages.CompletionItemKind.Property:
313
+ return CompletionItemKind.Property;
314
+ case this._monaco.languages.CompletionItemKind.Event:
315
+ return CompletionItemKind.Event;
316
+ case this._monaco.languages.CompletionItemKind.Operator:
317
+ return CompletionItemKind.Operator;
318
+ case this._monaco.languages.CompletionItemKind.Unit:
319
+ return CompletionItemKind.Unit;
320
+ case this._monaco.languages.CompletionItemKind.Value:
321
+ return CompletionItemKind.Value;
322
+ case this._monaco.languages.CompletionItemKind.Constant:
323
+ return CompletionItemKind.Constant;
324
+ case this._monaco.languages.CompletionItemKind.Enum:
325
+ return CompletionItemKind.Enum;
326
+ case this._monaco.languages.CompletionItemKind.EnumMember:
327
+ return CompletionItemKind.EnumMember;
328
+ case this._monaco.languages.CompletionItemKind.Keyword:
329
+ return CompletionItemKind.Keyword;
330
+ case this._monaco.languages.CompletionItemKind.Text:
331
+ return CompletionItemKind.Text;
332
+ case this._monaco.languages.CompletionItemKind.Color:
333
+ return CompletionItemKind.Color;
334
+ case this._monaco.languages.CompletionItemKind.File:
335
+ return CompletionItemKind.File;
336
+ case this._monaco.languages.CompletionItemKind.Reference:
337
+ return CompletionItemKind.Reference;
338
+ case this._monaco.languages.CompletionItemKind.Customcolor:
339
+ return CompletionItemKind.Color;
340
+ case this._monaco.languages.CompletionItemKind.Folder:
341
+ return CompletionItemKind.Folder;
342
+ case this._monaco.languages.CompletionItemKind.TypeParameter:
343
+ return CompletionItemKind.TypeParameter;
344
+ case this._monaco.languages.CompletionItemKind.Snippet:
345
+ return CompletionItemKind.Snippet;
346
+ default:
347
+ return value + 1;
348
+ }
349
+ }
350
+ }, {
351
+ key: "asDocumentation",
352
+ value: function asDocumentation(format, documentation) {
353
+ switch (format) {
354
+ case MarkupKind.PlainText:
355
+ return {
356
+ kind: format,
357
+ value: documentation
358
+ };
359
+ case MarkupKind.Markdown:
360
+ return {
361
+ kind: format,
362
+ value: documentation.value
363
+ };
364
+ default:
365
+ return "Unsupported Markup content received. Kind is: ".concat(format);
366
+ }
367
+ }
368
+ }, {
369
+ key: "fillPrimaryInsertText",
370
+ value: function fillPrimaryInsertText(target, source) {
371
+ var format = InsertTextFormat.PlainText;
372
+ var text;
373
+ var range;
374
+ if (source.insertTextRules !== undefined && (source.insertTextRules & this._monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet) === 0) {
375
+ format = InsertTextFormat.Snippet;
376
+ text = source.insertText;
377
+ }
378
+ target.insertTextFormat = format;
379
+ text = source.insertText;
380
+ if (source.range) {
381
+ range = this.asRange(source.range);
382
+ }
383
+ target.insertTextFormat = format;
384
+ if (source.fromEdit && text && range) {
385
+ target.textEdit = {
386
+ newText: text,
387
+ range: range
388
+ };
389
+ } else {
390
+ target.insertText = text;
391
+ }
392
+ target.insertTextMode = source.insertTextMode;
393
+ }
394
+ }, {
395
+ key: "asTextEdit",
396
+ value: function asTextEdit(edit) {
397
+ var range = this.asRange(edit.range);
398
+ return {
399
+ range: range,
400
+ newText: edit.text || ''
401
+ };
402
+ }
403
+ }, {
404
+ key: "asTextEdits",
405
+ value: function asTextEdits(items) {
406
+ var _this3 = this;
407
+ if (!items) {
408
+ return undefined;
409
+ }
410
+ return items.map(function (item) {
411
+ return _this3.asTextEdit(item);
412
+ });
413
+ }
414
+ }, {
415
+ key: "asReferenceParams",
416
+ value: function asReferenceParams(model, position, options) {
417
+ return {
418
+ textDocument: this.asTextDocumentIdentifier(model),
419
+ position: this.asPosition(position.lineNumber, position.column),
420
+ context: {
421
+ includeDeclaration: options.includeDeclaration
422
+ }
423
+ };
424
+ }
425
+ }, {
426
+ key: "asDocumentSymbolParams",
427
+ value: function asDocumentSymbolParams(model) {
428
+ return {
429
+ textDocument: this.asTextDocumentIdentifier(model)
430
+ };
431
+ }
432
+ }, {
433
+ key: "asCodeLensParams",
434
+ value: function asCodeLensParams(model) {
435
+ return {
436
+ textDocument: this.asTextDocumentIdentifier(model)
437
+ };
438
+ }
439
+ }, {
440
+ key: "asDiagnosticSeverity",
441
+ value: function asDiagnosticSeverity(value) {
442
+ switch (value) {
443
+ case this._monaco.MarkerSeverity.Error:
444
+ return DiagnosticSeverity.Error;
445
+ case this._monaco.MarkerSeverity.Warning:
446
+ return DiagnosticSeverity.Warning;
447
+ case this._monaco.MarkerSeverity.Info:
448
+ return DiagnosticSeverity.Information;
449
+ case this._monaco.MarkerSeverity.Hint:
450
+ return DiagnosticSeverity.Hint;
451
+ }
452
+ return undefined;
453
+ }
454
+ }, {
455
+ key: "asDiagnostic",
456
+ value: function asDiagnostic(marker) {
457
+ var range = this.asRange(new this._monaco.Range(marker.startLineNumber, marker.startColumn, marker.endLineNumber, marker.endColumn));
458
+ var severity = this.asDiagnosticSeverity(marker.severity);
459
+ var diag = Diagnostic.create(range, marker.message, severity, marker.code, marker.source);
460
+ return diag;
461
+ }
462
+ }, {
463
+ key: "asDiagnostics",
464
+ value: function asDiagnostics(markers) {
465
+ var _this4 = this;
466
+ if (markers === void 0 || markers === null) {
467
+ return markers;
468
+ }
469
+ return markers.map(function (marker) {
470
+ return _this4.asDiagnostic(marker);
471
+ });
472
+ }
473
+ }, {
474
+ key: "asCodeActionContext",
475
+ value: function asCodeActionContext(context, diagnostics) {
476
+ if (context === void 0 || context === null) {
477
+ return context;
478
+ }
479
+ return CodeActionContext.create(diagnostics, Is.isString(context.only) ? [context.only] : undefined, context.trigger);
480
+ }
481
+ }, {
482
+ key: "asCodeActionParams",
483
+ value: function asCodeActionParams(model, range, context, diagnostics) {
484
+ return {
485
+ textDocument: this.asTextDocumentIdentifier(model),
486
+ range: this.asRange(range),
487
+ context: this.asCodeActionContext(context, diagnostics)
488
+ };
489
+ }
490
+ }, {
491
+ key: "asCommand",
492
+ value: function asCommand(item) {
493
+ if (item) {
494
+ var args = item.arguments || [];
495
+ return Command.create.apply(Command, [item.title, item.id].concat(_toConsumableArray(args)));
496
+ }
497
+ return undefined;
498
+ }
499
+ }, {
500
+ key: "asCodeLens",
501
+ value: function asCodeLens(item) {
502
+ var result = CodeLens.create(this.asRange(item.range));
503
+ if (item.command) {
504
+ result.command = this.asCommand(item.command);
505
+ }
506
+ if (ProtocolCodeLens.is(item)) {
507
+ if (item.data) {
508
+ result.data = item.data;
509
+ }
510
+ }
511
+ return result;
512
+ }
513
+ }, {
514
+ key: "asFormattingOptions",
515
+ value: function asFormattingOptions(options) {
516
+ return {
517
+ tabSize: options.tabSize,
518
+ insertSpaces: options.insertSpaces
519
+ };
520
+ }
521
+ }, {
522
+ key: "asDocumentFormattingParams",
523
+ value: function asDocumentFormattingParams(model, options) {
524
+ return {
525
+ textDocument: this.asTextDocumentIdentifier(model),
526
+ options: this.asFormattingOptions(options)
527
+ };
528
+ }
529
+ }, {
530
+ key: "asDocumentRangeFormattingParams",
531
+ value: function asDocumentRangeFormattingParams(model, range, options) {
532
+ return {
533
+ textDocument: this.asTextDocumentIdentifier(model),
534
+ range: this.asRange(range),
535
+ options: this.asFormattingOptions(options)
536
+ };
537
+ }
538
+ }, {
539
+ key: "asDocumentOnTypeFormattingParams",
540
+ value: function asDocumentOnTypeFormattingParams(model, position, ch, options) {
541
+ return {
542
+ textDocument: this.asTextDocumentIdentifier(model),
543
+ position: this.asPosition(position.lineNumber, position.column),
544
+ ch: ch,
545
+ options: this.asFormattingOptions(options)
546
+ };
547
+ }
548
+ }, {
549
+ key: "asRenameParams",
550
+ value: function asRenameParams(model, position, newName) {
551
+ return {
552
+ textDocument: this.asTextDocumentIdentifier(model),
553
+ position: this.asPosition(position.lineNumber, position.column),
554
+ newName: newName
555
+ };
556
+ }
557
+ }, {
558
+ key: "asDocumentLinkParams",
559
+ value: function asDocumentLinkParams(model) {
560
+ return {
561
+ textDocument: this.asTextDocumentIdentifier(model)
562
+ };
563
+ }
564
+ }, {
565
+ key: "asDocumentLink",
566
+ value: function asDocumentLink(item) {
567
+ var result = DocumentLink.create(this.asRange(item.range));
568
+ if (item.url) {
569
+ result.target = typeof item.url === 'string' ? item.url : item.url.toString();
570
+ }
571
+ if (ProtocolDocumentLink.is(item) && item.data) {
572
+ result.data = item.data;
573
+ }
574
+ if (item.tooltip) {
575
+ result.tooltip = item.tooltip;
576
+ }
577
+ return result;
578
+ }
579
+ }, {
580
+ key: "asCodeAction",
581
+ value: function asCodeAction(item) {
582
+ var result = {
583
+ title: item.title
584
+ };
585
+ var protocolCodeAction = ProtocolCodeAction.is(item) ? item : undefined;
586
+ if (Is.isNumber(item.kind)) {
587
+ result.kind = item.kind;
588
+ }
589
+ if (item.diagnostics) {
590
+ result.diagnostics = this.asDiagnostics(item.diagnostics);
591
+ }
592
+ if (item.edit) {
593
+ throw new Error("VS Code code actions can only be converted to a protocol code action without an edit.");
594
+ }
595
+ if (item.command) {
596
+ result.command = this.asCommand(item.command);
597
+ }
598
+ if (item.isPreferred !== undefined) {
599
+ result.isPreferred = item.isPreferred;
600
+ }
601
+ if (item.disabled) {
602
+ result.disabled = {
603
+ reason: item.disabled
604
+ };
605
+ }
606
+ if (protocolCodeAction) {
607
+ if (protocolCodeAction.data !== undefined) {
608
+ result.data = protocolCodeAction.data;
609
+ }
610
+ }
611
+ return result;
612
+ }
613
+ }, {
614
+ key: "asInlayHintLabelPart",
615
+ value: function asInlayHintLabelPart(part) {
616
+ return {
617
+ value: part.label,
618
+ command: this.asCommand(part.command),
619
+ location: this.asLocation(part.location),
620
+ tooltip: this.asMarkupContent(part.tooltip)
621
+ };
622
+ }
623
+ }, {
624
+ key: "asInlayHintLabel",
625
+ value: function asInlayHintLabel(label) {
626
+ var _this5 = this;
627
+ if (Array.isArray(label)) {
628
+ return label.map(function (part) {
629
+ return _this5.asInlayHintLabelPart(part);
630
+ });
631
+ }
632
+ return label;
633
+ }
634
+ }, {
635
+ key: "asInlayHint",
636
+ value: function asInlayHint(item) {
637
+ var result = InlayHint.create(this.asPosition(item.position.lineNumber, item.position.column), this.asInlayHintLabel(item.label), item.kind);
638
+ if (ProtocolInlayHint.is(item)) {
639
+ if (item.data) {
640
+ result.data = item.data;
641
+ }
642
+ }
643
+ return result;
644
+ }
645
+ }]);
646
+ return MonacoToProtocolConverter;
647
+ }();
648
+ export var ProtocolToMonacoConverter = /*#__PURE__*/function () {
649
+ function ProtocolToMonacoConverter(_monaco) {
650
+ _classCallCheck(this, ProtocolToMonacoConverter);
651
+ this._monaco = _monaco;
652
+ }
653
+ _createClass(ProtocolToMonacoConverter, [{
654
+ key: "asResourceEdits",
655
+ value: function asResourceEdits(resource, edits, asMetadata, modelVersionId) {
656
+ var _this6 = this;
657
+ return edits.map(function (edit) {
658
+ return {
659
+ resource: resource,
660
+ textEdit: _this6.asTextEdit(edit),
661
+ versionId: modelVersionId,
662
+ metadata: AnnotatedTextEdit.is(edit) ? asMetadata(edit.annotationId) : undefined
663
+ };
664
+ });
665
+ }
666
+ }, {
667
+ key: "asWorkspaceEditMetadata",
668
+ value: function asWorkspaceEditMetadata(changeAnnotation) {
669
+ return {
670
+ needsConfirmation: changeAnnotation.needsConfirmation === true,
671
+ label: changeAnnotation.label,
672
+ description: changeAnnotation.description
673
+ };
674
+ }
675
+ }, {
676
+ key: "asWorkspaceEdit",
677
+ value: function asWorkspaceEdit(item) {
678
+ var _this7 = this;
679
+ if (!item) {
680
+ return undefined;
681
+ }
682
+ var sharedMetadata = new Map();
683
+ if (item.changeAnnotations !== undefined) {
684
+ for (var _i = 0, _Object$keys = Object.keys(item.changeAnnotations); _i < _Object$keys.length; _i++) {
685
+ var key = _Object$keys[_i];
686
+ var metaData = this.asWorkspaceEditMetadata(item.changeAnnotations[key]);
687
+ sharedMetadata.set(key, metaData);
688
+ }
689
+ }
690
+ var asMetadata = function asMetadata(annotation) {
691
+ if (annotation === undefined) {
692
+ return undefined;
693
+ } else {
694
+ return sharedMetadata.get(annotation);
695
+ }
696
+ };
697
+ var edits = [];
698
+ if (item.documentChanges) {
699
+ item.documentChanges.forEach(function (change) {
700
+ if (ls.CreateFile.is(change)) {
701
+ edits.push({
702
+ newUri: _this7._monaco.Uri.parse(change.uri),
703
+ options: change.options,
704
+ metadata: asMetadata(change.annotationId)
705
+ });
706
+ } else if (ls.RenameFile.is(change)) {
707
+ edits.push({
708
+ oldUri: _this7._monaco.Uri.parse(change.oldUri),
709
+ newUri: _this7._monaco.Uri.parse(change.newUri),
710
+ options: change.options,
711
+ metadata: asMetadata(change.annotationId)
712
+ });
713
+ } else if (ls.DeleteFile.is(change)) {
714
+ edits.push({
715
+ oldUri: _this7._monaco.Uri.parse(change.uri),
716
+ options: change.options,
717
+ metadata: asMetadata(change.annotationId)
718
+ });
719
+ } else if (ls.TextDocumentEdit.is(change)) {
720
+ var resource = _this7._monaco.Uri.parse(change.textDocument.uri);
721
+ var version = typeof change.textDocument.version === 'number' ? change.textDocument.version : undefined;
722
+ edits.push.apply(edits, _toConsumableArray(_this7.asResourceEdits(resource, change.edits, asMetadata, version)));
723
+ } else {
724
+ console.error("Unknown workspace edit change received:\n".concat(JSON.stringify(change, undefined, 4)));
725
+ }
726
+ });
727
+ } else if (item.changes) {
728
+ for (var _i2 = 0, _Object$keys2 = Object.keys(item.changes); _i2 < _Object$keys2.length; _i2++) {
729
+ var _key = _Object$keys2[_i2];
730
+ var resource = this._monaco.Uri.parse(_key);
731
+ edits.push.apply(edits, _toConsumableArray(this.asResourceEdits(resource, item.changes[_key], asMetadata)));
732
+ }
733
+ }
734
+ return {
735
+ edits: edits
736
+ };
737
+ }
738
+ }, {
739
+ key: "asTextEdit",
740
+ value: function asTextEdit(edit) {
741
+ if (!edit) {
742
+ return undefined;
743
+ }
744
+ var range = this.asRange(edit.range);
745
+ return {
746
+ range: range,
747
+ text: edit.newText
748
+ };
749
+ }
750
+ }, {
751
+ key: "asTextEdits",
752
+ value: function asTextEdits(items) {
753
+ var _this8 = this;
754
+ if (!items) {
755
+ return undefined;
756
+ }
757
+ return items.map(function (item) {
758
+ return _this8.asTextEdit(item);
759
+ });
760
+ }
761
+ }, {
762
+ key: "asCodeLens",
763
+ value: function asCodeLens(item) {
764
+ if (!item) {
765
+ return undefined;
766
+ }
767
+ var range = this.asRange(item.range);
768
+ var result = {
769
+ range: range
770
+ };
771
+ if (item.command) {
772
+ result.command = this.asCommand(item.command);
773
+ }
774
+ if (item.data !== void 0 && item.data !== null) {
775
+ result.data = item.data;
776
+ }
777
+ return result;
778
+ }
779
+ }, {
780
+ key: "asCodeLensList",
781
+ value: function asCodeLensList(items) {
782
+ var _this9 = this;
783
+ if (!items) {
784
+ return undefined;
785
+ }
786
+ return {
787
+ lenses: items.map(function (codeLens) {
788
+ return _this9.asCodeLens(codeLens);
789
+ }),
790
+ dispose: function dispose() {}
791
+ };
792
+ }
793
+ }, {
794
+ key: "asCodeActionList",
795
+ value: function asCodeActionList(actions) {
796
+ var _this10 = this;
797
+ return {
798
+ actions: actions.map(function (action) {
799
+ return _this10.asCodeAction(action);
800
+ }),
801
+ dispose: function dispose() {}
802
+ };
803
+ }
804
+ }, {
805
+ key: "asCodeAction",
806
+ value: function asCodeAction(item) {
807
+ if (Command.is(item)) {
808
+ return {
809
+ command: {
810
+ id: item.command,
811
+ title: item.title,
812
+ arguments: item.arguments
813
+ },
814
+ title: item.title
815
+ };
816
+ }
817
+ return {
818
+ title: item.title,
819
+ command: this.asCommand(item.command),
820
+ edit: this.asWorkspaceEdit(item.edit),
821
+ diagnostics: this.asDiagnostics(item.diagnostics),
822
+ kind: item.kind,
823
+ disabled: item.disabled ? item.disabled.reason : undefined,
824
+ isPreferred: item.isPreferred,
825
+ data: item.data
826
+ };
827
+ }
828
+ }, {
829
+ key: "asCommand",
830
+ value: function asCommand(command) {
831
+ if (!command) {
832
+ return undefined;
833
+ }
834
+ return {
835
+ id: command.command,
836
+ title: command.title,
837
+ arguments: command.arguments
838
+ };
839
+ }
840
+ }, {
841
+ key: "asDocumentSymbol",
842
+ value: function asDocumentSymbol(value) {
843
+ var _this11 = this;
844
+ var children = value.children && value.children.map(function (c) {
845
+ return _this11.asDocumentSymbol(c);
846
+ });
847
+ return {
848
+ name: value.name,
849
+ detail: value.detail || '',
850
+ kind: this.asSymbolKind(value.kind),
851
+ tags: value.tags || [],
852
+ range: this.asRange(value.range),
853
+ selectionRange: this.asRange(value.selectionRange),
854
+ children: children
855
+ };
856
+ }
857
+ }, {
858
+ key: "asDocumentSymbols",
859
+ value: function asDocumentSymbols(values) {
860
+ var _this12 = this;
861
+ if (DocumentSymbol.is(values[0])) {
862
+ return values.map(function (s) {
863
+ return _this12.asDocumentSymbol(s);
864
+ });
865
+ }
866
+ return this.asSymbolInformations(values);
867
+ }
868
+ }, {
869
+ key: "asSymbolInformations",
870
+ value: function asSymbolInformations(values, uri) {
871
+ var _this13 = this;
872
+ if (!values) {
873
+ return undefined;
874
+ }
875
+ return values.map(function (information) {
876
+ return _this13.asSymbolInformation(information, uri);
877
+ });
878
+ }
879
+ }, {
880
+ key: "asSymbolInformation",
881
+ value: function asSymbolInformation(item, uri) {
882
+ var location = this.asLocation(uri ? _objectSpread(_objectSpread({}, item.location), {}, {
883
+ uri: uri.toString()
884
+ }) : item.location);
885
+ return {
886
+ name: item.name,
887
+ detail: '',
888
+ containerName: item.containerName,
889
+ kind: this.asSymbolKind(item.kind),
890
+ tags: item.tags || [],
891
+ range: location.range,
892
+ selectionRange: location.range
893
+ };
894
+ }
895
+ }, {
896
+ key: "asSymbolKind",
897
+ value: function asSymbolKind(item) {
898
+ if (item <= SymbolKind.TypeParameter) {
899
+ // Symbol kind is one based in the protocol and zero based in code.
900
+ return item - 1;
901
+ }
902
+ return this._monaco.languages.SymbolKind.Property;
903
+ }
904
+ }, {
905
+ key: "asDocumentHighlights",
906
+ value: function asDocumentHighlights(values) {
907
+ var _this14 = this;
908
+ if (!values) {
909
+ return undefined;
910
+ }
911
+ return values.map(function (item) {
912
+ return _this14.asDocumentHighlight(item);
913
+ });
914
+ }
915
+ }, {
916
+ key: "asDocumentHighlight",
917
+ value: function asDocumentHighlight(item) {
918
+ var range = this.asRange(item.range);
919
+ var kind = Is.isNumber(item.kind) ? this.asDocumentHighlightKind(item.kind) : undefined;
920
+ return {
921
+ range: range,
922
+ kind: kind
923
+ };
924
+ }
925
+ }, {
926
+ key: "asDocumentHighlightKind",
927
+ value: function asDocumentHighlightKind(item) {
928
+ switch (item) {
929
+ case DocumentHighlightKind.Text:
930
+ return this._monaco.languages.DocumentHighlightKind.Text;
931
+ case DocumentHighlightKind.Read:
932
+ return this._monaco.languages.DocumentHighlightKind.Read;
933
+ case DocumentHighlightKind.Write:
934
+ return this._monaco.languages.DocumentHighlightKind.Write;
935
+ }
936
+ return this._monaco.languages.DocumentHighlightKind.Text;
937
+ }
938
+ }, {
939
+ key: "asReferences",
940
+ value: function asReferences(values) {
941
+ var _this15 = this;
942
+ if (!values) {
943
+ return undefined;
944
+ }
945
+ return values.map(function (location) {
946
+ return _this15.asLocation(location);
947
+ });
948
+ }
949
+ }, {
950
+ key: "asDefinitionResult",
951
+ value: function asDefinitionResult(item) {
952
+ var _this16 = this;
953
+ if (!item) {
954
+ return undefined;
955
+ }
956
+ if (Array.isArray(item)) {
957
+ if (item.length === 0) {
958
+ return undefined;
959
+ } else if (LocationLink.is(item[0])) {
960
+ var links = item;
961
+ return links.map(function (location) {
962
+ return _this16.asLocationLink(location);
963
+ });
964
+ } else {
965
+ var locations = item;
966
+ return locations.map(function (location) {
967
+ return _this16.asLocation(location);
968
+ });
969
+ }
970
+ } else {
971
+ return this.asLocation(item);
972
+ }
973
+ }
974
+ }, {
975
+ key: "asLocation",
976
+ value: function asLocation(item) {
977
+ if (!item) {
978
+ return undefined;
979
+ }
980
+ var uri = this._monaco.Uri.parse(item.uri);
981
+ var range = this.asRange(item.range);
982
+ return {
983
+ uri: uri,
984
+ range: range
985
+ };
986
+ }
987
+ }, {
988
+ key: "asLocationLink",
989
+ value: function asLocationLink(item) {
990
+ if (!item) {
991
+ return undefined;
992
+ }
993
+ var result = {
994
+ uri: this._monaco.Uri.parse(item.targetUri),
995
+ range: this.asRange(item.targetSelectionRange),
996
+ // See issue: https://github.com/Microsoft/vscode/issues/58649
997
+ originSelectionRange: this.asRange(item.originSelectionRange),
998
+ targetSelectionRange: this.asRange(item.targetSelectionRange)
999
+ };
1000
+ if (!result.targetSelectionRange) {
1001
+ throw new Error("targetSelectionRange must not be undefined or null");
1002
+ }
1003
+ return result;
1004
+ }
1005
+ }, {
1006
+ key: "asSignatureHelpResult",
1007
+ value: function asSignatureHelpResult(item) {
1008
+ if (!item) {
1009
+ return undefined;
1010
+ }
1011
+ var result = {};
1012
+ if (Is.isNumber(item.activeSignature)) {
1013
+ result.activeSignature = item.activeSignature;
1014
+ } else {
1015
+ // activeSignature was optional in the past
1016
+ result.activeSignature = 0;
1017
+ }
1018
+ if (Is.isNumber(item.activeParameter)) {
1019
+ result.activeParameter = item.activeParameter;
1020
+ } else {
1021
+ // activeParameter was optional in the past
1022
+ result.activeParameter = 0;
1023
+ }
1024
+ if (item.signatures) {
1025
+ result.signatures = this.asSignatureInformations(item.signatures);
1026
+ } else {
1027
+ result.signatures = [];
1028
+ }
1029
+ return {
1030
+ value: result,
1031
+ dispose: function dispose() {}
1032
+ };
1033
+ }
1034
+ }, {
1035
+ key: "asSignatureInformations",
1036
+ value: function asSignatureInformations(items) {
1037
+ var _this17 = this;
1038
+ return items.map(function (item) {
1039
+ return _this17.asSignatureInformation(item);
1040
+ });
1041
+ }
1042
+ }, {
1043
+ key: "asSignatureInformation",
1044
+ value: function asSignatureInformation(item) {
1045
+ var result = {
1046
+ label: item.label
1047
+ };
1048
+ if (item.documentation) {
1049
+ result.documentation = this.asDocumentation(item.documentation);
1050
+ }
1051
+ if (item.parameters) {
1052
+ result.parameters = this.asParameterInformations(item.parameters);
1053
+ } else {
1054
+ result.parameters = [];
1055
+ }
1056
+ if (item.activeParameter) {
1057
+ result.activeParameter = item.activeParameter;
1058
+ }
1059
+ return result;
1060
+ }
1061
+ }, {
1062
+ key: "asParameterInformations",
1063
+ value: function asParameterInformations(item) {
1064
+ var _this18 = this;
1065
+ return item.map(function (item) {
1066
+ return _this18.asParameterInformation(item);
1067
+ });
1068
+ }
1069
+ }, {
1070
+ key: "asParameterInformation",
1071
+ value: function asParameterInformation(item) {
1072
+ var result = {
1073
+ label: item.label
1074
+ };
1075
+ if (item.documentation) {
1076
+ result.documentation = this.asDocumentation(item.documentation);
1077
+ }
1078
+ return result;
1079
+ }
1080
+ }, {
1081
+ key: "asHover",
1082
+ value: function asHover(hover) {
1083
+ if (!hover) {
1084
+ return undefined;
1085
+ }
1086
+ return {
1087
+ contents: this.asHoverContent(hover.contents),
1088
+ range: this.asRange(hover.range)
1089
+ };
1090
+ }
1091
+ }, {
1092
+ key: "asHoverContent",
1093
+ value: function asHoverContent(contents) {
1094
+ var _this19 = this;
1095
+ if (Array.isArray(contents)) {
1096
+ return contents.map(function (content) {
1097
+ return _this19.asMarkdownString(content);
1098
+ });
1099
+ }
1100
+ return [this.asMarkdownString(contents)];
1101
+ }
1102
+ }, {
1103
+ key: "asDocumentation",
1104
+ value: function asDocumentation(value) {
1105
+ if (Is.isString(value)) {
1106
+ return value;
1107
+ }
1108
+ if (value.kind === MarkupKind.PlainText) {
1109
+ return value.value;
1110
+ }
1111
+ return this.asMarkdownString(value);
1112
+ }
1113
+ }, {
1114
+ key: "asMarkdownString",
1115
+ value: function asMarkdownString(content) {
1116
+ if (MarkupContent.is(content)) {
1117
+ return {
1118
+ value: content.value
1119
+ };
1120
+ }
1121
+ if (Is.isString(content)) {
1122
+ return {
1123
+ value: content
1124
+ };
1125
+ }
1126
+ var language = content.language,
1127
+ value = content.value;
1128
+ return {
1129
+ value: '```' + language + '\n' + value + '\n```'
1130
+ };
1131
+ }
1132
+ }, {
1133
+ key: "asSeverity",
1134
+ value: function asSeverity(severity) {
1135
+ if (severity === 1) {
1136
+ return this._monaco.MarkerSeverity.Error;
1137
+ }
1138
+ if (severity === 2) {
1139
+ return this._monaco.MarkerSeverity.Warning;
1140
+ }
1141
+ if (severity === 3) {
1142
+ return this._monaco.MarkerSeverity.Info;
1143
+ }
1144
+ return this._monaco.MarkerSeverity.Hint;
1145
+ }
1146
+ }, {
1147
+ key: "asDiagnostics",
1148
+ value: function asDiagnostics(diagnostics) {
1149
+ var _this20 = this;
1150
+ if (!diagnostics) {
1151
+ return undefined;
1152
+ }
1153
+ return diagnostics.map(function (diagnostic) {
1154
+ return _this20.asDiagnostic(diagnostic);
1155
+ });
1156
+ }
1157
+ }, {
1158
+ key: "asDiagnostic",
1159
+ value: function asDiagnostic(diagnostic) {
1160
+ return {
1161
+ code: typeof diagnostic.code === 'number' ? diagnostic.code.toString() : diagnostic.code,
1162
+ severity: this.asSeverity(diagnostic.severity),
1163
+ message: diagnostic.message,
1164
+ source: diagnostic.source,
1165
+ startLineNumber: diagnostic.range.start.line + 1,
1166
+ startColumn: diagnostic.range.start.character + 1,
1167
+ endLineNumber: diagnostic.range.end.line + 1,
1168
+ endColumn: diagnostic.range.end.character + 1,
1169
+ relatedInformation: this.asRelatedInformations(diagnostic.relatedInformation),
1170
+ tags: diagnostic.tags
1171
+ };
1172
+ }
1173
+ }, {
1174
+ key: "asRelatedInformations",
1175
+ value: function asRelatedInformations(relatedInformation) {
1176
+ var _this21 = this;
1177
+ if (!relatedInformation) {
1178
+ return undefined;
1179
+ }
1180
+ return relatedInformation.map(function (item) {
1181
+ return _this21.asRelatedInformation(item);
1182
+ });
1183
+ }
1184
+ }, {
1185
+ key: "asRelatedInformation",
1186
+ value: function asRelatedInformation(relatedInformation) {
1187
+ return {
1188
+ resource: this._monaco.Uri.parse(relatedInformation.location.uri),
1189
+ startLineNumber: relatedInformation.location.range.start.line + 1,
1190
+ startColumn: relatedInformation.location.range.start.character + 1,
1191
+ endLineNumber: relatedInformation.location.range.end.line + 1,
1192
+ endColumn: relatedInformation.location.range.end.character + 1,
1193
+ message: relatedInformation.message
1194
+ };
1195
+ }
1196
+ }, {
1197
+ key: "asCompletionResult",
1198
+ value: function asCompletionResult(result, defaultMonacoRange) {
1199
+ var _this22 = this;
1200
+ if (!result) {
1201
+ return {
1202
+ incomplete: false,
1203
+ suggestions: []
1204
+ };
1205
+ }
1206
+ if (Array.isArray(result)) {
1207
+ var suggestions = result.map(function (item) {
1208
+ return _this22.asCompletionItem(item, defaultMonacoRange, defaultRange);
1209
+ });
1210
+ return {
1211
+ incomplete: false,
1212
+ suggestions: suggestions
1213
+ };
1214
+ }
1215
+ var defaultRange = this.getCompletionItemDefaultRange(result);
1216
+ return {
1217
+ incomplete: result.isIncomplete,
1218
+ suggestions: result.items.map(function (item) {
1219
+ return _this22.asCompletionItem(item, defaultMonacoRange, defaultRange, result.itemDefaults);
1220
+ })
1221
+ };
1222
+ }
1223
+ }, {
1224
+ key: "asCompletionItem",
1225
+ value: function asCompletionItem(item, defaultMonacoRange, defaultRange, itemDefaults) {
1226
+ var _insertText$range, _item$data, _item$insertTextMode;
1227
+ var result = {
1228
+ label: this.asCompletionItemLabel(item)
1229
+ };
1230
+ if (item.detail) {
1231
+ result.detail = item.detail;
1232
+ }
1233
+ if (item.documentation) {
1234
+ result.documentation = this.asDocumentation(item.documentation);
1235
+ result.documentationFormat = Is.isString(item.documentation) ? undefined : item.documentation.kind;
1236
+ }
1237
+ if (item.filterText) {
1238
+ result.filterText = item.filterText;
1239
+ }
1240
+ var insertText = this.asCompletionInsertText(item, defaultRange, itemDefaults === null || itemDefaults === void 0 ? void 0 : itemDefaults.insertTextFormat);
1241
+ result.insertText = insertText.insertText;
1242
+ result.range = (_insertText$range = insertText.range) !== null && _insertText$range !== void 0 ? _insertText$range : defaultMonacoRange;
1243
+ result.fromEdit = insertText.fromEdit;
1244
+ if (insertText.isSnippet) {
1245
+ result.insertTextRules = this._monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet;
1246
+ }
1247
+ if (Is.isNumber(item.kind)) {
1248
+ var _this$asCompletionIte = this.asCompletionItemKind(item.kind),
1249
+ _this$asCompletionIte2 = _slicedToArray(_this$asCompletionIte, 2),
1250
+ itemKind = _this$asCompletionIte2[0],
1251
+ original = _this$asCompletionIte2[1];
1252
+ result.kind = itemKind;
1253
+ if (original) {
1254
+ result.originalItemKind = original;
1255
+ }
1256
+ }
1257
+ if (item.sortText) {
1258
+ result.sortText = item.sortText;
1259
+ }
1260
+ if (item.additionalTextEdits) {
1261
+ result.additionalTextEdits = this.asTextEdits(item.additionalTextEdits);
1262
+ }
1263
+ if (Is.isStringArray(item.commitCharacters)) {
1264
+ result.commitCharacters = item.commitCharacters.slice();
1265
+ }
1266
+ if (item.command) {
1267
+ result.command = this.asCommand(item.command);
1268
+ }
1269
+ if (item.deprecated === true || item.deprecated === false) {
1270
+ result.deprecated = item.deprecated;
1271
+ }
1272
+ if (item.preselect === true || item.preselect === false) {
1273
+ result.preselect = item.preselect;
1274
+ }
1275
+ var data = (_item$data = item.data) !== null && _item$data !== void 0 ? _item$data : itemDefaults === null || itemDefaults === void 0 ? void 0 : itemDefaults.data;
1276
+ if (data !== undefined) {
1277
+ result.data = data;
1278
+ }
1279
+ if (item.deprecated === true || item.deprecated === false) {
1280
+ result.deprecated = item.deprecated;
1281
+ }
1282
+ var insertTextMode = (_item$insertTextMode = item.insertTextMode) !== null && _item$insertTextMode !== void 0 ? _item$insertTextMode : itemDefaults === null || itemDefaults === void 0 ? void 0 : itemDefaults.insertTextMode;
1283
+ if (insertTextMode) {
1284
+ result.insertTextMode = insertTextMode;
1285
+ }
1286
+ if (item.tags) {
1287
+ result.tags = item.tags;
1288
+ }
1289
+ return result;
1290
+ }
1291
+ }, {
1292
+ key: "getCompletionItemDefaultRange",
1293
+ value: function getCompletionItemDefaultRange(list) {
1294
+ var _list$itemDefaults;
1295
+ var rangeDefaults = (_list$itemDefaults = list.itemDefaults) === null || _list$itemDefaults === void 0 ? void 0 : _list$itemDefaults.editRange;
1296
+ return ls.Range.is(rangeDefaults) ? this.asRange(rangeDefaults) : rangeDefaults !== undefined ? {
1297
+ insert: this.asRange(rangeDefaults.insert),
1298
+ replace: this.asRange(rangeDefaults.replace)
1299
+ } : undefined;
1300
+ }
1301
+ }, {
1302
+ key: "asCompletionItemLabel",
1303
+ value: function asCompletionItemLabel(item) {
1304
+ if (ls.CompletionItemLabelDetails.is(item.labelDetails)) {
1305
+ return {
1306
+ label: item.label,
1307
+ detail: item.labelDetails.detail,
1308
+ description: item.labelDetails.description
1309
+ };
1310
+ } else {
1311
+ return item.label;
1312
+ }
1313
+ }
1314
+ }, {
1315
+ key: "asCompletionItemKind",
1316
+ value: function asCompletionItemKind(value) {
1317
+ if (CompletionItemKind.Text <= value && value <= CompletionItemKind.TypeParameter) {
1318
+ switch (value) {
1319
+ case CompletionItemKind.Text:
1320
+ return [this._monaco.languages.CompletionItemKind.Text, undefined];
1321
+ case CompletionItemKind.Method:
1322
+ return [this._monaco.languages.CompletionItemKind.Method, undefined];
1323
+ case CompletionItemKind.Function:
1324
+ return [this._monaco.languages.CompletionItemKind.Function, undefined];
1325
+ case CompletionItemKind.Constructor:
1326
+ return [this._monaco.languages.CompletionItemKind.Constructor, undefined];
1327
+ case CompletionItemKind.Field:
1328
+ return [this._monaco.languages.CompletionItemKind.Field, undefined];
1329
+ case CompletionItemKind.Variable:
1330
+ return [this._monaco.languages.CompletionItemKind.Variable, undefined];
1331
+ case CompletionItemKind.Class:
1332
+ return [this._monaco.languages.CompletionItemKind.Class, undefined];
1333
+ case CompletionItemKind.Interface:
1334
+ return [this._monaco.languages.CompletionItemKind.Interface, undefined];
1335
+ case CompletionItemKind.Module:
1336
+ return [this._monaco.languages.CompletionItemKind.Module, undefined];
1337
+ case CompletionItemKind.Property:
1338
+ return [this._monaco.languages.CompletionItemKind.Property, undefined];
1339
+ case CompletionItemKind.Unit:
1340
+ return [this._monaco.languages.CompletionItemKind.Unit, undefined];
1341
+ case CompletionItemKind.Value:
1342
+ return [this._monaco.languages.CompletionItemKind.Value, undefined];
1343
+ case CompletionItemKind.Enum:
1344
+ return [this._monaco.languages.CompletionItemKind.Enum, undefined];
1345
+ case CompletionItemKind.Keyword:
1346
+ return [this._monaco.languages.CompletionItemKind.Keyword, undefined];
1347
+ case CompletionItemKind.Snippet:
1348
+ return [this._monaco.languages.CompletionItemKind.Snippet, undefined];
1349
+ case CompletionItemKind.Color:
1350
+ return [this._monaco.languages.CompletionItemKind.Color, undefined];
1351
+ case CompletionItemKind.File:
1352
+ return [this._monaco.languages.CompletionItemKind.File, undefined];
1353
+ case CompletionItemKind.Reference:
1354
+ return [this._monaco.languages.CompletionItemKind.Reference, undefined];
1355
+ case CompletionItemKind.Folder:
1356
+ return [this._monaco.languages.CompletionItemKind.Folder, undefined];
1357
+ case CompletionItemKind.EnumMember:
1358
+ return [this._monaco.languages.CompletionItemKind.EnumMember, undefined];
1359
+ case CompletionItemKind.Constant:
1360
+ return [this._monaco.languages.CompletionItemKind.Constant, undefined];
1361
+ case CompletionItemKind.Struct:
1362
+ return [this._monaco.languages.CompletionItemKind.Struct, undefined];
1363
+ case CompletionItemKind.Event:
1364
+ return [this._monaco.languages.CompletionItemKind.Event, undefined];
1365
+ case CompletionItemKind.Operator:
1366
+ return [this._monaco.languages.CompletionItemKind.Operator, undefined];
1367
+ case CompletionItemKind.TypeParameter:
1368
+ return [this._monaco.languages.CompletionItemKind.TypeParameter, undefined];
1369
+ default:
1370
+ return [value - 1, undefined];
1371
+ }
1372
+ }
1373
+ return [CompletionItemKind.Text, value];
1374
+ }
1375
+ }, {
1376
+ key: "asCompletionInsertText",
1377
+ value: function asCompletionInsertText(item, defaultRange, defaultInsertTextFormat) {
1378
+ var _item$insertTextForma;
1379
+ var insertTextFormat = (_item$insertTextForma = item.insertTextFormat) !== null && _item$insertTextForma !== void 0 ? _item$insertTextForma : defaultInsertTextFormat;
1380
+ var isSnippet = insertTextFormat === InsertTextFormat.Snippet;
1381
+ if (item.textEdit !== undefined || defaultRange !== undefined) {
1382
+ var _item$textEditText;
1383
+ var _ref = item.textEdit !== undefined ? this.getCompletionRangeAndText(item.textEdit) : [defaultRange, (_item$textEditText = item.textEditText) !== null && _item$textEditText !== void 0 ? _item$textEditText : item.label],
1384
+ _ref2 = _slicedToArray(_ref, 2),
1385
+ _range = _ref2[0],
1386
+ newText = _ref2[1];
1387
+ return {
1388
+ insertText: newText,
1389
+ range: _range,
1390
+ fromEdit: true,
1391
+ isSnippet: isSnippet
1392
+ };
1393
+ } else if (item.insertText) {
1394
+ return {
1395
+ isSnippet: isSnippet,
1396
+ insertText: item.insertText,
1397
+ fromEdit: false,
1398
+ range: defaultRange
1399
+ };
1400
+ }
1401
+ return {
1402
+ insertText: item.label,
1403
+ range: defaultRange,
1404
+ fromEdit: false,
1405
+ isSnippet: false
1406
+ };
1407
+ }
1408
+ }, {
1409
+ key: "getCompletionRangeAndText",
1410
+ value: function getCompletionRangeAndText(value) {
1411
+ if (ls.InsertReplaceEdit.is(value)) {
1412
+ return [{
1413
+ insert: this.asRange(value.insert),
1414
+ replace: this.asRange(value.replace)
1415
+ }, value.newText];
1416
+ } else {
1417
+ return [this.asRange(value.range), value.newText];
1418
+ }
1419
+ }
1420
+ }, {
1421
+ key: "asDocumentLinks",
1422
+ value: function asDocumentLinks(documentLinks) {
1423
+ var _this23 = this;
1424
+ var links = documentLinks.map(function (link) {
1425
+ return _this23.asDocumentLink(link);
1426
+ });
1427
+ return {
1428
+ links: links
1429
+ };
1430
+ }
1431
+ }, {
1432
+ key: "asDocumentLink",
1433
+ value: function asDocumentLink(documentLink) {
1434
+ return {
1435
+ range: this.asRange(documentLink.range),
1436
+ url: documentLink.target,
1437
+ data: documentLink.data,
1438
+ tooltip: documentLink.tooltip
1439
+ };
1440
+ }
1441
+ }, {
1442
+ key: "asRange",
1443
+ value: function asRange(range) {
1444
+ if (range === undefined) {
1445
+ return undefined;
1446
+ }
1447
+ if (range === null) {
1448
+ return null;
1449
+ }
1450
+ var start = this.asPosition(range.start);
1451
+ var end = this.asPosition(range.end);
1452
+ if (start instanceof this._monaco.Position && end instanceof this._monaco.Position) {
1453
+ return new this._monaco.Range(start.lineNumber, start.column, end.lineNumber, end.column);
1454
+ }
1455
+ var startLineNumber = !start || start.lineNumber === undefined ? undefined : start.lineNumber;
1456
+ var startColumn = !start || start.column === undefined ? undefined : start.column;
1457
+ var endLineNumber = !end || end.lineNumber === undefined ? undefined : end.lineNumber;
1458
+ var endColumn = !end || end.column === undefined ? undefined : end.column;
1459
+ return {
1460
+ startLineNumber: startLineNumber,
1461
+ startColumn: startColumn,
1462
+ endLineNumber: endLineNumber,
1463
+ endColumn: endColumn
1464
+ };
1465
+ }
1466
+ }, {
1467
+ key: "asPosition",
1468
+ value: function asPosition(position) {
1469
+ if (position === undefined) {
1470
+ return undefined;
1471
+ }
1472
+ if (position === null) {
1473
+ return null;
1474
+ }
1475
+ var line = position.line,
1476
+ character = position.character;
1477
+ var lineNumber = line === undefined ? undefined : line + 1;
1478
+ var column = character === undefined ? undefined : character + 1;
1479
+ if (lineNumber !== undefined && column !== undefined) {
1480
+ return new this._monaco.Position(lineNumber, column);
1481
+ }
1482
+ return {
1483
+ lineNumber: lineNumber,
1484
+ column: column
1485
+ };
1486
+ }
1487
+ }, {
1488
+ key: "asColorInformations",
1489
+ value: function asColorInformations(items) {
1490
+ var _this24 = this;
1491
+ return items.map(function (item) {
1492
+ return _this24.asColorInformation(item);
1493
+ });
1494
+ }
1495
+ }, {
1496
+ key: "asColorInformation",
1497
+ value: function asColorInformation(item) {
1498
+ return {
1499
+ range: this.asRange(item.range),
1500
+ color: item.color
1501
+ };
1502
+ }
1503
+ }, {
1504
+ key: "asColorPresentations",
1505
+ value: function asColorPresentations(items) {
1506
+ var _this25 = this;
1507
+ return items.map(function (item) {
1508
+ return _this25.asColorPresentation(item);
1509
+ });
1510
+ }
1511
+ }, {
1512
+ key: "asColorPresentation",
1513
+ value: function asColorPresentation(item) {
1514
+ return {
1515
+ label: item.label,
1516
+ textEdit: this.asTextEdit(item.textEdit),
1517
+ additionalTextEdits: this.asTextEdits(item.additionalTextEdits)
1518
+ };
1519
+ }
1520
+ }, {
1521
+ key: "asFoldingRanges",
1522
+ value: function asFoldingRanges(items) {
1523
+ var _this26 = this;
1524
+ if (!items) {
1525
+ return items;
1526
+ }
1527
+ return items.map(function (item) {
1528
+ return _this26.asFoldingRange(item);
1529
+ });
1530
+ }
1531
+ }, {
1532
+ key: "asFoldingRange",
1533
+ value: function asFoldingRange(item) {
1534
+ return {
1535
+ start: item.startLine + 1,
1536
+ end: item.endLine + 1,
1537
+ kind: this.asFoldingRangeKind(item.kind)
1538
+ };
1539
+ }
1540
+ }, {
1541
+ key: "asFoldingRangeKind",
1542
+ value: function asFoldingRangeKind(kind) {
1543
+ if (kind) {
1544
+ switch (kind) {
1545
+ case FoldingRangeKind.Comment:
1546
+ return this._monaco.languages.FoldingRangeKind.Comment;
1547
+ case FoldingRangeKind.Imports:
1548
+ return this._monaco.languages.FoldingRangeKind.Imports;
1549
+ case FoldingRangeKind.Region:
1550
+ return this._monaco.languages.FoldingRangeKind.Region;
1551
+ }
1552
+ }
1553
+ return undefined;
1554
+ }
1555
+ }, {
1556
+ key: "asSemanticTokens",
1557
+ value: function asSemanticTokens(semanticTokens) {
1558
+ return {
1559
+ resultId: semanticTokens.resultId,
1560
+ data: Uint32Array.from(semanticTokens.data)
1561
+ };
1562
+ }
1563
+ }, {
1564
+ key: "asInlayHintLabelPart",
1565
+ value: function asInlayHintLabelPart(part) {
1566
+ return {
1567
+ label: part.value,
1568
+ command: this.asCommand(part.command),
1569
+ location: this.asLocation(part.location),
1570
+ tooltip: part.tooltip && this.asMarkdownString(part.tooltip)
1571
+ };
1572
+ }
1573
+ }, {
1574
+ key: "asInlayHintLabel",
1575
+ value: function asInlayHintLabel(label) {
1576
+ var _this27 = this;
1577
+ if (Array.isArray(label)) {
1578
+ return label.map(function (part) {
1579
+ return _this27.asInlayHintLabelPart(part);
1580
+ });
1581
+ }
1582
+ return label;
1583
+ }
1584
+ }, {
1585
+ key: "asInlayHint",
1586
+ value: function asInlayHint(inlayHint) {
1587
+ return {
1588
+ data: inlayHint.data,
1589
+ label: this.asInlayHintLabel(inlayHint.label),
1590
+ position: this.asPosition(inlayHint.position),
1591
+ kind: inlayHint.kind,
1592
+ paddingLeft: inlayHint.paddingLeft,
1593
+ paddingRight: inlayHint.paddingRight,
1594
+ tooltip: inlayHint.tooltip && this.asMarkdownString(inlayHint.tooltip)
1595
+ };
1596
+ }
1597
+ }, {
1598
+ key: "asInlayHintList",
1599
+ value: function asInlayHintList(items) {
1600
+ var _this28 = this;
1601
+ if (!items) {
1602
+ return undefined;
1603
+ }
1604
+ return {
1605
+ hints: items.map(function (hint) {
1606
+ return _this28.asInlayHint(hint);
1607
+ }),
1608
+ dispose: function dispose() {}
1609
+ };
1610
+ }
1611
+ }]);
1612
+ return ProtocolToMonacoConverter;
1613
+ }();