brighterscript 1.0.0-alpha.4 → 1.0.0-alpha.41

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 (620) hide show
  1. package/CHANGELOG.md +1393 -291
  2. package/README.md +72 -131
  3. package/bsconfig.schema.json +85 -1
  4. package/dist/ActionPipeline.d.ts +10 -0
  5. package/dist/ActionPipeline.js +40 -0
  6. package/dist/ActionPipeline.js.map +1 -0
  7. package/dist/AstValidationSegmenter.d.ts +42 -0
  8. package/dist/AstValidationSegmenter.js +237 -0
  9. package/dist/AstValidationSegmenter.js.map +1 -0
  10. package/dist/BsConfig.d.ts +56 -6
  11. package/dist/BusyStatusTracker.d.ts +31 -0
  12. package/dist/BusyStatusTracker.js +83 -0
  13. package/dist/BusyStatusTracker.js.map +1 -0
  14. package/dist/Cache.d.ts +5 -6
  15. package/dist/Cache.js +12 -11
  16. package/dist/Cache.js.map +1 -1
  17. package/dist/CacheVerifier.d.ts +7 -0
  18. package/dist/CacheVerifier.js +20 -0
  19. package/dist/CacheVerifier.js.map +1 -0
  20. package/dist/CodeActionUtil.d.ts +6 -3
  21. package/dist/CodeActionUtil.js +19 -5
  22. package/dist/CodeActionUtil.js.map +1 -1
  23. package/dist/CommentFlagProcessor.d.ts +7 -6
  24. package/dist/CommentFlagProcessor.js +11 -8
  25. package/dist/CommentFlagProcessor.js.map +1 -1
  26. package/dist/CrossScopeValidator.d.ts +67 -0
  27. package/dist/CrossScopeValidator.js +617 -0
  28. package/dist/CrossScopeValidator.js.map +1 -0
  29. package/dist/DependencyGraph.d.ts +8 -3
  30. package/dist/DependencyGraph.js +49 -16
  31. package/dist/DependencyGraph.js.map +1 -1
  32. package/dist/DiagnosticCollection.d.ts +5 -3
  33. package/dist/DiagnosticCollection.js +21 -16
  34. package/dist/DiagnosticCollection.js.map +1 -1
  35. package/dist/DiagnosticFilterer.d.ts +8 -4
  36. package/dist/DiagnosticFilterer.js +90 -54
  37. package/dist/DiagnosticFilterer.js.map +1 -1
  38. package/dist/DiagnosticManager.d.ts +61 -0
  39. package/dist/DiagnosticManager.js +238 -0
  40. package/dist/DiagnosticManager.js.map +1 -0
  41. package/dist/DiagnosticMessages.d.ts +204 -24
  42. package/dist/DiagnosticMessages.js +266 -33
  43. package/dist/DiagnosticMessages.js.map +1 -1
  44. package/dist/DiagnosticSeverityAdjuster.d.ts +7 -0
  45. package/dist/DiagnosticSeverityAdjuster.js +41 -0
  46. package/dist/DiagnosticSeverityAdjuster.js.map +1 -0
  47. package/dist/FunctionScope.d.ts +28 -0
  48. package/dist/FunctionScope.js +52 -0
  49. package/dist/FunctionScope.js.map +1 -0
  50. package/dist/KeyedThrottler.d.ts +3 -3
  51. package/dist/KeyedThrottler.js +3 -3
  52. package/dist/KeyedThrottler.js.map +1 -1
  53. package/dist/LanguageServer.d.ts +72 -47
  54. package/dist/LanguageServer.js +545 -314
  55. package/dist/LanguageServer.js.map +1 -1
  56. package/dist/Logger.d.ts +9 -10
  57. package/dist/Logger.js +36 -30
  58. package/dist/Logger.js.map +1 -1
  59. package/dist/PluginInterface.d.ts +29 -7
  60. package/dist/PluginInterface.js +90 -7
  61. package/dist/PluginInterface.js.map +1 -1
  62. package/dist/Program.d.ts +201 -100
  63. package/dist/Program.js +1079 -700
  64. package/dist/Program.js.map +1 -1
  65. package/dist/ProgramBuilder.d.ts +29 -18
  66. package/dist/ProgramBuilder.js +178 -141
  67. package/dist/ProgramBuilder.js.map +1 -1
  68. package/dist/Scope.d.ts +144 -109
  69. package/dist/Scope.js +533 -552
  70. package/dist/Scope.js.map +1 -1
  71. package/dist/SemanticTokenUtils.d.ts +14 -0
  72. package/dist/SemanticTokenUtils.js +85 -0
  73. package/dist/SemanticTokenUtils.js.map +1 -0
  74. package/dist/Stopwatch.d.ts +4 -0
  75. package/dist/Stopwatch.js +8 -1
  76. package/dist/Stopwatch.js.map +1 -1
  77. package/dist/SymbolTable.d.ts +91 -24
  78. package/dist/SymbolTable.js +291 -64
  79. package/dist/SymbolTable.js.map +1 -1
  80. package/dist/SymbolTypeFlag.d.ts +9 -0
  81. package/dist/SymbolTypeFlag.js +14 -0
  82. package/dist/SymbolTypeFlag.js.map +1 -0
  83. package/dist/Throttler.d.ts +12 -0
  84. package/dist/Throttler.js +39 -0
  85. package/dist/Throttler.js.map +1 -1
  86. package/dist/Watcher.d.ts +0 -3
  87. package/dist/Watcher.js +0 -3
  88. package/dist/Watcher.js.map +1 -1
  89. package/dist/XmlScope.d.ts +5 -15
  90. package/dist/XmlScope.js +35 -87
  91. package/dist/XmlScope.js.map +1 -1
  92. package/dist/astUtils/CachedLookups.d.ts +50 -0
  93. package/dist/astUtils/CachedLookups.js +335 -0
  94. package/dist/astUtils/CachedLookups.js.map +1 -0
  95. package/dist/astUtils/CachedLookups.spec.js +39 -0
  96. package/dist/astUtils/CachedLookups.spec.js.map +1 -0
  97. package/dist/astUtils/Editor.d.ts +69 -0
  98. package/dist/astUtils/Editor.js +245 -0
  99. package/dist/astUtils/Editor.js.map +1 -0
  100. package/dist/astUtils/Editor.spec.js +258 -0
  101. package/dist/astUtils/Editor.spec.js.map +1 -0
  102. package/dist/astUtils/creators.d.ts +36 -19
  103. package/dist/astUtils/creators.js +222 -43
  104. package/dist/astUtils/creators.js.map +1 -1
  105. package/dist/astUtils/creators.spec.js +5 -5
  106. package/dist/astUtils/creators.spec.js.map +1 -1
  107. package/dist/astUtils/reflection.d.ts +148 -82
  108. package/dist/astUtils/reflection.js +324 -137
  109. package/dist/astUtils/reflection.js.map +1 -1
  110. package/dist/astUtils/reflection.spec.js +267 -167
  111. package/dist/astUtils/reflection.spec.js.map +1 -1
  112. package/dist/astUtils/stackedVisitor.js.map +1 -1
  113. package/dist/astUtils/stackedVisitor.spec.js +14 -14
  114. package/dist/astUtils/stackedVisitor.spec.js.map +1 -1
  115. package/dist/astUtils/visitors.d.ts +114 -53
  116. package/dist/astUtils/visitors.js +70 -13
  117. package/dist/astUtils/visitors.js.map +1 -1
  118. package/dist/astUtils/visitors.spec.js +463 -51
  119. package/dist/astUtils/visitors.spec.js.map +1 -1
  120. package/dist/astUtils/xml.d.ts +9 -8
  121. package/dist/astUtils/xml.js +10 -5
  122. package/dist/astUtils/xml.js.map +1 -1
  123. package/dist/bscPlugin/BscPlugin.d.ts +22 -1
  124. package/dist/bscPlugin/BscPlugin.js +88 -0
  125. package/dist/bscPlugin/BscPlugin.js.map +1 -1
  126. package/dist/bscPlugin/CallExpressionInfo.d.ts +36 -0
  127. package/dist/bscPlugin/CallExpressionInfo.js +135 -0
  128. package/dist/bscPlugin/CallExpressionInfo.js.map +1 -0
  129. package/dist/bscPlugin/FileWriter.d.ts +6 -0
  130. package/dist/bscPlugin/FileWriter.js +24 -0
  131. package/dist/bscPlugin/FileWriter.js.map +1 -0
  132. package/dist/bscPlugin/SignatureHelpUtil.d.ts +10 -0
  133. package/dist/bscPlugin/SignatureHelpUtil.js +137 -0
  134. package/dist/bscPlugin/SignatureHelpUtil.js.map +1 -0
  135. package/dist/bscPlugin/codeActions/CodeActionsProcessor.d.ts +1 -1
  136. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +30 -18
  137. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  138. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +94 -21
  139. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
  140. package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +64 -0
  141. package/dist/bscPlugin/completions/CompletionsProcessor.js +626 -0
  142. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -0
  143. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +2188 -0
  144. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -0
  145. package/dist/bscPlugin/definition/DefinitionProvider.d.ts +13 -0
  146. package/dist/bscPlugin/definition/DefinitionProvider.js +212 -0
  147. package/dist/bscPlugin/definition/DefinitionProvider.js.map +1 -0
  148. package/dist/bscPlugin/definition/DefinitionProvider.spec.d.ts +1 -0
  149. package/dist/bscPlugin/definition/DefinitionProvider.spec.js +87 -0
  150. package/dist/bscPlugin/definition/DefinitionProvider.spec.js.map +1 -0
  151. package/dist/bscPlugin/fileProviders/FileProvider.d.ts +9 -0
  152. package/dist/bscPlugin/fileProviders/FileProvider.js +51 -0
  153. package/dist/bscPlugin/fileProviders/FileProvider.js.map +1 -0
  154. package/dist/bscPlugin/hover/HoverProcessor.d.ts +18 -0
  155. package/dist/bscPlugin/hover/HoverProcessor.js +218 -0
  156. package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -0
  157. package/dist/bscPlugin/hover/HoverProcessor.spec.d.ts +1 -0
  158. package/dist/bscPlugin/hover/HoverProcessor.spec.js +786 -0
  159. package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -0
  160. package/dist/bscPlugin/references/ReferencesProvider.d.ts +12 -0
  161. package/dist/bscPlugin/references/ReferencesProvider.js +57 -0
  162. package/dist/bscPlugin/references/ReferencesProvider.js.map +1 -0
  163. package/dist/bscPlugin/references/ReferencesProvider.spec.d.ts +1 -0
  164. package/dist/bscPlugin/references/ReferencesProvider.spec.js +51 -0
  165. package/dist/bscPlugin/references/ReferencesProvider.spec.js.map +1 -0
  166. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +14 -0
  167. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +154 -0
  168. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -0
  169. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.d.ts +1 -0
  170. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +530 -0
  171. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -0
  172. package/dist/bscPlugin/serialize/BslibInjector.spec.d.ts +1 -0
  173. package/dist/bscPlugin/serialize/BslibInjector.spec.js +33 -0
  174. package/dist/bscPlugin/serialize/BslibInjector.spec.js.map +1 -0
  175. package/dist/bscPlugin/serialize/BslibManager.d.ts +12 -0
  176. package/dist/bscPlugin/serialize/BslibManager.js +46 -0
  177. package/dist/bscPlugin/serialize/BslibManager.js.map +1 -0
  178. package/dist/bscPlugin/serialize/FileSerializer.d.ts +9 -0
  179. package/dist/bscPlugin/serialize/FileSerializer.js +75 -0
  180. package/dist/bscPlugin/serialize/FileSerializer.js.map +1 -0
  181. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.d.ts +7 -0
  182. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.js +22 -0
  183. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.js.map +1 -0
  184. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.d.ts +1 -0
  185. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js +291 -0
  186. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js.map +1 -0
  187. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.d.ts +7 -0
  188. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.js +26 -0
  189. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.js.map +1 -0
  190. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.d.ts +1 -0
  191. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js +245 -0
  192. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js.map +1 -0
  193. package/dist/bscPlugin/symbols/symbolUtils.d.ts +5 -0
  194. package/dist/bscPlugin/symbols/symbolUtils.js +141 -0
  195. package/dist/bscPlugin/symbols/symbolUtils.js.map +1 -0
  196. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.d.ts +21 -0
  197. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js +201 -0
  198. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -0
  199. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.d.ts +1 -0
  200. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js +75 -0
  201. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +1 -0
  202. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +12 -0
  203. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js +99 -0
  204. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +1 -0
  205. package/dist/bscPlugin/validation/BrsFileAfterValidator.d.ts +7 -0
  206. package/dist/bscPlugin/validation/BrsFileAfterValidator.js +18 -0
  207. package/dist/bscPlugin/validation/BrsFileAfterValidator.js.map +1 -0
  208. package/dist/bscPlugin/validation/BrsFileValidator.d.ts +36 -0
  209. package/dist/bscPlugin/validation/BrsFileValidator.js +534 -0
  210. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -0
  211. package/dist/bscPlugin/validation/BrsFileValidator.spec.d.ts +1 -0
  212. package/dist/bscPlugin/validation/BrsFileValidator.spec.js +1118 -0
  213. package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -0
  214. package/dist/bscPlugin/validation/ProgramValidator.d.ts +11 -0
  215. package/dist/bscPlugin/validation/ProgramValidator.js +33 -0
  216. package/dist/bscPlugin/validation/ProgramValidator.js.map +1 -0
  217. package/dist/bscPlugin/validation/ScopeValidator.d.ts +128 -0
  218. package/dist/bscPlugin/validation/ScopeValidator.js +1045 -0
  219. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -0
  220. package/dist/bscPlugin/validation/ScopeValidator.spec.d.ts +1 -0
  221. package/dist/bscPlugin/validation/ScopeValidator.spec.js +3380 -0
  222. package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -0
  223. package/dist/bscPlugin/validation/XmlFileValidator.d.ts +8 -0
  224. package/dist/bscPlugin/validation/XmlFileValidator.js +44 -0
  225. package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -0
  226. package/dist/cli.js +117 -11
  227. package/dist/cli.js.map +1 -1
  228. package/dist/deferred.d.ts +3 -3
  229. package/dist/deferred.js.map +1 -1
  230. package/dist/diagnosticUtils.d.ts +10 -3
  231. package/dist/diagnosticUtils.js +62 -24
  232. package/dist/diagnosticUtils.js.map +1 -1
  233. package/dist/examples/plugins/removePrint.js +8 -12
  234. package/dist/examples/plugins/removePrint.js.map +1 -1
  235. package/dist/files/AssetFile.d.ts +24 -0
  236. package/dist/files/AssetFile.js +25 -0
  237. package/dist/files/AssetFile.js.map +1 -0
  238. package/dist/files/BrsFile.Class.spec.js +912 -153
  239. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  240. package/dist/files/BrsFile.d.ts +142 -85
  241. package/dist/files/BrsFile.js +845 -935
  242. package/dist/files/BrsFile.js.map +1 -1
  243. package/dist/files/BrsFile.spec.js +3778 -862
  244. package/dist/files/BrsFile.spec.js.map +1 -1
  245. package/dist/files/BscFile.d.ts +101 -0
  246. package/dist/files/BscFile.js +15 -0
  247. package/dist/files/BscFile.js.map +1 -0
  248. package/dist/files/Factory.d.ts +25 -0
  249. package/dist/files/Factory.js +22 -0
  250. package/dist/files/Factory.js.map +1 -0
  251. package/dist/files/LazyFileData.d.ts +20 -0
  252. package/dist/files/LazyFileData.js +54 -0
  253. package/dist/files/LazyFileData.js.map +1 -0
  254. package/dist/files/LazyFileData.spec.d.ts +1 -0
  255. package/dist/files/LazyFileData.spec.js +27 -0
  256. package/dist/files/LazyFileData.spec.js.map +1 -0
  257. package/dist/files/XmlFile.d.ts +73 -41
  258. package/dist/files/XmlFile.js +128 -138
  259. package/dist/files/XmlFile.js.map +1 -1
  260. package/dist/files/XmlFile.spec.js +451 -324
  261. package/dist/files/XmlFile.spec.js.map +1 -1
  262. package/dist/files/tests/imports.spec.js +62 -52
  263. package/dist/files/tests/imports.spec.js.map +1 -1
  264. package/dist/files/tests/optionalChaning.spec.d.ts +1 -0
  265. package/dist/files/tests/optionalChaning.spec.js +152 -0
  266. package/dist/files/tests/optionalChaning.spec.js.map +1 -0
  267. package/dist/globalCallables.d.ts +3 -1
  268. package/dist/globalCallables.js +417 -163
  269. package/dist/globalCallables.js.map +1 -1
  270. package/dist/index.d.ts +26 -3
  271. package/dist/index.js +44 -5
  272. package/dist/index.js.map +1 -1
  273. package/dist/interfaces.d.ts +783 -122
  274. package/dist/interfaces.js +21 -0
  275. package/dist/interfaces.js.map +1 -1
  276. package/dist/lexer/Character.spec.js +5 -5
  277. package/dist/lexer/Character.spec.js.map +1 -1
  278. package/dist/lexer/Lexer.d.ts +51 -12
  279. package/dist/lexer/Lexer.js +201 -57
  280. package/dist/lexer/Lexer.js.map +1 -1
  281. package/dist/lexer/Lexer.spec.js +781 -565
  282. package/dist/lexer/Lexer.spec.js.map +1 -1
  283. package/dist/lexer/Token.d.ts +27 -11
  284. package/dist/lexer/Token.js +10 -2
  285. package/dist/lexer/Token.js.map +1 -1
  286. package/dist/lexer/TokenKind.d.ts +31 -2
  287. package/dist/lexer/TokenKind.js +134 -10
  288. package/dist/lexer/TokenKind.js.map +1 -1
  289. package/dist/logging.d.ts +9 -0
  290. package/dist/logging.js +16 -0
  291. package/dist/logging.js.map +1 -0
  292. package/dist/parser/AstNode.d.ts +191 -0
  293. package/dist/parser/AstNode.js +269 -0
  294. package/dist/parser/AstNode.js.map +1 -0
  295. package/dist/parser/AstNode.spec.d.ts +1 -0
  296. package/dist/parser/AstNode.spec.js +1455 -0
  297. package/dist/parser/AstNode.spec.js.map +1 -0
  298. package/dist/parser/BrightScriptDocParser.d.ts +56 -0
  299. package/dist/parser/BrightScriptDocParser.js +294 -0
  300. package/dist/parser/BrightScriptDocParser.js.map +1 -0
  301. package/dist/parser/BrightScriptDocParser.spec.d.ts +1 -0
  302. package/dist/parser/BrightScriptDocParser.spec.js +310 -0
  303. package/dist/parser/BrightScriptDocParser.spec.js.map +1 -0
  304. package/dist/parser/BrsTranspileState.d.ts +22 -3
  305. package/dist/parser/BrsTranspileState.js +19 -0
  306. package/dist/parser/BrsTranspileState.js.map +1 -1
  307. package/dist/parser/Expression.d.ts +489 -221
  308. package/dist/parser/Expression.js +1206 -506
  309. package/dist/parser/Expression.js.map +1 -1
  310. package/dist/parser/Expression.spec.d.ts +1 -0
  311. package/dist/parser/Expression.spec.js +40 -0
  312. package/dist/parser/Expression.spec.js.map +1 -0
  313. package/dist/parser/Parser.Class.spec.js +230 -125
  314. package/dist/parser/Parser.Class.spec.js.map +1 -1
  315. package/dist/parser/Parser.d.ts +113 -124
  316. package/dist/parser/Parser.js +1510 -983
  317. package/dist/parser/Parser.js.map +1 -1
  318. package/dist/parser/Parser.spec.d.ts +3 -1
  319. package/dist/parser/Parser.spec.js +1533 -517
  320. package/dist/parser/Parser.spec.js.map +1 -1
  321. package/dist/parser/SGParser.d.ts +60 -7
  322. package/dist/parser/SGParser.js +225 -185
  323. package/dist/parser/SGParser.js.map +1 -1
  324. package/dist/parser/SGParser.spec.js +29 -32
  325. package/dist/parser/SGParser.spec.js.map +1 -1
  326. package/dist/parser/SGTypes.d.ts +295 -52
  327. package/dist/parser/SGTypes.js +540 -187
  328. package/dist/parser/SGTypes.js.map +1 -1
  329. package/dist/parser/Statement.d.ts +808 -261
  330. package/dist/parser/Statement.js +2232 -588
  331. package/dist/parser/Statement.js.map +1 -1
  332. package/dist/parser/Statement.spec.js +133 -36
  333. package/dist/parser/Statement.spec.js.map +1 -1
  334. package/dist/parser/TranspileState.d.ts +26 -12
  335. package/dist/parser/TranspileState.js +114 -15
  336. package/dist/parser/TranspileState.js.map +1 -1
  337. package/dist/parser/tests/Parser.spec.d.ts +3 -9
  338. package/dist/parser/tests/Parser.spec.js +7 -13
  339. package/dist/parser/tests/Parser.spec.js.map +1 -1
  340. package/dist/parser/tests/controlFlow/For.spec.js +83 -75
  341. package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
  342. package/dist/parser/tests/controlFlow/ForEach.spec.js +58 -51
  343. package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
  344. package/dist/parser/tests/controlFlow/If.spec.js +382 -239
  345. package/dist/parser/tests/controlFlow/If.spec.js.map +1 -1
  346. package/dist/parser/tests/controlFlow/While.spec.js +52 -45
  347. package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
  348. package/dist/parser/tests/expression/Additive.spec.js +51 -43
  349. package/dist/parser/tests/expression/Additive.spec.js.map +1 -1
  350. package/dist/parser/tests/expression/ArrayLiterals.spec.js +192 -142
  351. package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +1 -1
  352. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +236 -160
  353. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
  354. package/dist/parser/tests/expression/Boolean.spec.js +41 -34
  355. package/dist/parser/tests/expression/Boolean.spec.js.map +1 -1
  356. package/dist/parser/tests/expression/Call.spec.js +173 -55
  357. package/dist/parser/tests/expression/Call.spec.js.map +1 -1
  358. package/dist/parser/tests/expression/Exponential.spec.js +20 -20
  359. package/dist/parser/tests/expression/Exponential.spec.js.map +1 -1
  360. package/dist/parser/tests/expression/Function.spec.js +291 -282
  361. package/dist/parser/tests/expression/Function.spec.js.map +1 -1
  362. package/dist/parser/tests/expression/Indexing.spec.js +193 -110
  363. package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
  364. package/dist/parser/tests/expression/Multiplicative.spec.js +42 -42
  365. package/dist/parser/tests/expression/Multiplicative.spec.js.map +1 -1
  366. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +213 -115
  367. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
  368. package/dist/parser/tests/expression/PrefixUnary.spec.js +58 -52
  369. package/dist/parser/tests/expression/PrefixUnary.spec.js.map +1 -1
  370. package/dist/parser/tests/expression/Primary.spec.js +76 -60
  371. package/dist/parser/tests/expression/Primary.spec.js.map +1 -1
  372. package/dist/parser/tests/expression/RegexLiteralExpression.spec.d.ts +1 -0
  373. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +171 -0
  374. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -0
  375. package/dist/parser/tests/expression/Relational.spec.js +50 -50
  376. package/dist/parser/tests/expression/Relational.spec.js.map +1 -1
  377. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +31 -31
  378. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +1 -1
  379. package/dist/parser/tests/expression/TemplateStringExpression.spec.js +235 -94
  380. package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
  381. package/dist/parser/tests/expression/TernaryExpression.spec.js +403 -174
  382. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
  383. package/dist/parser/tests/expression/TypeExpression.spec.d.ts +1 -0
  384. package/dist/parser/tests/expression/TypeExpression.spec.js +126 -0
  385. package/dist/parser/tests/expression/TypeExpression.spec.js.map +1 -0
  386. package/dist/parser/tests/expression/UnaryExpression.spec.d.ts +1 -0
  387. package/dist/parser/tests/expression/UnaryExpression.spec.js +52 -0
  388. package/dist/parser/tests/expression/UnaryExpression.spec.js.map +1 -0
  389. package/dist/parser/tests/statement/AssignmentOperators.spec.js +44 -44
  390. package/dist/parser/tests/statement/AssignmentOperators.spec.js.map +1 -1
  391. package/dist/parser/tests/statement/ConstStatement.spec.d.ts +1 -0
  392. package/dist/parser/tests/statement/ConstStatement.spec.js +262 -0
  393. package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -0
  394. package/dist/parser/tests/statement/Continue.spec.d.ts +1 -0
  395. package/dist/parser/tests/statement/Continue.spec.js +119 -0
  396. package/dist/parser/tests/statement/Continue.spec.js.map +1 -0
  397. package/dist/parser/tests/statement/Declaration.spec.js +61 -55
  398. package/dist/parser/tests/statement/Declaration.spec.js.map +1 -1
  399. package/dist/parser/tests/statement/Dim.spec.js +22 -22
  400. package/dist/parser/tests/statement/Dim.spec.js.map +1 -1
  401. package/dist/parser/tests/statement/Enum.spec.d.ts +1 -0
  402. package/dist/parser/tests/statement/Enum.spec.js +744 -0
  403. package/dist/parser/tests/statement/Enum.spec.js.map +1 -0
  404. package/dist/parser/tests/statement/For.spec.d.ts +1 -0
  405. package/dist/parser/tests/statement/For.spec.js +45 -0
  406. package/dist/parser/tests/statement/For.spec.js.map +1 -0
  407. package/dist/parser/tests/statement/ForEach.spec.d.ts +1 -0
  408. package/dist/parser/tests/statement/ForEach.spec.js +36 -0
  409. package/dist/parser/tests/statement/ForEach.spec.js.map +1 -0
  410. package/dist/parser/tests/statement/Function.spec.js +226 -215
  411. package/dist/parser/tests/statement/Function.spec.js.map +1 -1
  412. package/dist/parser/tests/statement/Goto.spec.js +16 -15
  413. package/dist/parser/tests/statement/Goto.spec.js.map +1 -1
  414. package/dist/parser/tests/statement/Increment.spec.js +64 -59
  415. package/dist/parser/tests/statement/Increment.spec.js.map +1 -1
  416. package/dist/parser/tests/statement/InterfaceStatement.spec.d.ts +1 -0
  417. package/dist/parser/tests/statement/InterfaceStatement.spec.js +110 -0
  418. package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -0
  419. package/dist/parser/tests/statement/LibraryStatement.spec.js +22 -22
  420. package/dist/parser/tests/statement/LibraryStatement.spec.js.map +1 -1
  421. package/dist/parser/tests/statement/Misc.spec.js +127 -168
  422. package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
  423. package/dist/parser/tests/statement/PrintStatement.spec.js +133 -114
  424. package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
  425. package/dist/parser/tests/statement/ReturnStatement.spec.js +57 -54
  426. package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
  427. package/dist/parser/tests/statement/Set.spec.js +131 -117
  428. package/dist/parser/tests/statement/Set.spec.js.map +1 -1
  429. package/dist/parser/tests/statement/Stop.spec.js +14 -13
  430. package/dist/parser/tests/statement/Stop.spec.js.map +1 -1
  431. package/dist/parser/tests/statement/Throw.spec.js +11 -8
  432. package/dist/parser/tests/statement/Throw.spec.js.map +1 -1
  433. package/dist/parser/tests/statement/TryCatch.spec.js +26 -15
  434. package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
  435. package/dist/preprocessor/Manifest.d.ts +6 -6
  436. package/dist/preprocessor/Manifest.js +17 -38
  437. package/dist/preprocessor/Manifest.js.map +1 -1
  438. package/dist/preprocessor/Manifest.spec.d.ts +1 -0
  439. package/dist/preprocessor/Manifest.spec.js +78 -103
  440. package/dist/preprocessor/Manifest.spec.js.map +1 -1
  441. package/dist/roku-types/data.json +19452 -0
  442. package/dist/roku-types/index.d.ts +5533 -0
  443. package/dist/roku-types/index.js +11 -0
  444. package/dist/roku-types/index.js.map +1 -0
  445. package/dist/types/ArrayType.d.ts +9 -5
  446. package/dist/types/ArrayType.js +73 -24
  447. package/dist/types/ArrayType.js.map +1 -1
  448. package/dist/types/ArrayType.spec.js +39 -11
  449. package/dist/types/ArrayType.spec.js.map +1 -1
  450. package/dist/types/AssociativeArrayType.d.ts +14 -0
  451. package/dist/types/AssociativeArrayType.js +60 -0
  452. package/dist/types/AssociativeArrayType.js.map +1 -0
  453. package/dist/types/BaseFunctionType.d.ts +9 -0
  454. package/dist/types/BaseFunctionType.js +25 -0
  455. package/dist/types/BaseFunctionType.js.map +1 -0
  456. package/dist/types/BooleanType.d.ts +10 -5
  457. package/dist/types/BooleanType.js +21 -9
  458. package/dist/types/BooleanType.js.map +1 -1
  459. package/dist/types/BooleanType.spec.js +10 -4
  460. package/dist/types/BooleanType.spec.js.map +1 -1
  461. package/dist/types/BscType.d.ts +29 -3
  462. package/dist/types/BscType.js +121 -0
  463. package/dist/types/BscType.js.map +1 -1
  464. package/dist/types/BscTypeKind.d.ts +25 -0
  465. package/dist/types/BscTypeKind.js +30 -0
  466. package/dist/types/BscTypeKind.js.map +1 -0
  467. package/dist/types/BuiltInInterfaceAdder.d.ts +25 -0
  468. package/dist/types/BuiltInInterfaceAdder.js +201 -0
  469. package/dist/types/BuiltInInterfaceAdder.js.map +1 -0
  470. package/dist/types/BuiltInInterfaceAdder.spec.d.ts +1 -0
  471. package/dist/types/BuiltInInterfaceAdder.spec.js +115 -0
  472. package/dist/types/BuiltInInterfaceAdder.spec.js.map +1 -0
  473. package/dist/types/ClassType.d.ts +16 -0
  474. package/dist/types/ClassType.js +57 -0
  475. package/dist/types/ClassType.js.map +1 -0
  476. package/dist/types/ClassType.spec.d.ts +1 -0
  477. package/dist/types/ClassType.spec.js +76 -0
  478. package/dist/types/ClassType.spec.js.map +1 -0
  479. package/dist/types/ComponentType.d.ts +27 -0
  480. package/dist/types/ComponentType.js +83 -0
  481. package/dist/types/ComponentType.js.map +1 -0
  482. package/dist/types/DoubleType.d.ts +10 -5
  483. package/dist/types/DoubleType.js +25 -18
  484. package/dist/types/DoubleType.js.map +1 -1
  485. package/dist/types/DoubleType.spec.js +12 -4
  486. package/dist/types/DoubleType.spec.js.map +1 -1
  487. package/dist/types/DynamicType.d.ts +12 -5
  488. package/dist/types/DynamicType.js +22 -6
  489. package/dist/types/DynamicType.js.map +1 -1
  490. package/dist/types/DynamicType.spec.js +16 -5
  491. package/dist/types/DynamicType.spec.js.map +1 -1
  492. package/dist/types/EnumType.d.ts +40 -0
  493. package/dist/types/EnumType.js +80 -0
  494. package/dist/types/EnumType.js.map +1 -0
  495. package/dist/types/EnumType.spec.d.ts +1 -0
  496. package/dist/types/EnumType.spec.js +33 -0
  497. package/dist/types/EnumType.spec.js.map +1 -0
  498. package/dist/types/FloatType.d.ts +10 -5
  499. package/dist/types/FloatType.js +25 -18
  500. package/dist/types/FloatType.js.map +1 -1
  501. package/dist/types/FloatType.spec.js +4 -4
  502. package/dist/types/FloatType.spec.js.map +1 -1
  503. package/dist/types/FunctionType.d.ts +10 -22
  504. package/dist/types/FunctionType.js +26 -63
  505. package/dist/types/FunctionType.js.map +1 -1
  506. package/dist/types/InheritableType.d.ts +29 -0
  507. package/dist/types/InheritableType.js +162 -0
  508. package/dist/types/InheritableType.js.map +1 -0
  509. package/dist/types/IntegerType.d.ts +10 -5
  510. package/dist/types/IntegerType.js +25 -18
  511. package/dist/types/IntegerType.js.map +1 -1
  512. package/dist/types/IntegerType.spec.js +8 -4
  513. package/dist/types/IntegerType.spec.js.map +1 -1
  514. package/dist/types/InterfaceType.d.ts +14 -6
  515. package/dist/types/InterfaceType.js +26 -15
  516. package/dist/types/InterfaceType.js.map +1 -1
  517. package/dist/types/InterfaceType.spec.d.ts +1 -0
  518. package/dist/types/InterfaceType.spec.js +227 -0
  519. package/dist/types/InterfaceType.spec.js.map +1 -0
  520. package/dist/types/InvalidType.d.ts +9 -5
  521. package/dist/types/InvalidType.js +20 -9
  522. package/dist/types/InvalidType.js.map +1 -1
  523. package/dist/types/InvalidType.spec.js +8 -4
  524. package/dist/types/InvalidType.spec.js.map +1 -1
  525. package/dist/types/LongIntegerType.d.ts +10 -5
  526. package/dist/types/LongIntegerType.js +25 -18
  527. package/dist/types/LongIntegerType.js.map +1 -1
  528. package/dist/types/LongIntegerType.spec.js +10 -4
  529. package/dist/types/LongIntegerType.spec.js.map +1 -1
  530. package/dist/types/NamespaceType.d.ts +12 -0
  531. package/dist/types/NamespaceType.js +28 -0
  532. package/dist/types/NamespaceType.js.map +1 -0
  533. package/dist/types/ObjectType.d.ts +10 -5
  534. package/dist/types/ObjectType.js +23 -9
  535. package/dist/types/ObjectType.js.map +1 -1
  536. package/dist/types/ObjectType.spec.js +3 -3
  537. package/dist/types/ObjectType.spec.js.map +1 -1
  538. package/dist/types/ReferenceType.d.ts +79 -0
  539. package/dist/types/ReferenceType.js +522 -0
  540. package/dist/types/ReferenceType.js.map +1 -0
  541. package/dist/types/ReferenceType.spec.d.ts +1 -0
  542. package/dist/types/ReferenceType.spec.js +151 -0
  543. package/dist/types/ReferenceType.spec.js.map +1 -0
  544. package/dist/types/StringType.d.ts +13 -5
  545. package/dist/types/StringType.js +25 -9
  546. package/dist/types/StringType.js.map +1 -1
  547. package/dist/types/StringType.spec.js +3 -3
  548. package/dist/types/StringType.spec.js.map +1 -1
  549. package/dist/types/TypedFunctionType.d.ts +33 -0
  550. package/dist/types/TypedFunctionType.js +106 -0
  551. package/dist/types/TypedFunctionType.js.map +1 -0
  552. package/dist/types/TypedFunctionType.spec.d.ts +1 -0
  553. package/dist/types/TypedFunctionType.spec.js +122 -0
  554. package/dist/types/TypedFunctionType.spec.js.map +1 -0
  555. package/dist/types/UninitializedType.d.ts +8 -6
  556. package/dist/types/UninitializedType.js +15 -9
  557. package/dist/types/UninitializedType.js.map +1 -1
  558. package/dist/types/UnionType.d.ts +20 -0
  559. package/dist/types/UnionType.js +127 -0
  560. package/dist/types/UnionType.js.map +1 -0
  561. package/dist/types/UnionType.spec.d.ts +1 -0
  562. package/dist/types/UnionType.spec.js +129 -0
  563. package/dist/types/UnionType.spec.js.map +1 -0
  564. package/dist/types/VoidType.d.ts +10 -5
  565. package/dist/types/VoidType.js +20 -9
  566. package/dist/types/VoidType.js.map +1 -1
  567. package/dist/types/VoidType.spec.js +3 -3
  568. package/dist/types/VoidType.spec.js.map +1 -1
  569. package/dist/types/helper.spec.d.ts +1 -0
  570. package/dist/types/helper.spec.js +144 -0
  571. package/dist/types/helper.spec.js.map +1 -0
  572. package/dist/types/helpers.d.ts +26 -0
  573. package/dist/types/helpers.js +191 -0
  574. package/dist/types/helpers.js.map +1 -0
  575. package/dist/types/index.d.ts +22 -0
  576. package/dist/types/index.js +39 -0
  577. package/dist/types/index.js.map +1 -0
  578. package/dist/util.d.ts +272 -117
  579. package/dist/util.js +1583 -343
  580. package/dist/util.js.map +1 -1
  581. package/dist/validators/ClassValidator.d.ts +9 -15
  582. package/dist/validators/ClassValidator.js +85 -138
  583. package/dist/validators/ClassValidator.js.map +1 -1
  584. package/package.json +174 -138
  585. package/dist/astUtils/index.d.ts +0 -7
  586. package/dist/astUtils/index.js +0 -26
  587. package/dist/astUtils/index.js.map +0 -1
  588. package/dist/lexer/index.d.ts +0 -3
  589. package/dist/lexer/index.js +0 -17
  590. package/dist/lexer/index.js.map +0 -1
  591. package/dist/parser/index.d.ts +0 -3
  592. package/dist/parser/index.js +0 -16
  593. package/dist/parser/index.js.map +0 -1
  594. package/dist/preprocessor/Chunk.d.ts +0 -82
  595. package/dist/preprocessor/Chunk.js +0 -77
  596. package/dist/preprocessor/Chunk.js.map +0 -1
  597. package/dist/preprocessor/Preprocessor.d.ts +0 -60
  598. package/dist/preprocessor/Preprocessor.js +0 -156
  599. package/dist/preprocessor/Preprocessor.js.map +0 -1
  600. package/dist/preprocessor/Preprocessor.spec.js +0 -152
  601. package/dist/preprocessor/Preprocessor.spec.js.map +0 -1
  602. package/dist/preprocessor/PreprocessorParser.d.ts +0 -61
  603. package/dist/preprocessor/PreprocessorParser.js +0 -194
  604. package/dist/preprocessor/PreprocessorParser.js.map +0 -1
  605. package/dist/preprocessor/PreprocessorParser.spec.js +0 -116
  606. package/dist/preprocessor/PreprocessorParser.spec.js.map +0 -1
  607. package/dist/preprocessor/index.d.ts +0 -3
  608. package/dist/preprocessor/index.js +0 -16
  609. package/dist/preprocessor/index.js.map +0 -1
  610. package/dist/types/CustomType.d.ts +0 -10
  611. package/dist/types/CustomType.js +0 -35
  612. package/dist/types/CustomType.js.map +0 -1
  613. package/dist/types/FunctionType.spec.js +0 -29
  614. package/dist/types/FunctionType.spec.js.map +0 -1
  615. package/dist/types/LazyType.d.ts +0 -15
  616. package/dist/types/LazyType.js +0 -32
  617. package/dist/types/LazyType.js.map +0 -1
  618. /package/dist/{preprocessor/Preprocessor.spec.d.ts → astUtils/CachedLookups.spec.d.ts} +0 -0
  619. /package/dist/{preprocessor/PreprocessorParser.spec.d.ts → astUtils/Editor.spec.d.ts} +0 -0
  620. /package/dist/{types/FunctionType.spec.d.ts → bscPlugin/completions/CompletionsProcessor.spec.d.ts} +0 -0
