brighterscript 1.0.0-alpha.5 → 1.0.0-alpha.51

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