naider 1.7.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 (359) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +884 -0
  3. package/SPEC-X.nx +276 -0
  4. package/SPEC.naide +431 -0
  5. package/bin/naide.js +519 -0
  6. package/examples/ai-app.naide +21 -0
  7. package/examples/ai-app.nx +21 -0
  8. package/examples/async.naide +50 -0
  9. package/examples/async.nx +40 -0
  10. package/examples/crud.naide +79 -0
  11. package/examples/crud.nx +64 -0
  12. package/examples/fullapp.naide +74 -0
  13. package/examples/fullapp.nx +74 -0
  14. package/examples/hello.naide +33 -0
  15. package/examples/hello.nx +29 -0
  16. package/examples/model.naide +44 -0
  17. package/examples/server.naide +28 -0
  18. package/examples/server.nx +27 -0
  19. package/examples/sql-app.naide +23 -0
  20. package/examples/sql-app.nx +23 -0
  21. package/examples/todo-api.naide +34 -0
  22. package/examples/todo-api.nx +31 -0
  23. package/lsp/server.js +172 -0
  24. package/package.json +56 -0
  25. package/src/generator.js +1313 -0
  26. package/src/index.js +41 -0
  27. package/src/lexer.js +402 -0
  28. package/src/parser.js +1671 -0
  29. package/src/preprocess.js +308 -0
  30. package/src/runtime.js +969 -0
  31. package/src/tokens.js +218 -0
  32. package/vscode-naide/README.md +38 -0
  33. package/vscode-naide/extension.js +41 -0
  34. package/vscode-naide/language-configuration-naide.json +32 -0
  35. package/vscode-naide/language-configuration-nx.json +32 -0
  36. package/vscode-naide/naide-lang-1.1.0.vsix +0 -0
  37. package/vscode-naide/node_modules/.bin/semver +16 -0
  38. package/vscode-naide/node_modules/.bin/semver.cmd +17 -0
  39. package/vscode-naide/node_modules/.bin/semver.ps1 +28 -0
  40. package/vscode-naide/node_modules/.package-lock.json +86 -0
  41. package/vscode-naide/node_modules/balanced-match/.github/FUNDING.yml +2 -0
  42. package/vscode-naide/node_modules/balanced-match/LICENSE.md +21 -0
  43. package/vscode-naide/node_modules/balanced-match/README.md +97 -0
  44. package/vscode-naide/node_modules/balanced-match/index.js +62 -0
  45. package/vscode-naide/node_modules/balanced-match/package.json +48 -0
  46. package/vscode-naide/node_modules/brace-expansion/.github/FUNDING.yml +2 -0
  47. package/vscode-naide/node_modules/brace-expansion/LICENSE +21 -0
  48. package/vscode-naide/node_modules/brace-expansion/README.md +157 -0
  49. package/vscode-naide/node_modules/brace-expansion/index.js +394 -0
  50. package/vscode-naide/node_modules/brace-expansion/package.json +49 -0
  51. package/vscode-naide/node_modules/minimatch/LICENSE +15 -0
  52. package/vscode-naide/node_modules/minimatch/README.md +296 -0
  53. package/vscode-naide/node_modules/minimatch/changelog.md +35 -0
  54. package/vscode-naide/node_modules/minimatch/lib/path.js +4 -0
  55. package/vscode-naide/node_modules/minimatch/minimatch.js +996 -0
  56. package/vscode-naide/node_modules/minimatch/package.json +35 -0
  57. package/vscode-naide/node_modules/semver/LICENSE +15 -0
  58. package/vscode-naide/node_modules/semver/README.md +680 -0
  59. package/vscode-naide/node_modules/semver/bin/semver.js +195 -0
  60. package/vscode-naide/node_modules/semver/classes/comparator.js +143 -0
  61. package/vscode-naide/node_modules/semver/classes/index.js +7 -0
  62. package/vscode-naide/node_modules/semver/classes/range.js +577 -0
  63. package/vscode-naide/node_modules/semver/classes/semver.js +350 -0
  64. package/vscode-naide/node_modules/semver/functions/clean.js +8 -0
  65. package/vscode-naide/node_modules/semver/functions/cmp.js +54 -0
  66. package/vscode-naide/node_modules/semver/functions/coerce.js +62 -0
  67. package/vscode-naide/node_modules/semver/functions/compare-build.js +9 -0
  68. package/vscode-naide/node_modules/semver/functions/compare-loose.js +5 -0
  69. package/vscode-naide/node_modules/semver/functions/compare.js +7 -0
  70. package/vscode-naide/node_modules/semver/functions/diff.js +60 -0
  71. package/vscode-naide/node_modules/semver/functions/eq.js +5 -0
  72. package/vscode-naide/node_modules/semver/functions/gt.js +5 -0
  73. package/vscode-naide/node_modules/semver/functions/gte.js +5 -0
  74. package/vscode-naide/node_modules/semver/functions/inc.js +21 -0
  75. package/vscode-naide/node_modules/semver/functions/lt.js +5 -0
  76. package/vscode-naide/node_modules/semver/functions/lte.js +5 -0
  77. package/vscode-naide/node_modules/semver/functions/major.js +5 -0
  78. package/vscode-naide/node_modules/semver/functions/minor.js +5 -0
  79. package/vscode-naide/node_modules/semver/functions/neq.js +5 -0
  80. package/vscode-naide/node_modules/semver/functions/parse.js +18 -0
  81. package/vscode-naide/node_modules/semver/functions/patch.js +5 -0
  82. package/vscode-naide/node_modules/semver/functions/prerelease.js +8 -0
  83. package/vscode-naide/node_modules/semver/functions/rcompare.js +5 -0
  84. package/vscode-naide/node_modules/semver/functions/rsort.js +5 -0
  85. package/vscode-naide/node_modules/semver/functions/satisfies.js +12 -0
  86. package/vscode-naide/node_modules/semver/functions/sort.js +5 -0
  87. package/vscode-naide/node_modules/semver/functions/truncate.js +48 -0
  88. package/vscode-naide/node_modules/semver/functions/valid.js +8 -0
  89. package/vscode-naide/node_modules/semver/index.js +93 -0
  90. package/vscode-naide/node_modules/semver/internal/constants.js +37 -0
  91. package/vscode-naide/node_modules/semver/internal/debug.js +11 -0
  92. package/vscode-naide/node_modules/semver/internal/identifiers.js +29 -0
  93. package/vscode-naide/node_modules/semver/internal/lrucache.js +42 -0
  94. package/vscode-naide/node_modules/semver/internal/parse-options.js +17 -0
  95. package/vscode-naide/node_modules/semver/internal/re.js +223 -0
  96. package/vscode-naide/node_modules/semver/package.json +78 -0
  97. package/vscode-naide/node_modules/semver/preload.js +4 -0
  98. package/vscode-naide/node_modules/semver/range.bnf +17 -0
  99. package/vscode-naide/node_modules/semver/ranges/gtr.js +6 -0
  100. package/vscode-naide/node_modules/semver/ranges/intersects.js +9 -0
  101. package/vscode-naide/node_modules/semver/ranges/ltr.js +6 -0
  102. package/vscode-naide/node_modules/semver/ranges/max-satisfying.js +27 -0
  103. package/vscode-naide/node_modules/semver/ranges/min-satisfying.js +26 -0
  104. package/vscode-naide/node_modules/semver/ranges/min-version.js +63 -0
  105. package/vscode-naide/node_modules/semver/ranges/outside.js +82 -0
  106. package/vscode-naide/node_modules/semver/ranges/simplify.js +49 -0
  107. package/vscode-naide/node_modules/semver/ranges/subset.js +249 -0
  108. package/vscode-naide/node_modules/semver/ranges/to-comparators.js +10 -0
  109. package/vscode-naide/node_modules/semver/ranges/valid.js +13 -0
  110. package/vscode-naide/node_modules/vscode-jsonrpc/License.txt +11 -0
  111. package/vscode-naide/node_modules/vscode-jsonrpc/README.md +69 -0
  112. package/vscode-naide/node_modules/vscode-jsonrpc/browser.d.ts +6 -0
  113. package/vscode-naide/node_modules/vscode-jsonrpc/browser.js +7 -0
  114. package/vscode-naide/node_modules/vscode-jsonrpc/lib/browser/main.d.ts +17 -0
  115. package/vscode-naide/node_modules/vscode-jsonrpc/lib/browser/main.js +76 -0
  116. package/vscode-naide/node_modules/vscode-jsonrpc/lib/browser/ril.d.ts +12 -0
  117. package/vscode-naide/node_modules/vscode-jsonrpc/lib/browser/ril.js +156 -0
  118. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/api.d.ts +14 -0
  119. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/api.js +81 -0
  120. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/cancellation.d.ts +32 -0
  121. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/cancellation.js +96 -0
  122. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/connection.d.ts +358 -0
  123. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/connection.js +1212 -0
  124. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/disposable.d.ts +9 -0
  125. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/disposable.js +16 -0
  126. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/encoding.d.ts +52 -0
  127. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/encoding.js +70 -0
  128. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/events.d.ts +39 -0
  129. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/events.js +128 -0
  130. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/is.d.ts +7 -0
  131. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/is.js +35 -0
  132. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/linkedMap.d.ts +53 -0
  133. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/linkedMap.js +398 -0
  134. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/messageBuffer.d.ts +18 -0
  135. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/messageBuffer.js +152 -0
  136. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/messageReader.d.ts +77 -0
  137. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/messageReader.js +197 -0
  138. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/messageWriter.d.ts +60 -0
  139. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/messageWriter.js +115 -0
  140. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/messages.d.ts +369 -0
  141. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/messages.js +306 -0
  142. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/ral.d.ts +74 -0
  143. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/ral.js +23 -0
  144. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/semaphore.d.ts +10 -0
  145. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/semaphore.js +68 -0
  146. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/sharedArrayCancellation.d.ts +15 -0
  147. package/vscode-naide/node_modules/vscode-jsonrpc/lib/common/sharedArrayCancellation.js +76 -0
  148. package/vscode-naide/node_modules/vscode-jsonrpc/lib/node/main.d.ts +63 -0
  149. package/vscode-naide/node_modules/vscode-jsonrpc/lib/node/main.js +257 -0
  150. package/vscode-naide/node_modules/vscode-jsonrpc/lib/node/ril.d.ts +13 -0
  151. package/vscode-naide/node_modules/vscode-jsonrpc/lib/node/ril.js +161 -0
  152. package/vscode-naide/node_modules/vscode-jsonrpc/node.cmd +5 -0
  153. package/vscode-naide/node_modules/vscode-jsonrpc/node.d.ts +6 -0
  154. package/vscode-naide/node_modules/vscode-jsonrpc/node.js +7 -0
  155. package/vscode-naide/node_modules/vscode-jsonrpc/package.json +45 -0
  156. package/vscode-naide/node_modules/vscode-jsonrpc/thirdpartynotices.txt +16 -0
  157. package/vscode-naide/node_modules/vscode-jsonrpc/typings/thenable.d.ts +5 -0
  158. package/vscode-naide/node_modules/vscode-languageclient/License.txt +11 -0
  159. package/vscode-naide/node_modules/vscode-languageclient/README.md +17 -0
  160. package/vscode-naide/node_modules/vscode-languageclient/browser.d.ts +6 -0
  161. package/vscode-naide/node_modules/vscode-languageclient/browser.js +7 -0
  162. package/vscode-naide/node_modules/vscode-languageclient/lib/browser/main.d.ts +8 -0
  163. package/vscode-naide/node_modules/vscode-languageclient/lib/browser/main.js +37 -0
  164. package/vscode-naide/node_modules/vscode-languageclient/lib/common/api.d.ts +36 -0
  165. package/vscode-naide/node_modules/vscode-languageclient/lib/common/api.js +27 -0
  166. package/vscode-naide/node_modules/vscode-languageclient/lib/common/callHierarchy.d.ts +37 -0
  167. package/vscode-naide/node_modules/vscode-languageclient/lib/common/callHierarchy.js +97 -0
  168. package/vscode-naide/node_modules/vscode-languageclient/lib/common/client.d.ts +476 -0
  169. package/vscode-naide/node_modules/vscode-languageclient/lib/common/client.js +1600 -0
  170. package/vscode-naide/node_modules/vscode-languageclient/lib/common/codeAction.d.ts +19 -0
  171. package/vscode-naide/node_modules/vscode-languageclient/lib/common/codeAction.js +99 -0
  172. package/vscode-naide/node_modules/vscode-languageclient/lib/common/codeConverter.d.ts +78 -0
  173. package/vscode-naide/node_modules/vscode-languageclient/lib/common/codeConverter.js +876 -0
  174. package/vscode-naide/node_modules/vscode-languageclient/lib/common/codeLens.d.ts +23 -0
  175. package/vscode-naide/node_modules/vscode-languageclient/lib/common/codeLens.js +78 -0
  176. package/vscode-naide/node_modules/vscode-languageclient/lib/common/colorProvider.d.ts +25 -0
  177. package/vscode-naide/node_modules/vscode-languageclient/lib/common/colorProvider.js +74 -0
  178. package/vscode-naide/node_modules/vscode-languageclient/lib/common/completion.d.ts +20 -0
  179. package/vscode-naide/node_modules/vscode-languageclient/lib/common/completion.js +126 -0
  180. package/vscode-naide/node_modules/vscode-languageclient/lib/common/configuration.d.ts +69 -0
  181. package/vscode-naide/node_modules/vscode-languageclient/lib/common/configuration.js +209 -0
  182. package/vscode-naide/node_modules/vscode-languageclient/lib/common/declaration.d.ts +16 -0
  183. package/vscode-naide/node_modules/vscode-languageclient/lib/common/declaration.js +54 -0
  184. package/vscode-naide/node_modules/vscode-languageclient/lib/common/definition.d.ts +16 -0
  185. package/vscode-naide/node_modules/vscode-languageclient/lib/common/definition.js +55 -0
  186. package/vscode-naide/node_modules/vscode-languageclient/lib/common/diagnostic.d.ts +122 -0
  187. package/vscode-naide/node_modules/vscode-languageclient/lib/common/diagnostic.js +814 -0
  188. package/vscode-naide/node_modules/vscode-languageclient/lib/common/documentHighlight.d.ts +15 -0
  189. package/vscode-naide/node_modules/vscode-languageclient/lib/common/documentHighlight.js +50 -0
  190. package/vscode-naide/node_modules/vscode-languageclient/lib/common/documentLink.d.ts +19 -0
  191. package/vscode-naide/node_modules/vscode-languageclient/lib/common/documentLink.js +71 -0
  192. package/vscode-naide/node_modules/vscode-languageclient/lib/common/documentSymbol.d.ts +17 -0
  193. package/vscode-naide/node_modules/vscode-languageclient/lib/common/documentSymbol.js +104 -0
  194. package/vscode-naide/node_modules/vscode-languageclient/lib/common/executeCommand.d.ts +21 -0
  195. package/vscode-naide/node_modules/vscode-languageclient/lib/common/executeCommand.js +72 -0
  196. package/vscode-naide/node_modules/vscode-languageclient/lib/common/features.d.ts +418 -0
  197. package/vscode-naide/node_modules/vscode-languageclient/lib/common/features.js +291 -0
  198. package/vscode-naide/node_modules/vscode-languageclient/lib/common/fileOperations.d.ts +116 -0
  199. package/vscode-naide/node_modules/vscode-languageclient/lib/common/fileOperations.js +333 -0
  200. package/vscode-naide/node_modules/vscode-languageclient/lib/common/fileSystemWatcher.d.ts +18 -0
  201. package/vscode-naide/node_modules/vscode-languageclient/lib/common/fileSystemWatcher.js +95 -0
  202. package/vscode-naide/node_modules/vscode-languageclient/lib/common/foldingRange.d.ts +19 -0
  203. package/vscode-naide/node_modules/vscode-languageclient/lib/common/foldingRange.js +65 -0
  204. package/vscode-naide/node_modules/vscode-languageclient/lib/common/formatting.d.ts +39 -0
  205. package/vscode-naide/node_modules/vscode-languageclient/lib/common/formatting.js +182 -0
  206. package/vscode-naide/node_modules/vscode-languageclient/lib/common/hover.d.ts +16 -0
  207. package/vscode-naide/node_modules/vscode-languageclient/lib/common/hover.js +58 -0
  208. package/vscode-naide/node_modules/vscode-languageclient/lib/common/implementation.d.ts +16 -0
  209. package/vscode-naide/node_modules/vscode-languageclient/lib/common/implementation.js +54 -0
  210. package/vscode-naide/node_modules/vscode-languageclient/lib/common/inlayHint.d.ts +20 -0
  211. package/vscode-naide/node_modules/vscode-languageclient/lib/common/inlayHint.js +92 -0
  212. package/vscode-naide/node_modules/vscode-languageclient/lib/common/inlineCompletion.d.ts +18 -0
  213. package/vscode-naide/node_modules/vscode-languageclient/lib/common/inlineCompletion.js +54 -0
  214. package/vscode-naide/node_modules/vscode-languageclient/lib/common/inlineValue.d.ts +18 -0
  215. package/vscode-naide/node_modules/vscode-languageclient/lib/common/inlineValue.js +65 -0
  216. package/vscode-naide/node_modules/vscode-languageclient/lib/common/linkedEditingRange.d.ts +21 -0
  217. package/vscode-naide/node_modules/vscode-languageclient/lib/common/linkedEditingRange.js +53 -0
  218. package/vscode-naide/node_modules/vscode-languageclient/lib/common/notebook.d.ts +96 -0
  219. package/vscode-naide/node_modules/vscode-languageclient/lib/common/notebook.js +851 -0
  220. package/vscode-naide/node_modules/vscode-languageclient/lib/common/progress.d.ts +11 -0
  221. package/vscode-naide/node_modules/vscode-languageclient/lib/common/progress.js +44 -0
  222. package/vscode-naide/node_modules/vscode-languageclient/lib/common/progressPart.d.ts +24 -0
  223. package/vscode-naide/node_modules/vscode-languageclient/lib/common/progressPart.js +96 -0
  224. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolCallHierarchyItem.d.ts +6 -0
  225. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolCallHierarchyItem.js +16 -0
  226. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolCodeAction.d.ts +6 -0
  227. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolCodeAction.js +14 -0
  228. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolCodeLens.d.ts +5 -0
  229. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolCodeLens.js +13 -0
  230. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolCompletionItem.d.ts +11 -0
  231. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolCompletionItem.js +13 -0
  232. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolConverter.d.ts +167 -0
  233. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolConverter.js +1134 -0
  234. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolDiagnostic.d.ts +18 -0
  235. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolDiagnostic.js +25 -0
  236. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolDocumentLink.d.ts +5 -0
  237. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolDocumentLink.js +13 -0
  238. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolInlayHint.d.ts +5 -0
  239. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolInlayHint.js +13 -0
  240. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolTypeHierarchyItem.d.ts +6 -0
  241. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolTypeHierarchyItem.js +16 -0
  242. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolWorkspaceSymbol.d.ts +7 -0
  243. package/vscode-naide/node_modules/vscode-languageclient/lib/common/protocolWorkspaceSymbol.js +18 -0
  244. package/vscode-naide/node_modules/vscode-languageclient/lib/common/reference.d.ts +20 -0
  245. package/vscode-naide/node_modules/vscode-languageclient/lib/common/reference.js +53 -0
  246. package/vscode-naide/node_modules/vscode-languageclient/lib/common/rename.d.ts +27 -0
  247. package/vscode-naide/node_modules/vscode-languageclient/lib/common/rename.js +113 -0
  248. package/vscode-naide/node_modules/vscode-languageclient/lib/common/selectionRange.d.ts +16 -0
  249. package/vscode-naide/node_modules/vscode-languageclient/lib/common/selectionRange.js +57 -0
  250. package/vscode-naide/node_modules/vscode-languageclient/lib/common/semanticTokens.d.ts +33 -0
  251. package/vscode-naide/node_modules/vscode-languageclient/lib/common/semanticTokens.js +179 -0
  252. package/vscode-naide/node_modules/vscode-languageclient/lib/common/signatureHelp.d.ts +16 -0
  253. package/vscode-naide/node_modules/vscode-languageclient/lib/common/signatureHelp.js +71 -0
  254. package/vscode-naide/node_modules/vscode-languageclient/lib/common/textSynchronization.d.ts +101 -0
  255. package/vscode-naide/node_modules/vscode-languageclient/lib/common/textSynchronization.js +402 -0
  256. package/vscode-naide/node_modules/vscode-languageclient/lib/common/typeDefinition.d.ts +16 -0
  257. package/vscode-naide/node_modules/vscode-languageclient/lib/common/typeDefinition.js +55 -0
  258. package/vscode-naide/node_modules/vscode-languageclient/lib/common/typeHierarchy.d.ts +31 -0
  259. package/vscode-naide/node_modules/vscode-languageclient/lib/common/typeHierarchy.js +96 -0
  260. package/vscode-naide/node_modules/vscode-languageclient/lib/common/utils/async.d.ts +41 -0
  261. package/vscode-naide/node_modules/vscode-languageclient/lib/common/utils/async.js +276 -0
  262. package/vscode-naide/node_modules/vscode-languageclient/lib/common/utils/is.d.ts +12 -0
  263. package/vscode-naide/node_modules/vscode-languageclient/lib/common/utils/is.js +57 -0
  264. package/vscode-naide/node_modules/vscode-languageclient/lib/common/utils/uuid.d.ts +22 -0
  265. package/vscode-naide/node_modules/vscode-languageclient/lib/common/utils/uuid.js +97 -0
  266. package/vscode-naide/node_modules/vscode-languageclient/lib/common/workspaceFolder.d.ts +30 -0
  267. package/vscode-naide/node_modules/vscode-languageclient/lib/common/workspaceFolder.js +148 -0
  268. package/vscode-naide/node_modules/vscode-languageclient/lib/common/workspaceSymbol.d.ts +19 -0
  269. package/vscode-naide/node_modules/vscode-languageclient/lib/common/workspaceSymbol.js +79 -0
  270. package/vscode-naide/node_modules/vscode-languageclient/lib/node/main.d.ts +100 -0
  271. package/vscode-naide/node_modules/vscode-languageclient/lib/node/main.js +570 -0
  272. package/vscode-naide/node_modules/vscode-languageclient/lib/node/processes.d.ts +6 -0
  273. package/vscode-naide/node_modules/vscode-languageclient/lib/node/processes.js +47 -0
  274. package/vscode-naide/node_modules/vscode-languageclient/lib/node/terminateProcess.sh +16 -0
  275. package/vscode-naide/node_modules/vscode-languageclient/node.cmd +5 -0
  276. package/vscode-naide/node_modules/vscode-languageclient/node.d.ts +6 -0
  277. package/vscode-naide/node_modules/vscode-languageclient/node.js +7 -0
  278. package/vscode-naide/node_modules/vscode-languageclient/package.json +50 -0
  279. package/vscode-naide/node_modules/vscode-languageserver-protocol/License.txt +11 -0
  280. package/vscode-naide/node_modules/vscode-languageserver-protocol/README.md +16 -0
  281. package/vscode-naide/node_modules/vscode-languageserver-protocol/browser.d.ts +6 -0
  282. package/vscode-naide/node_modules/vscode-languageserver-protocol/browser.js +7 -0
  283. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/browser/main.d.ts +4 -0
  284. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/browser/main.js +28 -0
  285. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/api.d.ts +58 -0
  286. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/api.js +77 -0
  287. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/connection.d.ts +187 -0
  288. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/connection.js +15 -0
  289. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/messages.d.ts +51 -0
  290. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/messages.js +44 -0
  291. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.$.d.ts +1 -0
  292. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.$.js +43 -0
  293. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.callHierarchy.d.ts +86 -0
  294. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.callHierarchy.js +42 -0
  295. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.colorProvider.d.ts +66 -0
  296. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.colorProvider.js +32 -0
  297. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.configuration.d.ts +35 -0
  298. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.configuration.js +24 -0
  299. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.d.ts +3252 -0
  300. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.declaration.d.ts +37 -0
  301. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.declaration.js +22 -0
  302. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.diagnostic.d.ts +341 -0
  303. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.diagnostic.js +74 -0
  304. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.fileOperations.d.ts +306 -0
  305. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.fileOperations.js +101 -0
  306. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.foldingRange.d.ts +109 -0
  307. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.foldingRange.js +30 -0
  308. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.implementation.d.ts +38 -0
  309. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.implementation.js +21 -0
  310. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.inlayHint.d.ts +110 -0
  311. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.inlayHint.js +43 -0
  312. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.inlineCompletion.d.ts +57 -0
  313. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.inlineCompletion.js +22 -0
  314. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.inlineValue.d.ts +86 -0
  315. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.inlineValue.js +30 -0
  316. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.js +943 -0
  317. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.linkedEditingRange.d.ts +52 -0
  318. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.linkedEditingRange.js +19 -0
  319. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.moniker.d.ts +106 -0
  320. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.moniker.js +68 -0
  321. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.notebook.d.ts +400 -0
  322. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.notebook.js +214 -0
  323. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.progress.d.ts +107 -0
  324. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.progress.js +37 -0
  325. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.selectionRange.d.ts +41 -0
  326. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.selectionRange.js +20 -0
  327. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.semanticTokens.d.ts +223 -0
  328. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.semanticTokens.js +57 -0
  329. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.showDocument.d.ts +72 -0
  330. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.showDocument.js +22 -0
  331. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.typeDefinition.d.ts +38 -0
  332. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.typeDefinition.js +21 -0
  333. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.typeHierarchy.d.ts +83 -0
  334. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.typeHierarchy.js +42 -0
  335. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.workspaceFolder.d.ts +74 -0
  336. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/protocol.workspaceFolder.js +27 -0
  337. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/utils/is.d.ts +9 -0
  338. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/common/utils/is.js +46 -0
  339. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/node/main.d.ts +6 -0
  340. package/vscode-naide/node_modules/vscode-languageserver-protocol/lib/node/main.js +28 -0
  341. package/vscode-naide/node_modules/vscode-languageserver-protocol/metaModel.schema.json +783 -0
  342. package/vscode-naide/node_modules/vscode-languageserver-protocol/node.cmd +5 -0
  343. package/vscode-naide/node_modules/vscode-languageserver-protocol/node.d.ts +6 -0
  344. package/vscode-naide/node_modules/vscode-languageserver-protocol/node.js +7 -0
  345. package/vscode-naide/node_modules/vscode-languageserver-protocol/package.json +45 -0
  346. package/vscode-naide/node_modules/vscode-languageserver-protocol/thirdpartynotices.txt +31 -0
  347. package/vscode-naide/node_modules/vscode-languageserver-types/License.txt +11 -0
  348. package/vscode-naide/node_modules/vscode-languageserver-types/README.md +17 -0
  349. package/vscode-naide/node_modules/vscode-languageserver-types/lib/esm/main.d.ts +3139 -0
  350. package/vscode-naide/node_modules/vscode-languageserver-types/lib/esm/main.js +2222 -0
  351. package/vscode-naide/node_modules/vscode-languageserver-types/lib/esm/package.json +3 -0
  352. package/vscode-naide/node_modules/vscode-languageserver-types/lib/umd/main.d.ts +3139 -0
  353. package/vscode-naide/node_modules/vscode-languageserver-types/lib/umd/main.js +2272 -0
  354. package/vscode-naide/node_modules/vscode-languageserver-types/package.json +38 -0
  355. package/vscode-naide/node_modules/vscode-languageserver-types/thirdpartynotices.txt +16 -0
  356. package/vscode-naide/package-lock.json +96 -0
  357. package/vscode-naide/package.json +59 -0
  358. package/vscode-naide/syntaxes/naide.tmLanguage.json +194 -0
  359. package/vscode-naide/syntaxes/naidex.tmLanguage.json +287 -0
