brighterscript 0.66.0-alpha.8 → 0.67.0

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 (472) hide show
  1. package/CHANGELOG.md +120 -71
  2. package/README.md +14 -418
  3. package/dist/BsConfig.d.ts +25 -2
  4. package/dist/Cache.js +3 -3
  5. package/dist/Cache.js.map +1 -1
  6. package/dist/CodeActionUtil.d.ts +3 -3
  7. package/dist/CodeActionUtil.js.map +1 -1
  8. package/dist/CommentFlagProcessor.d.ts +3 -4
  9. package/dist/CommentFlagProcessor.js +4 -3
  10. package/dist/CommentFlagProcessor.js.map +1 -1
  11. package/dist/DependencyGraph.js +8 -8
  12. package/dist/DependencyGraph.js.map +1 -1
  13. package/dist/DiagnosticFilterer.d.ts +8 -4
  14. package/dist/DiagnosticFilterer.js +71 -38
  15. package/dist/DiagnosticFilterer.js.map +1 -1
  16. package/dist/DiagnosticMessages.d.ts +15 -36
  17. package/dist/DiagnosticMessages.js +15 -61
  18. package/dist/DiagnosticMessages.js.map +1 -1
  19. package/dist/DiagnosticSeverityAdjuster.js +3 -0
  20. package/dist/DiagnosticSeverityAdjuster.js.map +1 -1
  21. package/dist/FunctionScope.d.ts +2 -3
  22. package/dist/FunctionScope.js +0 -3
  23. package/dist/FunctionScope.js.map +1 -1
  24. package/dist/LanguageServer.d.ts +1 -2
  25. package/dist/LanguageServer.js +29 -35
  26. package/dist/LanguageServer.js.map +1 -1
  27. package/dist/Logger.d.ts +5 -9
  28. package/dist/Logger.js +18 -22
  29. package/dist/Logger.js.map +1 -1
  30. package/dist/PluginInterface.d.ts +13 -15
  31. package/dist/PluginInterface.js +16 -70
  32. package/dist/PluginInterface.js.map +1 -1
  33. package/dist/Program.d.ts +105 -138
  34. package/dist/Program.js +479 -702
  35. package/dist/Program.js.map +1 -1
  36. package/dist/ProgramBuilder.d.ts +8 -19
  37. package/dist/ProgramBuilder.js +82 -87
  38. package/dist/ProgramBuilder.js.map +1 -1
  39. package/dist/Scope.d.ts +56 -46
  40. package/dist/Scope.js +281 -217
  41. package/dist/Scope.js.map +1 -1
  42. package/dist/Stopwatch.js +1 -1
  43. package/dist/Stopwatch.js.map +1 -1
  44. package/dist/SymbolTable.d.ts +12 -68
  45. package/dist/SymbolTable.js +28 -213
  46. package/dist/SymbolTable.js.map +1 -1
  47. package/dist/XmlScope.d.ts +5 -7
  48. package/dist/XmlScope.js +36 -76
  49. package/dist/XmlScope.js.map +1 -1
  50. package/dist/astUtils/{Editor.d.ts → AstEditor.d.ts} +1 -6
  51. package/dist/astUtils/{Editor.js → AstEditor.js} +3 -9
  52. package/dist/astUtils/AstEditor.js.map +1 -0
  53. package/dist/astUtils/{Editor.spec.js → AstEditor.spec.js} +6 -10
  54. package/dist/astUtils/AstEditor.spec.js.map +1 -0
  55. package/dist/astUtils/creators.d.ts +8 -19
  56. package/dist/astUtils/creators.js +22 -54
  57. package/dist/astUtils/creators.js.map +1 -1
  58. package/dist/astUtils/creators.spec.js +0 -10
  59. package/dist/astUtils/creators.spec.js.map +1 -1
  60. package/dist/astUtils/reflection.d.ts +45 -81
  61. package/dist/astUtils/reflection.js +157 -220
  62. package/dist/astUtils/reflection.js.map +1 -1
  63. package/dist/astUtils/reflection.spec.js +19 -96
  64. package/dist/astUtils/reflection.spec.js.map +1 -1
  65. package/dist/astUtils/stackedVisitor.spec.js.map +1 -1
  66. package/dist/astUtils/visitors.d.ts +14 -18
  67. package/dist/astUtils/visitors.js +9 -22
  68. package/dist/astUtils/visitors.js.map +1 -1
  69. package/dist/astUtils/visitors.spec.js +9 -62
  70. package/dist/astUtils/visitors.spec.js.map +1 -1
  71. package/dist/astUtils/xml.d.ts +9 -9
  72. package/dist/astUtils/xml.js +6 -6
  73. package/dist/astUtils/xml.js.map +1 -1
  74. package/dist/bscPlugin/BscPlugin.d.ts +8 -11
  75. package/dist/bscPlugin/BscPlugin.js +21 -29
  76. package/dist/bscPlugin/BscPlugin.js.map +1 -1
  77. package/dist/bscPlugin/CallExpressionInfo.d.ts +6 -5
  78. package/dist/bscPlugin/CallExpressionInfo.js +2 -2
  79. package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
  80. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +11 -11
  81. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  82. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +4 -4
  83. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
  84. package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +1 -49
  85. package/dist/bscPlugin/completions/CompletionsProcessor.js +23 -424
  86. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
  87. package/dist/bscPlugin/definition/DefinitionProvider.d.ts +13 -0
  88. package/dist/bscPlugin/definition/DefinitionProvider.js +200 -0
  89. package/dist/bscPlugin/definition/DefinitionProvider.js.map +1 -0
  90. package/dist/bscPlugin/definition/DefinitionProvider.spec.js +87 -0
  91. package/dist/bscPlugin/definition/DefinitionProvider.spec.js.map +1 -0
  92. package/dist/bscPlugin/hover/HoverProcessor.d.ts +3 -7
  93. package/dist/bscPlugin/hover/HoverProcessor.js +88 -128
  94. package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
  95. package/dist/bscPlugin/hover/HoverProcessor.spec.js +24 -336
  96. package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
  97. package/dist/bscPlugin/references/ReferencesProvider.d.ts +12 -0
  98. package/dist/bscPlugin/references/ReferencesProvider.js +56 -0
  99. package/dist/bscPlugin/references/ReferencesProvider.js.map +1 -0
  100. package/dist/bscPlugin/references/ReferencesProvider.spec.js +51 -0
  101. package/dist/bscPlugin/references/ReferencesProvider.spec.js.map +1 -0
  102. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +0 -1
  103. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +5 -49
  104. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
  105. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +0 -22
  106. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -1
  107. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.d.ts +7 -0
  108. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.js +22 -0
  109. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.js.map +1 -0
  110. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js +290 -0
  111. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js.map +1 -0
  112. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.d.ts +7 -0
  113. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.js +26 -0
  114. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.js.map +1 -0
  115. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js +245 -0
  116. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js.map +1 -0
  117. package/dist/bscPlugin/symbols/symbolUtils.d.ts +5 -0
  118. package/dist/bscPlugin/symbols/symbolUtils.js +140 -0
  119. package/dist/bscPlugin/symbols/symbolUtils.js.map +1 -0
  120. package/dist/bscPlugin/transpile/{BrsFileTranspileProcessor.d.ts → BrsFilePreTranspileProcessor.d.ts} +2 -4
  121. package/dist/bscPlugin/transpile/{BrsFileTranspileProcessor.js → BrsFilePreTranspileProcessor.js} +15 -36
  122. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +1 -0
  123. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js +46 -0
  124. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js.map +1 -0
  125. package/dist/bscPlugin/validation/BrsFileValidator.d.ts +1 -0
  126. package/dist/bscPlugin/validation/BrsFileValidator.js +30 -41
  127. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
  128. package/dist/bscPlugin/validation/BrsFileValidator.spec.js +2 -2
  129. package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -1
  130. package/dist/bscPlugin/validation/ProgramValidator.d.ts +3 -3
  131. package/dist/bscPlugin/validation/ProgramValidator.js +6 -6
  132. package/dist/bscPlugin/validation/ProgramValidator.js.map +1 -1
  133. package/dist/bscPlugin/validation/ScopeValidator.d.ts +6 -28
  134. package/dist/bscPlugin/validation/ScopeValidator.js +166 -387
  135. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
  136. package/dist/bscPlugin/validation/XmlFileValidator.js +9 -9
  137. package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -1
  138. package/dist/diagnosticUtils.d.ts +2 -3
  139. package/dist/diagnosticUtils.js +5 -5
  140. package/dist/diagnosticUtils.js.map +1 -1
  141. package/dist/examples/plugins/removePrint.js +1 -1
  142. package/dist/examples/plugins/removePrint.js.map +1 -1
  143. package/dist/files/BrsFile.Class.spec.js +143 -114
  144. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  145. package/dist/files/BrsFile.d.ts +61 -83
  146. package/dist/files/BrsFile.js +552 -607
  147. package/dist/files/BrsFile.js.map +1 -1
  148. package/dist/files/BrsFile.spec.js +1365 -1201
  149. package/dist/files/BrsFile.spec.js.map +1 -1
  150. package/dist/files/XmlFile.d.ts +28 -56
  151. package/dist/files/XmlFile.js +103 -89
  152. package/dist/files/XmlFile.js.map +1 -1
  153. package/dist/files/XmlFile.spec.js +179 -122
  154. package/dist/files/XmlFile.spec.js.map +1 -1
  155. package/dist/files/tests/imports.spec.js +19 -29
  156. package/dist/files/tests/imports.spec.js.map +1 -1
  157. package/dist/files/tests/optionalChaning.spec.js +14 -14
  158. package/dist/files/tests/optionalChaning.spec.js.map +1 -1
  159. package/dist/globalCallables.js +83 -88
  160. package/dist/globalCallables.js.map +1 -1
  161. package/dist/index.d.ts +1 -9
  162. package/dist/index.js +1 -9
  163. package/dist/index.js.map +1 -1
  164. package/dist/interfaces.d.ts +173 -423
  165. package/dist/interfaces.js +0 -24
  166. package/dist/interfaces.js.map +1 -1
  167. package/dist/lexer/Lexer.d.ts +9 -15
  168. package/dist/lexer/Lexer.js +35 -46
  169. package/dist/lexer/Lexer.js.map +1 -1
  170. package/dist/lexer/Lexer.spec.js +48 -40
  171. package/dist/lexer/Lexer.spec.js.map +1 -1
  172. package/dist/lexer/Token.d.ts +1 -5
  173. package/dist/lexer/Token.js +1 -1
  174. package/dist/lexer/Token.js.map +1 -1
  175. package/dist/lexer/TokenKind.d.ts +0 -6
  176. package/dist/lexer/TokenKind.js +2 -14
  177. package/dist/lexer/TokenKind.js.map +1 -1
  178. package/dist/logging.d.ts +9 -0
  179. package/dist/logging.js +16 -0
  180. package/dist/logging.js.map +1 -0
  181. package/dist/parser/AstNode.d.ts +6 -90
  182. package/dist/parser/AstNode.js +5 -96
  183. package/dist/parser/AstNode.js.map +1 -1
  184. package/dist/parser/AstNode.spec.js.map +1 -1
  185. package/dist/parser/BrsTranspileState.d.ts +3 -4
  186. package/dist/parser/BrsTranspileState.js +2 -3
  187. package/dist/parser/BrsTranspileState.js.map +1 -1
  188. package/dist/parser/Expression.d.ts +114 -137
  189. package/dist/parser/Expression.js +244 -373
  190. package/dist/parser/Expression.js.map +1 -1
  191. package/dist/parser/Parser.Class.spec.js +19 -46
  192. package/dist/parser/Parser.Class.spec.js.map +1 -1
  193. package/dist/parser/Parser.d.ts +18 -14
  194. package/dist/parser/Parser.js +196 -175
  195. package/dist/parser/Parser.js.map +1 -1
  196. package/dist/parser/Parser.spec.d.ts +0 -2
  197. package/dist/parser/Parser.spec.js +10 -674
  198. package/dist/parser/Parser.spec.js.map +1 -1
  199. package/dist/parser/SGParser.d.ts +6 -44
  200. package/dist/parser/SGParser.js +198 -194
  201. package/dist/parser/SGParser.js.map +1 -1
  202. package/dist/parser/SGParser.spec.js +11 -14
  203. package/dist/parser/SGParser.spec.js.map +1 -1
  204. package/dist/parser/SGTypes.d.ts +52 -280
  205. package/dist/parser/SGTypes.js +185 -562
  206. package/dist/parser/SGTypes.js.map +1 -1
  207. package/dist/parser/Statement.d.ts +140 -172
  208. package/dist/parser/Statement.js +201 -337
  209. package/dist/parser/Statement.js.map +1 -1
  210. package/dist/parser/Statement.spec.js.map +1 -1
  211. package/dist/parser/TranspileState.d.ts +3 -2
  212. package/dist/parser/TranspileState.js +8 -10
  213. package/dist/parser/TranspileState.js.map +1 -1
  214. package/dist/parser/tests/Parser.spec.js +3 -5
  215. package/dist/parser/tests/Parser.spec.js.map +1 -1
  216. package/dist/parser/tests/controlFlow/For.spec.js +8 -16
  217. package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
  218. package/dist/parser/tests/controlFlow/ForEach.spec.js +6 -12
  219. package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
  220. package/dist/parser/tests/controlFlow/While.spec.js +4 -8
  221. package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
  222. package/dist/parser/tests/expression/Call.spec.js +4 -4
  223. package/dist/parser/tests/expression/Call.spec.js.map +1 -1
  224. package/dist/parser/tests/expression/Indexing.spec.js +25 -0
  225. package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
  226. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +73 -29
  227. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
  228. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +10 -10
  229. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -1
  230. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +24 -24
  231. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +1 -1
  232. package/dist/parser/tests/expression/TemplateStringExpression.spec.js +47 -35
  233. package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
  234. package/dist/parser/tests/expression/TernaryExpression.spec.js +83 -36
  235. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
  236. package/dist/parser/tests/expression/UnaryExpression.spec.js +2 -2
  237. package/dist/parser/tests/expression/UnaryExpression.spec.js.map +1 -1
  238. package/dist/parser/tests/statement/ConstStatement.spec.js +26 -27
  239. package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -1
  240. package/dist/parser/tests/statement/Continue.spec.js +2 -2
  241. package/dist/parser/tests/statement/Continue.spec.js.map +1 -1
  242. package/dist/parser/tests/statement/Dim.spec.js.map +1 -1
  243. package/dist/parser/tests/statement/Enum.spec.js +393 -90
  244. package/dist/parser/tests/statement/Enum.spec.js.map +1 -1
  245. package/dist/parser/tests/statement/For.spec.js +6 -6
  246. package/dist/parser/tests/statement/For.spec.js.map +1 -1
  247. package/dist/parser/tests/statement/ForEach.spec.js +4 -4
  248. package/dist/parser/tests/statement/ForEach.spec.js.map +1 -1
  249. package/dist/parser/tests/statement/Function.spec.js +1 -1
  250. package/dist/parser/tests/statement/Function.spec.js.map +1 -1
  251. package/dist/parser/tests/statement/InterfaceStatement.spec.js +18 -18
  252. package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
  253. package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
  254. package/dist/parser/tests/statement/PrintStatement.spec.js +13 -16
  255. package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
  256. package/dist/parser/tests/statement/ReturnStatement.spec.js +3 -5
  257. package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
  258. package/dist/parser/tests/statement/Set.spec.js +13 -26
  259. package/dist/parser/tests/statement/Set.spec.js.map +1 -1
  260. package/dist/parser/tests/statement/Throw.spec.js.map +1 -1
  261. package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
  262. package/dist/preprocessor/Chunk.js +1 -2
  263. package/dist/preprocessor/Chunk.js.map +1 -1
  264. package/dist/preprocessor/Preprocessor.d.ts +3 -4
  265. package/dist/preprocessor/Preprocessor.js +3 -3
  266. package/dist/preprocessor/Preprocessor.js.map +1 -1
  267. package/dist/preprocessor/PreprocessorParser.js +8 -1
  268. package/dist/preprocessor/PreprocessorParser.js.map +1 -1
  269. package/dist/roku-types/data.json +293 -243
  270. package/dist/roku-types/index.d.ts +38 -17
  271. package/dist/types/ArrayType.d.ts +4 -9
  272. package/dist/types/ArrayType.js +24 -72
  273. package/dist/types/ArrayType.js.map +1 -1
  274. package/dist/types/ArrayType.spec.js +10 -39
  275. package/dist/types/ArrayType.spec.js.map +1 -1
  276. package/dist/types/BooleanType.d.ts +4 -8
  277. package/dist/types/BooleanType.js +8 -19
  278. package/dist/types/BooleanType.js.map +1 -1
  279. package/dist/types/BooleanType.spec.js +3 -9
  280. package/dist/types/BooleanType.spec.js.map +1 -1
  281. package/dist/types/BscType.d.ts +2 -29
  282. package/dist/types/BscType.js +0 -113
  283. package/dist/types/BscType.js.map +1 -1
  284. package/dist/types/CustomType.d.ts +9 -0
  285. package/dist/types/CustomType.js +32 -0
  286. package/dist/types/CustomType.js.map +1 -0
  287. package/dist/types/DoubleType.d.ts +4 -8
  288. package/dist/types/DoubleType.js +20 -23
  289. package/dist/types/DoubleType.js.map +1 -1
  290. package/dist/types/DoubleType.spec.js +3 -11
  291. package/dist/types/DoubleType.spec.js.map +1 -1
  292. package/dist/types/DynamicType.d.ts +3 -9
  293. package/dist/types/DynamicType.js +2 -18
  294. package/dist/types/DynamicType.js.map +1 -1
  295. package/dist/types/DynamicType.spec.js +4 -15
  296. package/dist/types/DynamicType.spec.js.map +1 -1
  297. package/dist/types/FloatType.d.ts +4 -8
  298. package/dist/types/FloatType.js +20 -23
  299. package/dist/types/FloatType.js.map +1 -1
  300. package/dist/types/FloatType.spec.js +3 -3
  301. package/dist/types/FloatType.spec.js.map +1 -1
  302. package/dist/types/FunctionType.d.ts +20 -10
  303. package/dist/types/FunctionType.js +52 -27
  304. package/dist/types/FunctionType.js.map +1 -1
  305. package/dist/types/FunctionType.spec.js +23 -0
  306. package/dist/types/FunctionType.spec.js.map +1 -0
  307. package/dist/types/IntegerType.d.ts +4 -8
  308. package/dist/types/IntegerType.js +20 -23
  309. package/dist/types/IntegerType.js.map +1 -1
  310. package/dist/types/IntegerType.spec.js +3 -7
  311. package/dist/types/IntegerType.spec.js.map +1 -1
  312. package/dist/types/InterfaceType.d.ts +10 -12
  313. package/dist/types/InterfaceType.js +48 -23
  314. package/dist/types/InterfaceType.js.map +1 -1
  315. package/dist/types/InterfaceType.spec.js +45 -82
  316. package/dist/types/InterfaceType.spec.js.map +1 -1
  317. package/dist/types/InvalidType.d.ts +4 -7
  318. package/dist/types/InvalidType.js +8 -18
  319. package/dist/types/InvalidType.js.map +1 -1
  320. package/dist/types/InvalidType.spec.js +3 -7
  321. package/dist/types/InvalidType.spec.js.map +1 -1
  322. package/dist/types/LongIntegerType.d.ts +4 -8
  323. package/dist/types/LongIntegerType.js +20 -23
  324. package/dist/types/LongIntegerType.js.map +1 -1
  325. package/dist/types/LongIntegerType.spec.js +3 -9
  326. package/dist/types/LongIntegerType.spec.js.map +1 -1
  327. package/dist/types/ObjectType.d.ts +4 -8
  328. package/dist/types/ObjectType.js +7 -21
  329. package/dist/types/ObjectType.js.map +1 -1
  330. package/dist/types/ObjectType.spec.js +2 -2
  331. package/dist/types/ObjectType.spec.js.map +1 -1
  332. package/dist/types/StringType.d.ts +4 -11
  333. package/dist/types/StringType.js +8 -23
  334. package/dist/types/StringType.js.map +1 -1
  335. package/dist/types/StringType.spec.js +2 -2
  336. package/dist/types/StringType.spec.js.map +1 -1
  337. package/dist/types/UninitializedType.d.ts +3 -7
  338. package/dist/types/UninitializedType.js +3 -14
  339. package/dist/types/UninitializedType.js.map +1 -1
  340. package/dist/types/VoidType.d.ts +4 -8
  341. package/dist/types/VoidType.js +8 -18
  342. package/dist/types/VoidType.js.map +1 -1
  343. package/dist/types/VoidType.spec.js +2 -2
  344. package/dist/types/VoidType.spec.js.map +1 -1
  345. package/dist/util.d.ts +43 -104
  346. package/dist/util.js +243 -640
  347. package/dist/util.js.map +1 -1
  348. package/dist/validators/ClassValidator.d.ts +6 -1
  349. package/dist/validators/ClassValidator.js +61 -20
  350. package/dist/validators/ClassValidator.js.map +1 -1
  351. package/package.json +13 -12
  352. package/dist/ActionPipeline.d.ts +0 -10
  353. package/dist/ActionPipeline.js +0 -40
  354. package/dist/ActionPipeline.js.map +0 -1
  355. package/dist/AstValidationSegmenter.d.ts +0 -25
  356. package/dist/AstValidationSegmenter.js +0 -150
  357. package/dist/AstValidationSegmenter.js.map +0 -1
  358. package/dist/CacheVerifier.d.ts +0 -7
  359. package/dist/CacheVerifier.js +0 -20
  360. package/dist/CacheVerifier.js.map +0 -1
  361. package/dist/astUtils/Editor.js.map +0 -1
  362. package/dist/astUtils/Editor.spec.js.map +0 -1
  363. package/dist/bscPlugin/FileWriter.d.ts +0 -6
  364. package/dist/bscPlugin/FileWriter.js +0 -24
  365. package/dist/bscPlugin/FileWriter.js.map +0 -1
  366. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +0 -1658
  367. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +0 -1
  368. package/dist/bscPlugin/fileProviders/FileProvider.d.ts +0 -9
  369. package/dist/bscPlugin/fileProviders/FileProvider.js +0 -51
  370. package/dist/bscPlugin/fileProviders/FileProvider.js.map +0 -1
  371. package/dist/bscPlugin/serialize/BslibInjector.spec.js +0 -19
  372. package/dist/bscPlugin/serialize/BslibInjector.spec.js.map +0 -1
  373. package/dist/bscPlugin/serialize/BslibManager.d.ts +0 -9
  374. package/dist/bscPlugin/serialize/BslibManager.js +0 -40
  375. package/dist/bscPlugin/serialize/BslibManager.js.map +0 -1
  376. package/dist/bscPlugin/serialize/FileSerializer.d.ts +0 -9
  377. package/dist/bscPlugin/serialize/FileSerializer.js +0 -72
  378. package/dist/bscPlugin/serialize/FileSerializer.js.map +0 -1
  379. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +0 -1
  380. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js +0 -41
  381. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +0 -1
  382. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +0 -11
  383. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js +0 -53
  384. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +0 -1
  385. package/dist/bscPlugin/validation/ScopeValidator.spec.js +0 -2004
  386. package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +0 -1
  387. package/dist/files/AssetFile.d.ts +0 -26
  388. package/dist/files/AssetFile.js +0 -26
  389. package/dist/files/AssetFile.js.map +0 -1
  390. package/dist/files/Factory.d.ts +0 -25
  391. package/dist/files/Factory.js +0 -22
  392. package/dist/files/Factory.js.map +0 -1
  393. package/dist/files/File.d.ts +0 -106
  394. package/dist/files/File.js +0 -16
  395. package/dist/files/File.js.map +0 -1
  396. package/dist/files/LazyFileData.d.ts +0 -20
  397. package/dist/files/LazyFileData.js +0 -54
  398. package/dist/files/LazyFileData.js.map +0 -1
  399. package/dist/files/LazyFileData.spec.js +0 -27
  400. package/dist/files/LazyFileData.spec.js.map +0 -1
  401. package/dist/parser/tests/expression/TypeExpression.spec.js +0 -127
  402. package/dist/parser/tests/expression/TypeExpression.spec.js.map +0 -1
  403. package/dist/types/AssociativeArrayType.d.ts +0 -11
  404. package/dist/types/AssociativeArrayType.js +0 -52
  405. package/dist/types/AssociativeArrayType.js.map +0 -1
  406. package/dist/types/BaseFunctionType.d.ts +0 -9
  407. package/dist/types/BaseFunctionType.js +0 -25
  408. package/dist/types/BaseFunctionType.js.map +0 -1
  409. package/dist/types/BscTypeKind.d.ts +0 -25
  410. package/dist/types/BscTypeKind.js +0 -30
  411. package/dist/types/BscTypeKind.js.map +0 -1
  412. package/dist/types/BuiltInInterfaceAdder.d.ts +0 -23
  413. package/dist/types/BuiltInInterfaceAdder.js +0 -160
  414. package/dist/types/BuiltInInterfaceAdder.js.map +0 -1
  415. package/dist/types/BuiltInInterfaceAdder.spec.d.ts +0 -1
  416. package/dist/types/BuiltInInterfaceAdder.spec.js +0 -116
  417. package/dist/types/BuiltInInterfaceAdder.spec.js.map +0 -1
  418. package/dist/types/ClassType.d.ts +0 -17
  419. package/dist/types/ClassType.js +0 -58
  420. package/dist/types/ClassType.js.map +0 -1
  421. package/dist/types/ClassType.spec.d.ts +0 -1
  422. package/dist/types/ClassType.spec.js +0 -77
  423. package/dist/types/ClassType.spec.js.map +0 -1
  424. package/dist/types/ComponentType.d.ts +0 -26
  425. package/dist/types/ComponentType.js +0 -83
  426. package/dist/types/ComponentType.js.map +0 -1
  427. package/dist/types/EnumType.d.ts +0 -40
  428. package/dist/types/EnumType.js +0 -81
  429. package/dist/types/EnumType.js.map +0 -1
  430. package/dist/types/EnumType.spec.d.ts +0 -1
  431. package/dist/types/EnumType.spec.js +0 -33
  432. package/dist/types/EnumType.spec.js.map +0 -1
  433. package/dist/types/InheritableType.d.ts +0 -28
  434. package/dist/types/InheritableType.js +0 -152
  435. package/dist/types/InheritableType.js.map +0 -1
  436. package/dist/types/NamespaceType.d.ts +0 -12
  437. package/dist/types/NamespaceType.js +0 -28
  438. package/dist/types/NamespaceType.js.map +0 -1
  439. package/dist/types/ReferenceType.d.ts +0 -63
  440. package/dist/types/ReferenceType.js +0 -423
  441. package/dist/types/ReferenceType.js.map +0 -1
  442. package/dist/types/ReferenceType.spec.d.ts +0 -1
  443. package/dist/types/ReferenceType.spec.js +0 -137
  444. package/dist/types/ReferenceType.spec.js.map +0 -1
  445. package/dist/types/TypedFunctionType.d.ts +0 -33
  446. package/dist/types/TypedFunctionType.js +0 -106
  447. package/dist/types/TypedFunctionType.js.map +0 -1
  448. package/dist/types/TypedFunctionType.spec.d.ts +0 -1
  449. package/dist/types/TypedFunctionType.spec.js +0 -122
  450. package/dist/types/TypedFunctionType.spec.js.map +0 -1
  451. package/dist/types/UnionType.d.ts +0 -20
  452. package/dist/types/UnionType.js +0 -123
  453. package/dist/types/UnionType.js.map +0 -1
  454. package/dist/types/UnionType.spec.d.ts +0 -1
  455. package/dist/types/UnionType.spec.js +0 -130
  456. package/dist/types/UnionType.spec.js.map +0 -1
  457. package/dist/types/helper.spec.d.ts +0 -1
  458. package/dist/types/helper.spec.js +0 -145
  459. package/dist/types/helper.spec.js.map +0 -1
  460. package/dist/types/helpers.d.ts +0 -24
  461. package/dist/types/helpers.js +0 -178
  462. package/dist/types/helpers.js.map +0 -1
  463. package/dist/types/index.d.ts +0 -22
  464. package/dist/types/index.js +0 -39
  465. package/dist/types/index.js.map +0 -1
  466. /package/dist/astUtils/{Editor.spec.d.ts → AstEditor.spec.d.ts} +0 -0
  467. /package/dist/bscPlugin/{completions/CompletionsProcessor.spec.d.ts → definition/DefinitionProvider.spec.d.ts} +0 -0
  468. /package/dist/bscPlugin/{serialize/BslibInjector.spec.d.ts → references/ReferencesProvider.spec.d.ts} +0 -0
  469. /package/dist/bscPlugin/{transpile/BrsFileTranspileProcessor.spec.d.ts → symbols/DocumentSymbolProcessor.spec.d.ts} +0 -0
  470. /package/dist/bscPlugin/{validation/ScopeValidator.spec.d.ts → symbols/WorkspaceSymbolProcessor.spec.d.ts} +0 -0
  471. /package/dist/{files/LazyFileData.spec.d.ts → bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.d.ts} +0 -0
  472. /package/dist/{parser/tests/expression/TypeExpression.spec.d.ts → types/FunctionType.spec.d.ts} +0 -0
