brighterscript 1.0.0-alpha.24 → 1.0.0-alpha.26

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 (536) hide show
  1. package/CHANGELOG.md +521 -233
  2. package/README.md +45 -139
  3. package/bsconfig.schema.json +46 -0
  4. package/dist/ActionPipeline.d.ts +10 -0
  5. package/dist/ActionPipeline.js +40 -0
  6. package/dist/ActionPipeline.js.map +1 -0
  7. package/dist/AstValidationSegmenter.d.ts +25 -0
  8. package/dist/AstValidationSegmenter.js +152 -0
  9. package/dist/AstValidationSegmenter.js.map +1 -0
  10. package/dist/BsConfig.d.ts +40 -4
  11. package/dist/BusyStatusTracker.d.ts +31 -0
  12. package/dist/BusyStatusTracker.js +83 -0
  13. package/dist/BusyStatusTracker.js.map +1 -0
  14. package/dist/Cache.js +3 -3
  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 +3 -3
  20. package/dist/CodeActionUtil.js.map +1 -1
  21. package/dist/CommentFlagProcessor.d.ts +3 -2
  22. package/dist/CommentFlagProcessor.js +5 -4
  23. package/dist/CommentFlagProcessor.js.map +1 -1
  24. package/dist/DependencyGraph.d.ts +3 -2
  25. package/dist/DependencyGraph.js +11 -10
  26. package/dist/DependencyGraph.js.map +1 -1
  27. package/dist/DiagnosticCollection.js +9 -5
  28. package/dist/DiagnosticCollection.js.map +1 -1
  29. package/dist/DiagnosticFilterer.d.ts +1 -0
  30. package/dist/DiagnosticFilterer.js +5 -3
  31. package/dist/DiagnosticFilterer.js.map +1 -1
  32. package/dist/DiagnosticMessages.d.ts +61 -13
  33. package/dist/DiagnosticMessages.js +116 -19
  34. package/dist/DiagnosticMessages.js.map +1 -1
  35. package/dist/DiagnosticSeverityAdjuster.d.ts +7 -0
  36. package/dist/DiagnosticSeverityAdjuster.js +41 -0
  37. package/dist/DiagnosticSeverityAdjuster.js.map +1 -0
  38. package/dist/FunctionScope.d.ts +28 -0
  39. package/dist/FunctionScope.js +52 -0
  40. package/dist/FunctionScope.js.map +1 -0
  41. package/dist/KeyedThrottler.d.ts +3 -3
  42. package/dist/KeyedThrottler.js +3 -3
  43. package/dist/KeyedThrottler.js.map +1 -1
  44. package/dist/LanguageServer.d.ts +23 -11
  45. package/dist/LanguageServer.js +150 -69
  46. package/dist/LanguageServer.js.map +1 -1
  47. package/dist/Logger.d.ts +3 -2
  48. package/dist/Logger.js +11 -3
  49. package/dist/Logger.js.map +1 -1
  50. package/dist/PluginInterface.d.ts +21 -3
  51. package/dist/PluginInterface.js +74 -6
  52. package/dist/PluginInterface.js.map +1 -1
  53. package/dist/Program.d.ts +158 -79
  54. package/dist/Program.js +841 -706
  55. package/dist/Program.js.map +1 -1
  56. package/dist/ProgramBuilder.d.ts +22 -12
  57. package/dist/ProgramBuilder.js +130 -103
  58. package/dist/ProgramBuilder.js.map +1 -1
  59. package/dist/Scope.d.ts +86 -137
  60. package/dist/Scope.js +453 -519
  61. package/dist/Scope.js.map +1 -1
  62. package/dist/Stopwatch.js +1 -1
  63. package/dist/Stopwatch.js.map +1 -1
  64. package/dist/SymbolTable.d.ts +89 -34
  65. package/dist/SymbolTable.js +239 -114
  66. package/dist/SymbolTable.js.map +1 -1
  67. package/dist/Throttler.d.ts +12 -0
  68. package/dist/Throttler.js +39 -0
  69. package/dist/Throttler.js.map +1 -1
  70. package/dist/Watcher.d.ts +0 -3
  71. package/dist/Watcher.js +0 -3
  72. package/dist/Watcher.js.map +1 -1
  73. package/dist/XmlScope.d.ts +4 -11
  74. package/dist/XmlScope.js +75 -88
  75. package/dist/XmlScope.js.map +1 -1
  76. package/dist/astUtils/CachedLookups.d.ts +48 -0
  77. package/dist/astUtils/CachedLookups.js +323 -0
  78. package/dist/astUtils/CachedLookups.js.map +1 -0
  79. package/dist/astUtils/{AstEditor.d.ts → Editor.d.ts} +9 -5
  80. package/dist/astUtils/{AstEditor.js → Editor.js} +10 -4
  81. package/dist/astUtils/Editor.js.map +1 -0
  82. package/dist/astUtils/{AstEditor.spec.js → Editor.spec.js} +69 -65
  83. package/dist/astUtils/Editor.spec.js.map +1 -0
  84. package/dist/astUtils/creators.d.ts +10 -10
  85. package/dist/astUtils/creators.js +54 -24
  86. package/dist/astUtils/creators.js.map +1 -1
  87. package/dist/astUtils/creators.spec.js +5 -5
  88. package/dist/astUtils/creators.spec.js.map +1 -1
  89. package/dist/astUtils/reflection.d.ts +132 -104
  90. package/dist/astUtils/reflection.js +220 -174
  91. package/dist/astUtils/reflection.js.map +1 -1
  92. package/dist/astUtils/reflection.spec.js +256 -157
  93. package/dist/astUtils/reflection.spec.js.map +1 -1
  94. package/dist/astUtils/stackedVisitor.spec.js +12 -12
  95. package/dist/astUtils/stackedVisitor.spec.js.map +1 -1
  96. package/dist/astUtils/visitors.d.ts +53 -35
  97. package/dist/astUtils/visitors.js +29 -3
  98. package/dist/astUtils/visitors.js.map +1 -1
  99. package/dist/astUtils/visitors.spec.js +208 -52
  100. package/dist/astUtils/visitors.spec.js.map +1 -1
  101. package/dist/astUtils/xml.d.ts +9 -9
  102. package/dist/astUtils/xml.js +9 -9
  103. package/dist/astUtils/xml.js.map +1 -1
  104. package/dist/bscPlugin/BscPlugin.d.ts +11 -2
  105. package/dist/bscPlugin/BscPlugin.js +37 -3
  106. package/dist/bscPlugin/BscPlugin.js.map +1 -1
  107. package/dist/bscPlugin/CallExpressionInfo.d.ts +36 -0
  108. package/dist/bscPlugin/CallExpressionInfo.js +131 -0
  109. package/dist/bscPlugin/CallExpressionInfo.js.map +1 -0
  110. package/dist/bscPlugin/FileWriter.d.ts +6 -0
  111. package/dist/bscPlugin/FileWriter.js +24 -0
  112. package/dist/bscPlugin/FileWriter.js.map +1 -0
  113. package/dist/bscPlugin/SignatureHelpUtil.d.ts +10 -0
  114. package/dist/bscPlugin/SignatureHelpUtil.js +136 -0
  115. package/dist/bscPlugin/SignatureHelpUtil.js.map +1 -0
  116. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +16 -13
  117. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  118. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +16 -16
  119. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
  120. package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +52 -1
  121. package/dist/bscPlugin/completions/CompletionsProcessor.js +517 -26
  122. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
  123. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +1909 -0
  124. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -0
  125. package/dist/bscPlugin/definition/DefinitionProvider.d.ts +13 -0
  126. package/dist/bscPlugin/definition/DefinitionProvider.js +210 -0
  127. package/dist/bscPlugin/definition/DefinitionProvider.js.map +1 -0
  128. package/dist/bscPlugin/definition/DefinitionProvider.spec.js +88 -0
  129. package/dist/bscPlugin/definition/DefinitionProvider.spec.js.map +1 -0
  130. package/dist/bscPlugin/fileProviders/FileProvider.d.ts +9 -0
  131. package/dist/bscPlugin/fileProviders/FileProvider.js +51 -0
  132. package/dist/bscPlugin/fileProviders/FileProvider.js.map +1 -0
  133. package/dist/bscPlugin/hover/HoverProcessor.d.ts +7 -7
  134. package/dist/bscPlugin/hover/HoverProcessor.js +123 -125
  135. package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
  136. package/dist/bscPlugin/hover/HoverProcessor.spec.js +371 -53
  137. package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
  138. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +2 -1
  139. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +83 -23
  140. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
  141. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +83 -6
  142. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -1
  143. package/dist/bscPlugin/serialize/BslibInjector.spec.d.ts +1 -0
  144. package/dist/bscPlugin/serialize/BslibInjector.spec.js +19 -0
  145. package/dist/bscPlugin/serialize/BslibInjector.spec.js.map +1 -0
  146. package/dist/bscPlugin/serialize/BslibManager.d.ts +9 -0
  147. package/dist/bscPlugin/serialize/BslibManager.js +40 -0
  148. package/dist/bscPlugin/serialize/BslibManager.js.map +1 -0
  149. package/dist/bscPlugin/serialize/FileSerializer.d.ts +9 -0
  150. package/dist/bscPlugin/serialize/FileSerializer.js +72 -0
  151. package/dist/bscPlugin/serialize/FileSerializer.js.map +1 -0
  152. package/dist/bscPlugin/transpile/{BrsFilePreTranspileProcessor.d.ts → BrsFileTranspileProcessor.d.ts} +4 -2
  153. package/dist/bscPlugin/transpile/{BrsFilePreTranspileProcessor.js → BrsFileTranspileProcessor.js} +38 -12
  154. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -0
  155. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.d.ts +1 -0
  156. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js +41 -0
  157. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +1 -0
  158. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +12 -0
  159. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js +99 -0
  160. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +1 -0
  161. package/dist/bscPlugin/validation/BrsFileValidator.d.ts +13 -5
  162. package/dist/bscPlugin/validation/BrsFileValidator.js +262 -52
  163. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
  164. package/dist/bscPlugin/validation/BrsFileValidator.spec.js +230 -14
  165. package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -1
  166. package/dist/bscPlugin/validation/ProgramValidator.d.ts +10 -0
  167. package/dist/bscPlugin/validation/ProgramValidator.js +32 -0
  168. package/dist/bscPlugin/validation/ProgramValidator.js.map +1 -0
  169. package/dist/bscPlugin/validation/ScopeValidator.d.ts +58 -27
  170. package/dist/bscPlugin/validation/ScopeValidator.js +514 -286
  171. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
  172. package/dist/bscPlugin/validation/ScopeValidator.spec.d.ts +1 -0
  173. package/dist/bscPlugin/validation/ScopeValidator.spec.js +2527 -0
  174. package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -0
  175. package/dist/bscPlugin/validation/XmlFileValidator.d.ts +8 -0
  176. package/dist/bscPlugin/validation/XmlFileValidator.js +44 -0
  177. package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -0
  178. package/dist/cli.js +104 -13
  179. package/dist/cli.js.map +1 -1
  180. package/dist/deferred.d.ts +3 -3
  181. package/dist/deferred.js.map +1 -1
  182. package/dist/diagnosticUtils.d.ts +8 -2
  183. package/dist/diagnosticUtils.js +47 -17
  184. package/dist/diagnosticUtils.js.map +1 -1
  185. package/dist/examples/plugins/removePrint.js +8 -10
  186. package/dist/examples/plugins/removePrint.js.map +1 -1
  187. package/dist/files/AssetFile.d.ts +26 -0
  188. package/dist/files/AssetFile.js +26 -0
  189. package/dist/files/AssetFile.js.map +1 -0
  190. package/dist/files/BrsFile.Class.spec.js +523 -493
  191. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  192. package/dist/files/BrsFile.d.ts +111 -117
  193. package/dist/files/BrsFile.js +684 -1142
  194. package/dist/files/BrsFile.js.map +1 -1
  195. package/dist/files/BrsFile.spec.js +1783 -1233
  196. package/dist/files/BrsFile.spec.js.map +1 -1
  197. package/dist/files/BscFile.d.ts +104 -0
  198. package/dist/files/BscFile.js +16 -0
  199. package/dist/files/BscFile.js.map +1 -0
  200. package/dist/files/Factory.d.ts +25 -0
  201. package/dist/files/Factory.js +22 -0
  202. package/dist/files/Factory.js.map +1 -0
  203. package/dist/files/LazyFileData.d.ts +20 -0
  204. package/dist/files/LazyFileData.js +54 -0
  205. package/dist/files/LazyFileData.js.map +1 -0
  206. package/dist/files/LazyFileData.spec.d.ts +1 -0
  207. package/dist/files/LazyFileData.spec.js +27 -0
  208. package/dist/files/LazyFileData.spec.js.map +1 -0
  209. package/dist/files/XmlFile.d.ts +70 -32
  210. package/dist/files/XmlFile.js +106 -118
  211. package/dist/files/XmlFile.js.map +1 -1
  212. package/dist/files/XmlFile.spec.js +325 -262
  213. package/dist/files/XmlFile.spec.js.map +1 -1
  214. package/dist/files/tests/imports.spec.js +48 -40
  215. package/dist/files/tests/imports.spec.js.map +1 -1
  216. package/dist/files/tests/optionalChaning.spec.js +84 -24
  217. package/dist/files/tests/optionalChaning.spec.js.map +1 -1
  218. package/dist/globalCallables.js +16 -21
  219. package/dist/globalCallables.js.map +1 -1
  220. package/dist/index.d.ts +12 -1
  221. package/dist/index.js +12 -1
  222. package/dist/index.js.map +1 -1
  223. package/dist/interfaces.d.ts +421 -162
  224. package/dist/interfaces.js +27 -0
  225. package/dist/interfaces.js.map +1 -1
  226. package/dist/lexer/Character.spec.js +5 -5
  227. package/dist/lexer/Character.spec.js.map +1 -1
  228. package/dist/lexer/Lexer.d.ts +12 -5
  229. package/dist/lexer/Lexer.js +28 -13
  230. package/dist/lexer/Lexer.js.map +1 -1
  231. package/dist/lexer/Lexer.spec.js +181 -135
  232. package/dist/lexer/Lexer.spec.js.map +1 -1
  233. package/dist/lexer/Token.d.ts +9 -1
  234. package/dist/lexer/Token.js +9 -1
  235. package/dist/lexer/Token.js.map +1 -1
  236. package/dist/lexer/TokenKind.d.ts +8 -0
  237. package/dist/lexer/TokenKind.js +24 -4
  238. package/dist/lexer/TokenKind.js.map +1 -1
  239. package/dist/parser/AstNode.d.ts +162 -0
  240. package/dist/parser/AstNode.js +225 -0
  241. package/dist/parser/AstNode.js.map +1 -0
  242. package/dist/parser/AstNode.spec.d.ts +1 -0
  243. package/dist/parser/AstNode.spec.js +165 -0
  244. package/dist/parser/AstNode.spec.js.map +1 -0
  245. package/dist/parser/BrsTranspileState.d.ts +4 -7
  246. package/dist/parser/BrsTranspileState.js +4 -12
  247. package/dist/parser/BrsTranspileState.js.map +1 -1
  248. package/dist/parser/Expression.d.ts +376 -283
  249. package/dist/parser/Expression.js +742 -585
  250. package/dist/parser/Expression.js.map +1 -1
  251. package/dist/parser/Parser.Class.spec.js +151 -145
  252. package/dist/parser/Parser.Class.spec.js.map +1 -1
  253. package/dist/parser/Parser.d.ts +48 -201
  254. package/dist/parser/Parser.js +705 -1026
  255. package/dist/parser/Parser.js.map +1 -1
  256. package/dist/parser/Parser.spec.d.ts +3 -1
  257. package/dist/parser/Parser.spec.js +861 -848
  258. package/dist/parser/Parser.spec.js.map +1 -1
  259. package/dist/parser/SGParser.d.ts +9 -8
  260. package/dist/parser/SGParser.js +10 -8
  261. package/dist/parser/SGParser.js.map +1 -1
  262. package/dist/parser/SGParser.spec.js +27 -38
  263. package/dist/parser/SGParser.spec.js.map +1 -1
  264. package/dist/parser/SGTypes.d.ts +98 -35
  265. package/dist/parser/SGTypes.js +169 -99
  266. package/dist/parser/SGTypes.js.map +1 -1
  267. package/dist/parser/Statement.d.ts +468 -272
  268. package/dist/parser/Statement.js +904 -631
  269. package/dist/parser/Statement.js.map +1 -1
  270. package/dist/parser/Statement.spec.js +47 -23
  271. package/dist/parser/Statement.spec.js.map +1 -1
  272. package/dist/parser/TranspileState.d.ts +1 -1
  273. package/dist/parser/TranspileState.js +7 -12
  274. package/dist/parser/TranspileState.js.map +1 -1
  275. package/dist/parser/tests/Parser.spec.js +3 -2
  276. package/dist/parser/tests/Parser.spec.js.map +1 -1
  277. package/dist/parser/tests/controlFlow/For.spec.js +33 -23
  278. package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
  279. package/dist/parser/tests/controlFlow/ForEach.spec.js +25 -20
  280. package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
  281. package/dist/parser/tests/controlFlow/If.spec.js +96 -94
  282. package/dist/parser/tests/controlFlow/If.spec.js.map +1 -1
  283. package/dist/parser/tests/controlFlow/While.spec.js +22 -16
  284. package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
  285. package/dist/parser/tests/expression/Additive.spec.js +8 -8
  286. package/dist/parser/tests/expression/Additive.spec.js.map +1 -1
  287. package/dist/parser/tests/expression/ArrayLiterals.spec.js +58 -21
  288. package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +1 -1
  289. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +62 -21
  290. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
  291. package/dist/parser/tests/expression/Boolean.spec.js +8 -8
  292. package/dist/parser/tests/expression/Boolean.spec.js.map +1 -1
  293. package/dist/parser/tests/expression/Call.spec.js +129 -21
  294. package/dist/parser/tests/expression/Call.spec.js.map +1 -1
  295. package/dist/parser/tests/expression/Exponential.spec.js +5 -5
  296. package/dist/parser/tests/expression/Exponential.spec.js.map +1 -1
  297. package/dist/parser/tests/expression/Function.spec.js +36 -36
  298. package/dist/parser/tests/expression/Function.spec.js.map +1 -1
  299. package/dist/parser/tests/expression/Indexing.spec.js +92 -22
  300. package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
  301. package/dist/parser/tests/expression/Multiplicative.spec.js +9 -9
  302. package/dist/parser/tests/expression/Multiplicative.spec.js.map +1 -1
  303. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +59 -59
  304. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
  305. package/dist/parser/tests/expression/PrefixUnary.spec.js +12 -12
  306. package/dist/parser/tests/expression/PrefixUnary.spec.js.map +1 -1
  307. package/dist/parser/tests/expression/Primary.spec.js +12 -12
  308. package/dist/parser/tests/expression/Primary.spec.js.map +1 -1
  309. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +10 -10
  310. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -1
  311. package/dist/parser/tests/expression/Relational.spec.js +13 -13
  312. package/dist/parser/tests/expression/Relational.spec.js.map +1 -1
  313. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +24 -24
  314. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +1 -1
  315. package/dist/parser/tests/expression/TemplateStringExpression.spec.js +96 -57
  316. package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
  317. package/dist/parser/tests/expression/TernaryExpression.spec.js +89 -89
  318. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
  319. package/dist/parser/tests/expression/TypeExpression.spec.d.ts +1 -0
  320. package/dist/parser/tests/expression/TypeExpression.spec.js +127 -0
  321. package/dist/parser/tests/expression/TypeExpression.spec.js.map +1 -0
  322. package/dist/parser/tests/expression/UnaryExpression.spec.d.ts +1 -0
  323. package/dist/parser/tests/expression/UnaryExpression.spec.js +52 -0
  324. package/dist/parser/tests/expression/UnaryExpression.spec.js.map +1 -0
  325. package/dist/parser/tests/statement/AssignmentOperators.spec.js +15 -15
  326. package/dist/parser/tests/statement/AssignmentOperators.spec.js.map +1 -1
  327. package/dist/parser/tests/statement/ConstStatement.spec.js +82 -33
  328. package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -1
  329. package/dist/parser/tests/statement/Continue.spec.d.ts +1 -0
  330. package/dist/parser/tests/statement/Continue.spec.js +119 -0
  331. package/dist/parser/tests/statement/Continue.spec.js.map +1 -0
  332. package/dist/parser/tests/statement/Declaration.spec.js +19 -19
  333. package/dist/parser/tests/statement/Declaration.spec.js.map +1 -1
  334. package/dist/parser/tests/statement/Dim.spec.js +22 -22
  335. package/dist/parser/tests/statement/Dim.spec.js.map +1 -1
  336. package/dist/parser/tests/statement/Enum.spec.js +98 -302
  337. package/dist/parser/tests/statement/Enum.spec.js.map +1 -1
  338. package/dist/parser/tests/statement/For.spec.js +9 -10
  339. package/dist/parser/tests/statement/For.spec.js.map +1 -1
  340. package/dist/parser/tests/statement/ForEach.spec.js +8 -9
  341. package/dist/parser/tests/statement/ForEach.spec.js.map +1 -1
  342. package/dist/parser/tests/statement/Function.spec.js +44 -35
  343. package/dist/parser/tests/statement/Function.spec.js.map +1 -1
  344. package/dist/parser/tests/statement/Goto.spec.js +5 -5
  345. package/dist/parser/tests/statement/Goto.spec.js.map +1 -1
  346. package/dist/parser/tests/statement/Increment.spec.js +20 -20
  347. package/dist/parser/tests/statement/Increment.spec.js.map +1 -1
  348. package/dist/parser/tests/statement/InterfaceStatement.spec.js +30 -196
  349. package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
  350. package/dist/parser/tests/statement/LibraryStatement.spec.js +11 -11
  351. package/dist/parser/tests/statement/LibraryStatement.spec.js.map +1 -1
  352. package/dist/parser/tests/statement/Misc.spec.js +16 -78
  353. package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
  354. package/dist/parser/tests/statement/PrintStatement.spec.js +36 -34
  355. package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
  356. package/dist/parser/tests/statement/ReturnStatement.spec.js +14 -12
  357. package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
  358. package/dist/parser/tests/statement/Set.spec.js +48 -35
  359. package/dist/parser/tests/statement/Set.spec.js.map +1 -1
  360. package/dist/parser/tests/statement/Stop.spec.js +6 -6
  361. package/dist/parser/tests/statement/Stop.spec.js.map +1 -1
  362. package/dist/parser/tests/statement/Throw.spec.js +6 -6
  363. package/dist/parser/tests/statement/Throw.spec.js.map +1 -1
  364. package/dist/parser/tests/statement/TryCatch.spec.js +18 -16
  365. package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
  366. package/dist/preprocessor/Manifest.d.ts +1 -1
  367. package/dist/preprocessor/Manifest.js +2 -2
  368. package/dist/preprocessor/Manifest.js.map +1 -1
  369. package/dist/preprocessor/Manifest.spec.js +8 -8
  370. package/dist/preprocessor/Manifest.spec.js.map +1 -1
  371. package/dist/preprocessor/Preprocessor.d.ts +5 -6
  372. package/dist/preprocessor/Preprocessor.js +5 -5
  373. package/dist/preprocessor/Preprocessor.js.map +1 -1
  374. package/dist/preprocessor/Preprocessor.spec.js +25 -25
  375. package/dist/preprocessor/Preprocessor.spec.js.map +1 -1
  376. package/dist/preprocessor/PreprocessorParser.d.ts +1 -1
  377. package/dist/preprocessor/PreprocessorParser.js +7 -1
  378. package/dist/preprocessor/PreprocessorParser.js.map +1 -1
  379. package/dist/preprocessor/PreprocessorParser.spec.js +13 -13
  380. package/dist/preprocessor/PreprocessorParser.spec.js.map +1 -1
  381. package/dist/roku-types/data.json +5892 -10081
  382. package/dist/roku-types/index.d.ts +622 -1719
  383. package/dist/types/ArrayType.d.ts +10 -9
  384. package/dist/types/ArrayType.js +65 -60
  385. package/dist/types/ArrayType.js.map +1 -1
  386. package/dist/types/ArrayType.spec.js +36 -68
  387. package/dist/types/ArrayType.spec.js.map +1 -1
  388. package/dist/types/AssociativeArrayType.d.ts +11 -0
  389. package/dist/types/AssociativeArrayType.js +52 -0
  390. package/dist/types/AssociativeArrayType.js.map +1 -0
  391. package/dist/types/BaseFunctionType.d.ts +9 -0
  392. package/dist/types/BaseFunctionType.js +25 -0
  393. package/dist/types/BaseFunctionType.js.map +1 -0
  394. package/dist/types/BooleanType.d.ts +8 -5
  395. package/dist/types/BooleanType.js +14 -7
  396. package/dist/types/BooleanType.js.map +1 -1
  397. package/dist/types/BooleanType.spec.js +10 -6
  398. package/dist/types/BooleanType.spec.js.map +1 -1
  399. package/dist/types/BscType.d.ts +32 -21
  400. package/dist/types/BscType.js +118 -21
  401. package/dist/types/BscType.js.map +1 -1
  402. package/dist/types/BscTypeKind.d.ts +25 -0
  403. package/dist/types/BscTypeKind.js +30 -0
  404. package/dist/types/BscTypeKind.js.map +1 -0
  405. package/dist/types/BuiltInInterfaceAdder.d.ts +23 -0
  406. package/dist/types/BuiltInInterfaceAdder.js +171 -0
  407. package/dist/types/BuiltInInterfaceAdder.js.map +1 -0
  408. package/dist/types/BuiltInInterfaceAdder.spec.d.ts +1 -0
  409. package/dist/types/BuiltInInterfaceAdder.spec.js +116 -0
  410. package/dist/types/BuiltInInterfaceAdder.spec.js.map +1 -0
  411. package/dist/types/ClassType.d.ts +17 -0
  412. package/dist/types/ClassType.js +58 -0
  413. package/dist/types/ClassType.js.map +1 -0
  414. package/dist/types/ClassType.spec.d.ts +1 -0
  415. package/dist/types/ClassType.spec.js +77 -0
  416. package/dist/types/ClassType.spec.js.map +1 -0
  417. package/dist/types/ComponentType.d.ts +26 -0
  418. package/dist/types/ComponentType.js +83 -0
  419. package/dist/types/ComponentType.js.map +1 -0
  420. package/dist/types/DoubleType.d.ts +8 -5
  421. package/dist/types/DoubleType.js +18 -16
  422. package/dist/types/DoubleType.js.map +1 -1
  423. package/dist/types/DoubleType.spec.js +12 -6
  424. package/dist/types/DoubleType.spec.js.map +1 -1
  425. package/dist/types/DynamicType.d.ts +9 -5
  426. package/dist/types/DynamicType.js +15 -4
  427. package/dist/types/DynamicType.js.map +1 -1
  428. package/dist/types/DynamicType.spec.js +16 -5
  429. package/dist/types/DynamicType.spec.js.map +1 -1
  430. package/dist/types/EnumType.d.ts +30 -12
  431. package/dist/types/EnumType.js +43 -17
  432. package/dist/types/EnumType.js.map +1 -1
  433. package/dist/types/EnumType.spec.d.ts +1 -0
  434. package/dist/types/EnumType.spec.js +33 -0
  435. package/dist/types/EnumType.spec.js.map +1 -0
  436. package/dist/types/FloatType.d.ts +8 -5
  437. package/dist/types/FloatType.js +18 -16
  438. package/dist/types/FloatType.js.map +1 -1
  439. package/dist/types/FloatType.spec.js +4 -6
  440. package/dist/types/FloatType.spec.js.map +1 -1
  441. package/dist/types/FunctionType.d.ts +13 -8
  442. package/dist/types/FunctionType.js +30 -14
  443. package/dist/types/FunctionType.js.map +1 -1
  444. package/dist/types/InheritableType.d.ts +28 -0
  445. package/dist/types/InheritableType.js +152 -0
  446. package/dist/types/InheritableType.js.map +1 -0
  447. package/dist/types/IntegerType.d.ts +8 -5
  448. package/dist/types/IntegerType.js +18 -16
  449. package/dist/types/IntegerType.js.map +1 -1
  450. package/dist/types/IntegerType.spec.js +8 -6
  451. package/dist/types/IntegerType.spec.js.map +1 -1
  452. package/dist/types/InterfaceType.d.ts +12 -13
  453. package/dist/types/InterfaceType.js +20 -48
  454. package/dist/types/InterfaceType.js.map +1 -1
  455. package/dist/types/InterfaceType.spec.js +90 -56
  456. package/dist/types/InterfaceType.spec.js.map +1 -1
  457. package/dist/types/InvalidType.d.ts +7 -5
  458. package/dist/types/InvalidType.js +13 -7
  459. package/dist/types/InvalidType.js.map +1 -1
  460. package/dist/types/InvalidType.spec.js +8 -6
  461. package/dist/types/InvalidType.spec.js.map +1 -1
  462. package/dist/types/LongIntegerType.d.ts +8 -5
  463. package/dist/types/LongIntegerType.js +17 -15
  464. package/dist/types/LongIntegerType.js.map +1 -1
  465. package/dist/types/LongIntegerType.spec.js +10 -6
  466. package/dist/types/LongIntegerType.spec.js.map +1 -1
  467. package/dist/types/NamespaceType.d.ts +12 -0
  468. package/dist/types/NamespaceType.js +28 -0
  469. package/dist/types/NamespaceType.js.map +1 -0
  470. package/dist/types/ObjectType.d.ts +9 -8
  471. package/dist/types/ObjectType.js +21 -11
  472. package/dist/types/ObjectType.js.map +1 -1
  473. package/dist/types/ObjectType.spec.js +3 -3
  474. package/dist/types/ObjectType.spec.js.map +1 -1
  475. package/dist/types/ReferenceType.d.ts +63 -0
  476. package/dist/types/ReferenceType.js +423 -0
  477. package/dist/types/ReferenceType.js.map +1 -0
  478. package/dist/types/ReferenceType.spec.d.ts +1 -0
  479. package/dist/types/ReferenceType.spec.js +137 -0
  480. package/dist/types/ReferenceType.spec.js.map +1 -0
  481. package/dist/types/StringType.d.ts +11 -5
  482. package/dist/types/StringType.js +18 -7
  483. package/dist/types/StringType.js.map +1 -1
  484. package/dist/types/StringType.spec.js +3 -5
  485. package/dist/types/StringType.spec.js.map +1 -1
  486. package/dist/types/TypedFunctionType.d.ts +22 -17
  487. package/dist/types/TypedFunctionType.js +78 -60
  488. package/dist/types/TypedFunctionType.js.map +1 -1
  489. package/dist/types/TypedFunctionType.spec.js +105 -20
  490. package/dist/types/TypedFunctionType.spec.js.map +1 -1
  491. package/dist/types/UninitializedType.d.ts +8 -6
  492. package/dist/types/UninitializedType.js +13 -7
  493. package/dist/types/UninitializedType.js.map +1 -1
  494. package/dist/types/UnionType.d.ts +20 -0
  495. package/dist/types/UnionType.js +123 -0
  496. package/dist/types/UnionType.js.map +1 -0
  497. package/dist/types/UnionType.spec.d.ts +1 -0
  498. package/dist/types/UnionType.spec.js +130 -0
  499. package/dist/types/UnionType.spec.js.map +1 -0
  500. package/dist/types/VoidType.d.ts +8 -5
  501. package/dist/types/VoidType.js +14 -7
  502. package/dist/types/VoidType.js.map +1 -1
  503. package/dist/types/VoidType.spec.js +3 -3
  504. package/dist/types/VoidType.spec.js.map +1 -1
  505. package/dist/types/helper.spec.d.ts +1 -0
  506. package/dist/types/helper.spec.js +145 -0
  507. package/dist/types/helper.spec.js.map +1 -0
  508. package/dist/types/helpers.d.ts +19 -37
  509. package/dist/types/helpers.js +159 -99
  510. package/dist/types/helpers.js.map +1 -1
  511. package/dist/types/index.d.ts +22 -0
  512. package/dist/types/index.js +39 -0
  513. package/dist/types/index.js.map +1 -0
  514. package/dist/util.d.ts +143 -139
  515. package/dist/util.js +864 -385
  516. package/dist/util.js.map +1 -1
  517. package/dist/validators/ClassValidator.d.ts +8 -25
  518. package/dist/validators/ClassValidator.js +99 -179
  519. package/dist/validators/ClassValidator.js.map +1 -1
  520. package/package.json +165 -152
  521. package/dist/astUtils/AstEditor.js.map +0 -1
  522. package/dist/astUtils/AstEditor.spec.js.map +0 -1
  523. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +0 -1
  524. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js +0 -32
  525. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js.map +0 -1
  526. package/dist/parser/SGTypes.spec.js +0 -351
  527. package/dist/parser/SGTypes.spec.js.map +0 -1
  528. package/dist/types/CustomType.d.ts +0 -12
  529. package/dist/types/CustomType.js +0 -44
  530. package/dist/types/CustomType.js.map +0 -1
  531. package/dist/types/LazyType.d.ts +0 -16
  532. package/dist/types/LazyType.js +0 -44
  533. package/dist/types/LazyType.js.map +0 -1
  534. /package/dist/astUtils/{AstEditor.spec.d.ts → Editor.spec.d.ts} +0 -0
  535. /package/dist/bscPlugin/{transpile/BrsFilePreTranspileProcessor.spec.d.ts → completions/CompletionsProcessor.spec.d.ts} +0 -0
  536. /package/dist/{parser/SGTypes.spec.d.ts → bscPlugin/definition/DefinitionProvider.spec.d.ts} +0 -0
