brighterscript 1.0.0-alpha.5 → 1.0.0-alpha.50

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 (715) hide show
  1. package/README.md +76 -138
  2. package/bsconfig.schema.json +121 -5
  3. package/dist/ActionPipeline.d.ts +10 -0
  4. package/dist/ActionPipeline.js +40 -0
  5. package/dist/ActionPipeline.js.map +1 -0
  6. package/dist/AstValidationSegmenter.d.ts +45 -0
  7. package/dist/AstValidationSegmenter.js +322 -0
  8. package/dist/AstValidationSegmenter.js.map +1 -0
  9. package/dist/BsConfig.d.ts +72 -39
  10. package/dist/BusyStatusTracker.d.ts +61 -0
  11. package/dist/BusyStatusTracker.js +148 -0
  12. package/dist/BusyStatusTracker.js.map +1 -0
  13. package/dist/Cache.d.ts +3 -8
  14. package/dist/Cache.js +9 -14
  15. package/dist/Cache.js.map +1 -1
  16. package/dist/CacheVerifier.d.ts +7 -0
  17. package/dist/CacheVerifier.js +20 -0
  18. package/dist/CacheVerifier.js.map +1 -0
  19. package/dist/CodeActionUtil.d.ts +12 -4
  20. package/dist/CodeActionUtil.js +22 -5
  21. package/dist/CodeActionUtil.js.map +1 -1
  22. package/dist/CommentFlagProcessor.d.ts +7 -6
  23. package/dist/CommentFlagProcessor.js +11 -8
  24. package/dist/CommentFlagProcessor.js.map +1 -1
  25. package/dist/CrossScopeValidator.d.ts +68 -0
  26. package/dist/CrossScopeValidator.js +642 -0
  27. package/dist/CrossScopeValidator.js.map +1 -0
  28. package/dist/DependencyGraph.d.ts +8 -3
  29. package/dist/DependencyGraph.js +49 -16
  30. package/dist/DependencyGraph.js.map +1 -1
  31. package/dist/DiagnosticCollection.d.ts +21 -5
  32. package/dist/DiagnosticCollection.js +77 -24
  33. package/dist/DiagnosticCollection.js.map +1 -1
  34. package/dist/DiagnosticFilterer.d.ts +27 -6
  35. package/dist/DiagnosticFilterer.js +273 -60
  36. package/dist/DiagnosticFilterer.js.map +1 -1
  37. package/dist/DiagnosticManager.d.ts +82 -0
  38. package/dist/DiagnosticManager.js +406 -0
  39. package/dist/DiagnosticManager.js.map +1 -0
  40. package/dist/DiagnosticMessages.d.ts +558 -196
  41. package/dist/DiagnosticMessages.js +870 -340
  42. package/dist/DiagnosticMessages.js.map +1 -1
  43. package/dist/DiagnosticSeverityAdjuster.d.ts +7 -0
  44. package/dist/DiagnosticSeverityAdjuster.js +45 -0
  45. package/dist/DiagnosticSeverityAdjuster.js.map +1 -0
  46. package/dist/FunctionScope.d.ts +28 -0
  47. package/dist/FunctionScope.js +52 -0
  48. package/dist/FunctionScope.js.map +1 -0
  49. package/dist/KeyedThrottler.d.ts +3 -3
  50. package/dist/KeyedThrottler.js +3 -3
  51. package/dist/KeyedThrottler.js.map +1 -1
  52. package/dist/LanguageServer.d.ts +100 -105
  53. package/dist/LanguageServer.js +444 -745
  54. package/dist/LanguageServer.js.map +1 -1
  55. package/dist/Logger.d.ts +17 -13
  56. package/dist/Logger.js +64 -34
  57. package/dist/Logger.js.map +1 -1
  58. package/dist/PluginInterface.d.ts +32 -10
  59. package/dist/PluginInterface.js +117 -7
  60. package/dist/PluginInterface.js.map +1 -1
  61. package/dist/Program.d.ts +241 -98
  62. package/dist/Program.js +1432 -717
  63. package/dist/Program.js.map +1 -1
  64. package/dist/ProgramBuilder.d.ts +47 -23
  65. package/dist/ProgramBuilder.js +224 -178
  66. package/dist/ProgramBuilder.js.map +1 -1
  67. package/dist/Scope.d.ts +149 -109
  68. package/dist/Scope.js +557 -550
  69. package/dist/Scope.js.map +1 -1
  70. package/dist/SemanticTokenUtils.js +5 -1
  71. package/dist/SemanticTokenUtils.js.map +1 -1
  72. package/dist/Stopwatch.d.ts +4 -0
  73. package/dist/Stopwatch.js +8 -1
  74. package/dist/Stopwatch.js.map +1 -1
  75. package/dist/SymbolTable.d.ts +136 -24
  76. package/dist/SymbolTable.js +565 -64
  77. package/dist/SymbolTable.js.map +1 -1
  78. package/dist/SymbolTypeFlag.d.ts +9 -0
  79. package/dist/SymbolTypeFlag.js +14 -0
  80. package/dist/SymbolTypeFlag.js.map +1 -0
  81. package/dist/Throttler.d.ts +12 -0
  82. package/dist/Throttler.js +39 -0
  83. package/dist/Throttler.js.map +1 -1
  84. package/dist/Watcher.d.ts +0 -3
  85. package/dist/Watcher.js +0 -3
  86. package/dist/Watcher.js.map +1 -1
  87. package/dist/XmlScope.d.ts +5 -15
  88. package/dist/XmlScope.js +34 -90
  89. package/dist/XmlScope.js.map +1 -1
  90. package/dist/astUtils/CachedLookups.d.ts +50 -0
  91. package/dist/astUtils/CachedLookups.js +334 -0
  92. package/dist/astUtils/CachedLookups.js.map +1 -0
  93. package/dist/astUtils/CachedLookups.spec.js +39 -0
  94. package/dist/astUtils/CachedLookups.spec.js.map +1 -0
  95. package/dist/astUtils/Editor.d.ts +69 -0
  96. package/dist/astUtils/Editor.js +245 -0
  97. package/dist/astUtils/Editor.js.map +1 -0
  98. package/dist/astUtils/Editor.spec.js +258 -0
  99. package/dist/astUtils/Editor.spec.js.map +1 -0
  100. package/dist/astUtils/creators.d.ts +54 -19
  101. package/dist/astUtils/creators.js +242 -42
  102. package/dist/astUtils/creators.js.map +1 -1
  103. package/dist/astUtils/creators.spec.js +5 -5
  104. package/dist/astUtils/creators.spec.js.map +1 -1
  105. package/dist/astUtils/reflection.d.ts +196 -85
  106. package/dist/astUtils/reflection.js +497 -144
  107. package/dist/astUtils/reflection.js.map +1 -1
  108. package/dist/astUtils/reflection.spec.js +267 -167
  109. package/dist/astUtils/reflection.spec.js.map +1 -1
  110. package/dist/astUtils/stackedVisitor.js.map +1 -1
  111. package/dist/astUtils/stackedVisitor.spec.js +14 -14
  112. package/dist/astUtils/stackedVisitor.spec.js.map +1 -1
  113. package/dist/astUtils/visitors.d.ts +116 -53
  114. package/dist/astUtils/visitors.js +95 -15
  115. package/dist/astUtils/visitors.js.map +1 -1
  116. package/dist/astUtils/visitors.spec.js +629 -51
  117. package/dist/astUtils/visitors.spec.js.map +1 -1
  118. package/dist/astUtils/xml.d.ts +9 -8
  119. package/dist/astUtils/xml.js +12 -7
  120. package/dist/astUtils/xml.js.map +1 -1
  121. package/dist/bscPlugin/BscPlugin.d.ts +24 -4
  122. package/dist/bscPlugin/BscPlugin.js +88 -4
  123. package/dist/bscPlugin/BscPlugin.js.map +1 -1
  124. package/dist/bscPlugin/CallExpressionInfo.d.ts +36 -0
  125. package/dist/bscPlugin/CallExpressionInfo.js +143 -0
  126. package/dist/bscPlugin/CallExpressionInfo.js.map +1 -0
  127. package/dist/bscPlugin/FileWriter.d.ts +6 -0
  128. package/dist/bscPlugin/FileWriter.js +24 -0
  129. package/dist/bscPlugin/FileWriter.js.map +1 -0
  130. package/dist/bscPlugin/SignatureHelpUtil.d.ts +10 -0
  131. package/dist/bscPlugin/SignatureHelpUtil.js +137 -0
  132. package/dist/bscPlugin/SignatureHelpUtil.js.map +1 -0
  133. package/dist/bscPlugin/codeActions/CodeActionsProcessor.d.ts +6 -5
  134. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +173 -27
  135. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  136. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +138 -21
  137. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
  138. package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +65 -0
  139. package/dist/bscPlugin/completions/CompletionsProcessor.js +633 -0
  140. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -0
  141. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +2512 -0
  142. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -0
  143. package/dist/bscPlugin/definition/DefinitionProvider.d.ts +13 -0
  144. package/dist/bscPlugin/definition/DefinitionProvider.js +212 -0
  145. package/dist/bscPlugin/definition/DefinitionProvider.js.map +1 -0
  146. package/dist/bscPlugin/definition/DefinitionProvider.spec.js +87 -0
  147. package/dist/bscPlugin/definition/DefinitionProvider.spec.js.map +1 -0
  148. package/dist/bscPlugin/fileProviders/FileProvider.d.ts +9 -0
  149. package/dist/bscPlugin/fileProviders/FileProvider.js +51 -0
  150. package/dist/bscPlugin/fileProviders/FileProvider.js.map +1 -0
  151. package/dist/bscPlugin/hover/HoverProcessor.d.ts +18 -0
  152. package/dist/bscPlugin/hover/HoverProcessor.js +230 -0
  153. package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -0
  154. package/dist/bscPlugin/hover/HoverProcessor.spec.js +991 -0
  155. package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -0
  156. package/dist/bscPlugin/references/ReferencesProvider.d.ts +12 -0
  157. package/dist/bscPlugin/references/ReferencesProvider.js +57 -0
  158. package/dist/bscPlugin/references/ReferencesProvider.js.map +1 -0
  159. package/dist/bscPlugin/references/ReferencesProvider.spec.d.ts +1 -0
  160. package/dist/bscPlugin/references/ReferencesProvider.spec.js +51 -0
  161. package/dist/bscPlugin/references/ReferencesProvider.spec.js.map +1 -0
  162. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +14 -0
  163. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +164 -0
  164. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -0
  165. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.d.ts +1 -0
  166. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +564 -0
  167. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -0
  168. package/dist/bscPlugin/serialize/BslibInjector.spec.d.ts +1 -0
  169. package/dist/bscPlugin/serialize/BslibInjector.spec.js +33 -0
  170. package/dist/bscPlugin/serialize/BslibInjector.spec.js.map +1 -0
  171. package/dist/bscPlugin/serialize/BslibManager.d.ts +12 -0
  172. package/dist/bscPlugin/serialize/BslibManager.js +46 -0
  173. package/dist/bscPlugin/serialize/BslibManager.js.map +1 -0
  174. package/dist/bscPlugin/serialize/FileSerializer.d.ts +9 -0
  175. package/dist/bscPlugin/serialize/FileSerializer.js +75 -0
  176. package/dist/bscPlugin/serialize/FileSerializer.js.map +1 -0
  177. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.d.ts +7 -0
  178. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.js +22 -0
  179. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.js.map +1 -0
  180. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.d.ts +1 -0
  181. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js +291 -0
  182. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js.map +1 -0
  183. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.d.ts +7 -0
  184. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.js +26 -0
  185. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.js.map +1 -0
  186. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.d.ts +1 -0
  187. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js +245 -0
  188. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js.map +1 -0
  189. package/dist/bscPlugin/symbols/symbolUtils.d.ts +5 -0
  190. package/dist/bscPlugin/symbols/symbolUtils.js +141 -0
  191. package/dist/bscPlugin/symbols/symbolUtils.js.map +1 -0
  192. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.d.ts +27 -0
  193. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js +418 -0
  194. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -0
  195. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.d.ts +1 -0
  196. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js +75 -0
  197. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +1 -0
  198. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +12 -0
  199. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js +99 -0
  200. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +1 -0
  201. package/dist/bscPlugin/validation/BrsFileAfterValidator.d.ts +7 -0
  202. package/dist/bscPlugin/validation/BrsFileAfterValidator.js +18 -0
  203. package/dist/bscPlugin/validation/BrsFileAfterValidator.js.map +1 -0
  204. package/dist/bscPlugin/validation/BrsFileValidator.d.ts +37 -0
  205. package/dist/bscPlugin/validation/BrsFileValidator.js +638 -0
  206. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -0
  207. package/dist/bscPlugin/validation/BrsFileValidator.spec.d.ts +1 -0
  208. package/dist/bscPlugin/validation/BrsFileValidator.spec.js +1517 -0
  209. package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -0
  210. package/dist/bscPlugin/validation/ProgramValidator.d.ts +11 -0
  211. package/dist/bscPlugin/validation/ProgramValidator.js +33 -0
  212. package/dist/bscPlugin/validation/ProgramValidator.js.map +1 -0
  213. package/dist/bscPlugin/validation/ScopeValidator.d.ts +141 -0
  214. package/dist/bscPlugin/validation/ScopeValidator.js +1323 -0
  215. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -0
  216. package/dist/bscPlugin/validation/ScopeValidator.spec.d.ts +1 -0
  217. package/dist/bscPlugin/validation/ScopeValidator.spec.js +6135 -0
  218. package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -0
  219. package/dist/bscPlugin/validation/XmlFileValidator.d.ts +8 -0
  220. package/dist/bscPlugin/validation/XmlFileValidator.js +36 -0
  221. package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -0
  222. package/dist/cli.js +126 -27
  223. package/dist/cli.js.map +1 -1
  224. package/dist/common/Sequencer.d.ts +53 -0
  225. package/dist/common/Sequencer.js +233 -0
  226. package/dist/common/Sequencer.js.map +1 -0
  227. package/dist/common/Sequencer.spec.d.ts +1 -0
  228. package/dist/common/Sequencer.spec.js +75 -0
  229. package/dist/common/Sequencer.spec.js.map +1 -0
  230. package/dist/deferred.d.ts +5 -3
  231. package/dist/deferred.js +10 -0
  232. package/dist/deferred.js.map +1 -1
  233. package/dist/diagnosticUtils.d.ts +10 -3
  234. package/dist/diagnosticUtils.js +64 -25
  235. package/dist/diagnosticUtils.js.map +1 -1
  236. package/dist/examples/plugins/removePrint.d.ts +2 -2
  237. package/dist/examples/plugins/removePrint.js +8 -12
  238. package/dist/examples/plugins/removePrint.js.map +1 -1
  239. package/dist/files/AssetFile.d.ts +24 -0
  240. package/dist/files/AssetFile.js +25 -0
  241. package/dist/files/AssetFile.js.map +1 -0
  242. package/dist/files/BrsFile.Class.spec.js +1213 -259
  243. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  244. package/dist/files/BrsFile.d.ts +145 -87
  245. package/dist/files/BrsFile.js +836 -934
  246. package/dist/files/BrsFile.js.map +1 -1
  247. package/dist/files/BrsFile.spec.js +4226 -902
  248. package/dist/files/BrsFile.spec.js.map +1 -1
  249. package/dist/files/BscFile.d.ts +102 -0
  250. package/dist/files/BscFile.js +15 -0
  251. package/dist/files/BscFile.js.map +1 -0
  252. package/dist/files/Factory.d.ts +25 -0
  253. package/dist/files/Factory.js +22 -0
  254. package/dist/files/Factory.js.map +1 -0
  255. package/dist/files/LazyFileData.d.ts +21 -0
  256. package/dist/files/LazyFileData.js +54 -0
  257. package/dist/files/LazyFileData.js.map +1 -0
  258. package/dist/files/LazyFileData.spec.d.ts +1 -0
  259. package/dist/files/LazyFileData.spec.js +27 -0
  260. package/dist/files/LazyFileData.spec.js.map +1 -0
  261. package/dist/files/XmlFile.d.ts +80 -41
  262. package/dist/files/XmlFile.js +161 -137
  263. package/dist/files/XmlFile.js.map +1 -1
  264. package/dist/files/XmlFile.spec.js +444 -336
  265. package/dist/files/XmlFile.spec.js.map +1 -1
  266. package/dist/files/tests/imports.spec.js +62 -52
  267. package/dist/files/tests/imports.spec.js.map +1 -1
  268. package/dist/files/tests/optionalChaning.spec.d.ts +1 -0
  269. package/dist/files/tests/optionalChaning.spec.js +152 -0
  270. package/dist/files/tests/optionalChaning.spec.js.map +1 -0
  271. package/dist/globalCallables.d.ts +3 -1
  272. package/dist/globalCallables.js +424 -184
  273. package/dist/globalCallables.js.map +1 -1
  274. package/dist/index.d.ts +32 -4
  275. package/dist/index.js +54 -7
  276. package/dist/index.js.map +1 -1
  277. package/dist/interfaces.d.ts +942 -125
  278. package/dist/interfaces.js +21 -0
  279. package/dist/interfaces.js.map +1 -1
  280. package/dist/lexer/Character.spec.js +5 -5
  281. package/dist/lexer/Character.spec.js.map +1 -1
  282. package/dist/lexer/Lexer.d.ts +51 -12
  283. package/dist/lexer/Lexer.js +215 -65
  284. package/dist/lexer/Lexer.js.map +1 -1
  285. package/dist/lexer/Lexer.spec.js +812 -568
  286. package/dist/lexer/Lexer.spec.js.map +1 -1
  287. package/dist/lexer/Token.d.ts +27 -11
  288. package/dist/lexer/Token.js +10 -2
  289. package/dist/lexer/Token.js.map +1 -1
  290. package/dist/lexer/TokenKind.d.ts +40 -2
  291. package/dist/lexer/TokenKind.js +147 -10
  292. package/dist/lexer/TokenKind.js.map +1 -1
  293. package/dist/logging.d.ts +14 -0
  294. package/dist/logging.js +29 -0
  295. package/dist/logging.js.map +1 -0
  296. package/dist/lsp/ActionQueue.d.ts +35 -0
  297. package/dist/lsp/ActionQueue.js +115 -0
  298. package/dist/lsp/ActionQueue.js.map +1 -0
  299. package/dist/lsp/ActionQueue.spec.d.ts +1 -0
  300. package/dist/lsp/ActionQueue.spec.js +80 -0
  301. package/dist/lsp/ActionQueue.spec.js.map +1 -0
  302. package/dist/lsp/DocumentManager.d.ts +63 -0
  303. package/dist/lsp/DocumentManager.js +122 -0
  304. package/dist/lsp/DocumentManager.js.map +1 -0
  305. package/dist/lsp/DocumentManager.spec.d.ts +1 -0
  306. package/dist/lsp/DocumentManager.spec.js +103 -0
  307. package/dist/lsp/DocumentManager.spec.js.map +1 -0
  308. package/dist/lsp/LspProject.d.ts +239 -0
  309. package/dist/lsp/LspProject.js +3 -0
  310. package/dist/lsp/LspProject.js.map +1 -0
  311. package/dist/lsp/PathFilterer.d.ts +75 -0
  312. package/dist/lsp/PathFilterer.js +196 -0
  313. package/dist/lsp/PathFilterer.js.map +1 -0
  314. package/dist/lsp/PathFilterer.spec.d.ts +1 -0
  315. package/dist/lsp/PathFilterer.spec.js +182 -0
  316. package/dist/lsp/PathFilterer.spec.js.map +1 -0
  317. package/dist/lsp/Project.d.ts +168 -0
  318. package/dist/lsp/Project.js +437 -0
  319. package/dist/lsp/Project.js.map +1 -0
  320. package/dist/lsp/Project.spec.d.ts +1 -0
  321. package/dist/lsp/Project.spec.js +267 -0
  322. package/dist/lsp/Project.spec.js.map +1 -0
  323. package/dist/lsp/ProjectManager.d.ts +242 -0
  324. package/dist/lsp/ProjectManager.js +824 -0
  325. package/dist/lsp/ProjectManager.js.map +1 -0
  326. package/dist/lsp/ProjectManager.spec.d.ts +1 -0
  327. package/dist/lsp/ProjectManager.spec.js +913 -0
  328. package/dist/lsp/ProjectManager.spec.js.map +1 -0
  329. package/dist/lsp/ReaderWriterManager.d.ts +21 -0
  330. package/dist/lsp/ReaderWriterManager.js +60 -0
  331. package/dist/lsp/ReaderWriterManager.js.map +1 -0
  332. package/dist/lsp/worker/MessageHandler.d.ts +99 -0
  333. package/dist/lsp/worker/MessageHandler.js +138 -0
  334. package/dist/lsp/worker/MessageHandler.js.map +1 -0
  335. package/dist/lsp/worker/MessageHandler.spec.d.ts +1 -0
  336. package/dist/lsp/worker/MessageHandler.spec.js +64 -0
  337. package/dist/lsp/worker/MessageHandler.spec.js.map +1 -0
  338. package/dist/lsp/worker/WorkerPool.d.ts +38 -0
  339. package/dist/lsp/worker/WorkerPool.js +78 -0
  340. package/dist/lsp/worker/WorkerPool.js.map +1 -0
  341. package/dist/lsp/worker/WorkerPool.spec.d.ts +1 -0
  342. package/dist/lsp/worker/WorkerPool.spec.js +59 -0
  343. package/dist/lsp/worker/WorkerPool.spec.js.map +1 -0
  344. package/dist/lsp/worker/WorkerThreadProject.d.ts +143 -0
  345. package/dist/lsp/worker/WorkerThreadProject.js +189 -0
  346. package/dist/lsp/worker/WorkerThreadProject.js.map +1 -0
  347. package/dist/lsp/worker/WorkerThreadProject.spec.d.ts +2 -0
  348. package/dist/lsp/worker/WorkerThreadProject.spec.js +71 -0
  349. package/dist/lsp/worker/WorkerThreadProject.spec.js.map +1 -0
  350. package/dist/lsp/worker/WorkerThreadProjectRunner.d.ts +15 -0
  351. package/dist/lsp/worker/WorkerThreadProjectRunner.js +58 -0
  352. package/dist/lsp/worker/WorkerThreadProjectRunner.js.map +1 -0
  353. package/dist/lsp/worker/run.d.ts +1 -0
  354. package/dist/lsp/worker/run.js +14 -0
  355. package/dist/lsp/worker/run.js.map +1 -0
  356. package/dist/parser/AstNode.d.ts +203 -0
  357. package/dist/parser/AstNode.js +303 -0
  358. package/dist/parser/AstNode.js.map +1 -0
  359. package/dist/parser/AstNode.spec.d.ts +1 -0
  360. package/dist/parser/AstNode.spec.js +1455 -0
  361. package/dist/parser/AstNode.spec.js.map +1 -0
  362. package/dist/parser/BrightScriptDocParser.d.ts +56 -0
  363. package/dist/parser/BrightScriptDocParser.js +294 -0
  364. package/dist/parser/BrightScriptDocParser.js.map +1 -0
  365. package/dist/parser/BrightScriptDocParser.spec.d.ts +1 -0
  366. package/dist/parser/BrightScriptDocParser.spec.js +310 -0
  367. package/dist/parser/BrightScriptDocParser.spec.js.map +1 -0
  368. package/dist/parser/BrsTranspileState.d.ts +22 -3
  369. package/dist/parser/BrsTranspileState.js +19 -0
  370. package/dist/parser/BrsTranspileState.js.map +1 -1
  371. package/dist/parser/Expression.d.ts +553 -221
  372. package/dist/parser/Expression.js +1414 -505
  373. package/dist/parser/Expression.js.map +1 -1
  374. package/dist/parser/Expression.spec.d.ts +1 -0
  375. package/dist/parser/Expression.spec.js +40 -0
  376. package/dist/parser/Expression.spec.js.map +1 -0
  377. package/dist/parser/Parser.Class.spec.js +255 -125
  378. package/dist/parser/Parser.Class.spec.js.map +1 -1
  379. package/dist/parser/Parser.d.ts +117 -124
  380. package/dist/parser/Parser.js +1669 -982
  381. package/dist/parser/Parser.js.map +1 -1
  382. package/dist/parser/Parser.spec.d.ts +3 -1
  383. package/dist/parser/Parser.spec.js +2111 -525
  384. package/dist/parser/Parser.spec.js.map +1 -1
  385. package/dist/parser/SGParser.d.ts +29 -13
  386. package/dist/parser/SGParser.js +85 -56
  387. package/dist/parser/SGParser.js.map +1 -1
  388. package/dist/parser/SGParser.spec.js +30 -45
  389. package/dist/parser/SGParser.spec.js.map +1 -1
  390. package/dist/parser/SGTypes.d.ts +134 -46
  391. package/dist/parser/SGTypes.js +206 -115
  392. package/dist/parser/SGTypes.js.map +1 -1
  393. package/dist/parser/Statement.d.ts +849 -267
  394. package/dist/parser/Statement.js +2412 -625
  395. package/dist/parser/Statement.js.map +1 -1
  396. package/dist/parser/Statement.spec.js +133 -36
  397. package/dist/parser/Statement.spec.js.map +1 -1
  398. package/dist/parser/TranspileState.d.ts +26 -12
  399. package/dist/parser/TranspileState.js +115 -24
  400. package/dist/parser/TranspileState.js.map +1 -1
  401. package/dist/parser/tests/Parser.spec.d.ts +3 -9
  402. package/dist/parser/tests/Parser.spec.js +7 -13
  403. package/dist/parser/tests/Parser.spec.js.map +1 -1
  404. package/dist/parser/tests/controlFlow/For.spec.js +83 -75
  405. package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
  406. package/dist/parser/tests/controlFlow/ForEach.spec.js +85 -51
  407. package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
  408. package/dist/parser/tests/controlFlow/If.spec.js +382 -239
  409. package/dist/parser/tests/controlFlow/If.spec.js.map +1 -1
  410. package/dist/parser/tests/controlFlow/While.spec.js +52 -45
  411. package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
  412. package/dist/parser/tests/expression/Additive.spec.js +51 -43
  413. package/dist/parser/tests/expression/Additive.spec.js.map +1 -1
  414. package/dist/parser/tests/expression/ArrayLiterals.spec.js +192 -142
  415. package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +1 -1
  416. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +236 -160
  417. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
  418. package/dist/parser/tests/expression/Boolean.spec.js +41 -34
  419. package/dist/parser/tests/expression/Boolean.spec.js.map +1 -1
  420. package/dist/parser/tests/expression/Call.spec.js +173 -55
  421. package/dist/parser/tests/expression/Call.spec.js.map +1 -1
  422. package/dist/parser/tests/expression/Exponential.spec.js +20 -20
  423. package/dist/parser/tests/expression/Exponential.spec.js.map +1 -1
  424. package/dist/parser/tests/expression/Function.spec.js +291 -282
  425. package/dist/parser/tests/expression/Function.spec.js.map +1 -1
  426. package/dist/parser/tests/expression/Indexing.spec.js +193 -110
  427. package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
  428. package/dist/parser/tests/expression/Multiplicative.spec.js +42 -42
  429. package/dist/parser/tests/expression/Multiplicative.spec.js.map +1 -1
  430. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +260 -115
  431. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
  432. package/dist/parser/tests/expression/PrefixUnary.spec.js +58 -52
  433. package/dist/parser/tests/expression/PrefixUnary.spec.js.map +1 -1
  434. package/dist/parser/tests/expression/Primary.spec.js +76 -60
  435. package/dist/parser/tests/expression/Primary.spec.js.map +1 -1
  436. package/dist/parser/tests/expression/RegexLiteralExpression.spec.d.ts +1 -0
  437. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +171 -0
  438. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -0
  439. package/dist/parser/tests/expression/Relational.spec.js +50 -50
  440. package/dist/parser/tests/expression/Relational.spec.js.map +1 -1
  441. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +31 -31
  442. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +1 -1
  443. package/dist/parser/tests/expression/TemplateStringExpression.spec.js +281 -94
  444. package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
  445. package/dist/parser/tests/expression/TernaryExpression.spec.js +747 -192
  446. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
  447. package/dist/parser/tests/expression/TypeExpression.spec.d.ts +1 -0
  448. package/dist/parser/tests/expression/TypeExpression.spec.js +126 -0
  449. package/dist/parser/tests/expression/TypeExpression.spec.js.map +1 -0
  450. package/dist/parser/tests/expression/UnaryExpression.spec.d.ts +1 -0
  451. package/dist/parser/tests/expression/UnaryExpression.spec.js +52 -0
  452. package/dist/parser/tests/expression/UnaryExpression.spec.js.map +1 -0
  453. package/dist/parser/tests/statement/AssignmentOperators.spec.js +44 -44
  454. package/dist/parser/tests/statement/AssignmentOperators.spec.js.map +1 -1
  455. package/dist/parser/tests/statement/ConstStatement.spec.d.ts +1 -0
  456. package/dist/parser/tests/statement/ConstStatement.spec.js +500 -0
  457. package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -0
  458. package/dist/parser/tests/statement/Continue.spec.d.ts +1 -0
  459. package/dist/parser/tests/statement/Continue.spec.js +119 -0
  460. package/dist/parser/tests/statement/Continue.spec.js.map +1 -0
  461. package/dist/parser/tests/statement/Declaration.spec.js +61 -55
  462. package/dist/parser/tests/statement/Declaration.spec.js.map +1 -1
  463. package/dist/parser/tests/statement/Dim.spec.js +29 -22
  464. package/dist/parser/tests/statement/Dim.spec.js.map +1 -1
  465. package/dist/parser/tests/statement/Enum.spec.d.ts +1 -0
  466. package/dist/parser/tests/statement/Enum.spec.js +744 -0
  467. package/dist/parser/tests/statement/Enum.spec.js.map +1 -0
  468. package/dist/parser/tests/statement/For.spec.d.ts +1 -0
  469. package/dist/parser/tests/statement/For.spec.js +45 -0
  470. package/dist/parser/tests/statement/For.spec.js.map +1 -0
  471. package/dist/parser/tests/statement/ForEach.spec.d.ts +1 -0
  472. package/dist/parser/tests/statement/ForEach.spec.js +36 -0
  473. package/dist/parser/tests/statement/ForEach.spec.js.map +1 -0
  474. package/dist/parser/tests/statement/Function.spec.js +226 -215
  475. package/dist/parser/tests/statement/Function.spec.js.map +1 -1
  476. package/dist/parser/tests/statement/Goto.spec.js +16 -15
  477. package/dist/parser/tests/statement/Goto.spec.js.map +1 -1
  478. package/dist/parser/tests/statement/Increment.spec.js +64 -61
  479. package/dist/parser/tests/statement/Increment.spec.js.map +1 -1
  480. package/dist/parser/tests/statement/InterfaceStatement.spec.d.ts +1 -0
  481. package/dist/parser/tests/statement/InterfaceStatement.spec.js +110 -0
  482. package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -0
  483. package/dist/parser/tests/statement/LibraryStatement.spec.js +22 -22
  484. package/dist/parser/tests/statement/LibraryStatement.spec.js.map +1 -1
  485. package/dist/parser/tests/statement/Misc.spec.js +127 -168
  486. package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
  487. package/dist/parser/tests/statement/PrintStatement.spec.js +133 -114
  488. package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
  489. package/dist/parser/tests/statement/ReturnStatement.spec.js +57 -54
  490. package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
  491. package/dist/parser/tests/statement/Set.spec.js +131 -117
  492. package/dist/parser/tests/statement/Set.spec.js.map +1 -1
  493. package/dist/parser/tests/statement/Stop.spec.js +14 -13
  494. package/dist/parser/tests/statement/Stop.spec.js.map +1 -1
  495. package/dist/parser/tests/statement/Throw.spec.js +11 -8
  496. package/dist/parser/tests/statement/Throw.spec.js.map +1 -1
  497. package/dist/parser/tests/statement/TryCatch.spec.js +26 -15
  498. package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
  499. package/dist/preprocessor/Manifest.d.ts +6 -6
  500. package/dist/preprocessor/Manifest.js +17 -38
  501. package/dist/preprocessor/Manifest.js.map +1 -1
  502. package/dist/preprocessor/Manifest.spec.d.ts +1 -0
  503. package/dist/preprocessor/Manifest.spec.js +78 -103
  504. package/dist/preprocessor/Manifest.spec.js.map +1 -1
  505. package/dist/roku-types/data.json +20347 -0
  506. package/dist/roku-types/index.d.ts +5726 -0
  507. package/dist/roku-types/index.js +11 -0
  508. package/dist/roku-types/index.js.map +1 -0
  509. package/dist/types/ArrayType.d.ts +12 -5
  510. package/dist/types/ArrayType.js +89 -24
  511. package/dist/types/ArrayType.js.map +1 -1
  512. package/dist/types/ArrayType.spec.js +39 -11
  513. package/dist/types/ArrayType.spec.js.map +1 -1
  514. package/dist/types/AssociativeArrayType.d.ts +15 -0
  515. package/dist/types/AssociativeArrayType.js +64 -0
  516. package/dist/types/AssociativeArrayType.js.map +1 -0
  517. package/dist/types/BaseFunctionType.d.ts +10 -0
  518. package/dist/types/BaseFunctionType.js +26 -0
  519. package/dist/types/BaseFunctionType.js.map +1 -0
  520. package/dist/types/BooleanType.d.ts +9 -5
  521. package/dist/types/BooleanType.js +19 -8
  522. package/dist/types/BooleanType.js.map +1 -1
  523. package/dist/types/BooleanType.spec.js +10 -4
  524. package/dist/types/BooleanType.spec.js.map +1 -1
  525. package/dist/types/BscType.d.ts +41 -3
  526. package/dist/types/BscType.js +152 -0
  527. package/dist/types/BscType.js.map +1 -1
  528. package/dist/types/BscTypeKind.d.ts +28 -0
  529. package/dist/types/BscTypeKind.js +33 -0
  530. package/dist/types/BscTypeKind.js.map +1 -0
  531. package/dist/types/BuiltInInterfaceAdder.d.ts +28 -0
  532. package/dist/types/BuiltInInterfaceAdder.js +212 -0
  533. package/dist/types/BuiltInInterfaceAdder.js.map +1 -0
  534. package/dist/types/BuiltInInterfaceAdder.spec.d.ts +1 -0
  535. package/dist/types/BuiltInInterfaceAdder.spec.js +115 -0
  536. package/dist/types/BuiltInInterfaceAdder.spec.js.map +1 -0
  537. package/dist/types/CallFuncableType.d.ts +24 -0
  538. package/dist/types/CallFuncableType.js +91 -0
  539. package/dist/types/CallFuncableType.js.map +1 -0
  540. package/dist/types/ClassType.d.ts +17 -0
  541. package/dist/types/ClassType.js +60 -0
  542. package/dist/types/ClassType.js.map +1 -0
  543. package/dist/types/ClassType.spec.d.ts +1 -0
  544. package/dist/types/ClassType.spec.js +76 -0
  545. package/dist/types/ClassType.spec.js.map +1 -0
  546. package/dist/types/ComponentType.d.ts +22 -0
  547. package/dist/types/ComponentType.js +107 -0
  548. package/dist/types/ComponentType.js.map +1 -0
  549. package/dist/types/DoubleType.d.ts +10 -5
  550. package/dist/types/DoubleType.js +21 -17
  551. package/dist/types/DoubleType.js.map +1 -1
  552. package/dist/types/DoubleType.spec.js +12 -4
  553. package/dist/types/DoubleType.spec.js.map +1 -1
  554. package/dist/types/DynamicType.d.ts +13 -5
  555. package/dist/types/DynamicType.js +26 -5
  556. package/dist/types/DynamicType.js.map +1 -1
  557. package/dist/types/DynamicType.spec.js +16 -5
  558. package/dist/types/DynamicType.spec.js.map +1 -1
  559. package/dist/types/EnumType.d.ts +42 -0
  560. package/dist/types/EnumType.js +98 -0
  561. package/dist/types/EnumType.js.map +1 -0
  562. package/dist/types/EnumType.spec.d.ts +1 -0
  563. package/dist/types/EnumType.spec.js +33 -0
  564. package/dist/types/EnumType.spec.js.map +1 -0
  565. package/dist/types/FloatType.d.ts +10 -5
  566. package/dist/types/FloatType.js +21 -17
  567. package/dist/types/FloatType.js.map +1 -1
  568. package/dist/types/FloatType.spec.js +4 -4
  569. package/dist/types/FloatType.spec.js.map +1 -1
  570. package/dist/types/FunctionType.d.ts +8 -22
  571. package/dist/types/FunctionType.js +25 -63
  572. package/dist/types/FunctionType.js.map +1 -1
  573. package/dist/types/InheritableType.d.ts +29 -0
  574. package/dist/types/InheritableType.js +173 -0
  575. package/dist/types/InheritableType.js.map +1 -0
  576. package/dist/types/InlineInterfaceType.d.ts +5 -0
  577. package/dist/types/InlineInterfaceType.js +17 -0
  578. package/dist/types/InlineInterfaceType.js.map +1 -0
  579. package/dist/types/IntegerType.d.ts +10 -5
  580. package/dist/types/IntegerType.js +21 -17
  581. package/dist/types/IntegerType.js.map +1 -1
  582. package/dist/types/IntegerType.spec.js +8 -4
  583. package/dist/types/IntegerType.spec.js.map +1 -1
  584. package/dist/types/InterfaceType.d.ts +14 -6
  585. package/dist/types/InterfaceType.js +30 -15
  586. package/dist/types/InterfaceType.js.map +1 -1
  587. package/dist/types/InterfaceType.spec.d.ts +1 -0
  588. package/dist/types/InterfaceType.spec.js +227 -0
  589. package/dist/types/InterfaceType.spec.js.map +1 -0
  590. package/dist/types/IntersectionType.d.ts +29 -0
  591. package/dist/types/IntersectionType.js +253 -0
  592. package/dist/types/IntersectionType.js.map +1 -0
  593. package/dist/types/IntersectionType.spec.d.ts +1 -0
  594. package/dist/types/IntersectionType.spec.js +150 -0
  595. package/dist/types/IntersectionType.spec.js.map +1 -0
  596. package/dist/types/InvalidType.d.ts +10 -5
  597. package/dist/types/InvalidType.js +21 -9
  598. package/dist/types/InvalidType.js.map +1 -1
  599. package/dist/types/InvalidType.spec.js +8 -4
  600. package/dist/types/InvalidType.spec.js.map +1 -1
  601. package/dist/types/LongIntegerType.d.ts +10 -5
  602. package/dist/types/LongIntegerType.js +21 -17
  603. package/dist/types/LongIntegerType.js.map +1 -1
  604. package/dist/types/LongIntegerType.spec.js +10 -4
  605. package/dist/types/LongIntegerType.spec.js.map +1 -1
  606. package/dist/types/NamespaceType.d.ts +12 -0
  607. package/dist/types/NamespaceType.js +28 -0
  608. package/dist/types/NamespaceType.js.map +1 -0
  609. package/dist/types/ObjectType.d.ts +12 -5
  610. package/dist/types/ObjectType.js +25 -8
  611. package/dist/types/ObjectType.js.map +1 -1
  612. package/dist/types/ObjectType.spec.js +3 -3
  613. package/dist/types/ObjectType.spec.js.map +1 -1
  614. package/dist/types/ReferenceType.d.ts +123 -0
  615. package/dist/types/ReferenceType.js +720 -0
  616. package/dist/types/ReferenceType.js.map +1 -0
  617. package/dist/types/ReferenceType.spec.d.ts +1 -0
  618. package/dist/types/ReferenceType.spec.js +151 -0
  619. package/dist/types/ReferenceType.spec.js.map +1 -0
  620. package/dist/types/StringType.d.ts +12 -5
  621. package/dist/types/StringType.js +23 -8
  622. package/dist/types/StringType.js.map +1 -1
  623. package/dist/types/StringType.spec.js +3 -3
  624. package/dist/types/StringType.spec.js.map +1 -1
  625. package/dist/types/TypeStatementType.d.ts +18 -0
  626. package/dist/types/TypeStatementType.js +45 -0
  627. package/dist/types/TypeStatementType.js.map +1 -0
  628. package/dist/types/TypedFunctionType.d.ts +34 -0
  629. package/dist/types/TypedFunctionType.js +147 -0
  630. package/dist/types/TypedFunctionType.js.map +1 -0
  631. package/dist/types/TypedFunctionType.spec.d.ts +1 -0
  632. package/dist/types/TypedFunctionType.spec.js +122 -0
  633. package/dist/types/TypedFunctionType.spec.js.map +1 -0
  634. package/dist/types/UninitializedType.d.ts +11 -6
  635. package/dist/types/UninitializedType.js +20 -11
  636. package/dist/types/UninitializedType.js.map +1 -1
  637. package/dist/types/UnionType.d.ts +27 -0
  638. package/dist/types/UnionType.js +193 -0
  639. package/dist/types/UnionType.js.map +1 -0
  640. package/dist/types/UnionType.spec.d.ts +1 -0
  641. package/dist/types/UnionType.spec.js +205 -0
  642. package/dist/types/UnionType.spec.js.map +1 -0
  643. package/dist/types/VoidType.d.ts +11 -5
  644. package/dist/types/VoidType.js +22 -8
  645. package/dist/types/VoidType.js.map +1 -1
  646. package/dist/types/VoidType.spec.js +3 -3
  647. package/dist/types/VoidType.spec.js.map +1 -1
  648. package/dist/types/helper.spec.d.ts +1 -0
  649. package/dist/types/helper.spec.js +174 -0
  650. package/dist/types/helper.spec.js.map +1 -0
  651. package/dist/types/helpers.d.ts +51 -0
  652. package/dist/types/helpers.js +323 -0
  653. package/dist/types/helpers.js.map +1 -0
  654. package/dist/types/index.d.ts +22 -0
  655. package/dist/types/index.js +39 -0
  656. package/dist/types/index.js.map +1 -0
  657. package/dist/types/roFunctionType.d.ts +11 -0
  658. package/dist/types/roFunctionType.js +37 -0
  659. package/dist/types/roFunctionType.js.map +1 -0
  660. package/dist/types/roFunctionType.spec.d.ts +1 -0
  661. package/dist/types/roFunctionType.spec.js +20 -0
  662. package/dist/types/roFunctionType.spec.js.map +1 -0
  663. package/dist/util.d.ts +288 -187
  664. package/dist/util.js +2018 -575
  665. package/dist/util.js.map +1 -1
  666. package/dist/validators/ClassValidator.d.ts +9 -15
  667. package/dist/validators/ClassValidator.js +93 -138
  668. package/dist/validators/ClassValidator.js.map +1 -1
  669. package/package.json +185 -138
  670. package/CHANGELOG.md +0 -1188
  671. package/dist/astUtils/index.d.ts +0 -7
  672. package/dist/astUtils/index.js +0 -26
  673. package/dist/astUtils/index.js.map +0 -1
  674. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.d.ts +0 -7
  675. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.js +0 -63
  676. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.js.map +0 -1
  677. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.js +0 -45
  678. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.js.map +0 -1
  679. package/dist/lexer/index.d.ts +0 -3
  680. package/dist/lexer/index.js +0 -17
  681. package/dist/lexer/index.js.map +0 -1
  682. package/dist/parser/SGTypes.spec.js +0 -351
  683. package/dist/parser/SGTypes.spec.js.map +0 -1
  684. package/dist/parser/index.d.ts +0 -3
  685. package/dist/parser/index.js +0 -16
  686. package/dist/parser/index.js.map +0 -1
  687. package/dist/preprocessor/Chunk.d.ts +0 -82
  688. package/dist/preprocessor/Chunk.js +0 -77
  689. package/dist/preprocessor/Chunk.js.map +0 -1
  690. package/dist/preprocessor/Preprocessor.d.ts +0 -60
  691. package/dist/preprocessor/Preprocessor.js +0 -156
  692. package/dist/preprocessor/Preprocessor.js.map +0 -1
  693. package/dist/preprocessor/Preprocessor.spec.js +0 -152
  694. package/dist/preprocessor/Preprocessor.spec.js.map +0 -1
  695. package/dist/preprocessor/PreprocessorParser.d.ts +0 -61
  696. package/dist/preprocessor/PreprocessorParser.js +0 -194
  697. package/dist/preprocessor/PreprocessorParser.js.map +0 -1
  698. package/dist/preprocessor/PreprocessorParser.spec.js +0 -116
  699. package/dist/preprocessor/PreprocessorParser.spec.js.map +0 -1
  700. package/dist/preprocessor/index.d.ts +0 -3
  701. package/dist/preprocessor/index.js +0 -16
  702. package/dist/preprocessor/index.js.map +0 -1
  703. package/dist/types/CustomType.d.ts +0 -10
  704. package/dist/types/CustomType.js +0 -35
  705. package/dist/types/CustomType.js.map +0 -1
  706. package/dist/types/FunctionType.spec.js +0 -29
  707. package/dist/types/FunctionType.spec.js.map +0 -1
  708. package/dist/types/LazyType.d.ts +0 -15
  709. package/dist/types/LazyType.js +0 -32
  710. package/dist/types/LazyType.js.map +0 -1
  711. /package/dist/{bscPlugin/semanticTokens/SemanticTokensProcessor.spec.d.ts → astUtils/CachedLookups.spec.d.ts} +0 -0
  712. /package/dist/{parser/SGTypes.spec.d.ts → astUtils/Editor.spec.d.ts} +0 -0
  713. /package/dist/{preprocessor/Preprocessor.spec.d.ts → bscPlugin/completions/CompletionsProcessor.spec.d.ts} +0 -0
  714. /package/dist/{preprocessor/PreprocessorParser.spec.d.ts → bscPlugin/definition/DefinitionProvider.spec.d.ts} +0 -0
  715. /package/dist/{types/FunctionType.spec.d.ts → bscPlugin/hover/HoverProcessor.spec.d.ts} +0 -0
