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,1455 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const util_1 = require("../util");
4
+ const fsExtra = require("fs-extra");
5
+ const Program_1 = require("../Program");
6
+ const chai_config_spec_1 = require("../chai-config.spec");
7
+ const testHelpers_spec_1 = require("../testHelpers.spec");
8
+ const testHelpers_spec_2 = require("../testHelpers.spec");
9
+ const reflection_1 = require("../astUtils/reflection");
10
+ const Statement_1 = require("./Statement");
11
+ const Parser_1 = require("./Parser");
12
+ describe('AstNode', () => {
13
+ let program;
14
+ beforeEach(() => {
15
+ fsExtra.emptyDirSync(testHelpers_spec_2.tempDir);
16
+ program = new Program_1.Program({
17
+ rootDir: testHelpers_spec_2.rootDir,
18
+ stagingDir: testHelpers_spec_2.stagingDir
19
+ });
20
+ program.createSourceScope(); //ensure source scope is created
21
+ });
22
+ afterEach(() => {
23
+ fsExtra.emptyDirSync(testHelpers_spec_2.tempDir);
24
+ program.dispose();
25
+ });
26
+ describe('findChildAtPosition', () => {
27
+ it('finds deepest AstNode that matches the position', () => {
28
+ const file = program.setFile('source/main.brs', `
29
+ sub main()
30
+ alpha = invalid
31
+ print alpha.beta.charlie.delta(alpha.echo.foxtrot())
32
+ end sub
33
+ `);
34
+ program.validate();
35
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
36
+ const delta = file.ast.findChildAtPosition(util_1.util.createPosition(3, 52));
37
+ (0, chai_config_spec_1.expect)(delta.tokens.name.text).to.eql('delta');
38
+ const foxtrot = file.ast.findChildAtPosition(util_1.util.createPosition(3, 71));
39
+ (0, chai_config_spec_1.expect)(foxtrot.tokens.name.text).to.eql('foxtrot');
40
+ });
41
+ });
42
+ describe('findChild', () => {
43
+ it('finds a child that matches the matcher', () => {
44
+ const file = program.setFile('source/main.brs', `
45
+ sub main()
46
+ alpha = invalid
47
+ print alpha.beta.charlie.delta(alpha.echo.foxtrot())
48
+ end sub
49
+ `);
50
+ (0, chai_config_spec_1.expect)(file.ast.findChild((node) => {
51
+ return (0, reflection_1.isAssignmentStatement)(node) && node.tokens.name.text === 'alpha';
52
+ })).instanceof(Statement_1.AssignmentStatement);
53
+ });
54
+ it('returns the exact node that matches', () => {
55
+ const file = program.setFile('source/main.brs', `
56
+ sub main()
57
+ alpha1 = invalid
58
+ alpha2 = invalid
59
+ end sub
60
+ `);
61
+ let count = 0;
62
+ const instance = file.ast.findChild((node) => {
63
+ if ((0, reflection_1.isAssignmentStatement)(node)) {
64
+ count++;
65
+ if (count === 2) {
66
+ return true;
67
+ }
68
+ }
69
+ });
70
+ const expected = file.ast.statements[0].func.body.statements[1];
71
+ (0, chai_config_spec_1.expect)(instance).to.equal(expected);
72
+ });
73
+ it('returns undefined when matcher never returned true', () => {
74
+ const file = program.setFile('source/main.brs', `
75
+ sub main()
76
+ alpha = invalid
77
+ print alpha.beta.charlie.delta(alpha.echo.foxtrot())
78
+ end sub
79
+ `);
80
+ (0, chai_config_spec_1.expect)(file.ast.findChild((node) => false)).not.to.exist;
81
+ });
82
+ it('returns the value returned from the matcher', () => {
83
+ const file = program.setFile('source/main.brs', `
84
+ sub main()
85
+ alpha = invalid
86
+ print alpha.beta.charlie.delta(alpha.echo.foxtrot())
87
+ end sub
88
+ `);
89
+ const secondStatement = file.ast.statements[0].func.body.statements[1];
90
+ (0, chai_config_spec_1.expect)(file.ast.findChild((node) => secondStatement)).to.equal(secondStatement);
91
+ });
92
+ it('cancels properly', () => {
93
+ const file = program.setFile('source/main.brs', `
94
+ sub main()
95
+ alpha = invalid
96
+ print alpha.beta.charlie.delta(alpha.echo.foxtrot())
97
+ end sub
98
+ `);
99
+ let count = 0;
100
+ file.ast.findChild((node, cancelToken) => {
101
+ count++;
102
+ cancelToken.cancel();
103
+ });
104
+ (0, chai_config_spec_1.expect)(count).to.eql(1);
105
+ });
106
+ });
107
+ describe('findAncestor', () => {
108
+ it('returns node when matcher returns true', () => {
109
+ const file = program.setFile('source/main.brs', `
110
+ sub main()
111
+ alpha = invalid
112
+ print alpha.beta.charlie.delta(alpha.echo.foxtrot())
113
+ end sub
114
+ `);
115
+ const secondStatement = file.ast.statements[0].func.body.statements[1];
116
+ const foxtrot = file.ast.findChild((node) => {
117
+ var _a;
118
+ return (0, reflection_1.isDottedGetExpression)(node) && ((_a = node.tokens.name) === null || _a === void 0 ? void 0 : _a.text) === 'foxtrot';
119
+ });
120
+ (0, chai_config_spec_1.expect)(foxtrot.findAncestor(reflection_1.isPrintStatement)).to.equal(secondStatement);
121
+ });
122
+ it('returns undefined when no match found', () => {
123
+ const file = program.setFile('source/main.brs', `
124
+ sub main()
125
+ alpha = invalid
126
+ print alpha.beta.charlie.delta(alpha.echo.foxtrot())
127
+ end sub
128
+ `);
129
+ const foxtrot = file.ast.findChild((node) => {
130
+ var _a;
131
+ return (0, reflection_1.isDottedGetExpression)(node) && ((_a = node.tokens.name) === null || _a === void 0 ? void 0 : _a.text) === 'foxtrot';
132
+ });
133
+ (0, chai_config_spec_1.expect)(foxtrot.findAncestor(reflection_1.isClassStatement)).to.be.undefined;
134
+ });
135
+ it('returns overridden node when returned in matcher', () => {
136
+ const file = program.setFile('source/main.brs', `
137
+ sub main()
138
+ alpha = invalid
139
+ print alpha.beta.charlie.delta(alpha.echo.foxtrot())
140
+ end sub
141
+ `);
142
+ const firstStatement = file.ast.statements[0].func.body.statements[0];
143
+ const foxtrot = file.ast.findChild((node) => {
144
+ var _a;
145
+ return (0, reflection_1.isDottedGetExpression)(node) && ((_a = node.tokens.name) === null || _a === void 0 ? void 0 : _a.text) === 'foxtrot';
146
+ });
147
+ (0, chai_config_spec_1.expect)(foxtrot.findAncestor(node => firstStatement)).to.equal(firstStatement);
148
+ });
149
+ it('returns overridden node when returned in matcher', () => {
150
+ const file = program.setFile('source/main.brs', `
151
+ sub main()
152
+ alpha = invalid
153
+ print alpha.beta.charlie.delta(alpha.echo.foxtrot())
154
+ end sub
155
+ `);
156
+ let count = 0;
157
+ const firstStatement = file.ast.statements[0].func.body.statements[0];
158
+ firstStatement.findAncestor((node, cancel) => {
159
+ count++;
160
+ cancel.cancel();
161
+ });
162
+ (0, chai_config_spec_1.expect)(count).to.eql(1);
163
+ });
164
+ });
165
+ describe('clone', () => {
166
+ function testClone(code) {
167
+ let originalOuter;
168
+ if (typeof code === 'string') {
169
+ const parser = Parser_1.Parser.parse(code, { mode: Parser_1.ParseMode.BrighterScript });
170
+ originalOuter = parser.ast;
171
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(parser);
172
+ }
173
+ else {
174
+ originalOuter = code;
175
+ }
176
+ const cloneOuter = originalOuter.clone();
177
+ //ensure the clone is identical to the original
178
+ //compare them both ways to ensure no extra properties exist
179
+ ensureIdentical(originalOuter, cloneOuter);
180
+ ensureIdentical(cloneOuter, originalOuter);
181
+ function ensureIdentical(original, clone, ancestors = [], seenNodes = new Map()) {
182
+ var _a, _b, _c;
183
+ for (let key in original) {
184
+ let fullKey = [...ancestors, key].join('.');
185
+ const originalValue = original === null || original === void 0 ? void 0 : original[key];
186
+ const cloneValue = clone === null || clone === void 0 ? void 0 : clone[key];
187
+ let typeOfValue = typeof originalValue;
188
+ //skip these properties
189
+ if (['parent', 'symbolTable', 'range'].includes(key) ||
190
+ //this is a circular reference property or the `returnType` prop, skip it
191
+ ((0, reflection_1.isFunctionExpression)(original) && (key === 'functionStatement' || key === 'returnType')) ||
192
+ //circular reference property for annotations
193
+ ((0, reflection_1.isAnnotationExpression)(original) && key === 'call')) {
194
+ continue;
195
+ }
196
+ //if this is an object, recurse
197
+ if (typeOfValue === 'object' && originalValue !== null) {
198
+ //skip circular references (but give some tollerance)
199
+ if (seenNodes.get(originalValue) > 2) {
200
+ throw new Error(`${fullKey} is a circular reference`);
201
+ }
202
+ seenNodes.set(originalValue, ((_a = seenNodes.get(originalValue)) !== null && _a !== void 0 ? _a : 0) + 1);
203
+ //object references should not be the same
204
+ if (originalValue === cloneValue) {
205
+ throw new Error(`${fullKey} is the same object reference`);
206
+ }
207
+ //compare child object values
208
+ ensureIdentical(originalValue, cloneValue, [...ancestors, key], seenNodes);
209
+ //for these tests, empty arrays can be the same as undefined so skip
210
+ }
211
+ else if ((Array.isArray(originalValue) && originalValue.length === 0 && cloneValue === undefined) ||
212
+ (Array.isArray(cloneValue) && cloneValue.length === 0 && originalValue === undefined)) {
213
+ continue;
214
+ //these values must be identical
215
+ }
216
+ else {
217
+ // eslint-disable-next-line no-useless-catch
218
+ try {
219
+ (0, chai_config_spec_1.expect)(cloneValue).to.equal(originalValue, `'${fullKey}' should be identical`);
220
+ }
221
+ catch (e) {
222
+ //build a full list of ancestors for orig and clone
223
+ let originalChain = [originalOuter];
224
+ let cloneChain = [cloneOuter];
225
+ for (let key of fullKey.split('.')) {
226
+ originalChain.push((_b = originalChain[originalChain.length - 1]) === null || _b === void 0 ? void 0 : _b[key]);
227
+ cloneChain.push((_c = cloneChain[cloneChain.length - 1]) === null || _c === void 0 ? void 0 : _c[key]);
228
+ }
229
+ console.error(e === null || e === void 0 ? void 0 : e.message, fullKey, originalChain, cloneChain);
230
+ throw e;
231
+ }
232
+ }
233
+ }
234
+ }
235
+ }
236
+ it('clones EmptyStatement', () => {
237
+ testClone(new Statement_1.EmptyStatement({
238
+ range: util_1.util.createLocation(1, 2, 3, 4)
239
+ }));
240
+ });
241
+ it('clones body with undefined statements array', () => {
242
+ const original = Parser_1.Parser.parse(`
243
+ sub main()
244
+ end sub
245
+ `).ast;
246
+ original.statements = undefined;
247
+ testClone(original);
248
+ });
249
+ it('clones body with undefined in the statements array', () => {
250
+ const original = Parser_1.Parser.parse(`
251
+ sub main()
252
+ end sub
253
+ `).ast;
254
+ original.statements.push(undefined);
255
+ testClone(original);
256
+ });
257
+ it('clones interfaces', () => {
258
+ testClone(`
259
+ interface Empty
260
+ end interface
261
+ interface Movie
262
+ name as string
263
+ previous as Movie
264
+ sub play()
265
+ function play2(a, b as string) as dynamic
266
+ end interface
267
+ interface Short extends Movie
268
+ length as integer
269
+ end interface
270
+ `);
271
+ });
272
+ it('handles when interfaces are missing their body', () => {
273
+ const original = Parser_1.Parser.parse(`
274
+ interface Empty
275
+ end interface
276
+ `).ast;
277
+ original.findChild(reflection_1.isInterfaceStatement).body = undefined;
278
+ testClone(original);
279
+ });
280
+ it('handles when interfaces have undefined statements in the body', () => {
281
+ const original = Parser_1.Parser.parse(`
282
+ interface Empty
283
+ end interface
284
+ `).ast;
285
+ original.findChild(reflection_1.isInterfaceStatement).body.push(undefined);
286
+ testClone(original);
287
+ });
288
+ it('handles when interfaces have undefined field type', () => {
289
+ const original = Parser_1.Parser.parse(`
290
+ interface Empty
291
+ name as string
292
+ end interface
293
+ `).ast;
294
+ original.findChild(reflection_1.isInterfaceFieldStatement).typeExpression = undefined;
295
+ testClone(original);
296
+ });
297
+ it('handles when interface function has undefined param and return type', () => {
298
+ const original = Parser_1.Parser.parse(`
299
+ interface Empty
300
+ function test() as dynamic
301
+ end interface
302
+ `).ast;
303
+ original.findChild(reflection_1.isInterfaceMethodStatement).params.push(undefined);
304
+ original.findChild(reflection_1.isInterfaceMethodStatement).returnTypeExpression = undefined;
305
+ testClone(original);
306
+ });
307
+ it('handles when interface function has undefined params array', () => {
308
+ const original = Parser_1.Parser.parse(`
309
+ interface Empty
310
+ function test(a) as dynamic
311
+ end interface
312
+ `).ast;
313
+ original.findChild(reflection_1.isInterfaceMethodStatement).params = undefined;
314
+ testClone(original);
315
+ });
316
+ it('clones empty class', () => {
317
+ testClone(`
318
+ class Movie
319
+ end class
320
+ `);
321
+ });
322
+ it('clones class with undefined body', () => {
323
+ const original = Parser_1.Parser.parse(`
324
+ class Movie
325
+ end class
326
+ `).ast;
327
+ original.findChild(reflection_1.isClassStatement).body = undefined;
328
+ testClone(original);
329
+ });
330
+ it('clones class with undefined body statement', () => {
331
+ const original = Parser_1.Parser.parse(`
332
+ class Movie
333
+ end class
334
+ `).ast;
335
+ original.findChild(reflection_1.isClassStatement).body.push(undefined);
336
+ testClone(original);
337
+ });
338
+ it('clones class having parent class', () => {
339
+ testClone(`
340
+ class Video
341
+ end class
342
+ class Movie extends Video
343
+ end class
344
+ `);
345
+ });
346
+ it('clones class', () => {
347
+ testClone(`
348
+ class Movie
349
+ name as string
350
+ previous as Movie
351
+ sub play()
352
+ end sub
353
+ function play2(a, b as string) as dynamic
354
+ end function
355
+ end class
356
+ `);
357
+ });
358
+ it('clones access modifiers', () => {
359
+ testClone(`
360
+ class Movie
361
+ public sub test()
362
+ end sub
363
+ protected name = "bob"
364
+ private child = {}
365
+ end class
366
+ `);
367
+ });
368
+ it('clones AssignmentStatement', () => {
369
+ testClone(`
370
+ sub main()
371
+ thing = true
372
+ end sub
373
+ `);
374
+ });
375
+ it('clones AssignmentStatement with missing value', () => {
376
+ const original = Parser_1.Parser.parse(`
377
+ sub main()
378
+ thing = true
379
+ end sub
380
+ `).ast;
381
+ original.findChild(reflection_1.isAssignmentStatement).value = undefined;
382
+ testClone(original);
383
+ });
384
+ it('clones Block with undefined statements array', () => {
385
+ const original = Parser_1.Parser.parse(`
386
+ sub main()
387
+ thing = true
388
+ end sub
389
+ `).ast;
390
+ original.findChild(reflection_1.isBlock).statements = undefined;
391
+ testClone(original);
392
+ });
393
+ it('clones Block with undefined statement in statements array', () => {
394
+ const original = Parser_1.Parser.parse(`
395
+ sub main()
396
+ thing = true
397
+ end sub
398
+ `).ast;
399
+ original.findChild(reflection_1.isBlock).statements.push(undefined);
400
+ testClone(original);
401
+ });
402
+ it('clones class with undefined method modifiers array', () => {
403
+ const original = Parser_1.Parser.parse(`
404
+ class Movie
405
+ sub test()
406
+ end sub
407
+ end class
408
+ `).ast;
409
+ original.findChild(reflection_1.isMethodStatement).modifiers = undefined;
410
+ testClone(original);
411
+ });
412
+ it('clones class with undefined func', () => {
413
+ const original = Parser_1.Parser.parse(`
414
+ class Movie
415
+ sub test()
416
+ end sub
417
+ end class
418
+ `).ast;
419
+ original.findChild(reflection_1.isMethodStatement).func = undefined;
420
+ testClone(original);
421
+ });
422
+ it('clones ExpressionStatement', () => {
423
+ testClone(`
424
+ sub main()
425
+ test()
426
+ end sub
427
+ `);
428
+ });
429
+ it('clones ExpressionStatement without an expression', () => {
430
+ const original = Parser_1.Parser.parse(`
431
+ sub main()
432
+ test()
433
+ end sub
434
+ `).ast;
435
+ original.findChild(reflection_1.isExpressionStatement).expression = undefined;
436
+ testClone(original);
437
+ });
438
+ it('clones IfStatement', () => {
439
+ testClone(`
440
+ sub main()
441
+ if true
442
+ end if
443
+ if true then
444
+ end if
445
+ if true
446
+ print 1
447
+ else if true
448
+ print 1
449
+ else
450
+ print 1
451
+ end if
452
+ end sub
453
+ `);
454
+ });
455
+ it('clones IfStatement without condition or branches', () => {
456
+ const original = Parser_1.Parser.parse(`
457
+ sub main()
458
+ if true
459
+ end if
460
+ end sub
461
+ `).ast;
462
+ original.findChild(reflection_1.isIfStatement).condition = undefined;
463
+ original.findChild(reflection_1.isIfStatement).thenBranch = undefined;
464
+ original.findChild(reflection_1.isIfStatement).elseBranch = undefined;
465
+ testClone(original);
466
+ });
467
+ it('clones IncrementStatement', () => {
468
+ testClone(`
469
+ sub main()
470
+ i = 0
471
+ i++
472
+ end sub
473
+ `);
474
+ });
475
+ it('clones IncrementStatement with missing `value`', () => {
476
+ const original = Parser_1.Parser.parse(`
477
+ sub main()
478
+ i = 0
479
+ i++
480
+ end sub
481
+ `).ast;
482
+ original.findChild(reflection_1.isIncrementStatement).value = undefined;
483
+ testClone(original);
484
+ });
485
+ it('clones PrintStatement with undefined expressions array', () => {
486
+ const original = Parser_1.Parser.parse(`
487
+ sub main()
488
+ print 1
489
+ end sub
490
+ `).ast;
491
+ original.findChild(reflection_1.isPrintStatement).expressions = undefined;
492
+ testClone(original);
493
+ });
494
+ it('clones PrintStatement with undefined expression in the expressions array', () => {
495
+ const original = Parser_1.Parser.parse(`
496
+ sub main()
497
+ print 1
498
+ end sub
499
+ `).ast;
500
+ original.findChild(reflection_1.isPrintStatement).expressions.push(undefined);
501
+ testClone(original);
502
+ });
503
+ it('clones DimStatement', () => {
504
+ testClone(`
505
+ sub main()
506
+ dim alpha[1,2]
507
+ end sub
508
+ `);
509
+ });
510
+ it('clones DimStatement with undefined dimensions', () => {
511
+ const original = Parser_1.Parser.parse(`
512
+ sub main()
513
+ dim alpha[1,2]
514
+ end sub
515
+ `).ast;
516
+ original.findChild(reflection_1.isDimStatement).dimensions = undefined;
517
+ testClone(original);
518
+ });
519
+ it('clones DimStatement with undefined as item in dimensions', () => {
520
+ const original = Parser_1.Parser.parse(`
521
+ sub main()
522
+ dim alpha[1,2]
523
+ end sub
524
+ `).ast;
525
+ original.findChild(reflection_1.isDimStatement).dimensions.push(undefined);
526
+ testClone(original);
527
+ });
528
+ it('clones Goto statement', () => {
529
+ testClone(`
530
+ sub main()
531
+ label1:
532
+ for i = 0 to 10
533
+ goto label1
534
+ end for
535
+ end sub
536
+ `);
537
+ });
538
+ it('clones return statement', () => {
539
+ testClone(`
540
+ sub main()
541
+ return
542
+ end sub
543
+ `);
544
+ });
545
+ it('clones return statement with value', () => {
546
+ testClone(`
547
+ function test()
548
+ return true
549
+ end function
550
+ `);
551
+ });
552
+ it('clones return statement with undefined value expression', () => {
553
+ const original = Parser_1.Parser.parse(`
554
+ function test()
555
+ return true
556
+ end function
557
+ `).ast;
558
+ original.findChild(reflection_1.isReturnStatement).value = undefined;
559
+ testClone(original);
560
+ });
561
+ it('clones stop statement', () => {
562
+ testClone(`
563
+ sub main()
564
+ stop
565
+ end sub
566
+ `);
567
+ });
568
+ it('clones ForStatement', () => {
569
+ testClone(`
570
+ function test()
571
+ for i = 0 to 10 step 2
572
+ end for
573
+ end function
574
+ `);
575
+ });
576
+ it('clones ForStatement with undefined items', () => {
577
+ const original = Parser_1.Parser.parse(`
578
+ function test()
579
+ for i = 0 to 10 step 2
580
+ end for
581
+ end function
582
+ `).ast;
583
+ original.findChild(reflection_1.isForStatement).counterDeclaration = undefined;
584
+ original.findChild(reflection_1.isForStatement).finalValue = undefined;
585
+ original.findChild(reflection_1.isForStatement).body = undefined;
586
+ original.findChild(reflection_1.isForStatement).increment = undefined;
587
+ testClone(original);
588
+ });
589
+ it('clones ForEachStatement', () => {
590
+ testClone(`
591
+ function test()
592
+ for each item in [1, 2, 3]
593
+ end for
594
+ end function
595
+ `);
596
+ });
597
+ it('clones ForEachStatement with undefined props', () => {
598
+ const original = Parser_1.Parser.parse(`
599
+ function test()
600
+ for each item in [1, 2, 3]
601
+ end for
602
+ end function
603
+ `).ast;
604
+ original.findChild(reflection_1.isForEachStatement).target = undefined;
605
+ original.findChild(reflection_1.isForEachStatement).body = undefined;
606
+ testClone(original);
607
+ });
608
+ it('clones EndStatement', () => {
609
+ testClone(`
610
+ function test()
611
+ end
612
+ end function
613
+ `);
614
+ });
615
+ it('clones ExitFor statement', () => {
616
+ testClone(`
617
+ sub main()
618
+ for i = 0 to 10
619
+ exit for
620
+ end for
621
+ end sub
622
+ `);
623
+ });
624
+ it('clones While statement', () => {
625
+ testClone(`
626
+ sub main()
627
+ while true
628
+ end while
629
+ end sub
630
+ `);
631
+ });
632
+ it('clones While statement', () => {
633
+ testClone(`
634
+ sub main()
635
+ while true
636
+ end while
637
+ end sub
638
+ `);
639
+ });
640
+ it('clones ExitWhile statement', () => {
641
+ testClone(`
642
+ sub main()
643
+ while true
644
+ exit while
645
+ end while
646
+ end sub
647
+ `);
648
+ });
649
+ it('clones tryCatch statement', () => {
650
+ testClone(`
651
+ sub main()
652
+ try
653
+ catch e
654
+ end try
655
+ end sub
656
+ `);
657
+ });
658
+ it('clones tryCatch statement when missing branches', () => {
659
+ const original = Parser_1.Parser.parse(`
660
+ sub main()
661
+ try
662
+ print 1
663
+ catch e
664
+ print 2
665
+ end try
666
+ end sub
667
+ `).ast;
668
+ original.findChild(reflection_1.isTryCatchStatement).tryBranch = undefined;
669
+ original.findChild(reflection_1.isTryCatchStatement).catchStatement = undefined;
670
+ testClone(original);
671
+ });
672
+ it('clones tryCatch statement when missing catch branch', () => {
673
+ const original = Parser_1.Parser.parse(`
674
+ sub main()
675
+ try
676
+ print 1
677
+ catch e
678
+ print 2
679
+ end try
680
+ end sub
681
+ `).ast;
682
+ original.findChild(reflection_1.isCatchStatement).catchBranch = undefined;
683
+ testClone(original);
684
+ });
685
+ it('clones throw statement', () => {
686
+ testClone(`
687
+ sub main()
688
+ throw "Crash"
689
+ end sub
690
+ `);
691
+ });
692
+ it('clones throw statement with missing expression', () => {
693
+ const original = Parser_1.Parser.parse(`
694
+ sub main()
695
+ throw "Crash"
696
+ end sub
697
+ `).ast;
698
+ original.findChild(reflection_1.isThrowStatement).expression = undefined;
699
+ testClone(original);
700
+ });
701
+ it('clones FunctionStatement when missing .func', () => {
702
+ const original = Parser_1.Parser.parse(`
703
+ sub main()
704
+ end sub
705
+ `).ast;
706
+ original.findChild(reflection_1.isFunctionStatement).func = undefined;
707
+ testClone(original);
708
+ });
709
+ it('clones empty enum statement', () => {
710
+ testClone(`
711
+ enum Direction
712
+ end enum
713
+ `);
714
+ });
715
+ it('clones enum statement with comments', () => {
716
+ testClone(`
717
+ enum Direction
718
+ 'the up direction
719
+ up = "up"
720
+ end enum
721
+ `);
722
+ });
723
+ it('clones enum statement with missing body', () => {
724
+ const original = Parser_1.Parser.parse(`
725
+ enum Direction
726
+ 'the up direction
727
+ up = "up"
728
+ end enum
729
+ `).ast;
730
+ original.findChild(reflection_1.isEnumStatement).body = undefined;
731
+ testClone(original);
732
+ });
733
+ it('clones enum statement with undefined in body', () => {
734
+ const original = Parser_1.Parser.parse(`
735
+ enum Direction
736
+ 'the up direction
737
+ up = "up"
738
+ end enum
739
+ `).ast;
740
+ original.findChild(reflection_1.isEnumStatement).body.push(undefined);
741
+ testClone(original);
742
+ });
743
+ it('clones enum member with missing value', () => {
744
+ const original = Parser_1.Parser.parse(`
745
+ enum Direction
746
+ up = "up"
747
+ end enum
748
+ `).ast;
749
+ original.findChild(reflection_1.isEnumMemberStatement).value = undefined;
750
+ testClone(original);
751
+ });
752
+ it('clones const', () => {
753
+ const original = Parser_1.Parser.parse(`
754
+ const key = "KEY"
755
+ `).ast;
756
+ testClone(original);
757
+ });
758
+ it('clones const with missing value', () => {
759
+ const original = Parser_1.Parser.parse(`
760
+ const key = "KEY"
761
+ `).ast;
762
+ original.findChild(reflection_1.isConstStatement).value = undefined;
763
+ testClone(original);
764
+ });
765
+ it('clones continue statement', () => {
766
+ testClone(`
767
+ sub main()
768
+ for i = 0 to 10
769
+ continue for
770
+ end for
771
+ end sub
772
+ `);
773
+ });
774
+ it('clones WhileStatement', () => {
775
+ const original = Parser_1.Parser.parse(`
776
+ sub main()
777
+ while true
778
+ print hello
779
+ end while
780
+ end sub
781
+ `).ast;
782
+ original.findChild(reflection_1.isWhileStatement).condition = undefined;
783
+ original.findChild(reflection_1.isWhileStatement).body = undefined;
784
+ testClone(original);
785
+ });
786
+ it('clones DottedSetStatement', () => {
787
+ const original = Parser_1.Parser.parse(`
788
+ sub main()
789
+ m.value = true
790
+ end sub
791
+ `).ast;
792
+ testClone(original);
793
+ });
794
+ it('clones DottedSetStatement with missing properties', () => {
795
+ const original = Parser_1.Parser.parse(`
796
+ sub main()
797
+ m.value = true
798
+ end sub
799
+ `).ast;
800
+ original.findChild(reflection_1.isDottedSetStatement).obj = undefined;
801
+ original.findChild(reflection_1.isDottedSetStatement).value = undefined;
802
+ testClone(original);
803
+ });
804
+ it('clones IndexedSetStatement with missing props', () => {
805
+ const original = Parser_1.Parser.parse(`
806
+ sub main()
807
+ m["value"] = true
808
+ end sub
809
+ `).ast;
810
+ original.findChild(reflection_1.isIndexedSetStatement).obj = undefined;
811
+ original.findChild(reflection_1.isIndexedSetStatement).value = undefined;
812
+ testClone(original);
813
+ });
814
+ it('clones IndexedSetStatement', () => {
815
+ const original = Parser_1.Parser.parse(`
816
+ sub main()
817
+ m["value"] = true
818
+ end sub
819
+ `).ast;
820
+ testClone(original);
821
+ });
822
+ it('clones IndexedSetStatement', () => {
823
+ const original = Parser_1.Parser.parse(`
824
+ sub main()
825
+ m["value"][2] = true
826
+ m["value", 2] = true
827
+ end sub
828
+ `).ast;
829
+ testClone(original);
830
+ });
831
+ it('clones IndexedSetStatement with undefined index entry', () => {
832
+ const original = Parser_1.Parser.parse(`
833
+ sub main()
834
+ m["value", 2] = true
835
+ end sub
836
+ `).ast;
837
+ original.findChild(reflection_1.isIndexedSetStatement).indexes[0] = undefined;
838
+ testClone(original);
839
+ });
840
+ it('clones IndexedSetStatement with missing props', () => {
841
+ const original = Parser_1.Parser.parse(`
842
+ sub main()
843
+ m["value"] = true
844
+ end sub
845
+ `).ast;
846
+ original.findChild(reflection_1.isIndexedSetStatement).indexes = undefined;
847
+ testClone(original);
848
+ });
849
+ it('clones LibraryStatement', () => {
850
+ const original = Parser_1.Parser.parse(`
851
+ Library "v30/bslCore.brs"
852
+ `).ast;
853
+ testClone(original);
854
+ });
855
+ it('clones NamespaceStatement', () => {
856
+ const original = Parser_1.Parser.parse(`
857
+ namespace Alpha
858
+ end namespace
859
+ `).ast;
860
+ testClone(original);
861
+ });
862
+ it('clones NamespaceStatement with missing items', () => {
863
+ const original = Parser_1.Parser.parse(`
864
+ namespace Alpha
865
+ end namespace
866
+ `).ast;
867
+ original.findChild(reflection_1.isNamespaceStatement).nameExpression = undefined;
868
+ original.findChild(reflection_1.isNamespaceStatement).body = undefined;
869
+ testClone(original);
870
+ });
871
+ it('clones ImportStatement', () => {
872
+ const original = Parser_1.Parser.parse(`
873
+ import "Something.brs"
874
+ `).ast;
875
+ testClone(original);
876
+ });
877
+ it('clones BinaryExpression', () => {
878
+ const original = Parser_1.Parser.parse(`
879
+ sub test()
880
+ print 1 + 2
881
+ end sub
882
+ `).ast;
883
+ testClone(original);
884
+ });
885
+ it('clones BinaryExpression with missing props', () => {
886
+ const original = Parser_1.Parser.parse(`
887
+ sub test()
888
+ print 1 + 2
889
+ end sub
890
+ `).ast;
891
+ original.findChild(reflection_1.isBinaryExpression).left = undefined;
892
+ original.findChild(reflection_1.isBinaryExpression).right = undefined;
893
+ testClone(original);
894
+ });
895
+ it('clones CallExpression', () => {
896
+ const original = Parser_1.Parser.parse(`
897
+ sub test()
898
+ test()
899
+ end sub
900
+ `).ast;
901
+ testClone(original);
902
+ });
903
+ it('clones CallExpression with args', () => {
904
+ const original = Parser_1.Parser.parse(`
905
+ sub test()
906
+ test(1,2,3)
907
+ end sub
908
+ `).ast;
909
+ testClone(original);
910
+ });
911
+ it('clones CallExpression with missing props', () => {
912
+ const original = Parser_1.Parser.parse(`
913
+ sub test()
914
+ test(1,2,3)
915
+ end sub
916
+ `).ast;
917
+ original.findChild(reflection_1.isCallExpression).callee = undefined;
918
+ original.findChild(reflection_1.isCallExpression).args = undefined;
919
+ testClone(original);
920
+ });
921
+ it('clones CallExpression with args containing undefined', () => {
922
+ const original = Parser_1.Parser.parse(`
923
+ sub test()
924
+ test(1,2,3)
925
+ end sub
926
+ `).ast;
927
+ original.findChild(reflection_1.isCallExpression).args[0] = undefined;
928
+ testClone(original);
929
+ });
930
+ it('clones FunctionExpression', () => {
931
+ const original = Parser_1.Parser.parse(`
932
+ sub test()
933
+ end sub
934
+ `).ast;
935
+ testClone(original);
936
+ });
937
+ it('clones FunctionExpression with undefined props', () => {
938
+ const original = Parser_1.Parser.parse(`
939
+ sub test()
940
+ end sub
941
+ `).ast;
942
+ original.findChild(reflection_1.isFunctionExpression).parameters = undefined;
943
+ original.findChild(reflection_1.isFunctionExpression).body = undefined;
944
+ testClone(original);
945
+ });
946
+ it('clones FunctionExpression with a parameter that is undefined', () => {
947
+ const original = Parser_1.Parser.parse(`
948
+ sub test(p1)
949
+ end sub
950
+ `).ast;
951
+ original.findChild(reflection_1.isFunctionExpression).parameters[0] = undefined;
952
+ testClone(original);
953
+ });
954
+ it('clones FunctionParameterExpression', () => {
955
+ const original = Parser_1.Parser.parse(`
956
+ sub test(p1)
957
+ end sub
958
+ `).ast;
959
+ testClone(original);
960
+ });
961
+ it('clones FunctionParameterExpression with default value', () => {
962
+ const original = Parser_1.Parser.parse(`
963
+ sub test(p1 = true)
964
+ end sub
965
+ `).ast;
966
+ testClone(original);
967
+ });
968
+ it('clones FunctionParameterExpression with undefined default value', () => {
969
+ const original = Parser_1.Parser.parse(`
970
+ sub test(p1 = true)
971
+ end sub
972
+ `).ast;
973
+ original.findChild(reflection_1.isFunctionExpression).parameters[0].defaultValue = undefined;
974
+ testClone(original);
975
+ });
976
+ it('clones NamespacedVariableNameExpression', () => {
977
+ const original = Parser_1.Parser.parse(`
978
+ sub test(p1 as Alpha.Beta)
979
+ end sub
980
+ `).ast;
981
+ testClone(original);
982
+ });
983
+ it('clones NamespacedVariableNameExpression with undefined expression', () => {
984
+ const original = Parser_1.Parser.parse(`
985
+ class Person extends Alpha.Humanoid
986
+ end class
987
+ `).ast;
988
+ original.findChild(reflection_1.isClassStatement).parentClassName = undefined;
989
+ testClone(original);
990
+ });
991
+ it('clones DottedGetExpression', () => {
992
+ const original = Parser_1.Parser.parse(`
993
+ sub test()
994
+ print alpha.beta.charlie
995
+ end sub
996
+ `).ast;
997
+ testClone(original);
998
+ });
999
+ it('clones DottedGetExpression with undefined expression', () => {
1000
+ const original = Parser_1.Parser.parse(`
1001
+ sub test()
1002
+ print alpha.beta.charlie
1003
+ end sub
1004
+ `).ast;
1005
+ original.findChild(reflection_1.isDottedGetExpression).obj = undefined;
1006
+ testClone(original);
1007
+ });
1008
+ it('clones XmlAttributeGetExpression', () => {
1009
+ const original = Parser_1.Parser.parse(`
1010
+ sub test()
1011
+ print xml@name
1012
+ end sub
1013
+ `).ast;
1014
+ testClone(original);
1015
+ });
1016
+ it('clones XmlAttributeGetExpression with undefined expression', () => {
1017
+ const original = Parser_1.Parser.parse(`
1018
+ sub test()
1019
+ print xml@name
1020
+ end sub
1021
+ `).ast;
1022
+ original.findChild(reflection_1.isXmlAttributeGetExpression).obj = undefined;
1023
+ testClone(original);
1024
+ });
1025
+ it('clones IndexedGetExpression', () => {
1026
+ const original = Parser_1.Parser.parse(`
1027
+ sub test()
1028
+ print m.stuff[0]
1029
+ end sub
1030
+ `).ast;
1031
+ testClone(original);
1032
+ });
1033
+ it('clones IndexedGetExpression with undefined expression', () => {
1034
+ const original = Parser_1.Parser.parse(`
1035
+ sub test()
1036
+ print m.stuff[0]
1037
+ end sub
1038
+ `).ast;
1039
+ original.findChild(reflection_1.isIndexedGetExpression).obj = undefined;
1040
+ original.findChild(reflection_1.isIndexedGetExpression).indexes = undefined;
1041
+ testClone(original);
1042
+ });
1043
+ it('clones IndexedGetExpression', () => {
1044
+ const original = Parser_1.Parser.parse(`
1045
+ sub test()
1046
+ print m.stuff[0, 1]
1047
+ end sub
1048
+ `).ast;
1049
+ testClone(original);
1050
+ });
1051
+ it('clones IndexedGetExpression with indexes having undefined props', () => {
1052
+ const original = Parser_1.Parser.parse(`
1053
+ sub test()
1054
+ print m.stuff[0, 1]
1055
+ end sub
1056
+ `).ast;
1057
+ original.findChild(reflection_1.isIndexedGetExpression).indexes[0] = undefined;
1058
+ testClone(original);
1059
+ });
1060
+ it('clones GroupingExpression', () => {
1061
+ const original = Parser_1.Parser.parse(`
1062
+ sub test()
1063
+ print (1 + 2)
1064
+ end sub
1065
+ `).ast;
1066
+ testClone(original);
1067
+ });
1068
+ it('clones GroupingExpression with undefined expression', () => {
1069
+ const original = Parser_1.Parser.parse(`
1070
+ sub test()
1071
+ print (1 + 2)
1072
+ end sub
1073
+ `).ast;
1074
+ original.findChild(reflection_1.isGroupingExpression).expression = undefined;
1075
+ testClone(original);
1076
+ });
1077
+ it('clones LiteralExpression', () => {
1078
+ const original = Parser_1.Parser.parse(`
1079
+ sub test()
1080
+ print true
1081
+ end sub
1082
+ `).ast;
1083
+ testClone(original);
1084
+ });
1085
+ it('clones ExcapedCharCodeLiteralExpression', () => {
1086
+ const original = Parser_1.Parser.parse(`
1087
+ sub test()
1088
+ print \`\n\`
1089
+ end sub
1090
+ `).ast;
1091
+ testClone(original);
1092
+ });
1093
+ it('clones ArrayLiteralExpression', () => {
1094
+ const original = Parser_1.Parser.parse(`
1095
+ sub test()
1096
+ print []
1097
+ end sub
1098
+ `).ast;
1099
+ testClone(original);
1100
+ });
1101
+ it('clones ArrayLiteralExpression with undefined items', () => {
1102
+ const original = Parser_1.Parser.parse(`
1103
+ sub test()
1104
+ print []
1105
+ end sub
1106
+ `).ast;
1107
+ original.findChild(reflection_1.isArrayLiteralExpression).elements = undefined;
1108
+ testClone(original);
1109
+ });
1110
+ it('clones ArrayLiteralExpression with with elements having an undefined', () => {
1111
+ const original = Parser_1.Parser.parse(`
1112
+ sub test()
1113
+ print [1,2,3]
1114
+ end sub
1115
+ `).ast;
1116
+ original.findChild(reflection_1.isArrayLiteralExpression).elements[0] = undefined;
1117
+ testClone(original);
1118
+ });
1119
+ it('clones AAMemberExpression', () => {
1120
+ const original = Parser_1.Parser.parse(`
1121
+ sub test()
1122
+ movie = {
1123
+ duration: 20
1124
+ }
1125
+ end sub
1126
+ `).ast;
1127
+ testClone(original);
1128
+ });
1129
+ it('clones AAMemberExpression with undefined expression', () => {
1130
+ const original = Parser_1.Parser.parse(`
1131
+ sub test()
1132
+ movie = {
1133
+ duration: 20
1134
+ }
1135
+ end sub
1136
+ `).ast;
1137
+ original.findChild(reflection_1.isAAMemberExpression).value = undefined;
1138
+ testClone(original);
1139
+ });
1140
+ it('clones AALiteralExpression', () => {
1141
+ const original = Parser_1.Parser.parse(`
1142
+ sub test()
1143
+ movie = {
1144
+ duration: 20
1145
+ }
1146
+ end sub
1147
+ `).ast;
1148
+ testClone(original);
1149
+ });
1150
+ it('clones AALiteralExpression with undefined items', () => {
1151
+ const original = Parser_1.Parser.parse(`
1152
+ sub test()
1153
+ movie = {
1154
+ duration: 20
1155
+ }
1156
+ end sub
1157
+ `).ast;
1158
+ original.findChild(reflection_1.isAALiteralExpression).elements = undefined;
1159
+ testClone(original);
1160
+ });
1161
+ it('clones AALiteralExpression with undefined items', () => {
1162
+ const original = Parser_1.Parser.parse(`
1163
+ sub test()
1164
+ movie = {
1165
+ duration: 20
1166
+ }
1167
+ end sub
1168
+ `).ast;
1169
+ original.findChild(reflection_1.isAALiteralExpression).elements.push(undefined);
1170
+ testClone(original);
1171
+ });
1172
+ it('clones UnaryExpression', () => {
1173
+ const original = Parser_1.Parser.parse(`
1174
+ sub test()
1175
+ print not true
1176
+ end sub
1177
+ `).ast;
1178
+ testClone(original);
1179
+ });
1180
+ it('clones UnaryExpression with undefined expression', () => {
1181
+ const original = Parser_1.Parser.parse(`
1182
+ sub test()
1183
+ print not true
1184
+ end sub
1185
+ `).ast;
1186
+ original.findChild(reflection_1.isUnaryExpression).right = undefined;
1187
+ testClone(original);
1188
+ });
1189
+ it('clones SourceLiteralExpression', () => {
1190
+ const original = Parser_1.Parser.parse(`
1191
+ sub test()
1192
+ print LINE_NUM
1193
+ end sub
1194
+ `).ast;
1195
+ testClone(original);
1196
+ });
1197
+ it('clones NewExpression', () => {
1198
+ const original = Parser_1.Parser.parse(`
1199
+ sub test()
1200
+ print new Person()
1201
+ end sub
1202
+ `).ast;
1203
+ testClone(original);
1204
+ });
1205
+ it('clones NewExpression with undefined expression', () => {
1206
+ const original = Parser_1.Parser.parse(`
1207
+ sub test()
1208
+ print new Person()
1209
+ end sub
1210
+ `).ast;
1211
+ original.findChild(reflection_1.isNewExpression).call = undefined;
1212
+ testClone(original);
1213
+ });
1214
+ it('clones CallfuncExpression', () => {
1215
+ const original = Parser_1.Parser.parse(`
1216
+ sub test()
1217
+ print node@.run(1)
1218
+ end sub
1219
+ `).ast;
1220
+ testClone(original);
1221
+ });
1222
+ it('clones CallfuncExpression with undefined expression', () => {
1223
+ const original = Parser_1.Parser.parse(`
1224
+ sub test()
1225
+ print node@.run()
1226
+ end sub
1227
+ `).ast;
1228
+ original.findChild(reflection_1.isCallfuncExpression).callee = undefined;
1229
+ original.findChild(reflection_1.isCallfuncExpression).args = undefined;
1230
+ testClone(original);
1231
+ });
1232
+ it('clones CallfuncExpression with undefined args', () => {
1233
+ const original = Parser_1.Parser.parse(`
1234
+ sub test()
1235
+ print node@.run()
1236
+ end sub
1237
+ `).ast;
1238
+ original.findChild(reflection_1.isCallfuncExpression).args[0] = undefined;
1239
+ testClone(original);
1240
+ });
1241
+ it('clones TemplateStringQuasiExpression', () => {
1242
+ const original = Parser_1.Parser.parse(`
1243
+ sub test()
1244
+ print \`hello \${name}\`
1245
+ end sub
1246
+ `).ast;
1247
+ testClone(original);
1248
+ });
1249
+ it('clones TemplateStringQuasiExpression with undefined expressions', () => {
1250
+ const original = Parser_1.Parser.parse(`
1251
+ sub test()
1252
+ print \`hello \${name}\`
1253
+ end sub
1254
+ `).ast;
1255
+ original.findChild(reflection_1.isTemplateStringQuasiExpression).expressions = undefined;
1256
+ testClone(original);
1257
+ });
1258
+ it('clones TemplateStringQuasiExpression with undefined expressions', () => {
1259
+ const original = Parser_1.Parser.parse(`
1260
+ sub test()
1261
+ print \`hello \${name}\`
1262
+ end sub
1263
+ `).ast;
1264
+ original.findChild(reflection_1.isTemplateStringQuasiExpression).expressions[0] = undefined;
1265
+ testClone(original);
1266
+ });
1267
+ it('clones TemplateStringExpression', () => {
1268
+ const original = Parser_1.Parser.parse(`
1269
+ sub test()
1270
+ print \`hello \${name} \\n\`
1271
+ end sub
1272
+ `).ast;
1273
+ testClone(original);
1274
+ });
1275
+ it('clones TemplateStringExpression with undefined expressions', () => {
1276
+ const original = Parser_1.Parser.parse(`
1277
+ sub test()
1278
+ print \`hello \${name}\`
1279
+ end sub
1280
+ `).ast;
1281
+ original.findChild(reflection_1.isTemplateStringExpression).quasis = undefined;
1282
+ original.findChild(reflection_1.isTemplateStringExpression).expressions = undefined;
1283
+ testClone(original);
1284
+ });
1285
+ it('clones TemplateStringExpression with undefined expressions', () => {
1286
+ const original = Parser_1.Parser.parse(`
1287
+ sub test()
1288
+ print \`hello \${name}\`
1289
+ end sub
1290
+ `).ast;
1291
+ original.findChild(reflection_1.isTemplateStringExpression).quasis.push(undefined);
1292
+ original.findChild(reflection_1.isTemplateStringExpression).expressions.push(undefined);
1293
+ testClone(original);
1294
+ });
1295
+ it('clones TemplateStringExpression', () => {
1296
+ const original = Parser_1.Parser.parse(`
1297
+ sub test()
1298
+ print tag\`hello \${name} \\n\`
1299
+ end sub
1300
+ `).ast;
1301
+ testClone(original);
1302
+ });
1303
+ it('clones TemplateStringExpression with undefined expressions', () => {
1304
+ const original = Parser_1.Parser.parse(`
1305
+ sub test()
1306
+ print tag\`hello \${name}\`
1307
+ end sub
1308
+ `).ast;
1309
+ original.findChild(reflection_1.isTaggedTemplateStringExpression).quasis = undefined;
1310
+ original.findChild(reflection_1.isTaggedTemplateStringExpression).expressions = undefined;
1311
+ testClone(original);
1312
+ });
1313
+ it('clones TemplateStringExpression with undefined expressions', () => {
1314
+ const original = Parser_1.Parser.parse(`
1315
+ sub test()
1316
+ print tag\`hello \${name}\`
1317
+ end sub
1318
+ `).ast;
1319
+ original.findChild(reflection_1.isTaggedTemplateStringExpression).quasis.push(undefined);
1320
+ original.findChild(reflection_1.isTaggedTemplateStringExpression).expressions.push(undefined);
1321
+ testClone(original);
1322
+ });
1323
+ it('clones TernaryExpression', () => {
1324
+ const original = Parser_1.Parser.parse(`
1325
+ sub test()
1326
+ print true ? 1 : 2
1327
+ end sub
1328
+ `).ast;
1329
+ testClone(original);
1330
+ });
1331
+ it('clones TernaryExpression with undefined expressions', () => {
1332
+ const original = Parser_1.Parser.parse(`
1333
+ sub test()
1334
+ print true ? 1 : 2
1335
+ end sub
1336
+ `).ast;
1337
+ original.findChild(reflection_1.isTernaryExpression).test = undefined;
1338
+ original.findChild(reflection_1.isTernaryExpression).consequent = undefined;
1339
+ original.findChild(reflection_1.isTernaryExpression).alternate = undefined;
1340
+ testClone(original);
1341
+ });
1342
+ it('clones NullCoalescingExpression', () => {
1343
+ const original = Parser_1.Parser.parse(`
1344
+ sub test()
1345
+ print a ?? b
1346
+ end sub
1347
+ `).ast;
1348
+ testClone(original);
1349
+ });
1350
+ it('clones NullCoalescingExpression with undefined expressions', () => {
1351
+ const original = Parser_1.Parser.parse(`
1352
+ sub test()
1353
+ print a ?? b
1354
+ end sub
1355
+ `).ast;
1356
+ original.findChild(reflection_1.isNullCoalescingExpression).consequent = undefined;
1357
+ original.findChild(reflection_1.isNullCoalescingExpression).alternate = undefined;
1358
+ testClone(original);
1359
+ });
1360
+ it('clones RegexLiteralExpression', () => {
1361
+ const original = Parser_1.Parser.parse(`
1362
+ sub test()
1363
+ print /test/gi
1364
+ end sub
1365
+ `).ast;
1366
+ testClone(original);
1367
+ });
1368
+ it('clones TypeCastExpression', () => {
1369
+ const original = Parser_1.Parser.parse(`
1370
+ sub test()
1371
+ print name as string
1372
+ end sub
1373
+ `).ast;
1374
+ testClone(original);
1375
+ });
1376
+ it('clones TypeCastExpression with undefined expression', () => {
1377
+ const original = Parser_1.Parser.parse(`
1378
+ sub test()
1379
+ print name as string
1380
+ end sub
1381
+ `).ast;
1382
+ original.findChild(reflection_1.isTypecastExpression).obj = undefined;
1383
+ testClone(original);
1384
+ });
1385
+ it('clones AugmentedAssignmentStatement', () => {
1386
+ const original = Parser_1.Parser.parse(`
1387
+ sub test()
1388
+ a += 1
1389
+ end sub
1390
+ `).ast;
1391
+ testClone(original);
1392
+ });
1393
+ it('clones TypecastStatement', () => {
1394
+ const original = Parser_1.Parser.parse(`
1395
+ sub test()
1396
+ typecast m as dynamic
1397
+ a += 1
1398
+ end sub
1399
+ `).ast;
1400
+ testClone(original);
1401
+ });
1402
+ it('clones ConditionalCompile statements', () => {
1403
+ const original = Parser_1.Parser.parse(`
1404
+ sub test()
1405
+ #const one = true
1406
+ #if true
1407
+ print "true"
1408
+ #else
1409
+ print "false
1410
+ #error "Custom error"
1411
+ #endif
1412
+ end sub
1413
+ `).ast;
1414
+ testClone(original);
1415
+ });
1416
+ it('clones AliasStatement', () => {
1417
+ const original = Parser_1.Parser.parse(`
1418
+ alias test2 = test
1419
+ sub test()
1420
+ end sub
1421
+ `).ast;
1422
+ testClone(original);
1423
+ });
1424
+ it('clones AnnotationExpressions above every statement type', () => {
1425
+ const original = Parser_1.Parser.parse(`
1426
+ @annotation()
1427
+ sub test()
1428
+ @annotation()
1429
+ statement = true
1430
+ @annotation()
1431
+ call()
1432
+ @annotation()
1433
+ 'comment
1434
+ end sub
1435
+
1436
+ @annotation()
1437
+ class Person
1438
+ end class
1439
+
1440
+ @annotation()
1441
+ enum Direction
1442
+ end enum
1443
+
1444
+ @annotation()
1445
+ namespace alpha
1446
+ end namespace
1447
+
1448
+ @annotation()
1449
+ const thing = 1
1450
+ `).ast;
1451
+ testClone(original);
1452
+ });
1453
+ });
1454
+ });
1455
+ //# sourceMappingURL=AstNode.spec.js.map