brighterscript 1.0.0-alpha.23 → 1.0.0-alpha.25

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 +585 -218
  2. package/README.md +45 -139
  3. package/bsconfig.schema.json +41 -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 +39 -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 +79 -15
  33. package/dist/DiagnosticMessages.js +134 -21
  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 +222 -87
  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 +162 -81
  54. package/dist/Program.js +903 -732
  55. package/dist/Program.js.map +1 -1
  56. package/dist/ProgramBuilder.d.ts +22 -12
  57. package/dist/ProgramBuilder.js +132 -104
  58. package/dist/ProgramBuilder.js.map +1 -1
  59. package/dist/Scope.d.ts +95 -134
  60. package/dist/Scope.js +477 -551
  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 +95 -29
  65. package/dist/SymbolTable.js +256 -102
  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 -6
  74. package/dist/XmlScope.js +74 -68
  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} +68 -64
  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 +26 -16
  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 -100
  90. package/dist/astUtils/reflection.js +225 -166
  91. package/dist/astUtils/reflection.js.map +1 -1
  92. package/dist/astUtils/reflection.spec.js +208 -126
  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 +54 -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 +178 -33
  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 +12 -2
  105. package/dist/bscPlugin/BscPlugin.js +41 -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 +135 -0
  115. package/dist/bscPlugin/SignatureHelpUtil.js.map +1 -0
  116. package/dist/bscPlugin/codeActions/CodeActionsProcessor.d.ts +1 -1
  117. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +21 -12
  118. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  119. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +86 -12
  120. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
  121. package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +57 -0
  122. package/dist/bscPlugin/completions/CompletionsProcessor.js +544 -0
  123. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -0
  124. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +1909 -0
  125. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -0
  126. package/dist/bscPlugin/fileProviders/FileProvider.d.ts +9 -0
  127. package/dist/bscPlugin/fileProviders/FileProvider.js +51 -0
  128. package/dist/bscPlugin/fileProviders/FileProvider.js.map +1 -0
  129. package/dist/bscPlugin/hover/HoverProcessor.d.ts +17 -0
  130. package/dist/bscPlugin/hover/HoverProcessor.js +188 -0
  131. package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -0
  132. package/dist/bscPlugin/hover/HoverProcessor.spec.js +513 -0
  133. package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -0
  134. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +3 -1
  135. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +102 -29
  136. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
  137. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +167 -6
  138. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -1
  139. package/dist/bscPlugin/serialize/BslibInjector.spec.d.ts +1 -0
  140. package/dist/bscPlugin/serialize/BslibInjector.spec.js +19 -0
  141. package/dist/bscPlugin/serialize/BslibInjector.spec.js.map +1 -0
  142. package/dist/bscPlugin/serialize/BslibManager.d.ts +9 -0
  143. package/dist/bscPlugin/serialize/BslibManager.js +40 -0
  144. package/dist/bscPlugin/serialize/BslibManager.js.map +1 -0
  145. package/dist/bscPlugin/serialize/FileSerializer.d.ts +9 -0
  146. package/dist/bscPlugin/serialize/FileSerializer.js +72 -0
  147. package/dist/bscPlugin/serialize/FileSerializer.js.map +1 -0
  148. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.d.ts +16 -0
  149. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js +123 -0
  150. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -0
  151. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.d.ts +1 -0
  152. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js +41 -0
  153. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +1 -0
  154. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +12 -0
  155. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js +99 -0
  156. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +1 -0
  157. package/dist/bscPlugin/validation/BrsFileValidator.d.ts +22 -1
  158. package/dist/bscPlugin/validation/BrsFileValidator.js +316 -29
  159. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
  160. package/dist/bscPlugin/validation/BrsFileValidator.spec.d.ts +1 -0
  161. package/dist/bscPlugin/validation/BrsFileValidator.spec.js +264 -0
  162. package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -0
  163. package/dist/bscPlugin/validation/ProgramValidator.d.ts +10 -0
  164. package/dist/bscPlugin/validation/ProgramValidator.js +32 -0
  165. package/dist/bscPlugin/validation/ProgramValidator.js.map +1 -0
  166. package/dist/bscPlugin/validation/ScopeValidator.d.ts +56 -8
  167. package/dist/bscPlugin/validation/ScopeValidator.js +514 -116
  168. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
  169. package/dist/bscPlugin/validation/ScopeValidator.spec.d.ts +1 -0
  170. package/dist/bscPlugin/validation/ScopeValidator.spec.js +2454 -0
  171. package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -0
  172. package/dist/bscPlugin/validation/XmlFileValidator.d.ts +8 -0
  173. package/dist/bscPlugin/validation/XmlFileValidator.js +44 -0
  174. package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -0
  175. package/dist/cli.js +107 -8
  176. package/dist/cli.js.map +1 -1
  177. package/dist/deferred.d.ts +3 -3
  178. package/dist/deferred.js.map +1 -1
  179. package/dist/diagnosticUtils.d.ts +8 -2
  180. package/dist/diagnosticUtils.js +47 -17
  181. package/dist/diagnosticUtils.js.map +1 -1
  182. package/dist/examples/plugins/removePrint.js +8 -10
  183. package/dist/examples/plugins/removePrint.js.map +1 -1
  184. package/dist/files/AssetFile.d.ts +26 -0
  185. package/dist/files/AssetFile.js +26 -0
  186. package/dist/files/AssetFile.js.map +1 -0
  187. package/dist/files/BrsFile.Class.spec.js +529 -486
  188. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  189. package/dist/files/BrsFile.d.ts +124 -112
  190. package/dist/files/BrsFile.js +819 -1131
  191. package/dist/files/BrsFile.js.map +1 -1
  192. package/dist/files/BrsFile.spec.js +1869 -1277
  193. package/dist/files/BrsFile.spec.js.map +1 -1
  194. package/dist/files/BscFile.d.ts +104 -0
  195. package/dist/files/BscFile.js +16 -0
  196. package/dist/files/BscFile.js.map +1 -0
  197. package/dist/files/Factory.d.ts +25 -0
  198. package/dist/files/Factory.js +22 -0
  199. package/dist/files/Factory.js.map +1 -0
  200. package/dist/files/LazyFileData.d.ts +20 -0
  201. package/dist/files/LazyFileData.js +54 -0
  202. package/dist/files/LazyFileData.js.map +1 -0
  203. package/dist/files/LazyFileData.spec.d.ts +1 -0
  204. package/dist/files/LazyFileData.spec.js +27 -0
  205. package/dist/files/LazyFileData.spec.js.map +1 -0
  206. package/dist/files/XmlFile.d.ts +70 -32
  207. package/dist/files/XmlFile.js +106 -117
  208. package/dist/files/XmlFile.js.map +1 -1
  209. package/dist/files/XmlFile.spec.js +325 -262
  210. package/dist/files/XmlFile.spec.js.map +1 -1
  211. package/dist/files/tests/imports.spec.js +49 -41
  212. package/dist/files/tests/imports.spec.js.map +1 -1
  213. package/dist/files/tests/optionalChaning.spec.js +104 -40
  214. package/dist/files/tests/optionalChaning.spec.js.map +1 -1
  215. package/dist/globalCallables.js +16 -18
  216. package/dist/globalCallables.js.map +1 -1
  217. package/dist/index.d.ts +13 -2
  218. package/dist/index.js +15 -2
  219. package/dist/index.js.map +1 -1
  220. package/dist/interfaces.d.ts +440 -150
  221. package/dist/interfaces.js +27 -0
  222. package/dist/interfaces.js.map +1 -1
  223. package/dist/lexer/Character.spec.js +5 -5
  224. package/dist/lexer/Character.spec.js.map +1 -1
  225. package/dist/lexer/Lexer.d.ts +12 -5
  226. package/dist/lexer/Lexer.js +28 -13
  227. package/dist/lexer/Lexer.js.map +1 -1
  228. package/dist/lexer/Lexer.spec.js +187 -134
  229. package/dist/lexer/Lexer.spec.js.map +1 -1
  230. package/dist/lexer/Token.d.ts +9 -1
  231. package/dist/lexer/Token.js +9 -1
  232. package/dist/lexer/Token.js.map +1 -1
  233. package/dist/lexer/TokenKind.d.ts +9 -0
  234. package/dist/lexer/TokenKind.js +30 -5
  235. package/dist/lexer/TokenKind.js.map +1 -1
  236. package/dist/parser/AstNode.d.ts +162 -0
  237. package/dist/parser/AstNode.js +225 -0
  238. package/dist/parser/AstNode.js.map +1 -0
  239. package/dist/parser/AstNode.spec.d.ts +1 -0
  240. package/dist/parser/AstNode.spec.js +165 -0
  241. package/dist/parser/AstNode.spec.js.map +1 -0
  242. package/dist/parser/BrsTranspileState.d.ts +4 -7
  243. package/dist/parser/BrsTranspileState.js +4 -12
  244. package/dist/parser/BrsTranspileState.js.map +1 -1
  245. package/dist/parser/Expression.d.ts +126 -167
  246. package/dist/parser/Expression.js +524 -394
  247. package/dist/parser/Expression.js.map +1 -1
  248. package/dist/parser/Parser.Class.spec.js +152 -146
  249. package/dist/parser/Parser.Class.spec.js.map +1 -1
  250. package/dist/parser/Parser.d.ts +45 -196
  251. package/dist/parser/Parser.js +470 -926
  252. package/dist/parser/Parser.js.map +1 -1
  253. package/dist/parser/Parser.spec.d.ts +3 -1
  254. package/dist/parser/Parser.spec.js +1034 -805
  255. package/dist/parser/Parser.spec.js.map +1 -1
  256. package/dist/parser/SGParser.d.ts +9 -8
  257. package/dist/parser/SGParser.js +10 -8
  258. package/dist/parser/SGParser.js.map +1 -1
  259. package/dist/parser/SGParser.spec.js +27 -38
  260. package/dist/parser/SGParser.spec.js.map +1 -1
  261. package/dist/parser/SGTypes.d.ts +98 -35
  262. package/dist/parser/SGTypes.js +169 -99
  263. package/dist/parser/SGTypes.js.map +1 -1
  264. package/dist/parser/Statement.d.ts +208 -122
  265. package/dist/parser/Statement.js +599 -364
  266. package/dist/parser/Statement.js.map +1 -1
  267. package/dist/parser/Statement.spec.js +45 -21
  268. package/dist/parser/Statement.spec.js.map +1 -1
  269. package/dist/parser/TranspileState.d.ts +1 -1
  270. package/dist/parser/TranspileState.js +7 -12
  271. package/dist/parser/TranspileState.js.map +1 -1
  272. package/dist/parser/tests/Parser.spec.js +3 -2
  273. package/dist/parser/tests/Parser.spec.js.map +1 -1
  274. package/dist/parser/tests/controlFlow/For.spec.js +33 -23
  275. package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
  276. package/dist/parser/tests/controlFlow/ForEach.spec.js +25 -20
  277. package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
  278. package/dist/parser/tests/controlFlow/If.spec.js +96 -94
  279. package/dist/parser/tests/controlFlow/If.spec.js.map +1 -1
  280. package/dist/parser/tests/controlFlow/While.spec.js +22 -16
  281. package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
  282. package/dist/parser/tests/expression/Additive.spec.js +8 -8
  283. package/dist/parser/tests/expression/Additive.spec.js.map +1 -1
  284. package/dist/parser/tests/expression/ArrayLiterals.spec.js +58 -21
  285. package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +1 -1
  286. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +61 -20
  287. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
  288. package/dist/parser/tests/expression/Boolean.spec.js +8 -8
  289. package/dist/parser/tests/expression/Boolean.spec.js.map +1 -1
  290. package/dist/parser/tests/expression/Call.spec.js +129 -21
  291. package/dist/parser/tests/expression/Call.spec.js.map +1 -1
  292. package/dist/parser/tests/expression/Exponential.spec.js +5 -5
  293. package/dist/parser/tests/expression/Exponential.spec.js.map +1 -1
  294. package/dist/parser/tests/expression/Function.spec.js +36 -36
  295. package/dist/parser/tests/expression/Function.spec.js.map +1 -1
  296. package/dist/parser/tests/expression/Indexing.spec.js +67 -22
  297. package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
  298. package/dist/parser/tests/expression/Multiplicative.spec.js +9 -9
  299. package/dist/parser/tests/expression/Multiplicative.spec.js.map +1 -1
  300. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +123 -81
  301. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
  302. package/dist/parser/tests/expression/PrefixUnary.spec.js +12 -12
  303. package/dist/parser/tests/expression/PrefixUnary.spec.js.map +1 -1
  304. package/dist/parser/tests/expression/Primary.spec.js +12 -12
  305. package/dist/parser/tests/expression/Primary.spec.js.map +1 -1
  306. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +10 -10
  307. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -1
  308. package/dist/parser/tests/expression/Relational.spec.js +13 -13
  309. package/dist/parser/tests/expression/Relational.spec.js.map +1 -1
  310. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +24 -24
  311. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +1 -1
  312. package/dist/parser/tests/expression/TemplateStringExpression.spec.js +221 -81
  313. package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
  314. package/dist/parser/tests/expression/TernaryExpression.spec.js +287 -105
  315. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
  316. package/dist/parser/tests/expression/TypeExpression.spec.d.ts +1 -0
  317. package/dist/parser/tests/expression/TypeExpression.spec.js +127 -0
  318. package/dist/parser/tests/expression/TypeExpression.spec.js.map +1 -0
  319. package/dist/parser/tests/expression/UnaryExpression.spec.d.ts +1 -0
  320. package/dist/parser/tests/expression/UnaryExpression.spec.js +52 -0
  321. package/dist/parser/tests/expression/UnaryExpression.spec.js.map +1 -0
  322. package/dist/parser/tests/statement/AssignmentOperators.spec.js +15 -15
  323. package/dist/parser/tests/statement/AssignmentOperators.spec.js.map +1 -1
  324. package/dist/parser/tests/statement/ConstStatement.spec.d.ts +1 -0
  325. package/dist/parser/tests/statement/ConstStatement.spec.js +262 -0
  326. package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -0
  327. package/dist/parser/tests/statement/Continue.spec.d.ts +1 -0
  328. package/dist/parser/tests/statement/Continue.spec.js +119 -0
  329. package/dist/parser/tests/statement/Continue.spec.js.map +1 -0
  330. package/dist/parser/tests/statement/Declaration.spec.js +19 -19
  331. package/dist/parser/tests/statement/Declaration.spec.js.map +1 -1
  332. package/dist/parser/tests/statement/Dim.spec.js +22 -22
  333. package/dist/parser/tests/statement/Dim.spec.js.map +1 -1
  334. package/dist/parser/tests/statement/Enum.spec.js +111 -300
  335. package/dist/parser/tests/statement/Enum.spec.js.map +1 -1
  336. package/dist/parser/tests/statement/For.spec.js +9 -10
  337. package/dist/parser/tests/statement/For.spec.js.map +1 -1
  338. package/dist/parser/tests/statement/ForEach.spec.js +8 -9
  339. package/dist/parser/tests/statement/ForEach.spec.js.map +1 -1
  340. package/dist/parser/tests/statement/Function.spec.js +44 -35
  341. package/dist/parser/tests/statement/Function.spec.js.map +1 -1
  342. package/dist/parser/tests/statement/Goto.spec.js +5 -5
  343. package/dist/parser/tests/statement/Goto.spec.js.map +1 -1
  344. package/dist/parser/tests/statement/Increment.spec.js +20 -20
  345. package/dist/parser/tests/statement/Increment.spec.js.map +1 -1
  346. package/dist/parser/tests/statement/InterfaceStatement.spec.js +30 -196
  347. package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
  348. package/dist/parser/tests/statement/LibraryStatement.spec.js +11 -11
  349. package/dist/parser/tests/statement/LibraryStatement.spec.js.map +1 -1
  350. package/dist/parser/tests/statement/Misc.spec.js +16 -78
  351. package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
  352. package/dist/parser/tests/statement/PrintStatement.spec.js +107 -90
  353. package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
  354. package/dist/parser/tests/statement/ReturnStatement.spec.js +14 -12
  355. package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
  356. package/dist/parser/tests/statement/Set.spec.js +48 -35
  357. package/dist/parser/tests/statement/Set.spec.js.map +1 -1
  358. package/dist/parser/tests/statement/Stop.spec.js +6 -6
  359. package/dist/parser/tests/statement/Stop.spec.js.map +1 -1
  360. package/dist/parser/tests/statement/Throw.spec.js +6 -6
  361. package/dist/parser/tests/statement/Throw.spec.js.map +1 -1
  362. package/dist/parser/tests/statement/TryCatch.spec.js +18 -16
  363. package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
  364. package/dist/preprocessor/Manifest.d.ts +1 -1
  365. package/dist/preprocessor/Manifest.js +3 -3
  366. package/dist/preprocessor/Manifest.js.map +1 -1
  367. package/dist/preprocessor/Manifest.spec.js +8 -8
  368. package/dist/preprocessor/Manifest.spec.js.map +1 -1
  369. package/dist/preprocessor/Preprocessor.d.ts +5 -6
  370. package/dist/preprocessor/Preprocessor.js +15 -11
  371. package/dist/preprocessor/Preprocessor.js.map +1 -1
  372. package/dist/preprocessor/Preprocessor.spec.js +25 -25
  373. package/dist/preprocessor/Preprocessor.spec.js.map +1 -1
  374. package/dist/preprocessor/PreprocessorParser.d.ts +1 -1
  375. package/dist/preprocessor/PreprocessorParser.js +7 -1
  376. package/dist/preprocessor/PreprocessorParser.js.map +1 -1
  377. package/dist/preprocessor/PreprocessorParser.spec.js +13 -13
  378. package/dist/preprocessor/PreprocessorParser.spec.js.map +1 -1
  379. package/dist/roku-types/data.json +6544 -10519
  380. package/dist/roku-types/index.d.ts +662 -1934
  381. package/dist/types/ArrayType.d.ts +10 -9
  382. package/dist/types/ArrayType.js +65 -60
  383. package/dist/types/ArrayType.js.map +1 -1
  384. package/dist/types/ArrayType.spec.js +36 -68
  385. package/dist/types/ArrayType.spec.js.map +1 -1
  386. package/dist/types/AssociativeArrayType.d.ts +11 -0
  387. package/dist/types/AssociativeArrayType.js +52 -0
  388. package/dist/types/AssociativeArrayType.js.map +1 -0
  389. package/dist/types/BaseFunctionType.d.ts +9 -0
  390. package/dist/types/BaseFunctionType.js +25 -0
  391. package/dist/types/BaseFunctionType.js.map +1 -0
  392. package/dist/types/BooleanType.d.ts +8 -5
  393. package/dist/types/BooleanType.js +14 -7
  394. package/dist/types/BooleanType.js.map +1 -1
  395. package/dist/types/BooleanType.spec.js +10 -6
  396. package/dist/types/BooleanType.spec.js.map +1 -1
  397. package/dist/types/BscType.d.ts +32 -21
  398. package/dist/types/BscType.js +118 -21
  399. package/dist/types/BscType.js.map +1 -1
  400. package/dist/types/BscTypeKind.d.ts +25 -0
  401. package/dist/types/BscTypeKind.js +30 -0
  402. package/dist/types/BscTypeKind.js.map +1 -0
  403. package/dist/types/BuiltInInterfaceAdder.d.ts +23 -0
  404. package/dist/types/BuiltInInterfaceAdder.js +164 -0
  405. package/dist/types/BuiltInInterfaceAdder.js.map +1 -0
  406. package/dist/types/BuiltInInterfaceAdder.spec.d.ts +1 -0
  407. package/dist/types/BuiltInInterfaceAdder.spec.js +116 -0
  408. package/dist/types/BuiltInInterfaceAdder.spec.js.map +1 -0
  409. package/dist/types/ClassType.d.ts +17 -0
  410. package/dist/types/ClassType.js +58 -0
  411. package/dist/types/ClassType.js.map +1 -0
  412. package/dist/types/ClassType.spec.d.ts +1 -0
  413. package/dist/types/ClassType.spec.js +77 -0
  414. package/dist/types/ClassType.spec.js.map +1 -0
  415. package/dist/types/ComponentType.d.ts +26 -0
  416. package/dist/types/ComponentType.js +83 -0
  417. package/dist/types/ComponentType.js.map +1 -0
  418. package/dist/types/DoubleType.d.ts +8 -5
  419. package/dist/types/DoubleType.js +18 -16
  420. package/dist/types/DoubleType.js.map +1 -1
  421. package/dist/types/DoubleType.spec.js +12 -6
  422. package/dist/types/DoubleType.spec.js.map +1 -1
  423. package/dist/types/DynamicType.d.ts +10 -5
  424. package/dist/types/DynamicType.js +16 -4
  425. package/dist/types/DynamicType.js.map +1 -1
  426. package/dist/types/DynamicType.spec.js +16 -5
  427. package/dist/types/DynamicType.spec.js.map +1 -1
  428. package/dist/types/EnumType.d.ts +30 -12
  429. package/dist/types/EnumType.js +43 -17
  430. package/dist/types/EnumType.js.map +1 -1
  431. package/dist/types/EnumType.spec.d.ts +1 -0
  432. package/dist/types/EnumType.spec.js +33 -0
  433. package/dist/types/EnumType.spec.js.map +1 -0
  434. package/dist/types/FloatType.d.ts +8 -5
  435. package/dist/types/FloatType.js +18 -16
  436. package/dist/types/FloatType.js.map +1 -1
  437. package/dist/types/FloatType.spec.js +4 -6
  438. package/dist/types/FloatType.spec.js.map +1 -1
  439. package/dist/types/FunctionType.d.ts +13 -8
  440. package/dist/types/FunctionType.js +30 -14
  441. package/dist/types/FunctionType.js.map +1 -1
  442. package/dist/types/InheritableType.d.ts +28 -0
  443. package/dist/types/InheritableType.js +152 -0
  444. package/dist/types/InheritableType.js.map +1 -0
  445. package/dist/types/IntegerType.d.ts +8 -5
  446. package/dist/types/IntegerType.js +18 -16
  447. package/dist/types/IntegerType.js.map +1 -1
  448. package/dist/types/IntegerType.spec.js +8 -6
  449. package/dist/types/IntegerType.spec.js.map +1 -1
  450. package/dist/types/InterfaceType.d.ts +12 -13
  451. package/dist/types/InterfaceType.js +20 -48
  452. package/dist/types/InterfaceType.js.map +1 -1
  453. package/dist/types/InterfaceType.spec.js +90 -56
  454. package/dist/types/InterfaceType.spec.js.map +1 -1
  455. package/dist/types/InvalidType.d.ts +7 -5
  456. package/dist/types/InvalidType.js +13 -7
  457. package/dist/types/InvalidType.js.map +1 -1
  458. package/dist/types/InvalidType.spec.js +8 -6
  459. package/dist/types/InvalidType.spec.js.map +1 -1
  460. package/dist/types/LongIntegerType.d.ts +8 -5
  461. package/dist/types/LongIntegerType.js +17 -15
  462. package/dist/types/LongIntegerType.js.map +1 -1
  463. package/dist/types/LongIntegerType.spec.js +10 -6
  464. package/dist/types/LongIntegerType.spec.js.map +1 -1
  465. package/dist/types/NamespaceType.d.ts +12 -0
  466. package/dist/types/NamespaceType.js +28 -0
  467. package/dist/types/NamespaceType.js.map +1 -0
  468. package/dist/types/ObjectType.d.ts +9 -8
  469. package/dist/types/ObjectType.js +21 -11
  470. package/dist/types/ObjectType.js.map +1 -1
  471. package/dist/types/ObjectType.spec.js +3 -3
  472. package/dist/types/ObjectType.spec.js.map +1 -1
  473. package/dist/types/ReferenceType.d.ts +63 -0
  474. package/dist/types/ReferenceType.js +423 -0
  475. package/dist/types/ReferenceType.js.map +1 -0
  476. package/dist/types/ReferenceType.spec.d.ts +1 -0
  477. package/dist/types/ReferenceType.spec.js +137 -0
  478. package/dist/types/ReferenceType.spec.js.map +1 -0
  479. package/dist/types/StringType.d.ts +11 -5
  480. package/dist/types/StringType.js +18 -7
  481. package/dist/types/StringType.js.map +1 -1
  482. package/dist/types/StringType.spec.js +3 -5
  483. package/dist/types/StringType.spec.js.map +1 -1
  484. package/dist/types/TypedFunctionType.d.ts +22 -17
  485. package/dist/types/TypedFunctionType.js +78 -60
  486. package/dist/types/TypedFunctionType.js.map +1 -1
  487. package/dist/types/TypedFunctionType.spec.js +105 -20
  488. package/dist/types/TypedFunctionType.spec.js.map +1 -1
  489. package/dist/types/UninitializedType.d.ts +8 -6
  490. package/dist/types/UninitializedType.js +13 -7
  491. package/dist/types/UninitializedType.js.map +1 -1
  492. package/dist/types/UnionType.d.ts +20 -0
  493. package/dist/types/UnionType.js +123 -0
  494. package/dist/types/UnionType.js.map +1 -0
  495. package/dist/types/UnionType.spec.d.ts +1 -0
  496. package/dist/types/UnionType.spec.js +130 -0
  497. package/dist/types/UnionType.spec.js.map +1 -0
  498. package/dist/types/VoidType.d.ts +8 -5
  499. package/dist/types/VoidType.js +14 -7
  500. package/dist/types/VoidType.js.map +1 -1
  501. package/dist/types/VoidType.spec.js +3 -3
  502. package/dist/types/VoidType.spec.js.map +1 -1
  503. package/dist/types/helper.spec.d.ts +1 -0
  504. package/dist/types/helper.spec.js +145 -0
  505. package/dist/types/helper.spec.js.map +1 -0
  506. package/dist/types/helpers.d.ts +19 -37
  507. package/dist/types/helpers.js +159 -99
  508. package/dist/types/helpers.js.map +1 -1
  509. package/dist/types/index.d.ts +22 -0
  510. package/dist/types/index.js +39 -0
  511. package/dist/types/index.js.map +1 -0
  512. package/dist/util.d.ts +167 -131
  513. package/dist/util.js +890 -350
  514. package/dist/util.js.map +1 -1
  515. package/dist/validators/ClassValidator.d.ts +7 -25
  516. package/dist/validators/ClassValidator.js +103 -194
  517. package/dist/validators/ClassValidator.js.map +1 -1
  518. package/package.json +165 -149
  519. package/dist/astUtils/AstEditor.js.map +0 -1
  520. package/dist/astUtils/AstEditor.spec.js.map +0 -1
  521. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.d.ts +0 -8
  522. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js +0 -40
  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/hover/HoverProcessor.spec.d.ts} +0 -0