@@ -0,0 +1,824 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.ProjectManager = void 0;
10
+ const util_1 = require("../util");
11
+ const roku_deploy_1 = require("roku-deploy");
12
+ const path = require("path");
13
+ const EventEmitter = require("eventemitter3");
14
+ const Project_1 = require("./Project");
15
+ const WorkerThreadProject_1 = require("./worker/WorkerThreadProject");
16
+ const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
17
+ const deferred_1 = require("../deferred");
18
+ const DocumentManager_1 = require("./DocumentManager");
19
+ const BusyStatusTracker_1 = require("../BusyStatusTracker");
20
+ const fastGlob = require("fast-glob");
21
+ const PathFilterer_1 = require("./PathFilterer");
22
+ const logging_1 = require("../logging");
23
+ const Cache_1 = require("../Cache");
24
+ const ActionQueue_1 = require("./ActionQueue");
25
+ const fsExtra = require("fs-extra");
26
+ const FileChangeTypeLookup = Object.entries(vscode_languageserver_protocol_1.FileChangeType).reduce((acc, [key, value]) => {
27
+ acc[value] = key;
28
+ acc[key] = value;
29
+ return acc;
30
+ }, {});
31
+ /**
32
+ * Manages all brighterscript projects for the language server
33
+ */
34
+ class ProjectManager {
35
+ constructor(options) {
36
+ var _a, _b;
37
+ /**
38
+ * Collection of all projects
39
+ */
40
+ this.projects = [];
41
+ /**
42
+ * Collection of standalone projects. These are projects that are not part of a workspace, but are instead single files.
43
+ * All of these are also present in the `projects` collection.
44
+ */
45
+ this.standaloneProjects = new Map();
46
+ this.busyStatusTracker = new BusyStatusTracker_1.BusyStatusTracker();
47
+ this.firstSync = new deferred_1.Deferred();
48
+ this.fileChangesQueue = new ActionQueue_1.ActionQueue({
49
+ maxActionDuration: 45000
50
+ });
51
+ this.emitter = new EventEmitter();
52
+ this.logger = (_a = options === null || options === void 0 ? void 0 : options.logger) !== null && _a !== void 0 ? _a : (0, logging_1.createLogger)();
53
+ this.pathFilterer = (_b = options === null || options === void 0 ? void 0 : options.pathFilterer) !== null && _b !== void 0 ? _b : new PathFilterer_1.PathFilterer({ logger: options === null || options === void 0 ? void 0 : options.logger });
54
+ this.documentManager = new DocumentManager_1.DocumentManager({
55
+ delay: ProjectManager.documentManagerDelay,
56
+ flushHandler: (event) => {
57
+ return this.flushDocumentChanges(event).catch(e => console.error(e));
58
+ }
59
+ });
60
+ this.on('validate-begin', (event) => {
61
+ this.busyStatusTracker.beginScopedRun(event.project, `validate-project`);
62
+ });
63
+ this.on('validate-end', (event) => {
64
+ void this.busyStatusTracker.endScopedRun(event.project, `validate-project`);
65
+ });
66
+ }
67
+ /**
68
+ * Apply all of the queued document changes. This should only be called as a result of the documentManager flushing changes, and never called manually
69
+ * @param event the document changes that have occurred since the last time we applied
70
+ */
71
+ async flushDocumentChanges(event) {
72
+ var _a;
73
+ this.logger.info(`flushDocumentChanges`, (_a = event === null || event === void 0 ? void 0 : event.actions) === null || _a === void 0 ? void 0 : _a.map(x => ({
74
+ type: x.type,
75
+ srcPath: x.srcPath,
76
+ allowStandaloneProject: x.allowStandaloneProject
77
+ })));
78
+ //ensure that we're fully initialized before proceeding
79
+ await this.onInitialized();
80
+ const actions = [...event.actions];
81
+ let idSequence = 0;
82
+ //add an ID to every action (so we can track which actions were handled by which projects)
83
+ for (const action of actions) {
84
+ action.id = idSequence++;
85
+ }
86
+ //apply all of the document actions to each project in parallel
87
+ const responses = await Promise.all(this.projects.map(async (project) => {
88
+ //wait for this project to finish activating
89
+ await project.whenActivated();
90
+ const filterer = new PathFilterer_1.PathCollection({
91
+ rootDir: project.rootDir,
92
+ globs: project.filePatterns
93
+ });
94
+ // only include files that are applicable to this specific project (still allow deletes to flow through since they're cheap)
95
+ const projectActions = actions.filter(action => {
96
+ return (
97
+ //if this is a delete, just pass it through because they're cheap to apply
98
+ action.type === 'delete' ||
99
+ //if this is a set, only pass it through if it's a file that this project cares about
100
+ filterer.isMatch(action.srcPath));
101
+ });
102
+ if (projectActions.length > 0) {
103
+ const responseActions = await project.applyFileChanges(projectActions);
104
+ return responseActions.map(x => ({
105
+ project: project,
106
+ action: x
107
+ }));
108
+ }
109
+ }));
110
+ //create standalone projects for any files not handled by any project
111
+ const flatResponses = responses.flat();
112
+ for (const action of actions) {
113
+ //skip this action if it doesn't support standalone projects
114
+ if (!action.allowStandaloneProject || action.type !== 'set') {
115
+ continue;
116
+ }
117
+ //a list of responses that handled this action
118
+ const handledResponses = flatResponses.filter(x => { var _a, _b; return ((_a = x === null || x === void 0 ? void 0 : x.action) === null || _a === void 0 ? void 0 : _a.id) === action.id && ((_b = x === null || x === void 0 ? void 0 : x.action) === null || _b === void 0 ? void 0 : _b.status) === 'accepted'; });
119
+ //remove any standalone project created for this file since it was handled by a normal project
120
+ const normalProjectsThatHandledThisFile = handledResponses.filter(x => !x.project.isStandaloneProject);
121
+ if (normalProjectsThatHandledThisFile.length > 0) {
122
+ //if there's a standalone project for this file, delete it
123
+ if (this.getStandaloneProject(action.srcPath, false)) {
124
+ this.logger.debug(`flushDocumentChanges: removing standalone project because the following normal projects handled the file: '${action.srcPath}', projects:`, normalProjectsThatHandledThisFile.map(x => util_1.util.getProjectLogName(x.project)));
125
+ this.removeStandaloneProject(action.srcPath);
126
+ }
127
+ // create a standalone project if this action was handled by zero normal projects.
128
+ //(safe to call even if there's already a standalone project, won't create dupes)
129
+ }
130
+ else {
131
+ //TODO only create standalone projects for files we understand (brightscript, brighterscript, scenegraph xml, etc)
132
+ await this.createStandaloneProject(action.srcPath);
133
+ }
134
+ }
135
+ this.logger.info('flushDocumentChanges complete', actions.map(x => ({
136
+ type: x.type,
137
+ srcPath: x.srcPath,
138
+ allowStandaloneProject: x.allowStandaloneProject
139
+ })));
140
+ }
141
+ /**
142
+ * Get a standalone project for a given file path
143
+ */
144
+ getStandaloneProject(srcPath, standardizePath = true) {
145
+ return this.standaloneProjects.get(standardizePath ? util_1.util.standardizePath(srcPath) : srcPath);
146
+ }
147
+ /**
148
+ * Create a project that validates a single file. This is useful for getting language support for files that don't belong to a project
149
+ */
150
+ async createStandaloneProject(srcPath) {
151
+ srcPath = util_1.util.standardizePath(srcPath);
152
+ //if we already have a standalone project with this path, do nothing because it already exists
153
+ if (this.getStandaloneProject(srcPath, false)) {
154
+ this.logger.log('createStandaloneProject skipping because we already have one for this path');
155
+ return;
156
+ }
157
+ this.logger.log(`Creating standalone project for '${srcPath}'`);
158
+ const projectNumber = ProjectManager.projectNumberSequence++;
159
+ const rootDir = path.join(__dirname, `standalone-project-${projectNumber}`);
160
+ const projectConfig = {
161
+ //these folders don't matter for standalone projects
162
+ workspaceFolder: rootDir,
163
+ projectDir: rootDir,
164
+ //there's no bsconfig.json for standalone projects, so projectKey is the same as the dir
165
+ projectKey: rootDir,
166
+ bsconfigPath: undefined,
167
+ enableThreading: false,
168
+ projectNumber: projectNumber,
169
+ files: [{
170
+ src: srcPath,
171
+ dest: 'source/standalone.brs'
172
+ }]
173
+ };
174
+ const project = this.constructProject(projectConfig);
175
+ project.srcPath = srcPath;
176
+ project.isStandaloneProject = true;
177
+ this.standaloneProjects.set(srcPath, project);
178
+ await this.activateProject(project, projectConfig);
179
+ }
180
+ removeStandaloneProject(srcPath) {
181
+ srcPath = util_1.util.standardizePath(srcPath);
182
+ const project = this.getStandaloneProject(srcPath, false);
183
+ if (project) {
184
+ if (project.srcPath === srcPath) {
185
+ this.logger.debug(`Removing standalone project for file '${srcPath}'`);
186
+ this.removeProject(project);
187
+ this.standaloneProjects.delete(srcPath);
188
+ }
189
+ }
190
+ }
191
+ /**
192
+ * Get a promise that resolves when this manager is finished initializing
193
+ */
194
+ onInitialized() {
195
+ return Promise.allSettled([
196
+ //wait for the first sync to finish
197
+ this.firstSync.promise,
198
+ //make sure we're not in the middle of a sync
199
+ this.syncPromise,
200
+ //make sure all projects are activated
201
+ ...this.projects.map(x => x.whenActivated())
202
+ ]);
203
+ }
204
+ /**
205
+ * Get a promise that resolves when the project manager is idle (no pending work)
206
+ */
207
+ async onIdle() {
208
+ await this.onInitialized();
209
+ //There are race conditions where the fileChangesQueue will become idle, but that causes the documentManager
210
+ //to start a new flush. So we must keep waiting until everything is idle
211
+ while (!this.documentManager.isIdle || !this.fileChangesQueue.isIdle) {
212
+ this.logger.debug('onIdle', { documentManagerIdle: this.documentManager.isIdle, fileChangesQueueIdle: this.fileChangesQueue.isIdle });
213
+ await Promise.allSettled([
214
+ //make sure all pending file changes have been flushed
215
+ this.documentManager.onIdle(),
216
+ //wait for the file changes queue to be idle
217
+ this.fileChangesQueue.onIdle()
218
+ ]);
219
+ }
220
+ this.logger.info('onIdle debug', { documentManagerIdle: this.documentManager.isIdle, fileChangesQueueIdle: this.fileChangesQueue.isIdle });
221
+ }
222
+ /**
223
+ * Given a list of all desired projects, create any missing projects and destroy and projects that are no longer available
224
+ * Treat workspaces that don't have a bsconfig.json as a project.
225
+ * Handle situations where bsconfig.json files were added or removed (to elevate/lower workspaceFolder projects accordingly)
226
+ * Leave existing projects alone if they are not affected by these changes
227
+ * @param workspaceConfigs an array of workspaces
228
+ */
229
+ async syncProjects(workspaceConfigs, forceReload = false) {
230
+ //if we're force reloading, destroy all projects and start fresh
231
+ if (forceReload) {
232
+ this.logger.log('syncProjects: forceReload is true so removing all existing projects');
233
+ for (const project of this.projects) {
234
+ this.removeProject(project);
235
+ }
236
+ }
237
+ this.logger.log('syncProjects', workspaceConfigs.map(x => x.workspaceFolder));
238
+ this.syncPromise = (async () => {
239
+ //build a list of unique projects across all workspace folders
240
+ let projectConfigs = (await Promise.all(workspaceConfigs.map(async (workspaceConfig) => {
241
+ const discoveredProjects = await this.discoverProjectsForWorkspace(workspaceConfig);
242
+ return discoveredProjects.map(discoveredProject => {
243
+ var _a;
244
+ return ({
245
+ name: discoveredProject === null || discoveredProject === void 0 ? void 0 : discoveredProject.name,
246
+ projectKey: (0, util_1.standardizePath) `${(_a = discoveredProject.bsconfigPath) !== null && _a !== void 0 ? _a : discoveredProject.dir}`,
247
+ projectDir: (0, util_1.standardizePath) `${discoveredProject.dir}`,
248
+ bsconfigPath: discoveredProject === null || discoveredProject === void 0 ? void 0 : discoveredProject.bsconfigPath,
249
+ workspaceFolder: (0, util_1.standardizePath) `${workspaceConfig.workspaceFolder}`,
250
+ excludePatterns: workspaceConfig.excludePatterns,
251
+ enableThreading: workspaceConfig.languageServer.enableThreading
252
+ });
253
+ });
254
+ }))).flat(1);
255
+ //TODO handle when a project came from the workspace config .projects array (it should probably never be filtered out)
256
+ //filter the project paths to only include those that are allowed by the path filterer
257
+ projectConfigs = this.pathFilterer.filter(projectConfigs, x => x.projectKey);
258
+ //delete projects not represented in the list
259
+ for (const project of this.projects) {
260
+ //we can't find this existing project in our new list, so scrap it
261
+ if (!projectConfigs.find(x => x.projectKey === project.projectKey)) {
262
+ this.removeProject(project);
263
+ }
264
+ }
265
+ // skip projects we already have (they're already loaded...no need to reload them)
266
+ projectConfigs = projectConfigs.filter(x => {
267
+ return !this.hasProject(x);
268
+ });
269
+ //dedupe by projectKey
270
+ projectConfigs = [
271
+ ...projectConfigs.reduce((acc, x) => acc.set(x.projectKey, x), new Map()).values()
272
+ ];
273
+ //create missing projects
274
+ await Promise.all(projectConfigs.map(async (config) => {
275
+ await this.createAndActivateProject(config);
276
+ }));
277
+ //mark that we've completed our first sync
278
+ this.firstSync.tryResolve();
279
+ })();
280
+ //return the sync promise
281
+ return this.syncPromise;
282
+ }
283
+ handleFileChanges(changes) {
284
+ this.logger.debug('handleFileChanges', changes.map(x => `${FileChangeTypeLookup[x.type]}: ${x.srcPath}`));
285
+ //this function should NOT be marked as async, because typescript wraps the body in an async call sometimes. These need to be registered synchronously
286
+ return this.fileChangesQueue.run(async (changes) => {
287
+ //wait for any pending syncs to finish
288
+ await this.onInitialized();
289
+ return this._handleFileChanges(changes);
290
+ }, changes);
291
+ }
292
+ /**
293
+ * Handle when files or directories are added, changed, or deleted in the workspace.
294
+ * This is safe to call any time. Changes will be queued and flushed at the correct times
295
+ */
296
+ async _handleFileChanges(changes) {
297
+ //normalize srcPath for all changes
298
+ for (const change of changes) {
299
+ change.srcPath = util_1.util.standardizePath(change.srcPath);
300
+ }
301
+ //filter any changes that are not allowed by the path filterer
302
+ changes = this.pathFilterer.filter(changes, x => x.srcPath);
303
+ this.logger.debug('handleFileChanges -> filtered', changes.map(x => `${FileChangeTypeLookup[x.type]}: ${x.srcPath}`));
304
+ //process all file changes in parallel
305
+ await Promise.all(changes.map(async (change) => {
306
+ await this.handleFileChange(change);
307
+ }));
308
+ }
309
+ /**
310
+ * Handle a single file change. If the file is a directory, this will recursively read all files in the directory and call `handleFileChanges` again
311
+ */
312
+ async handleFileChange(change) {
313
+ if (change.type === vscode_languageserver_protocol_1.FileChangeType.Deleted) {
314
+ //mark this document or directory as deleted
315
+ this.documentManager.delete(change.srcPath);
316
+ //file added or changed
317
+ }
318
+ else {
319
+ //if this is a new directory, read all files recursively and register those as file changes too
320
+ if (util_1.util.isDirectorySync(change.srcPath)) {
321
+ const files = await fastGlob('**/*', {
322
+ cwd: change.srcPath,
323
+ onlyFiles: true,
324
+ absolute: true
325
+ });
326
+ //pipe all files found recursively in the new directory through this same function so they can be processed correctly
327
+ await Promise.all(files.map((srcPath) => {
328
+ return this.handleFileChange({
329
+ srcPath: util_1.util.standardizePath(srcPath),
330
+ type: vscode_languageserver_protocol_1.FileChangeType.Changed,
331
+ allowStandaloneProject: change.allowStandaloneProject
332
+ });
333
+ }));
334
+ //this is a new file. set the file contents
335
+ }
336
+ else {
337
+ this.documentManager.set({
338
+ srcPath: change.srcPath,
339
+ fileContents: change.fileContents,
340
+ allowStandaloneProject: change.allowStandaloneProject
341
+ });
342
+ }
343
+ }
344
+ //reload any projects whose bsconfig.json was changed
345
+ const projectsToReload = this.projects.filter(project => {
346
+ var _a;
347
+ //this is a path to a bsconfig.json file
348
+ if (((_a = project.bsconfigPath) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === change.srcPath.toLowerCase()) {
349
+ //fetch file contents if we don't already have them
350
+ if (!change.fileContents) {
351
+ try {
352
+ change.fileContents = fsExtra.readFileSync(project.bsconfigPath).toString();
353
+ }
354
+ finally { }
355
+ }
356
+ ///the bsconfig contents have changed since we last saw it, so reload this project
357
+ if (project.bsconfigFileContents !== change.fileContents) {
358
+ return true;
359
+ }
360
+ }
361
+ return false;
362
+ });
363
+ if (projectsToReload.length > 0) {
364
+ await Promise.all(projectsToReload.map(x => this.reloadProject(x)));
365
+ }
366
+ }
367
+ /**
368
+ * Handle when a file is closed in the editor (this mostly just handles removing standalone projects)
369
+ */
370
+ async handleFileClose(event) {
371
+ this.logger.debug(`File was closed. ${event.srcPath}`);
372
+ this.removeStandaloneProject(event.srcPath);
373
+ //most other methods on this class are async, might as well make this one async too for consistency and future expansion
374
+ await Promise.resolve();
375
+ }
376
+ /**
377
+ * Given a project, forcibly reload it by removing it and re-adding it
378
+ */
379
+ async reloadProject(project) {
380
+ this.logger.log('Reloading project', { projectPath: project.projectKey });
381
+ this.removeProject(project);
382
+ project = await this.createAndActivateProject(project.activateOptions);
383
+ }
384
+ /**
385
+ * Get all the semantic tokens for the given file
386
+ * @returns an array of semantic tokens
387
+ */
388
+ async getSemanticTokens(options) {
389
+ //wait for all pending syncs to finish
390
+ await this.onIdle();
391
+ let result = await util_1.util.promiseRaceMatch(this.projects.map(x => x.getSemanticTokens(options)),
392
+ //keep the first non-falsey result
393
+ (result) => (result === null || result === void 0 ? void 0 : result.length) > 0);
394
+ return result;
395
+ }
396
+ /**
397
+ * Get a string containing the transpiled contents of the file at the given path
398
+ * @returns the transpiled contents of the file as a string
399
+ */
400
+ async transpileFile(options) {
401
+ //wait for all pending syncs to finish
402
+ await this.onIdle();
403
+ let result = await util_1.util.promiseRaceMatch(this.projects.map(x => x.transpileFile(options)),
404
+ //keep the first non-falsey result
405
+ (result) => !!result);
406
+ return result;
407
+ }
408
+ /**
409
+ * Get the completions for the given position in the file
410
+ */
411
+ async getCompletions(options) {
412
+ var _a;
413
+ await this.onIdle();
414
+ //if the request has been cancelled since originally requested due to idle time being slow, skip the rest of the wor
415
+ if ((_a = options === null || options === void 0 ? void 0 : options.cancellationToken) === null || _a === void 0 ? void 0 : _a.isCancellationRequested) {
416
+ this.logger.debug('ProjectManager getCompletions cancelled', options);
417
+ return;
418
+ }
419
+ this.logger.debug('ProjectManager getCompletions', options);
420
+ //Ask every project for results, keep whichever one responds first that has a valid response
421
+ let result = await util_1.util.promiseRaceMatch(this.projects.map(x => x.getCompletions(options)),
422
+ //keep the first non-falsey result
423
+ (result) => { var _a; return ((_a = result === null || result === void 0 ? void 0 : result.items) === null || _a === void 0 ? void 0 : _a.length) > 0; });
424
+ return result;
425
+ }
426
+ /**
427
+ * Get the hover information for the given position in the file. If multiple projects have hover information, the projects will be raced and
428
+ * the fastest result will be returned
429
+ * @returns the hover information or undefined if no hover information was found
430
+ */
431
+ async getHover(options) {
432
+ //wait for all pending syncs to finish
433
+ await this.onIdle();
434
+ //Ask every project for hover info, keep whichever one responds first that has a valid response
435
+ let hovers = await util_1.util.promiseRaceMatch(this.projects.map(x => x.getHover(options)),
436
+ //keep the first set of non-empty results
437
+ (result) => (result === null || result === void 0 ? void 0 : result.length) > 0);
438
+ let result = {
439
+ contents: [],
440
+ range: undefined
441
+ };
442
+ //consolidate all hover results into a single hover
443
+ for (const hover of hovers !== null && hovers !== void 0 ? hovers : []) {
444
+ if (typeof (hover === null || hover === void 0 ? void 0 : hover.contents) === 'string') {
445
+ result.contents.push(hover.contents);
446
+ }
447
+ else if (Array.isArray(hover === null || hover === void 0 ? void 0 : hover.contents)) {
448
+ result.contents.push(...hover.contents);
449
+ }
450
+ if (!result.range && hover.range) {
451
+ result.range = hover.range;
452
+ }
453
+ result.range = util_1.util.createBoundingRange(result.range, hover.range);
454
+ }
455
+ //now only keep unique hovers
456
+ result.contents = [...new Set(result.contents)];
457
+ return result;
458
+ }
459
+ /**
460
+ * Get the definition for the symbol at the given position in the file
461
+ * @returns a list of locations where the symbol under the position is defined in the project
462
+ */
463
+ async getDefinition(options) {
464
+ //wait for all pending syncs to finish
465
+ await this.onIdle();
466
+ //TODO should we merge definitions across ALL projects? or just return definitions from the first project we found
467
+ //Ask every project for definition info, keep whichever one responds first that has a valid response
468
+ let result = await util_1.util.promiseRaceMatch(this.projects.map(x => x.getDefinition(options)),
469
+ //keep the first non-falsey result
470
+ (result) => !!result);
471
+ return result;
472
+ }
473
+ async getSignatureHelp(options) {
474
+ var _a;
475
+ //wait for all pending syncs to finish
476
+ await this.onIdle();
477
+ //Ask every project for definition info, keep whichever one responds first that has a valid response
478
+ let signatures = await util_1.util.promiseRaceMatch(this.projects.map(x => x.getSignatureHelp(options)),
479
+ //keep the first non-falsey result
480
+ (result) => !!result);
481
+ if ((signatures === null || signatures === void 0 ? void 0 : signatures.length) > 0) {
482
+ const activeSignature = signatures.length > 0 ? 0 : undefined;
483
+ const activeParameter = activeSignature >= 0 ? (_a = signatures[activeSignature]) === null || _a === void 0 ? void 0 : _a.index : undefined;
484
+ let result = {
485
+ signatures: signatures.map((s) => s.signature),
486
+ activeSignature: activeSignature,
487
+ activeParameter: activeParameter
488
+ };
489
+ return result;
490
+ }
491
+ }
492
+ async getDocumentSymbol(options) {
493
+ //wait for all pending syncs to finish
494
+ await this.onIdle();
495
+ //Ask every project for definition info, keep whichever one responds first that has a valid response
496
+ let result = await util_1.util.promiseRaceMatch(this.projects.map(x => x.getDocumentSymbol(options)),
497
+ //keep the first non-falsey result
498
+ (result) => !!result);
499
+ return result;
500
+ }
501
+ async getWorkspaceSymbol() {
502
+ //wait for all pending syncs to finish
503
+ await this.onIdle();
504
+ //Ask every project for definition info, keep whichever one responds first that has a valid response
505
+ let responses = await Promise.allSettled(this.projects.map(x => x.getWorkspaceSymbol()));
506
+ let results = responses
507
+ //keep all symbol results
508
+ .map((x) => {
509
+ return x.status === 'fulfilled' ? x.value : [];
510
+ })
511
+ //flatten the array
512
+ .flat()
513
+ //throw out nulls
514
+ .filter(x => !!x);
515
+ // Remove duplicates
516
+ const allSymbols = Object.values(results.reduce((map, symbol) => {
517
+ const key = symbol.location.uri + symbol.name;
518
+ map[key] = symbol;
519
+ return map;
520
+ }, {}));
521
+ return allSymbols;
522
+ }
523
+ async getReferences(options) {
524
+ //wait for all pending syncs to finish
525
+ await this.onIdle();
526
+ //Ask every project for definition info, keep whichever one responds first that has a valid response
527
+ let result = await util_1.util.promiseRaceMatch(this.projects.map(x => x.getReferences(options)),
528
+ //keep the first non-falsey result
529
+ (result) => !!result);
530
+ return result !== null && result !== void 0 ? result : [];
531
+ }
532
+ async getCodeActions(options) {
533
+ //wait for all pending syncs to finish
534
+ await this.onIdle();
535
+ //Ask every project for definition info, keep whichever one responds first that has a valid response
536
+ let result = await util_1.util.promiseRaceMatch(this.projects.map(x => x.getCodeActions(options)),
537
+ //keep the first non-falsey result
538
+ (result) => !!result);
539
+ return result;
540
+ }
541
+ /**
542
+ * Scan a given workspace for all `bsconfig.json` files. If at least one is found, then only folders who have bsconfig.json are returned.
543
+ * If none are found, then the workspaceFolder itself is treated as a project
544
+ */
545
+ async discoverProjectsForWorkspace(workspaceConfig) {
546
+ var _a, _b, _c;
547
+ //config may provide a list of project paths. If we have these, no other discovery is permitted
548
+ if (Array.isArray(workspaceConfig.projects) && workspaceConfig.projects.length > 0) {
549
+ this.logger.debug(`Using project paths from workspace config`, workspaceConfig.projects);
550
+ const projectConfigs = workspaceConfig.projects.reduce((acc, project) => {
551
+ //skip this project if it's disabled or we don't have a path
552
+ if (project.disabled || !project.path) {
553
+ return acc;
554
+ }
555
+ //ensure the project path is absolute
556
+ if (!path.isAbsolute(project.path)) {
557
+ project.path = path.resolve(workspaceConfig.workspaceFolder, project.path);
558
+ }
559
+ //skip this project if the path does't exist
560
+ if (!fsExtra.existsSync(project.path)) {
561
+ return acc;
562
+ }
563
+ //if the project is a directory
564
+ if (fsExtra.statSync(project.path).isDirectory()) {
565
+ acc.push({
566
+ name: project.name,
567
+ bsconfigPath: undefined,
568
+ dir: project.path
569
+ });
570
+ //it's a path to a file (hopefully bsconfig.json)
571
+ }
572
+ else {
573
+ acc.push({
574
+ name: project.name,
575
+ dir: path.dirname(project.path),
576
+ bsconfigPath: project.path
577
+ });
578
+ }
579
+ return acc;
580
+ }, []);
581
+ //if we didn't find any valid project paths, log a warning. having zero projects is acceptable, it typically means the user wanted to disable discovery or
582
+ //disabled all their projects on purpose
583
+ if (projectConfigs.length === 0) {
584
+ this.logger.warn(`No valid project paths found in workspace config`, JSON.stringify(workspaceConfig.projects, null, 4));
585
+ }
586
+ return projectConfigs;
587
+ }
588
+ //automatic discovery disabled?
589
+ if (!workspaceConfig.languageServer.enableProjectDiscovery) {
590
+ return [{
591
+ dir: workspaceConfig.workspaceFolder
592
+ }];
593
+ }
594
+ //get the list of exclude patterns, negate them so they actually work like excludes), and coerce to forward slashes since that's what fast-glob expects
595
+ const excludePatterns = ((_a = workspaceConfig.excludePatterns) !== null && _a !== void 0 ? _a : []).map(x => (0, util_1.standardizePath) `!${x}`.replace(/[\\/]+/g, '/'));
596
+ let files = await fastGlob(['**/bsconfig.json', ...excludePatterns], {
597
+ cwd: workspaceConfig.workspaceFolder,
598
+ followSymbolicLinks: false,
599
+ absolute: true,
600
+ onlyFiles: true,
601
+ deep: (_b = workspaceConfig.languageServer.projectDiscoveryMaxDepth) !== null && _b !== void 0 ? _b : 15
602
+ });
603
+ //filter the files to only include those that are allowed by the path filterer
604
+ files = this.pathFilterer.filter(files);
605
+ //if we found at least one bsconfig.json, then ALL projects must have a bsconfig.json.
606
+ if (files.length > 0) {
607
+ return files.map(file => ({
608
+ dir: (0, util_1.standardizePath) `${path.dirname(file)}`,
609
+ bsconfigPath: (0, util_1.standardizePath) `${file}`
610
+ }));
611
+ }
612
+ //look for roku project folders
613
+ let rokuLikeDirs = (await Promise.all(
614
+ //find all folders containing a `manifest` file
615
+ (await fastGlob(['**/manifest', ...excludePatterns], {
616
+ cwd: workspaceConfig.workspaceFolder,
617
+ followSymbolicLinks: false,
618
+ absolute: true,
619
+ onlyFiles: true,
620
+ deep: (_c = workspaceConfig.languageServer.projectDiscoveryMaxDepth) !== null && _c !== void 0 ? _c : 15
621
+ })).map(async (manifestEntry) => {
622
+ const manifestDir = path.dirname(manifestEntry);
623
+ //TODO validate that manifest is a Roku manifest
624
+ const files = await roku_deploy_1.rokuDeploy.getFilePaths([
625
+ 'source/**/*.{brs,bs}',
626
+ ...excludePatterns
627
+ ], manifestDir);
628
+ if (files.length > 0) {
629
+ return (0, util_1.standardizePath) `${manifestDir}`;
630
+ }
631
+ })
632
+ //throw out nulls
633
+ )).filter(x => !!x);
634
+ //throw out any directories that are not allowed by the path filterer
635
+ rokuLikeDirs = this.pathFilterer.filter(rokuLikeDirs, srcPath => srcPath);
636
+ if (rokuLikeDirs.length > 0) {
637
+ return rokuLikeDirs.map(file => ({
638
+ dir: file
639
+ }));
640
+ }
641
+ //treat the workspace folder as a brightscript project itself
642
+ return [{
643
+ dir: workspaceConfig.workspaceFolder
644
+ }];
645
+ }
646
+ /**
647
+ * Returns true if we have this project, or false if we don't
648
+ * @returns true if the project exists, or false if it doesn't
649
+ */
650
+ hasProject(config) {
651
+ return !!this.getProject(config);
652
+ }
653
+ /**
654
+ * Get a project with the specified path
655
+ * @param param path to the project or an obj that has `projectPath` prop
656
+ * @returns a project, or undefined if no project was found
657
+ */
658
+ getProject(param) {
659
+ var _a, _b;
660
+ const projectKey = util_1.util.standardizePath((typeof param === 'string') ? param : ((_b = (_a = param === null || param === void 0 ? void 0 : param.projectKey) !== null && _a !== void 0 ? _a : param === null || param === void 0 ? void 0 : param.bsconfigPath) !== null && _b !== void 0 ? _b : param === null || param === void 0 ? void 0 : param.projectDir));
661
+ if (!projectKey) {
662
+ return;
663
+ }
664
+ return this.projects.find(x => x.projectKey === projectKey);
665
+ }
666
+ /**
667
+ * Remove a project from the language server
668
+ */
669
+ removeProject(project) {
670
+ const idx = this.projects.findIndex(x => x.projectKey === (project === null || project === void 0 ? void 0 : project.projectKey));
671
+ if (idx > -1) {
672
+ this.logger.log('Removing project', { projectKey: project.projectKey, projectNumber: project.projectNumber });
673
+ this.projects.splice(idx, 1);
674
+ }
675
+ //anytime we remove a project, we should emit an event that clears all of its diagnostics
676
+ this.emit('diagnostics', { project: project, diagnostics: [] });
677
+ project === null || project === void 0 ? void 0 : project.dispose();
678
+ this.busyStatusTracker.endAllRunsForScope(project);
679
+ }
680
+ /**
681
+ * Get a projectNumber for a given config. Try to reuse project numbers when we've seen this project before
682
+ * - If the config already has one, use that.
683
+ * - If we've already seen this config before, use the same project number as before
684
+ */
685
+ getProjectNumber(config) {
686
+ if (config.projectNumber !== undefined) {
687
+ return config.projectNumber;
688
+ }
689
+ const key = (0, util_1.standardizePath) `${config.projectKey}` + '-' + (0, util_1.standardizePath) `${config.workspaceFolder}` + '-' + (0, util_1.standardizePath) `${config.bsconfigPath}`;
690
+ return ProjectManager.projectNumberCache.getOrAdd(key, () => {
691
+ return ProjectManager.projectNumberSequence++;
692
+ });
693
+ }
694
+ /**
695
+ * Constructs a project for the given config. Just makes the project, doesn't activate it
696
+ * @returns a new project, or the existing project if one already exists with this config info
697
+ */
698
+ constructProject(config) {
699
+ //skip this project if we already have it
700
+ if (this.hasProject(config)) {
701
+ return this.getProject(config);
702
+ }
703
+ config.projectNumber = this.getProjectNumber(config);
704
+ let project = config.enableThreading
705
+ ? new WorkerThreadProject_1.WorkerThreadProject({
706
+ logger: this.logger.createLogger()
707
+ })
708
+ : new Project_1.Project({
709
+ logger: this.logger.createLogger()
710
+ });
711
+ this.logger.log(`Created project #${config.projectNumber} for: "${config.projectKey}" (${config.enableThreading ? 'worker thread' : 'main thread'})`);
712
+ this.projects.push(project);
713
+ //pipe all project-specific events through our emitter, and include the project reference
714
+ project.on('all', (eventName, data) => {
715
+ this.emit(eventName, Object.assign(Object.assign({}, data), { project: project }));
716
+ });
717
+ return project;
718
+ }
719
+ /**
720
+ * Constructs a project for the given config
721
+ * @returns a new project, or the existing project if one already exists with this config info
722
+ */
723
+ async createAndActivateProject(config) {
724
+ //skip this project if we already have it
725
+ if (this.hasProject(config)) {
726
+ return this.getProject(config.projectKey);
727
+ }
728
+ const project = this.constructProject(config);
729
+ await this.activateProject(project, config);
730
+ return project;
731
+ }
732
+ async activateProject(project, config) {
733
+ this.logger.debug('Activating project', util_1.util.getProjectLogName(project), {
734
+ projectPath: config === null || config === void 0 ? void 0 : config.projectKey,
735
+ bsconfigPath: config.bsconfigPath
736
+ });
737
+ await project.activate(config);
738
+ //send an event to indicate that this project has been activated
739
+ this.emit('project-activate', { project: project });
740
+ //register this project's list of files with the path filterer
741
+ const unregister = this.pathFilterer.registerIncludeList(project.rootDir, project.filePatterns);
742
+ project.disposables.push({ dispose: unregister });
743
+ }
744
+ on(eventName, handler) {
745
+ this.emitter.on(eventName, handler);
746
+ return () => {
747
+ this.emitter.removeListener(eventName, handler);
748
+ };
749
+ }
750
+ async emit(eventName, data) {
751
+ //emit these events on next tick, otherwise they will be processed immediately which could cause issues
752
+ await util_1.util.sleep(0);
753
+ this.emitter.emit(eventName, data);
754
+ }
755
+ dispose() {
756
+ var _a;
757
+ this.emitter.removeAllListeners();
758
+ for (const project of this.projects) {
759
+ (_a = project === null || project === void 0 ? void 0 : project.dispose) === null || _a === void 0 ? void 0 : _a.call(project);
760
+ }
761
+ }
762
+ }
763
+ ProjectManager.documentManagerDelay = 150;
764
+ /**
765
+ * A unique project counter to help distinguish log entries in lsp mode
766
+ */
767
+ ProjectManager.projectNumberSequence = 0;
768
+ ProjectManager.projectNumberCache = new Cache_1.Cache();
769
+ __decorate([
770
+ TrackBusyStatus
771
+ ], ProjectManager.prototype, "flushDocumentChanges", null);
772
+ __decorate([
773
+ TrackBusyStatus
774
+ ], ProjectManager.prototype, "syncProjects", null);
775
+ __decorate([
776
+ TrackBusyStatus
777
+ ], ProjectManager.prototype, "getSemanticTokens", null);
778
+ __decorate([
779
+ TrackBusyStatus
780
+ ], ProjectManager.prototype, "transpileFile", null);
781
+ __decorate([
782
+ TrackBusyStatus
783
+ ], ProjectManager.prototype, "getCompletions", null);
784
+ __decorate([
785
+ TrackBusyStatus
786
+ ], ProjectManager.prototype, "getHover", null);
787
+ __decorate([
788
+ TrackBusyStatus
789
+ ], ProjectManager.prototype, "getDefinition", null);
790
+ __decorate([
791
+ TrackBusyStatus
792
+ ], ProjectManager.prototype, "getSignatureHelp", null);
793
+ __decorate([
794
+ TrackBusyStatus
795
+ ], ProjectManager.prototype, "getDocumentSymbol", null);
796
+ __decorate([
797
+ TrackBusyStatus
798
+ ], ProjectManager.prototype, "getWorkspaceSymbol", null);
799
+ __decorate([
800
+ TrackBusyStatus
801
+ ], ProjectManager.prototype, "getReferences", null);
802
+ __decorate([
803
+ TrackBusyStatus
804
+ ], ProjectManager.prototype, "getCodeActions", null);
805
+ __decorate([
806
+ TrackBusyStatus
807
+ ], ProjectManager.prototype, "createAndActivateProject", null);
808
+ __decorate([
809
+ TrackBusyStatus
810
+ ], ProjectManager.prototype, "activateProject", null);
811
+ exports.ProjectManager = ProjectManager;
812
+ /**
813
+ * An annotation used to wrap the method in a busyStatus tracking call
814
+ */
815
+ function TrackBusyStatus(target, propertyKey, descriptor) {
816
+ let originalMethod = descriptor.value;
817
+ //wrapping the original method
818
+ descriptor.value = function value(...args) {
819
+ return this.busyStatusTracker.run(() => {
820
+ return originalMethod.apply(this, args);
821
+ }, originalMethod.name);
822
+ };
823
+ }
824
+ //# sourceMappingURL=ProjectManager.js.map