@theia/plugin-ext 1.45.1 → 1.46.0-next.72

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 (1138) hide show
  1. package/README.md +54 -54
  2. package/lib/common/arrays.d.ts +23 -23
  3. package/lib/common/arrays.js +60 -60
  4. package/lib/common/assert.d.ts +1 -1
  5. package/lib/common/assert.js +25 -25
  6. package/lib/common/cache.d.ts +11 -11
  7. package/lib/common/cache.js +47 -47
  8. package/lib/common/character-classifier.d.ts +18 -18
  9. package/lib/common/character-classifier.js +60 -60
  10. package/lib/common/collections.d.ts +8 -8
  11. package/lib/common/collections.js +55 -55
  12. package/lib/common/commands.d.ts +3 -3
  13. package/lib/common/commands.js +16 -16
  14. package/lib/common/connection.d.ts +54 -54
  15. package/lib/common/connection.js +107 -107
  16. package/lib/common/disposable-util.d.ts +6 -6
  17. package/lib/common/disposable-util.js +37 -37
  18. package/lib/common/editor-options.d.ts +30 -30
  19. package/lib/common/editor-options.js +72 -72
  20. package/lib/common/env.d.ts +3 -3
  21. package/lib/common/env.js +17 -17
  22. package/lib/common/errors.d.ts +17 -17
  23. package/lib/common/errors.js +58 -58
  24. package/lib/common/id-generator.d.ts +6 -6
  25. package/lib/common/id-generator.js +28 -28
  26. package/lib/common/index.d.ts +3 -3
  27. package/lib/common/index.js +33 -33
  28. package/lib/common/language-pack-service.d.ts +15 -15
  29. package/lib/common/language-pack-service.js +20 -20
  30. package/lib/common/link-computer.d.ts +41 -41
  31. package/lib/common/link-computer.js +275 -275
  32. package/lib/common/object-identifier.d.ts +8 -8
  33. package/lib/common/object-identifier.js +32 -32
  34. package/lib/common/objects.d.ts +1 -1
  35. package/lib/common/objects.js +46 -46
  36. package/lib/common/paths-util.d.ts +3 -3
  37. package/lib/common/paths-util.js +144 -144
  38. package/lib/common/plugin-api-rpc-model.d.ts +755 -755
  39. package/lib/common/plugin-api-rpc-model.d.ts.map +1 -1
  40. package/lib/common/plugin-api-rpc-model.js +178 -178
  41. package/lib/common/plugin-api-rpc.d.ts +2112 -2088
  42. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  43. package/lib/common/plugin-api-rpc.js +304 -302
  44. package/lib/common/plugin-api-rpc.js.map +1 -1
  45. package/lib/common/plugin-ext-api-contribution.d.ts +88 -58
  46. package/lib/common/plugin-ext-api-contribution.d.ts.map +1 -1
  47. package/lib/common/plugin-ext-api-contribution.js +5 -5
  48. package/lib/common/plugin-ext-api-contribution.js.map +1 -1
  49. package/lib/common/plugin-identifiers.d.ts +40 -40
  50. package/lib/common/plugin-identifiers.js +80 -80
  51. package/lib/common/plugin-protocol.d.ts +942 -929
  52. package/lib/common/plugin-protocol.d.ts.map +1 -1
  53. package/lib/common/plugin-protocol.js +75 -74
  54. package/lib/common/plugin-protocol.js.map +1 -1
  55. package/lib/common/proxy-handler.d.ts +72 -65
  56. package/lib/common/proxy-handler.d.ts.map +1 -1
  57. package/lib/common/proxy-handler.js +103 -99
  58. package/lib/common/proxy-handler.js.map +1 -1
  59. package/lib/common/reference-map.d.ts +7 -7
  60. package/lib/common/reference-map.js +39 -39
  61. package/lib/common/rpc-protocol.d.ts +75 -65
  62. package/lib/common/rpc-protocol.d.ts.map +1 -1
  63. package/lib/common/rpc-protocol.js +258 -229
  64. package/lib/common/rpc-protocol.js.map +1 -1
  65. package/lib/common/semantic-tokens-dto.d.ts +18 -18
  66. package/lib/common/semantic-tokens-dto.js +162 -162
  67. package/lib/common/test-types.d.ts +91 -91
  68. package/lib/common/test-types.js +74 -74
  69. package/lib/common/types.d.ts +37 -37
  70. package/lib/common/types.js +121 -121
  71. package/lib/common/uint.d.ts +7 -7
  72. package/lib/common/uint.js +33 -33
  73. package/lib/common/uri-components.d.ts +38 -39
  74. package/lib/common/uri-components.d.ts.map +1 -1
  75. package/lib/common/uri-components.js +62 -66
  76. package/lib/common/uri-components.js.map +1 -1
  77. package/lib/hosted/browser/hosted-plugin-watcher.d.ts +15 -15
  78. package/lib/hosted/browser/hosted-plugin-watcher.js +59 -59
  79. package/lib/hosted/browser/hosted-plugin.d.ts +99 -157
  80. package/lib/hosted/browser/hosted-plugin.d.ts.map +1 -1
  81. package/lib/hosted/browser/hosted-plugin.js +599 -871
  82. package/lib/hosted/browser/hosted-plugin.js.map +1 -1
  83. package/lib/hosted/browser/plugin-worker.d.ts +6 -6
  84. package/lib/hosted/browser/plugin-worker.js +57 -57
  85. package/lib/hosted/browser/worker/debug-stub.d.ts +3 -3
  86. package/lib/hosted/browser/worker/debug-stub.d.ts.map +1 -1
  87. package/lib/hosted/browser/worker/debug-stub.js +29 -29
  88. package/lib/hosted/browser/worker/debug-stub.js.map +1 -1
  89. package/lib/hosted/browser/worker/plugin-manifest-loader.d.ts +2 -2
  90. package/lib/hosted/browser/worker/plugin-manifest-loader.js +107 -107
  91. package/lib/hosted/browser/worker/worker-env-ext.d.ts +13 -14
  92. package/lib/hosted/browser/worker/worker-env-ext.d.ts.map +1 -1
  93. package/lib/hosted/browser/worker/worker-env-ext.js +52 -38
  94. package/lib/hosted/browser/worker/worker-env-ext.js.map +1 -1
  95. package/lib/hosted/browser/worker/worker-main.d.ts +1 -1
  96. package/lib/hosted/browser/worker/worker-main.js +182 -194
  97. package/lib/hosted/browser/worker/worker-main.js.map +1 -1
  98. package/lib/hosted/browser/worker/worker-plugin-module.d.ts +5 -0
  99. package/lib/hosted/browser/worker/worker-plugin-module.d.ts.map +1 -0
  100. package/lib/hosted/browser/worker/worker-plugin-module.js +78 -0
  101. package/lib/hosted/browser/worker/worker-plugin-module.js.map +1 -0
  102. package/lib/hosted/common/hosted-plugin.d.ts +97 -0
  103. package/lib/hosted/common/hosted-plugin.d.ts.map +1 -0
  104. package/lib/hosted/common/hosted-plugin.js +408 -0
  105. package/lib/hosted/common/hosted-plugin.js.map +1 -0
  106. package/lib/hosted/node/hosted-plugin-cli-contribution.d.ts +16 -16
  107. package/lib/hosted/node/hosted-plugin-cli-contribution.js +76 -76
  108. package/lib/hosted/node/hosted-plugin-deployer-handler.d.ts +43 -43
  109. package/lib/hosted/node/hosted-plugin-deployer-handler.js +270 -270
  110. package/lib/hosted/node/hosted-plugin-localization-service.d.ts +46 -46
  111. package/lib/hosted/node/hosted-plugin-localization-service.js +389 -389
  112. package/lib/hosted/node/hosted-plugin-process.d.ts +47 -47
  113. package/lib/hosted/node/hosted-plugin-process.d.ts.map +1 -1
  114. package/lib/hosted/node/hosted-plugin-process.js +224 -224
  115. package/lib/hosted/node/hosted-plugin-process.js.map +1 -1
  116. package/lib/hosted/node/hosted-plugin-protocol.d.ts +21 -21
  117. package/lib/hosted/node/hosted-plugin-protocol.js +36 -36
  118. package/lib/hosted/node/hosted-plugin.d.ts +36 -36
  119. package/lib/hosted/node/hosted-plugin.js +118 -118
  120. package/lib/hosted/node/metadata-scanner.d.ts +17 -17
  121. package/lib/hosted/node/metadata-scanner.js +82 -82
  122. package/lib/hosted/node/plugin-activation-events.d.ts +6 -6
  123. package/lib/hosted/node/plugin-activation-events.js +95 -95
  124. package/lib/hosted/node/plugin-ext-hosted-backend-module.d.ts +3 -3
  125. package/lib/hosted/node/plugin-ext-hosted-backend-module.d.ts.map +1 -1
  126. package/lib/hosted/node/plugin-ext-hosted-backend-module.js +82 -80
  127. package/lib/hosted/node/plugin-ext-hosted-backend-module.js.map +1 -1
  128. package/lib/hosted/node/plugin-host-module.d.ts +5 -0
  129. package/lib/hosted/node/plugin-host-module.d.ts.map +1 -0
  130. package/lib/hosted/node/plugin-host-module.js +68 -0
  131. package/lib/hosted/node/plugin-host-module.js.map +1 -0
  132. package/lib/hosted/node/plugin-host-proxy.d.ts +18 -18
  133. package/lib/hosted/node/plugin-host-proxy.js +70 -70
  134. package/lib/hosted/node/plugin-host-rpc.d.ts +107 -21
  135. package/lib/hosted/node/plugin-host-rpc.d.ts.map +1 -1
  136. package/lib/hosted/node/plugin-host-rpc.js +341 -192
  137. package/lib/hosted/node/plugin-host-rpc.js.map +1 -1
  138. package/lib/hosted/node/plugin-host.d.ts +1 -1
  139. package/lib/hosted/node/plugin-host.js +102 -101
  140. package/lib/hosted/node/plugin-host.js.map +1 -1
  141. package/lib/hosted/node/plugin-language-pack-service.d.ts +7 -7
  142. package/lib/hosted/node/plugin-language-pack-service.js +53 -53
  143. package/lib/hosted/node/plugin-manifest-loader.d.ts +2 -2
  144. package/lib/hosted/node/plugin-manifest-loader.js +35 -35
  145. package/lib/hosted/node/plugin-reader.d.ts +25 -25
  146. package/lib/hosted/node/plugin-reader.d.ts.map +1 -1
  147. package/lib/hosted/node/plugin-reader.js +146 -143
  148. package/lib/hosted/node/plugin-reader.js.map +1 -1
  149. package/lib/hosted/node/plugin-service.d.ts +47 -39
  150. package/lib/hosted/node/plugin-service.d.ts.map +1 -1
  151. package/lib/hosted/node/plugin-service.js +203 -193
  152. package/lib/hosted/node/plugin-service.js.map +1 -1
  153. package/lib/hosted/node/scanners/backend-init-theia.d.ts +2 -2
  154. package/lib/hosted/node/scanners/backend-init-theia.js +60 -60
  155. package/lib/hosted/node/scanners/file-plugin-uri-factory.d.ts +10 -10
  156. package/lib/hosted/node/scanners/file-plugin-uri-factory.js +40 -40
  157. package/lib/hosted/node/scanners/file-plugin-uri-factory.js.map +1 -1
  158. package/lib/hosted/node/scanners/grammars-reader.d.ts +5 -5
  159. package/lib/hosted/node/scanners/grammars-reader.js +63 -63
  160. package/lib/hosted/node/scanners/plugin-uri-factory.d.ts +16 -16
  161. package/lib/hosted/node/scanners/plugin-uri-factory.js +19 -19
  162. package/lib/hosted/node/scanners/scanner-theia.d.ts +68 -54
  163. package/lib/hosted/node/scanners/scanner-theia.d.ts.map +1 -1
  164. package/lib/hosted/node/scanners/scanner-theia.js +859 -824
  165. package/lib/hosted/node/scanners/scanner-theia.js.map +1 -1
  166. package/lib/hosted/node-electron/plugin-ext-hosted-electron-backend-module.d.ts +2 -2
  167. package/lib/hosted/node-electron/plugin-ext-hosted-electron-backend-module.js +26 -26
  168. package/lib/hosted/node-electron/scanner-theia-electron.d.ts +5 -5
  169. package/lib/hosted/node-electron/scanner-theia-electron.js +40 -40
  170. package/lib/main/browser/authentication-main.d.ts +51 -51
  171. package/lib/main/browser/authentication-main.d.ts.map +1 -1
  172. package/lib/main/browser/authentication-main.js +315 -313
  173. package/lib/main/browser/authentication-main.js.map +1 -1
  174. package/lib/main/browser/clipboard-main.d.ts +9 -9
  175. package/lib/main/browser/clipboard-main.js +32 -32
  176. package/lib/main/browser/command-registry-main.d.ts +26 -26
  177. package/lib/main/browser/command-registry-main.js +107 -107
  178. package/lib/main/browser/commands.d.ts +12 -12
  179. package/lib/main/browser/commands.js +102 -102
  180. package/lib/main/browser/comments/comment-glyph-widget.d.ts +12 -12
  181. package/lib/main/browser/comments/comment-glyph-widget.js +42 -42
  182. package/lib/main/browser/comments/comment-thread-widget.d.ts +153 -153
  183. package/lib/main/browser/comments/comment-thread-widget.js +470 -470
  184. package/lib/main/browser/comments/comments-context-key-service.d.ts +17 -17
  185. package/lib/main/browser/comments/comments-context-key-service.js +80 -80
  186. package/lib/main/browser/comments/comments-contribution.d.ts +31 -31
  187. package/lib/main/browser/comments/comments-contribution.d.ts.map +1 -1
  188. package/lib/main/browser/comments/comments-contribution.js +267 -264
  189. package/lib/main/browser/comments/comments-contribution.js.map +1 -1
  190. package/lib/main/browser/comments/comments-decorator.d.ts +15 -15
  191. package/lib/main/browser/comments/comments-decorator.js +107 -107
  192. package/lib/main/browser/comments/comments-main.d.ts +111 -111
  193. package/lib/main/browser/comments/comments-main.js +356 -356
  194. package/lib/main/browser/comments/comments-main.js.map +1 -1
  195. package/lib/main/browser/comments/comments-service.d.ts +75 -75
  196. package/lib/main/browser/comments/comments-service.js +120 -120
  197. package/lib/main/browser/custom-editors/custom-editor-contribution.d.ts +6 -6
  198. package/lib/main/browser/custom-editors/custom-editor-contribution.js +50 -50
  199. package/lib/main/browser/custom-editors/custom-editor-opener.d.ts +21 -21
  200. package/lib/main/browser/custom-editors/custom-editor-opener.js +111 -111
  201. package/lib/main/browser/custom-editors/custom-editor-opener.js.map +1 -1
  202. package/lib/main/browser/custom-editors/custom-editor-service.d.ts +16 -16
  203. package/lib/main/browser/custom-editors/custom-editor-service.js +102 -102
  204. package/lib/main/browser/custom-editors/custom-editor-widget-factory.d.ts +9 -9
  205. package/lib/main/browser/custom-editors/custom-editor-widget-factory.js +39 -39
  206. package/lib/main/browser/custom-editors/custom-editor-widget.d.ts +36 -36
  207. package/lib/main/browser/custom-editors/custom-editor-widget.d.ts.map +1 -1
  208. package/lib/main/browser/custom-editors/custom-editor-widget.js +120 -118
  209. package/lib/main/browser/custom-editors/custom-editor-widget.js.map +1 -1
  210. package/lib/main/browser/custom-editors/custom-editors-main.d.ts +119 -119
  211. package/lib/main/browser/custom-editors/custom-editors-main.js +436 -436
  212. package/lib/main/browser/custom-editors/custom-editors-main.js.map +1 -1
  213. package/lib/main/browser/custom-editors/plugin-custom-editor-registry.d.ts +23 -23
  214. package/lib/main/browser/custom-editors/plugin-custom-editor-registry.js +142 -142
  215. package/lib/main/browser/data-transfer/data-transfer-type-converters.d.ts +8 -8
  216. package/lib/main/browser/data-transfer/data-transfer-type-converters.d.ts.map +1 -1
  217. package/lib/main/browser/data-transfer/data-transfer-type-converters.js +62 -64
  218. package/lib/main/browser/data-transfer/data-transfer-type-converters.js.map +1 -1
  219. package/lib/main/browser/debug/debug-main.d.ts +48 -48
  220. package/lib/main/browser/debug/debug-main.js +295 -295
  221. package/lib/main/browser/debug/plugin-debug-adapter-contribution.d.ts +18 -18
  222. package/lib/main/browser/debug/plugin-debug-adapter-contribution.js +42 -42
  223. package/lib/main/browser/debug/plugin-debug-configuration-provider.d.ts +12 -12
  224. package/lib/main/browser/debug/plugin-debug-configuration-provider.js +38 -38
  225. package/lib/main/browser/debug/plugin-debug-service.d.ts +55 -55
  226. package/lib/main/browser/debug/plugin-debug-service.js +367 -367
  227. package/lib/main/browser/debug/plugin-debug-session-contribution-registry.d.ts +30 -30
  228. package/lib/main/browser/debug/plugin-debug-session-contribution-registry.js +75 -75
  229. package/lib/main/browser/debug/plugin-debug-session-factory.d.ts +55 -55
  230. package/lib/main/browser/debug/plugin-debug-session-factory.js +70 -70
  231. package/lib/main/browser/decorations/decorations-main.d.ts +15 -15
  232. package/lib/main/browser/decorations/decorations-main.js +119 -119
  233. package/lib/main/browser/dialogs/modal-notification.d.ts +18 -18
  234. package/lib/main/browser/dialogs/modal-notification.js +109 -109
  235. package/lib/main/browser/dialogs-main.d.ts +16 -16
  236. package/lib/main/browser/dialogs-main.js +162 -162
  237. package/lib/main/browser/documents-main.d.ts +50 -50
  238. package/lib/main/browser/documents-main.js +249 -249
  239. package/lib/main/browser/editors-and-documents-main.d.ts +36 -32
  240. package/lib/main/browser/editors-and-documents-main.d.ts.map +1 -1
  241. package/lib/main/browser/editors-and-documents-main.js +321 -302
  242. package/lib/main/browser/editors-and-documents-main.js.map +1 -1
  243. package/lib/main/browser/env-main.d.ts +6 -15
  244. package/lib/main/browser/env-main.d.ts.map +1 -1
  245. package/lib/main/browser/env-main.js +63 -82
  246. package/lib/main/browser/env-main.js.map +1 -1
  247. package/lib/main/browser/file-system-main-impl.d.ts +27 -27
  248. package/lib/main/browser/file-system-main-impl.js +205 -205
  249. package/lib/main/browser/hierarchy/hierarchy-types-converters.d.ts +24 -24
  250. package/lib/main/browser/hierarchy/hierarchy-types-converters.js +184 -184
  251. package/lib/main/browser/keybindings/keybindings-contribution-handler.d.ts +9 -9
  252. package/lib/main/browser/keybindings/keybindings-contribution-handler.js +77 -77
  253. package/lib/main/browser/label-service-main.d.ts +10 -10
  254. package/lib/main/browser/label-service-main.js +46 -46
  255. package/lib/main/browser/languages-main.d.ts +143 -143
  256. package/lib/main/browser/languages-main.d.ts.map +1 -1
  257. package/lib/main/browser/languages-main.js +1187 -1184
  258. package/lib/main/browser/languages-main.js.map +1 -1
  259. package/lib/main/browser/localization-main.d.ts +8 -8
  260. package/lib/main/browser/localization-main.js +31 -31
  261. package/lib/main/browser/main-context.d.ts +3 -3
  262. package/lib/main/browser/main-context.d.ts.map +1 -1
  263. package/lib/main/browser/main-context.js +159 -161
  264. package/lib/main/browser/main-context.js.map +1 -1
  265. package/lib/main/browser/main-file-system-event-service.d.ts +7 -7
  266. package/lib/main/browser/main-file-system-event-service.js +65 -65
  267. package/lib/main/browser/menus/menus-contribution-handler.d.ts +29 -29
  268. package/lib/main/browser/menus/menus-contribution-handler.d.ts.map +1 -1
  269. package/lib/main/browser/menus/menus-contribution-handler.js +201 -198
  270. package/lib/main/browser/menus/menus-contribution-handler.js.map +1 -1
  271. package/lib/main/browser/menus/plugin-menu-command-adapter.d.ts +44 -44
  272. package/lib/main/browser/menus/plugin-menu-command-adapter.js +310 -310
  273. package/lib/main/browser/menus/plugin-menu-command-adapter.js.map +1 -1
  274. package/lib/main/browser/menus/vscode-theia-menu-mappings.d.ts +18 -18
  275. package/lib/main/browser/menus/vscode-theia-menu-mappings.js +107 -107
  276. package/lib/main/browser/message-registry-main.d.ts +10 -8
  277. package/lib/main/browser/message-registry-main.d.ts.map +1 -1
  278. package/lib/main/browser/message-registry-main.js +40 -52
  279. package/lib/main/browser/message-registry-main.js.map +1 -1
  280. package/lib/main/browser/notebooks/notebook-documents-and-editors-main.d.ts +50 -51
  281. package/lib/main/browser/notebooks/notebook-documents-and-editors-main.d.ts.map +1 -1
  282. package/lib/main/browser/notebooks/notebook-documents-and-editors-main.js +199 -201
  283. package/lib/main/browser/notebooks/notebook-documents-and-editors-main.js.map +1 -1
  284. package/lib/main/browser/notebooks/notebook-documents-main.d.ts +21 -21
  285. package/lib/main/browser/notebooks/notebook-documents-main.js +131 -131
  286. package/lib/main/browser/notebooks/notebook-dto.d.ts +17 -17
  287. package/lib/main/browser/notebooks/notebook-dto.js +130 -130
  288. package/lib/main/browser/notebooks/notebook-editors-main.d.ts +19 -19
  289. package/lib/main/browser/notebooks/notebook-editors-main.js +57 -57
  290. package/lib/main/browser/notebooks/notebook-kernels-main.d.ts +42 -41
  291. package/lib/main/browser/notebooks/notebook-kernels-main.d.ts.map +1 -1
  292. package/lib/main/browser/notebooks/notebook-kernels-main.js +260 -223
  293. package/lib/main/browser/notebooks/notebook-kernels-main.js.map +1 -1
  294. package/lib/main/browser/notebooks/notebook-renderers-main.d.ts +11 -11
  295. package/lib/main/browser/notebooks/notebook-renderers-main.js +38 -38
  296. package/lib/main/browser/notebooks/notebooks-main.d.ts +30 -30
  297. package/lib/main/browser/notebooks/notebooks-main.js +102 -102
  298. package/lib/main/browser/notebooks/renderers/cell-output-webview.d.ts +39 -33
  299. package/lib/main/browser/notebooks/renderers/cell-output-webview.d.ts.map +1 -1
  300. package/lib/main/browser/notebooks/renderers/cell-output-webview.js +249 -206
  301. package/lib/main/browser/notebooks/renderers/cell-output-webview.js.map +1 -1
  302. package/lib/main/browser/notebooks/renderers/output-webview-internal.d.ts +13 -12
  303. package/lib/main/browser/notebooks/renderers/output-webview-internal.d.ts.map +1 -1
  304. package/lib/main/browser/notebooks/renderers/output-webview-internal.js +457 -376
  305. package/lib/main/browser/notebooks/renderers/output-webview-internal.js.map +1 -1
  306. package/lib/main/browser/notebooks/renderers/webview-communication.d.ts +60 -51
  307. package/lib/main/browser/notebooks/renderers/webview-communication.d.ts.map +1 -1
  308. package/lib/main/browser/notebooks/renderers/webview-communication.js +21 -21
  309. package/lib/main/browser/notification-main.d.ts +6 -18
  310. package/lib/main/browser/notification-main.d.ts.map +1 -1
  311. package/lib/main/browser/notification-main.js +26 -75
  312. package/lib/main/browser/notification-main.js.map +1 -1
  313. package/lib/main/browser/output-channel-registry-main.d.ts +10 -10
  314. package/lib/main/browser/output-channel-registry-main.js +60 -60
  315. package/lib/main/browser/plugin-authentication-service.d.ts +13 -13
  316. package/lib/main/browser/plugin-authentication-service.js +80 -80
  317. package/lib/main/browser/plugin-contribution-handler.d.ts +75 -75
  318. package/lib/main/browser/plugin-contribution-handler.d.ts.map +1 -1
  319. package/lib/main/browser/plugin-contribution-handler.js +664 -659
  320. package/lib/main/browser/plugin-contribution-handler.js.map +1 -1
  321. package/lib/main/browser/plugin-ext-frontend-module.d.ts +7 -7
  322. package/lib/main/browser/plugin-ext-frontend-module.d.ts.map +1 -1
  323. package/lib/main/browser/plugin-ext-frontend-module.js +230 -230
  324. package/lib/main/browser/plugin-ext-frontend-module.js.map +1 -1
  325. package/lib/main/browser/plugin-ext-widget.d.ts +28 -28
  326. package/lib/main/browser/plugin-ext-widget.js +129 -129
  327. package/lib/main/browser/plugin-frontend-contribution.d.ts +9 -9
  328. package/lib/main/browser/plugin-frontend-contribution.js +79 -79
  329. package/lib/main/browser/plugin-frontend-view-contribution.d.ts +6 -6
  330. package/lib/main/browser/plugin-frontend-view-contribution.js +50 -50
  331. package/lib/main/browser/plugin-icon-service.d.ts +16 -19
  332. package/lib/main/browser/plugin-icon-service.d.ts.map +1 -1
  333. package/lib/main/browser/plugin-icon-service.js +96 -155
  334. package/lib/main/browser/plugin-icon-service.js.map +1 -1
  335. package/lib/main/browser/plugin-icon-theme-service.d.ts +146 -146
  336. package/lib/main/browser/plugin-icon-theme-service.js +561 -561
  337. package/lib/main/browser/plugin-shared-style.d.ts +40 -40
  338. package/lib/main/browser/plugin-shared-style.js +144 -144
  339. package/lib/main/browser/plugin-storage.d.ts +13 -13
  340. package/lib/main/browser/plugin-storage.js +46 -46
  341. package/lib/main/browser/plugin-terminal-registry.d.ts +4 -4
  342. package/lib/main/browser/plugin-terminal-registry.js +34 -34
  343. package/lib/main/browser/preference-registry-main.d.ts +19 -19
  344. package/lib/main/browser/preference-registry-main.js +104 -104
  345. package/lib/main/browser/quick-open-main.d.ts +32 -31
  346. package/lib/main/browser/quick-open-main.d.ts.map +1 -1
  347. package/lib/main/browser/quick-open-main.js +318 -281
  348. package/lib/main/browser/quick-open-main.js.map +1 -1
  349. package/lib/main/browser/scm-main.d.ts +106 -106
  350. package/lib/main/browser/scm-main.js +346 -346
  351. package/lib/main/browser/scm-main.js.map +1 -1
  352. package/lib/main/browser/secrets-main.d.ts +12 -12
  353. package/lib/main/browser/secrets-main.js +67 -67
  354. package/lib/main/browser/selection-provider-command.d.ts +12 -12
  355. package/lib/main/browser/selection-provider-command.d.ts.map +1 -1
  356. package/lib/main/browser/selection-provider-command.js +56 -57
  357. package/lib/main/browser/selection-provider-command.js.map +1 -1
  358. package/lib/main/browser/status-bar-message-registry-main.d.ts +16 -16
  359. package/lib/main/browser/status-bar-message-registry-main.js +55 -55
  360. package/lib/main/browser/tabs/tabs-main.d.ts +47 -47
  361. package/lib/main/browser/tabs/tabs-main.js +291 -291
  362. package/lib/main/browser/tasks-main.d.ts +33 -33
  363. package/lib/main/browser/tasks-main.js +208 -208
  364. package/lib/main/browser/terminal-main.d.ts +50 -50
  365. package/lib/main/browser/terminal-main.d.ts.map +1 -1
  366. package/lib/main/browser/terminal-main.js +269 -269
  367. package/lib/main/browser/terminal-main.js.map +1 -1
  368. package/lib/main/browser/test-main.d.ts +140 -140
  369. package/lib/main/browser/test-main.js +559 -559
  370. package/lib/main/browser/text-editor-main.d.ts +47 -47
  371. package/lib/main/browser/text-editor-main.js +384 -384
  372. package/lib/main/browser/text-editor-model-service.d.ts +28 -28
  373. package/lib/main/browser/text-editor-model-service.js +108 -108
  374. package/lib/main/browser/text-editors-main.d.ts +37 -38
  375. package/lib/main/browser/text-editors-main.d.ts.map +1 -1
  376. package/lib/main/browser/text-editors-main.js +164 -158
  377. package/lib/main/browser/text-editors-main.js.map +1 -1
  378. package/lib/main/browser/theme-icon-override.d.ts +1 -1
  379. package/lib/main/browser/theme-icon-override.js +244 -250
  380. package/lib/main/browser/theme-icon-override.js.map +1 -1
  381. package/lib/main/browser/theming-main.d.ts +9 -9
  382. package/lib/main/browser/theming-main.js +35 -35
  383. package/lib/main/browser/timeline-main.d.ts +13 -13
  384. package/lib/main/browser/timeline-main.js +50 -50
  385. package/lib/main/browser/view/dnd-file-content-store.d.ts +7 -7
  386. package/lib/main/browser/view/dnd-file-content-store.js +51 -51
  387. package/lib/main/browser/view/plugin-tree-view-node-label-provider.d.ts +11 -11
  388. package/lib/main/browser/view/plugin-tree-view-node-label-provider.js +90 -90
  389. package/lib/main/browser/view/plugin-tree-view-node-label-provider.js.map +1 -1
  390. package/lib/main/browser/view/plugin-view-registry.d.ts +105 -103
  391. package/lib/main/browser/view/plugin-view-registry.d.ts.map +1 -1
  392. package/lib/main/browser/view/plugin-view-registry.js +892 -876
  393. package/lib/main/browser/view/plugin-view-registry.js.map +1 -1
  394. package/lib/main/browser/view/plugin-view-widget.d.ts +62 -62
  395. package/lib/main/browser/view/plugin-view-widget.d.ts.map +1 -1
  396. package/lib/main/browser/view/plugin-view-widget.js +206 -207
  397. package/lib/main/browser/view/plugin-view-widget.js.map +1 -1
  398. package/lib/main/browser/view/tree-view-decorator-service.d.ts +30 -30
  399. package/lib/main/browser/view/tree-view-decorator-service.js +68 -68
  400. package/lib/main/browser/view/tree-view-widget.d.ts +166 -166
  401. package/lib/main/browser/view/tree-view-widget.d.ts.map +1 -1
  402. package/lib/main/browser/view/tree-view-widget.js +843 -844
  403. package/lib/main/browser/view/tree-view-widget.js.map +1 -1
  404. package/lib/main/browser/view/tree-views-main.d.ts +34 -34
  405. package/lib/main/browser/view/tree-views-main.js +181 -181
  406. package/lib/main/browser/view/view-context-key-service.d.ts +18 -18
  407. package/lib/main/browser/view/view-context-key-service.js +74 -74
  408. package/lib/main/browser/view-column-service.d.ts +23 -23
  409. package/lib/main/browser/view-column-service.js +129 -129
  410. package/lib/main/browser/webview/webview-context-keys.d.ts +16 -12
  411. package/lib/main/browser/webview/webview-context-keys.d.ts.map +1 -1
  412. package/lib/main/browser/webview/webview-context-keys.js +72 -63
  413. package/lib/main/browser/webview/webview-context-keys.js.map +1 -1
  414. package/lib/main/browser/webview/webview-environment.d.ts +16 -16
  415. package/lib/main/browser/webview/webview-environment.js +96 -96
  416. package/lib/main/browser/webview/webview-frontend-security-warnings.d.ts +11 -11
  417. package/lib/main/browser/webview/webview-frontend-security-warnings.js +73 -73
  418. package/lib/main/browser/webview/webview-preferences.d.ts +12 -12
  419. package/lib/main/browser/webview/webview-preferences.js +57 -57
  420. package/lib/main/browser/webview/webview-resource-cache.d.ts +17 -17
  421. package/lib/main/browser/webview/webview-resource-cache.js +90 -90
  422. package/lib/main/browser/webview/webview-theme-data-provider.d.ts +30 -30
  423. package/lib/main/browser/webview/webview-theme-data-provider.js +132 -132
  424. package/lib/main/browser/webview/webview-widget-factory.d.ts +8 -8
  425. package/lib/main/browser/webview/webview-widget-factory.d.ts.map +1 -1
  426. package/lib/main/browser/webview/webview-widget-factory.js +39 -38
  427. package/lib/main/browser/webview/webview-widget-factory.js.map +1 -1
  428. package/lib/main/browser/webview/webview.d.ts +162 -161
  429. package/lib/main/browser/webview/webview.d.ts.map +1 -1
  430. package/lib/main/browser/webview/webview.js +620 -619
  431. package/lib/main/browser/webview/webview.js.map +1 -1
  432. package/lib/main/browser/webview-views/webview-views-main.d.ts +32 -32
  433. package/lib/main/browser/webview-views/webview-views-main.js +136 -136
  434. package/lib/main/browser/webview-views/webview-views.d.ts +19 -19
  435. package/lib/main/browser/webview-views/webview-views.js +22 -22
  436. package/lib/main/browser/webviews-main.d.ts +40 -40
  437. package/lib/main/browser/webviews-main.d.ts.map +1 -1
  438. package/lib/main/browser/webviews-main.js +248 -243
  439. package/lib/main/browser/webviews-main.js.map +1 -1
  440. package/lib/main/browser/window-state-main.d.ts +16 -16
  441. package/lib/main/browser/window-state-main.js +61 -61
  442. package/lib/main/browser/workspace-main.d.ts +77 -77
  443. package/lib/main/browser/workspace-main.js +348 -348
  444. package/lib/main/common/basic-message-registry-main.d.ts +14 -0
  445. package/lib/main/common/basic-message-registry-main.d.ts.map +1 -0
  446. package/lib/main/common/basic-message-registry-main.js +50 -0
  447. package/lib/main/common/basic-message-registry-main.js.map +1 -0
  448. package/lib/main/common/basic-notification-main.d.ts +19 -0
  449. package/lib/main/common/basic-notification-main.d.ts.map +1 -0
  450. package/lib/main/common/basic-notification-main.js +75 -0
  451. package/lib/main/common/basic-notification-main.js.map +1 -0
  452. package/lib/main/common/env-main.d.ts +11 -0
  453. package/lib/main/common/env-main.d.ts.map +1 -0
  454. package/lib/main/common/env-main.js +40 -0
  455. package/lib/main/common/env-main.js.map +1 -0
  456. package/lib/main/common/plugin-paths-protocol.d.ts +8 -8
  457. package/lib/main/common/plugin-paths-protocol.js +21 -21
  458. package/lib/main/common/plugin-theia-environment.d.ts +7 -7
  459. package/lib/main/common/plugin-theia-environment.js +47 -47
  460. package/lib/main/common/webview-protocol.d.ts +12 -12
  461. package/lib/main/common/webview-protocol.js +31 -31
  462. package/lib/main/electron-browser/plugin-ext-frontend-electron-module.d.ts +3 -3
  463. package/lib/main/electron-browser/plugin-ext-frontend-electron-module.js +25 -25
  464. package/lib/main/electron-browser/webview/electron-webview-widget-factory.d.ts +23 -23
  465. package/lib/main/electron-browser/webview/electron-webview-widget-factory.js +53 -53
  466. package/lib/main/node/errors.spec.d.ts +1 -1
  467. package/lib/main/node/errors.spec.js +35 -35
  468. package/lib/main/node/errors.spec.js.map +1 -1
  469. package/lib/main/node/handlers/plugin-theia-directory-handler.d.ts +18 -13
  470. package/lib/main/node/handlers/plugin-theia-directory-handler.d.ts.map +1 -1
  471. package/lib/main/node/handlers/plugin-theia-directory-handler.js +137 -119
  472. package/lib/main/node/handlers/plugin-theia-directory-handler.js.map +1 -1
  473. package/lib/main/node/handlers/plugin-theia-file-handler.d.ts +10 -10
  474. package/lib/main/node/handlers/plugin-theia-file-handler.js +74 -74
  475. package/lib/main/node/handlers/plugin-theia-file-handler.js.map +1 -1
  476. package/lib/main/node/paths/const.d.ts +5 -5
  477. package/lib/main/node/paths/const.js +24 -24
  478. package/lib/main/node/paths/plugin-paths-service.d.ts +25 -25
  479. package/lib/main/node/paths/plugin-paths-service.js +160 -160
  480. package/lib/main/node/plugin-cli-contribution.d.ts +21 -21
  481. package/lib/main/node/plugin-cli-contribution.js +84 -84
  482. package/lib/main/node/plugin-deployer-contribution.d.ts +8 -8
  483. package/lib/main/node/plugin-deployer-contribution.js +48 -48
  484. package/lib/main/node/plugin-deployer-directory-handler-context-impl.d.ts +7 -7
  485. package/lib/main/node/plugin-deployer-directory-handler-context-impl.js +44 -44
  486. package/lib/main/node/plugin-deployer-entry-impl.d.ts +34 -34
  487. package/lib/main/node/plugin-deployer-entry-impl.js +111 -111
  488. package/lib/main/node/plugin-deployer-file-handler-context-impl.d.ts +7 -7
  489. package/lib/main/node/plugin-deployer-file-handler-context-impl.js +31 -31
  490. package/lib/main/node/plugin-deployer-impl.d.ts +61 -61
  491. package/lib/main/node/plugin-deployer-impl.d.ts.map +1 -1
  492. package/lib/main/node/plugin-deployer-impl.js +338 -334
  493. package/lib/main/node/plugin-deployer-impl.js.map +1 -1
  494. package/lib/main/node/plugin-deployer-proxy-entry-impl.d.ts +29 -29
  495. package/lib/main/node/plugin-deployer-proxy-entry-impl.js +98 -98
  496. package/lib/main/node/plugin-deployer-resolver-context-impl.d.ts +15 -15
  497. package/lib/main/node/plugin-deployer-resolver-context-impl.js +42 -42
  498. package/lib/main/node/plugin-ext-backend-module.d.ts +2 -2
  499. package/lib/main/node/plugin-ext-backend-module.js +73 -73
  500. package/lib/main/node/plugin-github-resolver.d.ts +23 -23
  501. package/lib/main/node/plugin-github-resolver.js +143 -143
  502. package/lib/main/node/plugin-http-resolver.d.ts +20 -20
  503. package/lib/main/node/plugin-http-resolver.js +99 -99
  504. package/lib/main/node/plugin-localization-server.d.ts +9 -9
  505. package/lib/main/node/plugin-localization-server.js +58 -58
  506. package/lib/main/node/plugin-mgmt-cli-contribution.d.ts +12 -12
  507. package/lib/main/node/plugin-mgmt-cli-contribution.js +70 -70
  508. package/lib/main/node/plugin-server-handler.d.ts +16 -16
  509. package/lib/main/node/plugin-server-handler.js +74 -74
  510. package/lib/main/node/plugin-service.d.ts +23 -23
  511. package/lib/main/node/plugin-service.js +109 -109
  512. package/lib/main/node/plugin-theia-deployer-participant.d.ts +6 -6
  513. package/lib/main/node/plugin-theia-deployer-participant.js +43 -43
  514. package/lib/main/node/plugin-uninstallation-manager.d.ts +14 -14
  515. package/lib/main/node/plugin-uninstallation-manager.js +84 -84
  516. package/lib/main/node/plugins-key-value-storage.d.ts +28 -28
  517. package/lib/main/node/plugins-key-value-storage.js +167 -167
  518. package/lib/main/node/plugins-key-value-storage.js.map +1 -1
  519. package/lib/main/node/plugins-key-value-storage.spec.d.ts +16 -16
  520. package/lib/main/node/plugins-key-value-storage.spec.js +100 -100
  521. package/lib/main/node/resolvers/local-directory-plugin-deployer-resolver.d.ts +7 -7
  522. package/lib/main/node/resolvers/local-directory-plugin-deployer-resolver.js +43 -43
  523. package/lib/main/node/resolvers/local-plugin-deployer-resolver.d.ts +8 -8
  524. package/lib/main/node/resolvers/local-plugin-deployer-resolver.js +59 -59
  525. package/lib/main/node/temp-dir-util.d.ts +2 -2
  526. package/lib/main/node/temp-dir-util.js +39 -39
  527. package/lib/main/node/webview-backend-security-warnings.d.ts +5 -5
  528. package/lib/main/node/webview-backend-security-warnings.js +51 -51
  529. package/lib/plugin/authentication-ext.d.ts +30 -30
  530. package/lib/plugin/authentication-ext.js +94 -94
  531. package/lib/plugin/clipboard-ext.d.ts +10 -9
  532. package/lib/plugin/clipboard-ext.d.ts.map +1 -1
  533. package/lib/plugin/clipboard-ext.js +55 -31
  534. package/lib/plugin/clipboard-ext.js.map +1 -1
  535. package/lib/plugin/command-registry.d.ts +41 -41
  536. package/lib/plugin/command-registry.js +182 -182
  537. package/lib/plugin/comments.d.ts +92 -92
  538. package/lib/plugin/comments.js +392 -392
  539. package/lib/plugin/custom-editors.d.ts +47 -47
  540. package/lib/plugin/custom-editors.js +255 -255
  541. package/lib/plugin/custom-editors.js.map +1 -1
  542. package/lib/plugin/debug/debug-ext.d.ts +88 -86
  543. package/lib/plugin/debug/debug-ext.d.ts.map +1 -1
  544. package/lib/plugin/debug/debug-ext.js +421 -394
  545. package/lib/plugin/debug/debug-ext.js.map +1 -1
  546. package/lib/plugin/debug/plugin-debug-adapter-creator.d.ts +10 -10
  547. package/lib/plugin/debug/plugin-debug-adapter-creator.js +41 -41
  548. package/lib/plugin/debug/plugin-debug-adapter-session.d.ts +26 -26
  549. package/lib/plugin/debug/plugin-debug-adapter-session.js +96 -96
  550. package/lib/plugin/debug/plugin-debug-adapter-tracker.d.ts +12 -12
  551. package/lib/plugin/debug/plugin-debug-adapter-tracker.js +77 -77
  552. package/lib/plugin/decorations.d.ts +14 -14
  553. package/lib/plugin/decorations.js +112 -112
  554. package/lib/plugin/dialogs.d.ts +10 -10
  555. package/lib/plugin/dialogs.js +91 -91
  556. package/lib/plugin/document-data.d.ts +38 -38
  557. package/lib/plugin/document-data.js +309 -309
  558. package/lib/plugin/documents.d.ts +56 -56
  559. package/lib/plugin/documents.js +253 -253
  560. package/lib/plugin/documents.js.map +1 -1
  561. package/lib/plugin/editors-and-documents.d.ts +25 -26
  562. package/lib/plugin/editors-and-documents.d.ts.map +1 -1
  563. package/lib/plugin/editors-and-documents.js +154 -137
  564. package/lib/plugin/editors-and-documents.js.map +1 -1
  565. package/lib/plugin/env.d.ts +38 -34
  566. package/lib/plugin/env.d.ts.map +1 -1
  567. package/lib/plugin/env.js +118 -85
  568. package/lib/plugin/env.js.map +1 -1
  569. package/lib/plugin/file-system-event-service-ext-impl.d.ts +40 -40
  570. package/lib/plugin/file-system-event-service-ext-impl.js +203 -203
  571. package/lib/plugin/file-system-ext-impl.d.ts +56 -56
  572. package/lib/plugin/file-system-ext-impl.js +346 -346
  573. package/lib/plugin/known-commands.d.ts +5 -5
  574. package/lib/plugin/known-commands.d.ts.map +1 -1
  575. package/lib/plugin/known-commands.js +400 -399
  576. package/lib/plugin/known-commands.js.map +1 -1
  577. package/lib/plugin/known-commands.spec.d.ts +1 -1
  578. package/lib/plugin/known-commands.spec.js +42 -42
  579. package/lib/plugin/label-service.d.ts +11 -11
  580. package/lib/plugin/label-service.js +35 -35
  581. package/lib/plugin/languages/call-hierarchy.d.ts +20 -20
  582. package/lib/plugin/languages/call-hierarchy.js +101 -101
  583. package/lib/plugin/languages/code-action.d.ts +24 -24
  584. package/lib/plugin/languages/code-action.js +137 -137
  585. package/lib/plugin/languages/color.d.ts +12 -12
  586. package/lib/plugin/languages/color.js +58 -58
  587. package/lib/plugin/languages/completion.d.ts +20 -20
  588. package/lib/plugin/languages/completion.js +164 -164
  589. package/lib/plugin/languages/declaration.d.ts +11 -11
  590. package/lib/plugin/languages/declaration.js +58 -58
  591. package/lib/plugin/languages/definition.d.ts +11 -11
  592. package/lib/plugin/languages/definition.js +58 -58
  593. package/lib/plugin/languages/diagnostics.d.ts +49 -49
  594. package/lib/plugin/languages/diagnostics.js +281 -281
  595. package/lib/plugin/languages/diagnostics.js.map +1 -1
  596. package/lib/plugin/languages/document-drop-edit.d.ts +15 -15
  597. package/lib/plugin/languages/document-drop-edit.js +22 -22
  598. package/lib/plugin/languages/document-formatting.d.ts +10 -10
  599. package/lib/plugin/languages/document-formatting.js +40 -40
  600. package/lib/plugin/languages/document-highlight.d.ts +12 -12
  601. package/lib/plugin/languages/document-highlight.js +50 -50
  602. package/lib/plugin/languages/evaluatable-expression.d.ts +11 -11
  603. package/lib/plugin/languages/evaluatable-expression.js +40 -40
  604. package/lib/plugin/languages/folding.d.ts +10 -10
  605. package/lib/plugin/languages/folding.js +39 -39
  606. package/lib/plugin/languages/hover.d.ts +11 -11
  607. package/lib/plugin/languages/hover.js +48 -48
  608. package/lib/plugin/languages/implementation.d.ts +11 -11
  609. package/lib/plugin/languages/implementation.js +58 -58
  610. package/lib/plugin/languages/inlay-hints.d.ts +19 -19
  611. package/lib/plugin/languages/inlay-hints.js +127 -127
  612. package/lib/plugin/languages/inline-completion.d.ts +20 -20
  613. package/lib/plugin/languages/inline-completion.js +93 -93
  614. package/lib/plugin/languages/inline-values.d.ts +10 -10
  615. package/lib/plugin/languages/inline-values.js +44 -44
  616. package/lib/plugin/languages/lens.d.ts +19 -19
  617. package/lib/plugin/languages/lens.js +89 -89
  618. package/lib/plugin/languages/link-provider.d.ts +14 -14
  619. package/lib/plugin/languages/link-provider.d.ts.map +1 -1
  620. package/lib/plugin/languages/link-provider.js +73 -71
  621. package/lib/plugin/languages/link-provider.js.map +1 -1
  622. package/lib/plugin/languages/linked-editing-range.d.ts +11 -11
  623. package/lib/plugin/languages/linked-editing-range.js +40 -40
  624. package/lib/plugin/languages/on-type-formatting.d.ts +11 -11
  625. package/lib/plugin/languages/on-type-formatting.js +41 -41
  626. package/lib/plugin/languages/outline.d.ts +20 -20
  627. package/lib/plugin/languages/outline.js +115 -115
  628. package/lib/plugin/languages/range-formatting.d.ts +10 -10
  629. package/lib/plugin/languages/range-formatting.js +41 -41
  630. package/lib/plugin/languages/reference.d.ts +11 -11
  631. package/lib/plugin/languages/reference.js +47 -47
  632. package/lib/plugin/languages/rename.d.ts +14 -14
  633. package/lib/plugin/languages/rename.js +114 -114
  634. package/lib/plugin/languages/selection-range.d.ts +11 -11
  635. package/lib/plugin/languages/selection-range.js +65 -65
  636. package/lib/plugin/languages/semantic-highlighting.d.ts +28 -28
  637. package/lib/plugin/languages/semantic-highlighting.js +175 -175
  638. package/lib/plugin/languages/signature.d.ts +15 -15
  639. package/lib/plugin/languages/signature.js +71 -71
  640. package/lib/plugin/languages/type-definition.d.ts +11 -11
  641. package/lib/plugin/languages/type-definition.js +58 -58
  642. package/lib/plugin/languages/type-hierarchy.d.ts +18 -18
  643. package/lib/plugin/languages/type-hierarchy.js +95 -95
  644. package/lib/plugin/languages/util.d.ts +4 -4
  645. package/lib/plugin/languages/util.js +27 -27
  646. package/lib/plugin/languages/workspace-symbol.d.ts +8 -8
  647. package/lib/plugin/languages/workspace-symbol.js +61 -61
  648. package/lib/plugin/languages-utils.d.ts +6 -6
  649. package/lib/plugin/languages-utils.js +65 -65
  650. package/lib/plugin/languages.d.ts +127 -127
  651. package/lib/plugin/languages.js +712 -712
  652. package/lib/plugin/localization-ext.d.ts +17 -16
  653. package/lib/plugin/localization-ext.d.ts.map +1 -1
  654. package/lib/plugin/localization-ext.js +99 -73
  655. package/lib/plugin/localization-ext.js.map +1 -1
  656. package/lib/plugin/markdown-string.d.ts +24 -24
  657. package/lib/plugin/markdown-string.d.ts.map +1 -1
  658. package/lib/plugin/markdown-string.js +124 -124
  659. package/lib/plugin/markdown-string.js.map +1 -1
  660. package/lib/plugin/message-registry.d.ts +9 -8
  661. package/lib/plugin/message-registry.d.ts.map +1 -1
  662. package/lib/plugin/message-registry.js +84 -60
  663. package/lib/plugin/message-registry.js.map +1 -1
  664. package/lib/plugin/node/debug/debug.spec.d.ts +1 -1
  665. package/lib/plugin/node/debug/debug.spec.js +87 -67
  666. package/lib/plugin/node/debug/debug.spec.js.map +1 -1
  667. package/lib/plugin/node/debug/plugin-node-debug-adapter-creator.d.ts +17 -17
  668. package/lib/plugin/node/debug/plugin-node-debug-adapter-creator.js +154 -154
  669. package/lib/plugin/node/env-node-ext.d.ts +16 -21
  670. package/lib/plugin/node/env-node-ext.d.ts.map +1 -1
  671. package/lib/plugin/node/env-node-ext.js +71 -63
  672. package/lib/plugin/node/env-node-ext.js.map +1 -1
  673. package/lib/plugin/node/plugin-container-module.d.ts +75 -0
  674. package/lib/plugin/node/plugin-container-module.d.ts.map +1 -0
  675. package/lib/plugin/node/plugin-container-module.js +115 -0
  676. package/lib/plugin/node/plugin-container-module.js.map +1 -0
  677. package/lib/plugin/notebook/notebook-document.d.ts +61 -61
  678. package/lib/plugin/notebook/notebook-document.js +372 -372
  679. package/lib/plugin/notebook/notebook-documents.d.ts +16 -16
  680. package/lib/plugin/notebook/notebook-documents.js +47 -47
  681. package/lib/plugin/notebook/notebook-editor.d.ts +20 -20
  682. package/lib/plugin/notebook/notebook-editor.js +98 -98
  683. package/lib/plugin/notebook/notebook-editors.d.ts +13 -13
  684. package/lib/plugin/notebook/notebook-editors.js +64 -64
  685. package/lib/plugin/notebook/notebook-kernels.d.ts +35 -36
  686. package/lib/plugin/notebook/notebook-kernels.d.ts.map +1 -1
  687. package/lib/plugin/notebook/notebook-kernels.js +516 -516
  688. package/lib/plugin/notebook/notebook-kernels.js.map +1 -1
  689. package/lib/plugin/notebook/notebook-renderers.d.ts +13 -13
  690. package/lib/plugin/notebook/notebook-renderers.d.ts.map +1 -1
  691. package/lib/plugin/notebook/notebook-renderers.js +62 -62
  692. package/lib/plugin/notebook/notebook-renderers.js.map +1 -1
  693. package/lib/plugin/notebook/notebooks.d.ts +57 -56
  694. package/lib/plugin/notebook/notebooks.d.ts.map +1 -1
  695. package/lib/plugin/notebook/notebooks.js +316 -297
  696. package/lib/plugin/notebook/notebooks.js.map +1 -1
  697. package/lib/plugin/notification.d.ts +17 -17
  698. package/lib/plugin/notification.js +67 -67
  699. package/lib/plugin/output-channel/log-output-channel.d.ts +23 -23
  700. package/lib/plugin/output-channel/log-output-channel.js +91 -91
  701. package/lib/plugin/output-channel/output-channel-item.d.ts +17 -17
  702. package/lib/plugin/output-channel/output-channel-item.js +51 -51
  703. package/lib/plugin/output-channel-registry.d.ts +13 -13
  704. package/lib/plugin/output-channel-registry.js +44 -44
  705. package/lib/plugin/path.d.ts +2 -2
  706. package/lib/plugin/path.js +59 -59
  707. package/lib/plugin/path.spec.d.ts +1 -1
  708. package/lib/plugin/path.spec.js +34 -34
  709. package/lib/plugin/plugin-context.d.ts +58 -58
  710. package/lib/plugin/plugin-context.d.ts.map +1 -1
  711. package/lib/plugin/plugin-context.js +1185 -1170
  712. package/lib/plugin/plugin-context.js.map +1 -1
  713. package/lib/plugin/plugin-icon-path.d.ts +11 -11
  714. package/lib/plugin/plugin-icon-path.js +49 -49
  715. package/lib/plugin/plugin-manager.d.ts +92 -83
  716. package/lib/plugin/plugin-manager.d.ts.map +1 -1
  717. package/lib/plugin/plugin-manager.js +428 -358
  718. package/lib/plugin/plugin-manager.js.map +1 -1
  719. package/lib/plugin/plugin-storage.d.ts +44 -36
  720. package/lib/plugin/plugin-storage.d.ts.map +1 -1
  721. package/lib/plugin/plugin-storage.js +119 -99
  722. package/lib/plugin/plugin-storage.js.map +1 -1
  723. package/lib/plugin/preference-registry.d.ts +40 -39
  724. package/lib/plugin/preference-registry.d.ts.map +1 -1
  725. package/lib/plugin/preference-registry.js +317 -287
  726. package/lib/plugin/preference-registry.js.map +1 -1
  727. package/lib/plugin/preference-registry.spec.d.ts +1 -1
  728. package/lib/plugin/preference-registry.spec.js +246 -239
  729. package/lib/plugin/preference-registry.spec.js.map +1 -1
  730. package/lib/plugin/prefix-sum-computer.d.ts +30 -30
  731. package/lib/plugin/prefix-sum-computer.js +172 -172
  732. package/lib/plugin/quick-open.d.ts +195 -202
  733. package/lib/plugin/quick-open.d.ts.map +1 -1
  734. package/lib/plugin/quick-open.js +622 -638
  735. package/lib/plugin/quick-open.js.map +1 -1
  736. package/lib/plugin/scm.d.ts +53 -53
  737. package/lib/plugin/scm.js +726 -726
  738. package/lib/plugin/secrets-ext.d.ts +39 -30
  739. package/lib/plugin/secrets-ext.d.ts.map +1 -1
  740. package/lib/plugin/secrets-ext.js +88 -68
  741. package/lib/plugin/secrets-ext.js.map +1 -1
  742. package/lib/plugin/status-bar/status-bar-item.d.ts +44 -44
  743. package/lib/plugin/status-bar/status-bar-item.js +122 -122
  744. package/lib/plugin/status-bar-message-registry.d.ts +20 -20
  745. package/lib/plugin/status-bar-message-registry.js +84 -84
  746. package/lib/plugin/tabs.d.ts +22 -22
  747. package/lib/plugin/tabs.js +358 -358
  748. package/lib/plugin/tasks/task-provider.d.ts +8 -8
  749. package/lib/plugin/tasks/task-provider.js +53 -53
  750. package/lib/plugin/tasks/tasks.d.ts +46 -46
  751. package/lib/plugin/tasks/tasks.js +215 -215
  752. package/lib/plugin/telemetry-ext.d.ts +43 -43
  753. package/lib/plugin/telemetry-ext.js +251 -251
  754. package/lib/plugin/terminal-ext.d.ts +113 -113
  755. package/lib/plugin/terminal-ext.d.ts.map +1 -1
  756. package/lib/plugin/terminal-ext.js +488 -468
  757. package/lib/plugin/terminal-ext.js.map +1 -1
  758. package/lib/plugin/test-item.d.ts +46 -46
  759. package/lib/plugin/test-item.js +195 -195
  760. package/lib/plugin/tests.d.ts +121 -121
  761. package/lib/plugin/tests.js +423 -423
  762. package/lib/plugin/tests.js.map +1 -1
  763. package/lib/plugin/text-editor.d.ts +104 -104
  764. package/lib/plugin/text-editor.js +464 -464
  765. package/lib/plugin/text-editors.d.ts +39 -37
  766. package/lib/plugin/text-editors.d.ts.map +1 -1
  767. package/lib/plugin/text-editors.js +132 -126
  768. package/lib/plugin/text-editors.js.map +1 -1
  769. package/lib/plugin/theming.d.ts +15 -15
  770. package/lib/plugin/theming.js +61 -61
  771. package/lib/plugin/timeline.d.ts +20 -20
  772. package/lib/plugin/timeline.js +157 -157
  773. package/lib/plugin/tree/tree-views.d.ts +107 -107
  774. package/lib/plugin/tree/tree-views.js +590 -590
  775. package/lib/plugin/type-converters.d.ts +204 -195
  776. package/lib/plugin/type-converters.d.ts.map +1 -1
  777. package/lib/plugin/type-converters.js +1676 -1637
  778. package/lib/plugin/type-converters.js.map +1 -1
  779. package/lib/plugin/type-converters.spec.d.ts +1 -1
  780. package/lib/plugin/type-converters.spec.js +395 -395
  781. package/lib/plugin/types-impl.d.ts +1653 -1633
  782. package/lib/plugin/types-impl.d.ts.map +1 -1
  783. package/lib/plugin/types-impl.js +3185 -3169
  784. package/lib/plugin/types-impl.js.map +1 -1
  785. package/lib/plugin/types-impl.spec.d.ts +1 -1
  786. package/lib/plugin/types-impl.spec.js +78 -78
  787. package/lib/plugin/webview-views.d.ts +55 -55
  788. package/lib/plugin/webview-views.d.ts.map +1 -1
  789. package/lib/plugin/webview-views.js +156 -155
  790. package/lib/plugin/webview-views.js.map +1 -1
  791. package/lib/plugin/webviews.d.ts +110 -95
  792. package/lib/plugin/webviews.d.ts.map +1 -1
  793. package/lib/plugin/webviews.js +393 -343
  794. package/lib/plugin/webviews.js.map +1 -1
  795. package/lib/plugin/window-state.d.ts +16 -16
  796. package/lib/plugin/window-state.js +54 -54
  797. package/lib/plugin/word-helper.d.ts +21 -21
  798. package/lib/plugin/word-helper.js +125 -125
  799. package/lib/plugin/workspace.d.ts +62 -61
  800. package/lib/plugin/workspace.d.ts.map +1 -1
  801. package/lib/plugin/workspace.js +445 -411
  802. package/lib/plugin/workspace.js.map +1 -1
  803. package/lib/plugin-ext-backend-electron-module.d.ts +3 -3
  804. package/lib/plugin-ext-backend-electron-module.js +24 -24
  805. package/lib/plugin-ext-backend-module.d.ts +3 -3
  806. package/lib/plugin-ext-backend-module.js +24 -24
  807. package/lib/plugin-ext-frontend-electron-module.d.ts +2 -2
  808. package/lib/plugin-ext-frontend-electron-module.js +19 -19
  809. package/lib/plugin-ext-frontend-module.d.ts +2 -2
  810. package/lib/plugin-ext-frontend-module.js +19 -19
  811. package/package.json +30 -31
  812. package/src/common/arrays.ts +70 -70
  813. package/src/common/assert.ts +23 -23
  814. package/src/common/cache.ts +51 -51
  815. package/src/common/character-classifier.ts +73 -73
  816. package/src/common/collections.ts +54 -54
  817. package/src/common/commands.ts +19 -19
  818. package/src/common/connection.ts +137 -137
  819. package/src/common/disposable-util.ts +39 -39
  820. package/src/common/editor-options.ts +74 -74
  821. package/src/common/env.ts +19 -19
  822. package/src/common/errors.ts +63 -63
  823. package/src/common/id-generator.ts +26 -26
  824. package/src/common/index.ts +24 -24
  825. package/src/common/language-pack-service.ts +34 -34
  826. package/src/common/link-computer.ts +354 -354
  827. package/src/common/object-identifier.ts +33 -33
  828. package/src/common/objects.ts +50 -50
  829. package/src/common/paths-util.ts +158 -158
  830. package/src/common/plugin-api-rpc-model.ts +897 -897
  831. package/src/common/plugin-api-rpc.ts +2686 -2669
  832. package/src/common/plugin-ext-api-contribution.ts +115 -82
  833. package/src/common/plugin-identifiers.ts +84 -84
  834. package/src/common/plugin-protocol.ts +1091 -1075
  835. package/src/common/proxy-handler.ts +141 -128
  836. package/src/common/reference-map.ts +38 -38
  837. package/src/common/rpc-protocol.ts +310 -272
  838. package/src/common/semantic-tokens-dto.ts +182 -182
  839. package/src/common/test-types.ts +153 -153
  840. package/src/common/types.ts +129 -129
  841. package/src/common/uint.ts +37 -37
  842. package/src/common/uri-components.ts +81 -85
  843. package/src/hosted/browser/hosted-plugin-watcher.ts +54 -54
  844. package/src/hosted/browser/hosted-plugin.ts +621 -910
  845. package/src/hosted/browser/plugin-worker.ts +52 -52
  846. package/src/hosted/browser/worker/debug-stub.ts +29 -28
  847. package/src/hosted/browser/worker/plugin-manifest-loader.ts +114 -114
  848. package/src/hosted/browser/worker/worker-env-ext.ts +42 -41
  849. package/src/hosted/browser/worker/worker-main.ts +212 -224
  850. package/src/hosted/browser/worker/worker-plugin-module.ts +80 -0
  851. package/src/hosted/common/hosted-plugin.ts +456 -0
  852. package/src/hosted/node/hosted-plugin-cli-contribution.ts +75 -75
  853. package/src/hosted/node/hosted-plugin-deployer-handler.ts +268 -268
  854. package/src/hosted/node/hosted-plugin-localization-service.ts +410 -410
  855. package/src/hosted/node/hosted-plugin-process.ts +248 -248
  856. package/src/hosted/node/hosted-plugin-protocol.ts +49 -49
  857. package/src/hosted/node/hosted-plugin.ts +116 -116
  858. package/src/hosted/node/metadata-scanner.ts +64 -64
  859. package/src/hosted/node/plugin-activation-events.ts +112 -112
  860. package/src/hosted/node/plugin-ext-hosted-backend-module.ts +94 -92
  861. package/src/hosted/node/plugin-host-module.ts +69 -0
  862. package/src/hosted/node/plugin-host-proxy.ts +82 -82
  863. package/src/hosted/node/plugin-host-rpc.ts +377 -218
  864. package/src/hosted/node/plugin-host.ts +110 -108
  865. package/src/hosted/node/plugin-language-pack-service.ts +43 -43
  866. package/src/hosted/node/plugin-manifest-loader.ts +32 -32
  867. package/src/hosted/node/plugin-reader.ts +136 -133
  868. package/src/hosted/node/plugin-service.ts +192 -175
  869. package/src/hosted/node/scanners/backend-init-theia.ts +71 -71
  870. package/src/hosted/node/scanners/file-plugin-uri-factory.ts +32 -32
  871. package/src/hosted/node/scanners/grammars-reader.ts +57 -57
  872. package/src/hosted/node/scanners/plugin-uri-factory.ts +33 -33
  873. package/src/hosted/node/scanners/scanner-theia.ts +951 -911
  874. package/src/hosted/node-electron/plugin-ext-hosted-electron-backend-module.ts +26 -26
  875. package/src/hosted/node-electron/scanner-theia-electron.ts +32 -32
  876. package/src/main/browser/authentication-main.ts +388 -386
  877. package/src/main/browser/clipboard-main.ts +38 -38
  878. package/src/main/browser/command-registry-main.ts +123 -123
  879. package/src/main/browser/commands.ts +104 -104
  880. package/src/main/browser/comments/comment-glyph-widget.ts +66 -66
  881. package/src/main/browser/comments/comment-thread-widget.tsx +696 -696
  882. package/src/main/browser/comments/comments-context-key-service.ts +68 -68
  883. package/src/main/browser/comments/comments-contribution.ts +268 -264
  884. package/src/main/browser/comments/comments-decorator.ts +110 -110
  885. package/src/main/browser/comments/comments-main.ts +482 -482
  886. package/src/main/browser/comments/comments-service.ts +205 -205
  887. package/src/main/browser/custom-editors/custom-editor-contribution.ts +38 -38
  888. package/src/main/browser/custom-editors/custom-editor-opener.tsx +105 -105
  889. package/src/main/browser/custom-editors/custom-editor-service.ts +108 -108
  890. package/src/main/browser/custom-editors/custom-editor-widget-factory.ts +44 -44
  891. package/src/main/browser/custom-editors/custom-editor-widget.ts +129 -127
  892. package/src/main/browser/custom-editors/custom-editors-main.ts +595 -595
  893. package/src/main/browser/custom-editors/plugin-custom-editor-registry.ts +142 -142
  894. package/src/main/browser/data-transfer/data-transfer-type-converters.ts +68 -70
  895. package/src/main/browser/debug/debug-main.ts +373 -373
  896. package/src/main/browser/debug/plugin-debug-adapter-contribution.ts +48 -48
  897. package/src/main/browser/debug/plugin-debug-configuration-provider.ts +63 -63
  898. package/src/main/browser/debug/plugin-debug-service.ts +427 -427
  899. package/src/main/browser/debug/plugin-debug-session-contribution-registry.ts +76 -76
  900. package/src/main/browser/debug/plugin-debug-session-factory.ts +105 -105
  901. package/src/main/browser/decorations/decorations-main.ts +146 -146
  902. package/src/main/browser/dialogs/modal-notification.ts +112 -112
  903. package/src/main/browser/dialogs/style/modal-notification.css +123 -123
  904. package/src/main/browser/dialogs-main.ts +185 -185
  905. package/src/main/browser/documents-main.ts +289 -289
  906. package/src/main/browser/editors-and-documents-main.ts +417 -395
  907. package/src/main/browser/env-main.ts +60 -87
  908. package/src/main/browser/file-system-main-impl.ts +263 -263
  909. package/src/main/browser/hierarchy/hierarchy-types-converters.ts +189 -189
  910. package/src/main/browser/keybindings/keybindings-contribution-handler.ts +66 -66
  911. package/src/main/browser/label-service-main.ts +51 -51
  912. package/src/main/browser/languages-main.ts +1440 -1436
  913. package/src/main/browser/localization-main.ts +34 -34
  914. package/src/main/browser/main-context.ts +212 -214
  915. package/src/main/browser/main-file-system-event-service.ts +76 -76
  916. package/src/main/browser/menus/menus-contribution-handler.ts +171 -166
  917. package/src/main/browser/menus/plugin-menu-command-adapter.ts +295 -295
  918. package/src/main/browser/menus/vscode-theia-menu-mappings.ts +105 -105
  919. package/src/main/browser/message-registry-main.ts +43 -56
  920. package/src/main/browser/notebooks/notebook-documents-and-editors-main.ts +249 -252
  921. package/src/main/browser/notebooks/notebook-documents-main.ts +165 -165
  922. package/src/main/browser/notebooks/notebook-dto.ts +131 -131
  923. package/src/main/browser/notebooks/notebook-editors-main.ts +70 -70
  924. package/src/main/browser/notebooks/notebook-kernels-main.ts +327 -286
  925. package/src/main/browser/notebooks/notebook-renderers-main.ts +47 -47
  926. package/src/main/browser/notebooks/notebooks-main.ts +135 -135
  927. package/src/main/browser/notebooks/renderers/cell-output-webview.tsx +254 -201
  928. package/src/main/browser/notebooks/renderers/output-webview-internal.ts +577 -477
  929. package/src/main/browser/notebooks/renderers/webview-communication.ts +90 -79
  930. package/src/main/browser/notification-main.ts +26 -86
  931. package/src/main/browser/output-channel-registry-main.ts +53 -53
  932. package/src/main/browser/plugin-authentication-service.ts +71 -71
  933. package/src/main/browser/plugin-contribution-handler.ts +698 -690
  934. package/src/main/browser/plugin-ext-frontend-module.ts +269 -268
  935. package/src/main/browser/plugin-ext-widget.tsx +132 -132
  936. package/src/main/browser/plugin-frontend-contribution.ts +70 -70
  937. package/src/main/browser/plugin-frontend-view-contribution.ts +38 -38
  938. package/src/main/browser/plugin-icon-service.ts +92 -156
  939. package/src/main/browser/plugin-icon-theme-service.ts +625 -625
  940. package/src/main/browser/plugin-shared-style.ts +154 -154
  941. package/src/main/browser/plugin-storage.ts +55 -55
  942. package/src/main/browser/plugin-terminal-registry.ts +27 -27
  943. package/src/main/browser/preference-registry-main.ts +123 -123
  944. package/src/main/browser/quick-open-main.ts +373 -324
  945. package/src/main/browser/scm-main.ts +472 -472
  946. package/src/main/browser/secrets-main.ts +82 -82
  947. package/src/main/browser/selection-provider-command.ts +45 -46
  948. package/src/main/browser/status-bar-message-registry-main.ts +90 -90
  949. package/src/main/browser/style/comments.css +345 -345
  950. package/src/main/browser/style/index.css +84 -84
  951. package/src/main/browser/style/plugin-sidebar.css +73 -73
  952. package/src/main/browser/style/tree.css +54 -54
  953. package/src/main/browser/style/webview.css +55 -55
  954. package/src/main/browser/tabs/tabs-main.ts +333 -333
  955. package/src/main/browser/tasks-main.ts +268 -268
  956. package/src/main/browser/terminal-main.ts +304 -304
  957. package/src/main/browser/test-main.ts +618 -618
  958. package/src/main/browser/text-editor-main.ts +472 -472
  959. package/src/main/browser/text-editor-model-service.ts +102 -102
  960. package/src/main/browser/text-editors-main.ts +215 -207
  961. package/src/main/browser/theme-icon-override.ts +246 -252
  962. package/src/main/browser/theming-main.ts +42 -42
  963. package/src/main/browser/timeline-main.ts +80 -80
  964. package/src/main/browser/view/dnd-file-content-store.ts +42 -42
  965. package/src/main/browser/view/plugin-tree-view-node-label-provider.ts +81 -81
  966. package/src/main/browser/view/plugin-view-registry.ts +942 -924
  967. package/src/main/browser/view/plugin-view-widget.ts +221 -222
  968. package/src/main/browser/view/tree-view-decorator-service.ts +51 -51
  969. package/src/main/browser/view/tree-view-widget.tsx +931 -932
  970. package/src/main/browser/view/tree-views-main.ts +209 -209
  971. package/src/main/browser/view/view-context-key-service.ts +70 -70
  972. package/src/main/browser/view-column-service.ts +125 -125
  973. package/src/main/browser/webview/pre/fake.html +14 -14
  974. package/src/main/browser/webview/pre/host.js +130 -130
  975. package/src/main/browser/webview/pre/index.html +17 -17
  976. package/src/main/browser/webview/pre/main.js +682 -682
  977. package/src/main/browser/webview/pre/service-worker.js +295 -295
  978. package/src/main/browser/webview/webview-context-keys.ts +62 -49
  979. package/src/main/browser/webview/webview-environment.ts +87 -87
  980. package/src/main/browser/webview/webview-frontend-security-warnings.ts +59 -59
  981. package/src/main/browser/webview/webview-preferences.ts +72 -72
  982. package/src/main/browser/webview/webview-resource-cache.ts +88 -88
  983. package/src/main/browser/webview/webview-theme-data-provider.ts +124 -124
  984. package/src/main/browser/webview/webview-widget-factory.ts +2 -1
  985. package/src/main/browser/webview/webview.ts +719 -717
  986. package/src/main/browser/webview-views/webview-views-main.ts +154 -154
  987. package/src/main/browser/webview-views/webview-views.ts +43 -43
  988. package/src/main/browser/webviews-main.ts +282 -277
  989. package/src/main/browser/window-state-main.ts +76 -76
  990. package/src/main/browser/workspace-main.ts +424 -424
  991. package/src/main/common/basic-message-registry-main.ts +53 -0
  992. package/src/main/common/basic-notification-main.ts +86 -0
  993. package/src/main/common/env-main.ts +44 -0
  994. package/src/main/common/plugin-paths-protocol.ts +26 -26
  995. package/src/main/common/plugin-theia-environment.ts +36 -36
  996. package/src/main/common/webview-protocol.ts +28 -28
  997. package/src/main/electron-browser/plugin-ext-frontend-electron-module.ts +25 -25
  998. package/src/main/electron-browser/webview/electron-webview-widget-factory.ts +59 -59
  999. package/src/main/node/errors.spec.ts +37 -37
  1000. package/src/main/node/handlers/plugin-theia-directory-handler.ts +137 -115
  1001. package/src/main/node/handlers/plugin-theia-file-handler.ts +66 -66
  1002. package/src/main/node/paths/const.ts +21 -21
  1003. package/src/main/node/paths/plugin-paths-service.ts +163 -163
  1004. package/src/main/node/plugin-cli-contribution.ts +85 -85
  1005. package/src/main/node/plugin-deployer-contribution.ts +35 -35
  1006. package/src/main/node/plugin-deployer-directory-handler-context-impl.ts +45 -45
  1007. package/src/main/node/plugin-deployer-entry-impl.ts +132 -132
  1008. package/src/main/node/plugin-deployer-file-handler-context-impl.ts +33 -33
  1009. package/src/main/node/plugin-deployer-impl.ts +364 -360
  1010. package/src/main/node/plugin-deployer-proxy-entry-impl.ts +96 -96
  1011. package/src/main/node/plugin-deployer-resolver-context-impl.ts +55 -55
  1012. package/src/main/node/plugin-ext-backend-module.ts +97 -97
  1013. package/src/main/node/plugin-github-resolver.ts +139 -139
  1014. package/src/main/node/plugin-http-resolver.ts +92 -92
  1015. package/src/main/node/plugin-localization-server.ts +42 -42
  1016. package/src/main/node/plugin-mgmt-cli-contribution.ts +64 -64
  1017. package/src/main/node/plugin-server-handler.ts +69 -69
  1018. package/src/main/node/plugin-service.ts +97 -97
  1019. package/src/main/node/plugin-theia-deployer-participant.ts +32 -32
  1020. package/src/main/node/plugin-uninstallation-manager.ts +74 -74
  1021. package/src/main/node/plugins-key-value-storage.spec.ts +110 -110
  1022. package/src/main/node/plugins-key-value-storage.ts +161 -161
  1023. package/src/main/node/resolvers/local-directory-plugin-deployer-resolver.ts +37 -37
  1024. package/src/main/node/resolvers/local-plugin-deployer-resolver.ts +56 -56
  1025. package/src/main/node/temp-dir-util.ts +36 -36
  1026. package/src/main/node/webview-backend-security-warnings.ts +45 -45
  1027. package/src/main/style/status-bar.css +35 -35
  1028. package/src/plugin/authentication-ext.ts +125 -125
  1029. package/src/plugin/clipboard-ext.ts +43 -37
  1030. package/src/plugin/command-registry.ts +219 -219
  1031. package/src/plugin/comments.ts +549 -549
  1032. package/src/plugin/custom-editors.ts +336 -336
  1033. package/src/plugin/debug/debug-ext.ts +499 -490
  1034. package/src/plugin/debug/plugin-debug-adapter-creator.ts +50 -50
  1035. package/src/plugin/debug/plugin-debug-adapter-session.ts +106 -106
  1036. package/src/plugin/debug/plugin-debug-adapter-tracker.ts +85 -85
  1037. package/src/plugin/decorations.ts +140 -140
  1038. package/src/plugin/dialogs.ts +96 -96
  1039. package/src/plugin/document-data.ts +366 -366
  1040. package/src/plugin/documents.ts +283 -283
  1041. package/src/plugin/editors-and-documents.ts +172 -170
  1042. package/src/plugin/env.ts +129 -113
  1043. package/src/plugin/file-system-event-service-ext-impl.ts +256 -256
  1044. package/src/plugin/file-system-ext-impl.ts +402 -402
  1045. package/src/plugin/known-commands.spec.ts +50 -50
  1046. package/src/plugin/known-commands.ts +428 -427
  1047. package/src/plugin/label-service.ts +36 -36
  1048. package/src/plugin/languages/call-hierarchy.ts +124 -124
  1049. package/src/plugin/languages/code-action.ts +162 -162
  1050. package/src/plugin/languages/color.ts +75 -75
  1051. package/src/plugin/languages/completion.ts +183 -183
  1052. package/src/plugin/languages/declaration.ts +72 -72
  1053. package/src/plugin/languages/definition.ts +73 -73
  1054. package/src/plugin/languages/diagnostics.ts +325 -325
  1055. package/src/plugin/languages/document-drop-edit.ts +44 -44
  1056. package/src/plugin/languages/document-formatting.ts +47 -47
  1057. package/src/plugin/languages/document-highlight.ts +61 -61
  1058. package/src/plugin/languages/evaluatable-expression.ts +47 -47
  1059. package/src/plugin/languages/folding.ts +46 -46
  1060. package/src/plugin/languages/hover.ts +58 -58
  1061. package/src/plugin/languages/implementation.ts +73 -73
  1062. package/src/plugin/languages/inlay-hints.ts +149 -149
  1063. package/src/plugin/languages/inline-completion.ts +126 -126
  1064. package/src/plugin/languages/inline-values.ts +50 -50
  1065. package/src/plugin/languages/lens.ts +102 -102
  1066. package/src/plugin/languages/link-provider.ts +81 -79
  1067. package/src/plugin/languages/linked-editing-range.ts +48 -48
  1068. package/src/plugin/languages/on-type-formatting.ts +50 -50
  1069. package/src/plugin/languages/outline.ts +126 -126
  1070. package/src/plugin/languages/range-formatting.ts +48 -48
  1071. package/src/plugin/languages/reference.ts +58 -58
  1072. package/src/plugin/languages/rename.ts +130 -130
  1073. package/src/plugin/languages/selection-range.ts +80 -80
  1074. package/src/plugin/languages/semantic-highlighting.ts +211 -211
  1075. package/src/plugin/languages/signature.ts +82 -82
  1076. package/src/plugin/languages/type-definition.ts +73 -73
  1077. package/src/plugin/languages/type-hierarchy.ts +117 -117
  1078. package/src/plugin/languages/util.ts +26 -26
  1079. package/src/plugin/languages/workspace-symbol.ts +66 -66
  1080. package/src/plugin/languages-utils.ts +68 -68
  1081. package/src/plugin/languages.ts +1022 -1022
  1082. package/src/plugin/localization-ext.ts +89 -84
  1083. package/src/plugin/markdown-string.ts +115 -115
  1084. package/src/plugin/message-registry.ts +70 -65
  1085. package/src/plugin/node/debug/debug.spec.ts +98 -94
  1086. package/src/plugin/node/debug/plugin-node-debug-adapter-creator.ts +167 -167
  1087. package/src/plugin/node/env-node-ext.ts +64 -69
  1088. package/src/plugin/node/plugin-container-module.ts +165 -0
  1089. package/src/plugin/notebook/notebook-document.ts +438 -438
  1090. package/src/plugin/notebook/notebook-documents.ts +58 -58
  1091. package/src/plugin/notebook/notebook-editor.ts +116 -116
  1092. package/src/plugin/notebook/notebook-editors.ts +71 -71
  1093. package/src/plugin/notebook/notebook-kernels.ts +617 -618
  1094. package/src/plugin/notebook/notebook-renderers.ts +71 -72
  1095. package/src/plugin/notebook/notebooks.ts +405 -385
  1096. package/src/plugin/notification.ts +80 -80
  1097. package/src/plugin/output-channel/log-output-channel.ts +108 -108
  1098. package/src/plugin/output-channel/output-channel-item.ts +73 -73
  1099. package/src/plugin/output-channel-registry.ts +52 -52
  1100. package/src/plugin/path.spec.ts +40 -40
  1101. package/src/plugin/path.ts +68 -68
  1102. package/src/plugin/plugin-context.ts +1495 -1478
  1103. package/src/plugin/plugin-icon-path.ts +50 -50
  1104. package/src/plugin/plugin-manager.ts +493 -439
  1105. package/src/plugin/plugin-storage.ts +138 -120
  1106. package/src/plugin/preference-registry.spec.ts +288 -283
  1107. package/src/plugin/preference-registry.ts +335 -329
  1108. package/src/plugin/prefix-sum-computer.ts +218 -218
  1109. package/src/plugin/quick-open.ts +759 -773
  1110. package/src/plugin/scm.ts +919 -919
  1111. package/src/plugin/secrets-ext.ts +104 -84
  1112. package/src/plugin/status-bar/status-bar-item.ts +193 -193
  1113. package/src/plugin/status-bar-message-registry.ts +103 -103
  1114. package/src/plugin/tabs.ts +426 -426
  1115. package/src/plugin/tasks/task-provider.ts +57 -57
  1116. package/src/plugin/tasks/tasks.ts +252 -252
  1117. package/src/plugin/telemetry-ext.ts +298 -298
  1118. package/src/plugin/terminal-ext.ts +553 -551
  1119. package/src/plugin/test-item.ts +174 -174
  1120. package/src/plugin/tests.ts +506 -506
  1121. package/src/plugin/text-editor.ts +582 -582
  1122. package/src/plugin/text-editors.ts +157 -150
  1123. package/src/plugin/theming.ts +73 -73
  1124. package/src/plugin/timeline.ts +186 -186
  1125. package/src/plugin/tree/tree-views.ts +682 -682
  1126. package/src/plugin/type-converters.spec.ts +476 -476
  1127. package/src/plugin/type-converters.ts +1748 -1712
  1128. package/src/plugin/types-impl.spec.ts +85 -85
  1129. package/src/plugin/types-impl.ts +3724 -3696
  1130. package/src/plugin/webview-views.ts +228 -227
  1131. package/src/plugin/webviews.ts +459 -433
  1132. package/src/plugin/window-state.ts +68 -68
  1133. package/src/plugin/word-helper.ts +162 -162
  1134. package/src/plugin/workspace.ts +505 -495
  1135. package/src/plugin-ext-backend-electron-module.ts +24 -24
  1136. package/src/plugin-ext-backend-module.ts +24 -24
  1137. package/src/plugin-ext-frontend-electron-module.ts +19 -19
  1138. package/src/plugin-ext-frontend-module.ts +19 -19
