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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (715) hide show
  1. package/README.md +76 -138
  2. package/bsconfig.schema.json +121 -5
  3. package/dist/ActionPipeline.d.ts +10 -0
  4. package/dist/ActionPipeline.js +40 -0
  5. package/dist/ActionPipeline.js.map +1 -0
  6. package/dist/AstValidationSegmenter.d.ts +45 -0
  7. package/dist/AstValidationSegmenter.js +322 -0
  8. package/dist/AstValidationSegmenter.js.map +1 -0
  9. package/dist/BsConfig.d.ts +72 -39
  10. package/dist/BusyStatusTracker.d.ts +61 -0
  11. package/dist/BusyStatusTracker.js +148 -0
  12. package/dist/BusyStatusTracker.js.map +1 -0
  13. package/dist/Cache.d.ts +3 -8
  14. package/dist/Cache.js +9 -14
  15. package/dist/Cache.js.map +1 -1
  16. package/dist/CacheVerifier.d.ts +7 -0
  17. package/dist/CacheVerifier.js +20 -0
  18. package/dist/CacheVerifier.js.map +1 -0
  19. package/dist/CodeActionUtil.d.ts +12 -4
  20. package/dist/CodeActionUtil.js +22 -5
  21. package/dist/CodeActionUtil.js.map +1 -1
  22. package/dist/CommentFlagProcessor.d.ts +7 -6
  23. package/dist/CommentFlagProcessor.js +11 -8
  24. package/dist/CommentFlagProcessor.js.map +1 -1
  25. package/dist/CrossScopeValidator.d.ts +68 -0
  26. package/dist/CrossScopeValidator.js +642 -0
  27. package/dist/CrossScopeValidator.js.map +1 -0
  28. package/dist/DependencyGraph.d.ts +8 -3
  29. package/dist/DependencyGraph.js +49 -16
  30. package/dist/DependencyGraph.js.map +1 -1
  31. package/dist/DiagnosticCollection.d.ts +21 -5
  32. package/dist/DiagnosticCollection.js +77 -24
  33. package/dist/DiagnosticCollection.js.map +1 -1
  34. package/dist/DiagnosticFilterer.d.ts +27 -6
  35. package/dist/DiagnosticFilterer.js +273 -60
  36. package/dist/DiagnosticFilterer.js.map +1 -1
  37. package/dist/DiagnosticManager.d.ts +82 -0
  38. package/dist/DiagnosticManager.js +406 -0
  39. package/dist/DiagnosticManager.js.map +1 -0
  40. package/dist/DiagnosticMessages.d.ts +558 -196
  41. package/dist/DiagnosticMessages.js +870 -340
  42. package/dist/DiagnosticMessages.js.map +1 -1
  43. package/dist/DiagnosticSeverityAdjuster.d.ts +7 -0
  44. package/dist/DiagnosticSeverityAdjuster.js +45 -0
  45. package/dist/DiagnosticSeverityAdjuster.js.map +1 -0
  46. package/dist/FunctionScope.d.ts +28 -0
  47. package/dist/FunctionScope.js +52 -0
  48. package/dist/FunctionScope.js.map +1 -0
  49. package/dist/KeyedThrottler.d.ts +3 -3
  50. package/dist/KeyedThrottler.js +3 -3
  51. package/dist/KeyedThrottler.js.map +1 -1
  52. package/dist/LanguageServer.d.ts +100 -105
  53. package/dist/LanguageServer.js +444 -745
  54. package/dist/LanguageServer.js.map +1 -1
  55. package/dist/Logger.d.ts +17 -13
  56. package/dist/Logger.js +64 -34
  57. package/dist/Logger.js.map +1 -1
  58. package/dist/PluginInterface.d.ts +32 -10
  59. package/dist/PluginInterface.js +117 -7
  60. package/dist/PluginInterface.js.map +1 -1
  61. package/dist/Program.d.ts +241 -98
  62. package/dist/Program.js +1432 -717
  63. package/dist/Program.js.map +1 -1
  64. package/dist/ProgramBuilder.d.ts +47 -23
  65. package/dist/ProgramBuilder.js +224 -178
  66. package/dist/ProgramBuilder.js.map +1 -1
  67. package/dist/Scope.d.ts +149 -109
  68. package/dist/Scope.js +557 -550
  69. package/dist/Scope.js.map +1 -1
  70. package/dist/SemanticTokenUtils.js +5 -1
  71. package/dist/SemanticTokenUtils.js.map +1 -1
  72. package/dist/Stopwatch.d.ts +4 -0
  73. package/dist/Stopwatch.js +8 -1
  74. package/dist/Stopwatch.js.map +1 -1
  75. package/dist/SymbolTable.d.ts +136 -24
  76. package/dist/SymbolTable.js +565 -64
  77. package/dist/SymbolTable.js.map +1 -1
  78. package/dist/SymbolTypeFlag.d.ts +9 -0
  79. package/dist/SymbolTypeFlag.js +14 -0
  80. package/dist/SymbolTypeFlag.js.map +1 -0
  81. package/dist/Throttler.d.ts +12 -0
  82. package/dist/Throttler.js +39 -0
  83. package/dist/Throttler.js.map +1 -1
  84. package/dist/Watcher.d.ts +0 -3
  85. package/dist/Watcher.js +0 -3
  86. package/dist/Watcher.js.map +1 -1
  87. package/dist/XmlScope.d.ts +5 -15
  88. package/dist/XmlScope.js +34 -90
  89. package/dist/XmlScope.js.map +1 -1
  90. package/dist/astUtils/CachedLookups.d.ts +50 -0
  91. package/dist/astUtils/CachedLookups.js +334 -0
  92. package/dist/astUtils/CachedLookups.js.map +1 -0
  93. package/dist/astUtils/CachedLookups.spec.js +39 -0
  94. package/dist/astUtils/CachedLookups.spec.js.map +1 -0
  95. package/dist/astUtils/Editor.d.ts +69 -0
  96. package/dist/astUtils/Editor.js +245 -0
  97. package/dist/astUtils/Editor.js.map +1 -0
  98. package/dist/astUtils/Editor.spec.js +258 -0
  99. package/dist/astUtils/Editor.spec.js.map +1 -0
  100. package/dist/astUtils/creators.d.ts +54 -19
  101. package/dist/astUtils/creators.js +242 -42
  102. package/dist/astUtils/creators.js.map +1 -1
  103. package/dist/astUtils/creators.spec.js +5 -5
  104. package/dist/astUtils/creators.spec.js.map +1 -1
  105. package/dist/astUtils/reflection.d.ts +196 -85
  106. package/dist/astUtils/reflection.js +497 -144
  107. package/dist/astUtils/reflection.js.map +1 -1
  108. package/dist/astUtils/reflection.spec.js +267 -167
  109. package/dist/astUtils/reflection.spec.js.map +1 -1
  110. package/dist/astUtils/stackedVisitor.js.map +1 -1
  111. package/dist/astUtils/stackedVisitor.spec.js +14 -14
  112. package/dist/astUtils/stackedVisitor.spec.js.map +1 -1
  113. package/dist/astUtils/visitors.d.ts +116 -53
  114. package/dist/astUtils/visitors.js +95 -15
  115. package/dist/astUtils/visitors.js.map +1 -1
  116. package/dist/astUtils/visitors.spec.js +629 -51
  117. package/dist/astUtils/visitors.spec.js.map +1 -1
  118. package/dist/astUtils/xml.d.ts +9 -8
  119. package/dist/astUtils/xml.js +12 -7
  120. package/dist/astUtils/xml.js.map +1 -1
  121. package/dist/bscPlugin/BscPlugin.d.ts +24 -4
  122. package/dist/bscPlugin/BscPlugin.js +88 -4
  123. package/dist/bscPlugin/BscPlugin.js.map +1 -1
  124. package/dist/bscPlugin/CallExpressionInfo.d.ts +36 -0
  125. package/dist/bscPlugin/CallExpressionInfo.js +143 -0
  126. package/dist/bscPlugin/CallExpressionInfo.js.map +1 -0
  127. package/dist/bscPlugin/FileWriter.d.ts +6 -0
  128. package/dist/bscPlugin/FileWriter.js +24 -0
  129. package/dist/bscPlugin/FileWriter.js.map +1 -0
  130. package/dist/bscPlugin/SignatureHelpUtil.d.ts +10 -0
  131. package/dist/bscPlugin/SignatureHelpUtil.js +137 -0
  132. package/dist/bscPlugin/SignatureHelpUtil.js.map +1 -0
  133. package/dist/bscPlugin/codeActions/CodeActionsProcessor.d.ts +6 -5
  134. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +173 -27
  135. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  136. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +138 -21
  137. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
  138. package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +65 -0
  139. package/dist/bscPlugin/completions/CompletionsProcessor.js +633 -0
  140. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -0
  141. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +2512 -0
  142. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -0
  143. package/dist/bscPlugin/definition/DefinitionProvider.d.ts +13 -0
  144. package/dist/bscPlugin/definition/DefinitionProvider.js +212 -0
  145. package/dist/bscPlugin/definition/DefinitionProvider.js.map +1 -0
  146. package/dist/bscPlugin/definition/DefinitionProvider.spec.js +87 -0
  147. package/dist/bscPlugin/definition/DefinitionProvider.spec.js.map +1 -0
  148. package/dist/bscPlugin/fileProviders/FileProvider.d.ts +9 -0
  149. package/dist/bscPlugin/fileProviders/FileProvider.js +51 -0
  150. package/dist/bscPlugin/fileProviders/FileProvider.js.map +1 -0
  151. package/dist/bscPlugin/hover/HoverProcessor.d.ts +18 -0
  152. package/dist/bscPlugin/hover/HoverProcessor.js +230 -0
  153. package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -0
  154. package/dist/bscPlugin/hover/HoverProcessor.spec.js +991 -0
  155. package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -0
  156. package/dist/bscPlugin/references/ReferencesProvider.d.ts +12 -0
  157. package/dist/bscPlugin/references/ReferencesProvider.js +57 -0
  158. package/dist/bscPlugin/references/ReferencesProvider.js.map +1 -0
  159. package/dist/bscPlugin/references/ReferencesProvider.spec.d.ts +1 -0
  160. package/dist/bscPlugin/references/ReferencesProvider.spec.js +51 -0
  161. package/dist/bscPlugin/references/ReferencesProvider.spec.js.map +1 -0
  162. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +14 -0
  163. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +164 -0
  164. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -0
  165. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.d.ts +1 -0
  166. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +564 -0
  167. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -0
  168. package/dist/bscPlugin/serialize/BslibInjector.spec.d.ts +1 -0
  169. package/dist/bscPlugin/serialize/BslibInjector.spec.js +33 -0
  170. package/dist/bscPlugin/serialize/BslibInjector.spec.js.map +1 -0
  171. package/dist/bscPlugin/serialize/BslibManager.d.ts +12 -0
  172. package/dist/bscPlugin/serialize/BslibManager.js +46 -0
  173. package/dist/bscPlugin/serialize/BslibManager.js.map +1 -0
  174. package/dist/bscPlugin/serialize/FileSerializer.d.ts +9 -0
  175. package/dist/bscPlugin/serialize/FileSerializer.js +75 -0
  176. package/dist/bscPlugin/serialize/FileSerializer.js.map +1 -0
  177. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.d.ts +7 -0
  178. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.js +22 -0
  179. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.js.map +1 -0
  180. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.d.ts +1 -0
  181. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js +291 -0
  182. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js.map +1 -0
  183. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.d.ts +7 -0
  184. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.js +26 -0
  185. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.js.map +1 -0
  186. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.d.ts +1 -0
  187. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js +245 -0
  188. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js.map +1 -0
  189. package/dist/bscPlugin/symbols/symbolUtils.d.ts +5 -0
  190. package/dist/bscPlugin/symbols/symbolUtils.js +141 -0
  191. package/dist/bscPlugin/symbols/symbolUtils.js.map +1 -0
  192. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.d.ts +27 -0
  193. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js +418 -0
  194. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -0
  195. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.d.ts +1 -0
  196. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js +75 -0
  197. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +1 -0
  198. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +12 -0
  199. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js +99 -0
  200. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +1 -0
  201. package/dist/bscPlugin/validation/BrsFileAfterValidator.d.ts +7 -0
  202. package/dist/bscPlugin/validation/BrsFileAfterValidator.js +18 -0
  203. package/dist/bscPlugin/validation/BrsFileAfterValidator.js.map +1 -0
  204. package/dist/bscPlugin/validation/BrsFileValidator.d.ts +37 -0
  205. package/dist/bscPlugin/validation/BrsFileValidator.js +638 -0
  206. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -0
  207. package/dist/bscPlugin/validation/BrsFileValidator.spec.d.ts +1 -0
  208. package/dist/bscPlugin/validation/BrsFileValidator.spec.js +1517 -0
  209. package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -0
  210. package/dist/bscPlugin/validation/ProgramValidator.d.ts +11 -0
  211. package/dist/bscPlugin/validation/ProgramValidator.js +33 -0
  212. package/dist/bscPlugin/validation/ProgramValidator.js.map +1 -0
  213. package/dist/bscPlugin/validation/ScopeValidator.d.ts +141 -0
  214. package/dist/bscPlugin/validation/ScopeValidator.js +1323 -0
  215. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -0
  216. package/dist/bscPlugin/validation/ScopeValidator.spec.d.ts +1 -0
  217. package/dist/bscPlugin/validation/ScopeValidator.spec.js +6135 -0
  218. package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -0
  219. package/dist/bscPlugin/validation/XmlFileValidator.d.ts +8 -0
  220. package/dist/bscPlugin/validation/XmlFileValidator.js +36 -0
  221. package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -0
  222. package/dist/cli.js +126 -27
  223. package/dist/cli.js.map +1 -1
  224. package/dist/common/Sequencer.d.ts +53 -0
  225. package/dist/common/Sequencer.js +233 -0
  226. package/dist/common/Sequencer.js.map +1 -0
  227. package/dist/common/Sequencer.spec.d.ts +1 -0
  228. package/dist/common/Sequencer.spec.js +75 -0
  229. package/dist/common/Sequencer.spec.js.map +1 -0
  230. package/dist/deferred.d.ts +5 -3
  231. package/dist/deferred.js +10 -0
  232. package/dist/deferred.js.map +1 -1
  233. package/dist/diagnosticUtils.d.ts +10 -3
  234. package/dist/diagnosticUtils.js +64 -25
  235. package/dist/diagnosticUtils.js.map +1 -1
  236. package/dist/examples/plugins/removePrint.d.ts +2 -2
  237. package/dist/examples/plugins/removePrint.js +8 -12
  238. package/dist/examples/plugins/removePrint.js.map +1 -1
  239. package/dist/files/AssetFile.d.ts +24 -0
  240. package/dist/files/AssetFile.js +25 -0
  241. package/dist/files/AssetFile.js.map +1 -0
  242. package/dist/files/BrsFile.Class.spec.js +1213 -259
  243. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  244. package/dist/files/BrsFile.d.ts +145 -87
  245. package/dist/files/BrsFile.js +836 -934
  246. package/dist/files/BrsFile.js.map +1 -1
  247. package/dist/files/BrsFile.spec.js +4226 -902
  248. package/dist/files/BrsFile.spec.js.map +1 -1
  249. package/dist/files/BscFile.d.ts +102 -0
  250. package/dist/files/BscFile.js +15 -0
  251. package/dist/files/BscFile.js.map +1 -0
  252. package/dist/files/Factory.d.ts +25 -0
  253. package/dist/files/Factory.js +22 -0
  254. package/dist/files/Factory.js.map +1 -0
  255. package/dist/files/LazyFileData.d.ts +21 -0
  256. package/dist/files/LazyFileData.js +54 -0
  257. package/dist/files/LazyFileData.js.map +1 -0
  258. package/dist/files/LazyFileData.spec.d.ts +1 -0
  259. package/dist/files/LazyFileData.spec.js +27 -0
  260. package/dist/files/LazyFileData.spec.js.map +1 -0
  261. package/dist/files/XmlFile.d.ts +80 -41
  262. package/dist/files/XmlFile.js +161 -137
  263. package/dist/files/XmlFile.js.map +1 -1
  264. package/dist/files/XmlFile.spec.js +444 -336
  265. package/dist/files/XmlFile.spec.js.map +1 -1
  266. package/dist/files/tests/imports.spec.js +62 -52
  267. package/dist/files/tests/imports.spec.js.map +1 -1
  268. package/dist/files/tests/optionalChaning.spec.d.ts +1 -0
  269. package/dist/files/tests/optionalChaning.spec.js +152 -0
  270. package/dist/files/tests/optionalChaning.spec.js.map +1 -0
  271. package/dist/globalCallables.d.ts +3 -1
  272. package/dist/globalCallables.js +424 -184
  273. package/dist/globalCallables.js.map +1 -1
  274. package/dist/index.d.ts +32 -4
  275. package/dist/index.js +54 -7
  276. package/dist/index.js.map +1 -1
  277. package/dist/interfaces.d.ts +942 -125
  278. package/dist/interfaces.js +21 -0
  279. package/dist/interfaces.js.map +1 -1
  280. package/dist/lexer/Character.spec.js +5 -5
  281. package/dist/lexer/Character.spec.js.map +1 -1
  282. package/dist/lexer/Lexer.d.ts +51 -12
  283. package/dist/lexer/Lexer.js +215 -65
  284. package/dist/lexer/Lexer.js.map +1 -1
  285. package/dist/lexer/Lexer.spec.js +812 -568
  286. package/dist/lexer/Lexer.spec.js.map +1 -1
  287. package/dist/lexer/Token.d.ts +27 -11
  288. package/dist/lexer/Token.js +10 -2
  289. package/dist/lexer/Token.js.map +1 -1
  290. package/dist/lexer/TokenKind.d.ts +40 -2
  291. package/dist/lexer/TokenKind.js +147 -10
  292. package/dist/lexer/TokenKind.js.map +1 -1
  293. package/dist/logging.d.ts +14 -0
  294. package/dist/logging.js +29 -0
  295. package/dist/logging.js.map +1 -0
  296. package/dist/lsp/ActionQueue.d.ts +35 -0
  297. package/dist/lsp/ActionQueue.js +115 -0
  298. package/dist/lsp/ActionQueue.js.map +1 -0
  299. package/dist/lsp/ActionQueue.spec.d.ts +1 -0
  300. package/dist/lsp/ActionQueue.spec.js +80 -0
  301. package/dist/lsp/ActionQueue.spec.js.map +1 -0
  302. package/dist/lsp/DocumentManager.d.ts +63 -0
  303. package/dist/lsp/DocumentManager.js +122 -0
  304. package/dist/lsp/DocumentManager.js.map +1 -0
  305. package/dist/lsp/DocumentManager.spec.d.ts +1 -0
  306. package/dist/lsp/DocumentManager.spec.js +103 -0
  307. package/dist/lsp/DocumentManager.spec.js.map +1 -0
  308. package/dist/lsp/LspProject.d.ts +239 -0
  309. package/dist/lsp/LspProject.js +3 -0
  310. package/dist/lsp/LspProject.js.map +1 -0
  311. package/dist/lsp/PathFilterer.d.ts +75 -0
  312. package/dist/lsp/PathFilterer.js +196 -0
  313. package/dist/lsp/PathFilterer.js.map +1 -0
  314. package/dist/lsp/PathFilterer.spec.d.ts +1 -0
  315. package/dist/lsp/PathFilterer.spec.js +182 -0
  316. package/dist/lsp/PathFilterer.spec.js.map +1 -0
  317. package/dist/lsp/Project.d.ts +168 -0
  318. package/dist/lsp/Project.js +437 -0
  319. package/dist/lsp/Project.js.map +1 -0
  320. package/dist/lsp/Project.spec.d.ts +1 -0
  321. package/dist/lsp/Project.spec.js +267 -0
  322. package/dist/lsp/Project.spec.js.map +1 -0
  323. package/dist/lsp/ProjectManager.d.ts +242 -0
  324. package/dist/lsp/ProjectManager.js +824 -0
  325. package/dist/lsp/ProjectManager.js.map +1 -0
  326. package/dist/lsp/ProjectManager.spec.d.ts +1 -0
  327. package/dist/lsp/ProjectManager.spec.js +913 -0
  328. package/dist/lsp/ProjectManager.spec.js.map +1 -0
  329. package/dist/lsp/ReaderWriterManager.d.ts +21 -0
  330. package/dist/lsp/ReaderWriterManager.js +60 -0
  331. package/dist/lsp/ReaderWriterManager.js.map +1 -0
  332. package/dist/lsp/worker/MessageHandler.d.ts +99 -0
  333. package/dist/lsp/worker/MessageHandler.js +138 -0
  334. package/dist/lsp/worker/MessageHandler.js.map +1 -0
  335. package/dist/lsp/worker/MessageHandler.spec.d.ts +1 -0
  336. package/dist/lsp/worker/MessageHandler.spec.js +64 -0
  337. package/dist/lsp/worker/MessageHandler.spec.js.map +1 -0
  338. package/dist/lsp/worker/WorkerPool.d.ts +38 -0
  339. package/dist/lsp/worker/WorkerPool.js +78 -0
  340. package/dist/lsp/worker/WorkerPool.js.map +1 -0
  341. package/dist/lsp/worker/WorkerPool.spec.d.ts +1 -0
  342. package/dist/lsp/worker/WorkerPool.spec.js +59 -0
  343. package/dist/lsp/worker/WorkerPool.spec.js.map +1 -0
  344. package/dist/lsp/worker/WorkerThreadProject.d.ts +143 -0
  345. package/dist/lsp/worker/WorkerThreadProject.js +189 -0
  346. package/dist/lsp/worker/WorkerThreadProject.js.map +1 -0
  347. package/dist/lsp/worker/WorkerThreadProject.spec.d.ts +2 -0
  348. package/dist/lsp/worker/WorkerThreadProject.spec.js +71 -0
  349. package/dist/lsp/worker/WorkerThreadProject.spec.js.map +1 -0
  350. package/dist/lsp/worker/WorkerThreadProjectRunner.d.ts +15 -0
  351. package/dist/lsp/worker/WorkerThreadProjectRunner.js +58 -0
  352. package/dist/lsp/worker/WorkerThreadProjectRunner.js.map +1 -0
  353. package/dist/lsp/worker/run.d.ts +1 -0
  354. package/dist/lsp/worker/run.js +14 -0
  355. package/dist/lsp/worker/run.js.map +1 -0
  356. package/dist/parser/AstNode.d.ts +203 -0
  357. package/dist/parser/AstNode.js +303 -0
  358. package/dist/parser/AstNode.js.map +1 -0
  359. package/dist/parser/AstNode.spec.d.ts +1 -0
  360. package/dist/parser/AstNode.spec.js +1455 -0
  361. package/dist/parser/AstNode.spec.js.map +1 -0
  362. package/dist/parser/BrightScriptDocParser.d.ts +56 -0
  363. package/dist/parser/BrightScriptDocParser.js +294 -0
  364. package/dist/parser/BrightScriptDocParser.js.map +1 -0
  365. package/dist/parser/BrightScriptDocParser.spec.d.ts +1 -0
  366. package/dist/parser/BrightScriptDocParser.spec.js +310 -0
  367. package/dist/parser/BrightScriptDocParser.spec.js.map +1 -0
  368. package/dist/parser/BrsTranspileState.d.ts +22 -3
  369. package/dist/parser/BrsTranspileState.js +19 -0
  370. package/dist/parser/BrsTranspileState.js.map +1 -1
  371. package/dist/parser/Expression.d.ts +553 -221
  372. package/dist/parser/Expression.js +1414 -505
  373. package/dist/parser/Expression.js.map +1 -1
  374. package/dist/parser/Expression.spec.d.ts +1 -0
  375. package/dist/parser/Expression.spec.js +40 -0
  376. package/dist/parser/Expression.spec.js.map +1 -0
  377. package/dist/parser/Parser.Class.spec.js +255 -125
  378. package/dist/parser/Parser.Class.spec.js.map +1 -1
  379. package/dist/parser/Parser.d.ts +117 -124
  380. package/dist/parser/Parser.js +1669 -982
  381. package/dist/parser/Parser.js.map +1 -1
  382. package/dist/parser/Parser.spec.d.ts +3 -1
  383. package/dist/parser/Parser.spec.js +2111 -525
  384. package/dist/parser/Parser.spec.js.map +1 -1
  385. package/dist/parser/SGParser.d.ts +29 -13
  386. package/dist/parser/SGParser.js +85 -56
  387. package/dist/parser/SGParser.js.map +1 -1
  388. package/dist/parser/SGParser.spec.js +30 -45
  389. package/dist/parser/SGParser.spec.js.map +1 -1
  390. package/dist/parser/SGTypes.d.ts +134 -46
  391. package/dist/parser/SGTypes.js +206 -115
  392. package/dist/parser/SGTypes.js.map +1 -1
  393. package/dist/parser/Statement.d.ts +849 -267
  394. package/dist/parser/Statement.js +2412 -625
  395. package/dist/parser/Statement.js.map +1 -1
  396. package/dist/parser/Statement.spec.js +133 -36
  397. package/dist/parser/Statement.spec.js.map +1 -1
  398. package/dist/parser/TranspileState.d.ts +26 -12
  399. package/dist/parser/TranspileState.js +115 -24
  400. package/dist/parser/TranspileState.js.map +1 -1
  401. package/dist/parser/tests/Parser.spec.d.ts +3 -9
  402. package/dist/parser/tests/Parser.spec.js +7 -13
  403. package/dist/parser/tests/Parser.spec.js.map +1 -1
  404. package/dist/parser/tests/controlFlow/For.spec.js +83 -75
  405. package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
  406. package/dist/parser/tests/controlFlow/ForEach.spec.js +85 -51
  407. package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
  408. package/dist/parser/tests/controlFlow/If.spec.js +382 -239
  409. package/dist/parser/tests/controlFlow/If.spec.js.map +1 -1
  410. package/dist/parser/tests/controlFlow/While.spec.js +52 -45
  411. package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
  412. package/dist/parser/tests/expression/Additive.spec.js +51 -43
  413. package/dist/parser/tests/expression/Additive.spec.js.map +1 -1
  414. package/dist/parser/tests/expression/ArrayLiterals.spec.js +192 -142
  415. package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +1 -1
  416. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +236 -160
  417. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
  418. package/dist/parser/tests/expression/Boolean.spec.js +41 -34
  419. package/dist/parser/tests/expression/Boolean.spec.js.map +1 -1
  420. package/dist/parser/tests/expression/Call.spec.js +173 -55
  421. package/dist/parser/tests/expression/Call.spec.js.map +1 -1
  422. package/dist/parser/tests/expression/Exponential.spec.js +20 -20
  423. package/dist/parser/tests/expression/Exponential.spec.js.map +1 -1
  424. package/dist/parser/tests/expression/Function.spec.js +291 -282
  425. package/dist/parser/tests/expression/Function.spec.js.map +1 -1
  426. package/dist/parser/tests/expression/Indexing.spec.js +193 -110
  427. package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
  428. package/dist/parser/tests/expression/Multiplicative.spec.js +42 -42
  429. package/dist/parser/tests/expression/Multiplicative.spec.js.map +1 -1
  430. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +260 -115
  431. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
  432. package/dist/parser/tests/expression/PrefixUnary.spec.js +58 -52
  433. package/dist/parser/tests/expression/PrefixUnary.spec.js.map +1 -1
  434. package/dist/parser/tests/expression/Primary.spec.js +76 -60
  435. package/dist/parser/tests/expression/Primary.spec.js.map +1 -1
  436. package/dist/parser/tests/expression/RegexLiteralExpression.spec.d.ts +1 -0
  437. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +171 -0
  438. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -0
  439. package/dist/parser/tests/expression/Relational.spec.js +50 -50
  440. package/dist/parser/tests/expression/Relational.spec.js.map +1 -1
  441. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +31 -31
  442. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +1 -1
  443. package/dist/parser/tests/expression/TemplateStringExpression.spec.js +281 -94
  444. package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
  445. package/dist/parser/tests/expression/TernaryExpression.spec.js +747 -192
  446. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
  447. package/dist/parser/tests/expression/TypeExpression.spec.d.ts +1 -0
  448. package/dist/parser/tests/expression/TypeExpression.spec.js +126 -0
  449. package/dist/parser/tests/expression/TypeExpression.spec.js.map +1 -0
  450. package/dist/parser/tests/expression/UnaryExpression.spec.d.ts +1 -0
  451. package/dist/parser/tests/expression/UnaryExpression.spec.js +52 -0
  452. package/dist/parser/tests/expression/UnaryExpression.spec.js.map +1 -0
  453. package/dist/parser/tests/statement/AssignmentOperators.spec.js +44 -44
  454. package/dist/parser/tests/statement/AssignmentOperators.spec.js.map +1 -1
  455. package/dist/parser/tests/statement/ConstStatement.spec.d.ts +1 -0
  456. package/dist/parser/tests/statement/ConstStatement.spec.js +500 -0
  457. package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -0
  458. package/dist/parser/tests/statement/Continue.spec.d.ts +1 -0
  459. package/dist/parser/tests/statement/Continue.spec.js +119 -0
  460. package/dist/parser/tests/statement/Continue.spec.js.map +1 -0
  461. package/dist/parser/tests/statement/Declaration.spec.js +61 -55
  462. package/dist/parser/tests/statement/Declaration.spec.js.map +1 -1
  463. package/dist/parser/tests/statement/Dim.spec.js +29 -22
  464. package/dist/parser/tests/statement/Dim.spec.js.map +1 -1
  465. package/dist/parser/tests/statement/Enum.spec.d.ts +1 -0
  466. package/dist/parser/tests/statement/Enum.spec.js +744 -0
  467. package/dist/parser/tests/statement/Enum.spec.js.map +1 -0
  468. package/dist/parser/tests/statement/For.spec.d.ts +1 -0
  469. package/dist/parser/tests/statement/For.spec.js +45 -0
  470. package/dist/parser/tests/statement/For.spec.js.map +1 -0
  471. package/dist/parser/tests/statement/ForEach.spec.d.ts +1 -0
  472. package/dist/parser/tests/statement/ForEach.spec.js +36 -0
  473. package/dist/parser/tests/statement/ForEach.spec.js.map +1 -0
  474. package/dist/parser/tests/statement/Function.spec.js +226 -215
  475. package/dist/parser/tests/statement/Function.spec.js.map +1 -1
  476. package/dist/parser/tests/statement/Goto.spec.js +16 -15
  477. package/dist/parser/tests/statement/Goto.spec.js.map +1 -1
  478. package/dist/parser/tests/statement/Increment.spec.js +64 -61
  479. package/dist/parser/tests/statement/Increment.spec.js.map +1 -1
  480. package/dist/parser/tests/statement/InterfaceStatement.spec.d.ts +1 -0
  481. package/dist/parser/tests/statement/InterfaceStatement.spec.js +110 -0
  482. package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -0
  483. package/dist/parser/tests/statement/LibraryStatement.spec.js +22 -22
  484. package/dist/parser/tests/statement/LibraryStatement.spec.js.map +1 -1
  485. package/dist/parser/tests/statement/Misc.spec.js +127 -168
  486. package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
  487. package/dist/parser/tests/statement/PrintStatement.spec.js +133 -114
  488. package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
  489. package/dist/parser/tests/statement/ReturnStatement.spec.js +57 -54
  490. package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
  491. package/dist/parser/tests/statement/Set.spec.js +131 -117
  492. package/dist/parser/tests/statement/Set.spec.js.map +1 -1
  493. package/dist/parser/tests/statement/Stop.spec.js +14 -13
  494. package/dist/parser/tests/statement/Stop.spec.js.map +1 -1
  495. package/dist/parser/tests/statement/Throw.spec.js +11 -8
  496. package/dist/parser/tests/statement/Throw.spec.js.map +1 -1
  497. package/dist/parser/tests/statement/TryCatch.spec.js +26 -15
  498. package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
  499. package/dist/preprocessor/Manifest.d.ts +6 -6
  500. package/dist/preprocessor/Manifest.js +17 -38
  501. package/dist/preprocessor/Manifest.js.map +1 -1
  502. package/dist/preprocessor/Manifest.spec.d.ts +1 -0
  503. package/dist/preprocessor/Manifest.spec.js +78 -103
  504. package/dist/preprocessor/Manifest.spec.js.map +1 -1
  505. package/dist/roku-types/data.json +20347 -0
  506. package/dist/roku-types/index.d.ts +5726 -0
  507. package/dist/roku-types/index.js +11 -0
  508. package/dist/roku-types/index.js.map +1 -0
  509. package/dist/types/ArrayType.d.ts +12 -5
  510. package/dist/types/ArrayType.js +89 -24
  511. package/dist/types/ArrayType.js.map +1 -1
  512. package/dist/types/ArrayType.spec.js +39 -11
  513. package/dist/types/ArrayType.spec.js.map +1 -1
  514. package/dist/types/AssociativeArrayType.d.ts +15 -0
  515. package/dist/types/AssociativeArrayType.js +64 -0
  516. package/dist/types/AssociativeArrayType.js.map +1 -0
  517. package/dist/types/BaseFunctionType.d.ts +10 -0
  518. package/dist/types/BaseFunctionType.js +26 -0
  519. package/dist/types/BaseFunctionType.js.map +1 -0
  520. package/dist/types/BooleanType.d.ts +9 -5
  521. package/dist/types/BooleanType.js +19 -8
  522. package/dist/types/BooleanType.js.map +1 -1
  523. package/dist/types/BooleanType.spec.js +10 -4
  524. package/dist/types/BooleanType.spec.js.map +1 -1
  525. package/dist/types/BscType.d.ts +41 -3
  526. package/dist/types/BscType.js +152 -0
  527. package/dist/types/BscType.js.map +1 -1
  528. package/dist/types/BscTypeKind.d.ts +28 -0
  529. package/dist/types/BscTypeKind.js +33 -0
  530. package/dist/types/BscTypeKind.js.map +1 -0
  531. package/dist/types/BuiltInInterfaceAdder.d.ts +28 -0
  532. package/dist/types/BuiltInInterfaceAdder.js +212 -0
  533. package/dist/types/BuiltInInterfaceAdder.js.map +1 -0
  534. package/dist/types/BuiltInInterfaceAdder.spec.d.ts +1 -0
  535. package/dist/types/BuiltInInterfaceAdder.spec.js +115 -0
  536. package/dist/types/BuiltInInterfaceAdder.spec.js.map +1 -0
  537. package/dist/types/CallFuncableType.d.ts +24 -0
  538. package/dist/types/CallFuncableType.js +91 -0
  539. package/dist/types/CallFuncableType.js.map +1 -0
  540. package/dist/types/ClassType.d.ts +17 -0
  541. package/dist/types/ClassType.js +60 -0
  542. package/dist/types/ClassType.js.map +1 -0
  543. package/dist/types/ClassType.spec.d.ts +1 -0
  544. package/dist/types/ClassType.spec.js +76 -0
  545. package/dist/types/ClassType.spec.js.map +1 -0
  546. package/dist/types/ComponentType.d.ts +22 -0
  547. package/dist/types/ComponentType.js +107 -0
  548. package/dist/types/ComponentType.js.map +1 -0
  549. package/dist/types/DoubleType.d.ts +10 -5
  550. package/dist/types/DoubleType.js +21 -17
  551. package/dist/types/DoubleType.js.map +1 -1
  552. package/dist/types/DoubleType.spec.js +12 -4
  553. package/dist/types/DoubleType.spec.js.map +1 -1
  554. package/dist/types/DynamicType.d.ts +13 -5
  555. package/dist/types/DynamicType.js +26 -5
  556. package/dist/types/DynamicType.js.map +1 -1
  557. package/dist/types/DynamicType.spec.js +16 -5
  558. package/dist/types/DynamicType.spec.js.map +1 -1
  559. package/dist/types/EnumType.d.ts +42 -0
  560. package/dist/types/EnumType.js +98 -0
  561. package/dist/types/EnumType.js.map +1 -0
  562. package/dist/types/EnumType.spec.d.ts +1 -0
  563. package/dist/types/EnumType.spec.js +33 -0
  564. package/dist/types/EnumType.spec.js.map +1 -0
  565. package/dist/types/FloatType.d.ts +10 -5
  566. package/dist/types/FloatType.js +21 -17
  567. package/dist/types/FloatType.js.map +1 -1
  568. package/dist/types/FloatType.spec.js +4 -4
  569. package/dist/types/FloatType.spec.js.map +1 -1
  570. package/dist/types/FunctionType.d.ts +8 -22
  571. package/dist/types/FunctionType.js +25 -63
  572. package/dist/types/FunctionType.js.map +1 -1
  573. package/dist/types/InheritableType.d.ts +29 -0
  574. package/dist/types/InheritableType.js +173 -0
  575. package/dist/types/InheritableType.js.map +1 -0
  576. package/dist/types/InlineInterfaceType.d.ts +5 -0
  577. package/dist/types/InlineInterfaceType.js +17 -0
  578. package/dist/types/InlineInterfaceType.js.map +1 -0
  579. package/dist/types/IntegerType.d.ts +10 -5
  580. package/dist/types/IntegerType.js +21 -17
  581. package/dist/types/IntegerType.js.map +1 -1
  582. package/dist/types/IntegerType.spec.js +8 -4
  583. package/dist/types/IntegerType.spec.js.map +1 -1
  584. package/dist/types/InterfaceType.d.ts +14 -6
  585. package/dist/types/InterfaceType.js +30 -15
  586. package/dist/types/InterfaceType.js.map +1 -1
  587. package/dist/types/InterfaceType.spec.d.ts +1 -0
  588. package/dist/types/InterfaceType.spec.js +227 -0
  589. package/dist/types/InterfaceType.spec.js.map +1 -0
  590. package/dist/types/IntersectionType.d.ts +29 -0
  591. package/dist/types/IntersectionType.js +253 -0
  592. package/dist/types/IntersectionType.js.map +1 -0
  593. package/dist/types/IntersectionType.spec.d.ts +1 -0
  594. package/dist/types/IntersectionType.spec.js +150 -0
  595. package/dist/types/IntersectionType.spec.js.map +1 -0
  596. package/dist/types/InvalidType.d.ts +10 -5
  597. package/dist/types/InvalidType.js +21 -9
  598. package/dist/types/InvalidType.js.map +1 -1
  599. package/dist/types/InvalidType.spec.js +8 -4
  600. package/dist/types/InvalidType.spec.js.map +1 -1
  601. package/dist/types/LongIntegerType.d.ts +10 -5
  602. package/dist/types/LongIntegerType.js +21 -17
  603. package/dist/types/LongIntegerType.js.map +1 -1
  604. package/dist/types/LongIntegerType.spec.js +10 -4
  605. package/dist/types/LongIntegerType.spec.js.map +1 -1
  606. package/dist/types/NamespaceType.d.ts +12 -0
  607. package/dist/types/NamespaceType.js +28 -0
  608. package/dist/types/NamespaceType.js.map +1 -0
  609. package/dist/types/ObjectType.d.ts +12 -5
  610. package/dist/types/ObjectType.js +25 -8
  611. package/dist/types/ObjectType.js.map +1 -1
  612. package/dist/types/ObjectType.spec.js +3 -3
  613. package/dist/types/ObjectType.spec.js.map +1 -1
  614. package/dist/types/ReferenceType.d.ts +123 -0
  615. package/dist/types/ReferenceType.js +720 -0
  616. package/dist/types/ReferenceType.js.map +1 -0
  617. package/dist/types/ReferenceType.spec.d.ts +1 -0
  618. package/dist/types/ReferenceType.spec.js +151 -0
  619. package/dist/types/ReferenceType.spec.js.map +1 -0
  620. package/dist/types/StringType.d.ts +12 -5
  621. package/dist/types/StringType.js +23 -8
  622. package/dist/types/StringType.js.map +1 -1
  623. package/dist/types/StringType.spec.js +3 -3
  624. package/dist/types/StringType.spec.js.map +1 -1
  625. package/dist/types/TypeStatementType.d.ts +18 -0
  626. package/dist/types/TypeStatementType.js +45 -0
  627. package/dist/types/TypeStatementType.js.map +1 -0
  628. package/dist/types/TypedFunctionType.d.ts +34 -0
  629. package/dist/types/TypedFunctionType.js +147 -0
  630. package/dist/types/TypedFunctionType.js.map +1 -0
  631. package/dist/types/TypedFunctionType.spec.d.ts +1 -0
  632. package/dist/types/TypedFunctionType.spec.js +122 -0
  633. package/dist/types/TypedFunctionType.spec.js.map +1 -0
  634. package/dist/types/UninitializedType.d.ts +11 -6
  635. package/dist/types/UninitializedType.js +20 -11
  636. package/dist/types/UninitializedType.js.map +1 -1
  637. package/dist/types/UnionType.d.ts +27 -0
  638. package/dist/types/UnionType.js +193 -0
  639. package/dist/types/UnionType.js.map +1 -0
  640. package/dist/types/UnionType.spec.d.ts +1 -0
  641. package/dist/types/UnionType.spec.js +205 -0
  642. package/dist/types/UnionType.spec.js.map +1 -0
  643. package/dist/types/VoidType.d.ts +11 -5
  644. package/dist/types/VoidType.js +22 -8
  645. package/dist/types/VoidType.js.map +1 -1
  646. package/dist/types/VoidType.spec.js +3 -3
  647. package/dist/types/VoidType.spec.js.map +1 -1
  648. package/dist/types/helper.spec.d.ts +1 -0
  649. package/dist/types/helper.spec.js +174 -0
  650. package/dist/types/helper.spec.js.map +1 -0
  651. package/dist/types/helpers.d.ts +51 -0
  652. package/dist/types/helpers.js +323 -0
  653. package/dist/types/helpers.js.map +1 -0
  654. package/dist/types/index.d.ts +22 -0
  655. package/dist/types/index.js +39 -0
  656. package/dist/types/index.js.map +1 -0
  657. package/dist/types/roFunctionType.d.ts +11 -0
  658. package/dist/types/roFunctionType.js +37 -0
  659. package/dist/types/roFunctionType.js.map +1 -0
  660. package/dist/types/roFunctionType.spec.d.ts +1 -0
  661. package/dist/types/roFunctionType.spec.js +20 -0
  662. package/dist/types/roFunctionType.spec.js.map +1 -0
  663. package/dist/util.d.ts +288 -187
  664. package/dist/util.js +2018 -575
  665. package/dist/util.js.map +1 -1
  666. package/dist/validators/ClassValidator.d.ts +9 -15
  667. package/dist/validators/ClassValidator.js +93 -138
  668. package/dist/validators/ClassValidator.js.map +1 -1
  669. package/package.json +185 -138
  670. package/CHANGELOG.md +0 -1188
  671. package/dist/astUtils/index.d.ts +0 -7
  672. package/dist/astUtils/index.js +0 -26
  673. package/dist/astUtils/index.js.map +0 -1
  674. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.d.ts +0 -7
  675. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.js +0 -63
  676. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.js.map +0 -1
  677. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.js +0 -45
  678. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.js.map +0 -1
  679. package/dist/lexer/index.d.ts +0 -3
  680. package/dist/lexer/index.js +0 -17
  681. package/dist/lexer/index.js.map +0 -1
  682. package/dist/parser/SGTypes.spec.js +0 -351
  683. package/dist/parser/SGTypes.spec.js.map +0 -1
  684. package/dist/parser/index.d.ts +0 -3
  685. package/dist/parser/index.js +0 -16
  686. package/dist/parser/index.js.map +0 -1
  687. package/dist/preprocessor/Chunk.d.ts +0 -82
  688. package/dist/preprocessor/Chunk.js +0 -77
  689. package/dist/preprocessor/Chunk.js.map +0 -1
  690. package/dist/preprocessor/Preprocessor.d.ts +0 -60
  691. package/dist/preprocessor/Preprocessor.js +0 -156
  692. package/dist/preprocessor/Preprocessor.js.map +0 -1
  693. package/dist/preprocessor/Preprocessor.spec.js +0 -152
  694. package/dist/preprocessor/Preprocessor.spec.js.map +0 -1
  695. package/dist/preprocessor/PreprocessorParser.d.ts +0 -61
  696. package/dist/preprocessor/PreprocessorParser.js +0 -194
  697. package/dist/preprocessor/PreprocessorParser.js.map +0 -1
  698. package/dist/preprocessor/PreprocessorParser.spec.js +0 -116
  699. package/dist/preprocessor/PreprocessorParser.spec.js.map +0 -1
  700. package/dist/preprocessor/index.d.ts +0 -3
  701. package/dist/preprocessor/index.js +0 -16
  702. package/dist/preprocessor/index.js.map +0 -1
  703. package/dist/types/CustomType.d.ts +0 -10
  704. package/dist/types/CustomType.js +0 -35
  705. package/dist/types/CustomType.js.map +0 -1
  706. package/dist/types/FunctionType.spec.js +0 -29
  707. package/dist/types/FunctionType.spec.js.map +0 -1
  708. package/dist/types/LazyType.d.ts +0 -15
  709. package/dist/types/LazyType.js +0 -32
  710. package/dist/types/LazyType.js.map +0 -1
  711. /package/dist/{bscPlugin/semanticTokens/SemanticTokensProcessor.spec.d.ts → astUtils/CachedLookups.spec.d.ts} +0 -0
  712. /package/dist/{parser/SGTypes.spec.d.ts → astUtils/Editor.spec.d.ts} +0 -0
  713. /package/dist/{preprocessor/Preprocessor.spec.d.ts → bscPlugin/completions/CompletionsProcessor.spec.d.ts} +0 -0
  714. /package/dist/{preprocessor/PreprocessorParser.spec.d.ts → bscPlugin/definition/DefinitionProvider.spec.d.ts} +0 -0
  715. /package/dist/{types/FunctionType.spec.d.ts → bscPlugin/hover/HoverProcessor.spec.d.ts} +0 -0
