@stylelint/language-server 1.0.0

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 (334) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +39 -0
  3. package/bin/stylelint-language-server.mjs +25 -0
  4. package/build/di/container.d.ts +12 -0
  5. package/build/di/container.js +76 -0
  6. package/build/di/container.js.map +1 -0
  7. package/build/di/hooks.d.ts +16 -0
  8. package/build/di/hooks.js +25 -0
  9. package/build/di/hooks.js.map +1 -0
  10. package/build/di/index.d.ts +7 -0
  11. package/build/di/index.js +8 -0
  12. package/build/di/index.js.map +1 -0
  13. package/build/di/inject.d.ts +48 -0
  14. package/build/di/inject.js +55 -0
  15. package/build/di/inject.js.map +1 -0
  16. package/build/di/module.d.ts +51 -0
  17. package/build/di/module.js +93 -0
  18. package/build/di/module.js.map +1 -0
  19. package/build/di/runtime/application.d.ts +17 -0
  20. package/build/di/runtime/application.js +209 -0
  21. package/build/di/runtime/application.js.map +1 -0
  22. package/build/di/runtime/decorators.d.ts +14 -0
  23. package/build/di/runtime/decorators.js +26 -0
  24. package/build/di/runtime/decorators.js.map +1 -0
  25. package/build/di/runtime/index.d.ts +3 -0
  26. package/build/di/runtime/index.js +4 -0
  27. package/build/di/runtime/index.js.map +1 -0
  28. package/build/di/runtime/symbols.d.ts +1 -0
  29. package/build/di/runtime/symbols.js +2 -0
  30. package/build/di/runtime/symbols.js.map +1 -0
  31. package/build/di/runtime/types.d.ts +20 -0
  32. package/build/di/runtime/types.js +2 -0
  33. package/build/di/runtime/types.js.map +1 -0
  34. package/build/di/tokens.d.ts +8 -0
  35. package/build/di/tokens.js +7 -0
  36. package/build/di/tokens.js.map +1 -0
  37. package/build/di/types.d.ts +16 -0
  38. package/build/di/types.js +2 -0
  39. package/build/di/types.js.map +1 -0
  40. package/build/server/config/default-options.d.ts +2 -0
  41. package/build/server/config/default-options.js +29 -0
  42. package/build/server/config/default-options.js.map +1 -0
  43. package/build/server/decorators.d.ts +121 -0
  44. package/build/server/decorators.js +272 -0
  45. package/build/server/decorators.js.map +1 -0
  46. package/build/server/index.d.ts +2 -0
  47. package/build/server/index.js +3 -0
  48. package/build/server/index.js.map +1 -0
  49. package/build/server/modules/documents.module.d.ts +1 -0
  50. package/build/server/modules/documents.module.js +12 -0
  51. package/build/server/modules/documents.module.js.map +1 -0
  52. package/build/server/modules/index.d.ts +6 -0
  53. package/build/server/modules/index.js +7 -0
  54. package/build/server/modules/index.js.map +1 -0
  55. package/build/server/modules/infrastructure.module.d.ts +1 -0
  56. package/build/server/modules/infrastructure.module.js +7 -0
  57. package/build/server/modules/infrastructure.module.js.map +1 -0
  58. package/build/server/modules/lsp.module.d.ts +1 -0
  59. package/build/server/modules/lsp.module.js +18 -0
  60. package/build/server/modules/lsp.module.js.map +1 -0
  61. package/build/server/modules/platform.module.d.ts +4 -0
  62. package/build/server/modules/platform.module.js +33 -0
  63. package/build/server/modules/platform.module.js.map +1 -0
  64. package/build/server/modules/stylelint-runtime.module.d.ts +1 -0
  65. package/build/server/modules/stylelint-runtime.module.js +19 -0
  66. package/build/server/modules/stylelint-runtime.module.js.map +1 -0
  67. package/build/server/modules/workspace.module.d.ts +1 -0
  68. package/build/server/modules/workspace.module.js +7 -0
  69. package/build/server/modules/workspace.module.js.map +1 -0
  70. package/build/server/runtime/application.d.ts +19 -0
  71. package/build/server/runtime/application.js +22 -0
  72. package/build/server/runtime/application.js.map +1 -0
  73. package/build/server/runtime/language-server-feature.d.ts +13 -0
  74. package/build/server/runtime/language-server-feature.js +142 -0
  75. package/build/server/runtime/language-server-feature.js.map +1 -0
  76. package/build/server/runtime/lsp-service-runtime.d.ts +15 -0
  77. package/build/server/runtime/lsp-service-runtime.js +133 -0
  78. package/build/server/runtime/lsp-service-runtime.js.map +1 -0
  79. package/build/server/server.d.ts +13 -0
  80. package/build/server/server.js +38 -0
  81. package/build/server/server.js.map +1 -0
  82. package/build/server/server.module.d.ts +1 -0
  83. package/build/server/server.module.js +13 -0
  84. package/build/server/server.module.js.map +1 -0
  85. package/build/server/services/documents/document-diagnostics.service.d.ts +15 -0
  86. package/build/server/services/documents/document-diagnostics.service.js +88 -0
  87. package/build/server/services/documents/document-diagnostics.service.js.map +1 -0
  88. package/build/server/services/documents/document-fixes.service.d.ts +14 -0
  89. package/build/server/services/documents/document-fixes.service.js +94 -0
  90. package/build/server/services/documents/document-fixes.service.js.map +1 -0
  91. package/build/server/services/documents/index.d.ts +2 -0
  92. package/build/server/services/documents/index.js +3 -0
  93. package/build/server/services/documents/index.js.map +1 -0
  94. package/build/server/services/index.d.ts +5 -0
  95. package/build/server/services/index.js +6 -0
  96. package/build/server/services/index.js.map +1 -0
  97. package/build/server/services/infrastructure/command.service.d.ts +22 -0
  98. package/build/server/services/infrastructure/command.service.js +151 -0
  99. package/build/server/services/infrastructure/command.service.js.map +1 -0
  100. package/build/server/services/infrastructure/index.d.ts +4 -0
  101. package/build/server/services/infrastructure/index.js +5 -0
  102. package/build/server/services/infrastructure/index.js.map +1 -0
  103. package/build/server/services/infrastructure/logging.service.d.ts +6 -0
  104. package/build/server/services/infrastructure/logging.service.js +4 -0
  105. package/build/server/services/infrastructure/logging.service.js.map +1 -0
  106. package/build/server/services/infrastructure/notification.service.d.ts +24 -0
  107. package/build/server/services/infrastructure/notification.service.js +142 -0
  108. package/build/server/services/infrastructure/notification.service.js.map +1 -0
  109. package/build/server/services/infrastructure/winston-logging.service.d.ts +10 -0
  110. package/build/server/services/infrastructure/winston-logging.service.js +48 -0
  111. package/build/server/services/infrastructure/winston-logging.service.js.map +1 -0
  112. package/build/server/services/lsp/auto-fix.service.d.ts +15 -0
  113. package/build/server/services/lsp/auto-fix.service.js +142 -0
  114. package/build/server/services/lsp/auto-fix.service.js.map +1 -0
  115. package/build/server/services/lsp/code-actions/code-action.service.d.ts +18 -0
  116. package/build/server/services/lsp/code-actions/code-action.service.js +288 -0
  117. package/build/server/services/lsp/code-actions/code-action.service.js.map +1 -0
  118. package/build/server/services/lsp/code-actions/disable-rule-file-code-action.service.d.ts +11 -0
  119. package/build/server/services/lsp/code-actions/disable-rule-file-code-action.service.js +72 -0
  120. package/build/server/services/lsp/code-actions/disable-rule-file-code-action.service.js.map +1 -0
  121. package/build/server/services/lsp/code-actions/disable-rule-line-code-action.service.d.ts +12 -0
  122. package/build/server/services/lsp/code-actions/disable-rule-line-code-action.service.js +80 -0
  123. package/build/server/services/lsp/code-actions/disable-rule-line-code-action.service.js.map +1 -0
  124. package/build/server/services/lsp/code-actions/index.d.ts +3 -0
  125. package/build/server/services/lsp/code-actions/index.js +4 -0
  126. package/build/server/services/lsp/code-actions/index.js.map +1 -0
  127. package/build/server/services/lsp/completion.service.d.ts +12 -0
  128. package/build/server/services/lsp/completion.service.js +183 -0
  129. package/build/server/services/lsp/completion.service.js.map +1 -0
  130. package/build/server/services/lsp/empty-config-warning.service.d.ts +17 -0
  131. package/build/server/services/lsp/empty-config-warning.service.js +149 -0
  132. package/build/server/services/lsp/empty-config-warning.service.js.map +1 -0
  133. package/build/server/services/lsp/formatter.service.d.ts +16 -0
  134. package/build/server/services/lsp/formatter.service.js +215 -0
  135. package/build/server/services/lsp/formatter.service.js.map +1 -0
  136. package/build/server/services/lsp/index.d.ts +8 -0
  137. package/build/server/services/lsp/index.js +9 -0
  138. package/build/server/services/lsp/index.js.map +1 -0
  139. package/build/server/services/lsp/old-stylelint-warning.service.d.ts +13 -0
  140. package/build/server/services/lsp/old-stylelint-warning.service.js +186 -0
  141. package/build/server/services/lsp/old-stylelint-warning.service.js.map +1 -0
  142. package/build/server/services/lsp/validator.service.d.ts +19 -0
  143. package/build/server/services/lsp/validator.service.js +273 -0
  144. package/build/server/services/lsp/validator.service.js.map +1 -0
  145. package/build/server/services/lsp/workspace-activity.service.d.ts +10 -0
  146. package/build/server/services/lsp/workspace-activity.service.js +76 -0
  147. package/build/server/services/lsp/workspace-activity.service.js.map +1 -0
  148. package/build/server/services/services.module.d.ts +1 -0
  149. package/build/server/services/services.module.js +19 -0
  150. package/build/server/services/services.module.js.map +1 -0
  151. package/build/server/services/stylelint-runtime/global-path-resolver.service.d.ts +38 -0
  152. package/build/server/services/stylelint-runtime/global-path-resolver.service.js +223 -0
  153. package/build/server/services/stylelint-runtime/global-path-resolver.service.js.map +1 -0
  154. package/build/server/services/stylelint-runtime/index.d.ts +11 -0
  155. package/build/server/services/stylelint-runtime/index.js +12 -0
  156. package/build/server/services/stylelint-runtime/index.js.map +1 -0
  157. package/build/server/services/stylelint-runtime/package-root-cache.service.d.ts +9 -0
  158. package/build/server/services/stylelint-runtime/package-root-cache.service.js +141 -0
  159. package/build/server/services/stylelint-runtime/package-root-cache.service.js.map +1 -0
  160. package/build/server/services/stylelint-runtime/package-root.service.d.ts +8 -0
  161. package/build/server/services/stylelint-runtime/package-root.service.js +119 -0
  162. package/build/server/services/stylelint-runtime/package-root.service.js.map +1 -0
  163. package/build/server/services/stylelint-runtime/pnp-configuration-cache.service.d.ts +16 -0
  164. package/build/server/services/stylelint-runtime/pnp-configuration-cache.service.js +195 -0
  165. package/build/server/services/stylelint-runtime/pnp-configuration-cache.service.js.map +1 -0
  166. package/build/server/services/stylelint-runtime/process-runner.service.d.ts +30 -0
  167. package/build/server/services/stylelint-runtime/process-runner.service.js +149 -0
  168. package/build/server/services/stylelint-runtime/process-runner.service.js.map +1 -0
  169. package/build/server/services/stylelint-runtime/stylelint-options.service.d.ts +12 -0
  170. package/build/server/services/stylelint-runtime/stylelint-options.service.js +185 -0
  171. package/build/server/services/stylelint-runtime/stylelint-options.service.js.map +1 -0
  172. package/build/server/services/stylelint-runtime/stylelint-runner.service.d.ts +42 -0
  173. package/build/server/services/stylelint-runtime/stylelint-runner.service.js +478 -0
  174. package/build/server/services/stylelint-runtime/stylelint-runner.service.js.map +1 -0
  175. package/build/server/services/stylelint-runtime/worker-environment.service.d.ts +17 -0
  176. package/build/server/services/stylelint-runtime/worker-environment.service.js +135 -0
  177. package/build/server/services/stylelint-runtime/worker-environment.service.js.map +1 -0
  178. package/build/server/services/stylelint-runtime/worker-process.service.d.ts +8 -0
  179. package/build/server/services/stylelint-runtime/worker-process.service.js +66 -0
  180. package/build/server/services/stylelint-runtime/worker-process.service.js.map +1 -0
  181. package/build/server/services/stylelint-runtime/worker-registry.service.d.ts +19 -0
  182. package/build/server/services/stylelint-runtime/worker-registry.service.js +289 -0
  183. package/build/server/services/stylelint-runtime/worker-registry.service.js.map +1 -0
  184. package/build/server/services/stylelint-runtime/workspace-stylelint.service.d.ts +37 -0
  185. package/build/server/services/stylelint-runtime/workspace-stylelint.service.js +185 -0
  186. package/build/server/services/stylelint-runtime/workspace-stylelint.service.js.map +1 -0
  187. package/build/server/services/workspace/index.d.ts +2 -0
  188. package/build/server/services/workspace/index.js +3 -0
  189. package/build/server/services/workspace/index.js.map +1 -0
  190. package/build/server/services/workspace/workspace-folder.service.d.ts +18 -0
  191. package/build/server/services/workspace/workspace-folder.service.js +101 -0
  192. package/build/server/services/workspace/workspace-folder.service.js.map +1 -0
  193. package/build/server/services/workspace/workspace-options.service.d.ts +12 -0
  194. package/build/server/services/workspace/workspace-options.service.js +125 -0
  195. package/build/server/services/workspace/workspace-options.service.js.map +1 -0
  196. package/build/server/stylelint/disable-metadata-lookup-table.d.ts +20 -0
  197. package/build/server/stylelint/disable-metadata-lookup-table.js +68 -0
  198. package/build/server/stylelint/disable-metadata-lookup-table.js.map +1 -0
  199. package/build/server/stylelint/formatting-options-to-rules.d.ts +12 -0
  200. package/build/server/stylelint/formatting-options-to-rules.js +19 -0
  201. package/build/server/stylelint/formatting-options-to-rules.js.map +1 -0
  202. package/build/server/stylelint/get-disable-diagnostic-rule.d.ts +7 -0
  203. package/build/server/stylelint/get-disable-diagnostic-rule.js +22 -0
  204. package/build/server/stylelint/get-disable-diagnostic-rule.js.map +1 -0
  205. package/build/server/stylelint/index.d.ts +7 -0
  206. package/build/server/stylelint/index.js +8 -0
  207. package/build/server/stylelint/index.js.map +1 -0
  208. package/build/server/stylelint/is-disable-report-rule.d.ts +6 -0
  209. package/build/server/stylelint/is-disable-report-rule.js +17 -0
  210. package/build/server/stylelint/is-disable-report-rule.js.map +1 -0
  211. package/build/server/stylelint/load-stylelint.d.ts +23 -0
  212. package/build/server/stylelint/load-stylelint.js +173 -0
  213. package/build/server/stylelint/load-stylelint.js.map +1 -0
  214. package/build/server/stylelint/process-linter-result.d.ts +32 -0
  215. package/build/server/stylelint/process-linter-result.js +129 -0
  216. package/build/server/stylelint/process-linter-result.js.map +1 -0
  217. package/build/server/stylelint/types.d.ts +143 -0
  218. package/build/server/stylelint/types.js +47 -0
  219. package/build/server/stylelint/types.js.map +1 -0
  220. package/build/server/stylelint/warning-to-diagnostic.d.ts +46 -0
  221. package/build/server/stylelint/warning-to-diagnostic.js +143 -0
  222. package/build/server/stylelint/warning-to-diagnostic.js.map +1 -0
  223. package/build/server/tokens.d.ts +20 -0
  224. package/build/server/tokens.js +16 -0
  225. package/build/server/tokens.js.map +1 -0
  226. package/build/server/types.d.ts +74 -0
  227. package/build/server/types.js +18 -0
  228. package/build/server/types.js.map +1 -0
  229. package/build/server/utils/documents/create-text-edits.d.ts +10 -0
  230. package/build/server/utils/documents/create-text-edits.js +31 -0
  231. package/build/server/utils/documents/create-text-edits.js.map +1 -0
  232. package/build/server/utils/documents/get-disable-type.d.ts +26 -0
  233. package/build/server/utils/documents/get-disable-type.js +32 -0
  234. package/build/server/utils/documents/get-disable-type.js.map +1 -0
  235. package/build/server/utils/documents/get-edit-info.d.ts +14 -0
  236. package/build/server/utils/documents/get-edit-info.js +31 -0
  237. package/build/server/utils/documents/get-edit-info.js.map +1 -0
  238. package/build/server/utils/documents/get-fixes.d.ts +12 -0
  239. package/build/server/utils/documents/get-fixes.js +18 -0
  240. package/build/server/utils/documents/get-fixes.js.map +1 -0
  241. package/build/server/utils/documents/index.d.ts +4 -0
  242. package/build/server/utils/documents/index.js +5 -0
  243. package/build/server/utils/documents/index.js.map +1 -0
  244. package/build/server/utils/errors.d.ts +10 -0
  245. package/build/server/utils/errors.js +89 -0
  246. package/build/server/utils/errors.js.map +1 -0
  247. package/build/server/utils/fs.d.ts +4 -0
  248. package/build/server/utils/fs.js +11 -0
  249. package/build/server/utils/fs.js.map +1 -0
  250. package/build/server/utils/functions/get-first-return-value.d.ts +11 -0
  251. package/build/server/utils/functions/get-first-return-value.js +28 -0
  252. package/build/server/utils/functions/get-first-return-value.js.map +1 -0
  253. package/build/server/utils/functions/index.d.ts +2 -0
  254. package/build/server/utils/functions/index.js +3 -0
  255. package/build/server/utils/functions/index.js.map +1 -0
  256. package/build/server/utils/functions/lazy-call.d.ts +12 -0
  257. package/build/server/utils/functions/lazy-call.js +33 -0
  258. package/build/server/utils/functions/lazy-call.js.map +1 -0
  259. package/build/server/utils/index.d.ts +11 -0
  260. package/build/server/utils/index.js +12 -0
  261. package/build/server/utils/index.js.map +1 -0
  262. package/build/server/utils/iterables.d.ts +8 -0
  263. package/build/server/utils/iterables.js +15 -0
  264. package/build/server/utils/iterables.js.map +1 -0
  265. package/build/server/utils/logging/error-formatter.d.ts +7 -0
  266. package/build/server/utils/logging/error-formatter.js +14 -0
  267. package/build/server/utils/logging/error-formatter.js.map +1 -0
  268. package/build/server/utils/logging/get-log-function.d.ts +8 -0
  269. package/build/server/utils/logging/get-log-function.js +11 -0
  270. package/build/server/utils/logging/get-log-function.js.map +1 -0
  271. package/build/server/utils/logging/index.d.ts +4 -0
  272. package/build/server/utils/logging/index.js +5 -0
  273. package/build/server/utils/logging/index.js.map +1 -0
  274. package/build/server/utils/logging/language-server-formatter.d.ts +19 -0
  275. package/build/server/utils/logging/language-server-formatter.js +55 -0
  276. package/build/server/utils/logging/language-server-formatter.js.map +1 -0
  277. package/build/server/utils/logging/language-server-transport.d.ts +19 -0
  278. package/build/server/utils/logging/language-server-transport.js +39 -0
  279. package/build/server/utils/logging/language-server-transport.js.map +1 -0
  280. package/build/server/utils/lsp/create-disable-completion-item.d.ts +7 -0
  281. package/build/server/utils/lsp/create-disable-completion-item.js +32 -0
  282. package/build/server/utils/lsp/create-disable-completion-item.js.map +1 -0
  283. package/build/server/utils/lsp/display-error.d.ts +7 -0
  284. package/build/server/utils/lsp/display-error.js +24 -0
  285. package/build/server/utils/lsp/display-error.js.map +1 -0
  286. package/build/server/utils/lsp/index.d.ts +4 -0
  287. package/build/server/utils/lsp/index.js +5 -0
  288. package/build/server/utils/lsp/index.js.map +1 -0
  289. package/build/server/utils/lsp/rule-code-actions-collection.d.ts +29 -0
  290. package/build/server/utils/lsp/rule-code-actions-collection.js +61 -0
  291. package/build/server/utils/lsp/rule-code-actions-collection.js.map +1 -0
  292. package/build/server/utils/lsp/types.d.ts +22 -0
  293. package/build/server/utils/lsp/types.js +2 -0
  294. package/build/server/utils/lsp/types.js.map +1 -0
  295. package/build/server/utils/objects/index.d.ts +3 -0
  296. package/build/server/utils/objects/index.js +4 -0
  297. package/build/server/utils/objects/index.js.map +1 -0
  298. package/build/server/utils/objects/is-object.d.ts +8 -0
  299. package/build/server/utils/objects/is-object.js +13 -0
  300. package/build/server/utils/objects/is-object.js.map +1 -0
  301. package/build/server/utils/objects/merge-assign.d.ts +8 -0
  302. package/build/server/utils/objects/merge-assign.js +38 -0
  303. package/build/server/utils/objects/merge-assign.js.map +1 -0
  304. package/build/server/utils/objects/merge-options-with-defaults.d.ts +5 -0
  305. package/build/server/utils/objects/merge-options-with-defaults.js +56 -0
  306. package/build/server/utils/objects/merge-options-with-defaults.js.map +1 -0
  307. package/build/server/utils/sets.d.ts +6 -0
  308. package/build/server/utils/sets.js +22 -0
  309. package/build/server/utils/sets.js.map +1 -0
  310. package/build/server/utils/strings.d.ts +12 -0
  311. package/build/server/utils/strings.js +20 -0
  312. package/build/server/utils/strings.js.map +1 -0
  313. package/build/server/utils/types.d.ts +27 -0
  314. package/build/server/utils/types.js +2 -0
  315. package/build/server/utils/types.js.map +1 -0
  316. package/build/server/worker/types.d.ts +63 -0
  317. package/build/server/worker/types.js +2 -0
  318. package/build/server/worker/types.js.map +1 -0
  319. package/build/server/worker/worker-entry.d.ts +1 -0
  320. package/build/server/worker/worker-entry.js +320 -0
  321. package/build/server/worker/worker-entry.js.map +1 -0
  322. package/build/server/worker/worker-logging.service.d.ts +18 -0
  323. package/build/server/worker/worker-logging.service.js +61 -0
  324. package/build/server/worker/worker-logging.service.js.map +1 -0
  325. package/build/server/worker/worker-process.d.ts +54 -0
  326. package/build/server/worker/worker-process.js +266 -0
  327. package/build/server/worker/worker-process.js.map +1 -0
  328. package/build/shared/log-level.d.ts +5 -0
  329. package/build/shared/log-level.js +11 -0
  330. package/build/shared/log-level.js.map +1 -0
  331. package/build/shared/types.d.ts +9 -0
  332. package/build/shared/types.js +3 -0
  333. package/build/shared/types.js.map +1 -0
  334. package/package.json +89 -0
