@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,2731 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ 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."); }
3
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
7
+ 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."); }
8
+ 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); }
9
+ 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; }
10
+ 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; } }
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+ 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; }
13
+ 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); } }
14
+ 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); }); }; }
15
+ 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); }
16
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
+ 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); } }
18
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
19
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
20
+ 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); }
21
+ /* eslint-disable @typescript-eslint/no-this-alias */
22
+ /* eslint-disable promise/always-return */
23
+ /* eslint-disable promise/catch-or-return */
24
+ /* --------------------------------------------------------------------------------------------
25
+ * Copyright (c) Microsoft Corporation. All rights reserved.
26
+ * Licensed under the MIT License. See License.txt in the project root for license information.
27
+ * ------------------------------------------------------------------------------------------ */
28
+
29
+ import { RAL, ResponseError, MessageReader, MessageWriter, Trace, TraceFormat, Emitter, createProtocolConnection, RegistrationRequest, UnregistrationRequest, InitializeRequest, TextDocumentSyncKind, InitializedNotification, ShutdownRequest, ExitNotification, LogMessageNotification, MessageType, ShowMessageNotification, ShowMessageRequest, TelemetryEventNotification, DidChangeTextDocumentNotification, DidChangeWatchedFilesNotification, PublishDiagnosticsNotification, ApplyWorkspaceEditRequest, TextDocumentEdit, ResourceOperationKind, FailureHandlingKind, DiagnosticTag, LSPErrorCodes, ShowDocumentRequest, WorkDoneProgress, SemanticTokensRequest, SemanticTokensRangeRequest, SemanticTokensDeltaRequest, DidOpenTextDocumentNotification, PositionEncodingKind, NotebookDocumentSyncRegistrationType, ErrorCodes, CodeLensResolveRequest, CompletionResolveRequest, CodeActionResolveRequest, InlayHintResolveRequest, DocumentLinkResolveRequest, WorkspaceSymbolResolveRequest, CancellationToken as ProtocolCancellationToken } from '@difizen/vscode-languageserver-protocol';
30
+ import { CallHierarchyFeature } from "./callHierarchy.js";
31
+ import { CodeActionFeature } from "./codeAction.js";
32
+ import * as c2p from "./codeConverter.js";
33
+ import { CodeLensFeature } from "./codeLens.js";
34
+ import { ColorProviderFeature } from "./colorProvider.js";
35
+ import { CompletionItemFeature } from "./completion.js";
36
+ import { ConfigurationFeature, SyncConfigurationFeature } from "./configuration.js";
37
+ import { DeclarationFeature } from "./declaration.js";
38
+ import { DefinitionFeature } from "./definition.js";
39
+ import { DiagnosticFeature } from "./diagnostic.js";
40
+ import { DocumentHighlightFeature } from "./documentHighlight.js";
41
+ import { DocumentLinkFeature } from "./documentLink.js";
42
+ import { DocumentSymbolFeature } from "./documentSymbol.js";
43
+ import { ExecuteCommandFeature } from "./executeCommand.js";
44
+ import { DynamicFeature, ensure, LSPCancellationError } from "./features.js";
45
+ import { DidCreateFilesFeature, DidDeleteFilesFeature, DidRenameFilesFeature, WillCreateFilesFeature, WillDeleteFilesFeature, WillRenameFilesFeature } from "./fileOperations.js";
46
+ import { FileSystemWatcherFeature } from "./fileSystemWatcher.js";
47
+ import { FoldingRangeFeature } from "./foldingRange.js";
48
+ import { DocumentFormattingFeature, DocumentOnTypeFormattingFeature, DocumentRangeFormattingFeature } from "./formatting.js";
49
+ import { HoverFeature } from "./hover.js";
50
+ import { ImplementationFeature } from "./implementation.js";
51
+ import { InlayHintsFeature } from "./inlayHint.js";
52
+ import { InlineCompletionItemFeature } from "./inlineCompletion.js";
53
+ import { InlineValueFeature } from "./inlineValue.js";
54
+ import { LinkedEditingFeature } from "./linkedEditingRange.js";
55
+ import { NotebookDocumentSyncFeature } from "./notebook.js";
56
+ import { ProgressFeature } from "./progress.js";
57
+ import { ProgressPart } from "./progressPart.js";
58
+ import * as p2c from "./protocolConverter.js";
59
+ import { ReferencesFeature } from "./reference.js";
60
+ import { RenameFeature } from "./rename.js";
61
+ import { SelectionRangeFeature } from "./selectionRange.js";
62
+ import { SemanticTokensFeature } from "./semanticTokens.js";
63
+ import { SignatureHelpFeature } from "./signatureHelp.js";
64
+ import { DidChangeTextDocumentFeature, DidCloseTextDocumentFeature, DidOpenTextDocumentFeature, DidSaveTextDocumentFeature, WillSaveFeature, WillSaveWaitUntilFeature } from "./textSynchronization.js";
65
+ import { TypeDefinitionFeature } from "./typeDefinition.js";
66
+ import { TypeHierarchyFeature } from "./typeHierarchy.js";
67
+ import { Delayer, Semaphore } from "./utils/async.js";
68
+ import * as Is from "./utils/is.js";
69
+ import * as UUID from "./utils/uuid.js";
70
+ import { Uri, version as VSCodeVersion, CancellationError, CancellationTokenSource, workspace as Workspace, window as Window, env as Env, languages as Languages } from "./vscodeAdaptor/vscodeAdaptor.js";
71
+ import { WorkspaceFoldersFeature } from "./workspaceFolder.js";
72
+ import { WorkspaceSymbolFeature } from "./workspaceSymbol.js";
73
+ /**
74
+ * Controls when the output channel is revealed.
75
+ */
76
+ export var RevealOutputChannelOn = /*#__PURE__*/function (RevealOutputChannelOn) {
77
+ RevealOutputChannelOn[RevealOutputChannelOn["Debug"] = 0] = "Debug";
78
+ RevealOutputChannelOn[RevealOutputChannelOn["Info"] = 1] = "Info";
79
+ RevealOutputChannelOn[RevealOutputChannelOn["Warn"] = 2] = "Warn";
80
+ RevealOutputChannelOn[RevealOutputChannelOn["Error"] = 3] = "Error";
81
+ RevealOutputChannelOn[RevealOutputChannelOn["Never"] = 4] = "Never";
82
+ return RevealOutputChannelOn;
83
+ }({});
84
+
85
+ /**
86
+ * A handler that is invoked when the initialization of the server failed.
87
+ */
88
+
89
+ /**
90
+ * An action to be performed when the connection is producing errors.
91
+ */
92
+ export var ErrorAction = /*#__PURE__*/function (ErrorAction) {
93
+ ErrorAction[ErrorAction["Continue"] = 1] = "Continue";
94
+ ErrorAction[ErrorAction["Shutdown"] = 2] = "Shutdown";
95
+ return ErrorAction;
96
+ }({});
97
+ /**
98
+ * An action to be performed when the connection to a server got closed.
99
+ */
100
+ export var CloseAction = /*#__PURE__*/function (CloseAction) {
101
+ CloseAction[CloseAction["DoNotRestart"] = 1] = "DoNotRestart";
102
+ CloseAction[CloseAction["Restart"] = 2] = "Restart";
103
+ return CloseAction;
104
+ }({});
105
+
106
+ /**
107
+ * A plugable error handler that is invoked when the connection is either
108
+ * producing errors or got closed.
109
+ */
110
+
111
+ /**
112
+ * Signals in which state the language client is in.
113
+ */
114
+ export var State = /*#__PURE__*/function (State) {
115
+ State[State["Stopped"] = 1] = "Stopped";
116
+ State[State["Starting"] = 3] = "Starting";
117
+ State[State["Running"] = 2] = "Running";
118
+ return State;
119
+ }({});
120
+
121
+ /**
122
+ * An event signaling a state change.
123
+ */
124
+
125
+ export var SuspendMode = /*#__PURE__*/function (SuspendMode) {
126
+ SuspendMode["off"] = "off";
127
+ SuspendMode["on"] = "on";
128
+ return SuspendMode;
129
+ }({});
130
+
131
+ // A general middleware is applied to both requests and notifications
132
+
133
+ /**
134
+ * The Middleware lets extensions intercept the request and notifications send and received
135
+ * from the server
136
+ */
137
+
138
+ // type TestOptions = {
139
+ // $testMode?: boolean;
140
+ // };
141
+ var ResolvedClientOptions;
142
+ (function (_ResolvedClientOptions) {
143
+ function sanitizeIsTrusted(isTrusted) {
144
+ if (isTrusted === undefined || isTrusted === null) {
145
+ return false;
146
+ }
147
+ if (typeof isTrusted === 'boolean' || _typeof(isTrusted) === 'object' && isTrusted !== null && Is.stringArray(isTrusted.enabledCommands)) {
148
+ return isTrusted;
149
+ }
150
+ return false;
151
+ }
152
+ _ResolvedClientOptions.sanitizeIsTrusted = sanitizeIsTrusted;
153
+ })(ResolvedClientOptions || (ResolvedClientOptions = {}));
154
+ var DefaultErrorHandler = /*#__PURE__*/function () {
155
+ function DefaultErrorHandler(client, maxRestartCount) {
156
+ _classCallCheck(this, DefaultErrorHandler);
157
+ this.client = client;
158
+ this.maxRestartCount = maxRestartCount;
159
+ this.restarts = [];
160
+ }
161
+ _createClass(DefaultErrorHandler, [{
162
+ key: "error",
163
+ value: function error(_error, _message, count) {
164
+ if (count && count <= 3) {
165
+ return {
166
+ action: ErrorAction.Continue
167
+ };
168
+ }
169
+ return {
170
+ action: ErrorAction.Shutdown
171
+ };
172
+ }
173
+ }, {
174
+ key: "closed",
175
+ value: function closed() {
176
+ this.restarts.push(Date.now());
177
+ if (this.restarts.length <= this.maxRestartCount) {
178
+ return {
179
+ action: CloseAction.Restart
180
+ };
181
+ } else {
182
+ var diff = this.restarts[this.restarts.length - 1] - this.restarts[0];
183
+ if (diff <= 3 * 60 * 1000) {
184
+ return {
185
+ action: CloseAction.DoNotRestart,
186
+ message: "The ".concat(this.client.name, " server crashed ").concat(this.maxRestartCount + 1, " times in the last 3 minutes. The server will not be restarted. See the output for more information.")
187
+ };
188
+ } else {
189
+ this.restarts.shift();
190
+ return {
191
+ action: CloseAction.Restart
192
+ };
193
+ }
194
+ }
195
+ }
196
+ }]);
197
+ return DefaultErrorHandler;
198
+ }();
199
+ var ClientState = /*#__PURE__*/function (ClientState) {
200
+ ClientState["Initial"] = "initial";
201
+ ClientState["Starting"] = "starting";
202
+ ClientState["StartFailed"] = "startFailed";
203
+ ClientState["Running"] = "running";
204
+ ClientState["Stopping"] = "stopping";
205
+ ClientState["Stopped"] = "stopped";
206
+ return ClientState;
207
+ }(ClientState || {});
208
+ export var MessageTransports;
209
+ (function (_MessageTransports) {
210
+ function is(value) {
211
+ var candidate = value;
212
+ return candidate && MessageReader.is(value.reader) && MessageWriter.is(value.writer);
213
+ }
214
+ _MessageTransports.is = is;
215
+ })(MessageTransports || (MessageTransports = {}));
216
+ export var BaseLanguageClient = /*#__PURE__*/function () {
217
+ function BaseLanguageClient(id, name, clientOptions) {
218
+ var _clientOptions$docume,
219
+ _clientOptions$synchr,
220
+ _clientOptions$output,
221
+ _clientOptions$reveal,
222
+ _clientOptions$stdioE,
223
+ _clientOptions$errorH,
224
+ _clientOptions$connec,
225
+ _clientOptions$middle,
226
+ _clientOptions$diagno,
227
+ _clientOptions$notebo,
228
+ _this = this;
229
+ _classCallCheck(this, BaseLanguageClient);
230
+ // private _idleStart: number | undefined;
231
+ this._traceFormat = TraceFormat.Text;
232
+ this._diagnosticQueue = new Map();
233
+ this._diagnosticQueueState = {
234
+ state: 'idle'
235
+ };
236
+ this._features = [];
237
+ this._dynamicFeatures = new Map();
238
+ this.workspaceEditLock = new Semaphore(1);
239
+ this._id = id;
240
+ this._name = name;
241
+ clientOptions = clientOptions || {};
242
+ var markdown = {
243
+ isTrusted: false,
244
+ supportHtml: false
245
+ };
246
+ if (clientOptions.markdown !== undefined) {
247
+ markdown.isTrusted = ResolvedClientOptions.sanitizeIsTrusted(clientOptions.markdown.isTrusted);
248
+ markdown.supportHtml = clientOptions.markdown.supportHtml === true;
249
+ }
250
+
251
+ // const defaultInterval = (clientOptions as TestOptions).$testMode ? 50 : 60000;
252
+
253
+ this._clientOptions = {
254
+ documentSelector: (_clientOptions$docume = clientOptions.documentSelector) !== null && _clientOptions$docume !== void 0 ? _clientOptions$docume : [],
255
+ synchronize: (_clientOptions$synchr = clientOptions.synchronize) !== null && _clientOptions$synchr !== void 0 ? _clientOptions$synchr : {},
256
+ diagnosticCollectionName: clientOptions.diagnosticCollectionName,
257
+ outputChannelName: (_clientOptions$output = clientOptions.outputChannelName) !== null && _clientOptions$output !== void 0 ? _clientOptions$output : this._name,
258
+ revealOutputChannelOn: (_clientOptions$reveal = clientOptions.revealOutputChannelOn) !== null && _clientOptions$reveal !== void 0 ? _clientOptions$reveal : RevealOutputChannelOn.Error,
259
+ stdioEncoding: (_clientOptions$stdioE = clientOptions.stdioEncoding) !== null && _clientOptions$stdioE !== void 0 ? _clientOptions$stdioE : 'utf8',
260
+ initializationOptions: clientOptions.initializationOptions,
261
+ initializationFailedHandler: clientOptions.initializationFailedHandler,
262
+ progressOnInitialization: !!clientOptions.progressOnInitialization,
263
+ errorHandler: (_clientOptions$errorH = clientOptions.errorHandler) !== null && _clientOptions$errorH !== void 0 ? _clientOptions$errorH : this.createDefaultErrorHandler((_clientOptions$connec = clientOptions.connectionOptions) === null || _clientOptions$connec === void 0 ? void 0 : _clientOptions$connec.maxRestartCount),
264
+ middleware: (_clientOptions$middle = clientOptions.middleware) !== null && _clientOptions$middle !== void 0 ? _clientOptions$middle : {},
265
+ uriConverters: clientOptions.uriConverters,
266
+ workspaceFolder: clientOptions.workspaceFolder,
267
+ connectionOptions: clientOptions.connectionOptions,
268
+ markdown: markdown,
269
+ // suspend: {
270
+ // mode: clientOptions.suspend?.mode ?? SuspendMode.off,
271
+ // callback: clientOptions.suspend?.callback ?? (() => Promise.resolve(true)),
272
+ // interval: clientOptions.suspend?.interval ? Math.max(clientOptions.suspend.interval, defaultInterval) : defaultInterval
273
+ // },
274
+ diagnosticPullOptions: (_clientOptions$diagno = clientOptions.diagnosticPullOptions) !== null && _clientOptions$diagno !== void 0 ? _clientOptions$diagno : {
275
+ onChange: true,
276
+ onSave: false
277
+ },
278
+ notebookDocumentOptions: (_clientOptions$notebo = clientOptions.notebookDocumentOptions) !== null && _clientOptions$notebo !== void 0 ? _clientOptions$notebo : {}
279
+ };
280
+ this._clientOptions.synchronize = this._clientOptions.synchronize || {};
281
+ this._state = ClientState.Initial;
282
+ this._ignoredRegistrations = new Set();
283
+ this._listeners = [];
284
+ this._notificationHandlers = new Map();
285
+ this._pendingNotificationHandlers = new Map();
286
+ this._notificationDisposables = new Map();
287
+ this._requestHandlers = new Map();
288
+ this._pendingRequestHandlers = new Map();
289
+ this._requestDisposables = new Map();
290
+ this._progressHandlers = new Map();
291
+ this._pendingProgressHandlers = new Map();
292
+ this._progressDisposables = new Map();
293
+ this._connection = undefined;
294
+ // this._idleStart = undefined;
295
+ this._initializeResult = undefined;
296
+ if (clientOptions.outputChannel) {
297
+ this._outputChannel = clientOptions.outputChannel;
298
+ this._disposeOutputChannel = false;
299
+ } else {
300
+ this._outputChannel = undefined;
301
+ this._disposeOutputChannel = true;
302
+ }
303
+ this._traceOutputChannel = clientOptions.traceOutputChannel;
304
+ this._diagnostics = undefined;
305
+ this._pendingOpenNotifications = new Set();
306
+ this._pendingChangeSemaphore = new Semaphore(1);
307
+ this._pendingChangeDelayer = new Delayer(250);
308
+ this._fileEvents = [];
309
+ this._fileEventDelayer = new Delayer(250);
310
+ this._onStop = undefined;
311
+ this._telemetryEmitter = new Emitter();
312
+ this._stateChangeEmitter = new Emitter();
313
+ this._trace = Trace.Off;
314
+ this._tracer = {
315
+ log: function log(messageOrDataObject, data) {
316
+ if (Is.string(messageOrDataObject)) {
317
+ _this.logTrace(messageOrDataObject, data);
318
+ } else {
319
+ _this.logObjectTrace(messageOrDataObject);
320
+ }
321
+ }
322
+ };
323
+ this._c2p = c2p.createConverter(clientOptions.uriConverters ? clientOptions.uriConverters.code2Protocol : undefined);
324
+ this._p2c = p2c.createConverter(clientOptions.uriConverters ? clientOptions.uriConverters.protocol2Code : undefined, this._clientOptions.markdown.isTrusted, this._clientOptions.markdown.supportHtml);
325
+ this._syncedDocuments = new Map();
326
+ this.registerBuiltinFeatures();
327
+ }
328
+ _createClass(BaseLanguageClient, [{
329
+ key: "name",
330
+ get: function get() {
331
+ return this._name;
332
+ }
333
+ }, {
334
+ key: "middleware",
335
+ get: function get() {
336
+ var _this$_clientOptions$;
337
+ return (_this$_clientOptions$ = this._clientOptions.middleware) !== null && _this$_clientOptions$ !== void 0 ? _this$_clientOptions$ : Object.create(null);
338
+ }
339
+ }, {
340
+ key: "clientOptions",
341
+ get: function get() {
342
+ return this._clientOptions;
343
+ }
344
+ }, {
345
+ key: "protocol2CodeConverter",
346
+ get: function get() {
347
+ return this._p2c;
348
+ }
349
+ }, {
350
+ key: "code2ProtocolConverter",
351
+ get: function get() {
352
+ return this._c2p;
353
+ }
354
+ }, {
355
+ key: "onTelemetry",
356
+ get: function get() {
357
+ return this._telemetryEmitter.event;
358
+ }
359
+ }, {
360
+ key: "onDidChangeState",
361
+ get: function get() {
362
+ return this._stateChangeEmitter.event;
363
+ }
364
+ }, {
365
+ key: "outputChannel",
366
+ get: function get() {
367
+ if (!this._outputChannel) {
368
+ this._outputChannel = Window.createOutputChannel(this._clientOptions.outputChannelName ? this._clientOptions.outputChannelName : this._name);
369
+ }
370
+ return this._outputChannel;
371
+ }
372
+ }, {
373
+ key: "traceOutputChannel",
374
+ get: function get() {
375
+ if (this._traceOutputChannel) {
376
+ return this._traceOutputChannel;
377
+ }
378
+ return this.outputChannel;
379
+ }
380
+ }, {
381
+ key: "diagnostics",
382
+ get: function get() {
383
+ return this._diagnostics;
384
+ }
385
+ }, {
386
+ key: "state",
387
+ get: function get() {
388
+ return this.getPublicState();
389
+ }
390
+ }, {
391
+ key: "$state",
392
+ get: function get() {
393
+ return this._state;
394
+ },
395
+ set: function set(value) {
396
+ var oldState = this.getPublicState();
397
+ this._state = value;
398
+ var newState = this.getPublicState();
399
+ if (newState !== oldState) {
400
+ this._stateChangeEmitter.fire({
401
+ oldState: oldState,
402
+ newState: newState
403
+ });
404
+ }
405
+ }
406
+ }, {
407
+ key: "getPublicState",
408
+ value: function getPublicState() {
409
+ switch (this.$state) {
410
+ case ClientState.Starting:
411
+ return State.Starting;
412
+ case ClientState.Running:
413
+ return State.Running;
414
+ default:
415
+ return State.Stopped;
416
+ }
417
+ }
418
+ }, {
419
+ key: "initializeResult",
420
+ get: function get() {
421
+ return this._initializeResult;
422
+ }
423
+ }, {
424
+ key: "sendRequest",
425
+ value: function () {
426
+ var _sendRequest2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(type) {
427
+ var _this$_clientOptions$2;
428
+ var connection,
429
+ param,
430
+ token,
431
+ _len,
432
+ params,
433
+ _key,
434
+ _sendRequest,
435
+ _args = arguments;
436
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
437
+ while (1) switch (_context.prev = _context.next) {
438
+ case 0:
439
+ if (!(this.$state === ClientState.StartFailed || this.$state === ClientState.Stopping || this.$state === ClientState.Stopped)) {
440
+ _context.next = 2;
441
+ break;
442
+ }
443
+ return _context.abrupt("return", Promise.reject(new ResponseError(ErrorCodes.ConnectionInactive, "Client is not running")));
444
+ case 2:
445
+ _context.next = 4;
446
+ return this.$start();
447
+ case 4:
448
+ connection = _context.sent;
449
+ if (!(this._didChangeTextDocumentFeature.syncKind === TextDocumentSyncKind.Full)) {
450
+ _context.next = 8;
451
+ break;
452
+ }
453
+ _context.next = 8;
454
+ return this.sendPendingFullTextDocumentChanges(connection);
455
+ case 8:
456
+ param = undefined;
457
+ token = undefined; // Separate cancellation tokens from other parameters for a better client interface
458
+ for (_len = _args.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
459
+ params[_key - 1] = _args[_key];
460
+ }
461
+ if (params.length === 1) {
462
+ // CancellationToken is an interface, so we need to check if the first param complies to it
463
+ if (ProtocolCancellationToken.is(params[0])) {
464
+ token = params[0];
465
+ } else {
466
+ param = params[0];
467
+ }
468
+ } else if (params.length === 2) {
469
+ param = params[0];
470
+ token = params[1];
471
+ }
472
+ if (!(token !== undefined && token.isCancellationRequested)) {
473
+ _context.next = 14;
474
+ break;
475
+ }
476
+ return _context.abrupt("return", Promise.reject(new ResponseError(LSPErrorCodes.RequestCancelled, 'Request got cancelled')));
477
+ case 14:
478
+ _sendRequest = (_this$_clientOptions$2 = this._clientOptions.middleware) === null || _this$_clientOptions$2 === void 0 ? void 0 : _this$_clientOptions$2.sendRequest;
479
+ if (!(_sendRequest !== undefined)) {
480
+ _context.next = 19;
481
+ break;
482
+ }
483
+ return _context.abrupt("return", _sendRequest(type, param, token, function (type, param, token) {
484
+ var params = [];
485
+
486
+ // Add the parameters if there are any
487
+ if (param !== undefined) {
488
+ params.push(param);
489
+ }
490
+
491
+ // Add the cancellation token if there is one
492
+ if (token !== undefined) {
493
+ params.push(token);
494
+ }
495
+ return connection.sendRequest.apply(connection, [type].concat(params));
496
+ }));
497
+ case 19:
498
+ return _context.abrupt("return", connection.sendRequest.apply(connection, [type].concat(params)));
499
+ case 20:
500
+ case "end":
501
+ return _context.stop();
502
+ }
503
+ }, _callee, this);
504
+ }));
505
+ function sendRequest(_x) {
506
+ return _sendRequest2.apply(this, arguments);
507
+ }
508
+ return sendRequest;
509
+ }()
510
+ }, {
511
+ key: "onRequest",
512
+ value: function onRequest(type, handler) {
513
+ var _this2 = this;
514
+ var method = typeof type === 'string' ? type : type.method;
515
+ this._requestHandlers.set(method, handler);
516
+ var connection = this.activeConnection();
517
+ var disposable;
518
+ if (connection !== undefined) {
519
+ this._requestDisposables.set(method, connection.onRequest(type, handler));
520
+ disposable = {
521
+ dispose: function dispose() {
522
+ var disposable = _this2._requestDisposables.get(method);
523
+ if (disposable !== undefined) {
524
+ disposable.dispose();
525
+ _this2._requestDisposables.delete(method);
526
+ }
527
+ }
528
+ };
529
+ } else {
530
+ this._pendingRequestHandlers.set(method, handler);
531
+ disposable = {
532
+ dispose: function dispose() {
533
+ _this2._pendingRequestHandlers.delete(method);
534
+ var disposable = _this2._requestDisposables.get(method);
535
+ if (disposable !== undefined) {
536
+ disposable.dispose();
537
+ _this2._requestDisposables.delete(method);
538
+ }
539
+ }
540
+ };
541
+ }
542
+ return {
543
+ dispose: function dispose() {
544
+ _this2._requestHandlers.delete(method);
545
+ disposable.dispose();
546
+ }
547
+ };
548
+ }
549
+ }, {
550
+ key: "sendNotification",
551
+ value: function () {
552
+ var _sendNotification2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(type, params) {
553
+ var _this$_clientOptions$3;
554
+ var needsPendingFullTextDocumentSync, openNotification, connection, _sendNotification;
555
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
556
+ while (1) switch (_context2.prev = _context2.next) {
557
+ case 0:
558
+ if (!(this.$state === ClientState.StartFailed || this.$state === ClientState.Stopping || this.$state === ClientState.Stopped)) {
559
+ _context2.next = 2;
560
+ break;
561
+ }
562
+ return _context2.abrupt("return", Promise.reject(new ResponseError(ErrorCodes.ConnectionInactive, "Client is not running")));
563
+ case 2:
564
+ needsPendingFullTextDocumentSync = this._didChangeTextDocumentFeature.syncKind === TextDocumentSyncKind.Full;
565
+ if (needsPendingFullTextDocumentSync && typeof type !== 'string' && type.method === DidOpenTextDocumentNotification.method) {
566
+ openNotification = params === null || params === void 0 ? void 0 : params.textDocument.uri;
567
+ this._pendingOpenNotifications.add(openNotification);
568
+ }
569
+ // Ensure we have a connection before we force the document sync.
570
+ _context2.next = 6;
571
+ return this.$start();
572
+ case 6:
573
+ connection = _context2.sent;
574
+ if (!needsPendingFullTextDocumentSync) {
575
+ _context2.next = 10;
576
+ break;
577
+ }
578
+ _context2.next = 10;
579
+ return this.sendPendingFullTextDocumentChanges(connection);
580
+ case 10:
581
+ // We need to remove the pending open notification before we actually
582
+ // send the notification over the connection. Otherwise there could be
583
+ // a request coming in that although the open notification got already put
584
+ // onto the wire will ignore pending document changes.
585
+ //
586
+ // Since the code path of connection.sendNotification is actually sync
587
+ // until the message is handed of to the writer and the writer as a semaphore
588
+ // lock with a capacity of 1 no additional async scheduling can happen until
589
+ // the message is actually handed of.
590
+ if (openNotification !== undefined) {
591
+ this._pendingOpenNotifications.delete(openNotification);
592
+ }
593
+ _sendNotification = (_this$_clientOptions$3 = this._clientOptions.middleware) === null || _this$_clientOptions$3 === void 0 ? void 0 : _this$_clientOptions$3.sendNotification;
594
+ return _context2.abrupt("return", _sendNotification ? _sendNotification(type, connection.sendNotification.bind(connection), params) : connection.sendNotification(type, params));
595
+ case 13:
596
+ case "end":
597
+ return _context2.stop();
598
+ }
599
+ }, _callee2, this);
600
+ }));
601
+ function sendNotification(_x2, _x3) {
602
+ return _sendNotification2.apply(this, arguments);
603
+ }
604
+ return sendNotification;
605
+ }()
606
+ }, {
607
+ key: "onNotification",
608
+ value: function onNotification(type, handler) {
609
+ var _this3 = this;
610
+ var method = typeof type === 'string' ? type : type.method;
611
+ this._notificationHandlers.set(method, handler);
612
+ var connection = this.activeConnection();
613
+ var disposable;
614
+ if (connection !== undefined) {
615
+ this._notificationDisposables.set(method, connection.onNotification(type, handler));
616
+ disposable = {
617
+ dispose: function dispose() {
618
+ var disposable = _this3._notificationDisposables.get(method);
619
+ if (disposable !== undefined) {
620
+ disposable.dispose();
621
+ _this3._notificationDisposables.delete(method);
622
+ }
623
+ }
624
+ };
625
+ } else {
626
+ this._pendingNotificationHandlers.set(method, handler);
627
+ disposable = {
628
+ dispose: function dispose() {
629
+ _this3._pendingNotificationHandlers.delete(method);
630
+ var disposable = _this3._notificationDisposables.get(method);
631
+ if (disposable !== undefined) {
632
+ disposable.dispose();
633
+ _this3._notificationDisposables.delete(method);
634
+ }
635
+ }
636
+ };
637
+ }
638
+ return {
639
+ dispose: function dispose() {
640
+ _this3._notificationHandlers.delete(method);
641
+ disposable.dispose();
642
+ }
643
+ };
644
+ }
645
+ }, {
646
+ key: "sendProgress",
647
+ value: function () {
648
+ var _sendProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(type, token, value) {
649
+ var connection;
650
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
651
+ while (1) switch (_context3.prev = _context3.next) {
652
+ case 0:
653
+ if (!(this.$state === ClientState.StartFailed || this.$state === ClientState.Stopping || this.$state === ClientState.Stopped)) {
654
+ _context3.next = 2;
655
+ break;
656
+ }
657
+ return _context3.abrupt("return", Promise.reject(new ResponseError(ErrorCodes.ConnectionInactive, "Client is not running")));
658
+ case 2:
659
+ _context3.prev = 2;
660
+ _context3.next = 5;
661
+ return this.$start();
662
+ case 5:
663
+ connection = _context3.sent;
664
+ return _context3.abrupt("return", connection.sendProgress(type, token, value));
665
+ case 9:
666
+ _context3.prev = 9;
667
+ _context3.t0 = _context3["catch"](2);
668
+ this.error("Sending progress for token ".concat(token, " failed."), _context3.t0);
669
+ throw _context3.t0;
670
+ case 13:
671
+ case "end":
672
+ return _context3.stop();
673
+ }
674
+ }, _callee3, this, [[2, 9]]);
675
+ }));
676
+ function sendProgress(_x4, _x5, _x6) {
677
+ return _sendProgress.apply(this, arguments);
678
+ }
679
+ return sendProgress;
680
+ }()
681
+ }, {
682
+ key: "onProgress",
683
+ value: function onProgress(type, token, handler) {
684
+ var _this$_clientOptions$4,
685
+ _this4 = this;
686
+ this._progressHandlers.set(token, {
687
+ type: type,
688
+ handler: handler
689
+ });
690
+ var connection = this.activeConnection();
691
+ var disposable;
692
+ var handleWorkDoneProgress = (_this$_clientOptions$4 = this._clientOptions.middleware) === null || _this$_clientOptions$4 === void 0 ? void 0 : _this$_clientOptions$4.handleWorkDoneProgress;
693
+ var realHandler = WorkDoneProgress.is(type) && handleWorkDoneProgress !== undefined ? function (params) {
694
+ handleWorkDoneProgress(token, params, function () {
695
+ return handler(params);
696
+ });
697
+ } : handler;
698
+ if (connection !== undefined) {
699
+ this._progressDisposables.set(token, connection.onProgress(type, token, realHandler));
700
+ disposable = {
701
+ dispose: function dispose() {
702
+ var disposable = _this4._progressDisposables.get(token);
703
+ if (disposable !== undefined) {
704
+ disposable.dispose();
705
+ _this4._progressDisposables.delete(token);
706
+ }
707
+ }
708
+ };
709
+ } else {
710
+ this._pendingProgressHandlers.set(token, {
711
+ type: type,
712
+ handler: handler
713
+ });
714
+ disposable = {
715
+ dispose: function dispose() {
716
+ _this4._pendingProgressHandlers.delete(token);
717
+ var disposable = _this4._progressDisposables.get(token);
718
+ if (disposable !== undefined) {
719
+ disposable.dispose();
720
+ _this4._progressDisposables.delete(token);
721
+ }
722
+ }
723
+ };
724
+ }
725
+ return {
726
+ dispose: function dispose() {
727
+ _this4._progressHandlers.delete(token);
728
+ disposable.dispose();
729
+ }
730
+ };
731
+ }
732
+ }, {
733
+ key: "createDefaultErrorHandler",
734
+ value: function createDefaultErrorHandler(maxRestartCount) {
735
+ if (maxRestartCount !== undefined && maxRestartCount < 0) {
736
+ throw new Error("Invalid maxRestartCount: ".concat(maxRestartCount));
737
+ }
738
+ return new DefaultErrorHandler(this, maxRestartCount !== null && maxRestartCount !== void 0 ? maxRestartCount : 4);
739
+ }
740
+ }, {
741
+ key: "setTrace",
742
+ value: function () {
743
+ var _setTrace = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(value) {
744
+ var connection;
745
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
746
+ while (1) switch (_context4.prev = _context4.next) {
747
+ case 0:
748
+ this._trace = value;
749
+ connection = this.activeConnection();
750
+ if (!(connection !== undefined)) {
751
+ _context4.next = 5;
752
+ break;
753
+ }
754
+ _context4.next = 5;
755
+ return connection.trace(this._trace, this._tracer, {
756
+ sendNotification: false,
757
+ traceFormat: this._traceFormat
758
+ });
759
+ case 5:
760
+ case "end":
761
+ return _context4.stop();
762
+ }
763
+ }, _callee4, this);
764
+ }));
765
+ function setTrace(_x7) {
766
+ return _setTrace.apply(this, arguments);
767
+ }
768
+ return setTrace;
769
+ }()
770
+ }, {
771
+ key: "data2String",
772
+ value: function data2String(data) {
773
+ if (data instanceof ResponseError) {
774
+ var responseError = data;
775
+ return " Message: ".concat(responseError.message, "\n Code: ").concat(responseError.code, " ").concat(responseError.data ? '\n' + responseError.data.toString() : '');
776
+ }
777
+ if (data instanceof Error) {
778
+ if (Is.string(data.stack)) {
779
+ return data.stack;
780
+ }
781
+ return data.message;
782
+ }
783
+ if (Is.string(data)) {
784
+ return data;
785
+ }
786
+ return data.toString();
787
+ }
788
+ }, {
789
+ key: "debug",
790
+ value: function debug(message, data) {
791
+ var showNotification = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
792
+ this.logOutputMessage(MessageType.Debug, RevealOutputChannelOn.Debug, 'Debug', message, data, showNotification);
793
+ }
794
+ }, {
795
+ key: "info",
796
+ value: function info(message, data) {
797
+ var showNotification = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
798
+ this.logOutputMessage(MessageType.Info, RevealOutputChannelOn.Info, 'Info', message, data, showNotification);
799
+ }
800
+ }, {
801
+ key: "warn",
802
+ value: function warn(message, data) {
803
+ var showNotification = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
804
+ this.logOutputMessage(MessageType.Warning, RevealOutputChannelOn.Warn, 'Warn', message, data, showNotification);
805
+ }
806
+ }, {
807
+ key: "error",
808
+ value: function error(message, data) {
809
+ var showNotification = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
810
+ this.logOutputMessage(MessageType.Error, RevealOutputChannelOn.Error, 'Error', message, data, showNotification);
811
+ }
812
+ }, {
813
+ key: "logOutputMessage",
814
+ value: function logOutputMessage(type, reveal, name, message, data, showNotification) {
815
+ this.outputChannel.appendLine("[".concat(name.padEnd(5), " - ").concat(new Date().toLocaleTimeString(), "] ").concat(message));
816
+ if (data !== null && data !== undefined) {
817
+ this.outputChannel.appendLine(this.data2String(data));
818
+ }
819
+ if (showNotification === 'force' || showNotification && this._clientOptions.revealOutputChannelOn <= reveal) {
820
+ this.showNotificationMessage(type, message);
821
+ }
822
+ }
823
+ }, {
824
+ key: "showNotificationMessage",
825
+ value: function showNotificationMessage(type, message) {
826
+ var _message2,
827
+ _this5 = this;
828
+ message = (_message2 = message) !== null && _message2 !== void 0 ? _message2 : 'A request has failed. See the output for more information.';
829
+ var messageFunc = type === MessageType.Error ? Window.showErrorMessage : type === MessageType.Warning ? Window.showWarningMessage : Window.showInformationMessage;
830
+ void messageFunc(message, 'Go to output').then(function (selection) {
831
+ if (selection !== undefined) {
832
+ _this5.outputChannel.show(true);
833
+ }
834
+ });
835
+ }
836
+ }, {
837
+ key: "logTrace",
838
+ value: function logTrace(message, data) {
839
+ this.traceOutputChannel.appendLine("[Trace - ".concat(new Date().toLocaleTimeString(), "] ").concat(message));
840
+ if (data) {
841
+ this.traceOutputChannel.appendLine(this.data2String(data));
842
+ }
843
+ }
844
+ }, {
845
+ key: "logObjectTrace",
846
+ value: function logObjectTrace(data) {
847
+ if (data.isLSPMessage && data.type) {
848
+ this.traceOutputChannel.append("[LSP - ".concat(new Date().toLocaleTimeString(), "] "));
849
+ } else {
850
+ this.traceOutputChannel.append("[Trace - ".concat(new Date().toLocaleTimeString(), "] "));
851
+ }
852
+ if (data) {
853
+ this.traceOutputChannel.appendLine("".concat(JSON.stringify(data)));
854
+ }
855
+ }
856
+ }, {
857
+ key: "needsStart",
858
+ value: function needsStart() {
859
+ return this.$state === ClientState.Initial || this.$state === ClientState.Stopping || this.$state === ClientState.Stopped;
860
+ }
861
+ }, {
862
+ key: "needsStop",
863
+ value: function needsStop() {
864
+ return this.$state === ClientState.Starting || this.$state === ClientState.Running;
865
+ }
866
+ }, {
867
+ key: "activeConnection",
868
+ value: function activeConnection() {
869
+ return this.$state === ClientState.Running && this._connection !== undefined ? this._connection : undefined;
870
+ }
871
+ }, {
872
+ key: "isRunning",
873
+ value: function isRunning() {
874
+ return this.$state === ClientState.Running;
875
+ }
876
+ }, {
877
+ key: "start",
878
+ value: function () {
879
+ var _start = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
880
+ var _this6 = this;
881
+ var _this$createOnStartPr, _this$createOnStartPr2, promise, resolve, reject, _iterator, _step, _step$value, _method, _handler, _iterator2, _step2, _step2$value, _method2, _handler2, _iterator3, _step3, _step3$value, _token, data, connection;
882
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
883
+ while (1) switch (_context7.prev = _context7.next) {
884
+ case 0:
885
+ if (!(this._disposed === 'disposing' || this._disposed === 'disposed')) {
886
+ _context7.next = 2;
887
+ break;
888
+ }
889
+ throw new Error("Client got disposed and can't be restarted.");
890
+ case 2:
891
+ if (!(this.$state === ClientState.Stopping)) {
892
+ _context7.next = 4;
893
+ break;
894
+ }
895
+ throw new Error("Client is currently stopping. Can only restart a full stopped client");
896
+ case 4:
897
+ if (!(this._onStart !== undefined)) {
898
+ _context7.next = 6;
899
+ break;
900
+ }
901
+ return _context7.abrupt("return", this._onStart);
902
+ case 6:
903
+ _this$createOnStartPr = this.createOnStartPromise(), _this$createOnStartPr2 = _slicedToArray(_this$createOnStartPr, 3), promise = _this$createOnStartPr2[0], resolve = _this$createOnStartPr2[1], reject = _this$createOnStartPr2[2];
904
+ this._onStart = promise;
905
+
906
+ // If we restart then the diagnostics collection is reused.
907
+ if (this._diagnostics === undefined) {
908
+ this._diagnostics = this._clientOptions.diagnosticCollectionName ? Languages.createDiagnosticCollection(this._clientOptions.diagnosticCollectionName) : Languages.createDiagnosticCollection();
909
+ }
910
+
911
+ // When we start make all buffer handlers pending so that they
912
+ // get added.
913
+ _iterator = _createForOfIteratorHelper(this._notificationHandlers);
914
+ try {
915
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
916
+ _step$value = _slicedToArray(_step.value, 2), _method = _step$value[0], _handler = _step$value[1];
917
+ if (!this._pendingNotificationHandlers.has(_method)) {
918
+ this._pendingNotificationHandlers.set(_method, _handler);
919
+ }
920
+ }
921
+ } catch (err) {
922
+ _iterator.e(err);
923
+ } finally {
924
+ _iterator.f();
925
+ }
926
+ _iterator2 = _createForOfIteratorHelper(this._requestHandlers);
927
+ try {
928
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
929
+ _step2$value = _slicedToArray(_step2.value, 2), _method2 = _step2$value[0], _handler2 = _step2$value[1];
930
+ if (!this._pendingRequestHandlers.has(_method2)) {
931
+ this._pendingRequestHandlers.set(_method2, _handler2);
932
+ }
933
+ }
934
+ } catch (err) {
935
+ _iterator2.e(err);
936
+ } finally {
937
+ _iterator2.f();
938
+ }
939
+ _iterator3 = _createForOfIteratorHelper(this._progressHandlers);
940
+ try {
941
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
942
+ _step3$value = _slicedToArray(_step3.value, 2), _token = _step3$value[0], data = _step3$value[1];
943
+ if (!this._pendingProgressHandlers.has(_token)) {
944
+ this._pendingProgressHandlers.set(_token, data);
945
+ }
946
+ }
947
+ } catch (err) {
948
+ _iterator3.e(err);
949
+ } finally {
950
+ _iterator3.f();
951
+ }
952
+ this.$state = ClientState.Starting;
953
+ _context7.prev = 16;
954
+ _context7.next = 19;
955
+ return this.createConnection();
956
+ case 19:
957
+ connection = _context7.sent;
958
+ connection.onNotification(LogMessageNotification.type, function (message) {
959
+ switch (message.type) {
960
+ case MessageType.Error:
961
+ _this6.error(message.message, undefined, false);
962
+ break;
963
+ case MessageType.Warning:
964
+ _this6.warn(message.message, undefined, false);
965
+ break;
966
+ case MessageType.Info:
967
+ _this6.info(message.message, undefined, false);
968
+ break;
969
+ case MessageType.Debug:
970
+ _this6.debug(message.message, undefined, false);
971
+ break;
972
+ default:
973
+ _this6.outputChannel.appendLine(message.message);
974
+ }
975
+ });
976
+ connection.onNotification(ShowMessageNotification.type, function (message) {
977
+ switch (message.type) {
978
+ case MessageType.Error:
979
+ void Window.showErrorMessage(message.message);
980
+ break;
981
+ case MessageType.Warning:
982
+ void Window.showWarningMessage(message.message);
983
+ break;
984
+ case MessageType.Info:
985
+ void Window.showInformationMessage(message.message);
986
+ break;
987
+ default:
988
+ void Window.showInformationMessage(message.message);
989
+ }
990
+ });
991
+ connection.onRequest(ShowMessageRequest.type, function (params) {
992
+ var messageFunc;
993
+ switch (params.type) {
994
+ case MessageType.Error:
995
+ messageFunc = Window.showErrorMessage;
996
+ break;
997
+ case MessageType.Warning:
998
+ messageFunc = Window.showWarningMessage;
999
+ break;
1000
+ case MessageType.Info:
1001
+ messageFunc = Window.showInformationMessage;
1002
+ break;
1003
+ default:
1004
+ messageFunc = Window.showInformationMessage;
1005
+ }
1006
+ var actions = params.actions || [];
1007
+ return messageFunc.apply(void 0, [params.message].concat(_toConsumableArray(actions)));
1008
+ });
1009
+ connection.onNotification(TelemetryEventNotification.type, function (data) {
1010
+ _this6._telemetryEmitter.fire(data);
1011
+ });
1012
+ connection.onRequest(ShowDocumentRequest.type, /*#__PURE__*/function () {
1013
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
1014
+ var _this6$_clientOptions;
1015
+ var showDocument, middleware;
1016
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1017
+ while (1) switch (_context6.prev = _context6.next) {
1018
+ case 0:
1019
+ showDocument = /*#__PURE__*/function () {
1020
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
1021
+ var uri, success, options;
1022
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1023
+ while (1) switch (_context5.prev = _context5.next) {
1024
+ case 0:
1025
+ uri = _this6.protocol2CodeConverter.asUri(params.uri);
1026
+ _context5.prev = 1;
1027
+ if (!(params.external === true)) {
1028
+ _context5.next = 9;
1029
+ break;
1030
+ }
1031
+ _context5.next = 5;
1032
+ return Env.openExternal(uri);
1033
+ case 5:
1034
+ success = _context5.sent;
1035
+ return _context5.abrupt("return", {
1036
+ success: success
1037
+ });
1038
+ case 9:
1039
+ options = {};
1040
+ if (params.selection !== undefined) {
1041
+ options.selection = _this6.protocol2CodeConverter.asRange(params.selection);
1042
+ }
1043
+ if (params.takeFocus === undefined || params.takeFocus === false) {
1044
+ options.preserveFocus = true;
1045
+ } else if (params.takeFocus === true) {
1046
+ options.preserveFocus = false;
1047
+ }
1048
+ _context5.next = 14;
1049
+ return Window.showTextDocument(uri, options);
1050
+ case 14:
1051
+ return _context5.abrupt("return", {
1052
+ success: true
1053
+ });
1054
+ case 15:
1055
+ _context5.next = 20;
1056
+ break;
1057
+ case 17:
1058
+ _context5.prev = 17;
1059
+ _context5.t0 = _context5["catch"](1);
1060
+ return _context5.abrupt("return", {
1061
+ success: false
1062
+ });
1063
+ case 20:
1064
+ case "end":
1065
+ return _context5.stop();
1066
+ }
1067
+ }, _callee5, null, [[1, 17]]);
1068
+ }));
1069
+ return function showDocument(_x9) {
1070
+ return _ref2.apply(this, arguments);
1071
+ };
1072
+ }();
1073
+ middleware = (_this6$_clientOptions = _this6._clientOptions.middleware.window) === null || _this6$_clientOptions === void 0 ? void 0 : _this6$_clientOptions.showDocument;
1074
+ if (!(middleware !== undefined)) {
1075
+ _context6.next = 6;
1076
+ break;
1077
+ }
1078
+ return _context6.abrupt("return", middleware(params, showDocument));
1079
+ case 6:
1080
+ return _context6.abrupt("return", showDocument(params));
1081
+ case 7:
1082
+ case "end":
1083
+ return _context6.stop();
1084
+ }
1085
+ }, _callee6);
1086
+ }));
1087
+ return function (_x8) {
1088
+ return _ref.apply(this, arguments);
1089
+ };
1090
+ }());
1091
+ connection.listen();
1092
+ _context7.next = 28;
1093
+ return this.initialize(connection);
1094
+ case 28:
1095
+ resolve();
1096
+ _context7.next = 36;
1097
+ break;
1098
+ case 31:
1099
+ _context7.prev = 31;
1100
+ _context7.t0 = _context7["catch"](16);
1101
+ this.$state = ClientState.StartFailed;
1102
+ this.error("".concat(this._name, " client: couldn't create connection to server."), _context7.t0, 'force');
1103
+ reject(_context7.t0);
1104
+ case 36:
1105
+ return _context7.abrupt("return", this._onStart);
1106
+ case 37:
1107
+ case "end":
1108
+ return _context7.stop();
1109
+ }
1110
+ }, _callee7, this, [[16, 31]]);
1111
+ }));
1112
+ function start() {
1113
+ return _start.apply(this, arguments);
1114
+ }
1115
+ return start;
1116
+ }()
1117
+ }, {
1118
+ key: "createOnStartPromise",
1119
+ value: function createOnStartPromise() {
1120
+ var resolve;
1121
+ var reject;
1122
+ var promise = new Promise(function (_resolve, _reject) {
1123
+ resolve = _resolve;
1124
+ reject = _reject;
1125
+ });
1126
+ return [promise, resolve, reject];
1127
+ }
1128
+ }, {
1129
+ key: "initialize",
1130
+ value: function () {
1131
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(connection) {
1132
+ var initOption, _ref3, _ref4, rootPath, workspaceFolders, initParams, _token2, part, result;
1133
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1134
+ while (1) switch (_context8.prev = _context8.next) {
1135
+ case 0:
1136
+ this.refreshTrace(connection, false);
1137
+ initOption = this._clientOptions.initializationOptions; // If the client is locked to a workspace folder use it. In this case the workspace folder
1138
+ // feature is not registered and we need to initialize the value here.
1139
+ _ref3 = this._clientOptions.workspaceFolder !== undefined ? [this._clientOptions.workspaceFolder.uri.fsPath, [{
1140
+ uri: this._c2p.asUri(this._clientOptions.workspaceFolder.uri),
1141
+ name: this._clientOptions.workspaceFolder.name
1142
+ }]] : [this._clientGetRootPath(), null], _ref4 = _slicedToArray(_ref3, 2), rootPath = _ref4[0], workspaceFolders = _ref4[1];
1143
+ initParams = {
1144
+ processId: null,
1145
+ clientInfo: {
1146
+ name: Env.appName,
1147
+ version: VSCodeVersion
1148
+ },
1149
+ locale: this.getLocale(),
1150
+ rootPath: rootPath ? rootPath : null,
1151
+ rootUri: rootPath ? this._c2p.asUri(Uri.file(rootPath)) : null,
1152
+ capabilities: this.computeClientCapabilities(),
1153
+ initializationOptions: Is.func(initOption) ? initOption() : initOption,
1154
+ trace: Trace.toString(this._trace),
1155
+ workspaceFolders: workspaceFolders
1156
+ };
1157
+ this.fillInitializeParams(initParams);
1158
+ if (!this._clientOptions.progressOnInitialization) {
1159
+ _context8.next = 23;
1160
+ break;
1161
+ }
1162
+ _token2 = UUID.generateUuid();
1163
+ part = new ProgressPart(connection, _token2);
1164
+ initParams.workDoneToken = _token2;
1165
+ _context8.prev = 9;
1166
+ _context8.next = 12;
1167
+ return this.doInitialize(connection, initParams);
1168
+ case 12:
1169
+ result = _context8.sent;
1170
+ part.done();
1171
+ return _context8.abrupt("return", result);
1172
+ case 17:
1173
+ _context8.prev = 17;
1174
+ _context8.t0 = _context8["catch"](9);
1175
+ part.cancel();
1176
+ throw _context8.t0;
1177
+ case 21:
1178
+ _context8.next = 24;
1179
+ break;
1180
+ case 23:
1181
+ return _context8.abrupt("return", this.doInitialize(connection, initParams));
1182
+ case 24:
1183
+ case "end":
1184
+ return _context8.stop();
1185
+ }
1186
+ }, _callee8, this, [[9, 17]]);
1187
+ }));
1188
+ function initialize(_x10) {
1189
+ return _initialize.apply(this, arguments);
1190
+ }
1191
+ return initialize;
1192
+ }()
1193
+ }, {
1194
+ key: "doInitialize",
1195
+ value: function () {
1196
+ var _doInitialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(connection, initParams) {
1197
+ var _this7 = this;
1198
+ var result, textDocumentSyncOptions, _iterator4, _step4, _step4$value, _method3, _handler3, _iterator5, _step5, _step5$value, _method4, _handler4, _iterator6, _step6, _step6$value, _token3, data;
1199
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1200
+ while (1) switch (_context9.prev = _context9.next) {
1201
+ case 0:
1202
+ _context9.prev = 0;
1203
+ _context9.next = 3;
1204
+ return connection.initialize(initParams);
1205
+ case 3:
1206
+ result = _context9.sent;
1207
+ if (!(result.capabilities.positionEncoding !== undefined && result.capabilities.positionEncoding !== PositionEncodingKind.UTF16)) {
1208
+ _context9.next = 6;
1209
+ break;
1210
+ }
1211
+ throw new Error("Unsupported position encoding (".concat(result.capabilities.positionEncoding, ") received from server ").concat(this.name));
1212
+ case 6:
1213
+ this._initializeResult = result;
1214
+ this.$state = ClientState.Running;
1215
+ textDocumentSyncOptions = undefined;
1216
+ if (Is.number(result.capabilities.textDocumentSync)) {
1217
+ if (result.capabilities.textDocumentSync === TextDocumentSyncKind.None) {
1218
+ textDocumentSyncOptions = {
1219
+ openClose: false,
1220
+ change: TextDocumentSyncKind.None,
1221
+ save: undefined
1222
+ };
1223
+ } else {
1224
+ textDocumentSyncOptions = {
1225
+ openClose: true,
1226
+ change: result.capabilities.textDocumentSync,
1227
+ save: {
1228
+ includeText: false
1229
+ }
1230
+ };
1231
+ }
1232
+ } else if (result.capabilities.textDocumentSync !== undefined && result.capabilities.textDocumentSync !== null) {
1233
+ textDocumentSyncOptions = result.capabilities.textDocumentSync;
1234
+ }
1235
+ this._capabilities = Object.assign({}, result.capabilities, {
1236
+ resolvedTextDocumentSync: textDocumentSyncOptions
1237
+ });
1238
+ connection.onNotification(PublishDiagnosticsNotification.type, function (params) {
1239
+ return _this7.handleDiagnostics(params);
1240
+ });
1241
+ connection.onRequest(RegistrationRequest.type, function (params) {
1242
+ return _this7.handleRegistrationRequest(params);
1243
+ });
1244
+ // See https://github.com/Microsoft/vscode-languageserver-node/issues/199
1245
+ connection.onRequest('client/registerFeature', function (params) {
1246
+ return _this7.handleRegistrationRequest(params);
1247
+ });
1248
+ connection.onRequest(UnregistrationRequest.type, function (params) {
1249
+ return _this7.handleUnregistrationRequest(params);
1250
+ });
1251
+ // See https://github.com/Microsoft/vscode-languageserver-node/issues/199
1252
+ connection.onRequest('client/unregisterFeature', function (params) {
1253
+ return _this7.handleUnregistrationRequest(params);
1254
+ });
1255
+ connection.onRequest(ApplyWorkspaceEditRequest.type, function (params) {
1256
+ return _this7.handleApplyWorkspaceEdit(params);
1257
+ });
1258
+
1259
+ // Add pending notification, request and progress handlers.
1260
+ _iterator4 = _createForOfIteratorHelper(this._pendingNotificationHandlers);
1261
+ try {
1262
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1263
+ _step4$value = _slicedToArray(_step4.value, 2), _method3 = _step4$value[0], _handler3 = _step4$value[1];
1264
+ this._notificationDisposables.set(_method3, connection.onNotification(_method3, _handler3));
1265
+ }
1266
+ } catch (err) {
1267
+ _iterator4.e(err);
1268
+ } finally {
1269
+ _iterator4.f();
1270
+ }
1271
+ this._pendingNotificationHandlers.clear();
1272
+ _iterator5 = _createForOfIteratorHelper(this._pendingRequestHandlers);
1273
+ try {
1274
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1275
+ _step5$value = _slicedToArray(_step5.value, 2), _method4 = _step5$value[0], _handler4 = _step5$value[1];
1276
+ this._requestDisposables.set(_method4, connection.onRequest(_method4, _handler4));
1277
+ }
1278
+ } catch (err) {
1279
+ _iterator5.e(err);
1280
+ } finally {
1281
+ _iterator5.f();
1282
+ }
1283
+ this._pendingRequestHandlers.clear();
1284
+ _iterator6 = _createForOfIteratorHelper(this._pendingProgressHandlers);
1285
+ try {
1286
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1287
+ _step6$value = _slicedToArray(_step6.value, 2), _token3 = _step6$value[0], data = _step6$value[1];
1288
+ this._progressDisposables.set(_token3, connection.onProgress(data.type, _token3, data.handler));
1289
+ }
1290
+ } catch (err) {
1291
+ _iterator6.e(err);
1292
+ } finally {
1293
+ _iterator6.f();
1294
+ }
1295
+ this._pendingProgressHandlers.clear();
1296
+
1297
+ // if (this._clientOptions.suspend.mode !== SuspendMode.off) {
1298
+ // this._idleInterval = RAL().timer.setInterval(() => this.checkSuspend(), this._clientOptions.suspend.interval);
1299
+ // }
1300
+ _context9.next = 28;
1301
+ return connection.sendNotification(InitializedNotification.type, {});
1302
+ case 28:
1303
+ this.hookFileEvents(connection);
1304
+ this.hookConfigurationChanged(connection);
1305
+ this.initializeFeatures(connection);
1306
+ return _context9.abrupt("return", result);
1307
+ case 34:
1308
+ _context9.prev = 34;
1309
+ _context9.t0 = _context9["catch"](0);
1310
+ if (this._clientOptions.initializationFailedHandler) {
1311
+ if (this._clientOptions.initializationFailedHandler(_context9.t0)) {
1312
+ void this.initialize(connection);
1313
+ } else {
1314
+ void this.stop();
1315
+ }
1316
+ } else if (_context9.t0 instanceof ResponseError && _context9.t0.data && _context9.t0.data.retry) {
1317
+ void Window.showErrorMessage(_context9.t0.message, {
1318
+ title: 'Retry',
1319
+ id: 'retry'
1320
+ }).then(function (item) {
1321
+ if (item && item.id === 'retry') {
1322
+ void _this7.initialize(connection);
1323
+ } else {
1324
+ void _this7.stop();
1325
+ }
1326
+ });
1327
+ } else {
1328
+ if (_context9.t0 && _context9.t0.message) {
1329
+ void Window.showErrorMessage(_context9.t0.message);
1330
+ }
1331
+ this.error('Server initialization failed.', _context9.t0);
1332
+ void this.stop();
1333
+ }
1334
+ throw _context9.t0;
1335
+ case 38:
1336
+ case "end":
1337
+ return _context9.stop();
1338
+ }
1339
+ }, _callee9, this, [[0, 34]]);
1340
+ }));
1341
+ function doInitialize(_x11, _x12) {
1342
+ return _doInitialize.apply(this, arguments);
1343
+ }
1344
+ return doInitialize;
1345
+ }()
1346
+ }, {
1347
+ key: "_clientGetRootPath",
1348
+ value: function _clientGetRootPath() {
1349
+ var folders = Workspace.workspaceFolders;
1350
+ if (!folders || folders.length === 0) {
1351
+ return undefined;
1352
+ }
1353
+ var folder = folders[0];
1354
+ if (folder.uri.scheme === 'file') {
1355
+ return folder.uri.fsPath;
1356
+ }
1357
+ return undefined;
1358
+ }
1359
+ }, {
1360
+ key: "stop",
1361
+ value: function stop() {
1362
+ var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2000;
1363
+ // Wait 2 seconds on stop
1364
+ return this.shutdown('stop', timeout);
1365
+ }
1366
+ }, {
1367
+ key: "dispose",
1368
+ value: function dispose() {
1369
+ var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2000;
1370
+ try {
1371
+ this._disposed = 'disposing';
1372
+ return this.stop(timeout);
1373
+ } finally {
1374
+ this._disposed = 'disposed';
1375
+ }
1376
+ }
1377
+ }, {
1378
+ key: "shutdown",
1379
+ value: function () {
1380
+ var _shutdown = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(mode, timeout) {
1381
+ var _this8 = this;
1382
+ var connection, tp, shutdown;
1383
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1384
+ while (1) switch (_context11.prev = _context11.next) {
1385
+ case 0:
1386
+ if (!(this.$state === ClientState.Stopped || this.$state === ClientState.Initial)) {
1387
+ _context11.next = 2;
1388
+ break;
1389
+ }
1390
+ return _context11.abrupt("return");
1391
+ case 2:
1392
+ if (!(this.$state === ClientState.Stopping)) {
1393
+ _context11.next = 8;
1394
+ break;
1395
+ }
1396
+ if (!(this._onStop !== undefined)) {
1397
+ _context11.next = 7;
1398
+ break;
1399
+ }
1400
+ return _context11.abrupt("return", this._onStop);
1401
+ case 7:
1402
+ throw new Error("Client ".concat(this.name, " is stopping but no stop promise available."));
1403
+ case 8:
1404
+ connection = this.activeConnection(); // We can't stop a client that is not running (e.g. has no connection). Especially not
1405
+ // on that us starting since it can't be correctly synchronized.
1406
+ if (!(connection === undefined || this.$state !== ClientState.Running)) {
1407
+ _context11.next = 11;
1408
+ break;
1409
+ }
1410
+ throw new Error("Client ".concat(this.name, " is not running and can't be stopped. It's current state is: ").concat(this.$state));
1411
+ case 11:
1412
+ this._initializeResult = undefined;
1413
+ this.$state = ClientState.Stopping;
1414
+ this.cleanUp(mode);
1415
+
1416
+ // eslint-disable-next-line promise/param-names
1417
+ tp = new Promise(function (c) {
1418
+ RAL().timer.setTimeout(c, timeout);
1419
+ });
1420
+ shutdown = function () {
1421
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(connection) {
1422
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1423
+ while (1) switch (_context10.prev = _context10.next) {
1424
+ case 0:
1425
+ _context10.next = 2;
1426
+ return connection.shutdown();
1427
+ case 2:
1428
+ _context10.next = 4;
1429
+ return connection.exit();
1430
+ case 4:
1431
+ return _context10.abrupt("return", connection);
1432
+ case 5:
1433
+ case "end":
1434
+ return _context10.stop();
1435
+ }
1436
+ }, _callee10);
1437
+ }));
1438
+ return function (_x15) {
1439
+ return _ref5.apply(this, arguments);
1440
+ };
1441
+ }()(connection);
1442
+ return _context11.abrupt("return", this._onStop = Promise.race([tp, shutdown]).then(function (connection) {
1443
+ // The connection won the race with the timeout.
1444
+ if (connection !== undefined) {
1445
+ connection.end();
1446
+ connection.dispose();
1447
+ } else {
1448
+ _this8.error("Stopping server timed out", undefined, false);
1449
+ throw new Error("Stopping the server timed out");
1450
+ }
1451
+ }, function (error) {
1452
+ _this8.error("Stopping server failed", error, false);
1453
+ throw error;
1454
+ }).finally(function () {
1455
+ _this8.$state = ClientState.Stopped;
1456
+ mode === 'stop' && _this8.cleanUpChannel();
1457
+ _this8._onStart = undefined;
1458
+ _this8._onStop = undefined;
1459
+ _this8._connection = undefined;
1460
+ _this8._ignoredRegistrations.clear();
1461
+ }));
1462
+ case 17:
1463
+ case "end":
1464
+ return _context11.stop();
1465
+ }
1466
+ }, _callee11, this);
1467
+ }));
1468
+ function shutdown(_x13, _x14) {
1469
+ return _shutdown.apply(this, arguments);
1470
+ }
1471
+ return shutdown;
1472
+ }()
1473
+ }, {
1474
+ key: "cleanUp",
1475
+ value: function cleanUp(mode) {
1476
+ // purge outstanding file events.
1477
+ this._fileEvents = [];
1478
+ this._fileEventDelayer.cancel();
1479
+ var disposables = this._listeners.splice(0, this._listeners.length);
1480
+ var _iterator7 = _createForOfIteratorHelper(disposables),
1481
+ _step7;
1482
+ try {
1483
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1484
+ var disposable = _step7.value;
1485
+ disposable.dispose();
1486
+ }
1487
+ } catch (err) {
1488
+ _iterator7.e(err);
1489
+ } finally {
1490
+ _iterator7.f();
1491
+ }
1492
+ if (this._syncedDocuments) {
1493
+ this._syncedDocuments.clear();
1494
+ }
1495
+ // Clear features in reverse order;
1496
+ var _iterator8 = _createForOfIteratorHelper(Array.from(this._features.entries()).map(function (entry) {
1497
+ return entry[1];
1498
+ }).reverse()),
1499
+ _step8;
1500
+ try {
1501
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1502
+ var feature = _step8.value;
1503
+ feature.clear();
1504
+ }
1505
+ } catch (err) {
1506
+ _iterator8.e(err);
1507
+ } finally {
1508
+ _iterator8.f();
1509
+ }
1510
+ if (mode === 'stop' && this._diagnostics !== undefined) {
1511
+ this._diagnostics.dispose();
1512
+ this._diagnostics = undefined;
1513
+ }
1514
+ if (this._idleInterval !== undefined) {
1515
+ this._idleInterval.dispose();
1516
+ this._idleInterval = undefined;
1517
+ }
1518
+ // this._idleStart = undefined;
1519
+ }
1520
+ }, {
1521
+ key: "cleanUpChannel",
1522
+ value: function cleanUpChannel() {
1523
+ if (this._outputChannel !== undefined && this._disposeOutputChannel) {
1524
+ this._outputChannel.dispose();
1525
+ this._outputChannel = undefined;
1526
+ }
1527
+ }
1528
+ }, {
1529
+ key: "notifyFileEvent",
1530
+ value: function notifyFileEvent(event) {
1531
+ var _this$clientOptions$m;
1532
+ var client = this;
1533
+ function didChangeWatchedFile(_x16) {
1534
+ return _didChangeWatchedFile.apply(this, arguments);
1535
+ }
1536
+ function _didChangeWatchedFile() {
1537
+ _didChangeWatchedFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(event) {
1538
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1539
+ while (1) switch (_context13.prev = _context13.next) {
1540
+ case 0:
1541
+ client._fileEvents.push(event);
1542
+ return _context13.abrupt("return", client._fileEventDelayer.trigger( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1543
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1544
+ while (1) switch (_context12.prev = _context12.next) {
1545
+ case 0:
1546
+ _context12.next = 2;
1547
+ return client.sendNotification(DidChangeWatchedFilesNotification.type, {
1548
+ changes: client._fileEvents
1549
+ });
1550
+ case 2:
1551
+ client._fileEvents = [];
1552
+ case 3:
1553
+ case "end":
1554
+ return _context12.stop();
1555
+ }
1556
+ }, _callee12);
1557
+ }))));
1558
+ case 2:
1559
+ case "end":
1560
+ return _context13.stop();
1561
+ }
1562
+ }, _callee13);
1563
+ }));
1564
+ return _didChangeWatchedFile.apply(this, arguments);
1565
+ }
1566
+ var workSpaceMiddleware = (_this$clientOptions$m = this.clientOptions.middleware) === null || _this$clientOptions$m === void 0 ? void 0 : _this$clientOptions$m.workspace;
1567
+ (workSpaceMiddleware !== null && workSpaceMiddleware !== void 0 && workSpaceMiddleware.didChangeWatchedFile ? workSpaceMiddleware.didChangeWatchedFile(event, didChangeWatchedFile) : didChangeWatchedFile(event)).catch(function (error) {
1568
+ client.error("Notify file events failed.", error);
1569
+ });
1570
+ }
1571
+ }, {
1572
+ key: "sendPendingFullTextDocumentChanges",
1573
+ value: function () {
1574
+ var _sendPendingFullTextDocumentChanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(connection) {
1575
+ var _this9 = this;
1576
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1577
+ while (1) switch (_context15.prev = _context15.next) {
1578
+ case 0:
1579
+ return _context15.abrupt("return", this._pendingChangeSemaphore.lock( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1580
+ var changes, _iterator9, _step9, document, _params;
1581
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1582
+ while (1) switch (_context14.prev = _context14.next) {
1583
+ case 0:
1584
+ _context14.prev = 0;
1585
+ changes = _this9._didChangeTextDocumentFeature.getPendingDocumentChanges(_this9._pendingOpenNotifications);
1586
+ if (!(changes.length === 0)) {
1587
+ _context14.next = 4;
1588
+ break;
1589
+ }
1590
+ return _context14.abrupt("return");
1591
+ case 4:
1592
+ _iterator9 = _createForOfIteratorHelper(changes);
1593
+ _context14.prev = 5;
1594
+ _iterator9.s();
1595
+ case 7:
1596
+ if ((_step9 = _iterator9.n()).done) {
1597
+ _context14.next = 15;
1598
+ break;
1599
+ }
1600
+ document = _step9.value;
1601
+ _params = _this9.code2ProtocolConverter.asChangeTextDocumentParams(document); // We await the send and not the delivery since it is more or less the same for
1602
+ // notifications.
1603
+ _context14.next = 12;
1604
+ return connection.sendNotification(DidChangeTextDocumentNotification.type, _params);
1605
+ case 12:
1606
+ _this9._didChangeTextDocumentFeature.notificationSent(document, DidChangeTextDocumentNotification.type, _params);
1607
+ case 13:
1608
+ _context14.next = 7;
1609
+ break;
1610
+ case 15:
1611
+ _context14.next = 20;
1612
+ break;
1613
+ case 17:
1614
+ _context14.prev = 17;
1615
+ _context14.t0 = _context14["catch"](5);
1616
+ _iterator9.e(_context14.t0);
1617
+ case 20:
1618
+ _context14.prev = 20;
1619
+ _iterator9.f();
1620
+ return _context14.finish(20);
1621
+ case 23:
1622
+ _context14.next = 29;
1623
+ break;
1624
+ case 25:
1625
+ _context14.prev = 25;
1626
+ _context14.t1 = _context14["catch"](0);
1627
+ _this9.error("Sending pending changes failed", _context14.t1, false);
1628
+ throw _context14.t1;
1629
+ case 29:
1630
+ case "end":
1631
+ return _context14.stop();
1632
+ }
1633
+ }, _callee14, null, [[0, 25], [5, 17, 20, 23]]);
1634
+ }))));
1635
+ case 1:
1636
+ case "end":
1637
+ return _context15.stop();
1638
+ }
1639
+ }, _callee15, this);
1640
+ }));
1641
+ function sendPendingFullTextDocumentChanges(_x17) {
1642
+ return _sendPendingFullTextDocumentChanges.apply(this, arguments);
1643
+ }
1644
+ return sendPendingFullTextDocumentChanges;
1645
+ }()
1646
+ }, {
1647
+ key: "triggerPendingChangeDelivery",
1648
+ value: function triggerPendingChangeDelivery() {
1649
+ var _this10 = this;
1650
+ this._pendingChangeDelayer.trigger( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1651
+ var connection;
1652
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1653
+ while (1) switch (_context16.prev = _context16.next) {
1654
+ case 0:
1655
+ connection = _this10.activeConnection();
1656
+ if (!(connection === undefined)) {
1657
+ _context16.next = 4;
1658
+ break;
1659
+ }
1660
+ _this10.triggerPendingChangeDelivery();
1661
+ return _context16.abrupt("return");
1662
+ case 4:
1663
+ _context16.next = 6;
1664
+ return _this10.sendPendingFullTextDocumentChanges(connection);
1665
+ case 6:
1666
+ case "end":
1667
+ return _context16.stop();
1668
+ }
1669
+ }, _callee16);
1670
+ }))).catch(function (error) {
1671
+ return _this10.error("Delivering pending changes failed", error, false);
1672
+ });
1673
+ }
1674
+ }, {
1675
+ key: "handleDiagnostics",
1676
+ value: function handleDiagnostics(params) {
1677
+ if (!this._diagnostics) {
1678
+ return;
1679
+ }
1680
+ var key = params.uri;
1681
+ if (this._diagnosticQueueState.state === 'busy' && this._diagnosticQueueState.document === key) {
1682
+ // Cancel the active run;
1683
+ this._diagnosticQueueState.tokenSource.cancel();
1684
+ }
1685
+ this._diagnosticQueue.set(params.uri, params.diagnostics);
1686
+ this.triggerDiagnosticQueue();
1687
+ }
1688
+ }, {
1689
+ key: "triggerDiagnosticQueue",
1690
+ value: function triggerDiagnosticQueue() {
1691
+ var _this11 = this;
1692
+ RAL().timer.setImmediate(function () {
1693
+ _this11.workDiagnosticQueue();
1694
+ });
1695
+ }
1696
+ }, {
1697
+ key: "workDiagnosticQueue",
1698
+ value: function workDiagnosticQueue() {
1699
+ var _this12 = this;
1700
+ if (this._diagnosticQueueState.state === 'busy') {
1701
+ return;
1702
+ }
1703
+ var next = this._diagnosticQueue.entries().next();
1704
+ if (next.done === true) {
1705
+ // Nothing in the queue
1706
+ return;
1707
+ }
1708
+ var _next$value = _slicedToArray(next.value, 2),
1709
+ document = _next$value[0],
1710
+ diagnostics = _next$value[1];
1711
+ this._diagnosticQueue.delete(document);
1712
+ var tokenSource = new CancellationTokenSource();
1713
+ this._diagnosticQueueState = {
1714
+ state: 'busy',
1715
+ document: document,
1716
+ tokenSource: tokenSource
1717
+ };
1718
+ this._p2c.asDiagnostics(diagnostics, tokenSource.token).then(function (converted) {
1719
+ if (!tokenSource.token.isCancellationRequested) {
1720
+ var _uri = _this12._p2c.asUri(document);
1721
+ var middleware = _this12.clientOptions.middleware;
1722
+ if (middleware.handleDiagnostics) {
1723
+ middleware.handleDiagnostics(_uri, converted, function (uri, diagnostics) {
1724
+ return _this12.setDiagnostics(uri, diagnostics);
1725
+ });
1726
+ } else {
1727
+ _this12.setDiagnostics(_uri, converted);
1728
+ }
1729
+ }
1730
+ }).catch(function (error) {
1731
+ _this12.error("Processing diagnostic queue failed.", error);
1732
+ }).finally(function () {
1733
+ _this12._diagnosticQueueState = {
1734
+ state: 'idle'
1735
+ };
1736
+ _this12.triggerDiagnosticQueue();
1737
+ });
1738
+ }
1739
+ }, {
1740
+ key: "setDiagnostics",
1741
+ value: function setDiagnostics(uri, diagnostics) {
1742
+ if (!this._diagnostics) {
1743
+ return;
1744
+ }
1745
+ this._diagnostics.set(uri, diagnostics);
1746
+ }
1747
+ }, {
1748
+ key: "getLocale",
1749
+ value: function getLocale() {
1750
+ return Env.language;
1751
+ }
1752
+ }, {
1753
+ key: "$start",
1754
+ value: function () {
1755
+ var _$start = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1756
+ var connection;
1757
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1758
+ while (1) switch (_context17.prev = _context17.next) {
1759
+ case 0:
1760
+ if (!(this.$state === ClientState.StartFailed)) {
1761
+ _context17.next = 2;
1762
+ break;
1763
+ }
1764
+ throw new Error("Previous start failed. Can't restart server.");
1765
+ case 2:
1766
+ _context17.next = 4;
1767
+ return this.start();
1768
+ case 4:
1769
+ connection = this.activeConnection();
1770
+ if (!(connection === undefined)) {
1771
+ _context17.next = 7;
1772
+ break;
1773
+ }
1774
+ throw new Error("Starting server failed");
1775
+ case 7:
1776
+ return _context17.abrupt("return", connection);
1777
+ case 8:
1778
+ case "end":
1779
+ return _context17.stop();
1780
+ }
1781
+ }, _callee17, this);
1782
+ }));
1783
+ function $start() {
1784
+ return _$start.apply(this, arguments);
1785
+ }
1786
+ return $start;
1787
+ }()
1788
+ }, {
1789
+ key: "createConnection",
1790
+ value: function () {
1791
+ var _createConnection2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1792
+ var _this13 = this;
1793
+ var errorHandler, closeHandler, transports;
1794
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1795
+ while (1) switch (_context18.prev = _context18.next) {
1796
+ case 0:
1797
+ errorHandler = function errorHandler(error, message, count) {
1798
+ _this13.handleConnectionError(error, message, count).catch(function (error) {
1799
+ return _this13.error("Handling connection error failed", error);
1800
+ });
1801
+ };
1802
+ closeHandler = function closeHandler() {
1803
+ _this13.handleConnectionClosed().catch(function (error) {
1804
+ return _this13.error("Handling connection close failed", error);
1805
+ });
1806
+ };
1807
+ _context18.next = 4;
1808
+ return this.createMessageTransports(this._clientOptions.stdioEncoding || 'utf8');
1809
+ case 4:
1810
+ transports = _context18.sent;
1811
+ this._connection = _createConnection(transports.reader, transports.writer, errorHandler, closeHandler, this._clientOptions.connectionOptions);
1812
+ return _context18.abrupt("return", this._connection);
1813
+ case 7:
1814
+ case "end":
1815
+ return _context18.stop();
1816
+ }
1817
+ }, _callee18, this);
1818
+ }));
1819
+ function createConnection() {
1820
+ return _createConnection2.apply(this, arguments);
1821
+ }
1822
+ return createConnection;
1823
+ }()
1824
+ }, {
1825
+ key: "handleConnectionClosed",
1826
+ value: function () {
1827
+ var _handleConnectionClosed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1828
+ var _this14 = this;
1829
+ var handlerResult, _handlerResult$messag, _handlerResult$messag2;
1830
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1831
+ while (1) switch (_context19.prev = _context19.next) {
1832
+ case 0:
1833
+ if (!(this.$state === ClientState.Stopped)) {
1834
+ _context19.next = 2;
1835
+ break;
1836
+ }
1837
+ return _context19.abrupt("return");
1838
+ case 2:
1839
+ try {
1840
+ if (this._connection !== undefined) {
1841
+ this._connection.dispose();
1842
+ }
1843
+ } catch (error) {
1844
+ // Disposing a connection could fail if error cases.
1845
+ }
1846
+ handlerResult = {
1847
+ action: CloseAction.DoNotRestart
1848
+ };
1849
+ if (!(this.$state !== ClientState.Stopping)) {
1850
+ _context19.next = 13;
1851
+ break;
1852
+ }
1853
+ _context19.prev = 5;
1854
+ _context19.next = 8;
1855
+ return this._clientOptions.errorHandler.closed();
1856
+ case 8:
1857
+ handlerResult = _context19.sent;
1858
+ _context19.next = 13;
1859
+ break;
1860
+ case 11:
1861
+ _context19.prev = 11;
1862
+ _context19.t0 = _context19["catch"](5);
1863
+ case 13:
1864
+ this._connection = undefined;
1865
+ if (handlerResult.action === CloseAction.DoNotRestart) {
1866
+ this.error((_handlerResult$messag = handlerResult.message) !== null && _handlerResult$messag !== void 0 ? _handlerResult$messag : 'Connection to server got closed. Server will not be restarted.', undefined, handlerResult.handled === true ? false : 'force');
1867
+ this.cleanUp('stop');
1868
+ if (this.$state === ClientState.Starting) {
1869
+ this.$state = ClientState.StartFailed;
1870
+ } else {
1871
+ this.$state = ClientState.Stopped;
1872
+ }
1873
+ this._onStop = Promise.resolve();
1874
+ this._onStart = undefined;
1875
+ } else if (handlerResult.action === CloseAction.Restart) {
1876
+ this.info((_handlerResult$messag2 = handlerResult.message) !== null && _handlerResult$messag2 !== void 0 ? _handlerResult$messag2 : 'Connection to server got closed. Server will restart.', !handlerResult.handled);
1877
+ this.cleanUp('restart');
1878
+ this.$state = ClientState.Initial;
1879
+ this._onStop = Promise.resolve();
1880
+ this._onStart = undefined;
1881
+ this.start().catch(function (error) {
1882
+ return _this14.error("Restarting server failed", error, 'force');
1883
+ });
1884
+ }
1885
+ case 15:
1886
+ case "end":
1887
+ return _context19.stop();
1888
+ }
1889
+ }, _callee19, this, [[5, 11]]);
1890
+ }));
1891
+ function handleConnectionClosed() {
1892
+ return _handleConnectionClosed.apply(this, arguments);
1893
+ }
1894
+ return handleConnectionClosed;
1895
+ }()
1896
+ }, {
1897
+ key: "handleConnectionError",
1898
+ value: function () {
1899
+ var _handleConnectionError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(error, message, count) {
1900
+ var _this15 = this;
1901
+ var handlerResult, _handlerResult$messag3, _handlerResult$messag4;
1902
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1903
+ while (1) switch (_context20.prev = _context20.next) {
1904
+ case 0:
1905
+ _context20.next = 2;
1906
+ return this._clientOptions.errorHandler.error(error, message, count);
1907
+ case 2:
1908
+ handlerResult = _context20.sent;
1909
+ if (handlerResult.action === ErrorAction.Shutdown) {
1910
+ this.error((_handlerResult$messag3 = handlerResult.message) !== null && _handlerResult$messag3 !== void 0 ? _handlerResult$messag3 : "Client ".concat(this._name, ": connection to server is erroring.\n").concat(error.message, "\nShutting down server."), undefined, handlerResult.handled === true ? false : 'force');
1911
+ this.stop().catch(function (error) {
1912
+ _this15.error("Stopping server failed", error, false);
1913
+ });
1914
+ } else {
1915
+ this.error((_handlerResult$messag4 = handlerResult.message) !== null && _handlerResult$messag4 !== void 0 ? _handlerResult$messag4 : "Client ".concat(this._name, ": connection to server is erroring.\n").concat(error.message), undefined, handlerResult.handled === true ? false : 'force');
1916
+ }
1917
+ case 4:
1918
+ case "end":
1919
+ return _context20.stop();
1920
+ }
1921
+ }, _callee20, this);
1922
+ }));
1923
+ function handleConnectionError(_x18, _x19, _x20) {
1924
+ return _handleConnectionError.apply(this, arguments);
1925
+ }
1926
+ return handleConnectionError;
1927
+ }()
1928
+ }, {
1929
+ key: "hookConfigurationChanged",
1930
+ value: function hookConfigurationChanged(connection) {
1931
+ var _this16 = this;
1932
+ this._listeners.push(Workspace.onDidChangeConfiguration(function () {
1933
+ _this16.refreshTrace(connection, true);
1934
+ }));
1935
+ }
1936
+ }, {
1937
+ key: "refreshTrace",
1938
+ value: function refreshTrace(connection) {
1939
+ var _this17 = this;
1940
+ var sendNotification = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1941
+ var config = Workspace.getConfiguration(this._id);
1942
+ var trace = Trace.Off;
1943
+ var traceFormat = TraceFormat.Text;
1944
+ if (config) {
1945
+ var traceConfig = config.get('trace.server', 'off');
1946
+ if (typeof traceConfig === 'string') {
1947
+ trace = Trace.fromString(traceConfig);
1948
+ } else {
1949
+ trace = Trace.fromString(config.get('trace.server.verbosity', 'off'));
1950
+ traceFormat = TraceFormat.fromString(config.get('trace.server.format', 'text'));
1951
+ }
1952
+ }
1953
+ this._trace = trace;
1954
+ this._traceFormat = traceFormat;
1955
+ connection.trace(this._trace, this._tracer, {
1956
+ sendNotification: sendNotification,
1957
+ traceFormat: this._traceFormat
1958
+ }).catch(function (error) {
1959
+ _this17.error("Updating trace failed with error", error, false);
1960
+ });
1961
+ }
1962
+ }, {
1963
+ key: "hookFileEvents",
1964
+ value: function hookFileEvents(_connection) {
1965
+ var fileEvents = this._clientOptions.synchronize.fileEvents;
1966
+ if (!fileEvents) {
1967
+ return;
1968
+ }
1969
+ var watchers;
1970
+ if (Is.array(fileEvents)) {
1971
+ watchers = fileEvents;
1972
+ } else {
1973
+ watchers = [fileEvents];
1974
+ }
1975
+ if (!watchers) {
1976
+ return;
1977
+ }
1978
+ this._dynamicFeatures.get(DidChangeWatchedFilesNotification.type.method).registerRaw(UUID.generateUuid(), watchers);
1979
+ }
1980
+ }, {
1981
+ key: "registerFeatures",
1982
+ value: function registerFeatures(features) {
1983
+ var _iterator10 = _createForOfIteratorHelper(features),
1984
+ _step10;
1985
+ try {
1986
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
1987
+ var feature = _step10.value;
1988
+ this.registerFeature(feature);
1989
+ }
1990
+ } catch (err) {
1991
+ _iterator10.e(err);
1992
+ } finally {
1993
+ _iterator10.f();
1994
+ }
1995
+ }
1996
+ }, {
1997
+ key: "registerFeature",
1998
+ value: function registerFeature(feature) {
1999
+ this._features.push(feature);
2000
+ if (DynamicFeature.is(feature)) {
2001
+ var registrationType = feature.registrationType;
2002
+ this._dynamicFeatures.set(registrationType.method, feature);
2003
+ }
2004
+ }
2005
+ }, {
2006
+ key: "getFeature",
2007
+ value: function getFeature(request) {
2008
+ return this._dynamicFeatures.get(request);
2009
+ }
2010
+ }, {
2011
+ key: "hasDedicatedTextSynchronizationFeature",
2012
+ value: function hasDedicatedTextSynchronizationFeature(textDocument) {
2013
+ var feature = this.getFeature(NotebookDocumentSyncRegistrationType.method);
2014
+ if (feature === undefined || !(feature instanceof NotebookDocumentSyncFeature)) {
2015
+ return false;
2016
+ }
2017
+ return feature.handles(textDocument);
2018
+ }
2019
+ }, {
2020
+ key: "registerBuiltinFeatures",
2021
+ value: function registerBuiltinFeatures() {
2022
+ var _this18 = this;
2023
+ var pendingFullTextDocumentChanges = new Map();
2024
+ this.registerFeature(new ConfigurationFeature(this));
2025
+ this.registerFeature(new DidOpenTextDocumentFeature(this, this._syncedDocuments));
2026
+ this._didChangeTextDocumentFeature = new DidChangeTextDocumentFeature(this, pendingFullTextDocumentChanges);
2027
+ this._didChangeTextDocumentFeature.onPendingChangeAdded(function () {
2028
+ _this18.triggerPendingChangeDelivery();
2029
+ });
2030
+ this.registerFeature(this._didChangeTextDocumentFeature);
2031
+ this.registerFeature(new WillSaveFeature(this));
2032
+ this.registerFeature(new WillSaveWaitUntilFeature(this));
2033
+ this.registerFeature(new DidSaveTextDocumentFeature(this));
2034
+ this.registerFeature(new DidCloseTextDocumentFeature(this, this._syncedDocuments, pendingFullTextDocumentChanges));
2035
+ this.registerFeature(new FileSystemWatcherFeature(this, function (event) {
2036
+ return _this18.notifyFileEvent(event);
2037
+ }));
2038
+ this.registerFeature(new CompletionItemFeature(this));
2039
+ this.registerFeature(new HoverFeature(this));
2040
+ this.registerFeature(new SignatureHelpFeature(this));
2041
+ this.registerFeature(new DefinitionFeature(this));
2042
+ this.registerFeature(new ReferencesFeature(this));
2043
+ this.registerFeature(new DocumentHighlightFeature(this));
2044
+ this.registerFeature(new DocumentSymbolFeature(this));
2045
+ this.registerFeature(new WorkspaceSymbolFeature(this));
2046
+ this.registerFeature(new CodeActionFeature(this));
2047
+ this.registerFeature(new CodeLensFeature(this));
2048
+ this.registerFeature(new DocumentFormattingFeature(this));
2049
+ this.registerFeature(new DocumentRangeFormattingFeature(this));
2050
+ this.registerFeature(new DocumentOnTypeFormattingFeature(this));
2051
+ this.registerFeature(new RenameFeature(this));
2052
+ this.registerFeature(new DocumentLinkFeature(this));
2053
+ this.registerFeature(new ExecuteCommandFeature(this));
2054
+ this.registerFeature(new SyncConfigurationFeature(this));
2055
+ this.registerFeature(new TypeDefinitionFeature(this));
2056
+ this.registerFeature(new ImplementationFeature(this));
2057
+ this.registerFeature(new ColorProviderFeature(this));
2058
+ // We only register the workspace folder feature if the client is not locked
2059
+ // to a specific workspace folder.
2060
+ if (this.clientOptions.workspaceFolder === undefined) {
2061
+ this.registerFeature(new WorkspaceFoldersFeature(this));
2062
+ }
2063
+ this.registerFeature(new FoldingRangeFeature(this));
2064
+ this.registerFeature(new DeclarationFeature(this));
2065
+ this.registerFeature(new SelectionRangeFeature(this));
2066
+ this.registerFeature(new ProgressFeature(this));
2067
+ this.registerFeature(new CallHierarchyFeature(this));
2068
+ this.registerFeature(new SemanticTokensFeature(this));
2069
+ this.registerFeature(new LinkedEditingFeature(this));
2070
+ this.registerFeature(new DidCreateFilesFeature(this));
2071
+ this.registerFeature(new DidRenameFilesFeature(this));
2072
+ this.registerFeature(new DidDeleteFilesFeature(this));
2073
+ this.registerFeature(new WillCreateFilesFeature(this));
2074
+ this.registerFeature(new WillRenameFilesFeature(this));
2075
+ this.registerFeature(new WillDeleteFilesFeature(this));
2076
+ this.registerFeature(new TypeHierarchyFeature(this));
2077
+ this.registerFeature(new InlineValueFeature(this));
2078
+ this.registerFeature(new InlayHintsFeature(this));
2079
+ this.registerFeature(new DiagnosticFeature(this));
2080
+ this.registerFeature(new NotebookDocumentSyncFeature(this));
2081
+ }
2082
+ }, {
2083
+ key: "registerProposedFeatures",
2084
+ value: function registerProposedFeatures() {
2085
+ this.registerFeatures(ProposedFeatures.createAll(this));
2086
+ }
2087
+ }, {
2088
+ key: "fillInitializeParams",
2089
+ value: function fillInitializeParams(params) {
2090
+ var _iterator11 = _createForOfIteratorHelper(this._features),
2091
+ _step11;
2092
+ try {
2093
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
2094
+ var feature = _step11.value;
2095
+ if (Is.func(feature.fillInitializeParams)) {
2096
+ feature.fillInitializeParams(params);
2097
+ }
2098
+ }
2099
+ } catch (err) {
2100
+ _iterator11.e(err);
2101
+ } finally {
2102
+ _iterator11.f();
2103
+ }
2104
+ }
2105
+ }, {
2106
+ key: "computeClientCapabilities",
2107
+ value: function computeClientCapabilities() {
2108
+ var result = {};
2109
+ ensure(result, 'workspace').applyEdit = true;
2110
+ var workspaceEdit = ensure(ensure(result, 'workspace'), 'workspaceEdit');
2111
+ workspaceEdit.documentChanges = true;
2112
+ workspaceEdit.resourceOperations = [ResourceOperationKind.Create, ResourceOperationKind.Rename, ResourceOperationKind.Delete];
2113
+ workspaceEdit.failureHandling = FailureHandlingKind.TextOnlyTransactional;
2114
+ workspaceEdit.normalizesLineEndings = true;
2115
+ workspaceEdit.changeAnnotationSupport = {
2116
+ groupsOnLabel: true
2117
+ };
2118
+ var diagnostics = ensure(ensure(result, 'textDocument'), 'publishDiagnostics');
2119
+ diagnostics.relatedInformation = true;
2120
+ diagnostics.versionSupport = false;
2121
+ diagnostics.tagSupport = {
2122
+ valueSet: [DiagnosticTag.Unnecessary, DiagnosticTag.Deprecated]
2123
+ };
2124
+ diagnostics.codeDescriptionSupport = true;
2125
+ diagnostics.dataSupport = true;
2126
+ var windowCapabilities = ensure(result, 'window');
2127
+ var showMessage = ensure(windowCapabilities, 'showMessage');
2128
+ showMessage.messageActionItem = {
2129
+ additionalPropertiesSupport: true
2130
+ };
2131
+ var showDocument = ensure(windowCapabilities, 'showDocument');
2132
+ showDocument.support = true;
2133
+ var generalCapabilities = ensure(result, 'general');
2134
+ generalCapabilities.staleRequestSupport = {
2135
+ cancel: true,
2136
+ retryOnContentModified: Array.from(BaseLanguageClient.RequestsToCancelOnContentModified)
2137
+ };
2138
+ generalCapabilities.regularExpressions = {
2139
+ engine: 'ECMAScript',
2140
+ version: 'ES2020'
2141
+ };
2142
+ generalCapabilities.markdown = {
2143
+ parser: 'marked',
2144
+ version: '1.1.0'
2145
+ };
2146
+ generalCapabilities.positionEncodings = ['utf-16'];
2147
+ if (this._clientOptions.markdown.supportHtml) {
2148
+ generalCapabilities.markdown.allowedTags = ['ul', 'li', 'p', 'code', 'blockquote', 'ol', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'em', 'pre', 'table', 'thead', 'tbody', 'tr', 'th', 'td', 'div', 'del', 'a', 'strong', 'br', 'img', 'span'];
2149
+ }
2150
+ var _iterator12 = _createForOfIteratorHelper(this._features),
2151
+ _step12;
2152
+ try {
2153
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
2154
+ var feature = _step12.value;
2155
+ feature.fillClientCapabilities(result);
2156
+ }
2157
+ } catch (err) {
2158
+ _iterator12.e(err);
2159
+ } finally {
2160
+ _iterator12.f();
2161
+ }
2162
+ return result;
2163
+ }
2164
+ }, {
2165
+ key: "initializeFeatures",
2166
+ value: function initializeFeatures(_connection) {
2167
+ var documentSelector = this._clientOptions.documentSelector;
2168
+ var _iterator13 = _createForOfIteratorHelper(this._features),
2169
+ _step13;
2170
+ try {
2171
+ for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
2172
+ var feature = _step13.value;
2173
+ if (Is.func(feature.preInitialize)) {
2174
+ feature.preInitialize(this._capabilities, documentSelector);
2175
+ }
2176
+ }
2177
+ } catch (err) {
2178
+ _iterator13.e(err);
2179
+ } finally {
2180
+ _iterator13.f();
2181
+ }
2182
+ var _iterator14 = _createForOfIteratorHelper(this._features),
2183
+ _step14;
2184
+ try {
2185
+ for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
2186
+ var _feature = _step14.value;
2187
+ _feature.initialize(this._capabilities, documentSelector);
2188
+ }
2189
+ } catch (err) {
2190
+ _iterator14.e(err);
2191
+ } finally {
2192
+ _iterator14.f();
2193
+ }
2194
+ }
2195
+ }, {
2196
+ key: "handleRegistrationRequest",
2197
+ value: function () {
2198
+ var _handleRegistrationRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
2199
+ var _this$clientOptions$m2,
2200
+ _this19 = this;
2201
+ var middleware;
2202
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2203
+ while (1) switch (_context21.prev = _context21.next) {
2204
+ case 0:
2205
+ middleware = (_this$clientOptions$m2 = this.clientOptions.middleware) === null || _this$clientOptions$m2 === void 0 ? void 0 : _this$clientOptions$m2.handleRegisterCapability;
2206
+ if (!middleware) {
2207
+ _context21.next = 5;
2208
+ break;
2209
+ }
2210
+ return _context21.abrupt("return", middleware(params, function (nextParams) {
2211
+ return _this19.doRegisterCapability(nextParams);
2212
+ }));
2213
+ case 5:
2214
+ return _context21.abrupt("return", this.doRegisterCapability(params));
2215
+ case 6:
2216
+ case "end":
2217
+ return _context21.stop();
2218
+ }
2219
+ }, _callee21, this);
2220
+ }));
2221
+ function handleRegistrationRequest(_x21) {
2222
+ return _handleRegistrationRequest.apply(this, arguments);
2223
+ }
2224
+ return handleRegistrationRequest;
2225
+ }()
2226
+ }, {
2227
+ key: "doRegisterCapability",
2228
+ value: function () {
2229
+ var _doRegisterCapability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
2230
+ var _iterator15, _step15, registration, _iterator16, _step16, _registration$registe, _documentSelector, _registration, feature, options, data;
2231
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2232
+ while (1) switch (_context22.prev = _context22.next) {
2233
+ case 0:
2234
+ if (this.isRunning()) {
2235
+ _context22.next = 4;
2236
+ break;
2237
+ }
2238
+ _iterator15 = _createForOfIteratorHelper(params.registrations);
2239
+ try {
2240
+ for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
2241
+ registration = _step15.value;
2242
+ this._ignoredRegistrations.add(registration.id);
2243
+ }
2244
+ } catch (err) {
2245
+ _iterator15.e(err);
2246
+ } finally {
2247
+ _iterator15.f();
2248
+ }
2249
+ return _context22.abrupt("return");
2250
+ case 4:
2251
+ _iterator16 = _createForOfIteratorHelper(params.registrations);
2252
+ _context22.prev = 5;
2253
+ _iterator16.s();
2254
+ case 7:
2255
+ if ((_step16 = _iterator16.n()).done) {
2256
+ _context22.next = 24;
2257
+ break;
2258
+ }
2259
+ _registration = _step16.value;
2260
+ feature = this._dynamicFeatures.get(_registration.method);
2261
+ if (!(feature === undefined)) {
2262
+ _context22.next = 12;
2263
+ break;
2264
+ }
2265
+ return _context22.abrupt("return", Promise.reject(new Error("No feature implementation for ".concat(_registration.method, " found. Registration failed."))));
2266
+ case 12:
2267
+ options = (_registration$registe = _registration.registerOptions) !== null && _registration$registe !== void 0 ? _registration$registe : {};
2268
+ options.documentSelector = (_documentSelector = options.documentSelector) !== null && _documentSelector !== void 0 ? _documentSelector : this._clientOptions.documentSelector;
2269
+ data = {
2270
+ id: _registration.id,
2271
+ registerOptions: options
2272
+ };
2273
+ _context22.prev = 15;
2274
+ feature.register(data);
2275
+ _context22.next = 22;
2276
+ break;
2277
+ case 19:
2278
+ _context22.prev = 19;
2279
+ _context22.t0 = _context22["catch"](15);
2280
+ return _context22.abrupt("return", Promise.reject(_context22.t0));
2281
+ case 22:
2282
+ _context22.next = 7;
2283
+ break;
2284
+ case 24:
2285
+ _context22.next = 29;
2286
+ break;
2287
+ case 26:
2288
+ _context22.prev = 26;
2289
+ _context22.t1 = _context22["catch"](5);
2290
+ _iterator16.e(_context22.t1);
2291
+ case 29:
2292
+ _context22.prev = 29;
2293
+ _iterator16.f();
2294
+ return _context22.finish(29);
2295
+ case 32:
2296
+ case "end":
2297
+ return _context22.stop();
2298
+ }
2299
+ }, _callee22, this, [[5, 26, 29, 32], [15, 19]]);
2300
+ }));
2301
+ function doRegisterCapability(_x22) {
2302
+ return _doRegisterCapability.apply(this, arguments);
2303
+ }
2304
+ return doRegisterCapability;
2305
+ }()
2306
+ }, {
2307
+ key: "handleUnregistrationRequest",
2308
+ value: function () {
2309
+ var _handleUnregistrationRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
2310
+ var _this$clientOptions$m3,
2311
+ _this20 = this;
2312
+ var middleware;
2313
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2314
+ while (1) switch (_context23.prev = _context23.next) {
2315
+ case 0:
2316
+ middleware = (_this$clientOptions$m3 = this.clientOptions.middleware) === null || _this$clientOptions$m3 === void 0 ? void 0 : _this$clientOptions$m3.handleUnregisterCapability;
2317
+ if (!middleware) {
2318
+ _context23.next = 5;
2319
+ break;
2320
+ }
2321
+ return _context23.abrupt("return", middleware(params, function (nextParams) {
2322
+ return _this20.doUnregisterCapability(nextParams);
2323
+ }));
2324
+ case 5:
2325
+ return _context23.abrupt("return", this.doUnregisterCapability(params));
2326
+ case 6:
2327
+ case "end":
2328
+ return _context23.stop();
2329
+ }
2330
+ }, _callee23, this);
2331
+ }));
2332
+ function handleUnregistrationRequest(_x23) {
2333
+ return _handleUnregistrationRequest.apply(this, arguments);
2334
+ }
2335
+ return handleUnregistrationRequest;
2336
+ }()
2337
+ }, {
2338
+ key: "doUnregisterCapability",
2339
+ value: function () {
2340
+ var _doUnregisterCapability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
2341
+ var _iterator17, _step17, unregistration, feature;
2342
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2343
+ while (1) switch (_context24.prev = _context24.next) {
2344
+ case 0:
2345
+ _iterator17 = _createForOfIteratorHelper(params.unregisterations);
2346
+ _context24.prev = 1;
2347
+ _iterator17.s();
2348
+ case 3:
2349
+ if ((_step17 = _iterator17.n()).done) {
2350
+ _context24.next = 13;
2351
+ break;
2352
+ }
2353
+ unregistration = _step17.value;
2354
+ if (!this._ignoredRegistrations.has(unregistration.id)) {
2355
+ _context24.next = 7;
2356
+ break;
2357
+ }
2358
+ return _context24.abrupt("continue", 11);
2359
+ case 7:
2360
+ feature = this._dynamicFeatures.get(unregistration.method);
2361
+ if (feature) {
2362
+ _context24.next = 10;
2363
+ break;
2364
+ }
2365
+ return _context24.abrupt("return", Promise.reject(new Error("No feature implementation for ".concat(unregistration.method, " found. Unregistration failed."))));
2366
+ case 10:
2367
+ feature.unregister(unregistration.id);
2368
+ case 11:
2369
+ _context24.next = 3;
2370
+ break;
2371
+ case 13:
2372
+ _context24.next = 18;
2373
+ break;
2374
+ case 15:
2375
+ _context24.prev = 15;
2376
+ _context24.t0 = _context24["catch"](1);
2377
+ _iterator17.e(_context24.t0);
2378
+ case 18:
2379
+ _context24.prev = 18;
2380
+ _iterator17.f();
2381
+ return _context24.finish(18);
2382
+ case 21:
2383
+ case "end":
2384
+ return _context24.stop();
2385
+ }
2386
+ }, _callee24, this, [[1, 15, 18, 21]]);
2387
+ }));
2388
+ function doUnregisterCapability(_x24) {
2389
+ return _doUnregisterCapability.apply(this, arguments);
2390
+ }
2391
+ return doUnregisterCapability;
2392
+ }()
2393
+ }, {
2394
+ key: "handleApplyWorkspaceEdit",
2395
+ value: function () {
2396
+ var _handleApplyWorkspaceEdit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
2397
+ var _this$clientOptions$m4,
2398
+ _this21 = this;
2399
+ var middleware, resultOrError;
2400
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2401
+ while (1) switch (_context25.prev = _context25.next) {
2402
+ case 0:
2403
+ middleware = (_this$clientOptions$m4 = this.clientOptions.middleware) === null || _this$clientOptions$m4 === void 0 || (_this$clientOptions$m4 = _this$clientOptions$m4.workspace) === null || _this$clientOptions$m4 === void 0 ? void 0 : _this$clientOptions$m4.handleApplyEdit;
2404
+ if (!middleware) {
2405
+ _context25.next = 10;
2406
+ break;
2407
+ }
2408
+ _context25.next = 4;
2409
+ return middleware(params, function (nextParams) {
2410
+ return _this21.doHandleApplyWorkspaceEdit(nextParams);
2411
+ });
2412
+ case 4:
2413
+ resultOrError = _context25.sent;
2414
+ if (!(resultOrError instanceof ResponseError)) {
2415
+ _context25.next = 7;
2416
+ break;
2417
+ }
2418
+ return _context25.abrupt("return", Promise.reject(resultOrError));
2419
+ case 7:
2420
+ return _context25.abrupt("return", resultOrError);
2421
+ case 10:
2422
+ return _context25.abrupt("return", this.doHandleApplyWorkspaceEdit(params));
2423
+ case 11:
2424
+ case "end":
2425
+ return _context25.stop();
2426
+ }
2427
+ }, _callee25, this);
2428
+ }));
2429
+ function handleApplyWorkspaceEdit(_x25) {
2430
+ return _handleApplyWorkspaceEdit.apply(this, arguments);
2431
+ }
2432
+ return handleApplyWorkspaceEdit;
2433
+ }()
2434
+ }, {
2435
+ key: "doHandleApplyWorkspaceEdit",
2436
+ value: function () {
2437
+ var _doHandleApplyWorkspaceEdit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
2438
+ var _this22 = this;
2439
+ var workspaceEdit, converted, openTextDocuments, versionMismatch, _iterator18, _step18, change, changeUri, _textDocument;
2440
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2441
+ while (1) switch (_context26.prev = _context26.next) {
2442
+ case 0:
2443
+ workspaceEdit = params.edit; // Make sure we convert workspace edits one after the other. Otherwise
2444
+ // we might execute a workspace edit received first after we received another
2445
+ // one since the conversion might race.
2446
+ _context26.next = 3;
2447
+ return this.workspaceEditLock.lock(function () {
2448
+ return _this22._p2c.asWorkspaceEdit(workspaceEdit);
2449
+ });
2450
+ case 3:
2451
+ converted = _context26.sent;
2452
+ // This is some sort of workaround since the version check should be done by VS Code in the Workspace.applyEdit.
2453
+ // However doing it here adds some safety since the server can lag more behind then an extension.
2454
+ openTextDocuments = new Map();
2455
+ Workspace.textDocuments.forEach(function (document) {
2456
+ return openTextDocuments.set(document.uri.toString(), document);
2457
+ });
2458
+ versionMismatch = false;
2459
+ if (!workspaceEdit.documentChanges) {
2460
+ _context26.next = 29;
2461
+ break;
2462
+ }
2463
+ _iterator18 = _createForOfIteratorHelper(workspaceEdit.documentChanges);
2464
+ _context26.prev = 9;
2465
+ _iterator18.s();
2466
+ case 11:
2467
+ if ((_step18 = _iterator18.n()).done) {
2468
+ _context26.next = 21;
2469
+ break;
2470
+ }
2471
+ change = _step18.value;
2472
+ if (!(TextDocumentEdit.is(change) && change.textDocument.version && change.textDocument.version >= 0)) {
2473
+ _context26.next = 19;
2474
+ break;
2475
+ }
2476
+ changeUri = this._p2c.asUri(change.textDocument.uri).toString();
2477
+ _textDocument = openTextDocuments.get(changeUri);
2478
+ if (!(_textDocument && _textDocument.version !== change.textDocument.version)) {
2479
+ _context26.next = 19;
2480
+ break;
2481
+ }
2482
+ versionMismatch = true;
2483
+ return _context26.abrupt("break", 21);
2484
+ case 19:
2485
+ _context26.next = 11;
2486
+ break;
2487
+ case 21:
2488
+ _context26.next = 26;
2489
+ break;
2490
+ case 23:
2491
+ _context26.prev = 23;
2492
+ _context26.t0 = _context26["catch"](9);
2493
+ _iterator18.e(_context26.t0);
2494
+ case 26:
2495
+ _context26.prev = 26;
2496
+ _iterator18.f();
2497
+ return _context26.finish(26);
2498
+ case 29:
2499
+ if (!versionMismatch) {
2500
+ _context26.next = 31;
2501
+ break;
2502
+ }
2503
+ return _context26.abrupt("return", Promise.resolve({
2504
+ applied: false
2505
+ }));
2506
+ case 31:
2507
+ return _context26.abrupt("return", Is.asPromise(Workspace.applyEdit(converted).then(function (value) {
2508
+ return {
2509
+ applied: value
2510
+ };
2511
+ })));
2512
+ case 32:
2513
+ case "end":
2514
+ return _context26.stop();
2515
+ }
2516
+ }, _callee26, this, [[9, 23, 26, 29]]);
2517
+ }));
2518
+ function doHandleApplyWorkspaceEdit(_x26) {
2519
+ return _doHandleApplyWorkspaceEdit.apply(this, arguments);
2520
+ }
2521
+ return doHandleApplyWorkspaceEdit;
2522
+ }()
2523
+ }, {
2524
+ key: "handleFailedRequest",
2525
+ value: function handleFailedRequest(type, token, error, defaultValue) {
2526
+ var showNotification = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
2527
+ // If we get a request cancel or a content modified don't log anything.
2528
+ if (error instanceof ResponseError) {
2529
+ // The connection got disposed while we were waiting for a response.
2530
+ // Simply return the default value. Is the best we can do.
2531
+ if (error.code === ErrorCodes.PendingResponseRejected || error.code === ErrorCodes.ConnectionInactive) {
2532
+ return defaultValue;
2533
+ }
2534
+ if (error.code === LSPErrorCodes.RequestCancelled || error.code === LSPErrorCodes.ServerCancelled) {
2535
+ if (token !== undefined && token.isCancellationRequested) {
2536
+ return defaultValue;
2537
+ } else {
2538
+ if (error.data !== undefined) {
2539
+ throw new LSPCancellationError(error.data);
2540
+ } else {
2541
+ throw new CancellationError();
2542
+ }
2543
+ }
2544
+ } else if (error.code === LSPErrorCodes.ContentModified) {
2545
+ if (BaseLanguageClient.RequestsToCancelOnContentModified.has(type.method) || BaseLanguageClient.CancellableResolveCalls.has(type.method)) {
2546
+ throw new CancellationError();
2547
+ } else {
2548
+ return defaultValue;
2549
+ }
2550
+ }
2551
+ }
2552
+ this.error("Request ".concat(type.method, " failed."), error, showNotification);
2553
+ throw error;
2554
+ }
2555
+
2556
+ // private checkSuspend(): void {
2557
+ // if (this.$state !== ClientState.Running) {
2558
+ // return;
2559
+ // }
2560
+ // const connection = this.activeConnection();
2561
+ // if (connection === undefined) {
2562
+ // this._idleStart = undefined;
2563
+ // return;
2564
+ // }
2565
+ // // Since the last idle start we sent a request. Cancel the idle counting.
2566
+ // if (connection.hasPendingResponse() || (this._idleStart !== undefined && connection.lastUsed > this._idleStart)) {
2567
+ // this._idleStart = undefined;
2568
+ // return;
2569
+ // }
2570
+ // if (this.isIdle()) {
2571
+ // const production = (this.clientOptions as TestOptions).$testMode !== true;
2572
+ // // Only do this in production since in test cases we only have
2573
+ // // 2000 ms to suspend.
2574
+ // if (production) {
2575
+ // if (this._idleStart === undefined) {
2576
+ // this._idleStart = Date.now();
2577
+ // return;
2578
+ // }
2579
+
2580
+ // const interval = this._clientOptions.suspend.interval;
2581
+ // const diff = Date.now() - this._idleStart;
2582
+ // if (diff < interval * 3) {
2583
+ // return;
2584
+ // }
2585
+ // if (diff > interval * 5) {
2586
+ // // Avoid that we shutdown the server when a computer resumes from sleep.
2587
+ // this._idleStart = undefined;
2588
+ // return;
2589
+ // }
2590
+ // }
2591
+
2592
+ // this._idleStart = undefined;
2593
+ // this.info(`Suspending server`);
2594
+ // this._clientOptions.suspend.callback().then((approved) => {
2595
+ // if (!approved) {
2596
+ // this._idleStart = undefined;
2597
+ // return;
2598
+ // }
2599
+ // return this.suspend().then(() => {
2600
+ // this.info(`Server got suspended`);
2601
+ // });
2602
+ // }, (error) => {
2603
+ // this.error(`Suspending server failed`, error, 'force');
2604
+ // });
2605
+ // } else {
2606
+ // this._idleStart = undefined;
2607
+ // }
2608
+ // }
2609
+
2610
+ // private isIdle(): boolean {
2611
+ // const suspendMode = this._clientOptions.suspend.mode;
2612
+ // if (suspendMode === SuspendMode.off) {
2613
+ // return false;
2614
+ // }
2615
+
2616
+ // for (const feature of this._features) {
2617
+ // const state = feature.getState();
2618
+ // // 'static' feature don't depend on registrations. So they
2619
+ // // can't block suspend
2620
+ // if (state.kind === 'static') {
2621
+ // continue;
2622
+ // }
2623
+ // // The feature has no registrations. So no blocking of the
2624
+ // // suspend.
2625
+ // if (!state.registrations) {
2626
+ // continue;
2627
+ // }
2628
+
2629
+ // if (state.kind === 'document' && state.matches === true) {
2630
+ // return false;
2631
+ // }
2632
+ // }
2633
+ // return true;
2634
+ // }
2635
+ }]);
2636
+ return BaseLanguageClient;
2637
+ }();
2638
+ BaseLanguageClient.RequestsToCancelOnContentModified = new Set([SemanticTokensRequest.method, SemanticTokensRangeRequest.method, SemanticTokensDeltaRequest.method]);
2639
+ BaseLanguageClient.CancellableResolveCalls = new Set([CompletionResolveRequest.method, CodeLensResolveRequest.method, CodeActionResolveRequest.method, InlayHintResolveRequest.method, DocumentLinkResolveRequest.method, WorkspaceSymbolResolveRequest.method]);
2640
+ var ConsoleLogger = /*#__PURE__*/function () {
2641
+ function ConsoleLogger() {
2642
+ _classCallCheck(this, ConsoleLogger);
2643
+ }
2644
+ _createClass(ConsoleLogger, [{
2645
+ key: "error",
2646
+ value: function error(message) {
2647
+ RAL().console.error(message);
2648
+ }
2649
+ }, {
2650
+ key: "warn",
2651
+ value: function warn(message) {
2652
+ RAL().console.warn(message);
2653
+ }
2654
+ }, {
2655
+ key: "info",
2656
+ value: function info(message) {
2657
+ RAL().console.info(message);
2658
+ }
2659
+ }, {
2660
+ key: "log",
2661
+ value: function log(message) {
2662
+ RAL().console.log(message);
2663
+ }
2664
+ }]);
2665
+ return ConsoleLogger;
2666
+ }();
2667
+ function _createConnection(input, output, errorHandler, closeHandler, options) {
2668
+ var logger = new ConsoleLogger();
2669
+ var connection = createProtocolConnection(input, output, logger, options);
2670
+ connection.onError(function (data) {
2671
+ errorHandler(data[0], data[1], data[2]);
2672
+ });
2673
+ connection.onClose(closeHandler);
2674
+ var result = {
2675
+ listen: function listen() {
2676
+ return connection.listen();
2677
+ },
2678
+ sendRequest: connection.sendRequest,
2679
+ onRequest: connection.onRequest,
2680
+ hasPendingResponse: connection.hasPendingResponse,
2681
+ sendNotification: connection.sendNotification,
2682
+ onNotification: connection.onNotification,
2683
+ onProgress: connection.onProgress,
2684
+ sendProgress: connection.sendProgress,
2685
+ trace: function trace(value, tracer, sendNotificationOrTraceOptions) {
2686
+ var defaultTraceOptions = {
2687
+ sendNotification: false,
2688
+ traceFormat: TraceFormat.Text
2689
+ };
2690
+ if (sendNotificationOrTraceOptions === undefined) {
2691
+ return connection.trace(value, tracer, defaultTraceOptions);
2692
+ } else if (Is.boolean(sendNotificationOrTraceOptions)) {
2693
+ return connection.trace(value, tracer, sendNotificationOrTraceOptions);
2694
+ } else {
2695
+ return connection.trace(value, tracer, sendNotificationOrTraceOptions);
2696
+ }
2697
+ },
2698
+ initialize: function initialize(params) {
2699
+ // This needs to return and MUST not be await to avoid any async
2700
+ // scheduling. Otherwise messages might overtake each other.
2701
+ return connection.sendRequest(InitializeRequest.type, params);
2702
+ },
2703
+ shutdown: function shutdown() {
2704
+ // This needs to return and MUST not be await to avoid any async
2705
+ // scheduling. Otherwise messages might overtake each other.
2706
+ return connection.sendRequest(ShutdownRequest.type, undefined);
2707
+ },
2708
+ exit: function exit() {
2709
+ // This needs to return and MUST not be await to avoid any async
2710
+ // scheduling. Otherwise messages might overtake each other.
2711
+ return connection.sendNotification(ExitNotification.type);
2712
+ },
2713
+ end: function end() {
2714
+ return connection.end();
2715
+ },
2716
+ dispose: function dispose() {
2717
+ return connection.dispose();
2718
+ }
2719
+ };
2720
+ return result;
2721
+ }
2722
+
2723
+ // Exporting proposed protocol.
2724
+ export var ProposedFeatures;
2725
+ (function (_ProposedFeatures) {
2726
+ function createAll(_client) {
2727
+ var result = [new InlineCompletionItemFeature(_client)];
2728
+ return result;
2729
+ }
2730
+ _ProposedFeatures.createAll = createAll;
2731
+ })(ProposedFeatures || (ProposedFeatures = {}));