package/dist/Scope.js CHANGED
@@ -1,18 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Scope = void 0;
4
- const vscode_languageserver_1 = require("vscode-languageserver");
4
+ /* eslint-disable @typescript-eslint/dot-notation */
5
+ const path = require("path");
5
6
  const chalk_1 = require("chalk");
6
- const DiagnosticMessages_1 = require("./DiagnosticMessages");
7
- const ClassValidator_1 = require("./validators/ClassValidator");
8
- const parser_1 = require("./parser");
7
+ const Parser_1 = require("./parser/Parser");
9
8
  const util_1 = require("./util");
10
- const globalCallables_1 = require("./globalCallables");
11
9
  const Cache_1 = require("./Cache");
12
- const vscode_uri_1 = require("vscode-uri");
13
- const Logger_1 = require("./Logger");
14
10
  const reflection_1 = require("./astUtils/reflection");
15
11
  const SymbolTable_1 = require("./SymbolTable");
12
+ const ReferenceType_1 = require("./types/ReferenceType");
13
+ const UnionType_1 = require("./types/UnionType");
14
+ const AssociativeArrayType_1 = require("./types/AssociativeArrayType");
15
+ const perf_hooks_1 = require("perf_hooks");
16
+ const logging_1 = require("./logging");
17
+ const UninitializedType_1 = require("./types/UninitializedType");
18
+ /**
19
+ * Assign some few factories to the SymbolTable to prevent cyclical imports. This file seems like the most intuitive place to do the linking
20
+ * since Scope will be used by pretty much everything
21
+ */
22
+ SymbolTable_1.SymbolTable.referenceTypeFactory = ReferenceType_1.referenceTypeFactory;
23
+ SymbolTable_1.SymbolTable.unionTypeFactory = UnionType_1.unionTypeFactory;
24
+ SymbolTable_1.SymbolTable.uninitializedTypeFactory = UninitializedType_1.uninitializedTypeFactory;
16
25
  /**
17
26
  * A class to keep track of all declarations within a given scope (like source scope, component scope)
18
27
  */