@@ -0,0 +1,744 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chai_config_spec_1 = require("../../../chai-config.spec");
4
+ const Expression_1 = require("../../Expression");
5
+ const DiagnosticMessages_1 = require("../../../DiagnosticMessages");
6
+ const testHelpers_spec_1 = require("../../../testHelpers.spec");
7
+ const Parser_1 = require("../../Parser");
8
+ const util_1 = require("../../../util");
9
+ const Statement_1 = require("../../Statement");
10
+ const Program_1 = require("../../../Program");
11
+ const sinon_1 = require("sinon");
12
+ const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
13
+ const visitors_1 = require("../../../astUtils/visitors");
14
+ const reflection_1 = require("../../../astUtils/reflection");
15
+ const testHelpers_spec_2 = require("../../../testHelpers.spec");
16
+ const sinon = (0, sinon_1.createSandbox)();
17
+ describe('EnumStatement', () => {
18
+ let program;
19
+ let testTranspile = (0, testHelpers_spec_1.getTestTranspile)(() => [program, testHelpers_spec_2.rootDir]);
20
+ beforeEach(() => {
21
+ program = new Program_1.Program({ rootDir: testHelpers_spec_2.rootDir, sourceMap: true });
22
+ });
23
+ afterEach(() => {
24
+ sinon.restore();
25
+ program.dispose();
26
+ });
27
+ it('parses empty enum statement', () => {
28
+ const parser = Parser_1.Parser.parse(`
29
+ enum SomeEnum
30
+ end enum
31
+ `, { mode: Parser_1.ParseMode.BrighterScript });
32
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(parser);
33
+ (0, chai_config_spec_1.expect)(parser.ast.statements[0]).to.be.instanceOf(Statement_1.EnumStatement);
34
+ });
35
+ it('supports annotations above', () => {
36
+ const parser = Parser_1.Parser.parse(`
37
+ @someAnnotation
38
+ enum SomeEnum
39
+ end enum
40
+ `, { mode: Parser_1.ParseMode.BrighterScript });
41
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(parser);
42
+ (0, chai_config_spec_1.expect)(parser.ast.statements[0].annotations[0].name).to.eql('someAnnotation');
43
+ });
44
+ it('constructs when missing enum name', () => {
45
+ const parser = Parser_1.Parser.parse(`
46
+ enum
47
+ end enum
48
+ `, { mode: Parser_1.ParseMode.BrighterScript });
49
+ (0, testHelpers_spec_1.expectDiagnostics)(parser, [
50
+ DiagnosticMessages_1.DiagnosticMessages.expectedIdentifier()
51
+ ]);
52
+ (0, chai_config_spec_1.expect)(parser.ast.statements[0]).to.be.instanceOf(Statement_1.EnumStatement);
53
+ });
54
+ it('collects uninitialized members', () => {
55
+ const parser = Parser_1.Parser.parse(`
56
+ enum Direction
57
+ up
58
+ down
59
+ left
60
+ right
61
+ end enum
62
+ `, { mode: Parser_1.ParseMode.BrighterScript });
63
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(parser);
64
+ (0, chai_config_spec_1.expect)(parser.ast.statements[0].getMembers().map(x => x.tokens.name.text)).to.eql([
65
+ 'up',
66
+ 'down',
67
+ 'left',
68
+ 'right'
69
+ ]);
70
+ });
71
+ it('collects int-initialized members', () => {
72
+ const parser = Parser_1.Parser.parse(`
73
+ enum Direction
74
+ up = 1
75
+ down = 2
76
+ left = 3
77
+ right = 4
78
+ end enum
79
+ `, { mode: Parser_1.ParseMode.BrighterScript });
80
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(parser);
81
+ const values = parser.ast.statements[0].getMembers().map(x => x.value);
82
+ (0, testHelpers_spec_1.expectInstanceOf)(values, [
83
+ Expression_1.LiteralExpression,
84
+ Expression_1.LiteralExpression,
85
+ Expression_1.LiteralExpression,
86
+ Expression_1.LiteralExpression
87
+ ]);
88
+ (0, chai_config_spec_1.expect)(values.map(x => x.tokens.value.text)).to.eql([
89
+ '1',
90
+ '2',
91
+ '3',
92
+ '4'
93
+ ]);
94
+ });
95
+ it('collects string-initialized members', () => {
96
+ const parser = Parser_1.Parser.parse(`
97
+ enum Direction
98
+ up = "u"
99
+ down = "d"
100
+ left = "l"
101
+ right = "r"
102
+ end enum
103
+ `, { mode: Parser_1.ParseMode.BrighterScript });
104
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(parser);
105
+ const values = parser.ast.statements[0].getMembers().map(x => x.value);
106
+ (0, testHelpers_spec_1.expectInstanceOf)(values, [
107
+ Expression_1.LiteralExpression,
108
+ Expression_1.LiteralExpression,
109
+ Expression_1.LiteralExpression,
110
+ Expression_1.LiteralExpression
111
+ ]);
112
+ (0, chai_config_spec_1.expect)(values.map(x => x.tokens.value.text)).to.eql([
113
+ '"u"',
114
+ '"d"',
115
+ '"l"',
116
+ '"r"'
117
+ ]);
118
+ });
119
+ it('flags when used in brs mode', () => {
120
+ const parser = Parser_1.Parser.parse(`
121
+ enum Direction
122
+ up = "u"
123
+ down = "d"
124
+ left = "l"
125
+ right = "r"
126
+ end enum
127
+ `, { mode: Parser_1.ParseMode.BrightScript });
128
+ (0, testHelpers_spec_1.expectDiagnostics)(parser, [
129
+ DiagnosticMessages_1.DiagnosticMessages.bsFeatureNotSupportedInBrsFiles('enum declarations')
130
+ ]);
131
+ });
132
+ it('allows enum at top of file', () => {
133
+ const parser = Parser_1.Parser.parse(`
134
+ enum Direction
135
+ value1
136
+ end enum
137
+
138
+ interface Person
139
+ name as string
140
+ end interface
141
+ `, { mode: Parser_1.ParseMode.BrighterScript });
142
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(parser);
143
+ (0, chai_config_spec_1.expect)(parser.ast.statements[0]).instanceof(Statement_1.EnumStatement);
144
+ (0, chai_config_spec_1.expect)(parser.ast.statements[1]).instanceof(Statement_1.InterfaceStatement);
145
+ });
146
+ it('allows enum at bottom of file', () => {
147
+ const parser = Parser_1.Parser.parse(`
148
+ interface Person
149
+ name as string
150
+ end interface
151
+
152
+ enum Direction
153
+ value1
154
+ end enum
155
+ `, { mode: Parser_1.ParseMode.BrighterScript });
156
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(parser);
157
+ (0, chai_config_spec_1.expect)(parser.ast.statements[0]).instanceof(Statement_1.InterfaceStatement);
158
+ (0, chai_config_spec_1.expect)(parser.ast.statements[1]).instanceof(Statement_1.EnumStatement);
159
+ });
160
+ it('allows enum in namespace', () => {
161
+ const file = program.setFile('source/types.bs', `
162
+ namespace entities
163
+ enum Person
164
+ name
165
+ end enum
166
+ end namespace
167
+
168
+ enum Direction
169
+ up
170
+ end enum
171
+ `);
172
+ program.validate();
173
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
174
+ (0, chai_config_spec_1.expect)(file.ast.findChildren(reflection_1.isEnumStatement).map(x => x.fullName)).to.eql([
175
+ 'entities.Person',
176
+ 'Direction'
177
+ ]);
178
+ });
179
+ describe('validation', () => {
180
+ it('allows enums named `optional`', () => {
181
+ program.setFile('source/main.bs', `
182
+ enum optional
183
+ thing = 1
184
+ end enum
185
+ `);
186
+ program.validate();
187
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
188
+ });
189
+ it('catches duplicate enums from same file', () => {
190
+ program.setFile('source/main.bs', `
191
+ enum Direction
192
+ up
193
+ end enum
194
+
195
+ enum Direction
196
+ up
197
+ end enum
198
+ `);
199
+ program.validate();
200
+ (0, testHelpers_spec_1.expectDiagnosticsIncludes)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.nameCollision('Enum', 'Enum', 'Direction')), { relatedInformation: [{
201
+ location: util_1.util.createLocationFromRange(util_1.util.pathToUri((0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/source/main.bs`), util_1.util.createRange(5, 21, 5, 30)),
202
+ message: 'Enum declared here'
203
+ },
204
+ {
205
+ location: util_1.util.createLocationFromRange(util_1.util.pathToUri((0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/source/main.bs`), util_1.util.createRange(1, 21, 1, 30)),
206
+ message: `In scope 'source'`
207
+ }] }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.nameCollision('Enum', 'Enum', 'Direction')), { relatedInformation: [{
208
+ location: util_1.util.createLocationFromRange(util_1.util.pathToUri((0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/source/main.bs`), util_1.util.createRange(1, 21, 1, 30)),
209
+ message: 'Enum declared here'
210
+ },
211
+ {
212
+ location: util_1.util.createLocationFromRange(util_1.util.pathToUri((0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/source/main.bs`), util_1.util.createRange(5, 21, 5, 30)),
213
+ message: `In scope 'source'`
214
+ }] })]);
215
+ });
216
+ it('catches duplicate enums from different files in same scope', () => {
217
+ program.setFile('source/main.bs', `
218
+ enum Direction
219
+ up
220
+ end enum
221
+ `);
222
+ program.setFile('source/lib.bs', `
223
+ enum Direction
224
+ up
225
+ end enum
226
+ `);
227
+ program.validate();
228
+ (0, testHelpers_spec_1.expectDiagnosticsIncludes)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.nameCollision('Enum', 'Enum', 'Direction')), { relatedInformation: [{
229
+ location: util_1.util.createLocationFromRange(util_1.util.pathToUri((0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/source/lib.bs`), util_1.util.createRange(1, 21, 1, 30)),
230
+ message: 'Enum declared here'
231
+ },
232
+ {
233
+ location: util_1.util.createLocationFromRange(util_1.util.pathToUri((0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/source/main.bs`), util_1.util.createRange(1, 21, 1, 30)),
234
+ message: `In scope 'source'`
235
+ }] })]);
236
+ });
237
+ it('allows duplicate enums across different scopes', () => {
238
+ program.setFile('source/main.bs', `
239
+ enum Direction
240
+ up
241
+ end enum
242
+ `);
243
+ program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
244
+ <?xml version="1.0" encoding="utf-8" ?>
245
+ <component name="Comp1" extends="Scene">
246
+ <script uri="comp1.bs" />
247
+ </component>
248
+ `);
249
+ program.setFile('components/comp1.bs', `
250
+ enum Direction
251
+ up
252
+ end enum
253
+ `);
254
+ program.validate();
255
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
256
+ });
257
+ it('flags duplicate members', () => {
258
+ program.setFile('source/main.bs', `
259
+ enum Direction
260
+ name
261
+ name
262
+ end enum
263
+ `);
264
+ program.validate();
265
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.duplicateIdentifier('name')), { location: { range: util_1.util.createRange(3, 20, 3, 24) } })]);
266
+ });
267
+ it('flags mixed enum value types with int first', () => {
268
+ program.setFile('source/main.bs', `
269
+ enum Direction
270
+ a = 1
271
+ b = "c"
272
+ end enum
273
+ `);
274
+ program.validate();
275
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.enumValueMustBeType('integer')), { location: { range: util_1.util.createRange(3, 24, 3, 27) } })]);
276
+ });
277
+ it('flags mixed enum value types with string first', () => {
278
+ program.setFile('source/main.bs', `
279
+ enum Direction
280
+ a = "a"
281
+ b = 1
282
+ end enum
283
+ `);
284
+ program.validate();
285
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.enumValueMustBeType('string')), { location: { range: util_1.util.createRange(3, 24, 3, 25) } })]);
286
+ });
287
+ it('flags missing value for string enum when string is first item', () => {
288
+ program.setFile('source/main.bs', `
289
+ enum Direction
290
+ a = "a"
291
+ b
292
+ end enum
293
+ `);
294
+ program.validate();
295
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.enumValueIsRequired('string')), { location: { range: util_1.util.createRange(3, 20, 3, 21) } })]);
296
+ });
297
+ it('allows mixing-and-matching int and hex int', () => {
298
+ program.setFile('source/main.bs', `
299
+ enum Direction
300
+ a = 1
301
+ b = &HFF
302
+ end enum
303
+ `);
304
+ program.validate();
305
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
306
+ });
307
+ it('allows floats', () => {
308
+ program.setFile('source/main.bs', `
309
+ enum Direction
310
+ a = 1.2
311
+ b = 5.2345
312
+ end enum
313
+ `);
314
+ program.validate();
315
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
316
+ });
317
+ it('only support non-object literals', () => {
318
+ program.setFile('source/main.bs', `
319
+ enum AppConfig
320
+ serverInfo = {}
321
+ end enum
322
+ `);
323
+ program.validate();
324
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.enumValueMustBeType('integer')), { location: { range: util_1.util.createRange(2, 33, 2, 35) } })]);
325
+ });
326
+ it('considers -1 to be an integer', () => {
327
+ program.setFile('source/main.bs', `
328
+ enum AppConfig
329
+ alpha = 1
330
+ beta = -1
331
+ end enum
332
+ `);
333
+ program.validate();
334
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
335
+ });
336
+ it('flags missing value for string enum where string is not first item', () => {
337
+ program.setFile('source/main.bs', `
338
+ enum Direction
339
+ a
340
+ b = "b" 'since this is the only value present, this is a string enum
341
+ end enum
342
+ `);
343
+ program.validate();
344
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.enumValueIsRequired('string')), { location: { range: util_1.util.createRange(2, 20, 2, 21) } })]);
345
+ });
346
+ it('catches unknown non-namespaced enum members', () => {
347
+ program.setFile('source/main.bs', `
348
+ enum Direction
349
+ up
350
+ end enum
351
+
352
+ sub main()
353
+ print Direction.up
354
+ print Direction.DOWN
355
+ print Direction.down
356
+ end sub
357
+ `);
358
+ program.validate();
359
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.unknownEnumValue('DOWN', 'Direction')), { location: { range: util_1.util.createRange(7, 36, 7, 40) } }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.unknownEnumValue('down', 'Direction')), { location: { range: util_1.util.createRange(8, 36, 8, 40) } })]);
360
+ });
361
+ it('catches unknown namespaced enum members', () => {
362
+ program.setFile('source/main.bs', `
363
+ sub main()
364
+ print Enums.Direction.DOWN
365
+ print Enums.Direction.down
366
+ print Enums.Direction.up
367
+ end sub
368
+ namespace Enums
369
+ enum Direction
370
+ up
371
+ end enum
372
+ end namespace
373
+
374
+ `);
375
+ program.validate();
376
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.unknownEnumValue('DOWN', 'Enums.Direction')), { location: { range: util_1.util.createRange(2, 42, 2, 46) } }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.unknownEnumValue('down', 'Enums.Direction')), { location: { range: util_1.util.createRange(3, 42, 3, 46) } })]);
377
+ });
378
+ });
379
+ describe('getMemberValueMap', () => {
380
+ function expectMemberValueMap(code, expected) {
381
+ const file = program.setFile('source/lib.brs', code);
382
+ const cancel = new vscode_languageserver_protocol_1.CancellationTokenSource();
383
+ let firstEnum;
384
+ file.ast.walk(statement => {
385
+ if ((0, reflection_1.isEnumStatement)(statement)) {
386
+ firstEnum = statement;
387
+ cancel.cancel();
388
+ }
389
+ }, {
390
+ walkMode: visitors_1.WalkMode.visitStatements,
391
+ cancel: cancel.token
392
+ });
393
+ (0, chai_config_spec_1.expect)(firstEnum).to.exist;
394
+ const values = firstEnum.getMemberValueMap();
395
+ (0, chai_config_spec_1.expect)([...values].reduce((prev, [key, value]) => {
396
+ prev[key] = value;
397
+ return prev;
398
+ }, {})).to.eql(expected);
399
+ }
400
+ it('defaults first enum value to 0', () => {
401
+ expectMemberValueMap(`
402
+ enum Direction
403
+ up
404
+ down
405
+ left
406
+ right
407
+ end enum
408
+ `, {
409
+ up: '0',
410
+ down: '1',
411
+ left: '2',
412
+ right: '3'
413
+ });
414
+ });
415
+ it('continues incrementing after defined int value', () => {
416
+ expectMemberValueMap(`
417
+ enum Direction
418
+ up
419
+ down = 9
420
+ left
421
+ right = 20
422
+ other
423
+ end enum
424
+ `, {
425
+ up: '0',
426
+ down: '9',
427
+ left: '10',
428
+ right: '20',
429
+ other: '21'
430
+ });
431
+ });
432
+ it('returns string values when defined', () => {
433
+ expectMemberValueMap(`
434
+ enum Direction
435
+ up = "up"
436
+ down = "DOWN"
437
+ left = "LeFt"
438
+ right = "righT"
439
+ end enum
440
+ `, {
441
+ up: '"up"',
442
+ down: '"DOWN"',
443
+ left: '"LeFt"',
444
+ right: '"righT"'
445
+ });
446
+ });
447
+ });
448
+ describe('transpile', () => {
449
+ it('transpiles negative number', async () => {
450
+ await testTranspile(`
451
+ sub main()
452
+ print Direction.up
453
+ end sub
454
+ enum Direction
455
+ up = -1
456
+ end enum
457
+ `, `
458
+ sub main()
459
+ print -1
460
+ end sub
461
+ `, undefined, undefined, false);
462
+ });
463
+ it('includes original value when no value could be computed', async () => {
464
+ await testTranspile(`
465
+ sub main()
466
+ print Direction.up
467
+ end sub
468
+ enum Direction
469
+ up = {}
470
+ end enum
471
+ `, `
472
+ sub main()
473
+ print invalid
474
+ end sub
475
+ `, undefined, undefined, false);
476
+ });
477
+ it('writes all literal values as-is (even if there are errors)', async () => {
478
+ await testTranspile(`
479
+ sub main()
480
+ print Direction.up
481
+ print Direction.down
482
+ print Direction.left
483
+ print Direction.right
484
+ print Direction.upRight
485
+ end sub
486
+ enum Direction
487
+ up = 1
488
+ down = "asdf"
489
+ left = 3.14
490
+ right = &HFF '255
491
+ upRight ' will be 256 since hex ints are parsed as ints
492
+ end enum
493
+ `, `
494
+ sub main()
495
+ print 1
496
+ print "asdf"
497
+ print 3.14
498
+ print &HFF
499
+ print 256
500
+ end sub
501
+ `, 'trim', undefined, false);
502
+ });
503
+ it('supports default-as-integer', async () => {
504
+ await testTranspile(`
505
+ enum Direction
506
+ up
507
+ down
508
+ left
509
+ right
510
+ end enum
511
+ sub main()
512
+ print Direction.up, Direction.down, Direction.left, Direction.right
513
+ end sub
514
+ `, `
515
+ sub main()
516
+ print 0, 1, 2, 3
517
+ end sub
518
+ `);
519
+ });
520
+ it('supports string enums', async () => {
521
+ await testTranspile(`
522
+ enum Direction
523
+ up = "up"
524
+ down = "down"
525
+ left = "left"
526
+ right = "right"
527
+ end enum
528
+ sub main()
529
+ print Direction.up, Direction.down, Direction.left, Direction.right
530
+ end sub
531
+ `, `
532
+ sub main()
533
+ print "up", "down", "left", "right"
534
+ end sub
535
+ `);
536
+ });
537
+ it('recognizes namespace-relative enums', () => {
538
+ program.setFile('source/main.bs', `
539
+ namespace MyNamespace
540
+ enum MyEnum
541
+ val1
542
+ val2
543
+ end enum
544
+
545
+ function foo() as MyEnum
546
+ return MyEnum.val1
547
+ end function
548
+ end namespace
549
+ `);
550
+ program.validate();
551
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
552
+ });
553
+ it('replaces enum values from separate file with literals', async () => {
554
+ program.setFile('source/enum.bs', `
555
+ enum CharacterType
556
+ Human = "Human"
557
+ Zombie = "Zombie"
558
+ end enum
559
+ namespace Locations
560
+ enum Houses
561
+ TownHouse
562
+ FarmHouse
563
+ end enum
564
+ end namespace
565
+ `);
566
+ await testTranspile(`
567
+ sub test()
568
+ print CharacterType.Human
569
+ print CharacterType.Zombie
570
+ print Locations.Houses.TownHouse
571
+ print Locations.Houses.FarmHouse
572
+ end sub
573
+ `, `
574
+ sub test()
575
+ print "Human"
576
+ print "Zombie"
577
+ print 0
578
+ print 1
579
+ end sub
580
+ `);
581
+ });
582
+ it('replaces enums in if statements', async () => {
583
+ await testTranspile(`
584
+ enum CharacterType
585
+ zombie = "zombie"
586
+ end enum
587
+ sub main()
588
+ if "one" = CharacterType.zombie or "two" = CharacterType.zombie and "three" = CharacterType.zombie
589
+ print true
590
+ end if
591
+ end sub
592
+ `, `
593
+ sub main()
594
+ if "one" = "zombie" or "two" = "zombie" and "three" = "zombie"
595
+ print true
596
+ end if
597
+ end sub
598
+ `);
599
+ });
600
+ it('handles both sides of a logical expression', async () => {
601
+ await testTranspile(`
602
+ sub main()
603
+ dir = m.direction = Direction.up
604
+ dir = Direction.up = m.direction
605
+ end sub
606
+ enum Direction
607
+ up = "up"
608
+ down = "down"
609
+ end enum
610
+ `, `
611
+ sub main()
612
+ dir = m.direction = "up"
613
+ dir = "up" = m.direction
614
+ end sub
615
+ `);
616
+ });
617
+ it('handles when found in boolean expressions', async () => {
618
+ await testTranspile(`
619
+ sub main()
620
+ result = Direction.up = "up" or Direction.down = "down" and Direction.up = Direction.down
621
+ end sub
622
+ enum Direction
623
+ up = "up"
624
+ down = "down"
625
+ end enum
626
+ `, `
627
+ sub main()
628
+ result = "up" = "up" or "down" = "down" and "up" = "down"
629
+ end sub
630
+ `);
631
+ });
632
+ it('replaces enum values in if statements', async () => {
633
+ await testTranspile(`
634
+ sub main()
635
+ if m.direction = Direction.up
636
+ print Direction.up
637
+ end if
638
+ end sub
639
+ enum Direction
640
+ up = "up"
641
+ down = "down"
642
+ end enum
643
+ `, `
644
+ sub main()
645
+ if m.direction = "up"
646
+ print "up"
647
+ end if
648
+ end sub
649
+ `);
650
+ });
651
+ it('replaces enum values in function default parameter value expressions', async () => {
652
+ await testTranspile(`
653
+ sub speak(dir = Direction.up)
654
+ end sub
655
+ enum Direction
656
+ up = "up"
657
+ end enum
658
+ `, `
659
+ sub speak(dir = "up")
660
+ end sub
661
+ `);
662
+ });
663
+ it('replaces enum values in for loops', async () => {
664
+ await testTranspile(`
665
+ sub main()
666
+ for i = Loop.start to Loop.end step Loop.step
667
+ end for
668
+ end sub
669
+ enum Loop
670
+ start = 0
671
+ end = 10
672
+ step = 1
673
+ end enum
674
+ `, `
675
+ sub main()
676
+ for i = 0 to 10 step 1
677
+ end for
678
+ end sub
679
+ `);
680
+ });
681
+ it('transpiles enum values when used in complex expressions', async () => {
682
+ await testTranspile(`
683
+ sub main()
684
+ print Direction.up.toStr()
685
+ end sub
686
+ enum Direction
687
+ up = "up"
688
+ down = "down"
689
+ end enum
690
+ `, `
691
+ sub main()
692
+ print "up".toStr()
693
+ end sub
694
+ `);
695
+ });
696
+ it('works when enum is in a namespace', async () => {
697
+ program.setFile('components/Colors.bs', `
698
+ namespace Colors
699
+ enum Primary
700
+ red = "#FF0000"
701
+ end enum
702
+ end namespace
703
+ `);
704
+ program.setFile('components/Button.xml', `
705
+ <component name="Button" extends="Group">
706
+ <script type="text/brightscript" uri="pkg:/components/Button.bs" />
707
+ </component>
708
+ `);
709
+ const file = program.setFile('components/Button.bs', `
710
+ import "Colors.bs"
711
+
712
+ namespace alpha
713
+ sub testIt()
714
+ print Colors.Primary.red
715
+ aa = {
716
+ value: Colors.Primary.red
717
+ }
718
+ end sub
719
+ end namespace
720
+
721
+ namespace Colors
722
+ sub testIt()
723
+ print Primary.red
724
+ end sub
725
+ end namespace
726
+ `);
727
+ program.validate();
728
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
729
+ await testTranspile(file, `
730
+ 'import "Colors.bs"
731
+ sub alpha_testIt()
732
+ print "#FF0000"
733
+ aa = {
734
+ value: "#FF0000"
735
+ }
736
+ end sub
737
+ sub Colors_testIt()
738
+ print "#FF0000"
739
+ end sub
740
+ `);
741
+ });
742
+ });
743
+ });
744
+ //# sourceMappingURL=Enum.spec.js.map