@@ -17,9 +17,9 @@ class KeyedThrottler {
17
17
  return this.throttlers[key].run(job);
18
18
  }
19
19
  /**
20
- * Get a promise that resolves the next time the throttler becomes idle.
21
- * If no throttler exists, this will resolve immediately
22
- */
20
+ * Get a promise that resolves the next time the throttler becomes idle.
21
+ * If no throttler exists, this will resolve immediately
22
+ */
23
23
  async onIdleOnce(key, resolveImmediatelyIfIdle = true) {
24
24
  const throttler = this.throttlers[key];
25
25
  if (throttler) {
@@ -1 +1 @@
1
- {"version":3,"file":"KeyedThrottler.js","sourceRoot":"","sources":["../src/KeyedThrottler.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAExC,MAAa,cAAc;IACvB,YACa,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;QAKlB,eAAU,GAAG,EAA+B,CAAC;IAFrD,CAAC;IAID;;OAEG;IACI,GAAG,CAAC,GAAW,EAAE,GAAQ;QAC5B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACvB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,IAAI,qBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACpD;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;IAED;;;MAGE;IACK,KAAK,CAAC,UAAU,CAAC,GAAW,EAAE,wBAAwB,GAAG,IAAI;QAChE,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,SAAS,EAAE;YACX,OAAO,SAAS,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAC;SACzD;aAAM;YACH,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC5B;IACL,CAAC;CACJ;AA/BD,wCA+BC"}
1
+ {"version":3,"file":"KeyedThrottler.js","sourceRoot":"","sources":["../src/KeyedThrottler.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAExC,MAAa,cAAc;IACvB,YACa,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;QAKlB,eAAU,GAAG,EAA+B,CAAC;IAFrD,CAAC;IAID;;OAEG;IACI,GAAG,CAAC,GAAW,EAAE,GAAQ;QAC5B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACvB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,IAAI,qBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACpD;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,UAAU,CAAC,GAAW,EAAE,wBAAwB,GAAG,IAAI;QAChE,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,SAAS,EAAE;YACX,OAAO,SAAS,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAC;SACzD;aAAM;YACH,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC5B;IACL,CAAC;CACJ;AA/BD,wCA+BC"}
@@ -3,6 +3,7 @@ import type { InitializeParams, ServerCapabilities, ExecuteCommandParams, Worksp
3
3
  import { FileChangeType } from 'vscode-languageserver/node';
4
4
  import { ProgramBuilder } from './ProgramBuilder';
5
5
  import { Throttler } from './Throttler';
6
+ import { BusyStatusTracker } from './BusyStatusTracker';
6
7
  export declare class LanguageServer {
7
8
  private connection;
8
9
  projects: Project[];
@@ -34,10 +35,12 @@ export declare class LanguageServer {
34
35
  private sendDiagnosticsThrottler;
35
36
  private boundValidateAll;
36
37
  private validateAllThrottled;
38
+ busyStatusTracker: BusyStatusTracker;
37
39
  run(): void;
40
+ private busyStatusIndex;
41
+ private sendBusyStatus;
38
42
  /**
39
43
  * Called when the client starts initialization
40
- * @param params
41
44
  */
42
45
  onInitialize(params: InitializeParams): {
43
46
  capabilities: ServerCapabilities<any>;
@@ -65,7 +68,6 @@ export declare class LanguageServer {
65
68
  private getWorkspacePaths;
66
69
  /**
67
70
  * Called when the client has finished initializing
68
- * @param params
69
71
  */
70
72
  private onInitialized;
71
73
  /**
@@ -82,17 +84,24 @@ export declare class LanguageServer {
82
84
  */
83
85
  private documentFileResolver;
84
86
  private getConfigFilePath;
87
+ /**
88
+ * A unique project counter to help distinguish log entries in lsp mode
89
+ */
90
+ private projectCounter;
91
+ /**
92
+ * @param projectPath path to the project
93
+ * @param workspacePath path to the workspace in which all project should reside or are referenced by
94
+ * @param projectNumber an optional project number to assign to the project. Used when reloading projects that should keep the same number
95
+ */
85
96
  private createProject;
86
97
  private createStandaloneFileProject;
87
98
  private getProjects;
88
99
  /**
89
100
  * Provide a list of completion items based on the current cursor position
90
- * @param textDocumentPosition
91
101
  */
92
102
  private onCompletion;
93
103
  /**
94
104
  * Provide a full completion item from the selection
95
- * @param item
96
105
  */
97
106
  private onCompletionResolve;
98
107
  private onCodeAction;
@@ -119,13 +128,11 @@ export declare class LanguageServer {
119
128
  * The CLIENT is in charge of what files to watch, so all client
120
129
  * implementations should ensure that all valid project
121
130
  * file types are watched (.brs,.bs,.xml,manifest, and any json/text/image files)
122
- * @param params
123
131
  */
124
132
  private onDidChangeWatchedFiles;
125
133
  /**
126
134
  * This only operates on files that match the specified files globs, so it is safe to throw
127
135
  * any file changes you receive with no unexpected side-effects
128
- * @param changes
129
136
  */
130
137
  handleFileChanges(project: Project, changes: {
131
138
  type: FileChangeType;
@@ -134,7 +141,7 @@ export declare class LanguageServer {
134
141
  /**
135
142
  * This only operates on files that match the specified files globs, so it is safe to throw
136
143
  * any file changes you receive with no unexpected side-effects
137
- * @param changes
144
+ * @returns true if the file was handled by this project, false if it was not
138
145
  */
139
146
  private handleFileChange;
140
147
  private onHover;
@@ -142,21 +149,23 @@ export declare class LanguageServer {
142
149
  private validateTextDocument;
143
150
  private validateAll;
144
151
  onWorkspaceSymbol(params: WorkspaceSymbolParams): Promise<SymbolInformation[]>;
145
- onDocumentSymbol(params: DocumentSymbolParams): Promise<import("vscode-languageserver-types").DocumentSymbol[]>;
152
+ onDocumentSymbol(params: DocumentSymbolParams): Promise<import("vscode-languageserver/node").DocumentSymbol[]>;
146
153
  private onDefinition;
147
154
  private onSignatureHelp;
148
155
  private onReferences;
156
+ private onValidateSettled;
149
157
  private onFullSemanticTokens;
150
158
  private diagnosticCollection;
151
159
  private sendDiagnostics;
152
160
  onExecuteCommand(params: ExecuteCommandParams): Promise<import("./Program").FileTranspileResult>;
153
- /**
154
- * @param srcPath The absolute path to the source file on disk
155
- */
156
161
  private transpileFile;
157
162
  dispose(): void;
158
163
  }
159
164
  export interface Project {
165
+ /**
166
+ * A unique number for this project, generated during this current language server session. Mostly used so we can identify which project is doing logging
167
+ */
168
+ projectNumber: number;
160
169
  firstRunPromise: Promise<any>;
161
170
  builder: ProgramBuilder;
162
171
  /**
@@ -175,3 +184,6 @@ export interface Project {
175
184
  export declare enum CustomCommands {
176
185
  TranspileFile = "TranspileFile"
177
186
  }
187
+ export declare enum NotificationName {
188
+ busyStatus = "busyStatus"
189
+ }
@@ -6,7 +6,7 @@ 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;
9
+ exports.NotificationName = exports.CustomCommands = exports.LanguageServer = void 0;
10
10
  require("array-flat-polyfill");
11
11
  const fastGlob = require("fast-glob");
12
12
  const path = require("path");
@@ -24,6 +24,7 @@ const KeyedThrottler_1 = require("./KeyedThrottler");
24
24
  const DiagnosticCollection_1 = require("./DiagnosticCollection");
25
25
  const reflection_1 = require("./astUtils/reflection");
26
26
  const SemanticTokenUtils_1 = require("./SemanticTokenUtils");
27
+ const BusyStatusTracker_1 = require("./BusyStatusTracker");
27
28
  class LanguageServer {
28
29
  constructor() {
29
30
  this.connection = undefined;
@@ -53,6 +54,12 @@ class LanguageServer {
53
54
  this.validateThrottler = new Throttler_1.Throttler(0);
54
55
  this.sendDiagnosticsThrottler = new Throttler_1.Throttler(0);
55
56
  this.boundValidateAll = this.validateAll.bind(this);
57
+ this.busyStatusTracker = new BusyStatusTracker_1.BusyStatusTracker();
58
+ this.busyStatusIndex = -1;
59
+ /**
60
+ * A unique project counter to help distinguish log entries in lsp mode
61
+ */
62
+ this.projectCounter = 0;
56
63
  this.diagnosticCollection = new DiagnosticCollection_1.DiagnosticCollection();
57
64
  }
58
65
  createConnection() {
@@ -66,6 +73,10 @@ class LanguageServer {
66
73
  // Create a connection for the server. The connection uses Node's IPC as a transport.
67
74
  // Also include all preview / proposed LSP features.
68
75
  this.connection = this.createConnection();
76
+ // Send the current status of the busyStatusTracker anytime it changes
77
+ this.busyStatusTracker.on('change', (status) => {
78
+ this.sendBusyStatus(status);
79
+ });
69
80
  //listen to all of the output log events and pipe them into the debug channel in the extension
70
81
  this.loggerSubscription = Logger_1.Logger.subscribe((text) => {
71
82
  this.connection.tracer.log(text);
@@ -120,9 +131,17 @@ class LanguageServer {
120
131
  // Listen on the connection
121
132
  this.connection.listen();
122
133
  }
134
+ sendBusyStatus(status) {
135
+ this.busyStatusIndex = ++this.busyStatusIndex <= 0 ? 0 : this.busyStatusIndex;
136
+ this.connection.sendNotification(NotificationName.busyStatus, {
137
+ status: status,
138
+ timestamp: Date.now(),
139
+ index: this.busyStatusIndex,
140
+ activeRuns: [...this.busyStatusTracker.activeRuns]
141
+ });
142
+ }
123
143
  /**
124
144
  * Called when the client starts initialization
125
- * @param params
126
145
  */
127
146
  onInitialize(params) {
128
147
  let clientCapabilities = params.capabilities;
@@ -284,7 +303,6 @@ class LanguageServer {
284
303
  }
285
304
  /**
286
305
  * Called when the client has finished initializing
287
- * @param params
288
306
  */
289
307
  async onInitialized() {
290
308
  let projectCreatedDeferred = new deferred_1.Deferred();
@@ -324,7 +342,6 @@ class LanguageServer {
324
342
  if (waitForFirstProject) {
325
343
  await this.initialProjectsCreated;
326
344
  }
327
- let status;
328
345
  for (let project of this.getProjects()) {
329
346
  try {
330
347
  await project.firstRunPromise;
@@ -337,7 +354,6 @@ class LanguageServer {
337
354
  this.sendCriticalFailure(`BrighterScript language server failed to start: \n${e.message}`);
338
355
  }
339
356
  }
340
- this.connection.sendNotification('build-status', status ? status : 'success');
341
357
  }
342
358
  /**
343
359
  * Event handler for when the program wants to load file contents.
@@ -363,7 +379,7 @@ class LanguageServer {
363
379
  };
364
380
  //if the client supports configuration, look for config group called "brightscript"
365
381
  if (this.hasConfigurationCapability) {
366
- await this.connection.workspace.getConfiguration({
382
+ config = await this.connection.workspace.getConfiguration({
367
383
  scopeUri: scopeUri,
368
384
  section: 'brightscript'
369
385
  });
@@ -392,7 +408,12 @@ class LanguageServer {
392
408
  //no config file could be found
393
409
  return undefined;
394
410
  }
395
- async createProject(projectPath, workspacePath = projectPath) {
411
+ /**
412
+ * @param projectPath path to the project
413
+ * @param workspacePath path to the workspace in which all project should reside or are referenced by
414
+ * @param projectNumber an optional project number to assign to the project. Used when reloading projects that should keep the same number
415
+ */
416
+ async createProject(projectPath, workspacePath = projectPath, projectNumber) {
396
417
  workspacePath !== null && workspacePath !== void 0 ? workspacePath : (workspacePath = projectPath);
397
418
  let project = this.projects.find((x) => x.projectPath === projectPath);
398
419
  //skip this project if we already have it
@@ -400,6 +421,9 @@ class LanguageServer {
400
421
  return;
401
422
  }
402
423
  let builder = new ProgramBuilder_1.ProgramBuilder();
424
+ projectNumber !== null && projectNumber !== void 0 ? projectNumber : (projectNumber = this.projectCounter++);
425
+ builder.logger.prefix = `[prj${projectNumber}]`;
426
+ builder.logger.log(`Created project #${projectNumber} for: "${projectPath}"`);
403
427
  //flush diagnostics every time the program finishes validating
404
428
  builder.plugins.add({
405
429
  name: 'bsc-language-server',
@@ -421,21 +445,11 @@ class LanguageServer {
421
445
  //config file doesn't exist...let `brighterscript` resolve the default way
422
446
  configFilePath = undefined;
423
447
  }
424
- let firstRunPromise = builder.run({
425
- cwd: cwd,
426
- project: configFilePath,
427
- watch: false,
428
- createPackage: false,
429
- deploy: false,
430
- copyToStaging: false,
431
- showDiagnosticsInConsole: false
432
- });
433
- firstRunPromise.catch((err) => {
434
- console.error(err);
435
- });
448
+ const firstRunDeferred = new deferred_1.Deferred();
436
449
  let newProject = {
450
+ projectNumber: projectNumber,
437
451
  builder: builder,
438
- firstRunPromise: firstRunPromise,
452
+ firstRunPromise: firstRunDeferred.promise,
439
453
  projectPath: projectPath,
440
454
  workspacePath: workspacePath,
441
455
  isFirstRunComplete: false,
@@ -444,19 +458,31 @@ class LanguageServer {
444
458
  isStandaloneFileProject: false
445
459
  };
446
460
  this.projects.push(newProject);
447
- await firstRunPromise.then(() => {
461
+ try {
462
+ await builder.run({
463
+ cwd: cwd,
464
+ project: configFilePath,
465
+ watch: false,
466
+ createPackage: false,
467
+ deploy: false,
468
+ copyToStaging: false,
469
+ showDiagnosticsInConsole: false
470
+ });
448
471
  newProject.isFirstRunComplete = true;
449
472
  newProject.isFirstRunSuccessful = true;
450
- }).catch(() => {
473
+ firstRunDeferred.resolve();
474
+ }
475
+ catch (e) {
476
+ builder.logger.error(e);
477
+ firstRunDeferred.reject(e);
451
478
  newProject.isFirstRunComplete = true;
452
479
  newProject.isFirstRunSuccessful = false;
453
- }).then(() => {
454
- //if we found a deprecated brsconfig.json, add a diagnostic warning the user
455
- if (configFilePath && path.basename(configFilePath) === 'brsconfig.json') {
456
- builder.addDiagnostic(configFilePath, Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.brsConfigJsonIsDeprecated()), { range: util_1.util.createRange(0, 0, 0, 0) }));
457
- return this.sendDiagnostics();
458
- }
459
- });
480
+ }
481
+ //if we found a deprecated brsconfig.json, add a diagnostic warning the user
482
+ if (configFilePath && path.basename(configFilePath) === 'brsconfig.json') {
483
+ builder.addDiagnostic(configFilePath, Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.brsConfigJsonIsDeprecated()), { range: util_1.util.createRange(0, 0, 0, 0) }));
484
+ return this.sendDiagnostics();
485
+ }
460
486
  }
461
487
  async createStandaloneFileProject(srcPath) {
462
488
  //skip this workspace if we already have it
@@ -489,6 +515,7 @@ class LanguageServer {
489
515
  console.error(err);
490
516
  });
491
517
  let newProject = {
518
+ projectNumber: this.projectCounter++,
492
519
  builder: builder,
493
520
  firstRunPromise: firstRunPromise,
494
521
  projectPath: srcPath,
@@ -517,7 +544,6 @@ class LanguageServer {
517
544
  }
518
545
  /**
519
546
  * Provide a list of completion items based on the current cursor position
520
- * @param textDocumentPosition
521
547
  */
522
548
  async onCompletion(params) {
523
549
  //ensure programs are initialized
@@ -525,17 +551,24 @@ class LanguageServer {
525
551
  let filePath = util_1.util.uriToPath(params.textDocument.uri);
526
552
  //wait until the file has settled
527
553
  await this.keyedThrottler.onIdleOnce(filePath, true);
554
+ // make sure validation is complete
555
+ await this.validateAllThrottled();
556
+ //wait for the validation cycle to settle
557
+ await this.onValidateSettled();
528
558
  let completions = this
529
559
  .getProjects()
530
560
  .flatMap(workspace => workspace.builder.program.getCompletions(filePath, params.position));
561
+ //only send one completion if name and type are the same
562
+ let completionsMap = new Map();
531
563
  for (let completion of completions) {
532
564
  completion.commitCharacters = ['.'];
565
+ let key = `${completion.sortText}-${completion.label}-${completion.kind}`;
566
+ completionsMap.set(key, completion);
533
567
  }
534
- return completions;
568
+ return [...completionsMap.values()];
535
569
  }
536
570
  /**
537
571
  * Provide a full completion item from the selection
538
- * @param item
539
572
  */
540
573
  onCompletionResolve(item) {
541
574
  if (item.data === 1) {
@@ -549,6 +582,7 @@ class LanguageServer {
549
582
  return item;
550
583
  }
551
584
  async onCodeAction(params) {
585
+ var _a;
552
586
  //ensure programs are initialized
553
587
  await this.waitAllProjectFirstRuns();
554
588
  let srcPath = util_1.util.uriToPath(params.textDocument.uri);
@@ -562,7 +596,7 @@ class LanguageServer {
562
596
  //clone the diagnostics for each code action, since certain diagnostics can have circular reference properties that kill the language server if serialized
563
597
  for (const codeAction of codeActions) {
564
598
  if (codeAction.diagnostics) {
565
- codeAction.diagnostics = codeAction.diagnostics.map(x => util_1.util.toDiagnostic(x, params.textDocument.uri));
599
+ codeAction.diagnostics = (_a = codeAction.diagnostics) === null || _a === void 0 ? void 0 : _a.map(x => util_1.util.toDiagnostic(x, params.textDocument.uri));
566
600
  }
567
601
  }
568
602
  return codeActions;
@@ -592,7 +626,7 @@ class LanguageServer {
592
626
  if (project.isStandaloneFileProject === false) {
593
627
  this.removeProject(project);
594
628
  //create a new workspace/brs program
595
- await this.createProject(project.projectPath, project.workspacePath);
629
+ await this.createProject(project.projectPath, project.workspacePath, project.projectNumber);
596
630
  //handle temp workspace
597
631
  }
598
632
  else {
@@ -669,12 +703,10 @@ class LanguageServer {
669
703
  * The CLIENT is in charge of what files to watch, so all client
670
704
  * implementations should ensure that all valid project
671
705
  * file types are watched (.brs,.bs,.xml,manifest, and any json/text/image files)
672
- * @param params
673
706
  */
674
707
  async onDidChangeWatchedFiles(params) {
675
708
  //ensure programs are initialized
676
709
  await this.waitAllProjectFirstRuns();
677
- this.connection.sendNotification('build-status', 'building');
678
710
  let projects = this.getProjects();
679
711
  //convert all file paths to absolute paths
680
712
  let changes = params.changes.map(x => {
@@ -743,37 +775,33 @@ class LanguageServer {
743
775
  //give every workspace the chance to handle file changes
744
776
  await Promise.all(projects.map((project) => this.handleFileChanges(project, changes)));
745
777
  }
746
- this.connection.sendNotification('build-status', 'success');
747
778
  }
748
779
  /**
749
780
  * This only operates on files that match the specified files globs, so it is safe to throw
750
781
  * any file changes you receive with no unexpected side-effects
751
- * @param changes
752
782
  */
753
783
  async handleFileChanges(project, changes) {
754
784
  //this loop assumes paths are both file paths and folder paths, which eliminates the need to detect.
755
785
  //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
756
- let consumeCount = 0;
757
786
  await Promise.all(changes.map(async (change) => {
758
787
  await this.keyedThrottler.run(change.srcPath, async () => {
759
- consumeCount += await this.handleFileChange(project, change) ? 1 : 0;
788
+ if (await this.handleFileChange(project, change)) {
789
+ await this.validateAllThrottled();
790
+ }
760
791
  });
761
792
  }));
762
- if (consumeCount > 0) {
763
- await this.validateAllThrottled();
764
- }
765
793
  }
766
794
  /**
767
795
  * This only operates on files that match the specified files globs, so it is safe to throw
768
796
  * any file changes you receive with no unexpected side-effects
769
- * @param changes
797
+ * @returns true if the file was handled by this project, false if it was not
770
798
  */
771
799
  async handleFileChange(project, change) {
772
800
  const { program, options, rootDir } = project.builder;
773
801
  //deleted
774
802
  if (change.type === node_1.FileChangeType.Deleted) {
775
803
  //try to act on this path as a directory
776
- project.builder.program.removeFilesInFolder(change.srcPath);
804
+ project.builder.removeFilesInFolder(change.srcPath);
777
805
  //if this is a file loaded in the program, remove it
778
806
  if (program.hasFile(change.srcPath)) {
779
807
  program.removeFile(change.srcPath);
@@ -870,7 +898,6 @@ class LanguageServer {
870
898
  //throttle file processing. first call is run immediately, and then the last call is processed.
871
899
  await this.keyedThrottler.run(filePath, () => {
872
900
  var _a;
873
- this.connection.sendNotification('build-status', 'building');
874
901
  let documentText = document.getText();
875
902
  for (const project of this.getProjects()) {
876
903
  //only add or replace existing files. All of the files in the project should
@@ -889,7 +916,7 @@ class LanguageServer {
889
916
  await this.validateAllThrottled();
890
917
  }
891
918
  catch (e) {
892
- this.sendCriticalFailure(`Critical error parsing / validating ${filePath}: ${e.message}`);
919
+ this.sendCriticalFailure(`Critical error parsing/validating ${filePath}: ${e.message}`);
893
920
  }
894
921
  }
895
922
  async validateAll() {
@@ -899,13 +926,15 @@ class LanguageServer {
899
926
  await this.synchronizeStandaloneProjects();
900
927
  let projects = this.getProjects();
901
928
  //validate all programs
902
- await Promise.all(projects.map((x) => x.builder.program.validate()));
929
+ await Promise.all(projects.map((project) => {
930
+ project.builder.program.validate();
931
+ return project;
932
+ }));
903
933
  }
904
934
  catch (e) {
905
935
  this.connection.console.error(e);
906
936
  this.sendCriticalFailure(`Critical error validating project: ${e.message}${(_a = e.stack) !== null && _a !== void 0 ? _a : ''}`);
907
937
  }
908
- this.connection.sendNotification('build-status', 'success');
909
938
  }
910
939
  async onWorkspaceSymbol(params) {
911
940
  await this.waitAllProjectFirstRuns();
@@ -947,7 +976,7 @@ class LanguageServer {
947
976
  try {
948
977
  const signatures = util_1.util.flatMap(await Promise.all(this.getProjects().map(project => project.builder.program.getSignatureHelp(filepath, params.position))), c => c);
949
978
  const activeSignature = signatures.length > 0 ? 0 : null;
950
- const activeParameter = activeSignature >= 0 ? (_a = signatures[activeSignature]) === null || _a === void 0 ? void 0 : _a.index : null;
979
+ const activeParameter = activeSignature !== null ? (_a = signatures[activeSignature]) === null || _a === void 0 ? void 0 : _a.index : null;
951
980
  let results = {
952
981
  signatures: signatures.map((s) => s.signature),
953
982
  activeSignature: activeSignature,
@@ -970,20 +999,35 @@ class LanguageServer {
970
999
  const srcPath = util_1.util.uriToPath(params.textDocument.uri);
971
1000
  const results = util_1.util.flatMap(await Promise.all(this.getProjects().map(project => {
972
1001
  return project.builder.program.getReferences(srcPath, position);
973
- })), c => c);
1002
+ })), c => c !== null && c !== void 0 ? c : []);
974
1003
  return results.filter((r) => r);
975
1004
  }
1005
+ onValidateSettled() {
1006
+ return Promise.all([
1007
+ //wait for the validator to start running (or timeout if it never did)
1008
+ this.validateThrottler.onRunOnce(100),
1009
+ //wait for the validator to stop running (or resolve immediately if it's already idle)
1010
+ this.validateThrottler.onIdleOnce(true)
1011
+ ]);
1012
+ }
976
1013
  async onFullSemanticTokens(params) {
977
1014
  await this.waitAllProjectFirstRuns();
1015
+ //wait for the file to settle (in case there are multiple file changes in quick succession)
978
1016
  await this.keyedThrottler.onIdleOnce(util_1.util.uriToPath(params.textDocument.uri), true);
1017
+ // make sure validation is complete
1018
+ await this.validateAllThrottled();
1019
+ //wait for the validation cycle to settle
1020
+ await this.onValidateSettled();
979
1021
  const srcPath = util_1.util.uriToPath(params.textDocument.uri);
980
1022
  for (const project of this.projects) {
981
1023
  //find the first program that has this file, since it would be incredibly inefficient to generate semantic tokens for the same file multiple times.
982
1024
  if (project.builder.program.hasFile(srcPath)) {
983
1025
  let semanticTokens = project.builder.program.getSemanticTokens(srcPath);
984
- return {
985
- data: (0, SemanticTokenUtils_1.encodeSemanticTokens)(semanticTokens)
986
- };
1026
+ if (semanticTokens !== undefined) {
1027
+ return {
1028
+ data: (0, SemanticTokenUtils_1.encodeSemanticTokens)(semanticTokens)
1029
+ };
1030
+ }
987
1031
  }
988
1032
  }
989
1033
  }
@@ -1012,9 +1056,6 @@ class LanguageServer {
1012
1056
  return result;
1013
1057
  }
1014
1058
  }
1015
- /**
1016
- * @param srcPath The absolute path to the source file on disk
1017
- */
1018
1059
  async transpileFile(srcPath) {
1019
1060
  //wait all program first runs
1020
1061
  await this.waitAllProjectFirstRuns();
@@ -1035,22 +1076,35 @@ __decorate([
1035
1076
  AddStackToErrorMessage
1036
1077
  ], LanguageServer.prototype, "onInitialize", null);
1037
1078
  __decorate([
1038
- AddStackToErrorMessage
1079
+ TrackBusyStatus
1080
+ ], LanguageServer.prototype, "getProjectPaths", null);
1081
+ __decorate([
1082
+ TrackBusyStatus
1083
+ ], LanguageServer.prototype, "syncProjects", null);
1084
+ __decorate([
1085
+ AddStackToErrorMessage,
1086
+ TrackBusyStatus
1039
1087
  ], LanguageServer.prototype, "onInitialized", null);
1040
1088
  __decorate([
1041
- AddStackToErrorMessage
1089
+ TrackBusyStatus
1090
+ ], LanguageServer.prototype, "createProject", null);
1091
+ __decorate([
1092
+ AddStackToErrorMessage,
1093
+ TrackBusyStatus
1042
1094
  ], LanguageServer.prototype, "onCompletion", null);
1043
1095
  __decorate([
1044
1096
  AddStackToErrorMessage
1045
1097
  ], LanguageServer.prototype, "onCompletionResolve", null);
1046
1098
  __decorate([
1047
- AddStackToErrorMessage
1099
+ AddStackToErrorMessage,
1100
+ TrackBusyStatus
1048
1101
  ], LanguageServer.prototype, "onCodeAction", null);
1049
1102
  __decorate([
1050
1103
  AddStackToErrorMessage
1051
1104
  ], LanguageServer.prototype, "onDidChangeConfiguration", null);
1052
1105
  __decorate([
1053
- AddStackToErrorMessage
1106
+ AddStackToErrorMessage,
1107
+ TrackBusyStatus
1054
1108
  ], LanguageServer.prototype, "onDidChangeWatchedFiles", null);
1055
1109
  __decorate([
1056
1110
  AddStackToErrorMessage
@@ -1059,34 +1113,49 @@ __decorate([
1059
1113
  AddStackToErrorMessage
1060
1114
  ], LanguageServer.prototype, "onDocumentClose", null);
1061
1115
  __decorate([
1062
- AddStackToErrorMessage
1116
+ AddStackToErrorMessage,
1117
+ TrackBusyStatus
1063
1118
  ], LanguageServer.prototype, "validateTextDocument", null);
1064
1119
  __decorate([
1065
- AddStackToErrorMessage
1120
+ TrackBusyStatus
1121
+ ], LanguageServer.prototype, "validateAll", null);
1122
+ __decorate([
1123
+ AddStackToErrorMessage,
1124
+ TrackBusyStatus
1066
1125
  ], LanguageServer.prototype, "onWorkspaceSymbol", null);
1067
1126
  __decorate([
1068
- AddStackToErrorMessage
1127
+ AddStackToErrorMessage,
1128
+ TrackBusyStatus
1069
1129
  ], LanguageServer.prototype, "onDocumentSymbol", null);
1070
1130
  __decorate([
1071
- AddStackToErrorMessage
1131
+ AddStackToErrorMessage,
1132
+ TrackBusyStatus
1072
1133
  ], LanguageServer.prototype, "onDefinition", null);
1073
1134
  __decorate([
1074
- AddStackToErrorMessage
1135
+ AddStackToErrorMessage,
1136
+ TrackBusyStatus
1075
1137
  ], LanguageServer.prototype, "onSignatureHelp", null);
1076
1138
  __decorate([
1077
- AddStackToErrorMessage
1139
+ AddStackToErrorMessage,
1140
+ TrackBusyStatus
1078
1141
  ], LanguageServer.prototype, "onReferences", null);
1079
1142
  __decorate([
1080
- AddStackToErrorMessage
1143
+ AddStackToErrorMessage,
1144
+ TrackBusyStatus
1081
1145
  ], LanguageServer.prototype, "onFullSemanticTokens", null);
1082
1146
  __decorate([
1083
- AddStackToErrorMessage
1147
+ AddStackToErrorMessage,
1148
+ TrackBusyStatus
1084
1149
  ], LanguageServer.prototype, "onExecuteCommand", null);
1085
1150
  exports.LanguageServer = LanguageServer;
1086
1151
  var CustomCommands;
1087
1152
  (function (CustomCommands) {
1088
1153
  CustomCommands["TranspileFile"] = "TranspileFile";
1089
1154
  })(CustomCommands = exports.CustomCommands || (exports.CustomCommands = {}));
1155
+ var NotificationName;
1156
+ (function (NotificationName) {
1157
+ NotificationName["busyStatus"] = "busyStatus";
1158
+ })(NotificationName = exports.NotificationName || (exports.NotificationName = {}));
1090
1159
  /**
1091
1160
  * Wraps a method. If there's an error (either sync or via a promise),
1092
1161
  * this appends the error's stack trace at the end of the error message so that the connection will
@@ -1118,4 +1187,16 @@ function AddStackToErrorMessage(target, propertyKey, descriptor) {
1118
1187
  }
1119
1188
  };
1120
1189
  }
1190
+ /**
1191
+ * An annotation used to wrap the method in a busyStatus tracking call
1192
+ */
1193
+ function TrackBusyStatus(target, propertyKey, descriptor) {
1194
+ let originalMethod = descriptor.value;
1195
+ //wrapping the original method
1196
+ descriptor.value = function value(...args) {
1197
+ return this.busyStatusTracker.run(() => {
1198
+ return originalMethod.apply(this, args);
1199
+ }, originalMethod.name);
1200
+ };
1201
+ }
1121
1202
  //# sourceMappingURL=LanguageServer.js.map