brighterscript 1.0.0-alpha.3 → 1.0.0-alpha.30

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