@@ -22,10 +31,16 @@ class Scope {
22
31
  this.program = program;
23
32
  this._dependencyGraphKey = _dependencyGraphKey;
24
33
  this.cache = new Cache_1.Cache();
34
+ this.useFileCachesForFileLinkLookups = false;
35
+ this.validationMetrics = {
36
+ linkTime: 0,
37
+ validationTime: 0
38
+ };
25
39
  /**
26
- * The list of diagnostics found specifically for this scope. Individual file diagnostics are stored on the files themselves.
40
+ * A list of functions that will be called whenever `unlinkSymbolTable` is called
27
41
  */
28
- this.diagnostics = [];
42
+ this.linkSymbolTableDisposables = [];
43
+ this.symbolsAddedDuringLinking = [];
29
44
  this.isValidated = false;
30
45
  //used for improved logging performance
31
46
  this._debugLogComponentName = `Scope '${chalk_1.default.redBright(this.name)}'`;
@@ -39,8 +54,82 @@ class Scope {
39
54
  * "namea", "namea.nameb", "namea.nameb.namec"
40
55
  */
41
56
  get namespaceLookup() {
57
+ let allFilesValidated = true;
58
+ for (const file of this.getAllFiles()) {
59
+ if ((0, reflection_1.isBrsFile)(file) && !file.hasTypedef) {
60
+ allFilesValidated = allFilesValidated && file.isValidated;
61
+ if (!allFilesValidated) {
62
+ break;
63
+ }
64
+ }
65
+ }
66
+ if (!allFilesValidated) {
67
+ // This is not fit to cache
68
+ // Since the files have not been validated, all namespace info might not have been available
69
+ return this.buildNamespaceLookup();
70
+ }
42
71
  return this.cache.getOrAdd('namespaceLookup', () => this.buildNamespaceLookup());
43
72
  }
73
+ /**
74
+ * A dictionary of namespaces, indexed by the lower case full name of each namespace.
75
+ * If a namespace is declared as "NameA.NameB.NameC", there will be 3 entries in this dictionary,
76
+ * "namea", "namea.nameb", "namea.nameb.namec"
77
+ */
78
+ get namespaceNameSet() {
79
+ return this.cache.getOrAdd('namespaceNameSet', () => {
80
+ const lowerNamespaceNames = new Set();
81
+ this.enumerateBrsFiles((file) => {
82
+ const fileNamespaceLookup = file.getNamespaceLookupObject();
83
+ for (const [lowerNamespaceName, _] of fileNamespaceLookup) {
84
+ lowerNamespaceNames.add(lowerNamespaceName);
85
+ }
86
+ });
87
+ return lowerNamespaceNames;
88
+ });
89
+ }
90
+ /**
91
+ * Get a NamespaceContainer by its name, looking for a fully qualified version first, then global version next if not found
92
+ */
93
+ getNamespace(name, containingNamespace) {
94
+ var _a, _b;
95
+ const nameLower = name === null || name === void 0 ? void 0 : name.toLowerCase();
96
+ const lookup = this.namespaceLookup;
97
+ let ns;
98
+ if (containingNamespace) {
99
+ ns = (_a = lookup.get(`${containingNamespace === null || containingNamespace === void 0 ? void 0 : containingNamespace.toLowerCase()}.${nameLower}`)) === null || _a === void 0 ? void 0 : _a.firstInstance;
100
+ }
101
+ //if we couldn't find the namespace by its full namespaced name, look for a global version
102
+ if (!ns) {
103
+ ns = (_b = lookup.get(nameLower)) === null || _b === void 0 ? void 0 : _b.firstInstance;
104
+ }
105
+ return ns;
106
+ }
107
+ /**
108
+ * Get a NamespaceContainer by its name, looking for a fully qualified version first, then global version next if not found
109
+ */
110
+ getNamespacesWithRoot(rootName, containingNamespace) {
111
+ const nameLower = rootName === null || rootName === void 0 ? void 0 : rootName.toLowerCase();
112
+ const lookup = this.namespaceLookup;
113
+ const lookupKeys = [...lookup.keys()];
114
+ let lookupName = nameLower;
115
+ if (containingNamespace) {
116
+ lookupName = `${containingNamespace === null || containingNamespace === void 0 ? void 0 : containingNamespace.toLowerCase()}.${nameLower}`;
117
+ }
118
+ const nsList = lookupKeys.filter(key => key === lookupName).map(key => lookup.get(key));
119
+ return nsList;
120
+ }
121
+ /**
122
+ * Get a NamespaceContainer by its name, looking for a fully qualified version first, then global version next if not found
123
+ */
124
+ getFirstNamespaceWithRoot(rootName, containingNamespace) {
125
+ var _a;
126
+ const nameLower = rootName === null || rootName === void 0 ? void 0 : rootName.toLowerCase();
127
+ let lookupName = nameLower;
128
+ if (containingNamespace) {
129
+ lookupName = `${containingNamespace === null || containingNamespace === void 0 ? void 0 : containingNamespace.toLowerCase()}.${nameLower}`;
130
+ }
131
+ return (_a = this.namespaceLookup.get(lookupName)) === null || _a === void 0 ? void 0 : _a.firstInstance;
132
+ }
44
133
  /**
45
134
  * Get the class with the specified name.
46
135
  * @param className - The class name, including the namespace of the class if possible
@@ -50,29 +139,214 @@ class Scope {
50
139
  var _a;
51
140
  return (_a = this.getClassFileLink(className, containingNamespace)) === null || _a === void 0 ? void 0 : _a.item;
52
141
  }
142
+ /**
143
+ * Get the interface with the specified name.
144
+ * @param ifaceName - The interface name, including the namespace of the interface if possible
145
+ * @param containingNamespace - The namespace used to resolve relative interface names. (i.e. the namespace around the current statement trying to find a interface)
146
+ */
147
+ getInterface(ifaceName, containingNamespace) {
148
+ var _a;
149
+ return (_a = this.getInterfaceFileLink(ifaceName, containingNamespace)) === null || _a === void 0 ? void 0 : _a.item;
150
+ }
151
+ /**
152
+ * Get the enum with the specified name.
153
+ * @param enumName - The enum name, including the namespace if possible
154
+ * @param containingNamespace - The namespace used to resolve relative enum names. (i.e. the namespace around the current statement trying to find an enum)
155
+ */
156
+ getEnum(enumName, containingNamespace) {
157
+ var _a;
158
+ return (_a = this.getEnumFileLink(enumName, containingNamespace)) === null || _a === void 0 ? void 0 : _a.item;
159
+ }
160
+ getFileLinkFromFileMap(cachedMapName, itemName, containingNamespace) {
161
+ var _a;
162
+ let result;
163
+ const fullNameLower = (_a = util_1.util.getFullyQualifiedClassName(itemName, containingNamespace)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
164
+ const itemNameLower = itemName === null || itemName === void 0 ? void 0 : itemName.toLowerCase();
165
+ if (fullNameLower) {
166
+ this.enumerateBrsFilesWithBreak((file) => {
167
+ let stmt = file['_cachedLookups'][cachedMapName].get(fullNameLower);
168
+ if (stmt) {
169
+ result = { item: stmt, file: file };
170
+ }
171
+ return !!stmt;
172
+ });
173
+ }
174
+ if (!result && itemNameLower && fullNameLower !== itemNameLower) {
175
+ this.enumerateBrsFilesWithBreak((file) => {
176
+ let stmt = file['_cachedLookups'][cachedMapName].get(itemNameLower);
177
+ if (stmt) {
178
+ result = { item: stmt, file: file };
179
+ }
180
+ return !!stmt;
181
+ });
182
+ }
183
+ return result;
184
+ }
53
185
  /**
54
186
  * Get a class and its containing file by the class name
55
187
  * @param className - The class name, including the namespace of the class if possible
56
188
  * @param containingNamespace - The namespace used to resolve relative class names. (i.e. the namespace around the current statement trying to find a class)
57
189
  */
58
190
  getClassFileLink(className, containingNamespace) {
59
- const lowerClassName = className === null || className === void 0 ? void 0 : className.toLowerCase();
191
+ var _a;
192
+ if (this.useFileCachesForFileLinkLookups) {
193
+ return this.getFileLinkFromFileMap('classStatementMap', className, containingNamespace);
194
+ }
195
+ const lowerName = className === null || className === void 0 ? void 0 : className.toLowerCase();
196
+ const fullNameLower = (_a = util_1.util.getFullyQualifiedClassName(lowerName, containingNamespace)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
60
197
  const classMap = this.getClassMap();
61
- let cls = classMap.get(util_1.util.getFullyQualifiedClassName(lowerClassName, containingNamespace === null || containingNamespace === void 0 ? void 0 : containingNamespace.toLowerCase()));
198
+ let cls = classMap.get(fullNameLower);
62
199
  //if we couldn't find the class by its full namespaced name, look for a global class with that name
63
- if (!cls) {
64
- cls = classMap.get(lowerClassName);
200
+ if (!cls && lowerName && lowerName !== fullNameLower) {
201
+ cls = classMap.get(lowerName);
65
202
  }
66
203
  return cls;
67
204
  }
68
205
  /**
69
- * Tests if a class exists with the specified name
70
- * @param className - the all-lower-case namespace-included class name
71
- * @param containingNamespace - The namespace used to resolve relative class names. (i.e. the namespace around the current statement trying to find a class)
72
- */
206
+ * Get an interface and its containing file by the interface name
207
+ * @param ifaceName - The interface name, including the namespace of the interface if possible
208
+ * @param containingNamespace - The namespace used to resolve relative interface names. (i.e. the namespace around the current statement trying to find a interface)
209
+ */
210
+ getInterfaceFileLink(ifaceName, containingNamespace) {
211
+ var _a;
212
+ if (this.useFileCachesForFileLinkLookups) {
213
+ return this.getFileLinkFromFileMap('interfaceStatementMap', ifaceName, containingNamespace);
214
+ }
215
+ const lowerName = ifaceName === null || ifaceName === void 0 ? void 0 : ifaceName.toLowerCase();
216
+ const fullNameLower = (_a = util_1.util.getFullyQualifiedClassName(lowerName, containingNamespace)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
217
+ const ifaceMap = this.getInterfaceMap();
218
+ let iface = ifaceMap.get(fullNameLower);
219
+ //if we couldn't find the iface by its full namespaced name, look for a global class with that name
220
+ if (!iface && lowerName && lowerName !== fullNameLower) {
221
+ iface = ifaceMap.get(lowerName);
222
+ }
223
+ return iface;
224
+ }
225
+ /**
226
+ * Get an Enum and its containing file by the Enum name
227
+ * @param enumName - The Enum name, including the namespace of the enum if possible
228
+ * @param containingNamespace - The namespace used to resolve relative enum names. (i.e. the namespace around the current statement trying to find a enum)
229
+ */
230
+ getEnumFileLink(enumName, containingNamespace) {
231
+ var _a;
232
+ if (this.useFileCachesForFileLinkLookups) {
233
+ return this.getFileLinkFromFileMap('enumStatementMap', enumName, containingNamespace);
234
+ }
235
+ const lowerName = enumName === null || enumName === void 0 ? void 0 : enumName.toLowerCase();
236
+ const fullNameLower = (_a = util_1.util.getFullyQualifiedClassName(lowerName, containingNamespace)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
237
+ const enumMap = this.getEnumMap();
238
+ let enumeration = enumMap.get(fullNameLower);
239
+ //if we couldn't find the enum by its full namespaced name, look for a global enum with that name
240
+ if (!enumeration && lowerName && lowerName !== fullNameLower) {
241
+ enumeration = enumMap.get(lowerName);
242
+ }
243
+ return enumeration;
244
+ }
245
+ /**
246
+ * Get an Enum and its containing file by the Enum name
247
+ * @param enumMemberName - The Enum name, including the namespace of the enum if possible
248
+ * @param containingNamespace - The namespace used to resolve relative enum names. (i.e. the namespace around the current statement trying to find a enum)
249
+ */
250
+ getEnumMemberFileLink(enumMemberName, containingNamespace) {
251
+ var _a, _b;
252
+ let lowerNameParts = (_a = enumMemberName === null || enumMemberName === void 0 ? void 0 : enumMemberName.toLowerCase()) === null || _a === void 0 ? void 0 : _a.split('.');
253
+ let memberName = (_b = lowerNameParts === null || lowerNameParts === void 0 ? void 0 : lowerNameParts.splice(lowerNameParts.length - 1, 1)) === null || _b === void 0 ? void 0 : _b[0];
254
+ let lowerName = lowerNameParts === null || lowerNameParts === void 0 ? void 0 : lowerNameParts.join('.').toLowerCase();
255
+ const enumMap = this.getEnumMap();
256
+ let enumeration = enumMap.get(util_1.util.getFullyQualifiedClassName(lowerName, containingNamespace === null || containingNamespace === void 0 ? void 0 : containingNamespace.toLowerCase()));
257
+ //if we couldn't find the enum by its full namespaced name, look for a global enum with that name
258
+ if (!enumeration) {
259
+ enumeration = enumMap.get(lowerName);
260
+ }
261
+ if (enumeration) {
262
+ let member = enumeration.item.findChild((child) => { var _a; return (0, reflection_1.isEnumMemberStatement)(child) && ((_a = child.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === memberName; });
263
+ return member ? { item: member, file: enumeration.file } : undefined;
264
+ }
265
+ }
266
+ /**
267
+ * Get a constant and its containing file by the constant name
268
+ * @param constName - The constant name, including the namespace of the constant if possible
269
+ * @param containingNamespace - The namespace used to resolve relative constant names. (i.e. the namespace around the current statement trying to find a constant)
270
+ */
271
+ getConstFileLink(constName, containingNamespace) {
272
+ var _a;
273
+ if (this.useFileCachesForFileLinkLookups) {
274
+ return this.getFileLinkFromFileMap('constStatementMap', constName, containingNamespace);
275
+ }
276
+ const lowerName = constName === null || constName === void 0 ? void 0 : constName.toLowerCase();
277
+ const fullNameLower = (_a = util_1.util.getFullyQualifiedClassName(lowerName, containingNamespace)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
278
+ const constMap = this.getConstMap();
279
+ let result = constMap.get(fullNameLower);
280
+ //if we couldn't find the constant by its full namespaced name, look for a global constant with that name
281
+ if (!result && lowerName !== fullNameLower) {
282
+ result = constMap.get(lowerName);
283
+ }
284
+ return result;
285
+ }
286
+ getAllFileLinks(name, containingNamespace, includeNamespaces = false, includeNameShadowsOutsideNamespace = false) {
287
+ var _a;
288
+ let links = [];
289
+ links.push(this.getClassFileLink(name, containingNamespace), this.getInterfaceFileLink(name, containingNamespace), this.getConstFileLink(name, containingNamespace), this.getEnumFileLink(name, containingNamespace));
290
+ if (includeNameShadowsOutsideNamespace && containingNamespace) {
291
+ links.push(this.getClassFileLink(name), this.getInterfaceFileLink(name), this.getConstFileLink(name), this.getEnumFileLink(name));
292
+ }
293
+ if (includeNamespaces) {
294
+ const nameSpaceContainer = this.getFirstNamespaceWithRoot(name, containingNamespace);
295
+ if (nameSpaceContainer) {
296
+ links.push({ item: (_a = nameSpaceContainer.namespaceStatements) === null || _a === void 0 ? void 0 : _a[0], file: nameSpaceContainer === null || nameSpaceContainer === void 0 ? void 0 : nameSpaceContainer.file });
297
+ }
298
+ }
299
+ const fullNameLower = (containingNamespace ? `${containingNamespace}.${name}` : name).toLowerCase();
300
+ const callable = this.getCallableByName(name);
301
+ if (callable) {
302
+ if ((!callable.hasNamespace && includeNameShadowsOutsideNamespace) || callable.getName(Parser_1.ParseMode.BrighterScript).toLowerCase() === fullNameLower) {
303
+ // this callable has no namespace, or has same namespace
304
+ links.push({ item: callable.functionStatement, file: callable.file });
305
+ }
306
+ }
307
+ // remove empty links
308
+ return links.filter(link => link);
309
+ }
310
+ /**
311
+ * Get a map of all enums by their member name.
312
+ * The keys are lower-case fully-qualified paths to the enum and its member. For example:
313
+ * namespace.enum.value
314
+ */
315
+ getEnumMemberMap() {
316
+ return this.cache.getOrAdd('enumMemberMap', () => {
317
+ const result = new Map();
318
+ for (const [key, eenum] of this.getEnumMap()) {
319
+ for (const member of eenum.item.getMembers()) {
320
+ result.set(`${key}.${member.name.toLowerCase()}`, member);
321
+ }
322
+ }
323
+ return result;
324
+ });
325
+ }
326
+ /**
327
+ * Tests if a class exists with the specified name
328
+ * @param className - the all-lower-case namespace-included class name
329
+ * @param namespaceName - The namespace used to resolve relative class names. (i.e. the namespace around the current statement trying to find a class)
330
+ */
73
331
  hasClass(className, namespaceName) {
74
332
  return !!this.getClass(className, namespaceName);
75
333
  }
334
+ /**
335
+ * Tests if an interface exists with the specified name
336
+ * @param ifaceName - the all-lower-case namespace-included interface name
337
+ * @param namespaceName - the current namespace name
338
+ */
339
+ hasInterface(ifaceName, namespaceName) {
340
+ return !!this.getInterface(ifaceName, namespaceName);
341
+ }
342
+ /**
343
+ * Tests if an enum exists with the specified name
344
+ * @param enumName - the all-lower-case namespace-included enum name
345
+ * @param namespaceName - the current namespace name
346
+ */
347
+ hasEnum(enumName, namespaceName) {
348
+ return !!this.getEnum(enumName, namespaceName);
349
+ }
76
350
  /**
77
351
  * A dictionary of all classes in this scope. This includes namespaced classes always with their full name.
78
352
  * The key is stored in lower case
@@ -81,13 +355,33 @@ class Scope {
81
355
  return this.cache.getOrAdd('classMap', () => {
82
356
  const map = new Map();
83
357
  this.enumerateBrsFiles((file) => {
84
- var _a;
85
- if (reflection_1.isBrsFile(file)) {
86
- for (let cls of file.parser.references.classStatements) {
87
- const lowerClassName = (_a = cls.getName(parser_1.ParseMode.BrighterScript)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
358
+ if ((0, reflection_1.isBrsFile)(file)) {
359
+ for (let cls of file['_cachedLookups'].classStatements) {
360
+ const className = cls.getName(Parser_1.ParseMode.BrighterScript);
361
+ //only track classes with a defined name (i.e. exclude nameless malformed classes)
362
+ if (className) {
363
+ map.set(className.toLowerCase(), { item: cls, file: file });
364
+ }
365
+ }
366
+ }
367
+ });
368
+ return map;
369
+ });
370
+ }
371
+ /**
372
+ * A dictionary of all Interfaces in this scope. This includes namespaced Interfaces always with their full name.
373
+ * The key is stored in lower case
374
+ */
375
+ getInterfaceMap() {
376
+ return this.cache.getOrAdd('interfaceMap', () => {
377
+ const map = new Map();
378
+ this.enumerateBrsFiles((file) => {
379
+ if ((0, reflection_1.isBrsFile)(file)) {
380
+ for (let iface of file['_cachedLookups'].interfaceStatements) {
381
+ const ifaceName = iface.getName(Parser_1.ParseMode.BrighterScript);
88
382
  //only track classes with a defined name (i.e. exclude nameless malformed classes)
89
- if (lowerClassName) {
90
- map.set(lowerClassName, { item: cls, file: file });
383
+ if (ifaceName) {
384
+ map.set(ifaceName.toLowerCase(), { item: iface, file: file });
91
385
  }
92
386
  }
93
387
  }
@@ -95,6 +389,42 @@ class Scope {
95
389
  return map;
96
390
  });
97
391
  }
392
+ /**
393
+ * A dictionary of all enums in this scope. This includes namespaced enums always with their full name.
394
+ * The key is stored in lower case
395
+ */
396
+ getEnumMap() {
397
+ return this.cache.getOrAdd('enumMap', () => {
398
+ const map = new Map();
399
+ this.enumerateBrsFiles((file) => {
400
+ for (let enumStmt of file['_cachedLookups'].enumStatements) {
401
+ //only track enums with a defined name (i.e. exclude nameless malformed enums)
402
+ if (enumStmt.fullName) {
403
+ map.set(enumStmt.fullName.toLowerCase(), { item: enumStmt, file: file });
404
+ }
405
+ }
406
+ });
407
+ return map;
408
+ });
409
+ }
410
+ /**
411
+ * A dictionary of all constants in this scope. This includes namespaced constants always with their full name.
412
+ * The key is stored in lower case
413
+ */
414
+ getConstMap() {
415
+ return this.cache.getOrAdd('constMap', () => {
416
+ const map = new Map();
417
+ this.enumerateBrsFiles((file) => {
418
+ for (let stmt of file['_cachedLookups'].constStatements) {
419
+ //only track enums with a defined name (i.e. exclude nameless malformed enums)
420
+ if (stmt.fullName) {
421
+ map.set(stmt.fullName.toLowerCase(), { item: stmt, file: file });
422
+ }
423
+ }
424
+ });
425
+ return map;
426
+ });
427
+ }
98
428
  onDependenciesChanged(event) {
99
429
  this.logDebug('invalidated because dependency graph said [', event.sourceKey, '] changed');
100
430
  this.invalidate();
@@ -113,7 +443,7 @@ class Scope {
113
443
  isKnownNamespace(namespaceName) {
114
444
  let namespaceNameLower = namespaceName.toLowerCase();
115
445
  this.enumerateBrsFiles((file) => {
116
- for (let namespace of file.parser.references.namespaceStatements) {
446
+ for (let namespace of file['_cachedLookups'].namespaceStatements) {
117
447
  let loopNamespaceNameLower = namespace.name.toLowerCase();
118
448
  if (loopNamespaceNameLower === namespaceNameLower || loopNamespaceNameLower.startsWith(namespaceNameLower + '.')) {
119
449
  return true;
@@ -152,20 +482,23 @@ class Scope {
152
482
  this.invalidate();
153
483
  }
154
484
  /**
155
- * Get the file with the specified pkgPath
156
- * @param filePath can be a srcPath, a pkgPath, or a destPath (same as pkgPath but without `pkg:/`)
485
+ * Get the file from this scope with the given path.
486
+ * @param filePath can be a srcPath or destPath
157
487
  * @param normalizePath should this function repair and standardize the path? Passing false should have a performance boost if you can guarantee your path is already sanitized
158
488
  */
159
- getFile(srcPath, normalizePath = true) {
160
- if (normalizePath) {
161
- srcPath = util_1.standardizePath `${srcPath}`;
489
+ getFile(filePath, normalizePath = true) {
490
+ if (typeof filePath !== 'string') {
491
+ return undefined;
162
492
  }
163
- let files = this.getAllFiles();
164
- for (let file of files) {
165
- if (file.srcPath === srcPath) {
166
- return file;
493
+ const key = path.isAbsolute(filePath) ? 'srcPath' : 'destPath';
494
+ let map = this.cache.getOrAdd('fileMaps-srcPath', () => {
495
+ const result = new Map();
496
+ for (const file of this.getAllFiles()) {
497
+ result.set(file[key].toLowerCase(), file);
167
498
  }
168
- }
499
+ return result;
500
+ });
501
+ return map.get((normalizePath ? util_1.util.standardizePath(filePath) : filePath).toLowerCase());
169
502
  }
170
503
  /**
171
504
  * Get the list of files referenced by this scope that are actually loaded in the program.
@@ -186,41 +519,50 @@ class Scope {
186
519
  for (let dependency of dependencies) {
187
520
  //load components by their name
188
521
  if (dependency.startsWith('component:')) {
189
- let comp = this.program.getComponent(dependency.replace(/$component:/, ''));
522
+ let comp = this.program.getComponent(dependency.replace(/^component:/, ''));
190
523
  if (comp) {
191
524
  result.push(comp.file);
192
525
  }
193
526
  }
194
527
  else {
195
- let file = this.program.getFile(dependency, false);
528
+ let file = this.program.getFile(dependency);
196
529
  if (file) {
197
530
  result.push(file);
198
531
  }
199
532
  }
200
533
  }
201
- this.logDebug('getAllFiles', () => result.map(x => x.pkgPath));
202
534
  return result;
203
535
  });
204
536
  }
205
537
  /**
206
- * Get the list of errors for this scope. It's calculated on the fly, so
207
- * call this sparingly.
538
+ * Gets a list of all files in this scope, but not imported files, and not from ancestor scopes
208
539
  */
209
- getDiagnostics() {
210
- let diagnosticLists = [this.diagnostics];
211
- //add diagnostics from every referenced file
212
- this.enumerateOwnFiles((file) => {
213
- diagnosticLists.push(file.getDiagnostics());
214
- });
215
- let allDiagnostics = Array.prototype.concat.apply([], diagnosticLists);
216
- let filteredDiagnostics = allDiagnostics.filter((x) => {
217
- return !util_1.util.diagnosticIsSuppressed(x);
540
+ getImmediateFiles() {
541
+ return this.cache.getOrAdd('getImmediateFiles', () => {
542
+ let result = [];
543
+ if ((0, reflection_1.isXmlScope)(this)) {
544
+ result.push(this.xmlFile);
545
+ }
546
+ let dependencies = this.dependencyGraph.getImmediateDependencies(this.dependencyGraphKey);
547
+ for (let dependency of dependencies) {
548
+ //load components by their name
549
+ if (dependency.startsWith('component:')) {
550
+ let comp = this.program.getComponent(dependency.replace(/^component:/, ''));
551
+ if (comp) {
552
+ result.push(...comp.scope.getImmediateFiles());
553
+ result.push(comp.file);
554
+ }
555
+ }
556
+ else {
557
+ let file = this.program.getFile(dependency);
558
+ if (file) {
559
+ result.push(file);
560
+ }
561
+ }
562
+ }
563
+ this.logDebug('getImmediateFiles', () => result.map(x => x.destPath));
564
+ return result;
218
565
  });
219
- //filter out diangostics that match any of the comment flags
220
- return filteredDiagnostics;
221
- }
222
- addDiagnostics(diagnostics) {
223
- this.diagnostics.push(...diagnostics);
224
566
  }
225
567
  /**
226
568
  * Get the list of callables available in this scope (either declared in this scope or in a parent scope)
@@ -238,16 +580,30 @@ class Scope {
238
580
  /**
239
581
  * Get the callable with the specified name.
240
582
  * If there are overridden callables with the same name, the closest callable to this scope is returned
241
- * @param name
242
583
  */
243
584
  getCallableByName(name) {
244
- let lowerName = name.toLowerCase();
245
- let callables = this.getAllCallables();
246
- for (let callable of callables) {
247
- if (callable.callable.getName(parser_1.ParseMode.BrighterScript).toLowerCase() === lowerName) {
248
- return callable.callable;
585
+ return this.getCallableMap().get(name.toLowerCase());
586
+ }
587
+ getCallableMap() {
588
+ return this.cache.getOrAdd('callableMap', () => {
589
+ var _a, _b;
590
+ const result = new Map();
591
+ for (let callable of this.getAllCallables()) {
592
+ const callableName = (_a = callable.callable.getName(Parser_1.ParseMode.BrighterScript)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
593
+ result.set(callableName, callable.callable);
594
+ result.set(
595
+ // Split by `.` and check the last term to consider namespaces.
596
+ (_b = callableName.split('.').pop()) === null || _b === void 0 ? void 0 : _b.toLowerCase(), callable.callable);
249
597
  }
250
- }
598
+ return result;
599
+ });
600
+ }
601
+ getCallableContainerMap() {
602
+ return this.cache.getOrAdd('callableContainerMap', () => {
603
+ let callables = this.getAllCallables();
604
+ //get a list of all callables, indexed by their lower case names
605
+ return util_1.util.getCallableContainersByLowerName(callables);
606
+ });
251
607
  }
252
608
  /**
253
609
  * Iterate over Brs files not shadowed by typedefs
@@ -256,11 +612,25 @@ class Scope {
256
612
  const files = this.getAllFiles();
257
613
  for (const file of files) {
258
614
  //only brs files without a typedef
259
- if (reflection_1.isBrsFile(file) && !file.hasTypedef) {
615
+ if ((0, reflection_1.isBrsFile)(file) && !file.hasTypedef) {
260
616
  callback(file);
261
617
  }
262
618
  }
263
619
  }
620
+ /**
621
+ * Iterate over Brs files not shadowed by typedefs
622
+ */
623
+ enumerateBrsFilesWithBreak(callback) {
624
+ const files = this.getAllFiles();
625
+ for (const file of files) {
626
+ //only brs files without a typedef
627
+ if ((0, reflection_1.isBrsFile)(file) && !file.hasTypedef) {
628
+ if (callback(file)) {
629
+ break;
630
+ }
631
+ }
632
+ }
633
+ }
264
634
  /**
265
635
  * Call a function for each file directly included in this scope (excluding files found only in parent scopes).
266
636
  */
@@ -268,7 +638,7 @@ class Scope {
268
638
  const files = this.getOwnFiles();
269
639
  for (const file of files) {
270
640
  //either XML components or files without a typedef
271
- if (reflection_1.isXmlFile(file) || !file.hasTypedef) {
641
+ if ((0, reflection_1.isXmlFile)(file) || ((0, reflection_1.isBrsFile)(file) && !file.hasTypedef)) {
272
642
  callback(file);
273
643
  }
274
644
  }
@@ -279,14 +649,16 @@ class Scope {
279
649
  */
280
650
  getOwnCallables() {
281
651
  let result = [];
282
- this.logDebug('getOwnCallables() files: ', () => this.getOwnFiles().map(x => x.pkgPath));
283
652
  //get callables from own files
284
653
  this.enumerateOwnFiles((file) => {
285
- for (let callable of file.callables) {
286
- result.push({
287
- callable: callable,
288
- scope: this
289
- });
654
+ var _a;
655
+ if ((0, reflection_1.isBrsFile)(file)) {
656
+ for (let callable of (_a = file === null || file === void 0 ? void 0 : file.callables) !== null && _a !== void 0 ? _a : []) {
657
+ result.push({
658
+ callable: callable,
659
+ scope: this
660
+ });
661
+ }
290
662
  }
291
663
  });
292
664
  return result;
@@ -295,55 +667,21 @@ class Scope {
295
667
  * Builds a tree of namespace objects
296
668
  */
297
669
  buildNamespaceLookup() {
298
- let namespaceLookup = {};
670
+ let namespaceLookup = new Map();
299
671
  this.enumerateBrsFiles((file) => {
300
- var _a;
301
- for (let namespace of file.parser.references.namespaceStatements) {
302
- //TODO should we handle non-brighterscript?
303
- let name = namespace.nameExpression.getName(parser_1.ParseMode.BrighterScript);
304
- let nameParts = name.split('.');
305
- let loopName = null;
306
- //ensure each namespace section is represented in the results
307
- //(so if the namespace name is A.B.C, this will make an entry for "A", an entry for "A.B", and an entry for "A.B.C"
308
- for (let part of nameParts) {
309
- loopName = loopName === null ? part : `${loopName}.${part}`;
310
- let lowerLoopName = loopName.toLowerCase();
311
- namespaceLookup[lowerLoopName] = (_a = namespaceLookup[lowerLoopName]) !== null && _a !== void 0 ? _a : {
312
- file: file,
313
- fullName: loopName,
314
- nameRange: namespace.nameExpression.range,
315
- lastPartName: part,
316
- namespaces: {},
317
- classStatements: {},
318
- functionStatements: {},
319
- statements: [],
320
- symbolTable: new SymbolTable_1.SymbolTable(this.symbolTable)
672
+ const fileNamespaceLookup = file.getNamespaceLookupObject();
673
+ for (const [lowerNamespaceName, nsContainer] of fileNamespaceLookup) {
674
+ if (!namespaceLookup.has(lowerNamespaceName)) {
675
+ const newScopeNsContainer = {
676
+ namespaceContainers: [],
677
+ symbolTable: new SymbolTable_1.SymbolTable(`Namespace Scope Aggregate: '${nsContainer.fullName}'`),
678
+ firstInstance: nsContainer
321
679
  };
680
+ namespaceLookup.set(lowerNamespaceName, newScopeNsContainer);
322
681
  }
323
- let ns = namespaceLookup[name.toLowerCase()];
324
- ns.statements.push(...namespace.body.statements);
325
- for (let statement of namespace.body.statements) {
326
- if (reflection_1.isClassStatement(statement) && statement.name) {
327
- ns.classStatements[statement.name.text.toLowerCase()] = statement;
328
- }
329
- else if (reflection_1.isFunctionStatement(statement) && statement.name) {
330
- ns.functionStatements[statement.name.text.toLowerCase()] = statement;
331
- }
332
- }
333
- // Merges all the symbol tables of the namespace statements into the new symbol table created above.
334
- // Set those symbol tables to have this new merged table as a parent
335
- ns.symbolTable.mergeSymbolTable(namespace.symbolTable);
336
- }
337
- //associate child namespaces with their parents
338
- for (let key in namespaceLookup) {
339
- let ns = namespaceLookup[key];
340
- let parts = ns.fullName.split('.');
341
- if (parts.length > 1) {
342
- //remove the last part
343
- parts.pop();
344
- let parentName = parts.join('.');
345
- namespaceLookup[parentName.toLowerCase()].namespaces[ns.lastPartName.toLowerCase()] = ns;
346
- }
682
+ const scopeNsContainer = namespaceLookup.get(lowerNamespaceName);
683
+ scopeNsContainer.symbolTable.mergeSymbolTable(nsContainer.symbolTable);
684
+ scopeNsContainer.namespaceContainers.push(nsContainer);
347
685
  }
348
686
  });
349
687
  return namespaceLookup;
@@ -351,58 +689,70 @@ class Scope {
351
689
  getAllNamespaceStatements() {
352
690
  let result = [];
353
691
  this.enumerateBrsFiles((file) => {
354
- result.push(...file.parser.references.namespaceStatements);
692
+ result.push(...file['_cachedLookups'].namespaceStatements);
355
693
  });
356
694
  return result;
357
695
  }
358
696
  logDebug(...args) {
359
697
  this.program.logger.debug(this._debugLogComponentName, ...args);
360
698
  }
361
- validate() {
362
- this.program.logger.time(Logger_1.LogLevel.debug, [this._debugLogComponentName, 'validate()'], () => {
699
+ shouldValidate(validationOptions = { force: false }) {
700
+ var _a;
701
+ //if this scope is already validated, no need to revalidate
702
+ if (this.isValidated === true && !validationOptions.force) {
703
+ this.logDebug('validate(): already validated');
704
+ return false;
705
+ }
706
+ if (!validationOptions.initialValidation && ((_a = validationOptions.filesToBeValidatedInScopeContext) === null || _a === void 0 ? void 0 : _a.size) === 0) {
707
+ // There was no need to validate this scope.
708
+ this.isValidated = true;
709
+ return false;
710
+ }
711
+ return true;
712
+ }
713
+ validate(validationOptions = { force: false }) {
714
+ var _a;
715
+ this.validationMetrics = {
716
+ linkTime: 0,
717
+ validationTime: 0
718
+ };
719
+ //if this scope is already validated, no need to revalidate
720
+ if (!this.shouldValidate(validationOptions)) {
721
+ this.logDebug('validate(): already validated');
722
+ // There was no need to validate this scope.
723
+ this.isValidated = true;
724
+ return false;
725
+ }
726
+ this.useFileCachesForFileLinkLookups = !validationOptions.initialValidation;
727
+ this.program.logger.time(logging_1.LogLevel.debug, [this._debugLogComponentName, 'validate()'], () => {
728
+ var _a;
363
729
  let parentScope = this.getParentScope();
364
730
  //validate our parent before we validate ourself
365
- if ((parentScope === null || parentScope === void 0 ? void 0 : parentScope.isValidated) === false) {
731
+ if (parentScope && parentScope.isValidated === false) {
366
732
  this.logDebug('validate(): validating parent first');
367
- parentScope.validate();
733
+ parentScope.validate(validationOptions);
368
734
  }
369
- //clear the scope's errors list (we will populate them from this method)
370
- this.diagnostics = [];
371
- // link the symbol table
735
+ //Since statements from files are shared across multiple scopes, we need to link those statements to the current scope
736
+ let t0 = perf_hooks_1.performance.now();
372
737
  this.linkSymbolTable();
373
- let callables = this.getAllCallables();
374
- //sort the callables by filepath and then method name, so the errors will be consistent
375
- callables = callables.sort((a, b) => {
376
- return (
377
- //sort by path
378
- a.callable.file.srcPath.localeCompare(b.callable.file.srcPath) ||
379
- //then sort by method name
380
- a.callable.name.localeCompare(b.callable.name));
381
- });
382
- //get a list of all callables, indexed by their lower case names
383
- let callableContainerMap = util_1.util.getCallableContainersByLowerName(callables);
384
- this._validate(callableContainerMap);
385
- // unlink the symbol table so it can't be accessed from the wrong scope
738
+ this.validationMetrics.linkTime = perf_hooks_1.performance.now() - t0;
739
+ const scopeValidateEvent = {
740
+ program: this.program,
741
+ scope: this,
742
+ changedFiles: (_a = validationOptions === null || validationOptions === void 0 ? void 0 : validationOptions.changedFiles) !== null && _a !== void 0 ? _a : [],
743
+ changedSymbols: validationOptions === null || validationOptions === void 0 ? void 0 : validationOptions.changedSymbols
744
+ };
745
+ t0 = perf_hooks_1.performance.now();
746
+ this.program.plugins.emit('validateScope', scopeValidateEvent);
747
+ this.validationMetrics.validationTime = perf_hooks_1.performance.now() - t0;
748
+ //unlink all symbol tables from this scope (so they don't accidentally stick around)
386
749
  this.unlinkSymbolTable();
750
+ this.isValidated = true;
387
751
  });
388
- }
389
- _validate(callableContainerMap) {
390
- //find all duplicate function declarations
391
- this.diagnosticFindDuplicateFunctionDeclarations(callableContainerMap);
392
- //detect missing and incorrect-case script imports
393
- this.diagnosticValidateScriptImportPaths();
394
- //enforce a series of checks on the bodies of class methods
395
- this.validateClasses();
396
- //do many per-file checks
397
- this.enumerateBrsFiles((file) => {
398
- this.diagnosticDetectCallsToUnknownFunctions(file, callableContainerMap);
399
- this.diagnosticDetectFunctionCallsWithWrongParamCount(file, callableContainerMap);
400
- this.diagnosticDetectShadowedLocalVars(file, callableContainerMap);
401
- this.diagnosticDetectFunctionCollisions(file);
402
- this.detectVariableNamespaceCollisions(file);
403
- this.diagnosticDetectInvalidFunctionExpressionTypes(file);
404
- this.diagnosticDetectInvalidFunctionCalls(file);
405
- });
752
+ for (let file of this.getAllFiles()) {
753
+ (_a = validationOptions.filesToBeValidatedInScopeContext) === null || _a === void 0 ? void 0 : _a.delete(file);
754
+ }
755
+ return true;
406
756
  }
407
757
  /**
408
758
  * Mark this scope as invalid, which means its `validate()` function needs to be called again before use.
@@ -411,318 +761,73 @@ class Scope {
411
761
  this.isValidated = false;
412
762
  //clear out various lookups (they'll get regenerated on demand the next time they're requested)
413
763
  this.cache.clear();
414
- this.clearSymbolTable();
415
764
  }
416
765
  get symbolTable() {
417
- var _a, _b;
418
- if (!this._symbolTable) {
419
- this._symbolTable = new SymbolTable_1.SymbolTable((_a = this.getParentScope()) === null || _a === void 0 ? void 0 : _a.symbolTable);
766
+ return this.cache.getOrAdd('symbolTable', () => {
767
+ var _a;
768
+ const result = new SymbolTable_1.SymbolTable(`Scope: '${this.name}'`, () => { var _a; return (_a = this.getParentScope()) === null || _a === void 0 ? void 0 : _a.symbolTable; });
769
+ result.addSymbol('m', undefined, new AssociativeArrayType_1.AssociativeArrayType(), 1 /* SymbolTypeFlag.runtime */);
420
770
  for (let file of this.getOwnFiles()) {
421
- if (reflection_1.isBrsFile(file)) {
422
- this._symbolTable.mergeSymbolTable((_b = file.parser) === null || _b === void 0 ? void 0 : _b.symbolTable);
771
+ if ((0, reflection_1.isBrsFile)(file)) {
772
+ result.mergeSymbolTable((_a = file.parser) === null || _a === void 0 ? void 0 : _a.symbolTable);
423
773
  }
424
774
  }
425
- }
426
- return this._symbolTable;
427
- }
428
- clearSymbolTable() {
429
- this._symbolTable = null;
430
- }
431
- /**
432
- * Builds the current symbol table for the scope, by merging the tables for all the files in this scope.
433
- * Also links all file symbols tables to this new table
434
- * This will only rebuilt if the symbol table has not been built before
435
- */
436
- linkSymbolTable() {
437
- var _a;
438
- for (const file of this.getOwnFiles()) {
439
- if (reflection_1.isBrsFile(file)) {
440
- (_a = file.parser) === null || _a === void 0 ? void 0 : _a.symbolTable.setParent(this.symbolTable);
441
- for (const namespace of file.parser.references.namespaceStatements) {
442
- const namespaceNameLower = namespace.nameExpression.getName(parser_1.ParseMode.BrighterScript).toLowerCase();
443
- const namespaceSymbolTable = this.namespaceLookup[namespaceNameLower].symbolTable;
444
- namespace.symbolTable.setParent(namespaceSymbolTable);
445
- }
446
- }
447
- }
448
- }
449
- unlinkSymbolTable() {
450
- var _a;
451
- for (let file of this.getOwnFiles()) {
452
- if (reflection_1.isBrsFile(file)) {
453
- (_a = file.parser) === null || _a === void 0 ? void 0 : _a.symbolTable.setParent(null);
454
- for (const namespace of file.parser.references.namespaceStatements) {
455
- namespace.symbolTable.setParent(null);
456
- }
457
- }
458
- }
459
- }
460
- detectVariableNamespaceCollisions(file) {
461
- //find all function parameters
462
- for (let func of file.parser.references.functionExpressions) {
463
- for (let param of func.parameters) {
464
- let lowerParamName = param.name.text.toLowerCase();
465
- let namespace = this.namespaceLookup[lowerParamName];
466
- //see if the param matches any starting namespace part
467
- if (namespace) {
468
- this.diagnostics.push(Object.assign(Object.assign({ file: file }, DiagnosticMessages_1.DiagnosticMessages.parameterMayNotHaveSameNameAsNamespace(param.name.text)), { range: param.name.range, relatedInformation: [{
469
- message: 'Namespace declared here',
470
- location: vscode_languageserver_1.Location.create(vscode_uri_1.URI.file(namespace.file.srcPath).toString(), namespace.nameRange)
471
- }] }));
472
- }
473
- }
474
- }
475
- for (let assignment of file.parser.references.assignmentStatements) {
476
- let lowerAssignmentName = assignment.name.text.toLowerCase();
477
- let namespace = this.namespaceLookup[lowerAssignmentName];
478
- //see if the param matches any starting namespace part
479
- if (namespace) {
480
- this.diagnostics.push(Object.assign(Object.assign({ file: file }, DiagnosticMessages_1.DiagnosticMessages.variableMayNotHaveSameNameAsNamespace(assignment.name.text)), { range: assignment.name.range, relatedInformation: [{
481
- message: 'Namespace declared here',
482
- location: vscode_languageserver_1.Location.create(vscode_uri_1.URI.file(namespace.file.srcPath).toString(), namespace.nameRange)
483
- }] }));
484
- }
485
- }
775
+ return result;
776
+ });
486
777
  }
487
- /**
488
- * Find various function collisions
778
+ get allNamespaceTypeTable() {
779
+ return this._allNamespaceTypeTable;
780
+ }
781
+ /**
782
+ * Builds the current symbol table for the scope, by merging the tables for all the files in this scope.
783
+ * Also links all file symbols tables to this new table
784
+ * This will only rebuilt if the symbol table has not been built before
785
+ *
786
+ * Tree of symbol tables:
787
+ * ```
788
+ * Global Scope Symbol Table
789
+ * - Source Scope Symbol Table :: Aggregate Namespaces Symbol Table (Siblings)
790
+ * - File 1 Symbol Table
791
+ * - File 2 Symbol Table
792
+ * - Component A Scope Symbol Table :: Aggregate Namespaces Symbol Table (Siblings)
793
+ * - File 1 Symbol Table
794
+ * - File 2 Symbol Table
795
+ * - Component B Scope Symbol Table :: Aggregate Namespaces Symbol Table (Siblings)
796
+ * - File 1 Symbol Table
797
+ * - File 2 Symbol Table
798
+ * ```
489
799
  */
490
- diagnosticDetectFunctionCollisions(file) {
491
- for (let func of file.callables) {
492
- const funcName = func.getName(parser_1.ParseMode.BrighterScript);
493
- const lowerFuncName = funcName === null || funcName === void 0 ? void 0 : funcName.toLowerCase();
494
- if (lowerFuncName) {
495
- //find function declarations with the same name as a stdlib function
496
- if (globalCallables_1.globalCallableMap.has(lowerFuncName)) {
497
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.scopeFunctionShadowedByBuiltInFunction()), { range: func.nameRange, file: file }));
498
- }
499
- //find any functions that have the same name as a class
500
- if (this.hasClass(lowerFuncName)) {
501
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.functionCannotHaveSameNameAsClass(funcName)), { range: func.nameRange, file: file }));
502
- }
503
- }
504
- }
505
- }
506
- /**
507
- * Find function parameters and function return types that are neither built-in types or known Class references
508
- */
509
- diagnosticDetectInvalidFunctionExpressionTypes(file) {
510
- var _a, _b;
511
- for (let func of file.parser.references.functionExpressions) {
512
- if (reflection_1.isCustomType(func.returnType) && func.returnTypeToken) {
513
- // check if this custom type is in our class map
514
- const returnTypeName = func.returnType.name;
515
- const currentNamespaceName = (_a = func.namespaceName) === null || _a === void 0 ? void 0 : _a.getName(parser_1.ParseMode.BrighterScript);
516
- if (!this.hasClass(returnTypeName, currentNamespaceName)) {
517
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.invalidFunctionReturnType(returnTypeName)), { range: func.returnTypeToken.range, file: file }));
518
- }
519
- }
520
- for (let param of func.parameters) {
521
- if (reflection_1.isCustomType(param.type) && param.typeToken) {
522
- const paramTypeName = param.type.name;
523
- const currentNamespaceName = (_b = func.namespaceName) === null || _b === void 0 ? void 0 : _b.getName(parser_1.ParseMode.BrighterScript);
524
- if (!this.hasClass(paramTypeName, currentNamespaceName)) {
525
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.functionParameterTypeIsInvalid(param.name.text, paramTypeName)), { range: param.typeToken.range, file: file }));
526
- }
527
- }
528
- }
529
- }
530
- }
531
- diagnosticDetectInvalidFunctionCalls(file) {
532
- for (let expCall of file.functionCalls) {
533
- const funcType = expCall.functionExpression.symbolTable.getSymbolType(expCall.name);
534
- if (!reflection_1.isFunctionType(funcType)) {
535
- // can not find function. Handled in a different validation function
536
- continue;
537
- }
538
- if (funcType.params.length !== expCall.args.length) {
539
- // Argument count mismatch. Handled in a different validation function
540
- continue;
541
- }
542
- for (let index = 0; index < funcType.params.length; index++) {
543
- const param = funcType.params[index];
544
- const arg = expCall.args[index];
545
- const argType = arg.type;
546
- if (!argType.isAssignableTo(param.type)) {
547
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.argumentTypeMismatch(arg.type.toTypeString(), param.type.toTypeString())), { range: arg.range, file: file }));
548
- }
800
+ linkSymbolTable() {
801
+ SymbolTable_1.SymbolTable.cacheVerifier.generateToken();
802
+ this._allNamespaceTypeTable = new SymbolTable_1.SymbolTable(`Scope NamespaceTypes ${this.name}`);
803
+ for (const file of this.getAllFiles()) {
804
+ if ((0, reflection_1.isBrsFile)(file)) {
805
+ this.linkSymbolTableDisposables.push(file.parser.symbolTable.pushParentProvider(() => this.symbolTable));
549
806
  }
550
807
  }
551
- }
552
- getNewExpressions() {
553
- let result = [];
554
808
  this.enumerateBrsFiles((file) => {
555
- let expressions = file.parser.references.newExpressions;
556
- for (let expression of expressions) {
557
- expression.file = file;
558
- result.push(expression);
559
- }
809
+ const namespaceTypes = file.getNamespaceSymbolTable();
810
+ this.linkSymbolTableDisposables.push(...this._allNamespaceTypeTable.mergeNamespaceSymbolTables(namespaceTypes));
560
811
  });
561
- return result;
562
- }
563
- validateClasses() {
564
- let validator = new ClassValidator_1.BsClassValidator();
565
- validator.validate(this);
566
- this.diagnostics.push(...validator.diagnostics);
567
- }
568
- /**
569
- * Detect calls to functions with the incorrect number of parameters
570
- * @param file
571
- * @param callableContainersByLowerName
572
- */
573
- diagnosticDetectFunctionCallsWithWrongParamCount(file, callableContainersByLowerName) {
574
- //validate all function calls
575
- for (let expCall of file.functionCalls) {
576
- let callableContainersWithThisName = callableContainersByLowerName.get(expCall.name.toLowerCase());
577
- if (callableContainersWithThisName && callableContainersWithThisName.length > 0) {
578
- // There are some global functions with the same name, but different return types and param counts - see "Val()"
579
- let paramCount = { min: parser_1.CallExpression.MaximumArguments, max: 0 };
580
- for (const callableContainer of callableContainersWithThisName) {
581
- let specificParamCount = util_1.util.getMinMaxParamCount(callableContainer.callable.params);
582
- if (specificParamCount.max > paramCount.max) {
583
- paramCount.max = specificParamCount.max;
584
- }
585
- if (specificParamCount.min < paramCount.min) {
586
- paramCount.min = specificParamCount.min;
587
- }
588
- }
589
- let expCallArgCount = expCall.args.length;
590
- if (expCall.args.length > paramCount.max || expCall.args.length < paramCount.min) {
591
- let minMaxParamsText = paramCount.min === paramCount.max ? paramCount.max : `${paramCount.min}-${paramCount.max}`;
592
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.mismatchArgumentCount(minMaxParamsText, expCallArgCount)), { range: expCall.nameRange,
593
- //TODO detect end of expression call
594
- file: file }));
595
- }
596
- }
597
- }
598
- }
599
- /**
600
- * Detect local variables (vars declared within a function expression) that have the same name as scope calls
601
- * @param file
602
- * @param callableContainerMap
603
- */
604
- diagnosticDetectShadowedLocalVars(file, callableContainerMap) {
605
- const classMap = this.getClassMap();
606
- for (let func of file.parser.references.functionExpressions) {
607
- //every var declaration in this function expression
608
- for (let symbol of func.symbolTable.ownSymbols) {
609
- const symbolNameLower = symbol.name.toLowerCase();
610
- //if the var is a function
611
- if (reflection_1.isFunctionType(symbol.type)) {
612
- //local var function with same name as stdlib function
613
- if (
614
- //has same name as stdlib
615
- globalCallables_1.globalCallableMap.has(symbolNameLower)) {
616
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarFunctionShadowsParentFunction('stdlib')), { range: symbol.range, file: file }));
617
- //this check needs to come after the stdlib one, because the stdlib functions are included
618
- //in the scope function list
619
- }
620
- else if (
621
- //has same name as scope function
622
- callableContainerMap.has(symbolNameLower)) {
623
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarFunctionShadowsParentFunction('scope')), { range: symbol.range, file: file }));
624
- }
625
- //var is not a function
626
- }
627
- else if (
628
- //is NOT a callable from stdlib (because non-function local vars can have same name as stdlib names)
629
- !globalCallables_1.globalCallableMap.has(symbolNameLower)) {
630
- //is same name as a callable
631
- if (callableContainerMap.has(symbolNameLower)) {
632
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarShadowedByScopedFunction()), { range: symbol.range, file: file }));
633
- //has the same name as an in-scope class
634
- }
635
- else if (classMap.has(symbolNameLower)) {
636
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarSameNameAsClass(classMap.get(symbolNameLower).item.getName(parser_1.ParseMode.BrighterScript))), { range: symbol.range, file: file }));
637
- }
812
+ for (const [_, scopeNsContainer] of this.namespaceLookup) {
813
+ for (let nsContainer of scopeNsContainer.namespaceContainers) {
814
+ for (let nsStmt of nsContainer.namespaceStatements) {
815
+ this.linkSymbolTableDisposables.push(nsStmt === null || nsStmt === void 0 ? void 0 : nsStmt.getSymbolTable().addSibling(scopeNsContainer.symbolTable));
638
816
  }
639
817
  }
640
818
  }
819
+ this.linkSymbolTableDisposables.push(this.symbolTable.addSibling(this._allNamespaceTypeTable));
641
820
  }
642
- /**
643
- * Detect calls to functions that are not defined in this scope
644
- * @param file
645
- * @param callablesByLowerName
646
- */
647
- diagnosticDetectCallsToUnknownFunctions(file, callablesByLowerName) {
648
- var _a;
649
- //validate all expression calls
650
- for (let expCall of file.functionCalls) {
651
- if (reflection_1.isBrsFile(file)) {
652
- const lowerName = expCall.name.toLowerCase();
653
- //for now, skip validation on any method named "super" within `.bs` contexts.
654
- //TODO revise this logic so we know if this function call resides within a class constructor function
655
- if (file.extension === '.bs' && lowerName === 'super') {
656
- continue;
657
- }
658
- //find a local variable with this name
659
- const localSymbol = (_a = file.getFunctionExpressionAtPosition(expCall.nameRange.start)) === null || _a === void 0 ? void 0 : _a.symbolTable.getSymbol(lowerName);
660
- //if we don't already have a variable with this name.
661
- if (!localSymbol) {
662
- const callablesWithThisName = util_1.util.getCallableContainersFromContainerMapByFunctionCall(callablesByLowerName, expCall);
663
- //use the first item from callablesByLowerName, because if there are more, that's a separate error
664
- let knownCallable = callablesWithThisName ? callablesWithThisName[0] : undefined;
665
- //detect calls to unknown functions
666
- if (!knownCallable) {
667
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.callToUnknownFunction(expCall.name, this.name)), { range: expCall.nameRange, file: file }));
668
- }
669
- }
670
- else {
671
- //if we found a variable with the same name as the function, assume the call is "known".
672
- //If the variable is a different type, some other check should add a diagnostic for that.
673
- }
674
- }
821
+ unlinkSymbolTable() {
822
+ for (const symbolToRemove of this.symbolsAddedDuringLinking) {
823
+ this.symbolTable.removeSymbol(symbolToRemove.name);
675
824
  }
676
- }
677
- /**
678
- * Create diagnostics for any duplicate function declarations
679
- * @param callablesByLowerName
680
- */
681
- diagnosticFindDuplicateFunctionDeclarations(callableContainersByLowerName) {
682
- //for each list of callables with the same name
683
- for (let [lowerName, callableContainers] of callableContainersByLowerName) {
684
- let globalCallables = [];
685
- let nonGlobalCallables = [];
686
- let ownCallables = [];
687
- let ancestorNonGlobalCallables = [];
688
- for (let container of callableContainers) {
689
- if (container.scope === this.program.globalScope) {
690
- globalCallables.push(container);
691
- }
692
- else {
693
- nonGlobalCallables.push(container);
694
- if (container.scope === this) {
695
- ownCallables.push(container);
696
- }
697
- else {
698
- ancestorNonGlobalCallables.push(container);
699
- }
700
- }
701
- }
702
- //add info diagnostics about child shadowing parent functions
703
- if (ownCallables.length > 0 && ancestorNonGlobalCallables.length > 0) {
704
- for (let container of ownCallables) {
705
- //skip the init function (because every component will have one of those){
706
- if (lowerName !== 'init') {
707
- let shadowedCallable = ancestorNonGlobalCallables[ancestorNonGlobalCallables.length - 1];
708
- if (!!shadowedCallable && shadowedCallable.callable.file === container.callable.file) {
709
- //same file: skip redundant imports
710
- continue;
711
- }
712
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.overridesAncestorFunction(container.callable.name, container.scope.name, shadowedCallable.callable.file.pkgPath,
713
- //grab the last item in the list, which should be the closest ancestor's version
714
- shadowedCallable.scope.name)), { range: container.callable.nameRange, file: container.callable.file }));
715
- }
716
- }
717
- }
718
- //add error diagnostics about duplicate functions in the same scope
719
- if (ownCallables.length > 1) {
720
- for (let callableContainer of ownCallables) {
721
- let callable = callableContainer.callable;
722
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.duplicateFunctionImplementation(callable.name, callableContainer.scope.name)), { range: util_1.util.createRange(callable.nameRange.start.line, callable.nameRange.start.character, callable.nameRange.start.line, callable.nameRange.end.character), file: callable.file }));
723
- }
724
- }
825
+ this.symbolsAddedDuringLinking = [];
826
+ for (const dispose of this.linkSymbolTableDisposables) {
827
+ dispose();
725
828
  }
829
+ this.linkSymbolTableDisposables = [];
830
+ this.cache.delete('namespaceLookup');
726
831
  }
727
832
  /**
728
833
  * Get the list of all script imports for this scope
@@ -730,47 +835,17 @@ class Scope {
730
835
  getOwnScriptImports() {
731
836
  let result = [];
732
837
  this.enumerateOwnFiles((file) => {
733
- if (reflection_1.isBrsFile(file)) {
838
+ if ((0, reflection_1.isBrsFile)(file)) {
734
839
  result.push(...file.ownScriptImports);
735
840
  }
736
- else if (reflection_1.isXmlFile(file)) {
841
+ else if ((0, reflection_1.isXmlFile)(file)) {
737
842
  result.push(...file.scriptTagImports);
738
843
  }
739
844
  });
740
845
  return result;
741
846
  }
742
- /**
743
- * Verify that all of the scripts imported by each file in this scope actually exist
744
- */
745
- diagnosticValidateScriptImportPaths() {
746
- let scriptImports = this.getOwnScriptImports();
747
- //verify every script import
748
- for (let scriptImport of scriptImports) {
749
- let referencedFile = this.getFileByRelativePath(scriptImport.pkgPath);
750
- //if we can't find the file
751
- if (!referencedFile) {
752
- //skip the default bslib file, it will exist at transpile time but should not show up in the program during validation cycle
753
- if (scriptImport.pkgPath === `pkg:/source/bslib.brs`) {
754
- continue;
755
- }
756
- let dInfo;
757
- if (scriptImport.text.trim().length === 0) {
758
- dInfo = DiagnosticMessages_1.DiagnosticMessages.scriptSrcCannotBeEmpty();
759
- }
760
- else {
761
- dInfo = DiagnosticMessages_1.DiagnosticMessages.referencedFileDoesNotExist();
762
- }
763
- this.diagnostics.push(Object.assign(Object.assign({}, dInfo), { range: scriptImport.filePathRange, file: scriptImport.sourceFile }));
764
- //if the character casing of the script import path does not match that of the actual path
765
- }
766
- else if (scriptImport.pkgPath !== referencedFile.pkgPath) {
767
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.scriptImportCaseMismatch(referencedFile.pkgPath)), { range: scriptImport.filePathRange, file: scriptImport.sourceFile }));
768
- }
769
- }
770
- }
771
847
  /**
772
848
  * Find the file with the specified relative path
773
- * @param relativePath
774
849
  */
775
850
  getFileByRelativePath(relativePath) {
776
851
  if (!relativePath) {
@@ -778,87 +853,19 @@ class Scope {
778
853
  }
779
854
  let files = this.getAllFiles();
780
855
  for (let file of files) {
781
- if (file.pkgPath.toLowerCase() === relativePath.toLowerCase()) {
856
+ if (file.destPath.toLowerCase() === relativePath.toLowerCase()) {
782
857
  return file;
783
858
  }
784
859
  }
785
860
  }
786
861
  /**
787
862
  * Determine if this file is included in this scope (excluding parent scopes)
788
- * @param file
789
863
  */
790
864
  hasFile(file) {
791
865
  let files = this.getOwnFiles();
792
866
  let hasFile = files.includes(file);
793
867
  return hasFile;
794
868
  }
795
- /**
796
- * Get all callables as completionItems
797
- */
798
- getCallablesAsCompletions(parseMode) {
799
- let completions = [];
800
- let callables = this.getAllCallables();
801
- if (parseMode === parser_1.ParseMode.BrighterScript) {
802
- //throw out the namespaced callables (they will be handled by another method)
803
- callables = callables.filter(x => x.callable.hasNamespace === false);
804
- }
805
- for (let callableContainer of callables) {
806
- completions.push(this.createCompletionFromCallable(callableContainer));
807
- }
808
- return completions;
809
- }
810
- createCompletionFromCallable(callableContainer) {
811
- return {
812
- label: callableContainer.callable.getName(parser_1.ParseMode.BrighterScript),
813
- kind: vscode_languageserver_1.CompletionItemKind.Function,
814
- detail: callableContainer.callable.shortDescription,
815
- documentation: callableContainer.callable.documentation ? { kind: 'markdown', value: callableContainer.callable.documentation } : undefined
816
- };
817
- }
818
- createCompletionFromFunctionStatement(statement) {
819
- return {
820
- label: statement.getName(parser_1.ParseMode.BrighterScript),
821
- kind: vscode_languageserver_1.CompletionItemKind.Function
822
- };
823
- }
824
- /**
825
- * Get the definition (where was this thing first defined) of the symbol under the position
826
- */
827
- getDefinition(file, position) {
828
- // Overridden in XMLScope. Brs files use implementation in BrsFile
829
- return [];
830
- }
831
- /**
832
- * Scan all files for property names, and return them as completions
833
- */
834
- getPropertyNameCompletions() {
835
- let results = [];
836
- this.enumerateBrsFiles((file) => {
837
- results.push(...file.propertyNameCompletions);
838
- });
839
- return results;
840
- }
841
- getAllClassMemberCompletions() {
842
- let results = new Map();
843
- let filesSearched = new Set();
844
- for (const file of this.getAllFiles()) {
845
- if (reflection_1.isXmlFile(file) || filesSearched.has(file)) {
846
- continue;
847
- }
848
- filesSearched.add(file);
849
- for (let cs of file.parser.references.classStatements) {
850
- for (let s of [...cs.methods, ...cs.fields]) {
851
- if (!results.has(s.name.text) && s.name.text.toLowerCase() !== 'new') {
852
- results.set(s.name.text, {
853
- label: s.name.text,
854
- kind: reflection_1.isClassMethodStatement(s) ? vscode_languageserver_1.CompletionItemKind.Method : vscode_languageserver_1.CompletionItemKind.Field
855
- });
856
- }
857
- }
858
- }
859
- }
860
- return results;
861
- }
862
869
  /**
863
870
  * @param className - The name of the class (including namespace if possible)
864
871
  * @param callsiteNamespace - the name of the namespace where the call site resides (this is NOT the known namespace of the class).
@@ -870,7 +877,7 @@ class Scope {
870
877
  let link = this.getClassFileLink(className, callsiteNamespace);
871
878
  while (link) {
872
879
  items.push(link);
873
- link = this.getClassFileLink((_b = (_a = link.item.parentClassName) === null || _a === void 0 ? void 0 : _a.getName(parser_1.ParseMode.BrighterScript)) === null || _b === void 0 ? void 0 : _b.toLowerCase(), callsiteNamespace);
880
+ link = this.getClassFileLink((_b = (_a = link.item.parentClassName) === null || _a === void 0 ? void 0 : _a.getName()) === null || _b === void 0 ? void 0 : _b.toLowerCase(), callsiteNamespace);
874
881
  }
875
882
  return items;
876
883
  }