@@ -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;
@@ -169,11 +188,17 @@ class LanguageServer {
169
188
  */
170
189
  async getWorkspaceExcludeGlobs(workspaceFolder) {
171
190
  var _a;
172
- //get any `files.exclude` globs to use to filter
173
- let config = await this.connection.workspace.getConfiguration({
174
- scopeUri: workspaceFolder,
175
- section: 'files'
176
- });
191
+ let config = {
192
+ exclude: {}
193
+ };
194
+ //if supported, ask vscode for the `files.exclude` configuration
195
+ if (this.hasConfigurationCapability) {
196
+ //get any `files.exclude` globs to use to filter
197
+ config = await this.connection.workspace.getConfiguration({
198
+ scopeUri: workspaceFolder,
199
+ section: 'files'
200
+ });
201
+ }
177
202
  return Object
178
203
  .keys((_a = config === null || config === void 0 ? void 0 : config.exclude) !== null && _a !== void 0 ? _a : {})
179
204
  .filter(x => { var _a; return (_a = config === null || config === void 0 ? void 0 : config.exclude) === null || _a === void 0 ? void 0 : _a[x]; })
@@ -206,10 +231,30 @@ class LanguageServer {
206
231
  if (files.length > 0) {
207
232
  return files.map(file => (0, util_1.standardizePath) `${path.dirname(file.src)}`);
208
233
  }
209
- else {
210
- //treat the workspace folder as a brightscript project itself
211
- return [workspaceFolder];
234
+ //look for roku project folders
235
+ const rokuLikeDirs = (await Promise.all(
236
+ //find all folders containing a `manifest` file
237
+ (await roku_deploy_1.rokuDeploy.getFilePaths([
238
+ '**/manifest',
239
+ ...excludes
240
+ //is there at least one .bs|.brs file under the `/source` folder?
241
+ ], workspaceFolder)).map(async (manifestEntry) => {
242
+ const manifestDir = path.dirname(manifestEntry.src);
243
+ const files = await roku_deploy_1.rokuDeploy.getFilePaths([
244
+ 'source/**/*.{brs,bs}',
245
+ ...excludes
246
+ ], manifestDir);
247
+ if (files.length > 0) {
248
+ return manifestDir;
249
+ }
250
+ })
251
+ //throw out nulls
252
+ )).filter(x => !!x);
253
+ if (rokuLikeDirs.length > 0) {
254
+ return rokuLikeDirs;
212
255
  }
256
+ //treat the workspace folder as a brightscript project itself
257
+ return [workspaceFolder];
213
258
  }
214
259
  /**
215
260
  * Find all folders with bsconfig.json files in them, and treat each as a project.
@@ -258,7 +303,6 @@ class LanguageServer {
258
303
  }
259
304
  /**
260
305
  * Called when the client has finished initializing
261
- * @param params
262
306
  */
263
307
  async onInitialized() {
264
308
  let projectCreatedDeferred = new deferred_1.Deferred();
@@ -298,7 +342,6 @@ class LanguageServer {
298
342
  if (waitForFirstProject) {
299
343
  await this.initialProjectsCreated;
300
344
  }
301
- let status;
302
345
  for (let project of this.getProjects()) {
303
346
  try {
304
347
  await project.firstRunPromise;
@@ -311,7 +354,6 @@ class LanguageServer {
311
354
  this.sendCriticalFailure(`BrighterScript language server failed to start: \n${e.message}`);
312
355
  }
313
356
  }
314
- this.connection.sendNotification('build-status', status ? status : 'success');
315
357
  }
316
358
  /**
317
359
  * Event handler for when the program wants to load file contents.
@@ -332,11 +374,16 @@ class LanguageServer {
332
374
  else {
333
375
  scopeUri = vscode_uri_1.URI.file(workspacePath).toString();
334
376
  }
335
- //look for config group called "brightscript"
336
- let config = await this.connection.workspace.getConfiguration({
337
- scopeUri: scopeUri,
338
- section: 'brightscript'
339
- });
377
+ let config = {
378
+ configFile: undefined
379
+ };
380
+ //if the client supports configuration, look for config group called "brightscript"
381
+ if (this.hasConfigurationCapability) {
382
+ config = await this.connection.workspace.getConfiguration({
383
+ scopeUri: scopeUri,
384
+ section: 'brightscript'
385
+ });
386
+ }
340
387
  let configFilePath;
341
388
  //if there's a setting, we need to find the file or show error if it can't be found
342
389
  if (config === null || config === void 0 ? void 0 : config.configFile) {
@@ -361,7 +408,12 @@ class LanguageServer {
361
408
  //no config file could be found
362
409
  return undefined;
363
410
  }
364
- 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) {
365
417
  workspacePath !== null && workspacePath !== void 0 ? workspacePath : (workspacePath = projectPath);
366
418
  let project = this.projects.find((x) => x.projectPath === projectPath);
367
419
  //skip this project if we already have it
@@ -369,6 +421,9 @@ class LanguageServer {
369
421
  return;
370
422
  }
371
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}"`);
372
427
  //flush diagnostics every time the program finishes validating
373
428
  builder.plugins.add({
374
429
  name: 'bsc-language-server',
@@ -390,21 +445,11 @@ class LanguageServer {
390
445
  //config file doesn't exist...let `brighterscript` resolve the default way
391
446
  configFilePath = undefined;
392
447
  }
393
- let firstRunPromise = builder.run({
394
- cwd: cwd,
395
- project: configFilePath,
396
- watch: false,
397
- createPackage: false,
398
- deploy: false,
399
- copyToStaging: false,
400
- showDiagnosticsInConsole: false
401
- });
402
- firstRunPromise.catch((err) => {
403
- console.error(err);
404
- });
448
+ const firstRunDeferred = new deferred_1.Deferred();
405
449
  let newProject = {
450
+ projectNumber: projectNumber,
406
451
  builder: builder,
407
- firstRunPromise: firstRunPromise,
452
+ firstRunPromise: firstRunDeferred.promise,
408
453
  projectPath: projectPath,
409
454
  workspacePath: workspacePath,
410
455
  isFirstRunComplete: false,
@@ -413,19 +458,31 @@ class LanguageServer {
413
458
  isStandaloneFileProject: false
414
459
  };
415
460
  this.projects.push(newProject);
416
- 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
+ });
417
471
  newProject.isFirstRunComplete = true;
418
472
  newProject.isFirstRunSuccessful = true;
419
- }).catch(() => {
473
+ firstRunDeferred.resolve();
474
+ }
475
+ catch (e) {
476
+ builder.logger.error(e);
477
+ firstRunDeferred.reject(e);
420
478
  newProject.isFirstRunComplete = true;
421
479
  newProject.isFirstRunSuccessful = false;
422
- }).then(() => {
423
- //if we found a deprecated brsconfig.json, add a diagnostic warning the user
424
- if (configFilePath && path.basename(configFilePath) === 'brsconfig.json') {
425
- builder.addDiagnostic(configFilePath, Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.brsConfigJsonIsDeprecated()), { range: util_1.util.createRange(0, 0, 0, 0) }));
426
- return this.sendDiagnostics();
427
- }
428
- });
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
+ }
429
486
  }
430
487
  async createStandaloneFileProject(srcPath) {
431
488
  //skip this workspace if we already have it
@@ -458,6 +515,7 @@ class LanguageServer {
458
515
  console.error(err);
459
516
  });
460
517
  let newProject = {
518
+ projectNumber: this.projectCounter++,
461
519
  builder: builder,
462
520
  firstRunPromise: firstRunPromise,
463
521
  projectPath: srcPath,
@@ -486,7 +544,6 @@ class LanguageServer {
486
544
  }
487
545
  /**
488
546
  * Provide a list of completion items based on the current cursor position
489
- * @param textDocumentPosition
490
547
  */
491
548
  async onCompletion(params) {
492
549
  //ensure programs are initialized
@@ -494,17 +551,24 @@ class LanguageServer {
494
551
  let filePath = util_1.util.uriToPath(params.textDocument.uri);
495
552
  //wait until the file has settled
496
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();
497
558
  let completions = this
498
559
  .getProjects()
499
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();
500
563
  for (let completion of completions) {
501
564
  completion.commitCharacters = ['.'];
565
+ let key = `${completion.sortText}-${completion.label}-${completion.kind}`;
566
+ completionsMap.set(key, completion);
502
567
  }
503
- return completions;
568
+ return [...completionsMap.values()];
504
569
  }
505
570
  /**
506
571
  * Provide a full completion item from the selection
507
- * @param item
508
572
  */
509
573
  onCompletionResolve(item) {
510
574
  if (item.data === 1) {
@@ -518,6 +582,7 @@ class LanguageServer {
518
582
  return item;
519
583
  }
520
584
  async onCodeAction(params) {
585
+ var _a;
521
586
  //ensure programs are initialized
522
587
  await this.waitAllProjectFirstRuns();
523
588
  let srcPath = util_1.util.uriToPath(params.textDocument.uri);
@@ -531,7 +596,7 @@ class LanguageServer {
531
596
  //clone the diagnostics for each code action, since certain diagnostics can have circular reference properties that kill the language server if serialized
532
597
  for (const codeAction of codeActions) {
533
598
  if (codeAction.diagnostics) {
534
- codeAction.diagnostics = codeAction.diagnostics.map(x => util_1.util.toDiagnostic(x));
599
+ codeAction.diagnostics = (_a = codeAction.diagnostics) === null || _a === void 0 ? void 0 : _a.map(x => util_1.util.toDiagnostic(x, params.textDocument.uri));
535
600
  }
536
601
  }
537
602
  return codeActions;
@@ -561,7 +626,7 @@ class LanguageServer {
561
626
  if (project.isStandaloneFileProject === false) {
562
627
  this.removeProject(project);
563
628
  //create a new workspace/brs program
564
- await this.createProject(project.projectPath, project.workspacePath);
629
+ await this.createProject(project.projectPath, project.workspacePath, project.projectNumber);
565
630
  //handle temp workspace
566
631
  }
567
632
  else {
@@ -638,12 +703,10 @@ class LanguageServer {
638
703
  * The CLIENT is in charge of what files to watch, so all client
639
704
  * implementations should ensure that all valid project
640
705
  * file types are watched (.brs,.bs,.xml,manifest, and any json/text/image files)
641
- * @param params
642
706
  */
643
707
  async onDidChangeWatchedFiles(params) {
644
708
  //ensure programs are initialized
645
709
  await this.waitAllProjectFirstRuns();
646
- this.connection.sendNotification('build-status', 'building');
647
710
  let projects = this.getProjects();
648
711
  //convert all file paths to absolute paths
649
712
  let changes = params.changes.map(x => {
@@ -712,37 +775,33 @@ class LanguageServer {
712
775
  //give every workspace the chance to handle file changes
713
776
  await Promise.all(projects.map((project) => this.handleFileChanges(project, changes)));
714
777
  }
715
- this.connection.sendNotification('build-status', 'success');
716
778
  }
717
779
  /**
718
780
  * This only operates on files that match the specified files globs, so it is safe to throw
719
781
  * any file changes you receive with no unexpected side-effects
720
- * @param changes
721
782
  */
722
783
  async handleFileChanges(project, changes) {
723
784
  //this loop assumes paths are both file paths and folder paths, which eliminates the need to detect.
724
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
725
- let consumeCount = 0;
726
786
  await Promise.all(changes.map(async (change) => {
727
787
  await this.keyedThrottler.run(change.srcPath, async () => {
728
- consumeCount += await this.handleFileChange(project, change) ? 1 : 0;
788
+ if (await this.handleFileChange(project, change)) {
789
+ await this.validateAllThrottled();
790
+ }
729
791
  });
730
792
  }));
731
- if (consumeCount > 0) {
732
- await this.validateAllThrottled();
733
- }
734
793
  }
735
794
  /**
736
795
  * This only operates on files that match the specified files globs, so it is safe to throw
737
796
  * any file changes you receive with no unexpected side-effects
738
- * @param changes
797
+ * @returns true if the file was handled by this project, false if it was not
739
798
  */
740
799
  async handleFileChange(project, change) {
741
800
  const { program, options, rootDir } = project.builder;
742
801
  //deleted
743
802
  if (change.type === node_1.FileChangeType.Deleted) {
744
803
  //try to act on this path as a directory
745
- project.builder.program.removeFilesInFolder(change.srcPath);
804
+ project.builder.removeFilesInFolder(change.srcPath);
746
805
  //if this is a file loaded in the program, remove it
747
806
  if (program.hasFile(change.srcPath)) {
748
807
  program.removeFile(change.srcPath);
@@ -787,14 +846,36 @@ class LanguageServer {
787
846
  }
788
847
  }
789
848
  async onHover(params) {
849
+ var _a;
790
850
  //ensure programs are initialized
791
851
  await this.waitAllProjectFirstRuns();
792
852
  const srcPath = util_1.util.uriToPath(params.textDocument.uri);
793
853
  let projects = this.getProjects();
794
- let hovers = await Promise.all(Array.prototype.concat.call([], projects.map(async (x) => x.builder.program.getHover(srcPath, params.position))));
795
- //return the first non-falsey hover. TODO is there a way to handle multiple hover results?
796
- let hover = hovers.filter((x) => !!x)[0];
797
- return hover;
854
+ let hovers = projects
855
+ //get hovers from all projects
856
+ .map((x) => x.builder.program.getHover(srcPath, params.position))
857
+ //flatten to a single list
858
+ .flat();
859
+ const contents = [
860
+ ...(hovers !== null && hovers !== void 0 ? hovers : [])
861
+ //pull all hover contents out into a flag array of strings
862
+ .map(x => {
863
+ return Array.isArray(x === null || x === void 0 ? void 0 : x.contents) ? x === null || x === void 0 ? void 0 : x.contents : [x === null || x === void 0 ? void 0 : x.contents];
864
+ }).flat()
865
+ //remove nulls
866
+ .filter(x => !!x)
867
+ //dedupe hovers across all projects
868
+ .reduce((set, content) => set.add(content), new Set()).values()
869
+ ];
870
+ if (contents.length > 0) {
871
+ let hover = {
872
+ //use the range from the first hover
873
+ range: (_a = hovers[0]) === null || _a === void 0 ? void 0 : _a.range,
874
+ //the contents of all hovers
875
+ contents: contents
876
+ };
877
+ return hover;
878
+ }
798
879
  }
799
880
  async onDocumentClose(event) {
800
881
  const { document } = event;
@@ -817,7 +898,6 @@ class LanguageServer {
817
898
  //throttle file processing. first call is run immediately, and then the last call is processed.
818
899
  await this.keyedThrottler.run(filePath, () => {
819
900
  var _a;
820
- this.connection.sendNotification('build-status', 'building');
821
901
  let documentText = document.getText();
822
902
  for (const project of this.getProjects()) {
823
903
  //only add or replace existing files. All of the files in the project should
@@ -836,7 +916,7 @@ class LanguageServer {
836
916
  await this.validateAllThrottled();
837
917
  }
838
918
  catch (e) {
839
- this.sendCriticalFailure(`Critical error parsing / validating ${filePath}: ${e.message}`);
919
+ this.sendCriticalFailure(`Critical error parsing/validating ${filePath}: ${e.message}`);
840
920
  }
841
921
  }
842
922
  async validateAll() {
@@ -846,13 +926,15 @@ class LanguageServer {
846
926
  await this.synchronizeStandaloneProjects();
847
927
  let projects = this.getProjects();
848
928
  //validate all programs
849
- 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
+ }));
850
933
  }
851
934
  catch (e) {
852
935
  this.connection.console.error(e);
853
936
  this.sendCriticalFailure(`Critical error validating project: ${e.message}${(_a = e.stack) !== null && _a !== void 0 ? _a : ''}`);
854
937
  }
855
- this.connection.sendNotification('build-status', 'success');
856
938
  }
857
939
  async onWorkspaceSymbol(params) {
858
940
  await this.waitAllProjectFirstRuns();
@@ -894,7 +976,7 @@ class LanguageServer {
894
976
  try {
895
977
  const signatures = util_1.util.flatMap(await Promise.all(this.getProjects().map(project => project.builder.program.getSignatureHelp(filepath, params.position))), c => c);
896
978
  const activeSignature = signatures.length > 0 ? 0 : null;
897
- 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;
898
980
  let results = {
899
981
  signatures: signatures.map((s) => s.signature),
900
982
  activeSignature: activeSignature,
@@ -917,20 +999,35 @@ class LanguageServer {
917
999
  const srcPath = util_1.util.uriToPath(params.textDocument.uri);
918
1000
  const results = util_1.util.flatMap(await Promise.all(this.getProjects().map(project => {
919
1001
  return project.builder.program.getReferences(srcPath, position);
920
- })), c => c);
1002
+ })), c => c !== null && c !== void 0 ? c : []);
921
1003
  return results.filter((r) => r);
922
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
+ }
923
1013
  async onFullSemanticTokens(params) {
924
1014
  await this.waitAllProjectFirstRuns();
1015
+ //wait for the file to settle (in case there are multiple file changes in quick succession)
925
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();
926
1021
  const srcPath = util_1.util.uriToPath(params.textDocument.uri);
927
1022
  for (const project of this.projects) {
928
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.
929
1024
  if (project.builder.program.hasFile(srcPath)) {
930
1025
  let semanticTokens = project.builder.program.getSemanticTokens(srcPath);
931
- return {
932
- data: (0, SemanticTokenUtils_1.encodeSemanticTokens)(semanticTokens)
933
- };
1026
+ if (semanticTokens !== undefined) {
1027
+ return {
1028
+ data: (0, SemanticTokenUtils_1.encodeSemanticTokens)(semanticTokens)
1029
+ };
1030
+ }
934
1031
  }
935
1032
  }
936
1033
  }
@@ -941,9 +1038,10 @@ class LanguageServer {
941
1038
  //Get only the changes to diagnostics since the last time we sent them to the client
942
1039
  const patch = this.diagnosticCollection.getPatch(this.projects);
943
1040
  for (let filePath in patch) {
944
- const diagnostics = patch[filePath].map(d => util_1.util.toDiagnostic(d));
1041
+ const uri = vscode_uri_1.URI.file(filePath).toString();
1042
+ const diagnostics = patch[filePath].map(d => util_1.util.toDiagnostic(d, uri));
945
1043
  this.connection.sendDiagnostics({
946
- uri: vscode_uri_1.URI.file(filePath).toString(),
1044
+ uri: uri,
947
1045
  diagnostics: diagnostics
948
1046
  });
949
1047
  }
@@ -958,9 +1056,6 @@ class LanguageServer {
958
1056
  return result;
959
1057
  }
960
1058
  }
961
- /**
962
- * @param srcPath The absolute path to the source file on disk
963
- */
964
1059
  async transpileFile(srcPath) {
965
1060
  //wait all program first runs
966
1061
  await this.waitAllProjectFirstRuns();
@@ -981,22 +1076,35 @@ __decorate([
981
1076
  AddStackToErrorMessage
982
1077
  ], LanguageServer.prototype, "onInitialize", null);
983
1078
  __decorate([
984
- AddStackToErrorMessage
1079
+ TrackBusyStatus
1080
+ ], LanguageServer.prototype, "getProjectPaths", null);
1081
+ __decorate([
1082
+ TrackBusyStatus
1083
+ ], LanguageServer.prototype, "syncProjects", null);
1084
+ __decorate([
1085
+ AddStackToErrorMessage,
1086
+ TrackBusyStatus
985
1087
  ], LanguageServer.prototype, "onInitialized", null);
986
1088
  __decorate([
987
- AddStackToErrorMessage
1089
+ TrackBusyStatus
1090
+ ], LanguageServer.prototype, "createProject", null);
1091
+ __decorate([
1092
+ AddStackToErrorMessage,
1093
+ TrackBusyStatus
988
1094
  ], LanguageServer.prototype, "onCompletion", null);
989
1095
  __decorate([
990
1096
  AddStackToErrorMessage
991
1097
  ], LanguageServer.prototype, "onCompletionResolve", null);
992
1098
  __decorate([
993
- AddStackToErrorMessage
1099
+ AddStackToErrorMessage,
1100
+ TrackBusyStatus
994
1101
  ], LanguageServer.prototype, "onCodeAction", null);
995
1102
  __decorate([
996
1103
  AddStackToErrorMessage
997
1104
  ], LanguageServer.prototype, "onDidChangeConfiguration", null);
998
1105
  __decorate([
999
- AddStackToErrorMessage
1106
+ AddStackToErrorMessage,
1107
+ TrackBusyStatus
1000
1108
  ], LanguageServer.prototype, "onDidChangeWatchedFiles", null);
1001
1109
  __decorate([
1002
1110
  AddStackToErrorMessage
@@ -1005,34 +1113,49 @@ __decorate([
1005
1113
  AddStackToErrorMessage
1006
1114
  ], LanguageServer.prototype, "onDocumentClose", null);
1007
1115
  __decorate([
1008
- AddStackToErrorMessage
1116
+ AddStackToErrorMessage,
1117
+ TrackBusyStatus
1009
1118
  ], LanguageServer.prototype, "validateTextDocument", null);
1010
1119
  __decorate([
1011
- AddStackToErrorMessage
1120
+ TrackBusyStatus
1121
+ ], LanguageServer.prototype, "validateAll", null);
1122
+ __decorate([
1123
+ AddStackToErrorMessage,
1124
+ TrackBusyStatus
1012
1125
  ], LanguageServer.prototype, "onWorkspaceSymbol", null);
1013
1126
  __decorate([
1014
- AddStackToErrorMessage
1127
+ AddStackToErrorMessage,
1128
+ TrackBusyStatus
1015
1129
  ], LanguageServer.prototype, "onDocumentSymbol", null);
1016
1130
  __decorate([
1017
- AddStackToErrorMessage
1131
+ AddStackToErrorMessage,
1132
+ TrackBusyStatus
1018
1133
  ], LanguageServer.prototype, "onDefinition", null);
1019
1134
  __decorate([
1020
- AddStackToErrorMessage
1135
+ AddStackToErrorMessage,
1136
+ TrackBusyStatus
1021
1137
  ], LanguageServer.prototype, "onSignatureHelp", null);
1022
1138
  __decorate([
1023
- AddStackToErrorMessage
1139
+ AddStackToErrorMessage,
1140
+ TrackBusyStatus
1024
1141
  ], LanguageServer.prototype, "onReferences", null);
1025
1142
  __decorate([
1026
- AddStackToErrorMessage
1143
+ AddStackToErrorMessage,
1144
+ TrackBusyStatus
1027
1145
  ], LanguageServer.prototype, "onFullSemanticTokens", null);
1028
1146
  __decorate([
1029
- AddStackToErrorMessage
1147
+ AddStackToErrorMessage,
1148
+ TrackBusyStatus
1030
1149
  ], LanguageServer.prototype, "onExecuteCommand", null);
1031
1150
  exports.LanguageServer = LanguageServer;
1032
1151
  var CustomCommands;
1033
1152
  (function (CustomCommands) {
1034
1153
  CustomCommands["TranspileFile"] = "TranspileFile";
1035
1154
  })(CustomCommands = exports.CustomCommands || (exports.CustomCommands = {}));
1155
+ var NotificationName;
1156
+ (function (NotificationName) {
1157
+ NotificationName["busyStatus"] = "busyStatus";
1158
+ })(NotificationName = exports.NotificationName || (exports.NotificationName = {}));
1036
1159
  /**
1037
1160
  * Wraps a method. If there's an error (either sync or via a promise),
1038
1161
  * this appends the error's stack trace at the end of the error message so that the connection will
@@ -1064,4 +1187,16 @@ function AddStackToErrorMessage(target, propertyKey, descriptor) {
1064
1187
  }
1065
1188
  };
1066
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
+ }
1067
1202
  //# sourceMappingURL=LanguageServer.js.map