@@ -1,304 +1,152 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SGAst = exports.SGComponent = exports.SGInterface = exports.SGInterfaceFunction = exports.getBscTypeFromSGFieldType = exports.SGFieldTypes = exports.SGFieldType = exports.SGInterfaceField = exports.SGScript = exports.SGCustomization = exports.SGChildren = exports.SGNode = exports.SGProlog = exports.SGElement = exports.SGAttribute = void 0;
3
+ exports.SGAst = exports.SGComponent = exports.SGInterface = exports.SGFunction = exports.SGFieldTypes = exports.SGField = exports.SGScript = exports.SGChildren = exports.SGNode = exports.SGProlog = exports.SGTag = void 0;
4
4
  const source_map_1 = require("source-map");
5
5
  const creators_1 = require("../astUtils/creators");
6
- const BooleanType_1 = require("../types/BooleanType");
7
- const DynamicType_1 = require("../types/DynamicType");
8
- const FloatType_1 = require("../types/FloatType");
9
- const IntegerType_1 = require("../types/IntegerType");
10
- const LongIntegerType_1 = require("../types/LongIntegerType");
11
- const StringType_1 = require("../types/StringType");
6
+ const xml_1 = require("../astUtils/xml");
12
7
  const util_1 = require("../util");
13
- class SGAttribute {
14
- constructor(key, equals, openingQuote, value, closingQuote) {
15
- this.tokens = {};
16
- this._range = null;
17
- this.tokens.key = key;
18
- this.tokens.equals = equals;
19
- this.tokens.openingQuote = openingQuote;
20
- this.tokens.value = value;
21
- this.tokens.closingQuote = closingQuote;
22
- }
23
- get key() {
24
- return this.tokens.key.text;
25
- }
26
- /**
27
- * The value of this attribute. This does not including the opening or closing quote
28
- */
29
- get value() {
30
- var _a;
31
- return (_a = this.tokens.value) === null || _a === void 0 ? void 0 : _a.text;
32
- }
33
- set value(val) {
34
- if (val === null || val === undefined) {
35
- val = '';
36
- }
37
- if (!this.tokens.equals) {
38
- this.tokens.equals = { text: '=' };
39
- }
40
- if (this.tokens.value) {
41
- this.tokens.value.text = val;
42
- }
43
- else {
44
- this.tokens.value = { text: val };
45
- }
46
- }
47
- get range() {
48
- if (!this._range) {
49
- this._range = util_1.default.createBoundingRange(this.tokens.key, this.tokens.equals, this.tokens.openingQuote, this.tokens.value, this.tokens.closingQuote);
50
- }
51
- return this._range;
52
- }
53
- transpile(state) {
54
- const result = [
55
- state.transpileToken(this.tokens.key)
56
- ];
57
- if (this.tokens.value) {
58
- result.push(state.transpileToken(this.tokens.equals, '='), state.transpileToken(this.tokens.openingQuote, '"'), state.transpileToken(this.tokens.value), state.transpileToken(this.tokens.closingQuote, '"'));
59
- }
60
- return new source_map_1.SourceNode(null, null, null, result);
61
- }
62
- clone() {
63
- return new SGAttribute(Object.assign({}, this.tokens.key), Object.assign({}, this.tokens.equals), Object.assign({}, this.tokens.openingQuote), Object.assign({}, this.tokens.value), Object.assign({}, this.tokens.closingQuote));
64
- }
65
- }
66
- exports.SGAttribute = SGAttribute;
67
- class SGElement {
68
- constructor(startTagOpen, startTagName, attributes = [], startTagClose, elements = [], endTagOpen, endTagName, endTagClose) {
69
- this.tokens = {};
70
- /**
71
- * Array of attributes found on this tag
72
- */
73
- this.attributes = [];
74
- /**
75
- * The array of direct children AST elements of this AST node
76
- */
77
- this.elements = [];
78
- this._range = null;
79
- this.tokens.startTagOpen = startTagOpen;
80
- this.tokens.startTagName = startTagName;
8
+ class SGTag {
9
+ constructor(tag, attributes = [], range) {
10
+ this.tag = tag;
81
11
  this.attributes = attributes;
82
- this.tokens.startTagClose = startTagClose;
83
- this.elements = elements;
84
- this.tokens.endTagOpen = endTagOpen;
85
- this.tokens.endTagName = endTagName;
86
- this.tokens.endTagClose = endTagClose;
87
- }
88
- get range() {
89
- var _a, _b, _c, _d;
90
- if (!this._range) {
91
- this._range = util_1.default.createBoundingRange(this.tokens.startTagOpen, this.tokens.startTagName, (_a = this.attributes) === null || _a === void 0 ? void 0 : _a[((_b = this.attributes) === null || _b === void 0 ? void 0 : _b.length) - 1], this.tokens.startTagClose, (_c = this.elements) === null || _c === void 0 ? void 0 : _c[((_d = this.elements) === null || _d === void 0 ? void 0 : _d.length) - 1], this.tokens.endTagOpen, this.tokens.endTagName, this.tokens.endTagClose);
92
- }
93
- return this._range;
94
- }
95
- /**
96
- * Is this a self-closing tag?
97
- */
98
- get isSelfClosing() {
99
- var _a;
100
- return this.tokens.startTagClose && ((_a = this.tokens.startTagClose) === null || _a === void 0 ? void 0 : _a.text) !== '>';
12
+ this.range = range;
101
13
  }
102
14
  get id() {
103
15
  return this.getAttributeValue('id');
104
16
  }
105
17
  set id(value) {
106
- this.setAttributeValue('id', value);
107
- }
108
- /**
109
- * Get the name of this tag.
110
- */
111
- get tagName() {
112
- var _a;
113
- return (_a = this.tokens.startTagName) === null || _a === void 0 ? void 0 : _a.text;
114
- }
115
- /**
116
- * Find all direct children by their tag name (case insensitive).
117
- * This does not step into children's children.
118
- *
119
- */
120
- getElementsByTagName(tagName) {
121
- const result = [];
122
- const lowerTagName = tagName.toLowerCase();
123
- for (const el of this.elements) {
124
- if (el.tokens.startTagName.text.toLowerCase() === lowerTagName) {
125
- result.push(el);
126
- }
127
- }
128
- return result;
18
+ this.setAttribute('id', value);
129
19
  }
130
- /**
131
- * Add a child to the end of the children array
132
- */
133
- addChild(tag) {
134
- this.elements.push(tag);
135
- return tag;
136
- }
137
- /**
138
- * Remove a child from the children array.
139
- * @returns true if node was found and removed, false if the node wasn't there and thus nothing was done
140
- */
141
- removeChild(tag) {
142
- const idx = this.elements.indexOf(tag);
143
- if (idx > -1) {
144
- this.elements.splice(idx, 1);
145
- return true;
146
- }
147
- return false;
148
- }
149
- /**
150
- * Does this node have the specified attribute?
151
- */
152
- hasAttribute(name) {
153
- return !!this.getAttribute(name);
154
- }
155
- /**
156
- * Get an SGAttribute by its name (case INsensitive)
157
- */
158
20
  getAttribute(name) {
159
- var _a;
160
- const nameLower = name.toLowerCase();
161
- for (const attr of this.attributes) {
162
- if (((_a = attr.tokens.key) === null || _a === void 0 ? void 0 : _a.text.toLowerCase()) === nameLower) {
163
- return attr;
164
- }
165
- }
21
+ return this.attributes.find(att => att.key.text.toLowerCase() === name);
166
22
  }
167
- /**
168
- * Get an attribute value by its name
169
- */
170
23
  getAttributeValue(name) {
171
24
  var _a, _b;
172
- return (_b = (_a = this.getAttribute(name)) === null || _a === void 0 ? void 0 : _a.tokens.value) === null || _b === void 0 ? void 0 : _b.text;
173
- }
174
- /**
175
- * Set an attribute value by its name. If no attribute exists with this name, it is created
176
- */
177
- setAttributeValue(name, value) {
178
- if (value === undefined) {
179
- this.removeAttribute(name);
180
- }
181
- else {
182
- let attr = this.getAttribute(name);
183
- //create an attribute with this name if we don't have one yet
184
- if (!attr) {
185
- attr = (0, creators_1.createSGAttribute)(name, value);
186
- this.attributes.push(attr);
25
+ return (_b = (_a = this.getAttribute(name.toLowerCase())) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.text;
26
+ }
27
+ setAttribute(name, value) {
28
+ const attr = this.getAttribute(name);
29
+ if (attr) {
30
+ if (value) {
31
+ attr.value = { text: value };
32
+ attr.range = undefined;
187
33
  }
188
- attr.value = value;
189
- }
190
- }
191
- /**
192
- * Remove an attribute by its name. DO NOT USE this to edit AST (use ASTEditor)
193
- * @returns true if an attribute was found and removed. False if no attribute was found
194
- */
195
- removeAttribute(name) {
196
- var _a;
197
- const nameLower = name.toLowerCase();
198
- for (let i = 0; i < this.attributes.length; i++) {
199
- if (((_a = this.attributes[i].key) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === nameLower) {
200
- this.attributes.splice(i, 1);
201
- return true;
34
+ else {
35
+ this.attributes.splice(this.attributes.indexOf(attr), 1);
202
36
  }
203
37
  }
204
- return false;
38
+ else if (value) {
39
+ this.attributes.push({
40
+ key: { text: name },
41
+ value: { text: value }
42
+ });
43
+ }
205
44
  }
206
45
  transpile(state) {
207
- return new source_map_1.SourceNode(null, null, null, [
208
- state.transpileToken(this.tokens.startTagOpen, '<'),
209
- state.transpileToken(this.tokens.startTagName),
210
- this.transpileAttributes(state, this.attributes),
211
- this.transpileBody(state)
46
+ return new source_map_1.SourceNode(null, null, state.srcPath, [
47
+ state.indentText,
48
+ '<',
49
+ state.transpileToken(this.tag),
50
+ ...this.transpileAttributes(state, this.attributes),
51
+ ...this.transpileBody(state)
212
52
  ]);
213
53
  }
214
54
  transpileBody(state) {
215
- var _a;
216
- if (this.isSelfClosing) {
217
- return new source_map_1.SourceNode(null, null, null, [
218
- ' ',
219
- state.transpileToken(this.tokens.startTagClose, '/>'),
220
- state.newline
221
- ]);
222
- }
223
- else {
224
- const chunks = [
225
- state.transpileToken(this.tokens.startTagClose, '>'),
226
- state.newline
227
- ];
228
- state.blockDepth++;
229
- for (const child of this.elements) {
230
- chunks.push(state.indentText, child.transpile(state));
231
- }
232
- state.blockDepth--;
233
- chunks.push(state.indentText, state.transpileToken(this.tokens.endTagOpen, '</'), state.transpileToken((_a = this.tokens.endTagName) !== null && _a !== void 0 ? _a : this.tokens.startTagName), state.transpileToken(this.tokens.endTagClose, '>'), state.newline);
234
- return new source_map_1.SourceNode(null, null, null, chunks);
235
- }
55
+ return [' />\n'];
236
56
  }
237
57
  transpileAttributes(state, attributes) {
238
- const chunks = [];
58
+ var _a, _b;
59
+ const result = [];
239
60
  for (const attr of attributes) {
240
- chunks.push(' ', attr.transpile(state));
61
+ result.push(' ', state.transpileToken(attr.key), '=', state.transpileToken((_a = attr.openQuote) !== null && _a !== void 0 ? _a : { text: '"' }), state.transpileToken(attr.value), state.transpileToken((_b = attr.closeQuote) !== null && _b !== void 0 ? _b : { text: '"' }));
241
62
  }
242
- return new source_map_1.SourceNode(null, null, null, chunks);
63
+ return result;
243
64
  }
244
65
  }
245
- exports.SGElement = SGElement;
246
- class SGProlog extends SGElement {
66
+ exports.SGTag = SGTag;
67
+ class SGProlog extends SGTag {
68
+ transpile(state) {
69
+ return new source_map_1.SourceNode(null, null, state.srcPath, [
70
+ '<?xml',
71
+ ...this.transpileAttributes(state, this.attributes),
72
+ ' ?>\n'
73
+ ]);
74
+ }
247
75
  }
248
76
  exports.SGProlog = SGProlog;
249
- class SGNode extends SGElement {
77
+ class SGNode extends SGTag {
78
+ constructor(tag, attributes, children = [], range) {
79
+ super(tag, attributes, range);
80
+ this.children = children;
81
+ }
82
+ transpileBody(state) {
83
+ if (this.children.length > 0) {
84
+ const body = ['>\n'];
85
+ state.blockDepth++;
86
+ body.push(...this.children.map(node => node.transpile(state)));
87
+ state.blockDepth--;
88
+ body.push(state.indentText, '</', this.tag.text, '>\n');
89
+ return body;
90
+ }
91
+ else {
92
+ return super.transpileBody(state);
93
+ }
94
+ }
250
95
  }
251
96
  exports.SGNode = SGNode;
252
- class SGChildren extends SGElement {
97
+ class SGChildren extends SGNode {
98
+ constructor(tag = { text: 'children' }, children = [], range) {
99
+ super(tag, [], children, range);
100
+ }
253
101
  }
254
102
  exports.SGChildren = SGChildren;
255
- class SGCustomization extends SGElement {
256
- }
257
- exports.SGCustomization = SGCustomization;
258
- class SGScript extends SGElement {
103
+ class SGScript extends SGTag {
104
+ constructor(tag = { text: 'script' }, attributes, cdata, range) {
105
+ super(tag, attributes, range);
106
+ this.cdata = cdata;
107
+ if (!attributes) {
108
+ this.type = 'text/brightscript';
109
+ }
110
+ }
259
111
  get type() {
260
112
  return this.getAttributeValue('type');
261
113
  }
262
114
  set type(value) {
263
- this.setAttributeValue('type', value);
115
+ this.setAttribute('type', value);
264
116
  }
265
117
  get uri() {
266
118
  return this.getAttributeValue('uri');
267
119
  }
268
120
  set uri(value) {
269
- this.setAttributeValue('uri', value);
121
+ this.setAttribute('uri', value);
270
122
  }
271
123
  transpileBody(state) {
272
124
  if (this.cdata) {
273
- return new source_map_1.SourceNode(null, null, null, [
125
+ return [
274
126
  '>',
275
127
  state.transpileToken(this.cdata),
276
128
  '</',
277
- this.tokens.startTagName.text,
278
- '>',
279
- state.newline
280
- ]);
129
+ this.tag.text,
130
+ '>\n'
131
+ ];
281
132
  }
282
133
  else {
283
134
  return super.transpileBody(state);
284
135
  }
285
136
  }
286
137
  transpileAttributes(state, attributes) {
287
- var _a, _b, _c;
288
138
  const modifiedAttributes = [];
289
139
  let foundType = false;
290
140
  const bsExtensionRegexp = /\.bs$/i;
291
141
  for (const attr of attributes) {
292
- const lowerKey = (_a = attr.tokens.key) === null || _a === void 0 ? void 0 : _a.text.toLowerCase();
293
- if (lowerKey === 'uri' && bsExtensionRegexp.exec((_b = attr.tokens.value) === null || _b === void 0 ? void 0 : _b.text)) {
294
- const clone = attr.clone();
295
- clone.tokens.value.text.replace(bsExtensionRegexp, '.brs');
296
- modifiedAttributes.push(clone);
142
+ const lowerKey = attr.key.text.toLowerCase();
143
+ if (lowerKey === 'uri' && bsExtensionRegexp.exec(attr.value.text)) {
144
+ modifiedAttributes.push(util_1.default.cloneSGAttribute(attr, attr.value.text.replace(bsExtensionRegexp, '.brs')));
297
145
  }
298
146
  else if (lowerKey === 'type') {
299
147
  foundType = true;
300
- if ((_c = attr.tokens.value) === null || _c === void 0 ? void 0 : _c.text.toLowerCase().endsWith('brighterscript')) {
301
- modifiedAttributes.push(attr.clone());
148
+ if (attr.value.text.toLowerCase().endsWith('brighterscript')) {
149
+ modifiedAttributes.push(util_1.default.cloneSGAttribute(attr, 'text/brightscript'));
302
150
  }
303
151
  else {
304
152
  modifiedAttributes.push(attr);
@@ -315,161 +163,85 @@ class SGScript extends SGElement {
315
163
  }
316
164
  }
317
165
  exports.SGScript = SGScript;
318
- class SGInterfaceField extends SGElement {
166
+ class SGField extends SGTag {
167
+ constructor(tag = { text: 'field' }, attributes = [], range) {
168
+ super(tag, attributes, range);
169
+ }
319
170
  get type() {
320
171
  return this.getAttributeValue('type');
321
172
  }
322
173
  set type(value) {
323
- this.setAttributeValue('type', value);
174
+ this.setAttribute('type', value);
324
175
  }
325
176
  get alias() {
326
177
  return this.getAttributeValue('alias');
327
178
  }
328
179
  set alias(value) {
329
- this.setAttributeValue('alias', value);
180
+ this.setAttribute('alias', value);
330
181
  }
331
182
  get value() {
332
183
  return this.getAttributeValue('value');
333
184
  }
334
185
  set value(value) {
335
- this.setAttributeValue('value', value);
186
+ this.setAttribute('value', value);
336
187
  }
337
188
  get onChange() {
338
189
  return this.getAttributeValue('onChange');
339
190
  }
340
191
  set onChange(value) {
341
- this.setAttributeValue('onChange', value);
192
+ this.setAttribute('onChange', value);
342
193
  }
343
194
  get alwaysNotify() {
344
195
  return this.getAttributeValue('alwaysNotify');
345
196
  }
346
197
  set alwaysNotify(value) {
347
- this.setAttributeValue('alwaysNotify', value);
198
+ this.setAttribute('alwaysNotify', value);
348
199
  }
349
200
  }
350
- exports.SGInterfaceField = SGInterfaceField;
351
- var SGFieldType;
352
- (function (SGFieldType) {
353
- SGFieldType["integer"] = "integer";
354
- SGFieldType["int"] = "int";
355
- SGFieldType["longinteger"] = "longinteger";
356
- SGFieldType["float"] = "float";
357
- SGFieldType["string"] = "string";
358
- SGFieldType["str"] = "str";
359
- SGFieldType["boolean"] = "boolean";
360
- SGFieldType["bool"] = "bool";
361
- SGFieldType["vector2d"] = "vector2d";
362
- SGFieldType["color"] = "color";
363
- SGFieldType["time"] = "time";
364
- SGFieldType["uri"] = "uri";
365
- SGFieldType["node"] = "node";
366
- SGFieldType["floatarray"] = "floatarray";
367
- SGFieldType["intarray"] = "intarray";
368
- SGFieldType["boolarray"] = "boolarray";
369
- SGFieldType["stringarray"] = "stringarray";
370
- SGFieldType["vector2darray"] = "vector2darray";
371
- SGFieldType["colorarray"] = "colorarray";
372
- SGFieldType["timearray"] = "timearray";
373
- SGFieldType["nodearray"] = "nodearray";
374
- SGFieldType["assocarray"] = "assocarray";
375
- SGFieldType["array"] = "array";
376
- SGFieldType["roarray"] = "roarray";
377
- SGFieldType["rect2d"] = "rect2d";
378
- SGFieldType["rect2darray"] = "rect2darray";
379
- })(SGFieldType = exports.SGFieldType || (exports.SGFieldType = {}));
380
- exports.SGFieldTypes = Object.keys(SGFieldType);
381
- function getBscTypeFromSGFieldType(sgFieldType) {
382
- switch (sgFieldType) {
383
- case SGFieldType.integer:
384
- case SGFieldType.int: {
385
- return new IntegerType_1.IntegerType();
386
- }
387
- case SGFieldType.longinteger: {
388
- return new LongIntegerType_1.LongIntegerType();
389
- }
390
- case SGFieldType.float: {
391
- return new FloatType_1.FloatType();
392
- }
393
- case SGFieldType.string:
394
- case SGFieldType.str: {
395
- return new StringType_1.StringType();
396
- }
397
- case SGFieldType.boolean:
398
- case SGFieldType.bool: {
399
- return new BooleanType_1.BooleanType();
400
- }
401
- default: {
402
- return new DynamicType_1.DynamicType();
403
- }
201
+ exports.SGField = SGField;
202
+ exports.SGFieldTypes = [
203
+ 'integer', 'int', 'longinteger', 'float', 'string', 'str', 'boolean', 'bool',
204
+ 'vector2d', 'color', 'time', 'uri', 'node', 'floatarray', 'intarray', 'boolarray',
205
+ 'stringarray', 'vector2darray', 'colorarray', 'timearray', 'nodearray', 'assocarray',
206
+ 'array', 'roarray', 'rect2d', 'rect2darray'
207
+ ];
208
+ class SGFunction extends SGTag {
209
+ constructor(tag = { text: 'function' }, attributes = [], range) {
210
+ super(tag, attributes, range);
404
211
  }
405
- }
406
- exports.getBscTypeFromSGFieldType = getBscTypeFromSGFieldType;
407
- class SGInterfaceFunction extends SGElement {
408
212
  get name() {
409
213
  return this.getAttributeValue('name');
410
214
  }
411
215
  set name(value) {
412
- this.setAttributeValue('name', value);
216
+ this.setAttribute('name', value);
413
217
  }
414
218
  }
415
- exports.SGInterfaceFunction = SGInterfaceFunction;
416
- class SGInterface extends SGElement {
417
- get fields() {
418
- return this.getElementsByTagName('field');
419
- }
420
- get functions() {
421
- return this.getElementsByTagName('function');
422
- }
423
- get members() {
424
- var _a;
425
- const result = [];
426
- for (const node of this.elements) {
427
- const tagName = (_a = node.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
428
- if (tagName === 'field' || tagName === 'function') {
429
- result.push(node);
430
- }
431
- }
432
- return result;
433
- }
434
- /**
435
- * Check if there's an SGField with the specified name
436
- */
437
- hasField(id) {
438
- var _a;
439
- for (const node of this.elements) {
440
- const tagName = (_a = node.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
441
- if (tagName === 'field' && node.id === id) {
442
- return true;
443
- }
444
- }
445
- return false;
446
- }
447
- /**
448
- * Check if there's an SGFunction with the specified name
449
- */
450
- hasFunction(name) {
451
- var _a;
452
- for (const node of this.elements) {
453
- const tagName = (_a = node.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
454
- if (tagName === 'function' && node.name === name) {
455
- return true;
219
+ exports.SGFunction = SGFunction;
220
+ class SGInterface extends SGTag {
221
+ constructor(tag = { text: 'interface' }, content, range) {
222
+ super(tag, [], range);
223
+ this.fields = [];
224
+ this.functions = [];
225
+ if (content) {
226
+ for (const tag of content) {
227
+ if ((0, xml_1.isSGField)(tag)) {
228
+ this.fields.push(tag);
229
+ }
230
+ else if ((0, xml_1.isSGFunction)(tag)) {
231
+ this.functions.push(tag);
232
+ }
456
233
  }
457
234
  }
458
- return false;
459
235
  }
460
- /**
461
- * Find a field by its ID
462
- */
463
236
  getField(id) {
464
237
  return this.fields.find(field => field.id === id);
465
238
  }
466
- /**
467
- * Set the value of a field. Creates a new field if one does not already exist with this ID
468
- */
469
239
  setField(id, type, onChange, alwaysNotify, alias) {
470
240
  let field = this.getField(id);
471
241
  if (!field) {
472
- field = this.addChild((0, creators_1.createSGInterfaceField)(id));
242
+ field = new SGField();
243
+ field.id = id;
244
+ this.fields.push(field);
473
245
  }
474
246
  field.type = type;
475
247
  field.onChange = onChange;
@@ -480,254 +252,105 @@ class SGInterface extends SGElement {
480
252
  field.alwaysNotify = alwaysNotify ? 'true' : 'false';
481
253
  }
482
254
  field.alias = alias;
483
- return field;
484
- }
485
- /**
486
- * Remove a field from the interface
487
- * @returns true if a field was found and removed. Returns false if no field was found with that name
488
- */
489
- removeField(id) {
490
- var _a;
491
- for (let i = 0; i < this.elements.length; i++) {
492
- const node = this.elements[i];
493
- if (((_a = node.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'field' && node.id === id) {
494
- this.elements.splice(i, 1);
495
- return true;
496
- }
497
- }
498
- return false;
499
255
  }
500
- /**
501
- * Get the interface function with the specified name
502
- */
503
256
  getFunction(name) {
504
- return this.functions.find(func => func.name === name);
257
+ return this.functions.find(field => field.name === name);
505
258
  }
506
- /**
507
- * Add or replace a function on the interface
508
- */
509
259
  setFunction(name) {
510
260
  let func = this.getFunction(name);
511
261
  if (!func) {
512
- func = this.addChild((0, creators_1.createSGInterfaceFunction)(name));
262
+ func = new SGFunction();
263
+ func.name = name;
264
+ this.functions.push(func);
513
265
  }
514
- return func;
515
- }
516
- /**
517
- * Remove a function from the interface
518
- * @returns true if a function was found and removed. Returns false if no function was found with that name
519
- */
520
- removeFunction(name) {
521
- var _a;
522
- for (let i = 0; i < this.elements.length; i++) {
523
- const node = this.elements[i];
524
- if (((_a = node.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'function' && node.getAttributeValue('name') === name) {
525
- this.elements.splice(i, 1);
526
- return true;
527
- }
266
+ }
267
+ transpileBody(state) {
268
+ const body = ['>\n'];
269
+ state.blockDepth++;
270
+ if (this.fields.length > 0) {
271
+ body.push(...this.fields.map(node => node.transpile(state)));
272
+ }
273
+ if (this.functions.length > 0) {
274
+ body.push(...this.functions.map(node => node.transpile(state)));
528
275
  }
529
- return false;
276
+ state.blockDepth--;
277
+ body.push(state.indentText, '</', this.tag.text, '>\n');
278
+ return body;
530
279
  }
531
280
  }
532
281
  exports.SGInterface = SGInterface;
533
- /**
534
- * The `<component>` element in SceneGraph. Not to be confused about usages of components like `<Rectangle>`, those are considered `SGNode` instances.
535
- */
536
- class SGComponent extends SGElement {
537
- /**
538
- * Get all the <Field> and <Function> elements across all <Interface> nodes in this component
539
- */
540
- get interfaceMembers() {
541
- const members = [];
542
- for (const ifaceNode of this.getElementsByTagName('interface')) {
543
- members.push(...ifaceNode.members);
282
+ class SGComponent extends SGTag {
283
+ constructor(tag = { text: 'component' }, attributes, content, range) {
284
+ super(tag, attributes, range);
285
+ this.scripts = [];
286
+ this.customizations = [];
287
+ if (content) {
288
+ for (const tag of content) {
289
+ if ((0, xml_1.isSGInterface)(tag)) {
290
+ this.api = tag;
291
+ }
292
+ else if ((0, xml_1.isSGScript)(tag)) {
293
+ this.scripts.push(tag);
294
+ }
295
+ else if ((0, xml_1.isSGChildren)(tag)) {
296
+ this.children = tag;
297
+ }
298
+ else if ((0, xml_1.isSGCustomization)(tag)) {
299
+ this.customizations.push(tag);
300
+ }
301
+ }
544
302
  }
545
- return members;
546
- }
547
- get scriptElements() {
548
- return this.getElementsByTagName('script');
549
- }
550
- /**
551
- * Get the <interface> element from this component (if present), or undefined if not.
552
- * NOTE: Roku supports and merges multiple <interface> elements in a component, but this
553
- * property points to the FIRST one. If you need to check whether a member exists,
554
- * look through `this.interfaceMemebers` instead.
555
- */
556
- get interfaceElement() {
557
- return this.getElementsByTagName('interface')[0];
558
- }
559
- /**
560
- * Get the `<children>` element of this component. (not to be confused with the AST `childTags` property).
561
- * If there are multiope `<children>` elements, this function will return the last `<children>` tag because that's what Roku devices do.
562
- */
563
- get childrenElement() {
564
- const children = this.getElementsByTagName('children');
565
- return children[children.length - 1];
566
- }
567
- get customizationElements() {
568
- return this.getElementsByTagName('customization');
569
- }
570
- /**
571
- * Specifies the name of the component, that allows you to create the component in your application.
572
- * For example, if the name of the component is `CastMemberInfo`, you could create instances of the component declaratively
573
- * in a child node element of a component `<children>` element (`<CastMemberInfo/>`), or using BrightScript in a `<script>`
574
- * element (`createObject("roSGNode","CastMemberInfo")`).
575
- *
576
- * The name attribute is case-sensitive. You cannot successfully create or declare a component unless the component name exactly
577
- * matches the name attribute, including case. Also be aware that two components with the exact same name in the same application
578
- * components directory will have undefined and generally undesirable results if you attempt to create a component object with that name in the application.
579
- */
303
+ }
580
304
  get name() {
581
305
  return this.getAttributeValue('name');
582
306
  }
583
307
  set name(value) {
584
- this.setAttributeValue('name', value);
585
- }
586
- /**
587
- * Specifies the name of the built-in or extended SceneGraph scene or node class whose functionality is extended by this component.
588
- *
589
- * For example, `extends="Group"` specifies that the component has all of the functionality of the Group node class (it can have child nodes, has translation/scale/rotation fields, and so forth).
590
- *
591
- * By default, a component extends the Group node class.
592
- */
308
+ this.setAttribute('name', value);
309
+ }
593
310
  get extends() {
594
311
  return this.getAttributeValue('extends');
595
312
  }
596
313
  set extends(value) {
597
- this.setAttributeValue('extends', value);
598
- }
599
- /**
600
- * Specifies the ID of a node declared in the XML file to have the initial remote control focus when the component is instantiated.
601
- */
602
- get initialFocus() {
603
- return this.getAttributeValue('initialFocus');
604
- }
605
- set initialFocus(value) {
606
- this.setAttributeValue('initialFocus', value);
607
- }
608
- /**
609
- * Specifies the version of the SceneGraph API. The default is 1.0 if not specified.
610
- */
611
- get version() {
612
- return this.getAttributeValue('version');
613
- }
614
- set version(value) {
615
- this.setAttributeValue('version', value);
616
- }
617
- /**
618
- * Does the specified field exist in the component interface?
619
- */
620
- hasInterfaceField(id) {
621
- for (const ifaceNode of this.getElementsByTagName('interface')) {
622
- if (ifaceNode.hasField(id)) {
623
- return true;
624
- }
625
- }
626
- return false;
627
- }
628
- /**
629
- * Does the specified function exist in the component interface?
630
- */
631
- hasInterfaceFunction(name) {
632
- for (const ifaceNode of this.getElementsByTagName('interface')) {
633
- if (ifaceNode.hasFunction(name)) {
634
- return true;
635
- }
636
- }
637
- return false;
638
- }
639
- /**
640
- * Get an interface field with the specified name
641
- */
642
- getInterfaceField(name) {
643
- for (const ifaceNode of this.getElementsByTagName('interface')) {
644
- const field = ifaceNode.getField(name);
645
- if (field) {
646
- return field;
647
- }
648
- }
314
+ this.setAttribute('extends', value);
649
315
  }
650
- /**
651
- * Return the first SGInterface node found, or insert a new one then return it
652
- */
653
- ensureInterfaceNode() {
654
- for (const el of this.elements) {
655
- if (el.tokens.startTagName.text.toLowerCase() === 'interface') {
656
- return el;
657
- }
316
+ transpileBody(state) {
317
+ const body = ['>\n'];
318
+ state.blockDepth++;
319
+ if (this.api) {
320
+ body.push(this.api.transpile(state));
658
321
  }
659
- return this.addChild((0, creators_1.createSGInterface)());
660
- }
661
- /**
662
- * Create or update a <field> interface element.
663
- * This will create a new `<interface>` element if there are none on the component already
664
- */
665
- setInterfaceField(id, type, onChange, alwaysNotify, alias) {
666
- let ifaceNode = this.ensureInterfaceNode();
667
- return ifaceNode.setField(id, type, onChange, alwaysNotify, alias);
668
- }
669
- /**
670
- * Create or update a <function> interface element.
671
- * This will create a new `<interface>` element if there are none on the component already
672
- */
673
- setInterfaceFunction(name) {
674
- let ifaceNode = this.ensureInterfaceNode();
675
- return ifaceNode.setFunction(name);
676
- }
677
- /**
678
- * Remove an interface field.
679
- * @returns true if a field was found and removed. Returns false if no field was found with that name
680
- */
681
- removeInterfaceField(id) {
682
- for (const ifaceNode of this.getElementsByTagName('interface')) {
683
- if (ifaceNode.removeField(id)) {
684
- return true;
685
- }
322
+ if (this.scripts.length > 0) {
323
+ body.push(...this.scripts.map(node => node.transpile(state)));
686
324
  }
687
- return false;
688
- }
689
- /**
690
- * Get an interface field with the specified name
691
- */
692
- getInterfaceFunction(name) {
693
- for (const ifaceNode of this.getElementsByTagName('interface')) {
694
- const func = ifaceNode.getFunction(name);
695
- if (func) {
696
- return func;
697
- }
325
+ if (this.children) {
326
+ body.push(this.children.transpile(state));
698
327
  }
699
- }
700
- /**
701
- * Remove an interface function.
702
- * @returns true if a function was found and removed. Returns false if no function was found with that name
703
- */
704
- removeInterfaceFunction(name) {
705
- for (const ifaceNode of this.getElementsByTagName('interface')) {
706
- if (ifaceNode.removeFunction(name)) {
707
- return true;
708
- }
328
+ if (this.customizations.length > 0) {
329
+ body.push(...this.customizations.map(node => node.transpile(state)));
709
330
  }
710
- return false;
331
+ state.blockDepth--;
332
+ body.push(state.indentText, '</', this.tag.text, '>\n');
333
+ return body;
711
334
  }
712
335
  }
713
336
  exports.SGComponent = SGComponent;
714
337
  class SGAst {
715
- constructor(prologElement, rootElement, componentElement) {
716
- this.prologElement = prologElement;
717
- this.rootElement = rootElement;
718
- this.componentElement = componentElement;
338
+ constructor(prolog, root, component) {
339
+ this.prolog = prolog;
340
+ this.root = root;
341
+ this.component = component;
719
342
  }
720
343
  transpile(state) {
721
344
  const chunks = [];
722
345
  //write XML prolog
723
- if (this.prologElement) {
724
- chunks.push(this.prologElement.transpile(state));
346
+ if (this.prolog) {
347
+ chunks.push(this.prolog.transpile(state));
725
348
  }
726
- if (this.componentElement) {
349
+ if (this.component) {
727
350
  //write content
728
- chunks.push(this.componentElement.transpile(state));
351
+ chunks.push(this.component.transpile(state));
729
352
  }
730
- return new source_map_1.SourceNode(null, null, null, chunks);
353
+ return chunks;
731
354
  }
732
355
  }
733
356
  exports.SGAst = SGAst;