@@ -0,0 +1,814 @@
1
+ "use strict";
2
+ /* --------------------------------------------------------------------------------------------
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License. See License.txt in the project root for license information.
5
+ * ------------------------------------------------------------------------------------------ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.DiagnosticFeature = exports.DiagnosticPullMode = exports.vsdiag = void 0;
8
+ const minimatch = require("minimatch");
9
+ const vscode_1 = require("vscode");
10
+ const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
11
+ const uuid_1 = require("./utils/uuid");
12
+ const features_1 = require("./features");
13
+ function ensure(target, key) {
14
+ if (target[key] === void 0) {
15
+ target[key] = {};
16
+ }
17
+ return target[key];
18
+ }
19
+ var vsdiag;
20
+ (function (vsdiag) {
21
+ let DocumentDiagnosticReportKind;
22
+ (function (DocumentDiagnosticReportKind) {
23
+ DocumentDiagnosticReportKind["full"] = "full";
24
+ DocumentDiagnosticReportKind["unChanged"] = "unChanged";
25
+ })(DocumentDiagnosticReportKind = vsdiag.DocumentDiagnosticReportKind || (vsdiag.DocumentDiagnosticReportKind = {}));
26
+ })(vsdiag || (exports.vsdiag = vsdiag = {}));
27
+ var DiagnosticPullMode;
28
+ (function (DiagnosticPullMode) {
29
+ DiagnosticPullMode["onType"] = "onType";
30
+ DiagnosticPullMode["onSave"] = "onSave";
31
+ })(DiagnosticPullMode || (exports.DiagnosticPullMode = DiagnosticPullMode = {}));
32
+ var RequestStateKind;
33
+ (function (RequestStateKind) {
34
+ RequestStateKind["active"] = "open";
35
+ RequestStateKind["reschedule"] = "reschedule";
36
+ RequestStateKind["outDated"] = "drop";
37
+ })(RequestStateKind || (RequestStateKind = {}));
38
+ /**
39
+ * Manages the open tabs. We don't directly use the tab API since for
40
+ * diagnostics we need to de-dupe tabs that show the same resources since
41
+ * we pull on the model not the UI.
42
+ */
43
+ class Tabs {
44
+ constructor() {
45
+ this.open = new Set();
46
+ this._onOpen = new vscode_1.EventEmitter();
47
+ this._onClose = new vscode_1.EventEmitter();
48
+ Tabs.fillTabResources(this.open);
49
+ const openTabsHandler = (event) => {
50
+ if (event.closed.length === 0 && event.opened.length === 0) {
51
+ return;
52
+ }
53
+ const oldTabs = this.open;
54
+ const currentTabs = new Set();
55
+ Tabs.fillTabResources(currentTabs);
56
+ const closed = new Set();
57
+ const opened = new Set(currentTabs);
58
+ for (const tab of oldTabs.values()) {
59
+ if (currentTabs.has(tab)) {
60
+ opened.delete(tab);
61
+ }
62
+ else {
63
+ closed.add(tab);
64
+ }
65
+ }
66
+ this.open = currentTabs;
67
+ if (closed.size > 0) {
68
+ const toFire = new Set();
69
+ for (const item of closed) {
70
+ toFire.add(vscode_1.Uri.parse(item));
71
+ }
72
+ this._onClose.fire(toFire);
73
+ }
74
+ if (opened.size > 0) {
75
+ const toFire = new Set();
76
+ for (const item of opened) {
77
+ toFire.add(vscode_1.Uri.parse(item));
78
+ }
79
+ this._onOpen.fire(toFire);
80
+ }
81
+ };
82
+ if (vscode_1.window.tabGroups.onDidChangeTabs !== undefined) {
83
+ this.disposable = vscode_1.window.tabGroups.onDidChangeTabs(openTabsHandler);
84
+ }
85
+ else {
86
+ this.disposable = { dispose: () => { } };
87
+ }
88
+ }
89
+ get onClose() {
90
+ return this._onClose.event;
91
+ }
92
+ get onOpen() {
93
+ return this._onOpen.event;
94
+ }
95
+ dispose() {
96
+ this.disposable.dispose();
97
+ }
98
+ isActive(document) {
99
+ return document instanceof vscode_1.Uri
100
+ ? vscode_1.window.activeTextEditor?.document.uri === document
101
+ : vscode_1.window.activeTextEditor?.document === document;
102
+ }
103
+ isVisible(document) {
104
+ const uri = document instanceof vscode_1.Uri ? document : document.uri;
105
+ return this.open.has(uri.toString());
106
+ }
107
+ getTabResources() {
108
+ const result = new Set();
109
+ Tabs.fillTabResources(new Set(), result);
110
+ return result;
111
+ }
112
+ static fillTabResources(strings, uris) {
113
+ const seen = strings ?? new Set();
114
+ for (const group of vscode_1.window.tabGroups.all) {
115
+ for (const tab of group.tabs) {
116
+ const input = tab.input;
117
+ let uri;
118
+ if (input instanceof vscode_1.TabInputText) {
119
+ uri = input.uri;
120
+ }
121
+ else if (input instanceof vscode_1.TabInputTextDiff) {
122
+ uri = input.modified;
123
+ }
124
+ else if (input instanceof vscode_1.TabInputCustom) {
125
+ uri = input.uri;
126
+ }
127
+ if (uri !== undefined && !seen.has(uri.toString())) {
128
+ seen.add(uri.toString());
129
+ uris !== undefined && uris.add(uri);
130
+ }
131
+ }
132
+ }
133
+ }
134
+ }
135
+ var PullState;
136
+ (function (PullState) {
137
+ PullState[PullState["document"] = 1] = "document";
138
+ PullState[PullState["workspace"] = 2] = "workspace";
139
+ })(PullState || (PullState = {}));
140
+ var DocumentOrUri;
141
+ (function (DocumentOrUri) {
142
+ function asKey(document) {
143
+ return document instanceof vscode_1.Uri ? document.toString() : document.uri.toString();
144
+ }
145
+ DocumentOrUri.asKey = asKey;
146
+ })(DocumentOrUri || (DocumentOrUri = {}));
147
+ class DocumentPullStateTracker {
148
+ constructor() {
149
+ this.documentPullStates = new Map();
150
+ this.workspacePullStates = new Map();
151
+ }
152
+ track(kind, document, arg1) {
153
+ const states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates;
154
+ const [key, uri, version] = document instanceof vscode_1.Uri
155
+ ? [document.toString(), document, arg1]
156
+ : [document.uri.toString(), document.uri, document.version];
157
+ let state = states.get(key);
158
+ if (state === undefined) {
159
+ state = { document: uri, pulledVersion: version, resultId: undefined };
160
+ states.set(key, state);
161
+ }
162
+ return state;
163
+ }
164
+ update(kind, document, arg1, arg2) {
165
+ const states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates;
166
+ const [key, uri, version, resultId] = document instanceof vscode_1.Uri
167
+ ? [document.toString(), document, arg1, arg2]
168
+ : [document.uri.toString(), document.uri, document.version, arg1];
169
+ let state = states.get(key);
170
+ if (state === undefined) {
171
+ state = { document: uri, pulledVersion: version, resultId };
172
+ states.set(key, state);
173
+ }
174
+ else {
175
+ state.pulledVersion = version;
176
+ state.resultId = resultId;
177
+ }
178
+ }
179
+ unTrack(kind, document) {
180
+ const key = DocumentOrUri.asKey(document);
181
+ const states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates;
182
+ states.delete(key);
183
+ }
184
+ tracks(kind, document) {
185
+ const key = DocumentOrUri.asKey(document);
186
+ const states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates;
187
+ return states.has(key);
188
+ }
189
+ getResultId(kind, document) {
190
+ const key = DocumentOrUri.asKey(document);
191
+ const states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates;
192
+ return states.get(key)?.resultId;
193
+ }
194
+ getAllResultIds() {
195
+ const result = [];
196
+ for (let [uri, value] of this.workspacePullStates) {
197
+ if (this.documentPullStates.has(uri)) {
198
+ value = this.documentPullStates.get(uri);
199
+ }
200
+ if (value.resultId !== undefined) {
201
+ result.push({ uri, value: value.resultId });
202
+ }
203
+ }
204
+ return result;
205
+ }
206
+ }
207
+ class DiagnosticRequestor {
208
+ constructor(client, tabs, options) {
209
+ this.client = client;
210
+ this.tabs = tabs;
211
+ this.options = options;
212
+ this.isDisposed = false;
213
+ this.onDidChangeDiagnosticsEmitter = new vscode_1.EventEmitter();
214
+ this.provider = this.createProvider();
215
+ this.diagnostics = vscode_1.languages.createDiagnosticCollection(options.identifier);
216
+ this.openRequests = new Map();
217
+ this.documentStates = new DocumentPullStateTracker();
218
+ this.workspaceErrorCounter = 0;
219
+ }
220
+ knows(kind, document) {
221
+ const uri = document instanceof vscode_1.Uri ? document : document.uri;
222
+ return this.documentStates.tracks(kind, document) || this.openRequests.has(uri.toString());
223
+ }
224
+ forget(kind, document) {
225
+ this.documentStates.unTrack(kind, document);
226
+ }
227
+ pull(document, cb) {
228
+ if (this.isDisposed) {
229
+ return;
230
+ }
231
+ const uri = document instanceof vscode_1.Uri ? document : document.uri;
232
+ this.pullAsync(document).then(() => {
233
+ if (cb) {
234
+ cb();
235
+ }
236
+ }, (error) => {
237
+ this.client.error(`Document pull failed for text document ${uri.toString()}`, error, false);
238
+ });
239
+ }
240
+ async pullAsync(document, version) {
241
+ if (this.isDisposed) {
242
+ return;
243
+ }
244
+ const isUri = document instanceof vscode_1.Uri;
245
+ const uri = isUri ? document : document.uri;
246
+ const key = uri.toString();
247
+ version = isUri ? version : document.version;
248
+ const currentRequestState = this.openRequests.get(key);
249
+ const documentState = isUri
250
+ ? this.documentStates.track(PullState.document, document, version)
251
+ : this.documentStates.track(PullState.document, document);
252
+ if (currentRequestState === undefined) {
253
+ const tokenSource = new vscode_1.CancellationTokenSource();
254
+ this.openRequests.set(key, { state: RequestStateKind.active, document: document, version: version, tokenSource });
255
+ let report;
256
+ let afterState;
257
+ try {
258
+ report = await this.provider.provideDiagnostics(document, documentState.resultId, tokenSource.token) ?? { kind: vsdiag.DocumentDiagnosticReportKind.full, items: [] };
259
+ }
260
+ catch (error) {
261
+ if (error instanceof features_1.LSPCancellationError && vscode_languageserver_protocol_1.DiagnosticServerCancellationData.is(error.data) && error.data.retriggerRequest === false) {
262
+ afterState = { state: RequestStateKind.outDated, document };
263
+ }
264
+ if (afterState === undefined && error instanceof vscode_1.CancellationError) {
265
+ afterState = { state: RequestStateKind.reschedule, document };
266
+ }
267
+ else {
268
+ throw error;
269
+ }
270
+ }
271
+ afterState = afterState ?? this.openRequests.get(key);
272
+ if (afterState === undefined) {
273
+ // This shouldn't happen. Log it
274
+ this.client.error(`Lost request state in diagnostic pull model. Clearing diagnostics for ${key}`);
275
+ this.diagnostics.delete(uri);
276
+ return;
277
+ }
278
+ this.openRequests.delete(key);
279
+ if (!this.tabs.isVisible(document)) {
280
+ this.documentStates.unTrack(PullState.document, document);
281
+ return;
282
+ }
283
+ if (afterState.state === RequestStateKind.outDated) {
284
+ return;
285
+ }
286
+ // report is only undefined if the request has thrown.
287
+ if (report !== undefined) {
288
+ if (report.kind === vsdiag.DocumentDiagnosticReportKind.full) {
289
+ this.diagnostics.set(uri, report.items);
290
+ }
291
+ documentState.pulledVersion = version;
292
+ documentState.resultId = report.resultId;
293
+ }
294
+ if (afterState.state === RequestStateKind.reschedule) {
295
+ this.pull(document);
296
+ }
297
+ }
298
+ else {
299
+ if (currentRequestState.state === RequestStateKind.active) {
300
+ // Cancel the current request and reschedule a new one when the old one returned.
301
+ currentRequestState.tokenSource.cancel();
302
+ this.openRequests.set(key, { state: RequestStateKind.reschedule, document: currentRequestState.document });
303
+ }
304
+ else if (currentRequestState.state === RequestStateKind.outDated) {
305
+ this.openRequests.set(key, { state: RequestStateKind.reschedule, document: currentRequestState.document });
306
+ }
307
+ }
308
+ }
309
+ forgetDocument(document) {
310
+ const uri = document instanceof vscode_1.Uri ? document : document.uri;
311
+ const key = uri.toString();
312
+ const request = this.openRequests.get(key);
313
+ if (this.options.workspaceDiagnostics) {
314
+ // If we run workspace diagnostic pull a last time for the diagnostics
315
+ // and the rely on getting them from the workspace result.
316
+ if (request !== undefined) {
317
+ this.openRequests.set(key, { state: RequestStateKind.reschedule, document: document });
318
+ }
319
+ else {
320
+ this.pull(document, () => {
321
+ this.forget(PullState.document, document);
322
+ });
323
+ }
324
+ }
325
+ else {
326
+ // We have normal pull or inter file dependencies. In this case we
327
+ // clear the diagnostics (to have the same start as after startup).
328
+ // We also cancel outstanding requests.
329
+ if (request !== undefined) {
330
+ if (request.state === RequestStateKind.active) {
331
+ request.tokenSource.cancel();
332
+ }
333
+ this.openRequests.set(key, { state: RequestStateKind.outDated, document: document });
334
+ }
335
+ this.diagnostics.delete(uri);
336
+ this.forget(PullState.document, document);
337
+ }
338
+ }
339
+ pullWorkspace() {
340
+ if (this.isDisposed) {
341
+ return;
342
+ }
343
+ this.pullWorkspaceAsync().then(() => {
344
+ this.workspaceTimeout = (0, vscode_languageserver_protocol_1.RAL)().timer.setTimeout(() => {
345
+ this.pullWorkspace();
346
+ }, 2000);
347
+ }, (error) => {
348
+ if (!(error instanceof features_1.LSPCancellationError) && !vscode_languageserver_protocol_1.DiagnosticServerCancellationData.is(error.data)) {
349
+ this.client.error(`Workspace diagnostic pull failed.`, error, false);
350
+ this.workspaceErrorCounter++;
351
+ }
352
+ if (this.workspaceErrorCounter <= 5) {
353
+ this.workspaceTimeout = (0, vscode_languageserver_protocol_1.RAL)().timer.setTimeout(() => {
354
+ this.pullWorkspace();
355
+ }, 2000);
356
+ }
357
+ });
358
+ }
359
+ async pullWorkspaceAsync() {
360
+ if (!this.provider.provideWorkspaceDiagnostics || this.isDisposed) {
361
+ return;
362
+ }
363
+ if (this.workspaceCancellation !== undefined) {
364
+ this.workspaceCancellation.cancel();
365
+ this.workspaceCancellation = undefined;
366
+ }
367
+ this.workspaceCancellation = new vscode_1.CancellationTokenSource();
368
+ const previousResultIds = this.documentStates.getAllResultIds().map((item) => {
369
+ return {
370
+ uri: this.client.protocol2CodeConverter.asUri(item.uri),
371
+ value: item.value
372
+ };
373
+ });
374
+ await this.provider.provideWorkspaceDiagnostics(previousResultIds, this.workspaceCancellation.token, (chunk) => {
375
+ if (!chunk || this.isDisposed) {
376
+ return;
377
+ }
378
+ for (const item of chunk.items) {
379
+ if (item.kind === vsdiag.DocumentDiagnosticReportKind.full) {
380
+ // Favour document pull result over workspace results. So skip if it is tracked
381
+ // as a document result.
382
+ if (!this.documentStates.tracks(PullState.document, item.uri)) {
383
+ this.diagnostics.set(item.uri, item.items);
384
+ }
385
+ }
386
+ this.documentStates.update(PullState.workspace, item.uri, item.version ?? undefined, item.resultId);
387
+ }
388
+ });
389
+ }
390
+ createProvider() {
391
+ const result = {
392
+ onDidChangeDiagnostics: this.onDidChangeDiagnosticsEmitter.event,
393
+ provideDiagnostics: (document, previousResultId, token) => {
394
+ const provideDiagnostics = (document, previousResultId, token) => {
395
+ const params = {
396
+ identifier: this.options.identifier,
397
+ textDocument: { uri: this.client.code2ProtocolConverter.asUri(document instanceof vscode_1.Uri ? document : document.uri) },
398
+ previousResultId: previousResultId
399
+ };
400
+ if (this.isDisposed === true || !this.client.isRunning()) {
401
+ return { kind: vsdiag.DocumentDiagnosticReportKind.full, items: [] };
402
+ }
403
+ return this.client.sendRequest(vscode_languageserver_protocol_1.DocumentDiagnosticRequest.type, params, token).then(async (result) => {
404
+ if (result === undefined || result === null || this.isDisposed || token.isCancellationRequested) {
405
+ return { kind: vsdiag.DocumentDiagnosticReportKind.full, items: [] };
406
+ }
407
+ if (result.kind === vscode_languageserver_protocol_1.DocumentDiagnosticReportKind.Full) {
408
+ return { kind: vsdiag.DocumentDiagnosticReportKind.full, resultId: result.resultId, items: await this.client.protocol2CodeConverter.asDiagnostics(result.items, token) };
409
+ }
410
+ else {
411
+ return { kind: vsdiag.DocumentDiagnosticReportKind.unChanged, resultId: result.resultId };
412
+ }
413
+ }, (error) => {
414
+ return this.client.handleFailedRequest(vscode_languageserver_protocol_1.DocumentDiagnosticRequest.type, token, error, { kind: vsdiag.DocumentDiagnosticReportKind.full, items: [] });
415
+ });
416
+ };
417
+ const middleware = this.client.middleware;
418
+ return middleware.provideDiagnostics
419
+ ? middleware.provideDiagnostics(document, previousResultId, token, provideDiagnostics)
420
+ : provideDiagnostics(document, previousResultId, token);
421
+ }
422
+ };
423
+ if (this.options.workspaceDiagnostics) {
424
+ result.provideWorkspaceDiagnostics = (resultIds, token, resultReporter) => {
425
+ const convertReport = async (report) => {
426
+ if (report.kind === vscode_languageserver_protocol_1.DocumentDiagnosticReportKind.Full) {
427
+ return {
428
+ kind: vsdiag.DocumentDiagnosticReportKind.full,
429
+ uri: this.client.protocol2CodeConverter.asUri(report.uri),
430
+ resultId: report.resultId,
431
+ version: report.version,
432
+ items: await this.client.protocol2CodeConverter.asDiagnostics(report.items, token)
433
+ };
434
+ }
435
+ else {
436
+ return {
437
+ kind: vsdiag.DocumentDiagnosticReportKind.unChanged,
438
+ uri: this.client.protocol2CodeConverter.asUri(report.uri),
439
+ resultId: report.resultId,
440
+ version: report.version
441
+ };
442
+ }
443
+ };
444
+ const convertPreviousResultIds = (resultIds) => {
445
+ const converted = [];
446
+ for (const item of resultIds) {
447
+ converted.push({ uri: this.client.code2ProtocolConverter.asUri(item.uri), value: item.value });
448
+ }
449
+ return converted;
450
+ };
451
+ const provideDiagnostics = (resultIds, token) => {
452
+ const partialResultToken = (0, uuid_1.generateUuid)();
453
+ const disposable = this.client.onProgress(vscode_languageserver_protocol_1.WorkspaceDiagnosticRequest.partialResult, partialResultToken, async (partialResult) => {
454
+ if (partialResult === undefined || partialResult === null) {
455
+ resultReporter(null);
456
+ return;
457
+ }
458
+ const converted = {
459
+ items: []
460
+ };
461
+ for (const item of partialResult.items) {
462
+ try {
463
+ converted.items.push(await convertReport(item));
464
+ }
465
+ catch (error) {
466
+ this.client.error(`Converting workspace diagnostics failed.`, error);
467
+ }
468
+ }
469
+ resultReporter(converted);
470
+ });
471
+ const params = {
472
+ identifier: this.options.identifier,
473
+ previousResultIds: convertPreviousResultIds(resultIds),
474
+ partialResultToken: partialResultToken
475
+ };
476
+ if (this.isDisposed === true || !this.client.isRunning()) {
477
+ return { items: [] };
478
+ }
479
+ return this.client.sendRequest(vscode_languageserver_protocol_1.WorkspaceDiagnosticRequest.type, params, token).then(async (result) => {
480
+ if (token.isCancellationRequested) {
481
+ return { items: [] };
482
+ }
483
+ const converted = {
484
+ items: []
485
+ };
486
+ for (const item of result.items) {
487
+ converted.items.push(await convertReport(item));
488
+ }
489
+ disposable.dispose();
490
+ resultReporter(converted);
491
+ return { items: [] };
492
+ }, (error) => {
493
+ disposable.dispose();
494
+ return this.client.handleFailedRequest(vscode_languageserver_protocol_1.DocumentDiagnosticRequest.type, token, error, { items: [] });
495
+ });
496
+ };
497
+ const middleware = this.client.middleware;
498
+ return middleware.provideWorkspaceDiagnostics
499
+ ? middleware.provideWorkspaceDiagnostics(resultIds, token, resultReporter, provideDiagnostics)
500
+ : provideDiagnostics(resultIds, token, resultReporter);
501
+ };
502
+ }
503
+ return result;
504
+ }
505
+ dispose() {
506
+ this.isDisposed = true;
507
+ // Cancel and clear workspace pull if present.
508
+ this.workspaceCancellation?.cancel();
509
+ this.workspaceTimeout?.dispose();
510
+ // Cancel all request and mark open requests as outdated.
511
+ for (const [key, request] of this.openRequests) {
512
+ if (request.state === RequestStateKind.active) {
513
+ request.tokenSource.cancel();
514
+ }
515
+ this.openRequests.set(key, { state: RequestStateKind.outDated, document: request.document });
516
+ }
517
+ // cleanup old diagnostics
518
+ this.diagnostics.dispose();
519
+ }
520
+ }
521
+ class BackgroundScheduler {
522
+ constructor(diagnosticRequestor) {
523
+ this.diagnosticRequestor = diagnosticRequestor;
524
+ this.documents = new vscode_languageserver_protocol_1.LinkedMap();
525
+ this.isDisposed = false;
526
+ }
527
+ add(document) {
528
+ if (this.isDisposed === true) {
529
+ return;
530
+ }
531
+ const key = DocumentOrUri.asKey(document);
532
+ if (this.documents.has(key)) {
533
+ return;
534
+ }
535
+ this.documents.set(key, document, vscode_languageserver_protocol_1.Touch.Last);
536
+ this.trigger();
537
+ }
538
+ remove(document) {
539
+ const key = DocumentOrUri.asKey(document);
540
+ this.documents.delete(key);
541
+ // No more documents. Stop background activity.
542
+ if (this.documents.size === 0) {
543
+ this.stop();
544
+ }
545
+ else if (key === this.endDocumentKey()) {
546
+ // Make sure we have a correct last document. It could have
547
+ this.endDocument = this.documents.last;
548
+ }
549
+ }
550
+ trigger() {
551
+ if (this.isDisposed === true) {
552
+ return;
553
+ }
554
+ // We have a round running. So simply make sure we run up to the
555
+ // last document
556
+ if (this.intervalHandle !== undefined) {
557
+ this.endDocument = this.documents.last;
558
+ return;
559
+ }
560
+ this.endDocument = this.documents.last;
561
+ this.intervalHandle = (0, vscode_languageserver_protocol_1.RAL)().timer.setInterval(() => {
562
+ const document = this.documents.first;
563
+ if (document !== undefined) {
564
+ const key = DocumentOrUri.asKey(document);
565
+ this.diagnosticRequestor.pull(document);
566
+ this.documents.set(key, document, vscode_languageserver_protocol_1.Touch.Last);
567
+ if (key === this.endDocumentKey()) {
568
+ this.stop();
569
+ }
570
+ }
571
+ }, 200);
572
+ }
573
+ dispose() {
574
+ this.isDisposed = true;
575
+ this.stop();
576
+ this.documents.clear();
577
+ }
578
+ stop() {
579
+ this.intervalHandle?.dispose();
580
+ this.intervalHandle = undefined;
581
+ this.endDocument = undefined;
582
+ }
583
+ endDocumentKey() {
584
+ return this.endDocument !== undefined ? DocumentOrUri.asKey(this.endDocument) : undefined;
585
+ }
586
+ }
587
+ class DiagnosticFeatureProviderImpl {
588
+ constructor(client, tabs, options) {
589
+ const diagnosticPullOptions = client.clientOptions.diagnosticPullOptions ?? { onChange: true, onSave: false };
590
+ const documentSelector = client.protocol2CodeConverter.asDocumentSelector(options.documentSelector);
591
+ const disposables = [];
592
+ const matchResource = (resource) => {
593
+ const selector = options.documentSelector;
594
+ if (diagnosticPullOptions.match !== undefined) {
595
+ return diagnosticPullOptions.match(selector, resource);
596
+ }
597
+ for (const filter of selector) {
598
+ if (!vscode_languageserver_protocol_1.TextDocumentFilter.is(filter)) {
599
+ continue;
600
+ }
601
+ // The filter is a language id. We can't determine if it matches
602
+ // so we return false.
603
+ if (typeof filter === 'string') {
604
+ return false;
605
+ }
606
+ if (filter.language !== undefined && filter.language !== '*') {
607
+ return false;
608
+ }
609
+ if (filter.scheme !== undefined && filter.scheme !== '*' && filter.scheme !== resource.scheme) {
610
+ return false;
611
+ }
612
+ if (filter.pattern !== undefined) {
613
+ const matcher = new minimatch.Minimatch(filter.pattern, { noext: true });
614
+ if (!matcher.makeRe()) {
615
+ return false;
616
+ }
617
+ if (!matcher.match(resource.fsPath)) {
618
+ return false;
619
+ }
620
+ }
621
+ }
622
+ return true;
623
+ };
624
+ const matches = (document) => {
625
+ return document instanceof vscode_1.Uri
626
+ ? matchResource(document)
627
+ : vscode_1.languages.match(documentSelector, document) > 0 && tabs.isVisible(document);
628
+ };
629
+ const isActiveDocument = (document) => {
630
+ return document instanceof vscode_1.Uri
631
+ ? this.activeTextDocument?.uri.toString() === document.toString()
632
+ : this.activeTextDocument === document;
633
+ };
634
+ this.diagnosticRequestor = new DiagnosticRequestor(client, tabs, options);
635
+ this.backgroundScheduler = new BackgroundScheduler(this.diagnosticRequestor);
636
+ const addToBackgroundIfNeeded = (document) => {
637
+ if (!matches(document) || !options.interFileDependencies || isActiveDocument(document)) {
638
+ return;
639
+ }
640
+ this.backgroundScheduler.add(document);
641
+ };
642
+ this.activeTextDocument = vscode_1.window.activeTextEditor?.document;
643
+ vscode_1.window.onDidChangeActiveTextEditor((editor) => {
644
+ const oldActive = this.activeTextDocument;
645
+ this.activeTextDocument = editor?.document;
646
+ if (oldActive !== undefined) {
647
+ addToBackgroundIfNeeded(oldActive);
648
+ }
649
+ if (this.activeTextDocument !== undefined) {
650
+ this.backgroundScheduler.remove(this.activeTextDocument);
651
+ }
652
+ });
653
+ // For pull model diagnostics we pull for documents visible in the UI.
654
+ // From an eventing point of view we still rely on open document events
655
+ // and filter the documents that are not visible in the UI instead of
656
+ // listening to Tab events. Major reason is event timing since we need
657
+ // to ensure that the pull is send after the document open has reached
658
+ // the server.
659
+ // We always pull on open.
660
+ const openFeature = client.getFeature(vscode_languageserver_protocol_1.DidOpenTextDocumentNotification.method);
661
+ disposables.push(openFeature.onNotificationSent((event) => {
662
+ const textDocument = event.textDocument;
663
+ // We already know about this document. This can happen via a tab open.
664
+ if (this.diagnosticRequestor.knows(PullState.document, textDocument)) {
665
+ return;
666
+ }
667
+ if (matches(textDocument)) {
668
+ this.diagnosticRequestor.pull(textDocument, () => { addToBackgroundIfNeeded(textDocument); });
669
+ }
670
+ }));
671
+ disposables.push(tabs.onOpen((opened) => {
672
+ for (const resource of opened) {
673
+ // We already know about this document. This can happen via a document open.
674
+ if (this.diagnosticRequestor.knows(PullState.document, resource)) {
675
+ continue;
676
+ }
677
+ const uriStr = resource.toString();
678
+ let textDocument;
679
+ for (const item of vscode_1.workspace.textDocuments) {
680
+ if (uriStr === item.uri.toString()) {
681
+ textDocument = item;
682
+ break;
683
+ }
684
+ }
685
+ // In VS Code the event timing is as follows:
686
+ // 1. tab events are fired.
687
+ // 2. open document events are fired and internal data structures like
688
+ // workspace.textDocuments and Window.activeTextEditor are updated.
689
+ //
690
+ // This means: for newly created tab/editors we don't find the underlying
691
+ // document yet. So we do nothing an rely on the underlying open document event
692
+ // to be fired.
693
+ if (textDocument !== undefined && matches(textDocument)) {
694
+ this.diagnosticRequestor.pull(textDocument, () => { addToBackgroundIfNeeded(textDocument); });
695
+ }
696
+ }
697
+ }));
698
+ // Pull all diagnostics for documents that are already open
699
+ const pulledTextDocuments = new Set();
700
+ for (const textDocument of vscode_1.workspace.textDocuments) {
701
+ if (matches(textDocument)) {
702
+ this.diagnosticRequestor.pull(textDocument, () => { addToBackgroundIfNeeded(textDocument); });
703
+ pulledTextDocuments.add(textDocument.uri.toString());
704
+ }
705
+ }
706
+ // Pull all tabs if not already pulled as text document
707
+ if (diagnosticPullOptions.onTabs === true) {
708
+ for (const resource of tabs.getTabResources()) {
709
+ if (!pulledTextDocuments.has(resource.toString()) && matches(resource)) {
710
+ this.diagnosticRequestor.pull(resource, () => { addToBackgroundIfNeeded(resource); });
711
+ }
712
+ }
713
+ }
714
+ // We don't need to pull on tab open since we will receive a document open as well later on
715
+ // and that event allows us to use a document for a match check which will have a set
716
+ // language id.
717
+ if (diagnosticPullOptions.onChange === true) {
718
+ const changeFeature = client.getFeature(vscode_languageserver_protocol_1.DidChangeTextDocumentNotification.method);
719
+ disposables.push(changeFeature.onNotificationSent(async (event) => {
720
+ const textDocument = event.textDocument;
721
+ if ((diagnosticPullOptions.filter === undefined || !diagnosticPullOptions.filter(textDocument, DiagnosticPullMode.onType)) && this.diagnosticRequestor.knows(PullState.document, textDocument)) {
722
+ this.diagnosticRequestor.pull(textDocument, () => { this.backgroundScheduler.trigger(); });
723
+ }
724
+ }));
725
+ }
726
+ if (diagnosticPullOptions.onSave === true) {
727
+ const saveFeature = client.getFeature(vscode_languageserver_protocol_1.DidSaveTextDocumentNotification.method);
728
+ disposables.push(saveFeature.onNotificationSent((event) => {
729
+ const textDocument = event.textDocument;
730
+ if ((diagnosticPullOptions.filter === undefined || !diagnosticPullOptions.filter(textDocument, DiagnosticPullMode.onSave)) && this.diagnosticRequestor.knows(PullState.document, textDocument)) {
731
+ this.diagnosticRequestor.pull(event.textDocument, () => { this.backgroundScheduler.trigger(); });
732
+ }
733
+ }));
734
+ }
735
+ // When the document closes clear things up
736
+ const closeFeature = client.getFeature(vscode_languageserver_protocol_1.DidCloseTextDocumentNotification.method);
737
+ disposables.push(closeFeature.onNotificationSent((event) => {
738
+ this.cleanUpDocument(event.textDocument);
739
+ }));
740
+ // Same when a tabs closes.
741
+ tabs.onClose((closed) => {
742
+ for (const document of closed) {
743
+ this.cleanUpDocument(document);
744
+ }
745
+ });
746
+ // We received a did change from the server.
747
+ this.diagnosticRequestor.onDidChangeDiagnosticsEmitter.event(() => {
748
+ for (const textDocument of vscode_1.workspace.textDocuments) {
749
+ if (matches(textDocument)) {
750
+ this.diagnosticRequestor.pull(textDocument);
751
+ }
752
+ }
753
+ });
754
+ // da348dc5-c30a-4515-9d98-31ff3be38d14 is the test UUID to test the middle ware. So don't auto trigger pulls.
755
+ if (options.workspaceDiagnostics === true && options.identifier !== 'da348dc5-c30a-4515-9d98-31ff3be38d14') {
756
+ this.diagnosticRequestor.pullWorkspace();
757
+ }
758
+ this.disposable = vscode_1.Disposable.from(...disposables, this.backgroundScheduler, this.diagnosticRequestor);
759
+ }
760
+ get onDidChangeDiagnosticsEmitter() {
761
+ return this.diagnosticRequestor.onDidChangeDiagnosticsEmitter;
762
+ }
763
+ get diagnostics() {
764
+ return this.diagnosticRequestor.provider;
765
+ }
766
+ cleanUpDocument(document) {
767
+ if (this.diagnosticRequestor.knows(PullState.document, document)) {
768
+ this.diagnosticRequestor.forgetDocument(document);
769
+ this.backgroundScheduler.remove(document);
770
+ }
771
+ }
772
+ }
773
+ class DiagnosticFeature extends features_1.TextDocumentLanguageFeature {
774
+ constructor(client) {
775
+ super(client, vscode_languageserver_protocol_1.DocumentDiagnosticRequest.type);
776
+ }
777
+ fillClientCapabilities(capabilities) {
778
+ let capability = ensure(ensure(capabilities, 'textDocument'), 'diagnostic');
779
+ capability.dynamicRegistration = true;
780
+ // We first need to decide how a UI will look with related documents.
781
+ // An easy implementation would be to only show related diagnostics for
782
+ // the active editor.
783
+ capability.relatedDocumentSupport = false;
784
+ ensure(ensure(capabilities, 'workspace'), 'diagnostics').refreshSupport = true;
785
+ }
786
+ initialize(capabilities, documentSelector) {
787
+ const client = this._client;
788
+ client.onRequest(vscode_languageserver_protocol_1.DiagnosticRefreshRequest.type, async () => {
789
+ for (const provider of this.getAllProviders()) {
790
+ provider.onDidChangeDiagnosticsEmitter.fire();
791
+ }
792
+ });
793
+ let [id, options] = this.getRegistration(documentSelector, capabilities.diagnosticProvider);
794
+ if (!id || !options) {
795
+ return;
796
+ }
797
+ this.register({ id: id, registerOptions: options });
798
+ }
799
+ clear() {
800
+ if (this.tabs !== undefined) {
801
+ this.tabs.dispose();
802
+ this.tabs = undefined;
803
+ }
804
+ super.clear();
805
+ }
806
+ registerLanguageProvider(options) {
807
+ if (this.tabs === undefined) {
808
+ this.tabs = new Tabs();
809
+ }
810
+ const provider = new DiagnosticFeatureProviderImpl(this._client, this.tabs, options);
811
+ return [provider.disposable, provider];
812
+ }
813
+ }
814
+ exports.DiagnosticFeature = DiagnosticFeature;