@@ -1,1712 +1,1748 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 Red Hat, Inc. and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import * as theia from '@theia/plugin';
18
- import * as lstypes from '@theia/core/shared/vscode-languageserver-protocol';
19
- import { InlineValueEvaluatableExpression, InlineValueText, InlineValueVariableLookup, QuickPickItemKind, URI } from './types-impl';
20
- import * as rpc from '../common/plugin-api-rpc';
21
- import {
22
- DecorationOptions, EditorPosition, Plugin, Position, WorkspaceTextEditDto, WorkspaceFileEditDto, Selection, TaskDto, WorkspaceEditDto
23
- } from '../common/plugin-api-rpc';
24
- import * as model from '../common/plugin-api-rpc-model';
25
- import { LanguageFilter, LanguageSelector, RelativePattern } from '@theia/editor/lib/common/language-selector';
26
- import { MarkdownString as PluginMarkdownStringImpl } from './markdown-string';
27
- import * as types from './types-impl';
28
- import { UriComponents } from '../common/uri-components';
29
- import { isReadonlyArray } from '../common/arrays';
30
- import { DisposableCollection, Mutable, isEmptyObject, isObject } from '@theia/core/lib/common';
31
- import * as notebooks from '@theia/notebook/lib/common';
32
- import { CommandsConverter } from './command-registry';
33
- import { BinaryBuffer } from '@theia/core/lib/common/buffer';
34
- import { CellRange, isTextStreamMime } from '@theia/notebook/lib/common';
35
- import { MarkdownString as MarkdownStringDTO } from '@theia/core/lib/common/markdown-rendering';
36
-
37
- import { TestItemDTO, TestMessageDTO } from '../common/test-types';
38
-
39
- const SIDE_GROUP = -2;
40
- const ACTIVE_GROUP = -1;
41
-
42
- export function toViewColumn(ep?: EditorPosition): theia.ViewColumn | undefined {
43
- if (typeof ep !== 'number') {
44
- return undefined;
45
- }
46
-
47
- if (ep === EditorPosition.ONE) {
48
- return <number>types.ViewColumn.One;
49
- } else if (ep === EditorPosition.TWO) {
50
- return <number>types.ViewColumn.Two;
51
- } else if (ep === EditorPosition.THREE) {
52
- return <number>types.ViewColumn.Three;
53
- } else if (ep === EditorPosition.FOUR) {
54
- return <number>types.ViewColumn.Four;
55
- } else if (ep === EditorPosition.FIVE) {
56
- return <number>types.ViewColumn.Five;
57
- } else if (ep === EditorPosition.SIX) {
58
- return <number>types.ViewColumn.Six;
59
- } else if (ep === EditorPosition.SEVEN) {
60
- return <number>types.ViewColumn.Seven;
61
- } else if (ep === EditorPosition.EIGHT) {
62
- return <number>types.ViewColumn.Eight;
63
- } else if (ep === EditorPosition.NINE) {
64
- return <number>types.ViewColumn.Nine;
65
- }
66
-
67
- return undefined;
68
- }
69
-
70
- export function fromViewColumn(column?: theia.ViewColumn): number {
71
- if (typeof column === 'number' && column >= types.ViewColumn.One) {
72
- return column - 1;
73
- }
74
-
75
- if (column! === <number>types.ViewColumn.Beside) {
76
- return SIDE_GROUP;
77
- }
78
-
79
- return ACTIVE_GROUP;
80
- }
81
-
82
- export function toWebviewPanelShowOptions(options: theia.ViewColumn | theia.WebviewPanelShowOptions): theia.WebviewPanelShowOptions {
83
- if (typeof options === 'object') {
84
- const showOptions = options as theia.WebviewPanelShowOptions;
85
- return {
86
- area: showOptions.area ? showOptions.area : types.WebviewPanelTargetArea.Main,
87
- viewColumn: showOptions.viewColumn ? fromViewColumn(showOptions.viewColumn) : undefined,
88
- preserveFocus: showOptions.preserveFocus ? showOptions.preserveFocus : false
89
- };
90
- }
91
-
92
- return {
93
- area: types.WebviewPanelTargetArea.Main,
94
- viewColumn: fromViewColumn(options as theia.ViewColumn),
95
- preserveFocus: false
96
- };
97
- }
98
-
99
- export function toSelection(selection: Selection): types.Selection {
100
- const { selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn } = selection;
101
- const start = new types.Position(selectionStartLineNumber - 1, selectionStartColumn - 1);
102
- const end = new types.Position(positionLineNumber - 1, positionColumn - 1);
103
- return new types.Selection(start, end);
104
- }
105
-
106
- export function fromSelection(selection: types.Selection): Selection {
107
- const { active, anchor } = selection;
108
- return {
109
- selectionStartLineNumber: anchor.line + 1,
110
- selectionStartColumn: anchor.character + 1,
111
- positionLineNumber: active.line + 1,
112
- positionColumn: active.character + 1
113
- };
114
- }
115
-
116
- export function toRange(range: model.Range): types.Range {
117
- const { startLineNumber, startColumn, endLineNumber, endColumn } = range;
118
- return new types.Range(startLineNumber - 1, startColumn - 1, endLineNumber - 1, endColumn - 1);
119
- }
120
-
121
- export function fromRange(range: undefined): undefined;
122
- export function fromRange(range: theia.Range): model.Range;
123
- export function fromRange(range: theia.Range | undefined): model.Range | undefined;
124
- export function fromRange(range: theia.Range | undefined): model.Range | undefined {
125
- if (!range) {
126
- return undefined;
127
- }
128
- const { start, end } = range;
129
- return {
130
- startLineNumber: start.line + 1,
131
- startColumn: start.character + 1,
132
- endLineNumber: end.line + 1,
133
- endColumn: end.character + 1
134
- };
135
- }
136
-
137
- export function fromPosition(position: types.Position | theia.Position): Position {
138
- return { lineNumber: position.line + 1, column: position.character + 1 };
139
- }
140
-
141
- export function toPosition(position: Position): types.Position {
142
- return new types.Position(position.lineNumber - 1, position.column - 1);
143
- }
144
-
145
- function isDecorationOptions(arg: unknown): arg is theia.DecorationOptions {
146
- return isObject<theia.DecorationOptions>(arg) && typeof arg.range !== 'undefined';
147
- }
148
-
149
- export function isDecorationOptionsArr(something: theia.Range[] | theia.DecorationOptions[]): something is theia.DecorationOptions[] {
150
- if (something.length === 0) {
151
- return true;
152
- }
153
- return isDecorationOptions(something[0]) ? true : false;
154
- }
155
-
156
- export function fromRangeOrRangeWithMessage(ranges: theia.Range[] | theia.DecorationOptions[]): DecorationOptions[] {
157
-
158
- if (isDecorationOptionsArr(ranges)) {
159
- return ranges.map(r => {
160
- let hoverMessage;
161
- if (Array.isArray(r.hoverMessage)) {
162
- hoverMessage = fromManyMarkdown(r.hoverMessage);
163
- } else if (r.hoverMessage) {
164
- hoverMessage = fromMarkdown(r.hoverMessage);
165
- } else {
166
- hoverMessage = undefined;
167
- }
168
- return {
169
- range: fromRange(r.range)!,
170
- hoverMessage: hoverMessage,
171
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
172
- renderOptions: <any> /* URI vs Uri */r.renderOptions
173
- };
174
- });
175
- } else {
176
- return ranges.map(r => ({ range: fromRange(r) }));
177
- }
178
- }
179
-
180
- export function fromManyMarkdown(markup: (theia.MarkdownString | theia.MarkedString)[]): MarkdownStringDTO[] {
181
- return markup.map(fromMarkdown);
182
- }
183
-
184
- interface Codeblock {
185
- language: string;
186
- value: string;
187
- }
188
-
189
- function isCodeblock(arg: unknown): arg is Codeblock {
190
- return isObject<Codeblock>(arg)
191
- && typeof arg.language === 'string'
192
- && typeof arg.value === 'string';
193
- }
194
-
195
- export function fromMarkdown(markup: theia.MarkdownString | theia.MarkedString): MarkdownStringDTO {
196
- if (isCodeblock(markup)) {
197
- const { language, value } = markup;
198
- return { value: '```' + language + '\n' + value + '\n```\n' };
199
- } else if (markup instanceof PluginMarkdownStringImpl) {
200
- return markup.toJSON();
201
- } else if (MarkdownStringDTO.is(markup)) {
202
- return markup;
203
- } else if (typeof markup === 'string') {
204
- return { value: markup };
205
- } else {
206
- return { value: '' };
207
- }
208
- }
209
-
210
- export function fromMarkdownOrString(value: string | theia.MarkdownString | undefined): string | MarkdownStringDTO | undefined {
211
- if (value === undefined) {
212
- return undefined;
213
- } else if (typeof value === 'string') {
214
- return value;
215
- } else {
216
- return fromMarkdown(value);
217
- }
218
- }
219
-
220
- export function toMarkdown(value: MarkdownStringDTO): PluginMarkdownStringImpl {
221
- const implemented = new PluginMarkdownStringImpl(value.value, value.supportThemeIcons);
222
- implemented.isTrusted = value.isTrusted;
223
- implemented.supportHtml = value.supportHtml;
224
- implemented.baseUri = value.baseUri && URI.revive(implemented.baseUri);
225
- return implemented;
226
- }
227
-
228
- export function fromDocumentSelector(selector: theia.DocumentSelector | undefined): LanguageSelector | undefined {
229
- if (!selector) {
230
- return undefined;
231
- } else if (isReadonlyArray(selector)) {
232
- return <LanguageSelector>selector.map(fromDocumentSelector);
233
- } else if (typeof selector === 'string') {
234
- return selector;
235
- } else {
236
- return {
237
- language: selector.language,
238
- scheme: selector.scheme,
239
- pattern: fromGlobPattern(selector.pattern!)
240
- } as LanguageFilter;
241
- }
242
-
243
- }
244
-
245
- export function fromGlobPattern(pattern: theia.GlobPattern): string | RelativePattern {
246
- if (typeof pattern === 'string') {
247
- return pattern;
248
- }
249
-
250
- if (isRelativePattern(pattern)) {
251
- return new types.RelativePattern(pattern.baseUri, pattern.pattern);
252
- }
253
-
254
- return pattern;
255
- }
256
-
257
- function isRelativePattern(obj: {}): obj is theia.RelativePattern {
258
- const rp = obj as theia.RelativePattern;
259
- return rp && typeof rp.baseUri === 'string' && typeof rp.pattern === 'string';
260
- }
261
-
262
- export function fromCompletionItemKind(kind?: types.CompletionItemKind): model.CompletionItemKind {
263
- switch (kind) {
264
- case types.CompletionItemKind.Method: return model.CompletionItemKind.Method;
265
- case types.CompletionItemKind.Function: return model.CompletionItemKind.Function;
266
- case types.CompletionItemKind.Constructor: return model.CompletionItemKind.Constructor;
267
- case types.CompletionItemKind.Field: return model.CompletionItemKind.Field;
268
- case types.CompletionItemKind.Variable: return model.CompletionItemKind.Variable;
269
- case types.CompletionItemKind.Class: return model.CompletionItemKind.Class;
270
- case types.CompletionItemKind.Interface: return model.CompletionItemKind.Interface;
271
- case types.CompletionItemKind.Struct: return model.CompletionItemKind.Struct;
272
- case types.CompletionItemKind.Module: return model.CompletionItemKind.Module;
273
- case types.CompletionItemKind.Property: return model.CompletionItemKind.Property;
274
- case types.CompletionItemKind.Unit: return model.CompletionItemKind.Unit;
275
- case types.CompletionItemKind.Value: return model.CompletionItemKind.Value;
276
- case types.CompletionItemKind.Constant: return model.CompletionItemKind.Constant;
277
- case types.CompletionItemKind.Enum: return model.CompletionItemKind.Enum;
278
- case types.CompletionItemKind.EnumMember: return model.CompletionItemKind.EnumMember;
279
- case types.CompletionItemKind.Keyword: return model.CompletionItemKind.Keyword;
280
- case types.CompletionItemKind.Snippet: return model.CompletionItemKind.Snippet;
281
- case types.CompletionItemKind.Text: return model.CompletionItemKind.Text;
282
- case types.CompletionItemKind.Color: return model.CompletionItemKind.Color;
283
- case types.CompletionItemKind.File: return model.CompletionItemKind.File;
284
- case types.CompletionItemKind.Reference: return model.CompletionItemKind.Reference;
285
- case types.CompletionItemKind.Folder: return model.CompletionItemKind.Folder;
286
- case types.CompletionItemKind.Event: return model.CompletionItemKind.Event;
287
- case types.CompletionItemKind.Operator: return model.CompletionItemKind.Operator;
288
- case types.CompletionItemKind.TypeParameter: return model.CompletionItemKind.TypeParameter;
289
- case types.CompletionItemKind.User: return model.CompletionItemKind.User;
290
- case types.CompletionItemKind.Issue: return model.CompletionItemKind.Issue;
291
- }
292
- return model.CompletionItemKind.Property;
293
- }
294
-
295
- export function toCompletionItemKind(kind?: model.CompletionItemKind): types.CompletionItemKind {
296
- switch (kind) {
297
- case model.CompletionItemKind.Method: return types.CompletionItemKind.Method;
298
- case model.CompletionItemKind.Function: return types.CompletionItemKind.Function;
299
- case model.CompletionItemKind.Constructor: return types.CompletionItemKind.Constructor;
300
- case model.CompletionItemKind.Field: return types.CompletionItemKind.Field;
301
- case model.CompletionItemKind.Variable: return types.CompletionItemKind.Variable;
302
- case model.CompletionItemKind.Class: return types.CompletionItemKind.Class;
303
- case model.CompletionItemKind.Interface: return types.CompletionItemKind.Interface;
304
- case model.CompletionItemKind.Struct: return types.CompletionItemKind.Struct;
305
- case model.CompletionItemKind.Module: return types.CompletionItemKind.Module;
306
- case model.CompletionItemKind.Property: return types.CompletionItemKind.Property;
307
- case model.CompletionItemKind.Unit: return types.CompletionItemKind.Unit;
308
- case model.CompletionItemKind.Value: return types.CompletionItemKind.Value;
309
- case model.CompletionItemKind.Constant: return types.CompletionItemKind.Constant;
310
- case model.CompletionItemKind.Enum: return types.CompletionItemKind.Enum;
311
- case model.CompletionItemKind.EnumMember: return types.CompletionItemKind.EnumMember;
312
- case model.CompletionItemKind.Keyword: return types.CompletionItemKind.Keyword;
313
- case model.CompletionItemKind.Snippet: return types.CompletionItemKind.Snippet;
314
- case model.CompletionItemKind.Text: return types.CompletionItemKind.Text;
315
- case model.CompletionItemKind.Color: return types.CompletionItemKind.Color;
316
- case model.CompletionItemKind.File: return types.CompletionItemKind.File;
317
- case model.CompletionItemKind.Reference: return types.CompletionItemKind.Reference;
318
- case model.CompletionItemKind.Folder: return types.CompletionItemKind.Folder;
319
- case model.CompletionItemKind.Event: return types.CompletionItemKind.Event;
320
- case model.CompletionItemKind.Operator: return types.CompletionItemKind.Operator;
321
- case model.CompletionItemKind.TypeParameter: return types.CompletionItemKind.TypeParameter;
322
- case model.CompletionItemKind.User: return types.CompletionItemKind.User;
323
- case model.CompletionItemKind.Issue: return types.CompletionItemKind.Issue;
324
- }
325
- return types.CompletionItemKind.Property;
326
- }
327
-
328
- export function fromTextEdit(edit: theia.TextEdit): model.TextEdit {
329
- return {
330
- text: edit.newText,
331
- range: fromRange(edit.range)
332
- };
333
- }
334
-
335
- function fromSnippetTextEdit(edit: theia.SnippetTextEdit): model.TextEdit & { insertAsSnippet?: boolean } {
336
- return {
337
- text: edit.snippet.value,
338
- range: fromRange(edit.range),
339
- insertAsSnippet: true
340
- };
341
- }
342
-
343
- export function convertDiagnosticToMarkerData(diagnostic: theia.Diagnostic): model.MarkerData {
344
- return {
345
- code: convertCode(diagnostic.code),
346
- severity: convertSeverity(diagnostic.severity),
347
- message: diagnostic.message,
348
- source: diagnostic.source,
349
- startLineNumber: diagnostic.range.start.line + 1,
350
- startColumn: diagnostic.range.start.character + 1,
351
- endLineNumber: diagnostic.range.end.line + 1,
352
- endColumn: diagnostic.range.end.character + 1,
353
- relatedInformation: convertRelatedInformation(diagnostic.relatedInformation),
354
- tags: convertTags(diagnostic.tags)
355
- };
356
- }
357
-
358
- export function convertCode(code: string | number | { value: string | number; target: theia.Uri } | undefined): string | undefined {
359
- if (typeof code === 'number') {
360
- return String(code);
361
- }
362
- if (typeof code === 'string' || typeof code === 'undefined') {
363
- return code;
364
- } else {
365
- return String(code.value);
366
- };
367
- }
368
-
369
- function convertSeverity(severity: types.DiagnosticSeverity): types.MarkerSeverity {
370
- switch (severity) {
371
- case types.DiagnosticSeverity.Error: return types.MarkerSeverity.Error;
372
- case types.DiagnosticSeverity.Warning: return types.MarkerSeverity.Warning;
373
- case types.DiagnosticSeverity.Information: return types.MarkerSeverity.Info;
374
- case types.DiagnosticSeverity.Hint: return types.MarkerSeverity.Hint;
375
- }
376
- }
377
-
378
- function convertRelatedInformation(diagnosticsRelatedInformation: theia.DiagnosticRelatedInformation[] | undefined): model.RelatedInformation[] | undefined {
379
- if (!diagnosticsRelatedInformation) {
380
- return undefined;
381
- }
382
-
383
- const relatedInformation: model.RelatedInformation[] = [];
384
- for (const item of diagnosticsRelatedInformation) {
385
- relatedInformation.push({
386
- resource: item.location.uri.toString(),
387
- message: item.message,
388
- startLineNumber: item.location.range.start.line + 1,
389
- startColumn: item.location.range.start.character + 1,
390
- endLineNumber: item.location.range.end.line + 1,
391
- endColumn: item.location.range.end.character + 1
392
- });
393
- }
394
- return relatedInformation;
395
- }
396
-
397
- function convertTags(tags: types.DiagnosticTag[] | undefined): types.MarkerTag[] | undefined {
398
- if (!tags) {
399
- return undefined;
400
- }
401
-
402
- const markerTags: types.MarkerTag[] = [];
403
- for (const tag of tags) {
404
- switch (tag) {
405
- case types.DiagnosticTag.Unnecessary:
406
- markerTags.push(types.MarkerTag.Unnecessary);
407
- break;
408
- case types.DiagnosticTag.Deprecated:
409
- markerTags.push(types.MarkerTag.Deprecated);
410
- break;
411
- }
412
- }
413
- return markerTags;
414
- }
415
-
416
- export function fromHover(hover: theia.Hover): model.Hover {
417
- return <model.Hover>{
418
- range: fromRange(hover.range),
419
- contents: fromManyMarkdown(hover.contents)
420
- };
421
- }
422
-
423
- export function fromEvaluatableExpression(evaluatableExpression: theia.EvaluatableExpression): model.EvaluatableExpression {
424
- return <model.EvaluatableExpression>{
425
- range: fromRange(evaluatableExpression.range),
426
- expression: evaluatableExpression.expression
427
- };
428
- }
429
-
430
- export function fromInlineValue(inlineValue: theia.InlineValue): model.InlineValue {
431
- if (inlineValue instanceof InlineValueText) {
432
- return <model.InlineValueText>{
433
- type: 'text',
434
- range: fromRange(inlineValue.range),
435
- text: inlineValue.text
436
- };
437
- } else if (inlineValue instanceof InlineValueVariableLookup) {
438
- return <model.InlineValueVariableLookup>{
439
- type: 'variable',
440
- range: fromRange(inlineValue.range),
441
- variableName: inlineValue.variableName,
442
- caseSensitiveLookup: inlineValue.caseSensitiveLookup
443
- };
444
- } else if (inlineValue instanceof InlineValueEvaluatableExpression) {
445
- return <model.InlineValueEvaluatableExpression>{
446
- type: 'expression',
447
- range: fromRange(inlineValue.range),
448
- expression: inlineValue.expression
449
- };
450
- } else {
451
- throw new Error('Unknown InlineValue type');
452
- }
453
- }
454
-
455
- export function toInlineValueContext(inlineValueContext: model.InlineValueContext): theia.InlineValueContext {
456
- const ivLocation = inlineValueContext.stoppedLocation;
457
- return <theia.InlineValueContext>{
458
- frameId: inlineValueContext.frameId,
459
- stoppedLocation: new types.Range(ivLocation.startLineNumber, ivLocation.startColumn, ivLocation.endLineNumber, ivLocation.endColumn)
460
- };
461
- }
462
-
463
- // eslint-disable-next-line @typescript-eslint/no-shadow
464
- export function fromLocation(location: theia.Location): model.Location;
465
- export function fromLocation(location: theia.Location | undefined): model.Location | undefined;
466
- export function fromLocation(location: theia.Location | undefined): model.Location | undefined {
467
- if (!location) {
468
- return undefined;
469
- }
470
- return <model.Location>{
471
- uri: location.uri,
472
- range: fromRange(location.range)
473
- };
474
- }
475
-
476
- export function fromTextDocumentShowOptions(options: theia.TextDocumentShowOptions): model.TextDocumentShowOptions {
477
- if (options.selection) {
478
- return {
479
- ...options,
480
- selection: fromRange(options.selection),
481
- };
482
- }
483
- return options as model.TextDocumentShowOptions;
484
- }
485
-
486
- export function fromDefinitionLink(definitionLink: theia.DefinitionLink): model.LocationLink {
487
- return <model.LocationLink>{
488
- uri: definitionLink.targetUri,
489
- range: fromRange(definitionLink.targetRange),
490
- originSelectionRange: definitionLink.originSelectionRange ? fromRange(definitionLink.originSelectionRange) : undefined,
491
- targetSelectionRange: definitionLink.targetSelectionRange ? fromRange(definitionLink.targetSelectionRange) : undefined
492
- };
493
- }
494
-
495
- export namespace DocumentLink {
496
-
497
- export function from(link: theia.DocumentLink): model.DocumentLink {
498
- return {
499
- range: fromRange(link.range),
500
- url: link.target,
501
- tooltip: link.tooltip
502
- };
503
- }
504
-
505
- export function to(link: model.DocumentLink): theia.DocumentLink {
506
- let target: URI | undefined = undefined;
507
- if (link.url) {
508
- try {
509
- target = typeof link.url === 'string' ? URI.parse(link.url, true) : URI.revive(link.url);
510
- } catch (err) {
511
- // ignore
512
- }
513
- }
514
- return new types.DocumentLink(toRange(link.range), target);
515
- }
516
- }
517
-
518
- export function fromDocumentHighlightKind(kind?: theia.DocumentHighlightKind): model.DocumentHighlightKind | undefined {
519
- switch (kind) {
520
- case types.DocumentHighlightKind.Text: return model.DocumentHighlightKind.Text;
521
- case types.DocumentHighlightKind.Read: return model.DocumentHighlightKind.Read;
522
- case types.DocumentHighlightKind.Write: return model.DocumentHighlightKind.Write;
523
- }
524
- return model.DocumentHighlightKind.Text;
525
- }
526
-
527
- export function fromDocumentHighlight(documentHighlight: theia.DocumentHighlight): model.DocumentHighlight {
528
- return <model.DocumentHighlight>{
529
- range: fromRange(documentHighlight.range),
530
- kind: fromDocumentHighlightKind(documentHighlight.kind)
531
- };
532
- }
533
-
534
- export namespace ParameterInformation {
535
- export function from(info: types.ParameterInformation): model.ParameterInformation {
536
- return {
537
- label: info.label,
538
- documentation: info.documentation ? fromMarkdown(info.documentation) : undefined
539
- };
540
- }
541
- export function to(info: model.ParameterInformation): types.ParameterInformation {
542
- return {
543
- label: info.label,
544
- documentation: MarkdownStringDTO.is(info.documentation) ? toMarkdown(info.documentation) : info.documentation
545
- };
546
- }
547
- }
548
-
549
- export namespace SignatureInformation {
550
-
551
- export function from(info: types.SignatureInformation): model.SignatureInformation {
552
- return {
553
- label: info.label,
554
- documentation: info.documentation ? fromMarkdown(info.documentation) : undefined,
555
- parameters: info.parameters && info.parameters.map(ParameterInformation.from),
556
- activeParameter: info.activeParameter
557
- };
558
- }
559
-
560
- export function to(info: model.SignatureInformation): types.SignatureInformation {
561
- return {
562
- label: info.label,
563
- documentation: MarkdownStringDTO.is(info.documentation) ? toMarkdown(info.documentation) : info.documentation,
564
- parameters: info.parameters && info.parameters.map(ParameterInformation.to),
565
- activeParameter: info.activeParameter
566
- };
567
- }
568
- }
569
-
570
- export namespace SignatureHelp {
571
-
572
- export function from(id: number, help: types.SignatureHelp): model.SignatureHelp {
573
- return {
574
- id,
575
- activeSignature: help.activeSignature,
576
- activeParameter: help.activeParameter,
577
- signatures: help.signatures && help.signatures.map(SignatureInformation.from)
578
- };
579
- }
580
-
581
- export function to(help: model.SignatureHelp): types.SignatureHelp {
582
- return {
583
- activeSignature: help.activeSignature,
584
- activeParameter: help.activeParameter,
585
- signatures: help.signatures && help.signatures.map(SignatureInformation.to)
586
- };
587
- }
588
- }
589
-
590
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
591
- export function fromWorkspaceEdit(value: theia.WorkspaceEdit, documents?: any): WorkspaceEditDto {
592
- const result: WorkspaceEditDto = {
593
- edits: []
594
- };
595
- for (const entry of (value as types.WorkspaceEdit)._allEntries()) {
596
- if (entry?._type === types.FileEditType.Text) {
597
- // text edits
598
- const doc = documents ? documents.getDocument(entry.uri.toString()) : undefined;
599
- const workspaceTextEditDto: WorkspaceTextEditDto = {
600
- resource: entry.uri,
601
- modelVersionId: doc?.version,
602
- textEdit: (entry.edit instanceof types.TextEdit) ? fromTextEdit(entry.edit) : fromSnippetTextEdit(entry.edit),
603
- metadata: entry.metadata
604
- };
605
- result.edits.push(workspaceTextEditDto);
606
- } else if (entry?._type === types.FileEditType.File) {
607
- // resource edits
608
- const workspaceFileEditDto: WorkspaceFileEditDto = {
609
- oldResource: entry.from,
610
- newResource: entry.to,
611
- options: entry.options,
612
- metadata: entry.metadata
613
- };
614
- result.edits.push(workspaceFileEditDto);
615
- } else if (entry?._type === types.FileEditType.Cell) {
616
- // cell edit
617
- if (entry.edit) {
618
- result.edits.push({
619
- metadata: entry.metadata,
620
- resource: entry.uri,
621
- cellEdit: entry.edit,
622
- });
623
- }
624
- } else if (entry?._type === types.FileEditType.CellReplace) {
625
- // cell replace
626
- result.edits.push({
627
- metadata: entry.metadata,
628
- resource: entry.uri,
629
- cellEdit: {
630
- editType: notebooks.CellEditType.Replace,
631
- index: entry.index,
632
- count: entry.count,
633
- cells: entry.cells.map(NotebookCellData.from)
634
- }
635
- });
636
- }
637
- }
638
- return result;
639
- }
640
-
641
- export namespace SymbolKind {
642
- const fromMapping: { [kind: number]: model.SymbolKind } = Object.create(null);
643
- fromMapping[model.SymbolKind.File] = model.SymbolKind.File;
644
- fromMapping[model.SymbolKind.Module] = model.SymbolKind.Module;
645
- fromMapping[model.SymbolKind.Namespace] = model.SymbolKind.Namespace;
646
- fromMapping[model.SymbolKind.Package] = model.SymbolKind.Package;
647
- fromMapping[model.SymbolKind.Class] = model.SymbolKind.Class;
648
- fromMapping[model.SymbolKind.Method] = model.SymbolKind.Method;
649
- fromMapping[model.SymbolKind.Property] = model.SymbolKind.Property;
650
- fromMapping[model.SymbolKind.Field] = model.SymbolKind.Field;
651
- fromMapping[model.SymbolKind.Constructor] = model.SymbolKind.Constructor;
652
- fromMapping[model.SymbolKind.Enum] = model.SymbolKind.Enum;
653
- fromMapping[model.SymbolKind.Interface] = model.SymbolKind.Interface;
654
- fromMapping[model.SymbolKind.Function] = model.SymbolKind.Function;
655
- fromMapping[model.SymbolKind.Variable] = model.SymbolKind.Variable;
656
- fromMapping[model.SymbolKind.Constant] = model.SymbolKind.Constant;
657
- fromMapping[model.SymbolKind.String] = model.SymbolKind.String;
658
- fromMapping[model.SymbolKind.Number] = model.SymbolKind.Number;
659
- fromMapping[model.SymbolKind.Boolean] = model.SymbolKind.Boolean;
660
- fromMapping[model.SymbolKind.Array] = model.SymbolKind.Array;
661
- fromMapping[model.SymbolKind.Object] = model.SymbolKind.Object;
662
- fromMapping[model.SymbolKind.Key] = model.SymbolKind.Key;
663
- fromMapping[model.SymbolKind.Null] = model.SymbolKind.Null;
664
- fromMapping[model.SymbolKind.EnumMember] = model.SymbolKind.EnumMember;
665
- fromMapping[model.SymbolKind.Struct] = model.SymbolKind.Struct;
666
- fromMapping[model.SymbolKind.Event] = model.SymbolKind.Event;
667
- fromMapping[model.SymbolKind.Operator] = model.SymbolKind.Operator;
668
- fromMapping[model.SymbolKind.TypeParameter] = model.SymbolKind.TypeParameter;
669
-
670
- export function fromSymbolKind(kind: theia.SymbolKind): model.SymbolKind {
671
- return fromMapping[kind] || model.SymbolKind.Property;
672
- }
673
-
674
- export function toSymbolKind(kind: model.SymbolKind): theia.SymbolKind {
675
- for (const k in fromMapping) {
676
- if (fromMapping[k] === kind) {
677
- return Number(k);
678
- }
679
- }
680
- return model.SymbolKind.Property;
681
- }
682
- }
683
-
684
- export function toCodeActionTriggerKind(triggerKind: model.CodeActionTriggerKind): types.CodeActionTriggerKind {
685
- switch (triggerKind) {
686
- case model.CodeActionTriggerKind.Invoke:
687
- return types.CodeActionTriggerKind.Invoke;
688
-
689
- case model.CodeActionTriggerKind.Automatic:
690
- return types.CodeActionTriggerKind.Automatic;
691
- }
692
- }
693
-
694
- export function fromDocumentSymbol(info: theia.DocumentSymbol): model.DocumentSymbol {
695
- const result: model.DocumentSymbol = {
696
- name: info.name,
697
- detail: info.detail,
698
- range: fromRange(info.range)!,
699
- tags: info.tags ? info.tags.map(fromSymbolTag) : [],
700
- selectionRange: fromRange(info.selectionRange)!,
701
- kind: SymbolKind.fromSymbolKind(info.kind)
702
- };
703
- if (info.children) {
704
- result.children = info.children.map(fromDocumentSymbol);
705
- }
706
- return result;
707
- }
708
-
709
- export function toDocumentSymbol(symbol: model.DocumentSymbol): theia.DocumentSymbol {
710
- return {
711
- name: symbol.name,
712
- detail: symbol.detail,
713
- range: toRange(symbol.range)!,
714
- tags: symbol.tags && symbol.tags.length > 0 ? symbol.tags.map(toSymbolTag) : [],
715
- selectionRange: toRange(symbol.selectionRange)!,
716
- children: symbol.children ? symbol.children.map(toDocumentSymbol) : [],
717
- kind: SymbolKind.toSymbolKind(symbol.kind)
718
- };
719
- }
720
-
721
- export function fromSymbolTag(kind: types.SymbolTag): model.SymbolTag {
722
- switch (kind) {
723
- case types.SymbolTag.Deprecated: return model.SymbolTag.Deprecated;
724
- }
725
- }
726
-
727
- export function toSymbolTag(kind: model.SymbolTag): types.SymbolTag {
728
- switch (kind) {
729
- case model.SymbolTag.Deprecated: return types.SymbolTag.Deprecated;
730
- }
731
- }
732
-
733
- export function isModelLocation(arg: unknown): arg is model.Location {
734
- return isObject<model.Location>(arg) &&
735
- isModelRange(arg.range) &&
736
- isUriComponents(arg.uri);
737
- }
738
-
739
- export function isModelRange(arg: unknown): arg is model.Range {
740
- return isObject<model.Range>(arg) &&
741
- typeof arg.startLineNumber === 'number' &&
742
- typeof arg.startColumn === 'number' &&
743
- typeof arg.endLineNumber === 'number' &&
744
- typeof arg.endColumn === 'number';
745
- }
746
-
747
- export function isUriComponents(arg: unknown): arg is UriComponents {
748
- return isObject<UriComponents>(arg) &&
749
- typeof arg.scheme === 'string' &&
750
- typeof arg.path === 'string' &&
751
- typeof arg.query === 'string' &&
752
- typeof arg.fragment === 'string';
753
- }
754
-
755
- export function isModelCallHierarchyItem(arg: unknown): arg is model.CallHierarchyItem {
756
- return isObject<model.CallHierarchyItem>(arg)
757
- && isModelRange(arg.range)
758
- && isModelRange(arg.selectionRange)
759
- && isUriComponents(arg.uri)
760
- && !!arg.name;
761
- }
762
-
763
- export function isModelCallHierarchyIncomingCall(arg: unknown): arg is model.CallHierarchyIncomingCall {
764
- return isObject<model.CallHierarchyIncomingCall>(arg) &&
765
- 'from' in arg &&
766
- 'fromRanges' in arg &&
767
- isModelCallHierarchyItem(arg.from);
768
- }
769
-
770
- export function isModelCallHierarchyOutgoingCall(arg: unknown): arg is model.CallHierarchyOutgoingCall {
771
- return isObject<model.CallHierarchyOutgoingCall>(arg) &&
772
- 'to' in arg &&
773
- 'fromRanges' in arg &&
774
- isModelCallHierarchyItem(arg.to);
775
- }
776
-
777
- export function toLocation(value: model.Location): types.Location {
778
- return new types.Location(URI.revive(value.uri), toRange(value.range));
779
- }
780
-
781
- export function fromHierarchyItem(item: types.CallHierarchyItem | types.TypeHierarchyItem): model.HierarchyItem {
782
- return {
783
- kind: SymbolKind.fromSymbolKind(item.kind),
784
- name: item.name,
785
- detail: item.detail,
786
- uri: item.uri,
787
- range: fromRange(item.range),
788
- selectionRange: fromRange(item.selectionRange),
789
- tags: item.tags,
790
- _itemId: item._itemId,
791
- _sessionId: item._sessionId,
792
- };
793
- }
794
-
795
- export function fromCallHierarchyItem(item: types.CallHierarchyItem): model.CallHierarchyItem {
796
- return <model.CallHierarchyItem>fromHierarchyItem(item);
797
- }
798
-
799
- export function toCallHierarchyItem(value: model.CallHierarchyItem): types.CallHierarchyItem {
800
- const item = new types.CallHierarchyItem(
801
- SymbolKind.toSymbolKind(value.kind),
802
- value.name,
803
- value.detail ? value.detail : '',
804
- URI.revive(value.uri),
805
- toRange(value.range),
806
- toRange(value.selectionRange),
807
- );
808
- item.tags = value.tags;
809
- item._itemId = value._itemId;
810
- item._sessionId = value._sessionId;
811
-
812
- return item;
813
- }
814
-
815
- export function toCallHierarchyIncomingCall(value: model.CallHierarchyIncomingCall): types.CallHierarchyIncomingCall {
816
- return new types.CallHierarchyIncomingCall(
817
- toCallHierarchyItem(value.from),
818
- value.fromRanges && value.fromRanges.map(toRange));
819
- }
820
-
821
- export function toCallHierarchyOutgoingCall(value: model.CallHierarchyOutgoingCall): types.CallHierarchyOutgoingCall {
822
- return new types.CallHierarchyOutgoingCall(
823
- toCallHierarchyItem(value.to),
824
- value.fromRanges && value.fromRanges.map(toRange));
825
- }
826
-
827
- export function isModelTypeHierarchyItem(arg: unknown): arg is model.TypeHierarchyItem {
828
- return isObject<model.TypeHierarchyItem>(arg)
829
- && isModelRange(arg.range)
830
- && isModelRange(arg.selectionRange)
831
- && isUriComponents(arg.uri)
832
- && !!arg.name;
833
- }
834
-
835
- export function fromTypeHierarchyItem(item: types.TypeHierarchyItem): model.TypeHierarchyItem {
836
- return <model.TypeHierarchyItem>fromHierarchyItem(item);
837
- }
838
-
839
- export function toTypeHierarchyItem(value: model.TypeHierarchyItem): types.TypeHierarchyItem {
840
- const item = new types.TypeHierarchyItem(
841
- SymbolKind.toSymbolKind(value.kind),
842
- value.name,
843
- value.detail ? value.detail : '',
844
- URI.revive(value.uri),
845
- toRange(value.selectionRange),
846
- toRange(value.range),
847
- );
848
- item.tags = value.tags;
849
- item._itemId = value._itemId;
850
- item._sessionId = value._sessionId;
851
-
852
- return item;
853
- }
854
-
855
- export function toWorkspaceFolder(folder: model.WorkspaceFolder): theia.WorkspaceFolder {
856
- return {
857
- uri: URI.revive(folder.uri),
858
- name: folder.name,
859
- index: folder.index
860
- };
861
- }
862
-
863
- export function fromTask(task: theia.Task): TaskDto | undefined {
864
- if (!task) {
865
- return undefined;
866
- }
867
-
868
- const taskDto = {} as TaskDto;
869
- taskDto.label = task.name;
870
- taskDto.source = task.source;
871
-
872
- taskDto.runOptions = { reevaluateOnRerun: task.runOptions.reevaluateOnRerun };
873
-
874
- if ((task as types.Task).hasProblemMatchers) {
875
- taskDto.problemMatcher = task.problemMatchers;
876
- }
877
- if ('detail' in task) {
878
- taskDto.detail = task.detail;
879
- }
880
- if (typeof task.scope === 'number') {
881
- taskDto.scope = task.scope;
882
- } else if (task.scope !== undefined) {
883
- taskDto.scope = task.scope.uri.toString();
884
- } else {
885
- taskDto.scope = types.TaskScope.Workspace;
886
- }
887
-
888
- if (task.presentationOptions) {
889
- taskDto.presentation = task.presentationOptions;
890
- }
891
-
892
- if (task.group) {
893
- taskDto.group = {
894
- kind: <rpc.TaskGroupKind>task.group.id,
895
- isDefault: !!task.group.isDefault
896
- };
897
- }
898
-
899
- const taskDefinition = task.definition;
900
- if (!taskDefinition) {
901
- return taskDto;
902
- }
903
-
904
- taskDto.type = taskDefinition.type;
905
- const { type, ...properties } = taskDefinition;
906
- for (const key in properties) {
907
- if (properties.hasOwnProperty(key)) {
908
- taskDto[key] = properties[key];
909
- }
910
- }
911
-
912
- const execution = task.execution;
913
- if (!execution) {
914
- return taskDto;
915
- }
916
-
917
- if (types.ShellExecution.is(execution)) {
918
- return fromShellExecution(execution, taskDto);
919
- }
920
-
921
- if (types.ProcessExecution.is(execution)) {
922
- return fromProcessExecution(execution, taskDto);
923
- }
924
-
925
- if (types.CustomExecution.is(execution)) {
926
- return fromCustomExecution(execution, taskDto);
927
- }
928
-
929
- return taskDto;
930
- }
931
-
932
- export function toTask(taskDto: TaskDto): theia.Task {
933
- if (!taskDto) {
934
- throw new Error('Task should be provided for converting');
935
- }
936
-
937
- const { type, taskType, label, source, scope, problemMatcher, detail, command, args, options, group, presentation, runOptions, ...properties } = taskDto;
938
- const result = {} as theia.Task;
939
- result.name = label;
940
- result.source = source;
941
- result.runOptions = runOptions ?? {};
942
- if (detail) {
943
- result.detail = detail;
944
- }
945
- if (typeof scope === 'string') {
946
- const uri = URI.parse(scope);
947
- result.scope = {
948
- uri,
949
- name: uri.toString(),
950
- index: 0
951
- };
952
- } else {
953
- result.scope = scope;
954
- }
955
-
956
- const taskDefinition: theia.TaskDefinition = {
957
- type: type
958
- };
959
-
960
- result.definition = taskDefinition;
961
-
962
- if (taskType === 'process') {
963
- result.execution = getProcessExecution(taskDto);
964
- }
965
-
966
- const execution = { command, args, options };
967
- if (taskType === 'shell' || types.ShellExecution.is(execution)) {
968
- result.execution = getShellExecution(taskDto);
969
- }
970
-
971
- if (taskType === 'customExecution' || types.CustomExecution.is(execution)) {
972
- result.execution = getCustomExecution(taskDto);
973
- // if taskType is customExecution, we need to put all the information into taskDefinition,
974
- // because some parameters may be in taskDefinition.
975
- taskDefinition.label = label;
976
- taskDefinition.command = command;
977
- taskDefinition.args = args;
978
- taskDefinition.options = options;
979
- }
980
-
981
- if (group) {
982
- result.group = new types.TaskGroup(
983
- group.kind,
984
- group.kind,
985
- group.isDefault
986
- );
987
- }
988
-
989
- if (presentation) {
990
- result.presentationOptions = presentation;
991
- }
992
-
993
- if (!properties) {
994
- return result;
995
- }
996
-
997
- for (const key in properties) {
998
- if (properties.hasOwnProperty(key)) {
999
- taskDefinition[key] = properties[key];
1000
- }
1001
- }
1002
-
1003
- return result;
1004
- }
1005
-
1006
- export function fromProcessExecution(execution: theia.ProcessExecution, taskDto: TaskDto): TaskDto {
1007
- taskDto.taskType = 'process';
1008
- taskDto.command = execution.process;
1009
- taskDto.args = execution.args;
1010
-
1011
- const options = execution.options;
1012
- if (options) {
1013
- taskDto.options = options;
1014
- }
1015
- return taskDto;
1016
- }
1017
-
1018
- export function fromShellExecution(execution: theia.ShellExecution, taskDto: TaskDto): TaskDto {
1019
- taskDto.taskType = 'shell';
1020
- const options = execution.options;
1021
- if (options) {
1022
- taskDto.options = getShellExecutionOptions(options);
1023
- }
1024
-
1025
- const commandLine = execution.commandLine;
1026
- if (commandLine) {
1027
- taskDto.command = commandLine;
1028
- return taskDto;
1029
- }
1030
-
1031
- if (execution.command) {
1032
- taskDto.command = getCommand(execution.command);
1033
- taskDto.args = getShellArgs(execution.args);
1034
- return taskDto;
1035
- } else {
1036
- throw new Error('Command is undefined');
1037
- }
1038
- }
1039
-
1040
- export function fromCustomExecution(execution: types.CustomExecution, taskDto: TaskDto): TaskDto {
1041
- taskDto.taskType = 'customExecution';
1042
- const callback = execution.callback;
1043
- if (callback) {
1044
- taskDto.callback = callback;
1045
- return taskDto;
1046
- } else {
1047
- throw new Error('Converting CustomExecution callback is not implemented');
1048
- }
1049
- }
1050
-
1051
- export function getProcessExecution(taskDto: TaskDto): theia.ProcessExecution {
1052
- return new types.ProcessExecution(
1053
- taskDto.command,
1054
- taskDto.args || [],
1055
- taskDto.options || {});
1056
- }
1057
-
1058
- export function getShellExecution(taskDto: TaskDto): theia.ShellExecution {
1059
- if (taskDto.command && Array.isArray(taskDto.args) && taskDto.args.length !== 0) {
1060
- return new types.ShellExecution(
1061
- taskDto.command,
1062
- taskDto.args,
1063
- taskDto.options || {});
1064
- }
1065
- return new types.ShellExecution(
1066
- taskDto.command || taskDto.commandLine,
1067
- taskDto.options || {});
1068
- }
1069
-
1070
- export function getCustomExecution(taskDto: TaskDto): theia.CustomExecution {
1071
- return new types.CustomExecution(taskDto.callback);
1072
- }
1073
-
1074
- export function getShellArgs(args: undefined | (string | theia.ShellQuotedString)[]): string[] {
1075
- if (!args || args.length === 0) {
1076
- return [];
1077
- }
1078
-
1079
- const element = args[0];
1080
- if (typeof element === 'string') {
1081
- return args as string[];
1082
- }
1083
-
1084
- const result: string[] = [];
1085
- const shellQuotedArgs = args as theia.ShellQuotedString[];
1086
-
1087
- shellQuotedArgs.forEach(arg => {
1088
- result.push(arg.value);
1089
- });
1090
-
1091
- return result;
1092
- }
1093
-
1094
- function getCommand(command: string | theia.ShellQuotedString): string {
1095
- return typeof command === 'string' ? command : command.value;
1096
- }
1097
-
1098
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1099
- export function getShellExecutionOptions(options: theia.ShellExecutionOptions): { [key: string]: any } {
1100
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1101
- const result = {} as { [key: string]: any };
1102
-
1103
- const env = options.env;
1104
- if (env) {
1105
- result['env'] = env;
1106
- }
1107
-
1108
- const executable = options.executable;
1109
- if (executable) {
1110
- result['executable'] = executable;
1111
- }
1112
-
1113
- const shellQuoting = options.shellQuoting;
1114
- if (shellQuoting) {
1115
- result['shellQuoting'] = shellQuoting;
1116
- }
1117
-
1118
- const shellArgs = options.shellArgs;
1119
- if (shellArgs) {
1120
- result['shellArgs'] = shellArgs;
1121
- }
1122
-
1123
- const cwd = options.cwd;
1124
- if (cwd) {
1125
- Object.assign(result, { cwd });
1126
- }
1127
-
1128
- return result;
1129
- }
1130
-
1131
- export function fromSymbolInformation(symbolInformation: theia.SymbolInformation): lstypes.SymbolInformation | undefined {
1132
- if (!symbolInformation) {
1133
- return undefined;
1134
- }
1135
-
1136
- if (symbolInformation.location && symbolInformation.location.range) {
1137
- const p1 = lstypes.Position.create(symbolInformation.location.range.start.line, symbolInformation.location.range.start.character);
1138
- const p2 = lstypes.Position.create(symbolInformation.location.range.end.line, symbolInformation.location.range.end.character);
1139
- return lstypes.SymbolInformation.create(symbolInformation.name, symbolInformation.kind++ as lstypes.SymbolKind, lstypes.Range.create(p1, p2),
1140
- symbolInformation.location.uri.toString(), symbolInformation.containerName);
1141
- }
1142
-
1143
- return {
1144
- name: symbolInformation.name,
1145
- containerName: symbolInformation.containerName,
1146
- kind: symbolInformation.kind++ as lstypes.SymbolKind,
1147
- location: {
1148
- uri: symbolInformation.location.uri.toString(),
1149
- range: symbolInformation.location.range,
1150
- }
1151
- };
1152
- }
1153
-
1154
- export function toSymbolInformation(symbolInformation: lstypes.SymbolInformation): theia.SymbolInformation | undefined {
1155
- if (!symbolInformation) {
1156
- return undefined;
1157
- }
1158
-
1159
- return <theia.SymbolInformation>{
1160
- name: symbolInformation.name,
1161
- containerName: symbolInformation.containerName,
1162
- kind: symbolInformation.kind,
1163
- location: {
1164
- uri: URI.parse(symbolInformation.location.uri),
1165
- range: symbolInformation.location.range
1166
- }
1167
- };
1168
- }
1169
-
1170
- export function fromSelectionRange(selectionRange: theia.SelectionRange): model.SelectionRange {
1171
- return { range: fromRange(selectionRange.range) };
1172
- }
1173
-
1174
- export function fromFoldingRange(foldingRange: theia.FoldingRange): model.FoldingRange {
1175
- const range: model.FoldingRange = {
1176
- start: foldingRange.start + 1,
1177
- end: foldingRange.end + 1
1178
- };
1179
- if (foldingRange.kind) {
1180
- range.kind = fromFoldingRangeKind(foldingRange.kind);
1181
- }
1182
- return range;
1183
- }
1184
-
1185
- export function fromFoldingRangeKind(kind: theia.FoldingRangeKind | undefined): model.FoldingRangeKind | undefined {
1186
- if (kind) {
1187
- switch (kind) {
1188
- case types.FoldingRangeKind.Comment:
1189
- return model.FoldingRangeKind.Comment;
1190
- case types.FoldingRangeKind.Imports:
1191
- return model.FoldingRangeKind.Imports;
1192
- case types.FoldingRangeKind.Region:
1193
- return model.FoldingRangeKind.Region;
1194
- }
1195
- }
1196
- return undefined;
1197
- }
1198
-
1199
- export function fromColor(color: types.Color): [number, number, number, number] {
1200
- return [color.red, color.green, color.blue, color.alpha];
1201
- }
1202
-
1203
- export function toColor(color: [number, number, number, number]): types.Color {
1204
- return new types.Color(color[0], color[1], color[2], color[3]);
1205
- }
1206
-
1207
- export function fromColorPresentation(colorPresentation: theia.ColorPresentation): model.ColorPresentation {
1208
- return {
1209
- label: colorPresentation.label,
1210
- textEdit: colorPresentation.textEdit ? fromTextEdit(colorPresentation.textEdit) : undefined,
1211
- additionalTextEdits: colorPresentation.additionalTextEdits ? colorPresentation.additionalTextEdits.map(value => fromTextEdit(value)) : undefined
1212
- };
1213
- }
1214
-
1215
- export function convertToTransferQuickPickItems(items: rpc.Item[]): rpc.TransferQuickPickItems[] {
1216
- return items.map<rpc.TransferQuickPickItems>((item, index) => {
1217
- if (typeof item === 'string') {
1218
- return { type: 'item', label: item, handle: index };
1219
- } else if (item.kind === QuickPickItemKind.Separator) {
1220
- return { type: 'separator', label: item.label, handle: index };
1221
- } else {
1222
- const { label, description, iconPath, detail, picked, alwaysShow, buttons } = item;
1223
- return {
1224
- type: 'item',
1225
- label,
1226
- description,
1227
- iconPath,
1228
- detail,
1229
- picked,
1230
- alwaysShow,
1231
- buttons,
1232
- handle: index,
1233
- };
1234
- }
1235
- });
1236
- }
1237
-
1238
- export namespace DecorationRenderOptions {
1239
- export function from(options: theia.DecorationRenderOptions): rpc.DecorationRenderOptions {
1240
- return {
1241
- isWholeLine: options.isWholeLine,
1242
- rangeBehavior: options.rangeBehavior ? DecorationRangeBehavior.from(options.rangeBehavior) : undefined,
1243
- overviewRulerLane: options.overviewRulerLane,
1244
- light: options.light ? ThemableDecorationRenderOptions.from(options.light) : undefined,
1245
- dark: options.dark ? ThemableDecorationRenderOptions.from(options.dark) : undefined,
1246
-
1247
- backgroundColor: <string | types.ThemeColor>options.backgroundColor,
1248
- outline: options.outline,
1249
- outlineColor: <string | types.ThemeColor>options.outlineColor,
1250
- outlineStyle: options.outlineStyle,
1251
- outlineWidth: options.outlineWidth,
1252
- border: options.border,
1253
- borderColor: <string | types.ThemeColor>options.borderColor,
1254
- borderRadius: options.borderRadius,
1255
- borderSpacing: options.borderSpacing,
1256
- borderStyle: options.borderStyle,
1257
- borderWidth: options.borderWidth,
1258
- fontStyle: options.fontStyle,
1259
- fontWeight: options.fontWeight,
1260
- textDecoration: options.textDecoration,
1261
- cursor: options.cursor,
1262
- color: <string | types.ThemeColor>options.color,
1263
- opacity: options.opacity,
1264
- letterSpacing: options.letterSpacing,
1265
- gutterIconPath: options.gutterIconPath ? pathOrURIToURI(options.gutterIconPath) : undefined,
1266
- gutterIconSize: options.gutterIconSize,
1267
- overviewRulerColor: <string | types.ThemeColor>options.overviewRulerColor,
1268
- before: options.before ? ThemableDecorationAttachmentRenderOptions.from(options.before) : undefined,
1269
- after: options.after ? ThemableDecorationAttachmentRenderOptions.from(options.after) : undefined,
1270
- };
1271
- }
1272
- }
1273
-
1274
- export namespace DecorationRangeBehavior {
1275
- export function from(value: types.DecorationRangeBehavior): rpc.TrackedRangeStickiness {
1276
- if (typeof value === 'undefined') {
1277
- return value;
1278
- }
1279
- switch (value) {
1280
- case types.DecorationRangeBehavior.OpenOpen:
1281
- return rpc.TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges;
1282
- case types.DecorationRangeBehavior.ClosedClosed:
1283
- return rpc.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges;
1284
- case types.DecorationRangeBehavior.OpenClosed:
1285
- return rpc.TrackedRangeStickiness.GrowsOnlyWhenTypingBefore;
1286
- case types.DecorationRangeBehavior.ClosedOpen:
1287
- return rpc.TrackedRangeStickiness.GrowsOnlyWhenTypingAfter;
1288
- }
1289
- }
1290
- }
1291
-
1292
- export namespace ThemableDecorationRenderOptions {
1293
- export function from(options: theia.ThemableDecorationRenderOptions): rpc.ThemeDecorationRenderOptions {
1294
- if (typeof options === 'undefined') {
1295
- return options;
1296
- }
1297
- return {
1298
- backgroundColor: <string | types.ThemeColor>options.backgroundColor,
1299
- outline: options.outline,
1300
- outlineColor: <string | types.ThemeColor>options.outlineColor,
1301
- outlineStyle: options.outlineStyle,
1302
- outlineWidth: options.outlineWidth,
1303
- border: options.border,
1304
- borderColor: <string | types.ThemeColor>options.borderColor,
1305
- borderRadius: options.borderRadius,
1306
- borderSpacing: options.borderSpacing,
1307
- borderStyle: options.borderStyle,
1308
- borderWidth: options.borderWidth,
1309
- fontStyle: options.fontStyle,
1310
- fontWeight: options.fontWeight,
1311
- textDecoration: options.textDecoration,
1312
- cursor: options.cursor,
1313
- color: <string | types.ThemeColor>options.color,
1314
- opacity: options.opacity,
1315
- letterSpacing: options.letterSpacing,
1316
- gutterIconPath: options.gutterIconPath ? pathOrURIToURI(options.gutterIconPath) : undefined,
1317
- gutterIconSize: options.gutterIconSize,
1318
- overviewRulerColor: <string | types.ThemeColor>options.overviewRulerColor,
1319
- before: options.before ? ThemableDecorationAttachmentRenderOptions.from(options.before) : undefined,
1320
- after: options.after ? ThemableDecorationAttachmentRenderOptions.from(options.after) : undefined,
1321
- };
1322
- }
1323
- }
1324
-
1325
- export namespace ThemableDecorationAttachmentRenderOptions {
1326
- export function from(options: theia.ThemableDecorationAttachmentRenderOptions): rpc.ContentDecorationRenderOptions {
1327
- if (typeof options === 'undefined') {
1328
- return options;
1329
- }
1330
- return {
1331
- contentText: options.contentText,
1332
- contentIconPath: options.contentIconPath ? pathOrURIToURI(options.contentIconPath) : undefined,
1333
- border: options.border,
1334
- borderColor: <string | types.ThemeColor>options.borderColor,
1335
- fontStyle: options.fontStyle,
1336
- fontWeight: options.fontWeight,
1337
- textDecoration: options.textDecoration,
1338
- color: <string | types.ThemeColor>options.color,
1339
- backgroundColor: <string | types.ThemeColor>options.backgroundColor,
1340
- margin: options.margin,
1341
- width: options.width,
1342
- height: options.height,
1343
- };
1344
- }
1345
- }
1346
-
1347
- export namespace ViewColumn {
1348
- export function from(column?: theia.ViewColumn): rpc.EditorGroupColumn {
1349
- if (typeof column === 'number' && column >= types.ViewColumn.One) {
1350
- return column - 1; // adjust zero index (ViewColumn.ONE => 0)
1351
- }
1352
-
1353
- if (column === types.ViewColumn.Beside) {
1354
- return SIDE_GROUP;
1355
- }
1356
-
1357
- return ACTIVE_GROUP; // default is always the active group
1358
- }
1359
-
1360
- export function to(position: rpc.EditorGroupColumn): theia.ViewColumn {
1361
- if (typeof position === 'number' && position >= 0) {
1362
- return position + 1; // adjust to index (ViewColumn.ONE => 1)
1363
- }
1364
-
1365
- throw new Error('invalid \'EditorGroupColumn\'');
1366
- }
1367
- }
1368
-
1369
- export function pathOrURIToURI(value: string | URI): URI {
1370
- if (typeof value === 'undefined') {
1371
- return value;
1372
- }
1373
- if (typeof value === 'string') {
1374
- return URI.file(value);
1375
- } else {
1376
- return value;
1377
- }
1378
- }
1379
-
1380
- export function pluginToPluginInfo(plugin: Plugin): rpc.PluginInfo {
1381
- return {
1382
- id: plugin.model.id,
1383
- name: plugin.model.name,
1384
- displayName: plugin.model.displayName
1385
- };
1386
- }
1387
-
1388
- export namespace InlayHintKind {
1389
- export function from(kind: theia.InlayHintKind): model.InlayHintKind {
1390
- return kind;
1391
- }
1392
- export function to(kind: model.InlayHintKind): theia.InlayHintKind {
1393
- return kind;
1394
- }
1395
- }
1396
-
1397
- export namespace DataTransferItem {
1398
- export function to(mime: string, item: model.DataTransferItemDTO, resolveFileData: (itemId: string) => Promise<Uint8Array>): theia.DataTransferItem {
1399
- const file = item.fileData;
1400
- if (file) {
1401
- return new class extends types.DataTransferItem {
1402
- override asFile(): theia.DataTransferFile {
1403
- return {
1404
- name: file.name,
1405
- uri: URI.revive(file.uri),
1406
- data: () => resolveFileData(item.id),
1407
- };
1408
- }
1409
- }('');
1410
- }
1411
-
1412
- if (mime === 'text/uri-list' && item.uriListData) {
1413
- return new types.DataTransferItem(reviveUriList(item.uriListData));
1414
- }
1415
-
1416
- return new types.DataTransferItem(item.asString);
1417
- }
1418
-
1419
- function reviveUriList(parts: ReadonlyArray<string | UriComponents>): string {
1420
- return parts.map(part => typeof part === 'string' ? part : URI.revive(part).toString()).join('\r\n');
1421
- }
1422
- }
1423
-
1424
- export namespace DataTransfer {
1425
- export function toDataTransfer(value: model.DataTransferDTO, resolveFileData: (itemId: string) => Promise<Uint8Array>): theia.DataTransfer {
1426
- const dataTransfer = new types.DataTransfer();
1427
- for (const [mimeType, item] of value.items) {
1428
- dataTransfer.set(mimeType, DataTransferItem.to(mimeType, item, resolveFileData));
1429
- }
1430
- return dataTransfer;
1431
- }
1432
- }
1433
-
1434
- export namespace NotebookDocumentContentOptions {
1435
- export function from(options: theia.NotebookDocumentContentOptions | undefined): notebooks.TransientOptions {
1436
- return {
1437
- transientOutputs: options?.transientOutputs ?? false,
1438
- transientCellMetadata: options?.transientCellMetadata ?? {},
1439
- transientDocumentMetadata: options?.transientDocumentMetadata ?? {},
1440
- };
1441
- }
1442
- }
1443
-
1444
- export namespace NotebookStatusBarItem {
1445
- export function from(item: theia.NotebookCellStatusBarItem, commandsConverter: CommandsConverter, disposables: DisposableCollection): notebooks.NotebookCellStatusBarItem {
1446
- const command = typeof item.command === 'string' ? { title: '', command: item.command } : item.command;
1447
- return {
1448
- alignment: item.alignment === types.NotebookCellStatusBarAlignment.Left ? notebooks.CellStatusbarAlignment.Left : notebooks.CellStatusbarAlignment.Right,
1449
- command: commandsConverter.toSafeCommand(command, disposables),
1450
- text: item.text,
1451
- tooltip: item.tooltip,
1452
- priority: item.priority
1453
- };
1454
- }
1455
- }
1456
-
1457
- export namespace NotebookData {
1458
-
1459
- export function from(data: theia.NotebookData): rpc.NotebookDataDto {
1460
- const res: rpc.NotebookDataDto = {
1461
- metadata: data.metadata ?? Object.create(null),
1462
- cells: [],
1463
- };
1464
- for (const cell of data.cells) {
1465
- // types.NotebookCellData.validate(cell);
1466
- res.cells.push(NotebookCellData.from(cell));
1467
- }
1468
- return res;
1469
- }
1470
-
1471
- export function to(data: rpc.NotebookDataDto): theia.NotebookData {
1472
- const res = new types.NotebookData(
1473
- data.cells.map(NotebookCellData.to),
1474
- );
1475
- if (!isEmptyObject(data.metadata)) {
1476
- res.metadata = data.metadata;
1477
- }
1478
- return res;
1479
- }
1480
- }
1481
-
1482
- export namespace NotebookCellData {
1483
-
1484
- export function from(data: theia.NotebookCellData): rpc.NotebookCellDataDto {
1485
- return {
1486
- cellKind: NotebookCellKind.from(data.kind),
1487
- language: data.languageId,
1488
- source: data.value,
1489
- // metadata: data.metadata,
1490
- // internalMetadata: NotebookCellExecutionSummary.from(data.executionSummary ?? {}),
1491
- outputs: data.outputs ? data.outputs.map(NotebookCellOutputConverter.from) : []
1492
- };
1493
- }
1494
-
1495
- export function to(data: rpc.NotebookCellDataDto): theia.NotebookCellData {
1496
- return new types.NotebookCellData(
1497
- NotebookCellKind.to(data.cellKind),
1498
- data.source,
1499
- data.language,
1500
- data.outputs ? data.outputs.map(NotebookCellOutput.to) : undefined,
1501
- data.metadata,
1502
- data.internalMetadata ? NotebookCellExecutionSummary.to(data.internalMetadata) : undefined
1503
- );
1504
- }
1505
- }
1506
-
1507
- export namespace NotebookCellKind {
1508
- export function from(data: theia.NotebookCellKind): notebooks.CellKind {
1509
- switch (data) {
1510
- case types.NotebookCellKind.Markup:
1511
- return notebooks.CellKind.Markup;
1512
- case types.NotebookCellKind.Code:
1513
- default:
1514
- return notebooks.CellKind.Code;
1515
- }
1516
- }
1517
-
1518
- export function to(data: notebooks.CellKind): theia.NotebookCellKind {
1519
- switch (data) {
1520
- case notebooks.CellKind.Markup:
1521
- return types.NotebookCellKind.Markup;
1522
- case notebooks.CellKind.Code:
1523
- default:
1524
- return types.NotebookCellKind.Code;
1525
- }
1526
- }
1527
- }
1528
-
1529
- export namespace NotebookCellOutput {
1530
- export function from(output: theia.NotebookCellOutput & { outputId: string }): rpc.NotebookOutputDto {
1531
- return {
1532
- outputId: output.outputId,
1533
- items: output.items.map(NotebookCellOutputItem.from),
1534
- metadata: output.metadata
1535
- };
1536
- }
1537
-
1538
- export function to(output: rpc.NotebookOutputDto): theia.NotebookCellOutput {
1539
- const items = output.items.map(NotebookCellOutputItem.to);
1540
- return new types.NotebookCellOutput(items, output.outputId, output.metadata);
1541
- }
1542
- }
1543
-
1544
- export namespace NotebookCellOutputItem {
1545
- export function from(item: types.NotebookCellOutputItem): rpc.NotebookOutputItemDto {
1546
- return {
1547
- mime: item.mime,
1548
- valueBytes: BinaryBuffer.wrap(item.data),
1549
- };
1550
- }
1551
-
1552
- export function to(item: rpc.NotebookOutputItemDto): types.NotebookCellOutputItem {
1553
- return new types.NotebookCellOutputItem(item.valueBytes.buffer, item.mime);
1554
- }
1555
- }
1556
-
1557
- export namespace NotebookCellOutputConverter {
1558
- export function from(output: types.NotebookCellOutput): rpc.NotebookOutputDto {
1559
- return {
1560
- outputId: output.outputId,
1561
- items: output.items.map(NotebookCellOutputItem.from),
1562
- metadata: output.metadata
1563
- };
1564
- }
1565
-
1566
- export function to(output: rpc.NotebookOutputDto): types.NotebookCellOutput {
1567
- const items = output.items.map(NotebookCellOutputItem.to);
1568
- return new types.NotebookCellOutput(items, output.outputId, output.metadata);
1569
- }
1570
-
1571
- export function ensureUniqueMimeTypes(items: types.NotebookCellOutputItem[], warn: boolean = false): types.NotebookCellOutputItem[] {
1572
- const seen = new Set<string>();
1573
- const removeIdx = new Set<number>();
1574
- for (let i = 0; i < items.length; i++) {
1575
- const item = items[i];
1576
- // We can have multiple text stream mime types in the same output.
1577
- if (!seen.has(item.mime) || isTextStreamMime(item.mime)) {
1578
- seen.add(item.mime);
1579
- continue;
1580
- }
1581
- // duplicated mime types... first has won
1582
- removeIdx.add(i);
1583
- if (warn) {
1584
- console.warn(`DUPLICATED mime type '${item.mime}' will be dropped`);
1585
- }
1586
- }
1587
- if (removeIdx.size === 0) {
1588
- return items;
1589
- }
1590
- return items.filter((_, index) => !removeIdx.has(index));
1591
- }
1592
- }
1593
-
1594
- export namespace NotebookCellExecutionSummary {
1595
- export function to(data: notebooks.NotebookCellInternalMetadata): theia.NotebookCellExecutionSummary {
1596
- return {
1597
- timing: typeof data.runStartTime === 'number' && typeof data.runEndTime === 'number' ? { startTime: data.runStartTime, endTime: data.runEndTime } : undefined,
1598
- executionOrder: data.executionOrder,
1599
- success: data.lastRunSuccess
1600
- };
1601
- }
1602
-
1603
- export function from(data: theia.NotebookCellExecutionSummary): Partial<notebooks.NotebookCellInternalMetadata> {
1604
- return {
1605
- lastRunSuccess: data.success,
1606
- runStartTime: data.timing?.startTime,
1607
- runEndTime: data.timing?.endTime,
1608
- executionOrder: data.executionOrder
1609
- };
1610
- }
1611
- }
1612
-
1613
- export namespace NotebookRange {
1614
-
1615
- export function from(range: theia.NotebookRange): CellRange {
1616
- return { start: range.start, end: range.end };
1617
- }
1618
-
1619
- export function to(range: CellRange): types.NotebookRange {
1620
- return new types.NotebookRange(range.start, range.end);
1621
- }
1622
- }
1623
-
1624
- export namespace NotebookKernelSourceAction {
1625
- export function from(item: theia.NotebookKernelSourceAction, commandsConverter: CommandsConverter, disposables: DisposableCollection): rpc.NotebookKernelSourceActionDto {
1626
- const command = typeof item.command === 'string' ? { title: '', command: item.command } : item.command;
1627
-
1628
- return {
1629
- command: commandsConverter.toSafeCommand(command, disposables),
1630
- label: item.label,
1631
- description: item.description,
1632
- detail: item.detail,
1633
- documentation: item.documentation
1634
- };
1635
- }
1636
- }
1637
-
1638
- export namespace TestMessage {
1639
- export function from(message: theia.TestMessage | readonly theia.TestMessage[]): TestMessageDTO[] {
1640
- if (isReadonlyArray(message)) {
1641
- return message.map(msg => TestMessage.from(msg)[0]);
1642
- }
1643
- return [{
1644
- location: fromLocation(message.location),
1645
- message: fromMarkdown(message.message)!,
1646
- expected: message.expectedOutput,
1647
- actual: message.actualOutput,
1648
- contextValue: message.contextValue
1649
- }];
1650
- }
1651
- }
1652
-
1653
- export namespace TestItem {
1654
- export function from(test: theia.TestItem): TestItemDTO {
1655
- return <TestItemDTO>TestItem.fromPartial(test);
1656
- }
1657
-
1658
- export function fromPartial(test: Partial<theia.TestItem>): Partial<TestItemDTO> {
1659
- const result: Partial<Mutable<TestItemDTO>> = {};
1660
-
1661
- if ('id' in test) {
1662
- result.id = test.id;
1663
- }
1664
-
1665
- if ('uri' in test) {
1666
- result.uri = test.uri;
1667
- }
1668
-
1669
- if ('label' in test) {
1670
- result.label = test.label;
1671
- }
1672
-
1673
- if ('range' in test) {
1674
- result.range = fromRange(test.range);
1675
- }
1676
-
1677
- if ('sortKey' in test) {
1678
- result.sortKey = test.sortText;
1679
- }
1680
-
1681
- if ('tags' in test) {
1682
- result.tags = test.tags ? test.tags.map(tag => tag.id) : [];
1683
- }
1684
- if ('busy' in test) {
1685
- result.busy = test.busy!;
1686
- }
1687
- if ('sortKey' in test) {
1688
- result.sortKey = test.sortText;
1689
- }
1690
- if ('canResolveChildren' in test) {
1691
- result.canResolveChildren = test.canResolveChildren!;
1692
- }
1693
- if ('description' in test) {
1694
- result.description = test.description;
1695
- }
1696
-
1697
- if ('description' in test) {
1698
- result.error = test.error;
1699
- }
1700
-
1701
- if (test.children) {
1702
- const children: TestItemDTO[] = [];
1703
- test.children.forEach(item => {
1704
- children.push(TestItem.from(item));
1705
- });
1706
- result.children = children;
1707
- }
1708
-
1709
- return result;
1710
-
1711
- }
1712
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 Red Hat, Inc. and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import * as theia from '@theia/plugin';
18
+ import * as lstypes from '@theia/core/shared/vscode-languageserver-protocol';
19
+ import { InlineValueEvaluatableExpression, InlineValueText, InlineValueVariableLookup, QuickPickItemKind, URI } from './types-impl';
20
+ import * as rpc from '../common/plugin-api-rpc';
21
+ import {
22
+ DecorationOptions, EditorPosition, Plugin, Position, WorkspaceTextEditDto, WorkspaceFileEditDto, Selection, TaskDto, WorkspaceEditDto
23
+ } from '../common/plugin-api-rpc';
24
+ import * as model from '../common/plugin-api-rpc-model';
25
+ import { LanguageFilter, LanguageSelector, RelativePattern } from '@theia/editor/lib/common/language-selector';
26
+ import { MarkdownString as PluginMarkdownStringImpl } from './markdown-string';
27
+ import * as types from './types-impl';
28
+ import { UriComponents } from '../common/uri-components';
29
+ import { isReadonlyArray } from '../common/arrays';
30
+ import { DisposableCollection, Mutable, isEmptyObject, isObject } from '@theia/core/lib/common';
31
+ import * as notebooks from '@theia/notebook/lib/common';
32
+ import { CommandsConverter } from './command-registry';
33
+ import { BinaryBuffer } from '@theia/core/lib/common/buffer';
34
+ import { CellRange, isTextStreamMime } from '@theia/notebook/lib/common';
35
+ import { MarkdownString as MarkdownStringDTO } from '@theia/core/lib/common/markdown-rendering';
36
+
37
+ import { TestItemDTO, TestMessageDTO } from '../common/test-types';
38
+ import { ThemeIcon } from '@theia/monaco-editor-core/esm/vs/base/common/themables';
39
+
40
+ const SIDE_GROUP = -2;
41
+ const ACTIVE_GROUP = -1;
42
+
43
+ export function toViewColumn(ep?: EditorPosition): theia.ViewColumn | undefined {
44
+ if (typeof ep !== 'number') {
45
+ return undefined;
46
+ }
47
+
48
+ if (ep === EditorPosition.ONE) {
49
+ return <number>types.ViewColumn.One;
50
+ } else if (ep === EditorPosition.TWO) {
51
+ return <number>types.ViewColumn.Two;
52
+ } else if (ep === EditorPosition.THREE) {
53
+ return <number>types.ViewColumn.Three;
54
+ } else if (ep === EditorPosition.FOUR) {
55
+ return <number>types.ViewColumn.Four;
56
+ } else if (ep === EditorPosition.FIVE) {
57
+ return <number>types.ViewColumn.Five;
58
+ } else if (ep === EditorPosition.SIX) {
59
+ return <number>types.ViewColumn.Six;
60
+ } else if (ep === EditorPosition.SEVEN) {
61
+ return <number>types.ViewColumn.Seven;
62
+ } else if (ep === EditorPosition.EIGHT) {
63
+ return <number>types.ViewColumn.Eight;
64
+ } else if (ep === EditorPosition.NINE) {
65
+ return <number>types.ViewColumn.Nine;
66
+ }
67
+
68
+ return undefined;
69
+ }
70
+
71
+ export function fromViewColumn(column?: theia.ViewColumn): number {
72
+ if (typeof column === 'number' && column >= types.ViewColumn.One) {
73
+ return column - 1;
74
+ }
75
+
76
+ if (column! === <number>types.ViewColumn.Beside) {
77
+ return SIDE_GROUP;
78
+ }
79
+
80
+ return ACTIVE_GROUP;
81
+ }
82
+
83
+ export function toWebviewPanelShowOptions(options: theia.ViewColumn | theia.WebviewPanelShowOptions): theia.WebviewPanelShowOptions {
84
+ if (typeof options === 'object') {
85
+ const showOptions = options as theia.WebviewPanelShowOptions;
86
+ return {
87
+ area: showOptions.area ? showOptions.area : types.WebviewPanelTargetArea.Main,
88
+ viewColumn: showOptions.viewColumn ? fromViewColumn(showOptions.viewColumn) : undefined,
89
+ preserveFocus: showOptions.preserveFocus ? showOptions.preserveFocus : false
90
+ };
91
+ }
92
+
93
+ return {
94
+ area: types.WebviewPanelTargetArea.Main,
95
+ viewColumn: fromViewColumn(options as theia.ViewColumn),
96
+ preserveFocus: false
97
+ };
98
+ }
99
+
100
+ export function toSelection(selection: Selection): types.Selection {
101
+ const { selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn } = selection;
102
+ const start = new types.Position(selectionStartLineNumber - 1, selectionStartColumn - 1);
103
+ const end = new types.Position(positionLineNumber - 1, positionColumn - 1);
104
+ return new types.Selection(start, end);
105
+ }
106
+
107
+ export function fromSelection(selection: types.Selection): Selection {
108
+ const { active, anchor } = selection;
109
+ return {
110
+ selectionStartLineNumber: anchor.line + 1,
111
+ selectionStartColumn: anchor.character + 1,
112
+ positionLineNumber: active.line + 1,
113
+ positionColumn: active.character + 1
114
+ };
115
+ }
116
+
117
+ export function toRange(range: model.Range): types.Range {
118
+ const { startLineNumber, startColumn, endLineNumber, endColumn } = range;
119
+ return new types.Range(startLineNumber - 1, startColumn - 1, endLineNumber - 1, endColumn - 1);
120
+ }
121
+
122
+ export function fromRange(range: undefined): undefined;
123
+ export function fromRange(range: theia.Range): model.Range;
124
+ export function fromRange(range: theia.Range | undefined): model.Range | undefined;
125
+ export function fromRange(range: theia.Range | undefined): model.Range | undefined {
126
+ if (!range) {
127
+ return undefined;
128
+ }
129
+ const { start, end } = range;
130
+ return {
131
+ startLineNumber: start.line + 1,
132
+ startColumn: start.character + 1,
133
+ endLineNumber: end.line + 1,
134
+ endColumn: end.character + 1
135
+ };
136
+ }
137
+
138
+ export function fromPosition(position: types.Position | theia.Position): Position {
139
+ return { lineNumber: position.line + 1, column: position.character + 1 };
140
+ }
141
+
142
+ export function toPosition(position: Position): types.Position {
143
+ return new types.Position(position.lineNumber - 1, position.column - 1);
144
+ }
145
+
146
+ function isDecorationOptions(arg: unknown): arg is theia.DecorationOptions {
147
+ return isObject<theia.DecorationOptions>(arg) && typeof arg.range !== 'undefined';
148
+ }
149
+
150
+ export function isDecorationOptionsArr(something: theia.Range[] | theia.DecorationOptions[]): something is theia.DecorationOptions[] {
151
+ if (something.length === 0) {
152
+ return true;
153
+ }
154
+ return isDecorationOptions(something[0]) ? true : false;
155
+ }
156
+
157
+ export function fromRangeOrRangeWithMessage(ranges: theia.Range[] | theia.DecorationOptions[]): DecorationOptions[] {
158
+
159
+ if (isDecorationOptionsArr(ranges)) {
160
+ return ranges.map(r => {
161
+ let hoverMessage;
162
+ if (Array.isArray(r.hoverMessage)) {
163
+ hoverMessage = fromManyMarkdown(r.hoverMessage);
164
+ } else if (r.hoverMessage) {
165
+ hoverMessage = fromMarkdown(r.hoverMessage);
166
+ } else {
167
+ hoverMessage = undefined;
168
+ }
169
+ return {
170
+ range: fromRange(r.range)!,
171
+ hoverMessage: hoverMessage,
172
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
173
+ renderOptions: <any> /* URI vs Uri */r.renderOptions
174
+ };
175
+ });
176
+ } else {
177
+ return ranges.map(r => ({ range: fromRange(r) }));
178
+ }
179
+ }
180
+
181
+ export function fromManyMarkdown(markup: (theia.MarkdownString | theia.MarkedString)[]): MarkdownStringDTO[] {
182
+ return markup.map(fromMarkdown);
183
+ }
184
+
185
+ interface Codeblock {
186
+ language: string;
187
+ value: string;
188
+ }
189
+
190
+ function isCodeblock(arg: unknown): arg is Codeblock {
191
+ return isObject<Codeblock>(arg)
192
+ && typeof arg.language === 'string'
193
+ && typeof arg.value === 'string';
194
+ }
195
+
196
+ export function fromMarkdown(markup: theia.MarkdownString | theia.MarkedString): MarkdownStringDTO {
197
+ if (isCodeblock(markup)) {
198
+ const { language, value } = markup;
199
+ return { value: '```' + language + '\n' + value + '\n```\n' };
200
+ } else if (markup instanceof PluginMarkdownStringImpl) {
201
+ return markup.toJSON();
202
+ } else if (MarkdownStringDTO.is(markup)) {
203
+ return markup;
204
+ } else if (typeof markup === 'string') {
205
+ return { value: markup };
206
+ } else {
207
+ return { value: '' };
208
+ }
209
+ }
210
+
211
+ export function fromMarkdownOrString(value: string | theia.MarkdownString | undefined): string | MarkdownStringDTO | undefined {
212
+ if (value === undefined) {
213
+ return undefined;
214
+ } else if (typeof value === 'string') {
215
+ return value;
216
+ } else {
217
+ return fromMarkdown(value);
218
+ }
219
+ }
220
+
221
+ export function toMarkdown(value: MarkdownStringDTO): PluginMarkdownStringImpl {
222
+ const implemented = new PluginMarkdownStringImpl(value.value, value.supportThemeIcons);
223
+ implemented.isTrusted = value.isTrusted;
224
+ implemented.supportHtml = value.supportHtml;
225
+ implemented.baseUri = value.baseUri && URI.revive(implemented.baseUri);
226
+ return implemented;
227
+ }
228
+
229
+ export function fromDocumentSelector(selector: theia.DocumentSelector | undefined): LanguageSelector | undefined {
230
+ if (!selector) {
231
+ return undefined;
232
+ } else if (isReadonlyArray(selector)) {
233
+ return <LanguageSelector>selector.map(fromDocumentSelector);
234
+ } else if (typeof selector === 'string') {
235
+ return selector;
236
+ } else {
237
+ return {
238
+ language: selector.language,
239
+ scheme: selector.scheme,
240
+ pattern: fromGlobPattern(selector.pattern!)
241
+ } as LanguageFilter;
242
+ }
243
+
244
+ }
245
+
246
+ export function fromGlobPattern(pattern: theia.GlobPattern): string | RelativePattern {
247
+ if (typeof pattern === 'string') {
248
+ return pattern;
249
+ }
250
+
251
+ if (isRelativePattern(pattern)) {
252
+ return new types.RelativePattern(pattern.baseUri, pattern.pattern);
253
+ }
254
+
255
+ return pattern;
256
+ }
257
+
258
+ function isRelativePattern(obj: {}): obj is theia.RelativePattern {
259
+ const rp = obj as theia.RelativePattern;
260
+ return rp && typeof rp.baseUri === 'string' && typeof rp.pattern === 'string';
261
+ }
262
+
263
+ export function fromCompletionItemKind(kind?: types.CompletionItemKind): model.CompletionItemKind {
264
+ switch (kind) {
265
+ case types.CompletionItemKind.Method: return model.CompletionItemKind.Method;
266
+ case types.CompletionItemKind.Function: return model.CompletionItemKind.Function;
267
+ case types.CompletionItemKind.Constructor: return model.CompletionItemKind.Constructor;
268
+ case types.CompletionItemKind.Field: return model.CompletionItemKind.Field;
269
+ case types.CompletionItemKind.Variable: return model.CompletionItemKind.Variable;
270
+ case types.CompletionItemKind.Class: return model.CompletionItemKind.Class;
271
+ case types.CompletionItemKind.Interface: return model.CompletionItemKind.Interface;
272
+ case types.CompletionItemKind.Struct: return model.CompletionItemKind.Struct;
273
+ case types.CompletionItemKind.Module: return model.CompletionItemKind.Module;
274
+ case types.CompletionItemKind.Property: return model.CompletionItemKind.Property;
275
+ case types.CompletionItemKind.Unit: return model.CompletionItemKind.Unit;
276
+ case types.CompletionItemKind.Value: return model.CompletionItemKind.Value;
277
+ case types.CompletionItemKind.Constant: return model.CompletionItemKind.Constant;
278
+ case types.CompletionItemKind.Enum: return model.CompletionItemKind.Enum;
279
+ case types.CompletionItemKind.EnumMember: return model.CompletionItemKind.EnumMember;
280
+ case types.CompletionItemKind.Keyword: return model.CompletionItemKind.Keyword;
281
+ case types.CompletionItemKind.Snippet: return model.CompletionItemKind.Snippet;
282
+ case types.CompletionItemKind.Text: return model.CompletionItemKind.Text;
283
+ case types.CompletionItemKind.Color: return model.CompletionItemKind.Color;
284
+ case types.CompletionItemKind.File: return model.CompletionItemKind.File;
285
+ case types.CompletionItemKind.Reference: return model.CompletionItemKind.Reference;
286
+ case types.CompletionItemKind.Folder: return model.CompletionItemKind.Folder;
287
+ case types.CompletionItemKind.Event: return model.CompletionItemKind.Event;
288
+ case types.CompletionItemKind.Operator: return model.CompletionItemKind.Operator;
289
+ case types.CompletionItemKind.TypeParameter: return model.CompletionItemKind.TypeParameter;
290
+ case types.CompletionItemKind.User: return model.CompletionItemKind.User;
291
+ case types.CompletionItemKind.Issue: return model.CompletionItemKind.Issue;
292
+ }
293
+ return model.CompletionItemKind.Property;
294
+ }
295
+
296
+ export function toCompletionItemKind(kind?: model.CompletionItemKind): types.CompletionItemKind {
297
+ switch (kind) {
298
+ case model.CompletionItemKind.Method: return types.CompletionItemKind.Method;
299
+ case model.CompletionItemKind.Function: return types.CompletionItemKind.Function;
300
+ case model.CompletionItemKind.Constructor: return types.CompletionItemKind.Constructor;
301
+ case model.CompletionItemKind.Field: return types.CompletionItemKind.Field;
302
+ case model.CompletionItemKind.Variable: return types.CompletionItemKind.Variable;
303
+ case model.CompletionItemKind.Class: return types.CompletionItemKind.Class;
304
+ case model.CompletionItemKind.Interface: return types.CompletionItemKind.Interface;
305
+ case model.CompletionItemKind.Struct: return types.CompletionItemKind.Struct;
306
+ case model.CompletionItemKind.Module: return types.CompletionItemKind.Module;
307
+ case model.CompletionItemKind.Property: return types.CompletionItemKind.Property;
308
+ case model.CompletionItemKind.Unit: return types.CompletionItemKind.Unit;
309
+ case model.CompletionItemKind.Value: return types.CompletionItemKind.Value;
310
+ case model.CompletionItemKind.Constant: return types.CompletionItemKind.Constant;
311
+ case model.CompletionItemKind.Enum: return types.CompletionItemKind.Enum;
312
+ case model.CompletionItemKind.EnumMember: return types.CompletionItemKind.EnumMember;
313
+ case model.CompletionItemKind.Keyword: return types.CompletionItemKind.Keyword;
314
+ case model.CompletionItemKind.Snippet: return types.CompletionItemKind.Snippet;
315
+ case model.CompletionItemKind.Text: return types.CompletionItemKind.Text;
316
+ case model.CompletionItemKind.Color: return types.CompletionItemKind.Color;
317
+ case model.CompletionItemKind.File: return types.CompletionItemKind.File;
318
+ case model.CompletionItemKind.Reference: return types.CompletionItemKind.Reference;
319
+ case model.CompletionItemKind.Folder: return types.CompletionItemKind.Folder;
320
+ case model.CompletionItemKind.Event: return types.CompletionItemKind.Event;
321
+ case model.CompletionItemKind.Operator: return types.CompletionItemKind.Operator;
322
+ case model.CompletionItemKind.TypeParameter: return types.CompletionItemKind.TypeParameter;
323
+ case model.CompletionItemKind.User: return types.CompletionItemKind.User;
324
+ case model.CompletionItemKind.Issue: return types.CompletionItemKind.Issue;
325
+ }
326
+ return types.CompletionItemKind.Property;
327
+ }
328
+
329
+ export function fromTextEdit(edit: theia.TextEdit): model.TextEdit {
330
+ return {
331
+ text: edit.newText,
332
+ range: fromRange(edit.range)
333
+ };
334
+ }
335
+
336
+ function fromSnippetTextEdit(edit: theia.SnippetTextEdit): model.TextEdit & { insertAsSnippet?: boolean } {
337
+ return {
338
+ text: edit.snippet.value,
339
+ range: fromRange(edit.range),
340
+ insertAsSnippet: true
341
+ };
342
+ }
343
+
344
+ export function convertDiagnosticToMarkerData(diagnostic: theia.Diagnostic): model.MarkerData {
345
+ return {
346
+ code: convertCode(diagnostic.code),
347
+ severity: convertSeverity(diagnostic.severity),
348
+ message: diagnostic.message,
349
+ source: diagnostic.source,
350
+ startLineNumber: diagnostic.range.start.line + 1,
351
+ startColumn: diagnostic.range.start.character + 1,
352
+ endLineNumber: diagnostic.range.end.line + 1,
353
+ endColumn: diagnostic.range.end.character + 1,
354
+ relatedInformation: convertRelatedInformation(diagnostic.relatedInformation),
355
+ tags: convertTags(diagnostic.tags)
356
+ };
357
+ }
358
+
359
+ export function convertCode(code: string | number | { value: string | number; target: theia.Uri } | undefined): string | undefined {
360
+ if (typeof code === 'number') {
361
+ return String(code);
362
+ }
363
+ if (typeof code === 'string' || typeof code === 'undefined') {
364
+ return code;
365
+ } else {
366
+ return String(code.value);
367
+ };
368
+ }
369
+
370
+ function convertSeverity(severity: types.DiagnosticSeverity): types.MarkerSeverity {
371
+ switch (severity) {
372
+ case types.DiagnosticSeverity.Error: return types.MarkerSeverity.Error;
373
+ case types.DiagnosticSeverity.Warning: return types.MarkerSeverity.Warning;
374
+ case types.DiagnosticSeverity.Information: return types.MarkerSeverity.Info;
375
+ case types.DiagnosticSeverity.Hint: return types.MarkerSeverity.Hint;
376
+ }
377
+ }
378
+
379
+ function convertRelatedInformation(diagnosticsRelatedInformation: theia.DiagnosticRelatedInformation[] | undefined): model.RelatedInformation[] | undefined {
380
+ if (!diagnosticsRelatedInformation) {
381
+ return undefined;
382
+ }
383
+
384
+ const relatedInformation: model.RelatedInformation[] = [];
385
+ for (const item of diagnosticsRelatedInformation) {
386
+ relatedInformation.push({
387
+ resource: item.location.uri.toString(),
388
+ message: item.message,
389
+ startLineNumber: item.location.range.start.line + 1,
390
+ startColumn: item.location.range.start.character + 1,
391
+ endLineNumber: item.location.range.end.line + 1,
392
+ endColumn: item.location.range.end.character + 1
393
+ });
394
+ }
395
+ return relatedInformation;
396
+ }
397
+
398
+ function convertTags(tags: types.DiagnosticTag[] | undefined): types.MarkerTag[] | undefined {
399
+ if (!tags) {
400
+ return undefined;
401
+ }
402
+
403
+ const markerTags: types.MarkerTag[] = [];
404
+ for (const tag of tags) {
405
+ switch (tag) {
406
+ case types.DiagnosticTag.Unnecessary:
407
+ markerTags.push(types.MarkerTag.Unnecessary);
408
+ break;
409
+ case types.DiagnosticTag.Deprecated:
410
+ markerTags.push(types.MarkerTag.Deprecated);
411
+ break;
412
+ }
413
+ }
414
+ return markerTags;
415
+ }
416
+
417
+ export function fromHover(hover: theia.Hover): model.Hover {
418
+ return <model.Hover>{
419
+ range: fromRange(hover.range),
420
+ contents: fromManyMarkdown(hover.contents)
421
+ };
422
+ }
423
+
424
+ export function fromEvaluatableExpression(evaluatableExpression: theia.EvaluatableExpression): model.EvaluatableExpression {
425
+ return <model.EvaluatableExpression>{
426
+ range: fromRange(evaluatableExpression.range),
427
+ expression: evaluatableExpression.expression
428
+ };
429
+ }
430
+
431
+ export function fromInlineValue(inlineValue: theia.InlineValue): model.InlineValue {
432
+ if (inlineValue instanceof InlineValueText) {
433
+ return <model.InlineValueText>{
434
+ type: 'text',
435
+ range: fromRange(inlineValue.range),
436
+ text: inlineValue.text
437
+ };
438
+ } else if (inlineValue instanceof InlineValueVariableLookup) {
439
+ return <model.InlineValueVariableLookup>{
440
+ type: 'variable',
441
+ range: fromRange(inlineValue.range),
442
+ variableName: inlineValue.variableName,
443
+ caseSensitiveLookup: inlineValue.caseSensitiveLookup
444
+ };
445
+ } else if (inlineValue instanceof InlineValueEvaluatableExpression) {
446
+ return <model.InlineValueEvaluatableExpression>{
447
+ type: 'expression',
448
+ range: fromRange(inlineValue.range),
449
+ expression: inlineValue.expression
450
+ };
451
+ } else {
452
+ throw new Error('Unknown InlineValue type');
453
+ }
454
+ }
455
+
456
+ export function toInlineValueContext(inlineValueContext: model.InlineValueContext): theia.InlineValueContext {
457
+ const ivLocation = inlineValueContext.stoppedLocation;
458
+ return <theia.InlineValueContext>{
459
+ frameId: inlineValueContext.frameId,
460
+ stoppedLocation: new types.Range(ivLocation.startLineNumber, ivLocation.startColumn, ivLocation.endLineNumber, ivLocation.endColumn)
461
+ };
462
+ }
463
+
464
+ // eslint-disable-next-line @typescript-eslint/no-shadow
465
+ export function fromLocation(location: theia.Location): model.Location;
466
+ export function fromLocation(location: theia.Location | undefined): model.Location | undefined;
467
+ export function fromLocation(location: theia.Location | undefined): model.Location | undefined {
468
+ if (!location) {
469
+ return undefined;
470
+ }
471
+ return <model.Location>{
472
+ uri: location.uri,
473
+ range: fromRange(location.range)
474
+ };
475
+ }
476
+
477
+ export function fromTextDocumentShowOptions(options: theia.TextDocumentShowOptions): model.TextDocumentShowOptions {
478
+ if (options.selection) {
479
+ return {
480
+ ...options,
481
+ selection: fromRange(options.selection),
482
+ };
483
+ }
484
+ return options as model.TextDocumentShowOptions;
485
+ }
486
+
487
+ export function fromDefinitionLink(definitionLink: theia.DefinitionLink): model.LocationLink {
488
+ return <model.LocationLink>{
489
+ uri: definitionLink.targetUri,
490
+ range: fromRange(definitionLink.targetRange),
491
+ originSelectionRange: definitionLink.originSelectionRange ? fromRange(definitionLink.originSelectionRange) : undefined,
492
+ targetSelectionRange: definitionLink.targetSelectionRange ? fromRange(definitionLink.targetSelectionRange) : undefined
493
+ };
494
+ }
495
+
496
+ export namespace DocumentLink {
497
+
498
+ export function from(link: theia.DocumentLink): model.DocumentLink {
499
+ return {
500
+ range: fromRange(link.range),
501
+ url: link.target,
502
+ tooltip: link.tooltip
503
+ };
504
+ }
505
+
506
+ export function to(link: model.DocumentLink): theia.DocumentLink {
507
+ let target: URI | undefined = undefined;
508
+ if (link.url) {
509
+ try {
510
+ target = typeof link.url === 'string' ? URI.parse(link.url, true) : URI.revive(link.url);
511
+ } catch (err) {
512
+ // ignore
513
+ }
514
+ }
515
+ return new types.DocumentLink(toRange(link.range), target);
516
+ }
517
+ }
518
+
519
+ export function fromDocumentHighlightKind(kind?: theia.DocumentHighlightKind): model.DocumentHighlightKind | undefined {
520
+ switch (kind) {
521
+ case types.DocumentHighlightKind.Text: return model.DocumentHighlightKind.Text;
522
+ case types.DocumentHighlightKind.Read: return model.DocumentHighlightKind.Read;
523
+ case types.DocumentHighlightKind.Write: return model.DocumentHighlightKind.Write;
524
+ }
525
+ return model.DocumentHighlightKind.Text;
526
+ }
527
+
528
+ export function fromDocumentHighlight(documentHighlight: theia.DocumentHighlight): model.DocumentHighlight {
529
+ return <model.DocumentHighlight>{
530
+ range: fromRange(documentHighlight.range),
531
+ kind: fromDocumentHighlightKind(documentHighlight.kind)
532
+ };
533
+ }
534
+
535
+ export namespace ParameterInformation {
536
+ export function from(info: types.ParameterInformation): model.ParameterInformation {
537
+ return {
538
+ label: info.label,
539
+ documentation: info.documentation ? fromMarkdown(info.documentation) : undefined
540
+ };
541
+ }
542
+ export function to(info: model.ParameterInformation): types.ParameterInformation {
543
+ return {
544
+ label: info.label,
545
+ documentation: MarkdownStringDTO.is(info.documentation) ? toMarkdown(info.documentation) : info.documentation
546
+ };
547
+ }
548
+ }
549
+
550
+ export namespace SignatureInformation {
551
+
552
+ export function from(info: types.SignatureInformation): model.SignatureInformation {
553
+ return {
554
+ label: info.label,
555
+ documentation: info.documentation ? fromMarkdown(info.documentation) : undefined,
556
+ parameters: info.parameters && info.parameters.map(ParameterInformation.from),
557
+ activeParameter: info.activeParameter
558
+ };
559
+ }
560
+
561
+ export function to(info: model.SignatureInformation): types.SignatureInformation {
562
+ return {
563
+ label: info.label,
564
+ documentation: MarkdownStringDTO.is(info.documentation) ? toMarkdown(info.documentation) : info.documentation,
565
+ parameters: info.parameters && info.parameters.map(ParameterInformation.to),
566
+ activeParameter: info.activeParameter
567
+ };
568
+ }
569
+ }
570
+
571
+ export namespace SignatureHelp {
572
+
573
+ export function from(id: number, help: types.SignatureHelp): model.SignatureHelp {
574
+ return {
575
+ id,
576
+ activeSignature: help.activeSignature,
577
+ activeParameter: help.activeParameter,
578
+ signatures: help.signatures && help.signatures.map(SignatureInformation.from)
579
+ };
580
+ }
581
+
582
+ export function to(help: model.SignatureHelp): types.SignatureHelp {
583
+ return {
584
+ activeSignature: help.activeSignature,
585
+ activeParameter: help.activeParameter,
586
+ signatures: help.signatures && help.signatures.map(SignatureInformation.to)
587
+ };
588
+ }
589
+ }
590
+
591
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
592
+ export function fromWorkspaceEdit(value: theia.WorkspaceEdit, documents?: any): WorkspaceEditDto {
593
+ const result: WorkspaceEditDto = {
594
+ edits: []
595
+ };
596
+ for (const entry of (value as types.WorkspaceEdit)._allEntries()) {
597
+ if (entry?._type === types.FileEditType.Text) {
598
+ // text edits
599
+ const doc = documents ? documents.getDocument(entry.uri.toString()) : undefined;
600
+ const workspaceTextEditDto: WorkspaceTextEditDto = {
601
+ resource: entry.uri,
602
+ modelVersionId: doc?.version,
603
+ textEdit: (entry.edit instanceof types.TextEdit) ? fromTextEdit(entry.edit) : fromSnippetTextEdit(entry.edit),
604
+ metadata: entry.metadata
605
+ };
606
+ result.edits.push(workspaceTextEditDto);
607
+ } else if (entry?._type === types.FileEditType.File) {
608
+ // resource edits
609
+ const workspaceFileEditDto: WorkspaceFileEditDto = {
610
+ oldResource: entry.from,
611
+ newResource: entry.to,
612
+ options: entry.options,
613
+ metadata: entry.metadata
614
+ };
615
+ result.edits.push(workspaceFileEditDto);
616
+ } else if (entry?._type === types.FileEditType.Cell) {
617
+ // cell edit
618
+ if (entry.edit) {
619
+ result.edits.push({
620
+ metadata: entry.metadata,
621
+ resource: entry.uri,
622
+ cellEdit: entry.edit,
623
+ });
624
+ }
625
+ } else if (entry?._type === types.FileEditType.CellReplace) {
626
+ // cell replace
627
+ result.edits.push({
628
+ metadata: entry.metadata,
629
+ resource: entry.uri,
630
+ cellEdit: {
631
+ editType: notebooks.CellEditType.Replace,
632
+ index: entry.index,
633
+ count: entry.count,
634
+ cells: entry.cells.map(NotebookCellData.from)
635
+ }
636
+ });
637
+ }
638
+ }
639
+ return result;
640
+ }
641
+
642
+ export namespace SymbolKind {
643
+ const fromMapping: { [kind: number]: model.SymbolKind } = Object.create(null);
644
+ fromMapping[model.SymbolKind.File] = model.SymbolKind.File;
645
+ fromMapping[model.SymbolKind.Module] = model.SymbolKind.Module;
646
+ fromMapping[model.SymbolKind.Namespace] = model.SymbolKind.Namespace;
647
+ fromMapping[model.SymbolKind.Package] = model.SymbolKind.Package;
648
+ fromMapping[model.SymbolKind.Class] = model.SymbolKind.Class;
649
+ fromMapping[model.SymbolKind.Method] = model.SymbolKind.Method;
650
+ fromMapping[model.SymbolKind.Property] = model.SymbolKind.Property;
651
+ fromMapping[model.SymbolKind.Field] = model.SymbolKind.Field;
652
+ fromMapping[model.SymbolKind.Constructor] = model.SymbolKind.Constructor;
653
+ fromMapping[model.SymbolKind.Enum] = model.SymbolKind.Enum;
654
+ fromMapping[model.SymbolKind.Interface] = model.SymbolKind.Interface;
655
+ fromMapping[model.SymbolKind.Function] = model.SymbolKind.Function;
656
+ fromMapping[model.SymbolKind.Variable] = model.SymbolKind.Variable;
657
+ fromMapping[model.SymbolKind.Constant] = model.SymbolKind.Constant;
658
+ fromMapping[model.SymbolKind.String] = model.SymbolKind.String;
659
+ fromMapping[model.SymbolKind.Number] = model.SymbolKind.Number;
660
+ fromMapping[model.SymbolKind.Boolean] = model.SymbolKind.Boolean;
661
+ fromMapping[model.SymbolKind.Array] = model.SymbolKind.Array;
662
+ fromMapping[model.SymbolKind.Object] = model.SymbolKind.Object;
663
+ fromMapping[model.SymbolKind.Key] = model.SymbolKind.Key;
664
+ fromMapping[model.SymbolKind.Null] = model.SymbolKind.Null;
665
+ fromMapping[model.SymbolKind.EnumMember] = model.SymbolKind.EnumMember;
666
+ fromMapping[model.SymbolKind.Struct] = model.SymbolKind.Struct;
667
+ fromMapping[model.SymbolKind.Event] = model.SymbolKind.Event;
668
+ fromMapping[model.SymbolKind.Operator] = model.SymbolKind.Operator;
669
+ fromMapping[model.SymbolKind.TypeParameter] = model.SymbolKind.TypeParameter;
670
+
671
+ export function fromSymbolKind(kind: theia.SymbolKind): model.SymbolKind {
672
+ return fromMapping[kind] || model.SymbolKind.Property;
673
+ }
674
+
675
+ export function toSymbolKind(kind: model.SymbolKind): theia.SymbolKind {
676
+ for (const k in fromMapping) {
677
+ if (fromMapping[k] === kind) {
678
+ return Number(k);
679
+ }
680
+ }
681
+ return model.SymbolKind.Property;
682
+ }
683
+ }
684
+
685
+ export function toCodeActionTriggerKind(triggerKind: model.CodeActionTriggerKind): types.CodeActionTriggerKind {
686
+ switch (triggerKind) {
687
+ case model.CodeActionTriggerKind.Invoke:
688
+ return types.CodeActionTriggerKind.Invoke;
689
+
690
+ case model.CodeActionTriggerKind.Automatic:
691
+ return types.CodeActionTriggerKind.Automatic;
692
+ }
693
+ }
694
+
695
+ export function fromDocumentSymbol(info: theia.DocumentSymbol): model.DocumentSymbol {
696
+ const result: model.DocumentSymbol = {
697
+ name: info.name,
698
+ detail: info.detail,
699
+ range: fromRange(info.range)!,
700
+ tags: info.tags ? info.tags.map(fromSymbolTag) : [],
701
+ selectionRange: fromRange(info.selectionRange)!,
702
+ kind: SymbolKind.fromSymbolKind(info.kind)
703
+ };
704
+ if (info.children) {
705
+ result.children = info.children.map(fromDocumentSymbol);
706
+ }
707
+ return result;
708
+ }
709
+
710
+ export function toDocumentSymbol(symbol: model.DocumentSymbol): theia.DocumentSymbol {
711
+ return {
712
+ name: symbol.name,
713
+ detail: symbol.detail,
714
+ range: toRange(symbol.range)!,
715
+ tags: symbol.tags && symbol.tags.length > 0 ? symbol.tags.map(toSymbolTag) : [],
716
+ selectionRange: toRange(symbol.selectionRange)!,
717
+ children: symbol.children ? symbol.children.map(toDocumentSymbol) : [],
718
+ kind: SymbolKind.toSymbolKind(symbol.kind)
719
+ };
720
+ }
721
+
722
+ export function fromSymbolTag(kind: types.SymbolTag): model.SymbolTag {
723
+ switch (kind) {
724
+ case types.SymbolTag.Deprecated: return model.SymbolTag.Deprecated;
725
+ }
726
+ }
727
+
728
+ export function toSymbolTag(kind: model.SymbolTag): types.SymbolTag {
729
+ switch (kind) {
730
+ case model.SymbolTag.Deprecated: return types.SymbolTag.Deprecated;
731
+ }
732
+ }
733
+
734
+ export function isModelLocation(arg: unknown): arg is model.Location {
735
+ return isObject<model.Location>(arg) &&
736
+ isModelRange(arg.range) &&
737
+ isUriComponents(arg.uri);
738
+ }
739
+
740
+ export function isModelRange(arg: unknown): arg is model.Range {
741
+ return isObject<model.Range>(arg) &&
742
+ typeof arg.startLineNumber === 'number' &&
743
+ typeof arg.startColumn === 'number' &&
744
+ typeof arg.endLineNumber === 'number' &&
745
+ typeof arg.endColumn === 'number';
746
+ }
747
+
748
+ export function isUriComponents(arg: unknown): arg is UriComponents {
749
+ return isObject<UriComponents>(arg) &&
750
+ typeof arg.scheme === 'string' &&
751
+ (arg['$mid'] === 1 || (
752
+ typeof arg.path === 'string' &&
753
+ typeof arg.query === 'string' &&
754
+ typeof arg.fragment === 'string'));
755
+ }
756
+
757
+ export function isModelCallHierarchyItem(arg: unknown): arg is model.CallHierarchyItem {
758
+ return isObject<model.CallHierarchyItem>(arg)
759
+ && isModelRange(arg.range)
760
+ && isModelRange(arg.selectionRange)
761
+ && isUriComponents(arg.uri)
762
+ && !!arg.name;
763
+ }
764
+
765
+ export function isModelCallHierarchyIncomingCall(arg: unknown): arg is model.CallHierarchyIncomingCall {
766
+ return isObject<model.CallHierarchyIncomingCall>(arg) &&
767
+ 'from' in arg &&
768
+ 'fromRanges' in arg &&
769
+ isModelCallHierarchyItem(arg.from);
770
+ }
771
+
772
+ export function isModelCallHierarchyOutgoingCall(arg: unknown): arg is model.CallHierarchyOutgoingCall {
773
+ return isObject<model.CallHierarchyOutgoingCall>(arg) &&
774
+ 'to' in arg &&
775
+ 'fromRanges' in arg &&
776
+ isModelCallHierarchyItem(arg.to);
777
+ }
778
+
779
+ export function toLocation(value: model.Location): types.Location {
780
+ return new types.Location(URI.revive(value.uri), toRange(value.range));
781
+ }
782
+
783
+ export function fromHierarchyItem(item: types.CallHierarchyItem | types.TypeHierarchyItem): model.HierarchyItem {
784
+ return {
785
+ kind: SymbolKind.fromSymbolKind(item.kind),
786
+ name: item.name,
787
+ detail: item.detail,
788
+ uri: item.uri,
789
+ range: fromRange(item.range),
790
+ selectionRange: fromRange(item.selectionRange),
791
+ tags: item.tags,
792
+ _itemId: item._itemId,
793
+ _sessionId: item._sessionId,
794
+ };
795
+ }
796
+
797
+ export function fromCallHierarchyItem(item: types.CallHierarchyItem): model.CallHierarchyItem {
798
+ return <model.CallHierarchyItem>fromHierarchyItem(item);
799
+ }
800
+
801
+ export function toCallHierarchyItem(value: model.CallHierarchyItem): types.CallHierarchyItem {
802
+ const item = new types.CallHierarchyItem(
803
+ SymbolKind.toSymbolKind(value.kind),
804
+ value.name,
805
+ value.detail ? value.detail : '',
806
+ URI.revive(value.uri),
807
+ toRange(value.range),
808
+ toRange(value.selectionRange),
809
+ );
810
+ item.tags = value.tags;
811
+ item._itemId = value._itemId;
812
+ item._sessionId = value._sessionId;
813
+
814
+ return item;
815
+ }
816
+
817
+ export function toCallHierarchyIncomingCall(value: model.CallHierarchyIncomingCall): types.CallHierarchyIncomingCall {
818
+ return new types.CallHierarchyIncomingCall(
819
+ toCallHierarchyItem(value.from),
820
+ value.fromRanges && value.fromRanges.map(toRange));
821
+ }
822
+
823
+ export function toCallHierarchyOutgoingCall(value: model.CallHierarchyOutgoingCall): types.CallHierarchyOutgoingCall {
824
+ return new types.CallHierarchyOutgoingCall(
825
+ toCallHierarchyItem(value.to),
826
+ value.fromRanges && value.fromRanges.map(toRange));
827
+ }
828
+
829
+ export function isModelTypeHierarchyItem(arg: unknown): arg is model.TypeHierarchyItem {
830
+ return isObject<model.TypeHierarchyItem>(arg)
831
+ && isModelRange(arg.range)
832
+ && isModelRange(arg.selectionRange)
833
+ && isUriComponents(arg.uri)
834
+ && !!arg.name;
835
+ }
836
+
837
+ export function fromTypeHierarchyItem(item: types.TypeHierarchyItem): model.TypeHierarchyItem {
838
+ return <model.TypeHierarchyItem>fromHierarchyItem(item);
839
+ }
840
+
841
+ export function toTypeHierarchyItem(value: model.TypeHierarchyItem): types.TypeHierarchyItem {
842
+ const item = new types.TypeHierarchyItem(
843
+ SymbolKind.toSymbolKind(value.kind),
844
+ value.name,
845
+ value.detail ? value.detail : '',
846
+ URI.revive(value.uri),
847
+ toRange(value.selectionRange),
848
+ toRange(value.range),
849
+ );
850
+ item.tags = value.tags;
851
+ item._itemId = value._itemId;
852
+ item._sessionId = value._sessionId;
853
+
854
+ return item;
855
+ }
856
+
857
+ export function toWorkspaceFolder(folder: model.WorkspaceFolder): theia.WorkspaceFolder {
858
+ return {
859
+ uri: URI.revive(folder.uri),
860
+ name: folder.name,
861
+ index: folder.index
862
+ };
863
+ }
864
+
865
+ export function fromTask(task: theia.Task): TaskDto | undefined {
866
+ if (!task) {
867
+ return undefined;
868
+ }
869
+
870
+ const taskDto = {} as TaskDto;
871
+ taskDto.label = task.name;
872
+ taskDto.source = task.source;
873
+
874
+ taskDto.runOptions = { reevaluateOnRerun: task.runOptions.reevaluateOnRerun };
875
+
876
+ if ((task as types.Task).hasProblemMatchers) {
877
+ taskDto.problemMatcher = task.problemMatchers;
878
+ }
879
+ if ('detail' in task) {
880
+ taskDto.detail = task.detail;
881
+ }
882
+ if (typeof task.scope === 'number') {
883
+ taskDto.scope = task.scope;
884
+ } else if (task.scope !== undefined) {
885
+ taskDto.scope = task.scope.uri.toString();
886
+ } else {
887
+ taskDto.scope = types.TaskScope.Workspace;
888
+ }
889
+
890
+ if (task.presentationOptions) {
891
+ taskDto.presentation = task.presentationOptions;
892
+ }
893
+
894
+ if (task.group) {
895
+ taskDto.group = {
896
+ kind: <rpc.TaskGroupKind>task.group.id,
897
+ isDefault: !!task.group.isDefault
898
+ };
899
+ }
900
+
901
+ const taskDefinition = task.definition;
902
+ if (!taskDefinition) {
903
+ return taskDto;
904
+ }
905
+
906
+ taskDto.type = taskDefinition.type;
907
+ const { type, ...properties } = taskDefinition;
908
+ for (const key in properties) {
909
+ if (properties.hasOwnProperty(key)) {
910
+ taskDto[key] = properties[key];
911
+ }
912
+ }
913
+
914
+ const execution = task.execution;
915
+ if (!execution) {
916
+ return taskDto;
917
+ }
918
+
919
+ if (types.ShellExecution.is(execution)) {
920
+ return fromShellExecution(execution, taskDto);
921
+ }
922
+
923
+ if (types.ProcessExecution.is(execution)) {
924
+ return fromProcessExecution(execution, taskDto);
925
+ }
926
+
927
+ if (types.CustomExecution.is(execution)) {
928
+ return fromCustomExecution(execution, taskDto);
929
+ }
930
+
931
+ return taskDto;
932
+ }
933
+
934
+ export function toTask(taskDto: TaskDto): theia.Task {
935
+ if (!taskDto) {
936
+ throw new Error('Task should be provided for converting');
937
+ }
938
+
939
+ const { type, taskType, label, source, scope, problemMatcher, detail, command, args, options, group, presentation, runOptions, ...properties } = taskDto;
940
+ const result = {} as theia.Task;
941
+ result.name = label;
942
+ result.source = source;
943
+ result.runOptions = runOptions ?? {};
944
+ if (detail) {
945
+ result.detail = detail;
946
+ }
947
+ if (typeof scope === 'string') {
948
+ const uri = URI.parse(scope);
949
+ result.scope = {
950
+ uri,
951
+ name: uri.toString(),
952
+ index: 0
953
+ };
954
+ } else {
955
+ result.scope = scope;
956
+ }
957
+
958
+ const taskDefinition: theia.TaskDefinition = {
959
+ type: type
960
+ };
961
+
962
+ result.definition = taskDefinition;
963
+
964
+ if (taskType === 'process') {
965
+ result.execution = getProcessExecution(taskDto);
966
+ }
967
+
968
+ const execution = { command, args, options };
969
+ if (taskType === 'shell' || types.ShellExecution.is(execution)) {
970
+ result.execution = getShellExecution(taskDto);
971
+ }
972
+
973
+ if (taskType === 'customExecution' || types.CustomExecution.is(execution)) {
974
+ result.execution = getCustomExecution(taskDto);
975
+ // if taskType is customExecution, we need to put all the information into taskDefinition,
976
+ // because some parameters may be in taskDefinition.
977
+ taskDefinition.label = label;
978
+ taskDefinition.command = command;
979
+ taskDefinition.args = args;
980
+ taskDefinition.options = options;
981
+ }
982
+
983
+ if (group) {
984
+ result.group = new types.TaskGroup(
985
+ group.kind,
986
+ group.kind,
987
+ group.isDefault
988
+ );
989
+ }
990
+
991
+ if (presentation) {
992
+ result.presentationOptions = presentation;
993
+ }
994
+
995
+ if (!properties) {
996
+ return result;
997
+ }
998
+
999
+ for (const key in properties) {
1000
+ if (properties.hasOwnProperty(key)) {
1001
+ taskDefinition[key] = properties[key];
1002
+ }
1003
+ }
1004
+
1005
+ return result;
1006
+ }
1007
+
1008
+ export function fromProcessExecution(execution: theia.ProcessExecution, taskDto: TaskDto): TaskDto {
1009
+ taskDto.taskType = 'process';
1010
+ taskDto.command = execution.process;
1011
+ taskDto.args = execution.args;
1012
+
1013
+ const options = execution.options;
1014
+ if (options) {
1015
+ taskDto.options = options;
1016
+ }
1017
+ return taskDto;
1018
+ }
1019
+
1020
+ export function fromShellExecution(execution: theia.ShellExecution, taskDto: TaskDto): TaskDto {
1021
+ taskDto.taskType = 'shell';
1022
+ const options = execution.options;
1023
+ if (options) {
1024
+ taskDto.options = getShellExecutionOptions(options);
1025
+ }
1026
+
1027
+ const commandLine = execution.commandLine;
1028
+ if (commandLine) {
1029
+ taskDto.command = commandLine;
1030
+ return taskDto;
1031
+ }
1032
+
1033
+ if (execution.command) {
1034
+ taskDto.command = getCommand(execution.command);
1035
+ taskDto.args = getShellArgs(execution.args);
1036
+ return taskDto;
1037
+ } else {
1038
+ throw new Error('Command is undefined');
1039
+ }
1040
+ }
1041
+
1042
+ export function fromCustomExecution(execution: types.CustomExecution, taskDto: TaskDto): TaskDto {
1043
+ taskDto.taskType = 'customExecution';
1044
+ const callback = execution.callback;
1045
+ if (callback) {
1046
+ taskDto.callback = callback;
1047
+ return taskDto;
1048
+ } else {
1049
+ throw new Error('Converting CustomExecution callback is not implemented');
1050
+ }
1051
+ }
1052
+
1053
+ export function getProcessExecution(taskDto: TaskDto): theia.ProcessExecution {
1054
+ return new types.ProcessExecution(
1055
+ taskDto.command,
1056
+ taskDto.args || [],
1057
+ taskDto.options || {});
1058
+ }
1059
+
1060
+ export function getShellExecution(taskDto: TaskDto): theia.ShellExecution {
1061
+ if (taskDto.command && Array.isArray(taskDto.args) && taskDto.args.length !== 0) {
1062
+ return new types.ShellExecution(
1063
+ taskDto.command,
1064
+ taskDto.args,
1065
+ taskDto.options || {});
1066
+ }
1067
+ return new types.ShellExecution(
1068
+ taskDto.command || taskDto.commandLine,
1069
+ taskDto.options || {});
1070
+ }
1071
+
1072
+ export function getCustomExecution(taskDto: TaskDto): theia.CustomExecution {
1073
+ return new types.CustomExecution(taskDto.callback);
1074
+ }
1075
+
1076
+ export function getShellArgs(args: undefined | (string | theia.ShellQuotedString)[]): string[] {
1077
+ if (!args || args.length === 0) {
1078
+ return [];
1079
+ }
1080
+
1081
+ const element = args[0];
1082
+ if (typeof element === 'string') {
1083
+ return args as string[];
1084
+ }
1085
+
1086
+ const result: string[] = [];
1087
+ const shellQuotedArgs = args as theia.ShellQuotedString[];
1088
+
1089
+ shellQuotedArgs.forEach(arg => {
1090
+ result.push(arg.value);
1091
+ });
1092
+
1093
+ return result;
1094
+ }
1095
+
1096
+ function getCommand(command: string | theia.ShellQuotedString): string {
1097
+ return typeof command === 'string' ? command : command.value;
1098
+ }
1099
+
1100
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1101
+ export function getShellExecutionOptions(options: theia.ShellExecutionOptions): { [key: string]: any } {
1102
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1103
+ const result = {} as { [key: string]: any };
1104
+
1105
+ const env = options.env;
1106
+ if (env) {
1107
+ result['env'] = env;
1108
+ }
1109
+
1110
+ const executable = options.executable;
1111
+ if (executable) {
1112
+ result['executable'] = executable;
1113
+ }
1114
+
1115
+ const shellQuoting = options.shellQuoting;
1116
+ if (shellQuoting) {
1117
+ result['shellQuoting'] = shellQuoting;
1118
+ }
1119
+
1120
+ const shellArgs = options.shellArgs;
1121
+ if (shellArgs) {
1122
+ result['shellArgs'] = shellArgs;
1123
+ }
1124
+
1125
+ const cwd = options.cwd;
1126
+ if (cwd) {
1127
+ Object.assign(result, { cwd });
1128
+ }
1129
+
1130
+ return result;
1131
+ }
1132
+
1133
+ export function fromSymbolInformation(symbolInformation: theia.SymbolInformation): lstypes.SymbolInformation | undefined {
1134
+ if (!symbolInformation) {
1135
+ return undefined;
1136
+ }
1137
+
1138
+ if (symbolInformation.location && symbolInformation.location.range) {
1139
+ const p1 = lstypes.Position.create(symbolInformation.location.range.start.line, symbolInformation.location.range.start.character);
1140
+ const p2 = lstypes.Position.create(symbolInformation.location.range.end.line, symbolInformation.location.range.end.character);
1141
+ return lstypes.SymbolInformation.create(symbolInformation.name, symbolInformation.kind++ as lstypes.SymbolKind, lstypes.Range.create(p1, p2),
1142
+ symbolInformation.location.uri.toString(), symbolInformation.containerName);
1143
+ }
1144
+
1145
+ return {
1146
+ name: symbolInformation.name,
1147
+ containerName: symbolInformation.containerName,
1148
+ kind: symbolInformation.kind++ as lstypes.SymbolKind,
1149
+ location: {
1150
+ uri: symbolInformation.location.uri.toString(),
1151
+ range: symbolInformation.location.range,
1152
+ }
1153
+ };
1154
+ }
1155
+
1156
+ export function toSymbolInformation(symbolInformation: lstypes.SymbolInformation): theia.SymbolInformation | undefined {
1157
+ if (!symbolInformation) {
1158
+ return undefined;
1159
+ }
1160
+
1161
+ return <theia.SymbolInformation>{
1162
+ name: symbolInformation.name,
1163
+ containerName: symbolInformation.containerName,
1164
+ kind: symbolInformation.kind,
1165
+ location: {
1166
+ uri: URI.parse(symbolInformation.location.uri),
1167
+ range: symbolInformation.location.range
1168
+ }
1169
+ };
1170
+ }
1171
+
1172
+ export function fromSelectionRange(selectionRange: theia.SelectionRange): model.SelectionRange {
1173
+ return { range: fromRange(selectionRange.range) };
1174
+ }
1175
+
1176
+ export function fromFoldingRange(foldingRange: theia.FoldingRange): model.FoldingRange {
1177
+ const range: model.FoldingRange = {
1178
+ start: foldingRange.start + 1,
1179
+ end: foldingRange.end + 1
1180
+ };
1181
+ if (foldingRange.kind) {
1182
+ range.kind = fromFoldingRangeKind(foldingRange.kind);
1183
+ }
1184
+ return range;
1185
+ }
1186
+
1187
+ export function fromFoldingRangeKind(kind: theia.FoldingRangeKind | undefined): model.FoldingRangeKind | undefined {
1188
+ if (kind) {
1189
+ switch (kind) {
1190
+ case types.FoldingRangeKind.Comment:
1191
+ return model.FoldingRangeKind.Comment;
1192
+ case types.FoldingRangeKind.Imports:
1193
+ return model.FoldingRangeKind.Imports;
1194
+ case types.FoldingRangeKind.Region:
1195
+ return model.FoldingRangeKind.Region;
1196
+ }
1197
+ }
1198
+ return undefined;
1199
+ }
1200
+
1201
+ export function fromColor(color: types.Color): [number, number, number, number] {
1202
+ return [color.red, color.green, color.blue, color.alpha];
1203
+ }
1204
+
1205
+ export function toColor(color: [number, number, number, number]): types.Color {
1206
+ return new types.Color(color[0], color[1], color[2], color[3]);
1207
+ }
1208
+
1209
+ export function fromColorPresentation(colorPresentation: theia.ColorPresentation): model.ColorPresentation {
1210
+ return {
1211
+ label: colorPresentation.label,
1212
+ textEdit: colorPresentation.textEdit ? fromTextEdit(colorPresentation.textEdit) : undefined,
1213
+ additionalTextEdits: colorPresentation.additionalTextEdits ? colorPresentation.additionalTextEdits.map(value => fromTextEdit(value)) : undefined
1214
+ };
1215
+ }
1216
+
1217
+ export function convertIconPath(iconPath: types.URI | { light: types.URI; dark: types.URI } | theia.ThemeIcon | undefined):
1218
+ UriComponents | { light: UriComponents; dark: UriComponents } | ThemeIcon | undefined {
1219
+ if (!iconPath) {
1220
+ return undefined;
1221
+ }
1222
+ if (iconPath instanceof types.URI) {
1223
+ return iconPath.toJSON();
1224
+ } else if ('dark' in iconPath) {
1225
+ return {
1226
+ dark: iconPath.dark.toJSON(),
1227
+ light: iconPath.light?.toJSON()
1228
+ };
1229
+ } else if (ThemeIcon.isThemeIcon(iconPath)) {
1230
+ return {
1231
+ id: iconPath.id,
1232
+ color: iconPath.color ? { id: iconPath.color.id } : undefined
1233
+ };
1234
+ } else {
1235
+ return undefined;
1236
+ }
1237
+ }
1238
+
1239
+ export function convertQuickInputButton(button: theia.QuickInputButton, index: number): rpc.TransferQuickInputButton {
1240
+ const iconPath = convertIconPath(button.iconPath);
1241
+ if (!iconPath) {
1242
+ throw new Error(`Could not convert icon path: '${button.iconPath}'`);
1243
+ }
1244
+ return {
1245
+ handle: index,
1246
+ iconPath: iconPath,
1247
+ tooltip: button.tooltip
1248
+ };
1249
+ }
1250
+
1251
+ export function convertToTransferQuickPickItems(items: (theia.QuickPickItem | string)[]): rpc.TransferQuickPickItem[] {
1252
+ return items.map((item, index) => {
1253
+ if (typeof item === 'string') {
1254
+ return { kind: 'item', label: item, handle: index };
1255
+ } else if (item.kind === QuickPickItemKind.Separator) {
1256
+ return { kind: 'separator', label: item.label, handle: index };
1257
+ } else {
1258
+ const { label, description, iconPath, detail, picked, alwaysShow, buttons } = item;
1259
+ return {
1260
+ kind: 'item',
1261
+ label,
1262
+ description,
1263
+ iconPath: convertIconPath(iconPath),
1264
+ detail,
1265
+ picked,
1266
+ alwaysShow,
1267
+ buttons: buttons ? buttons.map(convertQuickInputButton) : undefined,
1268
+ handle: index,
1269
+ };
1270
+ }
1271
+ });
1272
+ }
1273
+
1274
+ export namespace DecorationRenderOptions {
1275
+ export function from(options: theia.DecorationRenderOptions): rpc.DecorationRenderOptions {
1276
+ return {
1277
+ isWholeLine: options.isWholeLine,
1278
+ rangeBehavior: options.rangeBehavior ? DecorationRangeBehavior.from(options.rangeBehavior) : undefined,
1279
+ overviewRulerLane: options.overviewRulerLane,
1280
+ light: options.light ? ThemableDecorationRenderOptions.from(options.light) : undefined,
1281
+ dark: options.dark ? ThemableDecorationRenderOptions.from(options.dark) : undefined,
1282
+
1283
+ backgroundColor: <string | types.ThemeColor>options.backgroundColor,
1284
+ outline: options.outline,
1285
+ outlineColor: <string | types.ThemeColor>options.outlineColor,
1286
+ outlineStyle: options.outlineStyle,
1287
+ outlineWidth: options.outlineWidth,
1288
+ border: options.border,
1289
+ borderColor: <string | types.ThemeColor>options.borderColor,
1290
+ borderRadius: options.borderRadius,
1291
+ borderSpacing: options.borderSpacing,
1292
+ borderStyle: options.borderStyle,
1293
+ borderWidth: options.borderWidth,
1294
+ fontStyle: options.fontStyle,
1295
+ fontWeight: options.fontWeight,
1296
+ textDecoration: options.textDecoration,
1297
+ cursor: options.cursor,
1298
+ color: <string | types.ThemeColor>options.color,
1299
+ opacity: options.opacity,
1300
+ letterSpacing: options.letterSpacing,
1301
+ gutterIconPath: options.gutterIconPath ? pathOrURIToURI(options.gutterIconPath) : undefined,
1302
+ gutterIconSize: options.gutterIconSize,
1303
+ overviewRulerColor: <string | types.ThemeColor>options.overviewRulerColor,
1304
+ before: options.before ? ThemableDecorationAttachmentRenderOptions.from(options.before) : undefined,
1305
+ after: options.after ? ThemableDecorationAttachmentRenderOptions.from(options.after) : undefined,
1306
+ };
1307
+ }
1308
+ }
1309
+
1310
+ export namespace DecorationRangeBehavior {
1311
+ export function from(value: types.DecorationRangeBehavior): rpc.TrackedRangeStickiness {
1312
+ if (typeof value === 'undefined') {
1313
+ return value;
1314
+ }
1315
+ switch (value) {
1316
+ case types.DecorationRangeBehavior.OpenOpen:
1317
+ return rpc.TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges;
1318
+ case types.DecorationRangeBehavior.ClosedClosed:
1319
+ return rpc.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges;
1320
+ case types.DecorationRangeBehavior.OpenClosed:
1321
+ return rpc.TrackedRangeStickiness.GrowsOnlyWhenTypingBefore;
1322
+ case types.DecorationRangeBehavior.ClosedOpen:
1323
+ return rpc.TrackedRangeStickiness.GrowsOnlyWhenTypingAfter;
1324
+ }
1325
+ }
1326
+ }
1327
+
1328
+ export namespace ThemableDecorationRenderOptions {
1329
+ export function from(options: theia.ThemableDecorationRenderOptions): rpc.ThemeDecorationRenderOptions {
1330
+ if (typeof options === 'undefined') {
1331
+ return options;
1332
+ }
1333
+ return {
1334
+ backgroundColor: <string | types.ThemeColor>options.backgroundColor,
1335
+ outline: options.outline,
1336
+ outlineColor: <string | types.ThemeColor>options.outlineColor,
1337
+ outlineStyle: options.outlineStyle,
1338
+ outlineWidth: options.outlineWidth,
1339
+ border: options.border,
1340
+ borderColor: <string | types.ThemeColor>options.borderColor,
1341
+ borderRadius: options.borderRadius,
1342
+ borderSpacing: options.borderSpacing,
1343
+ borderStyle: options.borderStyle,
1344
+ borderWidth: options.borderWidth,
1345
+ fontStyle: options.fontStyle,
1346
+ fontWeight: options.fontWeight,
1347
+ textDecoration: options.textDecoration,
1348
+ cursor: options.cursor,
1349
+ color: <string | types.ThemeColor>options.color,
1350
+ opacity: options.opacity,
1351
+ letterSpacing: options.letterSpacing,
1352
+ gutterIconPath: options.gutterIconPath ? pathOrURIToURI(options.gutterIconPath) : undefined,
1353
+ gutterIconSize: options.gutterIconSize,
1354
+ overviewRulerColor: <string | types.ThemeColor>options.overviewRulerColor,
1355
+ before: options.before ? ThemableDecorationAttachmentRenderOptions.from(options.before) : undefined,
1356
+ after: options.after ? ThemableDecorationAttachmentRenderOptions.from(options.after) : undefined,
1357
+ };
1358
+ }
1359
+ }
1360
+
1361
+ export namespace ThemableDecorationAttachmentRenderOptions {
1362
+ export function from(options: theia.ThemableDecorationAttachmentRenderOptions): rpc.ContentDecorationRenderOptions {
1363
+ if (typeof options === 'undefined') {
1364
+ return options;
1365
+ }
1366
+ return {
1367
+ contentText: options.contentText,
1368
+ contentIconPath: options.contentIconPath ? pathOrURIToURI(options.contentIconPath) : undefined,
1369
+ border: options.border,
1370
+ borderColor: <string | types.ThemeColor>options.borderColor,
1371
+ fontStyle: options.fontStyle,
1372
+ fontWeight: options.fontWeight,
1373
+ textDecoration: options.textDecoration,
1374
+ color: <string | types.ThemeColor>options.color,
1375
+ backgroundColor: <string | types.ThemeColor>options.backgroundColor,
1376
+ margin: options.margin,
1377
+ width: options.width,
1378
+ height: options.height,
1379
+ };
1380
+ }
1381
+ }
1382
+
1383
+ export namespace ViewColumn {
1384
+ export function from(column?: theia.ViewColumn): rpc.EditorGroupColumn {
1385
+ if (typeof column === 'number' && column >= types.ViewColumn.One) {
1386
+ return column - 1; // adjust zero index (ViewColumn.ONE => 0)
1387
+ }
1388
+
1389
+ if (column === types.ViewColumn.Beside) {
1390
+ return SIDE_GROUP;
1391
+ }
1392
+
1393
+ return ACTIVE_GROUP; // default is always the active group
1394
+ }
1395
+
1396
+ export function to(position: rpc.EditorGroupColumn): theia.ViewColumn {
1397
+ if (typeof position === 'number' && position >= 0) {
1398
+ return position + 1; // adjust to index (ViewColumn.ONE => 1)
1399
+ }
1400
+
1401
+ throw new Error('invalid \'EditorGroupColumn\'');
1402
+ }
1403
+ }
1404
+
1405
+ export function pathOrURIToURI(value: string | URI): URI {
1406
+ if (typeof value === 'undefined') {
1407
+ return value;
1408
+ }
1409
+ if (typeof value === 'string') {
1410
+ return URI.file(value);
1411
+ } else {
1412
+ return value;
1413
+ }
1414
+ }
1415
+
1416
+ export function pluginToPluginInfo(plugin: Plugin): rpc.PluginInfo {
1417
+ return {
1418
+ id: plugin.model.id,
1419
+ name: plugin.model.name,
1420
+ displayName: plugin.model.displayName
1421
+ };
1422
+ }
1423
+
1424
+ export namespace InlayHintKind {
1425
+ export function from(kind: theia.InlayHintKind): model.InlayHintKind {
1426
+ return kind;
1427
+ }
1428
+ export function to(kind: model.InlayHintKind): theia.InlayHintKind {
1429
+ return kind;
1430
+ }
1431
+ }
1432
+
1433
+ export namespace DataTransferItem {
1434
+ export function to(mime: string, item: model.DataTransferItemDTO, resolveFileData: (itemId: string) => Promise<Uint8Array>): theia.DataTransferItem {
1435
+ const file = item.fileData;
1436
+ if (file) {
1437
+ return new class extends types.DataTransferItem {
1438
+ override asFile(): theia.DataTransferFile {
1439
+ return {
1440
+ name: file.name,
1441
+ uri: URI.revive(file.uri),
1442
+ data: () => resolveFileData(file.id),
1443
+ };
1444
+ }
1445
+ }('');
1446
+ }
1447
+
1448
+ if (mime === 'text/uri-list' && item.uriListData) {
1449
+ return new types.DataTransferItem(reviveUriList(item.uriListData));
1450
+ }
1451
+
1452
+ return new types.DataTransferItem(item.asString);
1453
+ }
1454
+
1455
+ function reviveUriList(parts: ReadonlyArray<string | UriComponents>): string {
1456
+ return parts.map(part => typeof part === 'string' ? part : URI.revive(part).toString()).join('\r\n');
1457
+ }
1458
+ }
1459
+
1460
+ export namespace DataTransfer {
1461
+ export function toDataTransfer(value: model.DataTransferDTO, resolveFileData: (itemId: string) => Promise<Uint8Array>): theia.DataTransfer {
1462
+ const dataTransfer = new types.DataTransfer();
1463
+ for (const [mimeType, item] of value.items) {
1464
+ dataTransfer.set(mimeType, DataTransferItem.to(mimeType, item, resolveFileData));
1465
+ }
1466
+ return dataTransfer;
1467
+ }
1468
+ }
1469
+
1470
+ export namespace NotebookDocumentContentOptions {
1471
+ export function from(options: theia.NotebookDocumentContentOptions | undefined): notebooks.TransientOptions {
1472
+ return {
1473
+ transientOutputs: options?.transientOutputs ?? false,
1474
+ transientCellMetadata: options?.transientCellMetadata ?? {},
1475
+ transientDocumentMetadata: options?.transientDocumentMetadata ?? {},
1476
+ };
1477
+ }
1478
+ }
1479
+
1480
+ export namespace NotebookStatusBarItem {
1481
+ export function from(item: theia.NotebookCellStatusBarItem, commandsConverter: CommandsConverter, disposables: DisposableCollection): notebooks.NotebookCellStatusBarItem {
1482
+ const command = typeof item.command === 'string' ? { title: '', command: item.command } : item.command;
1483
+ return {
1484
+ alignment: item.alignment === types.NotebookCellStatusBarAlignment.Left ? notebooks.CellStatusbarAlignment.Left : notebooks.CellStatusbarAlignment.Right,
1485
+ command: commandsConverter.toSafeCommand(command, disposables),
1486
+ text: item.text,
1487
+ tooltip: item.tooltip,
1488
+ priority: item.priority
1489
+ };
1490
+ }
1491
+ }
1492
+
1493
+ export namespace NotebookData {
1494
+
1495
+ export function from(data: theia.NotebookData): rpc.NotebookDataDto {
1496
+ const res: rpc.NotebookDataDto = {
1497
+ metadata: data.metadata ?? Object.create(null),
1498
+ cells: [],
1499
+ };
1500
+ for (const cell of data.cells) {
1501
+ // types.NotebookCellData.validate(cell);
1502
+ res.cells.push(NotebookCellData.from(cell));
1503
+ }
1504
+ return res;
1505
+ }
1506
+
1507
+ export function to(data: rpc.NotebookDataDto): theia.NotebookData {
1508
+ const res = new types.NotebookData(
1509
+ data.cells.map(NotebookCellData.to),
1510
+ );
1511
+ if (!isEmptyObject(data.metadata)) {
1512
+ res.metadata = data.metadata;
1513
+ }
1514
+ return res;
1515
+ }
1516
+ }
1517
+
1518
+ export namespace NotebookCellData {
1519
+
1520
+ export function from(data: theia.NotebookCellData): rpc.NotebookCellDataDto {
1521
+ return {
1522
+ cellKind: NotebookCellKind.from(data.kind),
1523
+ language: data.languageId,
1524
+ source: data.value,
1525
+ // metadata: data.metadata,
1526
+ // internalMetadata: NotebookCellExecutionSummary.from(data.executionSummary ?? {}),
1527
+ outputs: data.outputs ? data.outputs.map(NotebookCellOutputConverter.from) : []
1528
+ };
1529
+ }
1530
+
1531
+ export function to(data: rpc.NotebookCellDataDto): theia.NotebookCellData {
1532
+ return new types.NotebookCellData(
1533
+ NotebookCellKind.to(data.cellKind),
1534
+ data.source,
1535
+ data.language,
1536
+ data.outputs ? data.outputs.map(NotebookCellOutput.to) : undefined,
1537
+ data.metadata,
1538
+ data.internalMetadata ? NotebookCellExecutionSummary.to(data.internalMetadata) : undefined
1539
+ );
1540
+ }
1541
+ }
1542
+
1543
+ export namespace NotebookCellKind {
1544
+ export function from(data: theia.NotebookCellKind): notebooks.CellKind {
1545
+ switch (data) {
1546
+ case types.NotebookCellKind.Markup:
1547
+ return notebooks.CellKind.Markup;
1548
+ case types.NotebookCellKind.Code:
1549
+ default:
1550
+ return notebooks.CellKind.Code;
1551
+ }
1552
+ }
1553
+
1554
+ export function to(data: notebooks.CellKind): theia.NotebookCellKind {
1555
+ switch (data) {
1556
+ case notebooks.CellKind.Markup:
1557
+ return types.NotebookCellKind.Markup;
1558
+ case notebooks.CellKind.Code:
1559
+ default:
1560
+ return types.NotebookCellKind.Code;
1561
+ }
1562
+ }
1563
+ }
1564
+
1565
+ export namespace NotebookCellOutput {
1566
+ export function from(output: theia.NotebookCellOutput & { outputId: string }): rpc.NotebookOutputDto {
1567
+ return {
1568
+ outputId: output.outputId,
1569
+ items: output.items.map(NotebookCellOutputItem.from),
1570
+ metadata: output.metadata
1571
+ };
1572
+ }
1573
+
1574
+ export function to(output: rpc.NotebookOutputDto): theia.NotebookCellOutput {
1575
+ const items = output.items.map(NotebookCellOutputItem.to);
1576
+ return new types.NotebookCellOutput(items, output.outputId, output.metadata);
1577
+ }
1578
+ }
1579
+
1580
+ export namespace NotebookCellOutputItem {
1581
+ export function from(item: types.NotebookCellOutputItem): rpc.NotebookOutputItemDto {
1582
+ return {
1583
+ mime: item.mime,
1584
+ valueBytes: BinaryBuffer.wrap(item.data),
1585
+ };
1586
+ }
1587
+
1588
+ export function to(item: rpc.NotebookOutputItemDto): types.NotebookCellOutputItem {
1589
+ return new types.NotebookCellOutputItem(item.valueBytes.buffer, item.mime);
1590
+ }
1591
+ }
1592
+
1593
+ export namespace NotebookCellOutputConverter {
1594
+ export function from(output: types.NotebookCellOutput): rpc.NotebookOutputDto {
1595
+ return {
1596
+ outputId: output.outputId,
1597
+ items: output.items.map(NotebookCellOutputItem.from),
1598
+ metadata: output.metadata
1599
+ };
1600
+ }
1601
+
1602
+ export function to(output: rpc.NotebookOutputDto): types.NotebookCellOutput {
1603
+ const items = output.items.map(NotebookCellOutputItem.to);
1604
+ return new types.NotebookCellOutput(items, output.outputId, output.metadata);
1605
+ }
1606
+
1607
+ export function ensureUniqueMimeTypes(items: types.NotebookCellOutputItem[], warn: boolean = false): types.NotebookCellOutputItem[] {
1608
+ const seen = new Set<string>();
1609
+ const removeIdx = new Set<number>();
1610
+ for (let i = 0; i < items.length; i++) {
1611
+ const item = items[i];
1612
+ // We can have multiple text stream mime types in the same output.
1613
+ if (!seen.has(item.mime) || isTextStreamMime(item.mime)) {
1614
+ seen.add(item.mime);
1615
+ continue;
1616
+ }
1617
+ // duplicated mime types... first has won
1618
+ removeIdx.add(i);
1619
+ if (warn) {
1620
+ console.warn(`DUPLICATED mime type '${item.mime}' will be dropped`);
1621
+ }
1622
+ }
1623
+ if (removeIdx.size === 0) {
1624
+ return items;
1625
+ }
1626
+ return items.filter((_, index) => !removeIdx.has(index));
1627
+ }
1628
+ }
1629
+
1630
+ export namespace NotebookCellExecutionSummary {
1631
+ export function to(data: notebooks.NotebookCellInternalMetadata): theia.NotebookCellExecutionSummary {
1632
+ return {
1633
+ timing: typeof data.runStartTime === 'number' && typeof data.runEndTime === 'number' ? { startTime: data.runStartTime, endTime: data.runEndTime } : undefined,
1634
+ executionOrder: data.executionOrder,
1635
+ success: data.lastRunSuccess
1636
+ };
1637
+ }
1638
+
1639
+ export function from(data: theia.NotebookCellExecutionSummary): Partial<notebooks.NotebookCellInternalMetadata> {
1640
+ return {
1641
+ lastRunSuccess: data.success,
1642
+ runStartTime: data.timing?.startTime,
1643
+ runEndTime: data.timing?.endTime,
1644
+ executionOrder: data.executionOrder
1645
+ };
1646
+ }
1647
+ }
1648
+
1649
+ export namespace NotebookRange {
1650
+
1651
+ export function from(range: theia.NotebookRange): CellRange {
1652
+ return { start: range.start, end: range.end };
1653
+ }
1654
+
1655
+ export function to(range: CellRange): types.NotebookRange {
1656
+ return new types.NotebookRange(range.start, range.end);
1657
+ }
1658
+ }
1659
+
1660
+ export namespace NotebookKernelSourceAction {
1661
+ export function from(item: theia.NotebookKernelSourceAction, commandsConverter: CommandsConverter, disposables: DisposableCollection): rpc.NotebookKernelSourceActionDto {
1662
+ const command = typeof item.command === 'string' ? { title: '', command: item.command } : item.command;
1663
+
1664
+ return {
1665
+ command: commandsConverter.toSafeCommand(command, disposables),
1666
+ label: item.label,
1667
+ description: item.description,
1668
+ detail: item.detail,
1669
+ documentation: item.documentation
1670
+ };
1671
+ }
1672
+ }
1673
+
1674
+ export namespace TestMessage {
1675
+ export function from(message: theia.TestMessage | readonly theia.TestMessage[]): TestMessageDTO[] {
1676
+ if (isReadonlyArray(message)) {
1677
+ return message.map(msg => TestMessage.from(msg)[0]);
1678
+ }
1679
+ return [{
1680
+ location: fromLocation(message.location),
1681
+ message: fromMarkdown(message.message)!,
1682
+ expected: message.expectedOutput,
1683
+ actual: message.actualOutput,
1684
+ contextValue: message.contextValue
1685
+ }];
1686
+ }
1687
+ }
1688
+
1689
+ export namespace TestItem {
1690
+ export function from(test: theia.TestItem): TestItemDTO {
1691
+ return <TestItemDTO>TestItem.fromPartial(test);
1692
+ }
1693
+
1694
+ export function fromPartial(test: Partial<theia.TestItem>): Partial<TestItemDTO> {
1695
+ const result: Partial<Mutable<TestItemDTO>> = {};
1696
+
1697
+ if ('id' in test) {
1698
+ result.id = test.id;
1699
+ }
1700
+
1701
+ if ('uri' in test) {
1702
+ result.uri = test.uri;
1703
+ }
1704
+
1705
+ if ('label' in test) {
1706
+ result.label = test.label;
1707
+ }
1708
+
1709
+ if ('range' in test) {
1710
+ result.range = fromRange(test.range);
1711
+ }
1712
+
1713
+ if ('sortKey' in test) {
1714
+ result.sortKey = test.sortText;
1715
+ }
1716
+
1717
+ if ('tags' in test) {
1718
+ result.tags = test.tags ? test.tags.map(tag => tag.id) : [];
1719
+ }
1720
+ if ('busy' in test) {
1721
+ result.busy = test.busy!;
1722
+ }
1723
+ if ('sortKey' in test) {
1724
+ result.sortKey = test.sortText;
1725
+ }
1726
+ if ('canResolveChildren' in test) {
1727
+ result.canResolveChildren = test.canResolveChildren!;
1728
+ }
1729
+ if ('description' in test) {
1730
+ result.description = test.description;
1731
+ }
1732
+
1733
+ if ('description' in test) {
1734
+ result.error = test.error;
1735
+ }
1736
+
1737
+ if (test.children) {
1738
+ const children: TestItemDTO[] = [];
1739
+ test.children.forEach(item => {
1740
+ children.push(TestItem.from(item));
1741
+ });
1742
+ result.children = children;
1743
+ }
1744
+
1745
+ return result;
1746
+
1747
+ }
1748
+ }