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
@@ -6,39 +6,30 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.CustomCommands = exports.LanguageServer = void 0;
10
- require("array-flat-polyfill");
11
- const glob = require("glob");
9
+ exports.NotificationName = exports.CustomCommands = exports.LanguageServer = void 0;
12
10
  const path = require("path");
13
- const rokuDeploy = require("roku-deploy");
11
+ require("array-flat-polyfill");
14
12
  const node_1 = require("vscode-languageserver/node");
15
13
  const vscode_uri_1 = require("vscode-uri");
16
14
  const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
17
- const deferred_1 = require("./deferred");
18
- const DiagnosticMessages_1 = require("./DiagnosticMessages");
19
- const ProgramBuilder_1 = require("./ProgramBuilder");
20
15
  const util_1 = require("./util");
21
- const Logger_1 = require("./Logger");
22
- const Throttler_1 = require("./Throttler");
23
- const KeyedThrottler_1 = require("./KeyedThrottler");
24
16
  const DiagnosticCollection_1 = require("./DiagnosticCollection");
25
- const reflection_1 = require("./astUtils/reflection");
26
17
  const SemanticTokenUtils_1 = require("./SemanticTokenUtils");
18
+ const logging_1 = require("./logging");
19
+ const ignore_1 = require("ignore");
20
+ const micromatch = require("micromatch");
21
+ const PathFilterer_1 = require("./lsp/PathFilterer");
22
+ const ProjectManager_1 = require("./lsp/ProjectManager");
23
+ const fsExtra = require("fs-extra");
24
+ const WorkerThreadProject_1 = require("./lsp/worker/WorkerThreadProject");
25
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
26
+ const isEqual = require("lodash.isequal");
27
27
  class LanguageServer {
28
28
  constructor() {
29
- this.connection = undefined;
30
- this.workspaces = [];
31
- /**
32
- * The number of milliseconds that should be used for language server typing debouncing
33
- */
34
- this.debounceTimeout = 150;
35
29
  /**
36
- * These workspaces are created on the fly whenever a file is opened that is not included
37
- * in any of the workspace projects.
38
- * Basically these are single-file workspaces to at least get parsing for standalone files.
39
- * Also, they should only be created when the file is opened, and destroyed when the file is closed.
30
+ * The language server protocol connection, used to send and receive all requests and responses
40
31
  */
41
- this.standaloneFileWorkspaces = {};
32
+ this.connection = undefined;
42
33
  this.hasConfigurationCapability = false;
43
34
  /**
44
35
  * Indicates whether the client supports workspace folders
@@ -49,77 +40,73 @@ class LanguageServer {
49
40
  * The text document manager supports full document sync only
50
41
  */
51
42
  this.documents = new node_1.TextDocuments(vscode_languageserver_textdocument_1.TextDocument);
52
- this.keyedThrottler = new KeyedThrottler_1.KeyedThrottler(this.debounceTimeout);
53
- this.validateThrottler = new Throttler_1.Throttler(0);
54
- this.boundValidateAll = this.validateAll.bind(this);
43
+ this.logger = (0, logging_1.createLogger)({
44
+ logLevel: logging_1.LogLevel.log
45
+ });
46
+ this.workspaceConfigsCache = new Map();
47
+ this.busyStatusIndex = -1;
48
+ this.pathFiltererDisposables = [];
55
49
  this.diagnosticCollection = new DiagnosticCollection_1.DiagnosticCollection();
56
- }
57
- createConnection() {
58
- return node_1.createConnection(node_1.ProposedFeatures.all);
59
- }
60
- validateAllThrottled() {
61
- return this.validateThrottler.run(this.boundValidateAll);
50
+ (0, logging_1.setLspLoggerProps)();
51
+ //replace the workerPool logger with our own so logging info can be synced
52
+ WorkerThreadProject_1.workerPool.logger = this.logger.createLogger();
53
+ this.pathFilterer = new PathFilterer_1.PathFilterer({ logger: this.logger });
54
+ this.projectManager = new ProjectManager_1.ProjectManager({
55
+ pathFilterer: this.pathFilterer,
56
+ logger: this.logger.createLogger()
57
+ });
58
+ //anytime a project emits a collection of diagnostics, send them to the client
59
+ this.projectManager.on('diagnostics', (event) => {
60
+ this.logger.debug(`Received ${event.diagnostics.length} diagnostics from project ${event.project.projectNumber}`);
61
+ this.sendDiagnostics(event).catch(logAndIgnoreError);
62
+ });
63
+ // Send all open document changes whenever a project is activated. This is necessary because at project startup, the project loads files from disk
64
+ // and may not have the latest unsaved file changes. Any existing projects that already use these files will just ignore the changes
65
+ // because the file contents haven't changed.
66
+ this.projectManager.on('project-activate', (event) => {
67
+ //keep logLevel in sync with the most verbose log level found across all projects
68
+ this.syncLogLevel().catch(logAndIgnoreError);
69
+ //resend all open document changes
70
+ const documents = [...this.documents.all()];
71
+ if (documents.length > 0) {
72
+ this.logger.log(`[${util_1.util.getProjectLogName(event.project)}] loaded or changed. Resending all open document changes.`, documents.map(x => x.uri));
73
+ for (const document of this.documents.all()) {
74
+ this.onTextDocumentDidChangeContent({
75
+ document: document
76
+ }).catch(logAndIgnoreError);
77
+ }
78
+ }
79
+ });
80
+ this.projectManager.busyStatusTracker.on('active-runs-change', (event) => {
81
+ this.sendBusyStatus();
82
+ });
62
83
  }
63
84
  //run the server
64
85
  run() {
86
+ var _a;
65
87
  // Create a connection for the server. The connection uses Node's IPC as a transport.
66
- // Also include all preview / proposed LSP features.
67
- this.connection = this.createConnection();
88
+ this.connection = this.establishConnection();
89
+ //disable logger colors when running in LSP mode
90
+ logging_1.logger.enableColor = false;
68
91
  //listen to all of the output log events and pipe them into the debug channel in the extension
69
- this.loggerSubscription = Logger_1.Logger.subscribe((text) => {
70
- this.connection.tracer.log(text);
92
+ this.loggerSubscription = logging_1.logger.subscribe((message) => {
93
+ this.connection.tracer.log(message.argsText);
71
94
  });
72
- this.connection.onInitialize(this.onInitialize.bind(this));
73
- this.connection.onInitialized(this.onInitialized.bind(this)); //eslint-disable-line
74
- this.connection.onDidChangeConfiguration(this.onDidChangeConfiguration.bind(this)); //eslint-disable-line
75
- this.connection.onDidChangeWatchedFiles(this.onDidChangeWatchedFiles.bind(this)); //eslint-disable-line
95
+ //bind all our on* methods that share the same name from connection
96
+ for (const name of Object.getOwnPropertyNames(LanguageServer.prototype)) {
97
+ if (/on+/.test(name) && typeof ((_a = this.connection) === null || _a === void 0 ? void 0 : _a[name]) === 'function') {
98
+ this.connection[name](this[name].bind(this));
99
+ }
100
+ }
101
+ //Register semantic token requests. TODO switch to a more specific connection function call once they actually add it
102
+ this.connection.onRequest(node_1.SemanticTokensRequest.method, this.onFullSemanticTokens.bind(this));
76
103
  // The content of a text document has changed. This event is emitted
77
104
  // when the text document is first opened, when its content has changed,
78
105
  // or when document is closed without saving (original contents are sent as a change)
79
106
  //
80
- this.documents.onDidChangeContent(async (change) => {
81
- await this.validateTextDocument(change.document);
82
- });
107
+ this.documents.onDidChangeContent(this.onTextDocumentDidChangeContent.bind(this));
83
108
  //whenever a document gets closed
84
- this.documents.onDidClose(async (change) => {
85
- await this.onDocumentClose(change.document);
86
- });
87
- // This handler provides the initial list of the completion items.
88
- this.connection.onCompletion(async (params) => {
89
- return this.onCompletion(params.textDocument.uri, params.position);
90
- });
91
- // This handler resolves additional information for the item selected in
92
- // the completion list.
93
- this.connection.onCompletionResolve(this.onCompletionResolve.bind(this));
94
- this.connection.onHover(this.onHover.bind(this));
95
- this.connection.onExecuteCommand(this.onExecuteCommand.bind(this));
96
- this.connection.onDefinition(this.onDefinition.bind(this));
97
- this.connection.onDocumentSymbol(this.onDocumentSymbol.bind(this));
98
- this.connection.onWorkspaceSymbol(this.onWorkspaceSymbol.bind(this));
99
- this.connection.onSignatureHelp(this.onSignatureHelp.bind(this));
100
- this.connection.onReferences(this.onReferences.bind(this));
101
- this.connection.onCodeAction(this.onCodeAction.bind(this));
102
- //TODO switch to a more specific connection function call once they actually add it
103
- this.connection.onRequest(node_1.SemanticTokensRequest.method, this.onFullSemanticTokens.bind(this));
104
- /*
105
- this.connection.onDidOpenTextDocument((params) => {
106
- // A text document got opened in VSCode.
107
- // params.uri uniquely identifies the document. For documents stored on disk this is a file URI.
108
- // params.text the initial full content of the document.
109
- this.connection.console.log(`${params.textDocument.uri} opened.`);
110
- });
111
- this.connection.onDidChangeTextDocument((params) => {
112
- // The content of a text document did change in VSCode.
113
- // params.uri uniquely identifies the document.
114
- // params.contentChanges describe the content changes to the document.
115
- this.connection.console.log(`${params.textDocument.uri} changed: ${JSON.stringify(params.contentChanges)}`);
116
- });
117
- this.connection.onDidCloseTextDocument((params) => {
118
- // A text document got closed in VSCode.
119
- // params.uri uniquely identifies the document.
120
- this.connection.console.log(`${params.textDocument.uri} closed.`);
121
- });
122
- */
109
+ this.documents.onDidClose(this.onDocumentClose.bind(this));
123
110
  // listen for open, change and close text document events
124
111
  this.documents.listen(this.connection);
125
112
  // Listen on the connection
@@ -127,7 +114,6 @@ class LanguageServer {
127
114
  }
128
115
  /**
129
116
  * Called when the client starts initialization
130
- * @param params
131
117
  */
132
118
  onInitialize(params) {
133
119
  let clientCapabilities = params.capabilities;
@@ -141,7 +127,7 @@ class LanguageServer {
141
127
  textDocumentSync: node_1.TextDocumentSyncKind.Full,
142
128
  // Tell the client that the server supports code completion
143
129
  completionProvider: {
144
- resolveProvider: true,
130
+ resolveProvider: false,
145
131
  //anytime the user types a period, auto-show the completion results
146
132
  triggerCharacters: ['.'],
147
133
  allCommitCharacters: ['.', '@']
@@ -171,41 +157,33 @@ class LanguageServer {
171
157
  }
172
158
  /**
173
159
  * Called when the client has finished initializing
174
- * @param params
175
160
  */
176
161
  async onInitialized() {
177
- var _a;
178
- let workspaceCreatedDeferred = new deferred_1.Deferred();
179
- this.initialWorkspacesCreated = workspaceCreatedDeferred.promise;
162
+ this.logger.log('onInitialized');
163
+ //cache a copy of all workspace configurations to use for comparison later
164
+ this.workspaceConfigsCache = new Map((await this.getWorkspaceConfigs()).map(x => [x.workspaceFolder, x]));
165
+ //set our logger to the most verbose logLevel found across any project
166
+ await this.syncLogLevel();
180
167
  try {
181
168
  if (this.hasConfigurationCapability) {
182
- // Register for all configuration changes.
183
- await this.connection.client.register(node_1.DidChangeConfigurationNotification.type, undefined);
169
+ // register for when the user changes workspace or user settings
170
+ await this.connection.client.register(node_1.DidChangeConfigurationNotification.type, {
171
+ //we only care about when these settings sections change
172
+ section: [
173
+ 'brightscript',
174
+ 'files'
175
+ ]
176
+ });
184
177
  }
185
- //ask the client for all workspace folders
186
- let workspaceFolders = (_a = await this.connection.workspace.getWorkspaceFolders()) !== null && _a !== void 0 ? _a : [];
187
- let workspacePaths = workspaceFolders.map((x) => {
188
- return util_1.util.uriToPath(x.uri);
189
- });
190
- await this.createWorkspaces(workspacePaths);
178
+ //populate the path filterer with the client's include/exclude lists
179
+ await this.rebuildPathFilterer();
180
+ await this.syncProjects();
191
181
  if (this.clientHasWorkspaceFolderCapability) {
182
+ //if the client changes their workspaces, we need to get our projects in sync
192
183
  this.connection.workspace.onDidChangeWorkspaceFolders(async (evt) => {
193
- //remove programs for removed workspace folders
194
- for (let removed of evt.removed) {
195
- let workspacePath = util_1.util.uriToPath(removed.uri);
196
- let workspace = this.workspaces.find((x) => x.workspacePath === workspacePath);
197
- if (workspace) {
198
- workspace.builder.dispose();
199
- this.workspaces.splice(this.workspaces.indexOf(workspace), 1);
200
- }
201
- }
202
- //create programs for new workspace folders
203
- await this.createWorkspaces(evt.added.map((x) => util_1.util.uriToPath(x.uri)));
184
+ await this.syncProjects();
204
185
  });
205
186
  }
206
- await this.waitAllProgramFirstRuns(false);
207
- workspaceCreatedDeferred.resolve();
208
- await this.sendDiagnostics();
209
187
  }
210
188
  catch (e) {
211
189
  this.sendCriticalFailure(`Critical failure during BrighterScript language server startup.
@@ -216,695 +194,409 @@ class LanguageServer {
216
194
  }
217
195
  }
218
196
  /**
219
- * Send a critical failure notification to the client, which should show a notification of some kind
220
- */
221
- sendCriticalFailure(message) {
222
- this.connection.sendNotification('critical-failure', message);
223
- }
224
- /**
225
- * Wait for all programs' first run to complete
226
- */
227
- async waitAllProgramFirstRuns(waitForFirstWorkSpace = true) {
228
- if (waitForFirstWorkSpace) {
229
- await this.initialWorkspacesCreated;
230
- }
231
- let status;
232
- let workspaces = this.getWorkspaces();
233
- for (let workspace of workspaces) {
234
- try {
235
- await workspace.firstRunPromise;
236
- }
237
- catch (e) {
238
- status = 'critical-error';
239
- //the first run failed...that won't change unless we reload the workspace, so replace with resolved promise
240
- //so we don't show this error again
241
- workspace.firstRunPromise = Promise.resolve();
242
- this.sendCriticalFailure(`BrighterScript language server failed to start: \n${e.message}`);
243
- }
244
- }
245
- this.connection.sendNotification('build-status', status ? status : 'success');
246
- }
247
- /**
248
- * Create project for each new workspace. If the workspace is already known,
249
- * it is skipped.
250
- * @param workspaceFolders
251
- */
252
- async createWorkspaces(workspacePaths) {
253
- return Promise.all(workspacePaths.map(async (workspacePath) => this.createWorkspace(workspacePath)));
254
- }
255
- /**
256
- * Event handler for when the program wants to load file contents.
257
- * anytime the program wants to load a file, check with our in-memory document cache first
197
+ * Set our logLevel to the most verbose log level found across all projects and workspaces
258
198
  */
259
- documentFileResolver(srcPath) {
260
- let pathUri = vscode_uri_1.URI.file(srcPath).toString();
261
- let document = this.documents.get(pathUri);
262
- if (document) {
263
- return document.getText();
264
- }
265
- }
266
- async getConfigFilePath(workspacePath) {
267
- let scopeUri;
268
- if (workspacePath.startsWith('file:')) {
269
- scopeUri = vscode_uri_1.URI.parse(workspacePath).toString();
270
- }
271
- else {
272
- scopeUri = vscode_uri_1.URI.file(workspacePath).toString();
273
- }
274
- //look for config group called "brightscript"
275
- let config = await this.connection.workspace.getConfiguration({
276
- scopeUri: scopeUri,
277
- section: 'brightscript'
278
- });
279
- let configFilePath;
280
- //if there's a setting, we need to find the file or show error if it can't be found
281
- if (config === null || config === void 0 ? void 0 : config.configFile) {
282
- configFilePath = path.resolve(workspacePath, config.configFile);
283
- if (await util_1.util.pathExists(configFilePath)) {
284
- return configFilePath;
285
- }
286
- else {
287
- this.sendCriticalFailure(`Cannot find config file specified in user/workspace settings at '${configFilePath}'`);
288
- }
289
- }
290
- //default to config file path found in the root of the workspace
291
- configFilePath = path.resolve(workspacePath, 'bsconfig.json');
292
- if (await util_1.util.pathExists(configFilePath)) {
293
- return configFilePath;
294
- }
295
- //look for the deprecated `brsconfig.json` file
296
- configFilePath = path.resolve(workspacePath, 'brsconfig.json');
297
- if (await util_1.util.pathExists(configFilePath)) {
298
- return configFilePath;
299
- }
300
- //no config file could be found
301
- return undefined;
302
- }
303
- async createWorkspace(workspacePath) {
304
- let workspace = this.workspaces.find((x) => x.workspacePath === workspacePath);
305
- //skip this workspace if we already have it
306
- if (workspace) {
307
- return;
308
- }
309
- let builder = new ProgramBuilder_1.ProgramBuilder();
310
- //prevent clearing the console on run...this isn't the CLI so we want to keep a full log of everything
311
- builder.allowConsoleClearing = false;
312
- //look for files in our in-memory cache before going to the file system
313
- builder.addFileResolver(this.documentFileResolver.bind(this));
314
- let configFilePath = await this.getConfigFilePath(workspacePath);
315
- let cwd = workspacePath;
316
- //if the config file exists, use it and its folder as cwd
317
- if (configFilePath && await util_1.util.pathExists(configFilePath)) {
318
- cwd = path.dirname(configFilePath);
319
- }
320
- else {
321
- //config file doesn't exist...let `brighterscript` resolve the default way
322
- configFilePath = undefined;
323
- }
324
- let firstRunPromise = builder.run({
325
- cwd: cwd,
326
- project: configFilePath,
327
- watch: false,
328
- createPackage: false,
329
- deploy: false,
330
- copyToStaging: false,
331
- showDiagnosticsInConsole: false
332
- });
333
- firstRunPromise.catch((err) => {
334
- console.error(err);
335
- });
336
- let newWorkspace = {
337
- builder: builder,
338
- firstRunPromise: firstRunPromise,
339
- workspacePath: workspacePath,
340
- isFirstRunComplete: false,
341
- isFirstRunSuccessful: false,
342
- configFilePath: configFilePath,
343
- isStandaloneFileWorkspace: false
344
- };
345
- this.workspaces.push(newWorkspace);
346
- await firstRunPromise.then(() => {
347
- newWorkspace.isFirstRunComplete = true;
348
- newWorkspace.isFirstRunSuccessful = true;
349
- }).catch(() => {
350
- newWorkspace.isFirstRunComplete = true;
351
- newWorkspace.isFirstRunSuccessful = false;
352
- }).then(() => {
353
- //if we found a deprecated brsconfig.json, add a diagnostic warning the user
354
- if (configFilePath && path.basename(configFilePath) === 'brsconfig.json') {
355
- builder.addDiagnostic(configFilePath, Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.brsConfigJsonIsDeprecated()), { range: util_1.util.createRange(0, 0, 0, 0) }));
356
- return this.sendDiagnostics();
357
- }
358
- });
359
- }
360
- /**
361
- * @param srcPath The absolute path to the source file on disk
362
- */
363
- async createStandaloneFileWorkspace(srcPath) {
364
- //skip this workspace if we already have it
365
- if (this.standaloneFileWorkspaces[srcPath]) {
366
- return this.standaloneFileWorkspaces[srcPath];
367
- }
368
- let builder = new ProgramBuilder_1.ProgramBuilder();
369
- //prevent clearing the console on run...this isn't the CLI so we want to keep a full log of everything
370
- builder.allowConsoleClearing = false;
371
- //look for files in our in-memory cache before going to the file system
372
- builder.addFileResolver(this.documentFileResolver.bind(this));
373
- //get the path to the directory where this file resides
374
- let cwd = path.dirname(srcPath);
375
- //get the closest config file and use most of the settings from that
376
- let configFilePath = await util_1.util.findClosestConfigFile(srcPath);
377
- let project = {};
378
- if (configFilePath) {
379
- project = util_1.util.normalizeAndResolveConfig({ project: configFilePath });
380
- }
381
- //override the rootDir and files array
382
- project.rootDir = cwd;
383
- project.files = [{
384
- src: srcPath,
385
- dest: path.basename(srcPath)
386
- }];
387
- let firstRunPromise = builder.run(Object.assign(Object.assign({}, project), { cwd: cwd, project: configFilePath, watch: false, createPackage: false, deploy: false, copyToStaging: false, diagnosticFilters: [
388
- //hide the "file not referenced by any other file" error..that's expected in a standalone file.
389
- 1013
390
- ] })).catch((err) => {
391
- console.error(err);
392
- });
393
- let newWorkspace = {
394
- builder: builder,
395
- firstRunPromise: firstRunPromise,
396
- workspacePath: srcPath,
397
- isFirstRunComplete: false,
398
- isFirstRunSuccessful: false,
399
- configFilePath: configFilePath,
400
- isStandaloneFileWorkspace: true
401
- };
402
- this.standaloneFileWorkspaces[srcPath] = newWorkspace;
403
- await firstRunPromise.then(() => {
404
- newWorkspace.isFirstRunComplete = true;
405
- newWorkspace.isFirstRunSuccessful = true;
406
- }).catch(() => {
407
- newWorkspace.isFirstRunComplete = true;
408
- newWorkspace.isFirstRunSuccessful = false;
409
- });
410
- return newWorkspace;
411
- }
412
- getWorkspaces() {
413
- let workspaces = this.workspaces.slice();
414
- for (let key in this.standaloneFileWorkspaces) {
415
- workspaces.push(this.standaloneFileWorkspaces[key]);
416
- }
417
- return workspaces;
418
- }
419
- /**
420
- * Provide a list of completion items based on the current cursor position
421
- * @param textDocumentPosition
422
- */
423
- async onCompletion(uri, position) {
424
- //ensure programs are initialized
425
- await this.waitAllProgramFirstRuns();
426
- let filePath = util_1.util.uriToPath(uri);
427
- //wait until the file has settled
428
- await this.keyedThrottler.onIdleOnce(filePath, true);
429
- let completions = this
430
- .getWorkspaces()
431
- .flatMap(workspace => workspace.builder.program.getCompletions(filePath, position));
432
- for (let completion of completions) {
433
- completion.commitCharacters = ['.'];
434
- }
435
- return completions;
436
- }
437
- /**
438
- * Provide a full completion item from the selection
439
- * @param item
440
- */
441
- onCompletionResolve(item) {
442
- if (item.data === 1) {
443
- item.detail = 'TypeScript details';
444
- item.documentation = 'TypeScript documentation';
445
- }
446
- else if (item.data === 2) {
447
- item.detail = 'JavaScript details';
448
- item.documentation = 'JavaScript documentation';
449
- }
450
- return item;
451
- }
452
- async onCodeAction(params) {
453
- //ensure programs are initialized
454
- await this.waitAllProgramFirstRuns();
455
- let srcPath = util_1.util.uriToPath(params.textDocument.uri);
456
- //wait until the file has settled
457
- await this.keyedThrottler.onIdleOnce(srcPath, true);
458
- const codeActions = this
459
- .getWorkspaces()
460
- //skip programs that don't have this file
461
- .filter(x => { var _a, _b; return (_b = (_a = x.builder) === null || _a === void 0 ? void 0 : _a.program) === null || _b === void 0 ? void 0 : _b.hasFile(srcPath); })
462
- .flatMap(workspace => workspace.builder.program.getCodeActions(srcPath, params.range));
463
- //clone the diagnostics for each code action, since certain diagnostics can have circular reference properties that kill the language server if serialized
464
- for (const codeAction of codeActions) {
465
- if (codeAction.diagnostics) {
466
- codeAction.diagnostics = codeAction.diagnostics.map(x => util_1.util.toDiagnostic(x));
467
- }
468
- }
469
- return codeActions;
470
- }
471
- /**
472
- * Reload all specified workspaces, or all workspaces if no workspaces are specified
473
- */
474
- async reloadWorkspaces(workspaces) {
475
- workspaces = workspaces ? workspaces : this.getWorkspaces();
476
- await Promise.all(workspaces.map(async (workspace) => {
477
- //ensure the workspace has finished starting up
478
- try {
479
- await workspace.firstRunPromise;
480
- }
481
- catch (e) { }
482
- //handle standard workspace
483
- if (workspace.isStandaloneFileWorkspace === false) {
484
- let idx = this.workspaces.indexOf(workspace);
485
- if (idx > -1) {
486
- //remove this workspace
487
- this.workspaces.splice(idx, 1);
488
- //dispose this workspace's resources
489
- workspace.builder.dispose();
199
+ async syncLogLevel() {
200
+ var _a, _b;
201
+ /**
202
+ * helper to get the logLevel from a list of items and return the item and level (if found), or undefined if not
203
+ */
204
+ const getLogLevel = async (items, fetcher) => {
205
+ const logLevels = await Promise.all(items.map(async (item) => {
206
+ let value = await fetcher(item);
207
+ //force string values to lower case (so we can support things like 'log' or 'Log' or 'LOG')
208
+ if (typeof value === 'string') {
209
+ value = value.toLowerCase();
490
210
  }
491
- //create a new workspace/brs program
492
- await this.createWorkspace(workspace.workspacePath);
493
- //handle temp workspace
494
- }
495
- else {
496
- workspace.builder.dispose();
497
- delete this.standaloneFileWorkspaces[workspace.workspacePath];
498
- await this.createStandaloneFileWorkspace(workspace.workspacePath);
499
- }
500
- }));
501
- if (workspaces.length > 0) {
502
- //wait for all of the programs to finish starting up
503
- await this.waitAllProgramFirstRuns();
504
- // valdiate all workspaces
505
- this.validateAllThrottled(); //eslint-disable-line
506
- }
507
- }
508
- getRootDir(workspace) {
509
- var _a, _b, _c;
510
- let options = (_b = (_a = workspace === null || workspace === void 0 ? void 0 : workspace.builder) === null || _a === void 0 ? void 0 : _a.program) === null || _b === void 0 ? void 0 : _b.options;
511
- return (_c = options === null || options === void 0 ? void 0 : options.rootDir) !== null && _c !== void 0 ? _c : options === null || options === void 0 ? void 0 : options.cwd;
512
- }
513
- /**
514
- * Sometimes users will alter their bsconfig files array, and will include standalone files.
515
- * If this is the case, those standalone workspaces should be removed because the file was
516
- * included in an actual program now.
517
- *
518
- * Sometimes files that used to be included are now excluded, so those open files need to be re-processed as standalone
519
- */
520
- async synchronizeStandaloneWorkspaces() {
521
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
522
- //remove standalone workspaces that are now included in projects
523
- for (let standaloneFilePath in this.standaloneFileWorkspaces) {
524
- let standaloneWorkspace = this.standaloneFileWorkspaces[standaloneFilePath];
525
- for (let workspace of this.workspaces) {
526
- await standaloneWorkspace.firstRunPromise;
527
- let dest = rokuDeploy.getDestPath(standaloneFilePath, (_d = (_c = (_b = (_a = workspace === null || workspace === void 0 ? void 0 : workspace.builder) === null || _a === void 0 ? void 0 : _a.program) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.files) !== null && _d !== void 0 ? _d : [], this.getRootDir(workspace));
528
- //destroy this standalone workspace because the file has now been included in an actual workspace,
529
- //or if the workspace wants the file
530
- if (((_f = (_e = workspace === null || workspace === void 0 ? void 0 : workspace.builder) === null || _e === void 0 ? void 0 : _e.program) === null || _f === void 0 ? void 0 : _f.hasFile(standaloneFilePath)) || dest) {
531
- standaloneWorkspace.builder.dispose();
532
- delete this.standaloneFileWorkspaces[standaloneFilePath];
211
+ const logLevelNumeric = this.logger.getLogLevelNumeric(value);
212
+ if (typeof logLevelNumeric === 'number') {
213
+ return logLevelNumeric;
533
214
  }
534
- }
535
- }
536
- //create standalone workspaces for open files that no longer have a project
537
- let textDocuments = this.documents.all();
538
- outer: for (let textDocument of textDocuments) {
539
- let filePath = vscode_uri_1.URI.parse(textDocument.uri).fsPath;
540
- let workspaces = this.getWorkspaces();
541
- for (let workspace of workspaces) {
542
- let dest = rokuDeploy.getDestPath(filePath, (_k = (_j = (_h = (_g = workspace === null || workspace === void 0 ? void 0 : workspace.builder) === null || _g === void 0 ? void 0 : _g.program) === null || _h === void 0 ? void 0 : _h.options) === null || _j === void 0 ? void 0 : _j.files) !== null && _k !== void 0 ? _k : [], this.getRootDir(workspace));
543
- //if this workspace has the file, or it wants the file, do NOT make a standalone workspace for this file
544
- if (((_m = (_l = workspace === null || workspace === void 0 ? void 0 : workspace.builder) === null || _l === void 0 ? void 0 : _l.program) === null || _m === void 0 ? void 0 : _m.hasFile(filePath)) || dest) {
545
- continue outer;
215
+ else {
216
+ return -1;
546
217
  }
218
+ }));
219
+ let idx = logLevels.findIndex(x => x > -1);
220
+ if (idx > -1) {
221
+ const mostVerboseLogLevel = Math.max(...logLevels);
222
+ return {
223
+ logLevel: mostVerboseLogLevel,
224
+ logLevelText: this.logger.getLogLevelText(mostVerboseLogLevel),
225
+ //find the first item having the most verbose logLevel
226
+ item: items[logLevels.findIndex(x => x === mostVerboseLogLevel)]
227
+ };
547
228
  }
548
- //if we got here, no workspace has this file, so make a standalone file workspace
549
- let workspace = await this.createStandaloneFileWorkspace(filePath);
550
- await workspace.firstRunPromise;
551
- }
552
- }
553
- async onDidChangeConfiguration() {
554
- if (this.hasConfigurationCapability) {
555
- await this.reloadWorkspaces();
556
- // Reset all cached document settings
229
+ };
230
+ const workspaces = await this.getWorkspaceConfigs();
231
+ let workspaceResult = await getLogLevel(workspaces, workspace => { var _a; return (_a = workspace === null || workspace === void 0 ? void 0 : workspace.languageServer) === null || _a === void 0 ? void 0 : _a.logLevel; });
232
+ if (workspaceResult) {
233
+ this.logger.info(`Setting global logLevel to '${workspaceResult.logLevelText}' based on configuration from workspace '${(_a = workspaceResult === null || workspaceResult === void 0 ? void 0 : workspaceResult.item) === null || _a === void 0 ? void 0 : _a.workspaceFolder}'`);
234
+ this.logger.logLevel = workspaceResult.logLevel;
235
+ return;
557
236
  }
558
- else {
559
- // this.globalSettings = <ExampleSettings>(
560
- // (change.settings.languageServerExample || this.defaultSettings)
561
- // );
237
+ let projectResult = await getLogLevel(this.projectManager.projects, (project) => project.logger.logLevel);
238
+ if (projectResult) {
239
+ this.logger.info(`Setting global logLevel to '${projectResult.logLevelText}' based on project #${(_b = projectResult === null || projectResult === void 0 ? void 0 : projectResult.item) === null || _b === void 0 ? void 0 : _b.projectNumber}`);
240
+ this.logger.logLevel = projectResult.logLevel;
241
+ return;
562
242
  }
243
+ //use a default level if no other level was found
244
+ this.logger.logLevel = logging_1.LogLevel.log;
245
+ }
246
+ async onTextDocumentDidChangeContent(event) {
247
+ this.logger.debug('onTextDocumentDidChangeContent', event.document.uri);
248
+ await this.projectManager.handleFileChanges([{
249
+ srcPath: vscode_uri_1.URI.parse(event.document.uri).fsPath,
250
+ type: node_1.FileChangeType.Changed,
251
+ fileContents: event.document.getText(),
252
+ allowStandaloneProject: true
253
+ }]);
563
254
  }
564
255
  /**
565
256
  * Called when watched files changed (add/change/delete).
566
257
  * The CLIENT is in charge of what files to watch, so all client
567
258
  * implementations should ensure that all valid project
568
259
  * file types are watched (.brs,.bs,.xml,manifest, and any json/text/image files)
569
- * @param params
570
260
  */
571
261
  async onDidChangeWatchedFiles(params) {
572
- //ensure programs are initialized
573
- await this.waitAllProgramFirstRuns();
574
- this.connection.sendNotification('build-status', 'building');
575
- let workspaces = this.getWorkspaces();
576
- //convert all file paths to absolute paths
577
- let changes = params.changes.map(x => {
578
- return {
579
- type: x.type,
580
- srcPath: util_1.standardizePath `${vscode_uri_1.URI.parse(x.uri).fsPath}`
581
- };
262
+ const workspacePaths = (await this.connection.workspace.getWorkspaceFolders()).map(x => util_1.util.uriToPath(x.uri));
263
+ let changes = params.changes
264
+ .map(x => ({
265
+ srcPath: util_1.util.uriToPath(x.uri),
266
+ type: x.type,
267
+ //if this is an open document, allow this file to be loaded in a standalone project (if applicable)
268
+ allowStandaloneProject: this.documents.get(x.uri) !== undefined
269
+ }))
270
+ //exclude all explicit top-level workspace folder paths (to fix a weird macos fs watcher bug that emits events for the workspace folder itself)
271
+ .filter(x => !workspacePaths.includes(x.srcPath));
272
+ this.logger.debug('onDidChangeWatchedFiles', changes);
273
+ //if the client changed any files containing include/exclude patterns, rebuild the path filterer before processing these changes
274
+ if (micromatch.some(changes.map(x => x.srcPath), [
275
+ '**/.gitignore',
276
+ '**/.vscode/settings.json',
277
+ '**/*bsconfig*.json'
278
+ ], {
279
+ dot: true
280
+ })) {
281
+ await this.rebuildPathFilterer();
282
+ }
283
+ //handle the file changes
284
+ await this.projectManager.handleFileChanges(changes);
285
+ }
286
+ async onDocumentClose(event) {
287
+ this.logger.debug('onDocumentClose', event.document.uri);
288
+ await this.projectManager.handleFileClose({
289
+ srcPath: util_1.util.uriToPath(event.document.uri)
582
290
  });
583
- let keys = changes.map(x => x.srcPath);
584
- //filter the list of changes to only the ones that made it through the debounce unscathed
585
- changes = changes.filter(x => keys.includes(x.srcPath));
586
- //if we have changes to work with
587
- if (changes.length > 0) {
588
- //reload any workspace whose bsconfig.json file has changed
589
- {
590
- let workspacesToReload = [];
591
- //get the file paths as a string array
592
- let filePaths = changes.map((x) => x.srcPath);
593
- for (let workspace of workspaces) {
594
- if (workspace.configFilePath && filePaths.includes(workspace.configFilePath)) {
595
- workspacesToReload.push(workspace);
596
- }
597
- }
598
- if (workspacesToReload.length > 0) {
599
- //vsc can generate a ton of these changes, for vsc system files, so we need to bail if there's no work to do on any of our actual workspace files
600
- //reload any workspaces that need to be reloaded
601
- await this.reloadWorkspaces(workspacesToReload);
602
- }
603
- //set the list of workspaces to non-reloaded workspaces
604
- workspaces = workspaces.filter(x => !workspacesToReload.includes(x));
605
- }
606
- //convert created folders into a list of files of their contents
607
- const directoryChanges = changes
608
- //get only creation items
609
- .filter(change => change.type === node_1.FileChangeType.Created)
610
- //keep only the directories
611
- .filter(change => util_1.util.isDirectorySync(change.srcPath));
612
- //remove the created directories from the changes array (we will add back each of their files next)
613
- changes = changes.filter(x => !directoryChanges.includes(x));
614
- //look up every file in each of the newly added directories
615
- const newFileChanges = directoryChanges
616
- //take just the path
617
- .map(x => x.srcPath)
618
- //exclude the roku deploy staging folder
619
- .filter(dirPath => !dirPath.includes('.roku-deploy-staging'))
620
- //get the files for each folder recursively
621
- .flatMap(dirPath => {
622
- //create a glob pattern to match all files
623
- let pattern = rokuDeploy.util.toForwardSlashes(`${dirPath}/**/*`);
624
- let files = glob.sync(pattern, {
625
- absolute: true
626
- });
627
- return files.map(x => {
628
- return {
629
- type: node_1.FileChangeType.Created,
630
- srcPath: util_1.standardizePath `${x}`
631
- };
632
- });
633
- });
634
- //add the new file changes to the changes array.
635
- changes.push(...newFileChanges);
636
- //give every workspace the chance to handle file changes
637
- await Promise.all(workspaces.map((workspace) => this.handleFileChanges(workspace, changes)));
638
- }
639
- this.connection.sendNotification('build-status', 'success');
640
291
  }
641
292
  /**
642
- * This only operates on files that match the specified files globs, so it is safe to throw
643
- * any file changes you receive with no unexpected side-effects
644
- * @param changes
293
+ * Provide a list of completion items based on the current cursor position
645
294
  */
646
- async handleFileChanges(workspace, changes) {
647
- //this loop assumes paths are both file paths and folder paths, which eliminates the need to detect.
648
- //All functions below can handle being given a file path AND a folder path, and will only operate on the one they are looking for
649
- let consumeCount = 0;
650
- await Promise.all(changes.map(async (change) => {
651
- await this.keyedThrottler.run(change.srcPath, async () => {
652
- consumeCount += await this.handleFileChange(workspace, change) ? 1 : 0;
653
- });
295
+ async onCompletion(params, cancellationToken, workDoneProgress, resultProgress) {
296
+ this.logger.debug('onCompletion', params, cancellationToken);
297
+ const srcPath = util_1.util.uriToPath(params.textDocument.uri);
298
+ const completions = await this.projectManager.getCompletions({
299
+ srcPath: srcPath,
300
+ position: params.position,
301
+ cancellationToken: cancellationToken
302
+ });
303
+ return completions;
304
+ }
305
+ /**
306
+ * Get a list of workspaces, and their configurations.
307
+ * Get only the settings for the workspace that are relevant to the language server. We do this so we can cache this object for use in change detection in the future.
308
+ */
309
+ async getWorkspaceConfigs() {
310
+ var _a;
311
+ //get all workspace folders (we'll use these to get settings)
312
+ let workspaces = await Promise.all(((_a = await this.connection.workspace.getWorkspaceFolders()) !== null && _a !== void 0 ? _a : []).map(async (x) => {
313
+ var _a, _b, _c, _d, _e, _f, _g, _h;
314
+ const workspaceFolder = util_1.util.uriToPath(x.uri);
315
+ const brightscriptConfig = await this.getClientConfiguration(x.uri, 'brightscript');
316
+ return {
317
+ workspaceFolder: workspaceFolder,
318
+ excludePatterns: await this.getWorkspaceExcludeGlobs(workspaceFolder),
319
+ projects: this.normalizeProjectPaths(workspaceFolder, brightscriptConfig === null || brightscriptConfig === void 0 ? void 0 : brightscriptConfig.projects),
320
+ languageServer: {
321
+ enableThreading: (_b = (_a = brightscriptConfig === null || brightscriptConfig === void 0 ? void 0 : brightscriptConfig.languageServer) === null || _a === void 0 ? void 0 : _a.enableThreading) !== null && _b !== void 0 ? _b : LanguageServer.enableThreadingDefault,
322
+ enableProjectDiscovery: (_d = (_c = brightscriptConfig === null || brightscriptConfig === void 0 ? void 0 : brightscriptConfig.languageServer) === null || _c === void 0 ? void 0 : _c.enableProjectDiscovery) !== null && _d !== void 0 ? _d : LanguageServer.enableProjectDiscoveryDefault,
323
+ projectDiscoveryMaxDepth: (_f = (_e = brightscriptConfig === null || brightscriptConfig === void 0 ? void 0 : brightscriptConfig.languageServer) === null || _e === void 0 ? void 0 : _e.projectDiscoveryMaxDepth) !== null && _f !== void 0 ? _f : 15,
324
+ projectDiscoveryExclude: (_g = brightscriptConfig === null || brightscriptConfig === void 0 ? void 0 : brightscriptConfig.languageServer) === null || _g === void 0 ? void 0 : _g.projectDiscoveryExclude,
325
+ logLevel: (_h = brightscriptConfig === null || brightscriptConfig === void 0 ? void 0 : brightscriptConfig.languageServer) === null || _h === void 0 ? void 0 : _h.logLevel
326
+ }
327
+ };
654
328
  }));
655
- if (consumeCount > 0) {
656
- await this.validateAllThrottled();
657
- }
329
+ return workspaces;
658
330
  }
659
331
  /**
660
- * This only operates on files that match the specified files globs, so it is safe to throw
661
- * any file changes you receive with no unexpected side-effects
662
- * @param changes
332
+ * Extract project paths from settings' projects list, expanding the workspaceFolder variable if necessary
663
333
  */
664
- async handleFileChange(workspace, change) {
665
- const program = workspace.builder.program;
666
- const options = workspace.builder.options;
667
- const rootDir = workspace.builder.rootDir;
668
- //deleted
669
- if (change.type === node_1.FileChangeType.Deleted) {
670
- //try to act on this path as a directory
671
- workspace.builder.program.removeFilesInFolder(change.srcPath);
672
- //if this is a file loaded in the program, remove it
673
- if (program.hasFile(change.srcPath)) {
674
- program.removeFile(change.srcPath);
675
- return true;
676
- }
677
- else {
678
- return false;
679
- }
680
- //created
681
- }
682
- else if (change.type === node_1.FileChangeType.Created) {
683
- // thanks to `onDidChangeWatchedFiles`, we can safely assume that all "Created" changes are file paths, (not directories)
684
- //get the dest path for this file.
685
- let destPath = rokuDeploy.getDestPath(change.srcPath, options.files, rootDir);
686
- //if we got a dest path, then the program wants this file
687
- if (destPath) {
688
- program.setFile({
689
- src: change.srcPath,
690
- dest: rokuDeploy.getDestPath(change.srcPath, options.files, rootDir)
691
- }, await workspace.builder.getFileContents(change.srcPath));
692
- return true;
334
+ normalizeProjectPaths(workspaceFolder, projects) {
335
+ return projects === null || projects === void 0 ? void 0 : projects.reduce((acc, project) => {
336
+ if (typeof project === 'string') {
337
+ acc.push({ path: project });
693
338
  }
694
- else {
695
- //no dest path means the program doesn't want this file
696
- return false;
697
- }
698
- //changed
699
- }
700
- else if (program.hasFile(change.srcPath)) {
701
- //sometimes "changed" events are emitted on files that were actually deleted,
702
- //so determine file existance and act accordingly
703
- if (await util_1.util.pathExists(change.srcPath)) {
704
- program.setFile({
705
- src: change.srcPath,
706
- dest: rokuDeploy.getDestPath(change.srcPath, options.files, rootDir)
707
- }, await workspace.builder.getFileContents(change.srcPath));
708
- }
709
- else {
710
- program.removeFile(change.srcPath);
339
+ else if (typeof project.path === 'string') {
340
+ acc.push(project);
711
341
  }
712
- return true;
342
+ return acc;
343
+ }, []).map(project => (Object.assign(Object.assign({}, project), {
344
+ // eslint-disable-next-line no-template-curly-in-string
345
+ path: util_1.util.standardizePath(project.path.replace('${workspaceFolder}', workspaceFolder)) })));
346
+ }
347
+ async onDidChangeConfiguration(args) {
348
+ this.logger.log('onDidChangeConfiguration', 'Reloading all projects');
349
+ const configs = new Map((await this.getWorkspaceConfigs()).map(x => [x.workspaceFolder, x]));
350
+ //find any changed configs. This includes newly created workspaces, deleted workspaces, etc.
351
+ //TODO: enhance this to only reload specific projects, depending on the change
352
+ if (!isEqual(configs, this.workspaceConfigsCache)) {
353
+ //now that we've processed any config diffs, update the cached copy of them
354
+ this.workspaceConfigsCache = configs;
355
+ //if configuration changed, rebuild the path filterer
356
+ await this.rebuildPathFilterer();
357
+ //if the user changes any user/workspace config settings, just mass-reload all projects
358
+ await this.syncProjects(true);
713
359
  }
714
360
  }
715
361
  async onHover(params) {
716
- //ensure programs are initialized
717
- await this.waitAllProgramFirstRuns();
718
- let srcPath = util_1.util.uriToPath(params.textDocument.uri);
719
- let workspaces = this.getWorkspaces();
720
- let hovers = await Promise.all(Array.prototype.concat.call([], workspaces.map(async (x) => x.builder.program.getHover(srcPath, params.position))));
721
- //return the first non-falsey hover. TODO is there a way to handle multiple hover results?
722
- let hover = hovers.filter((x) => !!x)[0];
723
- //TODO improve this to support more than just .brs files
724
- if (hover === null || hover === void 0 ? void 0 : hover.contents) {
725
- //create fenced code block to get colorization
726
- hover.contents = {
727
- //TODO - make the program.getHover call figure out what language this is for
728
- language: 'brightscript',
729
- value: hover.contents
730
- };
731
- }
732
- return hover;
733
- }
734
- async onDocumentClose(textDocument) {
735
- let filePath = vscode_uri_1.URI.parse(textDocument.uri).fsPath;
736
- let standaloneFileWorkspace = this.standaloneFileWorkspaces[filePath];
737
- //if this was a temp file, close it
738
- if (standaloneFileWorkspace) {
739
- await standaloneFileWorkspace.firstRunPromise;
740
- standaloneFileWorkspace.builder.dispose();
741
- delete this.standaloneFileWorkspaces[filePath];
742
- await this.sendDiagnostics();
743
- }
744
- }
745
- async validateTextDocument(textDocument) {
746
- //ensure programs are initialized
747
- await this.waitAllProgramFirstRuns();
748
- let filePath = vscode_uri_1.URI.parse(textDocument.uri).fsPath;
749
- try {
750
- //throttle file processing. first call is run immediately, and then the last call is processed.
751
- await this.keyedThrottler.run(filePath, () => {
752
- var _a;
753
- this.connection.sendNotification('build-status', 'building');
754
- let documentText = textDocument.getText();
755
- for (const workspace of this.getWorkspaces()) {
756
- //only add or replace existing files. All of the files in the project should
757
- //have already been loaded by other means
758
- if (workspace.builder.program.hasFile(filePath)) {
759
- let rootDir = (_a = workspace.builder.program.options.rootDir) !== null && _a !== void 0 ? _a : workspace.builder.program.options.cwd;
760
- let dest = rokuDeploy.getDestPath(filePath, workspace.builder.program.options.files, rootDir);
761
- workspace.builder.program.setFile({
762
- src: filePath,
763
- dest: dest
764
- }, documentText);
765
- }
766
- }
767
- });
768
- // validate all workspaces
769
- await this.validateAllThrottled();
770
- }
771
- catch (e) {
772
- this.sendCriticalFailure(`Critical error parsing/ validating ${filePath}: ${e.message}`);
773
- }
774
- }
775
- async validateAll() {
776
- var _a;
777
- try {
778
- //synchronize parsing for open files that were included/excluded from projects
779
- await this.synchronizeStandaloneWorkspaces();
780
- let workspaces = this.getWorkspaces();
781
- //validate all programs
782
- await Promise.all(workspaces.map((x) => x.builder.program.validate()));
783
- await this.sendDiagnostics();
784
- }
785
- catch (e) {
786
- this.connection.console.error(e);
787
- this.sendCriticalFailure(`Critical error validating workspace: ${e.message}${(_a = e.stack) !== null && _a !== void 0 ? _a : ''}`);
788
- }
789
- this.connection.sendNotification('build-status', 'success');
362
+ this.logger.debug('onHover', params);
363
+ const srcPath = util_1.util.uriToPath(params.textDocument.uri);
364
+ const result = await this.projectManager.getHover({ srcPath: srcPath, position: params.position });
365
+ return result;
790
366
  }
791
367
  async onWorkspaceSymbol(params) {
792
- await this.waitAllProgramFirstRuns();
793
- const results = util_1.util.flatMap(await Promise.all(this.getWorkspaces().map(workspace => {
794
- return workspace.builder.program.getWorkspaceSymbols();
795
- })), c => c);
796
- // Remove duplicates
797
- const allSymbols = Object.values(results.reduce((map, symbol) => {
798
- const key = symbol.location.uri + symbol.name;
799
- map[key] = symbol;
800
- return map;
801
- }, {}));
802
- return allSymbols;
368
+ this.logger.debug('onWorkspaceSymbol', params);
369
+ const result = await this.projectManager.getWorkspaceSymbol();
370
+ return result;
803
371
  }
804
372
  async onDocumentSymbol(params) {
805
- await this.waitAllProgramFirstRuns();
806
- await this.keyedThrottler.onIdleOnce(util_1.util.uriToPath(params.textDocument.uri), true);
373
+ this.logger.debug('onDocumentSymbol', params);
807
374
  const srcPath = util_1.util.uriToPath(params.textDocument.uri);
808
- for (const workspace of this.getWorkspaces()) {
809
- const file = workspace.builder.program.getFile(srcPath);
810
- if (reflection_1.isBrsFile(file)) {
811
- return file.getDocumentSymbols();
812
- }
813
- }
375
+ const result = await this.projectManager.getDocumentSymbol({ srcPath: srcPath });
376
+ return result;
814
377
  }
815
378
  async onDefinition(params) {
816
- await this.waitAllProgramFirstRuns();
379
+ this.logger.debug('onDefinition', params);
817
380
  const srcPath = util_1.util.uriToPath(params.textDocument.uri);
818
- const results = util_1.util.flatMap(await Promise.all(this.getWorkspaces().map(workspace => {
819
- return workspace.builder.program.getDefinition(srcPath, params.position);
820
- })), c => c);
821
- return results;
381
+ const result = this.projectManager.getDefinition({ srcPath: srcPath, position: params.position });
382
+ return result;
822
383
  }
823
384
  async onSignatureHelp(params) {
824
- var _a, _b, _c;
825
- await this.waitAllProgramFirstRuns();
826
- const filepath = util_1.util.uriToPath(params.textDocument.uri);
827
- await this.keyedThrottler.onIdleOnce(filepath, true);
828
- try {
829
- const signatures = util_1.util.flatMap(await Promise.all(this.getWorkspaces().map(workspace => workspace.builder.program.getSignatureHelp(filepath, params.position))), c => c);
830
- const activeSignature = signatures.length > 0 ? 0 : null;
831
- const activeParameter = activeSignature >= 0 ? (_a = signatures[activeSignature]) === null || _a === void 0 ? void 0 : _a.index : null;
832
- let results = {
833
- signatures: signatures.map((s) => s.signature),
834
- activeSignature: activeSignature,
835
- activeParameter: activeParameter
836
- };
837
- return results;
385
+ this.logger.debug('onSignatureHelp', params);
386
+ const srcPath = util_1.util.uriToPath(params.textDocument.uri);
387
+ const result = await this.projectManager.getSignatureHelp({ srcPath: srcPath, position: params.position });
388
+ if (result) {
389
+ return result;
838
390
  }
839
- catch (e) {
840
- this.connection.console.error(`error in onSignatureHelp: ${(_c = (_b = e.stack) !== null && _b !== void 0 ? _b : e.message) !== null && _c !== void 0 ? _c : e}`);
391
+ else {
841
392
  return {
842
393
  signatures: [],
843
- activeSignature: 0,
844
- activeParameter: 0
394
+ activeSignature: null,
395
+ activeParameter: null
845
396
  };
846
397
  }
847
398
  }
848
399
  async onReferences(params) {
849
- await this.waitAllProgramFirstRuns();
850
- const position = params.position;
400
+ this.logger.debug('onReferences', params);
851
401
  const srcPath = util_1.util.uriToPath(params.textDocument.uri);
852
- const results = util_1.util.flatMap(await Promise.all(this.getWorkspaces().map(workspace => {
853
- return workspace.builder.program.getReferences(srcPath, position);
854
- })), c => c);
855
- return results.filter((r) => r);
402
+ const result = await this.projectManager.getReferences({ srcPath: srcPath, position: params.position });
403
+ return result !== null && result !== void 0 ? result : [];
856
404
  }
857
405
  async onFullSemanticTokens(params) {
858
- await this.waitAllProgramFirstRuns();
859
- await this.keyedThrottler.onIdleOnce(util_1.util.uriToPath(params.textDocument.uri), true);
406
+ this.logger.debug('onFullSemanticTokens', params);
860
407
  const srcPath = util_1.util.uriToPath(params.textDocument.uri);
861
- for (const workspace of this.workspaces) {
862
- //find the first program that has this file, since it would be incredibly inefficient to generate semantic tokens for the same file multiple times.
863
- if (workspace.builder.program.hasFile(srcPath)) {
864
- let semanticTokens = workspace.builder.program.getSemanticTokens(srcPath);
865
- return {
866
- data: SemanticTokenUtils_1.encodeSemanticTokens(semanticTokens)
867
- };
868
- }
869
- }
408
+ const result = await this.projectManager.getSemanticTokens({ srcPath: srcPath });
409
+ return {
410
+ data: (0, SemanticTokenUtils_1.encodeSemanticTokens)(result)
411
+ };
870
412
  }
871
- async sendDiagnostics() {
872
- //Get only the changes to diagnostics since the last time we sent them to the client
873
- const patch = await this.diagnosticCollection.getPatch(this.workspaces);
874
- for (let filePath in patch) {
875
- const diagnostics = patch[filePath].map(d => util_1.util.toDiagnostic(d));
876
- this.connection.sendDiagnostics({
877
- uri: vscode_uri_1.URI.file(filePath).toString(),
878
- diagnostics: diagnostics
879
- });
880
- }
413
+ async onCodeAction(params) {
414
+ this.logger.debug('onCodeAction', params);
415
+ const srcPath = util_1.util.uriToPath(params.textDocument.uri);
416
+ const result = await this.projectManager.getCodeActions({ srcPath: srcPath, range: params.range });
417
+ return result;
881
418
  }
882
419
  async onExecuteCommand(params) {
883
- await this.waitAllProgramFirstRuns();
420
+ this.logger.debug('onExecuteCommand', params);
884
421
  if (params.command === CustomCommands.TranspileFile) {
885
- return this.transpileFile(params.arguments[0]);
422
+ const args = {
423
+ srcPath: params.arguments[0]
424
+ };
425
+ const result = await this.projectManager.transpileFile(args);
426
+ //back-compat: include `pathAbsolute` property so older vscode versions still work
427
+ result.pathAbsolute = result.srcPath;
428
+ return result;
429
+ }
430
+ }
431
+ /**
432
+ * Establish a connection to the client if not already connected
433
+ */
434
+ establishConnection() {
435
+ if (!this.connection) {
436
+ this.connection = (0, node_1.createConnection)(node_1.ProposedFeatures.all);
886
437
  }
438
+ return this.connection;
439
+ }
440
+ /**
441
+ * Send a new busy status notification to the client based on the current busy status
442
+ */
443
+ sendBusyStatus() {
444
+ var _a;
445
+ this.busyStatusIndex = ++this.busyStatusIndex <= 0 ? 0 : this.busyStatusIndex;
446
+ (_a = this.connection.sendNotification(NotificationName.busyStatus, {
447
+ status: this.projectManager.busyStatusTracker.status,
448
+ timestamp: Date.now(),
449
+ index: this.busyStatusIndex,
450
+ activeRuns: [
451
+ //extract only specific information from the active run so we know what's going on
452
+ ...this.projectManager.busyStatusTracker.activeRuns.map(x => ({
453
+ scope: util_1.util.getProjectLogName(x.scope),
454
+ label: x.label,
455
+ startTime: x.startTime.getTime()
456
+ }))
457
+ ]
458
+ })) === null || _a === void 0 ? void 0 : _a.catch(logAndIgnoreError);
459
+ }
460
+ /**
461
+ * Populate the path filterer with the client's include/exclude lists and the projects include lists
462
+ * @returns the instance of the path filterer
463
+ */
464
+ async rebuildPathFilterer() {
465
+ var _a;
466
+ //dispose of any previous pathFilterer disposables
467
+ (_a = this.pathFiltererDisposables) === null || _a === void 0 ? void 0 : _a.forEach(dispose => dispose());
468
+ //keep track of all the pathFilterer disposables so we can dispose them later
469
+ this.pathFiltererDisposables = [];
470
+ const workspaceConfigs = await this.getWorkspaceConfigs();
471
+ await Promise.all(workspaceConfigs.map(async (workspaceConfig) => {
472
+ const rootDir = util_1.util.uriToPath(workspaceConfig.workspaceFolder);
473
+ //always exclude everything from these common folders
474
+ this.pathFiltererDisposables.push(this.pathFilterer.registerExcludeList(rootDir, [
475
+ '**/node_modules/**/*',
476
+ '**/.git/**/*',
477
+ 'out/**/*',
478
+ '**/.roku-deploy-staging/**/*'
479
+ ]));
480
+ //get any `files.exclude` patterns from the client from this workspace
481
+ this.pathFiltererDisposables.push(this.pathFilterer.registerExcludeList(rootDir, workspaceConfig.excludePatterns));
482
+ //get any .gitignore patterns from the client from this workspace
483
+ const gitignorePath = path.resolve(rootDir, '.gitignore');
484
+ if (await fsExtra.pathExists(gitignorePath)) {
485
+ const matcher = (0, ignore_1.default)({ ignoreCase: true }).add(fsExtra.readFileSync(gitignorePath).toString());
486
+ this.pathFiltererDisposables.push(this.pathFilterer.registerExcludeMatcher((p) => {
487
+ const relPath = path.relative(rootDir, p);
488
+ if (ignore_1.default.isPathValid(relPath)) {
489
+ return matcher.test(relPath).ignored;
490
+ }
491
+ else {
492
+ //we do not have a valid relative path, so we cannot determine if it is ignored...thus it is NOT ignored
493
+ return false;
494
+ }
495
+ }));
496
+ }
497
+ }));
498
+ this.logger.log('pathFilterer successfully reconstructed');
499
+ return this.pathFilterer;
887
500
  }
888
501
  /**
889
- * @param srcPath The absolute path to the source file on disk
502
+ * Ask the client for the list of `files.exclude` and `files.watcherExclude` patterns. Useful when determining if we should process a file
890
503
  */
891
- async transpileFile(srcPath) {
892
- //wait all program first runs
893
- await this.waitAllProgramFirstRuns();
894
- let workspaces = this.getWorkspaces();
895
- //find the first workspace that has this file
896
- for (let workspace of workspaces) {
897
- if (workspace.builder.program.hasFile(srcPath)) {
898
- return workspace.builder.program.getTranspiledFileContents(srcPath);
504
+ async getWorkspaceExcludeGlobs(workspaceFolder) {
505
+ var _a;
506
+ const filesConfig = await this.getClientConfiguration(workspaceFolder, 'files');
507
+ const searchConfig = await this.getClientConfiguration(workspaceFolder, 'search');
508
+ const languageServerConfig = await this.getClientConfiguration(workspaceFolder, 'brightscript');
509
+ return [
510
+ ...this.extractExcludes(filesConfig === null || filesConfig === void 0 ? void 0 : filesConfig.exclude),
511
+ ...this.extractExcludes(filesConfig === null || filesConfig === void 0 ? void 0 : filesConfig.watcherExclude),
512
+ ...this.extractExcludes(searchConfig === null || searchConfig === void 0 ? void 0 : searchConfig.exclude),
513
+ ...this.extractExcludes((_a = languageServerConfig === null || languageServerConfig === void 0 ? void 0 : languageServerConfig.languageServer) === null || _a === void 0 ? void 0 : _a.projectDiscoveryExclude)
514
+ ];
515
+ }
516
+ extractExcludes(exclude) {
517
+ //if the exclude is not defined, return an empty array
518
+ if (!exclude) {
519
+ return [];
520
+ }
521
+ return Object
522
+ .keys(exclude)
523
+ .filter(x => exclude[x])
524
+ //vscode files.exclude patterns support ignoring folders without needing to add `**/*`. So for our purposes, we need to
525
+ //append **/* to everything without a file extension or magic at the end
526
+ .map(pattern => {
527
+ const result = [
528
+ //send the pattern as-is (this handles weird cases and exact file matches)
529
+ pattern
530
+ ];
531
+ //treat the pattern as a directory (no harm in doing this because if it's a file, the pattern will just never match anything)
532
+ if (!pattern.endsWith('/**/*')) {
533
+ result.push(`${pattern}/**/*`);
899
534
  }
535
+ return result;
536
+ })
537
+ .flat(1);
538
+ }
539
+ /**
540
+ * Ask the project manager to sync all projects found within the list of workspaces
541
+ * @param forceReload if true, all projects are discarded and recreated from scratch
542
+ */
543
+ async syncProjects(forceReload = false) {
544
+ const workspaces = await this.getWorkspaceConfigs();
545
+ await this.projectManager.syncProjects(workspaces, forceReload);
546
+ //set our logLevel to the most verbose log level found across all projects and workspaces
547
+ await this.syncLogLevel();
548
+ }
549
+ /**
550
+ * Given a workspaceFolder path, get the specified configuration from the client (if applicable).
551
+ * Be sure to use optional chaining to traverse the result in case that configuration doesn't exist or the client doesn't support `getConfiguration`
552
+ * @param workspaceFolder the folder for the workspace in the client
553
+ */
554
+ async getClientConfiguration(workspaceFolder, section) {
555
+ const scopeUri = util_1.util.pathToUri(workspaceFolder);
556
+ let config = {};
557
+ //if the client supports configuration, look for config group called "brightscript"
558
+ if (this.hasConfigurationCapability) {
559
+ config = await this.connection.workspace.getConfiguration({
560
+ scopeUri: scopeUri,
561
+ section: section
562
+ });
900
563
  }
564
+ return config;
565
+ }
566
+ /**
567
+ * Send a critical failure notification to the client, which should show a notification of some kind
568
+ */
569
+ sendCriticalFailure(message) {
570
+ this.connection.sendNotification('critical-failure', message).catch(logAndIgnoreError);
571
+ }
572
+ /**
573
+ * Send diagnostics to the client
574
+ */
575
+ async sendDiagnostics(options) {
576
+ const patch = this.diagnosticCollection.getPatch(options.project.projectNumber, options.diagnostics);
577
+ await Promise.all(Object.keys(patch).map(async (srcPath) => {
578
+ const uri = vscode_uri_1.URI.file(srcPath).toString();
579
+ const diagnostics = patch[srcPath].map(d => util_1.util.toDiagnostic(d, uri));
580
+ await this.connection.sendDiagnostics({
581
+ uri: uri,
582
+ diagnostics: diagnostics
583
+ });
584
+ }));
901
585
  }
902
586
  dispose() {
903
- var _a;
587
+ var _a, _b, _c;
904
588
  (_a = this.loggerSubscription) === null || _a === void 0 ? void 0 : _a.call(this);
905
- this.validateThrottler.dispose();
589
+ (_c = (_b = this.projectManager) === null || _b === void 0 ? void 0 : _b.dispose) === null || _c === void 0 ? void 0 : _c.call(_b);
906
590
  }
907
591
  }
592
+ /**
593
+ * The default threading setting for the language server. Can be overridden by per-workspace settings
594
+ */
595
+ LanguageServer.enableThreadingDefault = true;
596
+ /**
597
+ * The default project discovery setting for the language server. Can be overridden by per-workspace settings
598
+ */
599
+ LanguageServer.enableProjectDiscoveryDefault = true;
908
600
  __decorate([
909
601
  AddStackToErrorMessage
910
602
  ], LanguageServer.prototype, "onInitialize", null);
@@ -913,28 +605,22 @@ __decorate([
913
605
  ], LanguageServer.prototype, "onInitialized", null);
914
606
  __decorate([
915
607
  AddStackToErrorMessage
916
- ], LanguageServer.prototype, "onCompletion", null);
608
+ ], LanguageServer.prototype, "onTextDocumentDidChangeContent", null);
917
609
  __decorate([
918
610
  AddStackToErrorMessage
919
- ], LanguageServer.prototype, "onCompletionResolve", null);
611
+ ], LanguageServer.prototype, "onDidChangeWatchedFiles", null);
920
612
  __decorate([
921
613
  AddStackToErrorMessage
922
- ], LanguageServer.prototype, "onCodeAction", null);
614
+ ], LanguageServer.prototype, "onDocumentClose", null);
923
615
  __decorate([
924
616
  AddStackToErrorMessage
925
- ], LanguageServer.prototype, "onDidChangeConfiguration", null);
617
+ ], LanguageServer.prototype, "onCompletion", null);
926
618
  __decorate([
927
619
  AddStackToErrorMessage
928
- ], LanguageServer.prototype, "onDidChangeWatchedFiles", null);
620
+ ], LanguageServer.prototype, "onDidChangeConfiguration", null);
929
621
  __decorate([
930
622
  AddStackToErrorMessage
931
623
  ], LanguageServer.prototype, "onHover", null);
932
- __decorate([
933
- AddStackToErrorMessage
934
- ], LanguageServer.prototype, "onDocumentClose", null);
935
- __decorate([
936
- AddStackToErrorMessage
937
- ], LanguageServer.prototype, "validateTextDocument", null);
938
624
  __decorate([
939
625
  AddStackToErrorMessage
940
626
  ], LanguageServer.prototype, "onWorkspaceSymbol", null);
@@ -953,6 +639,9 @@ __decorate([
953
639
  __decorate([
954
640
  AddStackToErrorMessage
955
641
  ], LanguageServer.prototype, "onFullSemanticTokens", null);
642
+ __decorate([
643
+ AddStackToErrorMessage
644
+ ], LanguageServer.prototype, "onCodeAction", null);
956
645
  __decorate([
957
646
  AddStackToErrorMessage
958
647
  ], LanguageServer.prototype, "onExecuteCommand", null);
@@ -961,6 +650,10 @@ var CustomCommands;
961
650
  (function (CustomCommands) {
962
651
  CustomCommands["TranspileFile"] = "TranspileFile";
963
652
  })(CustomCommands = exports.CustomCommands || (exports.CustomCommands = {}));
653
+ var NotificationName;
654
+ (function (NotificationName) {
655
+ NotificationName["busyStatus"] = "busyStatus";
656
+ })(NotificationName = exports.NotificationName || (exports.NotificationName = {}));
964
657
  /**
965
658
  * Wraps a method. If there's an error (either sync or via a promise),
966
659
  * this appends the error's stack trace at the end of the error message so that the connection will
@@ -992,4 +685,10 @@ function AddStackToErrorMessage(target, propertyKey, descriptor) {
992
685
  }
993
686
  };
994
687
  }
688
+ function logAndIgnoreError(error) {
689
+ if (error === null || error === void 0 ? void 0 : error.stack) {
690
+ error.message = error.stack;
691
+ }
692
+ console.error(error);
693
+ }
995
694
  //# sourceMappingURL=LanguageServer.js.map