@@ -0,0 +1,209 @@
1
+ import { createContainer } from '../container.js';
2
+ import { isRuntimeServiceConstructor } from './decorators.js';
3
+ /**
4
+ * Collects all runtime service constructors from the provided modules.
5
+ */
6
+ function collectRuntimeServiceConstructors(modules) {
7
+ const constructors = new Set();
8
+ for (const metadata of modules) {
9
+ for (const [token] of metadata.providers) {
10
+ if (typeof token === 'function' && isRuntimeServiceConstructor(token)) {
11
+ constructors.add(token);
12
+ }
13
+ }
14
+ }
15
+ return constructors;
16
+ }
17
+ /**
18
+ * Determines if the provided value implements the runtime lifecycle participant contract.
19
+ */
20
+ function isLifecycleParticipant(value) {
21
+ return (typeof value === 'object' &&
22
+ value !== null &&
23
+ (typeof value.onStart === 'function' ||
24
+ typeof value.onShutdown === 'function'));
25
+ }
26
+ class DefaultRuntimeApplication {
27
+ #container;
28
+ #modules;
29
+ #features;
30
+ #services = [];
31
+ #participants = [];
32
+ #started = false;
33
+ #disposed = false;
34
+ #startPromise;
35
+ #disposePromise;
36
+ constructor(container, modules, features) {
37
+ this.#container = container;
38
+ this.#modules = modules;
39
+ this.#features = features;
40
+ }
41
+ async start() {
42
+ if (this.#startPromise) {
43
+ return this.#startPromise;
44
+ }
45
+ if (this.#disposed) {
46
+ throw new Error('Cannot start a disposed runtime application.');
47
+ }
48
+ this.#startPromise = this.#startInternal();
49
+ return this.#startPromise;
50
+ }
51
+ async #startInternal() {
52
+ if (this.#started) {
53
+ return;
54
+ }
55
+ this.#instantiateRuntimeServices();
56
+ const context = this.#createContext();
57
+ await this.#runFeatures('start', context);
58
+ await this.#runParticipants('onStart', context);
59
+ this.#started = true;
60
+ }
61
+ async dispose() {
62
+ if (this.#disposePromise) {
63
+ return this.#disposePromise;
64
+ }
65
+ this.#disposePromise = this.#disposeInternal();
66
+ return this.#disposePromise;
67
+ }
68
+ resolve(token) {
69
+ return this.#container.resolve(token);
70
+ }
71
+ async #disposeInternal() {
72
+ if (this.#disposed) {
73
+ return;
74
+ }
75
+ if (this.#startPromise) {
76
+ await this.#startPromise;
77
+ }
78
+ if (!this.#started) {
79
+ this.#disposed = true;
80
+ return;
81
+ }
82
+ const context = this.#createContext();
83
+ const participantErrors = await this.#runParticipants('onShutdown', context, true);
84
+ const featureErrors = await this.#runFeatures('shutdown', context, true);
85
+ this.#disposeServices();
86
+ this.#disposeFeatures();
87
+ this.#participants.length = 0;
88
+ this.#services.length = 0;
89
+ this.#disposed = true;
90
+ if (participantErrors.length > 0 || featureErrors.length > 0) {
91
+ const firstError = participantErrors.length > 0 ? participantErrors[0] : featureErrors[0];
92
+ throw this.#normalizeDisposalError(firstError);
93
+ }
94
+ }
95
+ #normalizeDisposalError(error) {
96
+ if (error instanceof Error) {
97
+ return error;
98
+ }
99
+ if (typeof error === 'string') {
100
+ return new Error(error);
101
+ }
102
+ if (typeof error === 'undefined') {
103
+ return new Error('unknown');
104
+ }
105
+ try {
106
+ const serialized = JSON.stringify(error);
107
+ return new Error(serialized ?? 'unknown');
108
+ }
109
+ catch {
110
+ return new Error('unknown');
111
+ }
112
+ }
113
+ #createContext() {
114
+ const resolve = (token) => this.#container.resolve(token);
115
+ return {
116
+ container: this.#container,
117
+ resolve,
118
+ metadata: {
119
+ services: this.#services,
120
+ },
121
+ };
122
+ }
123
+ #instantiateRuntimeServices() {
124
+ if (this.#services.length > 0) {
125
+ return;
126
+ }
127
+ const constructors = collectRuntimeServiceConstructors(this.#modules);
128
+ for (const ctor of constructors) {
129
+ const instance = this.#container.resolve(ctor);
130
+ if (typeof instance !== 'object' || instance === null) {
131
+ throw new Error('Runtime services must be class instances.');
132
+ }
133
+ this.#services.push(instance);
134
+ if (isLifecycleParticipant(instance)) {
135
+ this.#participants.push(instance);
136
+ }
137
+ }
138
+ }
139
+ async #runParticipants(method, context, ignoreErrors = false) {
140
+ const errors = [];
141
+ for (const participant of this.#participants) {
142
+ const handler = participant[method];
143
+ if (!handler) {
144
+ continue;
145
+ }
146
+ try {
147
+ await handler.call(participant, context);
148
+ }
149
+ catch (error) {
150
+ if (!ignoreErrors) {
151
+ throw error;
152
+ }
153
+ errors.push(error);
154
+ }
155
+ }
156
+ return errors;
157
+ }
158
+ async #runFeatures(method, context, ignoreErrors = false) {
159
+ const errors = [];
160
+ for (const feature of this.#features) {
161
+ const handler = feature[method];
162
+ if (!handler) {
163
+ continue;
164
+ }
165
+ try {
166
+ await handler.call(feature, context);
167
+ }
168
+ catch (error) {
169
+ if (!ignoreErrors) {
170
+ throw error;
171
+ }
172
+ errors.push(error);
173
+ }
174
+ }
175
+ return errors;
176
+ }
177
+ #disposeServices() {
178
+ for (const service of this.#services) {
179
+ if (typeof service.dispose === 'function') {
180
+ try {
181
+ service.dispose();
182
+ }
183
+ catch {
184
+ // Best-effort cleanup.
185
+ }
186
+ }
187
+ }
188
+ }
189
+ #disposeFeatures() {
190
+ for (const feature of this.#features) {
191
+ if (typeof feature.dispose === 'function') {
192
+ try {
193
+ feature.dispose();
194
+ }
195
+ catch {
196
+ // Best-effort cleanup.
197
+ }
198
+ }
199
+ }
200
+ }
201
+ }
202
+ /**
203
+ * Creates a runtime application backed by the shared dependency injection container.
204
+ */
205
+ export function createRuntimeApplication(options) {
206
+ const container = createContainer(options.modules, { overrides: options.overrides });
207
+ return new DefaultRuntimeApplication(container, options.modules, options.features ?? []);
208
+ }
209
+ //# sourceMappingURL=application.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application.js","sourceRoot":"","sources":["../../../src/di/runtime/application.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAkB,MAAM,iBAAiB,CAAC;AAGlE,OAAO,EAAE,2BAA2B,EAAkC,MAAM,iBAAiB,CAAC;AAe9F;;GAEG;AACH,SAAS,iCAAiC,CACzC,OAAyB;IAEzB,MAAM,YAAY,GAAG,IAAI,GAAG,EAA6B,CAAC;IAE1D,KAAK,MAAM,QAAQ,IAAI,OAAO,EAAE,CAAC;QAChC,KAAK,MAAM,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC;YAC1C,IAAI,OAAO,KAAK,KAAK,UAAU,IAAI,2BAA2B,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvE,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,YAAY,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,SAAS,sBAAsB,CAAC,KAAc;IAC7C,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAC,OAAQ,KAAqC,CAAC,OAAO,KAAK,UAAU;YACpE,OAAQ,KAAqC,CAAC,UAAU,KAAK,UAAU,CAAC,CACzE,CAAC;AACH,CAAC;AAED,MAAM,yBAAyB;IACrB,UAAU,CAAY;IACtB,QAAQ,CAAmB;IAC3B,SAAS,CAAmB;IAC5B,SAAS,GAAa,EAAE,CAAC;IACzB,aAAa,GAAkC,EAAE,CAAC;IAC3D,QAAQ,GAAG,KAAK,CAAC;IACjB,SAAS,GAAG,KAAK,CAAC;IAClB,aAAa,CAAiB;IAC9B,eAAe,CAAiB;IAEhC,YAAY,SAAoB,EAAE,OAAyB,EAAE,QAA0B;QACtF,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QA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,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,IAAI,OAAQ,OAAoC,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;gBACzE,IAAI,CAAC;oBACH,OAAmC,CAAC,OAAO,EAAE,CAAC;gBAChD,CAAC;gBAAC,MAAM,CAAC;oBACR,uBAAuB;gBACxB,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAED,gBAAgB;QACf,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;gBAC3C,IAAI,CAAC;oBACJ,OAAO,CAAC,OAAO,EAAE,CAAC;gBACnB,CAAC;gBAAC,MAAM,CAAC;oBACR,uBAAuB;gBACxB,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAkC;IAC1E,MAAM,SAAS,GAAG,eAAe,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAErF,OAAO,IAAI,yBAAyB,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;AAC1F,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Constructable } from '../inject.js';
2
+ import type { ClassDecoratorFunction } from '../types.js';
3
+ import { runtimeServiceSymbol } from './symbols.js';
4
+ export type RuntimeServiceConstructor = Constructable<unknown> & {
5
+ [runtimeServiceSymbol]: true;
6
+ };
7
+ /**
8
+ * Marks a class as a runtime service to be registered automatically.
9
+ */
10
+ export declare function runtimeService(): ClassDecoratorFunction;
11
+ /**
12
+ * Determines if a class is marked as a runtime service.
13
+ */
14
+ export declare function isRuntimeServiceConstructor(target: Constructable<unknown>): target is RuntimeServiceConstructor;
@@ -0,0 +1,26 @@
1
+ import { runtimeServiceSymbol } from './symbols.js';
2
+ /**
3
+ * Marks a class as a runtime service to be registered automatically.
4
+ */
5
+ export function runtimeService() {
6
+ // Function type used to match decorator signature.
7
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
8
+ return (target, { kind }) => {
9
+ if (kind !== 'class') {
10
+ throw new Error('@runtimeService() can only be applied to classes.');
11
+ }
12
+ Object.defineProperty(target, runtimeServiceSymbol, {
13
+ value: true,
14
+ writable: false,
15
+ configurable: false,
16
+ enumerable: false,
17
+ });
18
+ };
19
+ }
20
+ /**
21
+ * Determines if a class is marked as a runtime service.
22
+ */
23
+ export function isRuntimeServiceConstructor(target) {
24
+ return Boolean(target[runtimeServiceSymbol]);
25
+ }
26
+ //# sourceMappingURL=decorators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/di/runtime/decorators.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAMpD;;GAEG;AACH,MAAM,UAAU,cAAc;IAC7B,mDAAmD;IACnD,sEAAsE;IACtE,OAAO,CAAC,MAAgB,EAAE,EAAE,IAAI,EAAyB,EAAE,EAAE;QAC5D,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACtE,CAAC;QAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,oBAAoB,EAAE;YACnD,KAAK,EAAE,IAAI;YACX,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,KAAK;SACjB,CAAC,CAAC;IACJ,CAAC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B,CAC1C,MAA8B;IAE9B,OAAO,OAAO,CAAE,MAA4C,CAAC,oBAAoB,CAAC,CAAC,CAAC;AACrF,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './application.js';
2
+ export * from './decorators.js';
3
+ export * from './types.js';
@@ -0,0 +1,4 @@
1
+ export * from './application.js';
2
+ export * from './decorators.js';
3
+ export * from './types.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/di/runtime/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const runtimeServiceSymbol: unique symbol;
@@ -0,0 +1,2 @@
1
+ export const runtimeServiceSymbol = Symbol('runtimeService');
2
+ //# sourceMappingURL=symbols.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"symbols.js","sourceRoot":"","sources":["../../../src/di/runtime/symbols.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { Container } from '../container.js';
2
+ import type { InjectionToken } from '../inject.js';
3
+ export type MaybePromise<T> = T | Promise<T>;
4
+ export interface RuntimeMetadata {
5
+ readonly services: readonly object[];
6
+ }
7
+ export interface RuntimeContext {
8
+ readonly container: Container;
9
+ readonly resolve: <T>(token: InjectionToken<T>) => T;
10
+ readonly metadata: RuntimeMetadata;
11
+ }
12
+ export interface RuntimeLifecycleParticipant {
13
+ onStart?(context: RuntimeContext): MaybePromise<void>;
14
+ onShutdown?(context: RuntimeContext): MaybePromise<void>;
15
+ }
16
+ export interface RuntimeFeature {
17
+ start?(context: RuntimeContext): MaybePromise<void>;
18
+ shutdown?(context: RuntimeContext): MaybePromise<void>;
19
+ dispose?(): void;
20
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/di/runtime/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ export type Token<T> = symbol & {
2
+ __type?: T;
3
+ };
4
+ export type TokenType<T extends Token<unknown>> = T extends Token<infer R> ? R : never;
5
+ /**
6
+ * Creates a unique token for dependency injection.
7
+ */
8
+ export declare function createToken<T>(description: string): Token<T>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Creates a unique token for dependency injection.
3
+ */
4
+ export function createToken(description) {
5
+ return Symbol(description);
6
+ }
7
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/di/tokens.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,UAAU,WAAW,CAAI,WAAmB;IACjD,OAAO,MAAM,CAAC,WAAW,CAAa,CAAC;AACxC,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * A class decorator function.
3
+ */
4
+ export type ClassDecoratorFunction<TFunction extends new (...args: any[]) => any = new (...args: any[]) => any> = (target: TFunction, context: ClassDecoratorContext) => void | TFunction;
5
+ /**
6
+ * A method decorator function.
7
+ */
8
+ export type MethodDecoratorFunction<TFunction extends Function = Function> = (target: TFunction, context: ClassMethodDecoratorContext) => void | TFunction;
9
+ type ParameterPrefixTuples<TParameters extends readonly unknown[], TPrefix extends readonly unknown[] = []> = TParameters extends readonly [infer Head, ...infer Tail] ? TPrefix | ParameterPrefixTuples<Tail, [...TPrefix, Head]> : TPrefix;
10
+ /**
11
+ * A function type that can accept any prefix of the parameters of `TFunction`
12
+ * while preserving its return type.
13
+ */
14
+ export type CompatibleMethod<TFunction extends (...args: any[]) => any> = ParameterPrefixTuples<Parameters<TFunction>> extends infer TPrefixes ? TPrefixes extends readonly unknown[] ? (...args: TPrefixes) => ReturnType<TFunction> : never : never;
15
+ export type CompatibleMethodDecorator<TFunction extends (...args: any[]) => any> = <TCompatible extends CompatibleMethod<TFunction>>(target: TCompatible, context: ClassMethodDecoratorContext) => void | TCompatible;
16
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/di/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import { LanguageServerOptions } from '../types.js';
2
+ export declare const defaultLanguageServerOptions: LanguageServerOptions;
@@ -0,0 +1,29 @@
1
+ // @no-unit-test -- This is just an export of an object, no logic to test.
2
+ export const defaultLanguageServerOptions = {
3
+ codeAction: {
4
+ disableRuleComment: {
5
+ location: 'separateLine',
6
+ },
7
+ },
8
+ config: null,
9
+ configFile: '',
10
+ configBasedir: '',
11
+ customSyntax: '',
12
+ ignoreDisables: false,
13
+ ignorePath: '',
14
+ packageManager: 'npm',
15
+ reportDescriptionlessDisables: false,
16
+ reportInvalidScopeDisables: false,
17
+ reportNeedlessDisables: false,
18
+ run: 'onType',
19
+ rules: {
20
+ customizations: [],
21
+ },
22
+ snippet: ['css', 'postcss'],
23
+ stylelintPath: '',
24
+ validate: ['css', 'postcss'],
25
+ lintFiles: {
26
+ glob: '**/*.css',
27
+ },
28
+ };
29
+ //# sourceMappingURL=default-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-options.js","sourceRoot":"","sources":["../../../src/server/config/default-options.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAI1E,MAAM,CAAC,MAAM,4BAA4B,GAA0B;IAClE,UAAU,EAAE;QACX,kBAAkB,EAAE;YACnB,QAAQ,EAAE,cAAc;SACxB;KACD;IACD,MAAM,EAAE,IAAI;IACZ,UAAU,EAAE,EAAE;IACd,aAAa,EAAE,EAAE;IACjB,YAAY,EAAE,EAAE;IAChB,cAAc,EAAE,KAAK;IACrB,UAAU,EAAE,EAAE;IACd,cAAc,EAAE,KAAK;IACrB,6BAA6B,EAAE,KAAK;IACpC,0BAA0B,EAAE,KAAK;IACjC,sBAAsB,EAAE,KAAK;IAC7B,GAAG,EAAE,QAAQ;IACb,KAAK,EAAE;QACN,cAAc,EAAE,EAAE;KAClB;IACD,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC;IAC3B,aAAa,EAAE,EAAE;IACjB,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC;IAC5B,SAAS,EAAE;QACV,IAAI,EAAE,UAAU;KAChB;CACD,CAAC"}
@@ -0,0 +1,121 @@
1
+ import type { HandlerResult, TextDocumentChangeEvent } from 'vscode-languageserver';
2
+ import type LSP from 'vscode-languageserver-protocol';
3
+ import type { TextDocument } from 'vscode-languageserver-textdocument';
4
+ import { Constructable } from '../di/index.js';
5
+ import { ClassDecoratorFunction, CompatibleMethodDecorator, MethodDecoratorFunction } from '../di/types.js';
6
+ import { CommandId } from './types.js';
7
+ import { MaybeAsync } from './utils/index.js';
8
+ declare const lspServiceMetadataKey = "__languageServerServiceMetadata__";
9
+ declare const lspServiceConstructorMetadataKey = "__isLanguageServerService__";
10
+ export interface CommandHandlerMetadata {
11
+ commandId: CommandId;
12
+ methodName: string | symbol;
13
+ handler: CommandMethod;
14
+ options: CommandOptions;
15
+ }
16
+ export type InitializeHandler = (params?: LSP.InitializeParams) => Partial<LSP.InitializeResult> | void;
17
+ export interface LspServiceInstanceMetadata {
18
+ commandHandlers: CommandHandlerMetadata[];
19
+ initializerHandlers: InitializeHandler[];
20
+ textDocumentHandlers: TextDocumentHandlerMetadata[];
21
+ notificationHandlers: NotificationHandlerMetadata[];
22
+ shutdownHandlers: ShutdownHandler[];
23
+ connectionHandlers: ConnectionHandlerMetadata[];
24
+ disposables: LSP.Disposable[];
25
+ }
26
+ export type TextDocumentEventName = 'onDidOpen' | 'onDidChangeContent' | 'onDidSave' | 'onDidClose';
27
+ export type TextDocumentEventHandler = (event: TextDocumentChangeEvent<TextDocument>) => Promise<void> | void;
28
+ export interface TextDocumentHandlerMetadata {
29
+ event: TextDocumentEventName;
30
+ handler: TextDocumentEventHandler;
31
+ }
32
+ export type NotificationRegistrationType = LSP.ProtocolNotificationType0<unknown> | LSP.ProtocolNotificationType<unknown, unknown> | LSP.NotificationType0 | LSP.NotificationType<unknown> | string | undefined;
33
+ export type NotificationMethod = (...args: unknown[]) => Promise<void> | void;
34
+ export interface NotificationHandlerMetadata {
35
+ type: NotificationRegistrationType;
36
+ handler: NotificationMethod;
37
+ }
38
+ interface ConnectionHandlerMap {
39
+ completion: CompletionRequestHandler;
40
+ codeAction: CodeActionRequestHandler;
41
+ documentFormatting: DocumentFormattingRequestHandler;
42
+ }
43
+ type ConnectionHandlerKind = keyof ConnectionHandlerMap;
44
+ export type ConnectionHandlerMetadata = {
45
+ [K in ConnectionHandlerKind]: {
46
+ kind: K;
47
+ handler: ConnectionHandlerMap[K];
48
+ };
49
+ }[ConnectionHandlerKind];
50
+ type CompletionRequestHandler = (params: LSP.CompletionParams) => Promise<LSP.CompletionItem[] | LSP.CompletionList | undefined | null>;
51
+ type CodeActionRequestHandler = (params: LSP.CodeActionParams) => Promise<(LSP.Command | LSP.CodeAction)[] | undefined | null>;
52
+ type DocumentFormattingRequestHandler = (params: LSP.DocumentFormattingParams) => Promise<LSP.TextEdit[] | undefined | null>;
53
+ type AsyncNotificationHandler0 = MaybeAsync<() => void>;
54
+ type AsyncNotificationHandler<P> = MaybeAsync<(params: P) => void>;
55
+ type AsyncGenericNotificationHandler = MaybeAsync<LSP.GenericNotificationHandler>;
56
+ type AsyncStarNotificationHandler = MaybeAsync<LSP.StarNotificationHandler>;
57
+ export type ShutdownHandler = () => void | Promise<void>;
58
+ export type DecoratedLspServiceConstructor = Constructable<object> & {
59
+ [lspServiceConstructorMetadataKey]: true;
60
+ };
61
+ /**
62
+ * Returns if the given instance is of a class decorated as a language server service.
63
+ */
64
+ export declare function isLanguageServerServiceInstance(instance: unknown): instance is {
65
+ [lspServiceMetadataKey]: LspServiceInstanceMetadata;
66
+ };
67
+ /**
68
+ * Returns if the given class is decorated as a language server service.
69
+ */
70
+ export declare function isLanguageServerServiceConstructor(target: Constructable<unknown>): target is Constructable<unknown> & {
71
+ __isLanguageServerService__: true;
72
+ };
73
+ /**
74
+ * Gets the language server service metadata for the given instance.
75
+ */
76
+ export declare function getLanguageServerServiceMetadata(instance: unknown): LspServiceInstanceMetadata | undefined;
77
+ /**
78
+ * Decorates a class as being a service that participates in the language server
79
+ * lifecycle.
80
+ */
81
+ export declare function lspService(): ClassDecoratorFunction;
82
+ export interface CommandOptions {
83
+ minArgs?: number;
84
+ }
85
+ export type CommandMethod = <R>(...args: any[]) => HandlerResult<any, R>;
86
+ /**
87
+ * Decorator to mark a method as a handler for a specific command ID.
88
+ * @param commandId The command ID to handle.
89
+ */
90
+ export declare function command(commandId: CommandId, options?: CommandOptions): MethodDecoratorFunction<CommandMethod>;
91
+ /**
92
+ * Decorator to mark a method as an initialization handler.
93
+ */
94
+ export declare function initialize(): CompatibleMethodDecorator<InitializeHandler>;
95
+ /**
96
+ *
97
+ */
98
+ export declare function textDocumentEvent(event: TextDocumentEventName): CompatibleMethodDecorator<TextDocumentEventHandler>;
99
+ export declare function notification<R0>(type: LSP.ProtocolNotificationType0<R0>): CompatibleMethodDecorator<AsyncNotificationHandler0>;
100
+ export declare function notification<P, R0>(type: LSP.ProtocolNotificationType<P, R0>): CompatibleMethodDecorator<AsyncNotificationHandler<P>>;
101
+ export declare function notification(type: LSP.NotificationType0): CompatibleMethodDecorator<AsyncNotificationHandler0>;
102
+ export declare function notification<P>(type: LSP.NotificationType<P>): CompatibleMethodDecorator<AsyncNotificationHandler<P>>;
103
+ export declare function notification(type: string): CompatibleMethodDecorator<AsyncGenericNotificationHandler>;
104
+ export declare function notification(): CompatibleMethodDecorator<AsyncStarNotificationHandler>;
105
+ /**
106
+ * Marks a method as a handler for a specific completion request.
107
+ */
108
+ export declare function completionRequest(): MethodDecoratorFunction<CompletionRequestHandler>;
109
+ /**
110
+ * Marks a method as a handler for a specific code action request.
111
+ */
112
+ export declare function codeActionRequest(): MethodDecoratorFunction<CodeActionRequestHandler>;
113
+ /**
114
+ * Marks a method as a handler for a specific document formatting request.
115
+ */
116
+ export declare function documentFormattingRequest(): MethodDecoratorFunction<DocumentFormattingRequestHandler>;
117
+ /**
118
+ * Marks a method as a shutdown handler.
119
+ */
120
+ export declare function shutdown(): MethodDecoratorFunction<ShutdownHandler>;
121
+ export {};