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
@@ -8,7 +8,7 @@ const Statement_1 = require("./Statement");
8
8
  const DiagnosticMessages_1 = require("../DiagnosticMessages");
9
9
  const util_1 = require("../util");
10
10
  const Expression_1 = require("./Expression");
11
- const Logger_1 = require("../Logger");
11
+ const logging_1 = require("../logging");
12
12
  const reflection_1 = require("../astUtils/reflection");
13
13
  const visitors_1 = require("../astUtils/visitors");
14
14
  const creators_1 = require("../astUtils/creators");
@@ -95,16 +95,17 @@ class Parser {
95
95
  */
96
96
  parse(toParse, options) {
97
97
  var _a;
98
+ this.logger = (_a = options === null || options === void 0 ? void 0 : options.logger) !== null && _a !== void 0 ? _a : (0, logging_1.createLogger)();
99
+ options = this.sanitizeParseOptions(options);
100
+ this.options = options;
98
101
  let tokens;
99
102
  if (typeof toParse === 'string') {
100
- tokens = Lexer_1.Lexer.scan(toParse).tokens;
103
+ tokens = Lexer_1.Lexer.scan(toParse, { trackLocations: options.trackLocations }).tokens;
101
104
  }
102
105
  else {
103
106
  tokens = toParse;
104
107
  }
105
- this.logger = (_a = options === null || options === void 0 ? void 0 : options.logger) !== null && _a !== void 0 ? _a : new Logger_1.Logger();
106
108
  this.tokens = tokens;
107
- this.options = this.sanitizeParseOptions(options);
108
109
  this.allowedLocalIdentifiers = [
109
110
  ...TokenKind_1.AllowedLocalIdentifiers,
110
111
  //when in plain brightscript mode, the BrighterScript source literals can be used as regular variables
@@ -153,7 +154,11 @@ class Parser {
153
154
  return body;
154
155
  }
155
156
  sanitizeParseOptions(options) {
156
- return Object.assign({ mode: 'brightscript' }, (options || {}));
157
+ var _a, _b;
158
+ options !== null && options !== void 0 ? options : (options = {});
159
+ (_a = options.mode) !== null && _a !== void 0 ? _a : (options.mode = ParseMode.BrightScript);
160
+ (_b = options.trackLocations) !== null && _b !== void 0 ? _b : (options.trackLocations = true);
161
+ return options;
157
162
  }
158
163
  /**
159
164
  * Determine if the parser is currently parsing tokens at the root level.
@@ -243,30 +248,18 @@ class Parser {
243
248
  interfaceFieldStatement(optionalKeyword) {
244
249
  const name = this.identifier(...TokenKind_1.AllowedProperties);
245
250
  let asToken;
246
- let typeExpression;
251
+ let typeToken;
252
+ let type;
247
253
  if (this.check(TokenKind_1.TokenKind.As)) {
248
- [asToken, typeExpression] = this.consumeAsTokenAndTypeExpression();
249
- }
250
- return new Statement_1.InterfaceFieldStatement(name, asToken, typeExpression, optionalKeyword);
251
- }
252
- consumeAsTokenAndTypeExpression() {
253
- let asToken = this.consumeToken(TokenKind_1.TokenKind.As);
254
- let typeExpression;
255
- if (asToken) {
256
- //if there's nothing after the `as`, add a diagnostic and continue
257
- if (this.checkEndOfStatement()) {
258
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.expectedIdentifierAfterKeyword(asToken.text)), { range: asToken.range }));
259
- //consume the statement separator
260
- this.consumeStatementSeparators();
261
- }
262
- else if (this.peek().kind !== TokenKind_1.TokenKind.Identifier && !this.checkAny(...TokenKind_1.DeclarableTypes, ...TokenKind_1.AllowedTypeIdentifiers)) {
263
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.expectedIdentifierAfterKeyword(asToken.text)), { range: asToken.range }));
264
- }
265
- else {
266
- typeExpression = this.typeExpression();
267
- }
254
+ asToken = this.consumeToken(TokenKind_1.TokenKind.As);
255
+ typeToken = this.typeToken();
256
+ type = util_1.util.tokenToBscType(typeToken);
257
+ }
258
+ if (!type) {
259
+ this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.functionParameterTypeIsInvalid(name.text, typeToken.text)), { range: typeToken.range }));
260
+ throw this.lastDiagnosticAsError();
268
261
  }
269
- return [asToken, typeExpression];
262
+ return new Statement_1.InterfaceFieldStatement(name, asToken, typeToken, type, optionalKeyword);
270
263
  }
271
264
  /**
272
265
  * Create a new InterfaceMethodStatement. This should only be called from within `interfaceDeclaration()`
@@ -285,36 +278,39 @@ class Parser {
285
278
  } while (this.match(TokenKind_1.TokenKind.Comma));
286
279
  }
287
280
  const rightParen = this.consumeToken(TokenKind_1.TokenKind.RightParen);
288
- // let asToken = null as Token;
289
- // let returnTypeExpression: TypeExpression;
290
- let asToken;
291
- let returnTypeExpression;
281
+ let asToken = null;
282
+ let returnTypeToken = null;
292
283
  if (this.check(TokenKind_1.TokenKind.As)) {
293
- [asToken, returnTypeExpression] = this.consumeAsTokenAndTypeExpression();
284
+ asToken = this.advance();
285
+ returnTypeToken = this.typeToken();
286
+ const returnType = util_1.util.tokenToBscType(returnTypeToken);
287
+ if (!returnType) {
288
+ this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.functionParameterTypeIsInvalid(name.text, returnTypeToken.text)), { range: returnTypeToken.range }));
289
+ throw this.lastDiagnosticAsError();
290
+ }
294
291
  }
295
- return new Statement_1.InterfaceMethodStatement(functionType, name, leftParen, params, rightParen, asToken, returnTypeExpression, optionalKeyword);
292
+ return new Statement_1.InterfaceMethodStatement(functionType, name, leftParen, params, rightParen, asToken, returnTypeToken, util_1.util.tokenToBscType(returnTypeToken), optionalKeyword);
296
293
  }
297
294
  interfaceDeclaration() {
298
295
  this.warnIfNotBrighterScriptMode('interface declarations');
299
296
  const parentAnnotations = this.enterAnnotationBlock();
300
297
  const interfaceToken = this.consume(DiagnosticMessages_1.DiagnosticMessages.expectedKeyword(TokenKind_1.TokenKind.Interface), TokenKind_1.TokenKind.Interface);
301
- const nameToken = this.identifier();
298
+ const nameToken = this.identifier(...this.allowedLocalIdentifiers);
302
299
  let extendsToken;
303
300
  let parentInterfaceName;
304
301
  if (this.peek().text.toLowerCase() === 'extends') {
305
302
  extendsToken = this.advance();
306
- if (this.checkEndOfStatement()) {
307
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.expectedIdentifierAfterKeyword(extendsToken.text)), { range: extendsToken.range }));
308
- }
309
- else {
310
- parentInterfaceName = this.typeExpression();
311
- }
303
+ parentInterfaceName = this.getNamespacedVariableNameExpression();
312
304
  }
313
305
  this.consumeStatementSeparators();
314
306
  //gather up all interface members (Fields, Methods)
315
307
  let body = [];
316
308
  while (this.checkAny(TokenKind_1.TokenKind.Comment, TokenKind_1.TokenKind.Identifier, TokenKind_1.TokenKind.At, ...TokenKind_1.AllowedProperties)) {
317
309
  try {
310
+ //break out of this loop if we encountered the `EndInterface` token not followed by `as`
311
+ if (this.check(TokenKind_1.TokenKind.EndInterface) && !this.checkNext(TokenKind_1.TokenKind.As)) {
312
+ break;
313
+ }
318
314
  let decl;
319
315
  //collect leading annotations
320
316
  if (this.check(TokenKind_1.TokenKind.At)) {
@@ -354,10 +350,6 @@ class Parser {
354
350
  }
355
351
  //ensure statement separator
356
352
  this.consumeStatementSeparators();
357
- //break out of this loop if we encountered the `EndInterface` token not followed by `as`
358
- if (this.check(TokenKind_1.TokenKind.EndInterface) && !this.checkNext(TokenKind_1.TokenKind.As)) {
359
- break;
360
- }
361
353
  }
362
354
  //consume the final `end interface` token
363
355
  const endInterfaceToken = this.consumeToken(TokenKind_1.TokenKind.EndInterface);
@@ -429,12 +421,7 @@ class Parser {
429
421
  //see if the class inherits from parent
430
422
  if (this.peek().text.toLowerCase() === 'extends') {
431
423
  extendsKeyword = this.advance();
432
- if (this.checkEndOfStatement()) {
433
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.expectedIdentifierAfterKeyword(extendsKeyword.text)), { range: extendsKeyword.range }));
434
- }
435
- else {
436
- parentClassName = this.typeExpression();
437
- }
424
+ parentClassName = this.getNamespacedVariableNameExpression();
438
425
  }
439
426
  //ensure statement separator
440
427
  this.consumeStatementSeparators();
@@ -530,10 +517,15 @@ class Parser {
530
517
  }
531
518
  let name = this.consume(DiagnosticMessages_1.DiagnosticMessages.expectedClassFieldIdentifier(), TokenKind_1.TokenKind.Identifier, ...TokenKind_1.AllowedProperties);
532
519
  let asToken;
533
- let fieldTypeExpression;
520
+ let fieldType;
534
521
  //look for `as SOME_TYPE`
535
522
  if (this.check(TokenKind_1.TokenKind.As)) {
536
- [asToken, fieldTypeExpression] = this.consumeAsTokenAndTypeExpression();
523
+ asToken = this.advance();
524
+ fieldType = this.typeToken();
525
+ //no field type specified
526
+ if (!util_1.util.tokenToBscType(fieldType)) {
527
+ this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.expectedValidTypeToFollowAsKeyword()), { range: this.peek().range }));
528
+ }
537
529
  }
538
530
  let initialValue;
539
531
  let equal;
@@ -542,10 +534,10 @@ class Parser {
542
534
  equal = this.advance();
543
535
  initialValue = this.expression();
544
536
  }
545
- return new Statement_1.FieldStatement(accessModifier, name, asToken, fieldTypeExpression, equal, initialValue, optionalKeyword);
537
+ return new Statement_1.FieldStatement(accessModifier, name, asToken, fieldType, equal, initialValue, optionalKeyword);
546
538
  }
547
539
  functionDeclaration(isAnonymous, checkIdentifier = true, onlyCallableAsMember = false) {
548
- var _a;
540
+ var _a, _b;
549
541
  let previousCallExpressions = this.callExpressions;
550
542
  this.callExpressions = [];
551
543
  try {
@@ -566,8 +558,7 @@ class Parser {
566
558
  start: this.peek().range.start,
567
559
  end: this.peek().range.start
568
560
  },
569
- leadingWhitespace: '',
570
- leadingTrivia: []
561
+ leadingWhitespace: ''
571
562
  };
572
563
  }
573
564
  let isSub = (functionType === null || functionType === void 0 ? void 0 : functionType.kind) === TokenKind_1.TokenKind.Sub;
@@ -593,18 +584,19 @@ class Parser {
593
584
  }
594
585
  let params = [];
595
586
  let asToken;
596
- let typeExpression;
587
+ let typeToken;
597
588
  if (!this.check(TokenKind_1.TokenKind.RightParen)) {
598
589
  do {
599
- if (params.length >= Expression_1.CallExpression.MaximumArguments) {
600
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.tooManyCallableParameters(params.length, Expression_1.CallExpression.MaximumArguments)), { range: this.peek().range }));
601
- }
602
590
  params.push(this.functionParameter());
603
591
  } while (this.match(TokenKind_1.TokenKind.Comma));
604
592
  }
605
593
  let rightParen = this.advance();
606
594
  if (this.check(TokenKind_1.TokenKind.As)) {
607
- [asToken, typeExpression] = this.consumeAsTokenAndTypeExpression();
595
+ asToken = this.advance();
596
+ typeToken = this.typeToken();
597
+ if (!util_1.util.tokenToBscType(typeToken, this.options.mode === ParseMode.BrighterScript)) {
598
+ this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.invalidFunctionReturnType((_a = typeToken.text) !== null && _a !== void 0 ? _a : '')), { range: typeToken.range }));
599
+ }
608
600
  }
609
601
  params.reduce((haveFoundOptional, param) => {
610
602
  if (haveFoundOptional && !param.defaultValue) {
@@ -615,7 +607,12 @@ class Parser {
615
607
  this.consumeStatementSeparators(true);
616
608
  let func = new Expression_1.FunctionExpression(params, undefined, //body
617
609
  functionType, undefined, //ending keyword
618
- leftParen, rightParen, asToken, typeExpression);
610
+ leftParen, rightParen, asToken, typeToken);
611
+ // add the function to the relevant symbol tables
612
+ if (!onlyCallableAsMember && name) {
613
+ const funcType = func.getFunctionType();
614
+ funcType.setName(name.text);
615
+ }
619
616
  this._references.functionExpressions.push(func);
620
617
  //support ending the function with `end sub` OR `end function`
621
618
  func.body = this.block();
@@ -623,7 +620,7 @@ class Parser {
623
620
  if (!func.body) {
624
621
  func.body = new Statement_1.Block([], util_1.util.createRangeFromPositions(func.range.start, func.range.start));
625
622
  }
626
- func.body.symbolTable = new SymbolTable_1.SymbolTable(`Block: Function '${(_a = name === null || name === void 0 ? void 0 : name.text) !== null && _a !== void 0 ? _a : ''}'`, () => func.getSymbolTable());
623
+ func.body.symbolTable = new SymbolTable_1.SymbolTable(`Block: Function '${(_b = name === null || name === void 0 ? void 0 : name.text) !== null && _b !== void 0 ? _b : ''}'`, () => func.getSymbolTable());
627
624
  if (!func.body) {
628
625
  this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.callableBlockMissingEndKeyword(functionTypeText)), { range: this.peek().range }));
629
626
  throw this.lastDiagnosticAsError();
@@ -662,19 +659,22 @@ class Parser {
662
659
  let name = this.advance();
663
660
  // force the name into an identifier so the AST makes some sense
664
661
  name.kind = TokenKind_1.TokenKind.Identifier;
665
- let typeExpression;
662
+ let typeToken;
666
663
  let defaultValue;
667
- let equalToken;
668
664
  // parse argument default value
669
- if ((equalToken = this.consumeTokenIf(TokenKind_1.TokenKind.Equal))) {
665
+ if (this.match(TokenKind_1.TokenKind.Equal)) {
670
666
  // it seems any expression is allowed here -- including ones that operate on other arguments!
671
667
  defaultValue = this.expression(false);
672
668
  }
673
669
  let asToken = null;
674
670
  if (this.check(TokenKind_1.TokenKind.As)) {
675
- [asToken, typeExpression] = this.consumeAsTokenAndTypeExpression();
671
+ asToken = this.advance();
672
+ typeToken = this.typeToken();
673
+ if (!util_1.util.tokenToBscType(typeToken, this.options.mode === ParseMode.BrighterScript)) {
674
+ this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.functionParameterTypeIsInvalid(name.text, typeToken.text)), { range: typeToken.range }));
675
+ }
676
676
  }
677
- return new Expression_1.FunctionParameterExpression(name, equalToken, defaultValue, asToken, typeExpression);
677
+ return new Expression_1.FunctionParameterExpression(name, typeToken, defaultValue, asToken);
678
678
  }
679
679
  assignment() {
680
680
  let name = this.advance();
@@ -682,6 +682,12 @@ class Parser {
682
682
  if (TokenKind_1.DisallowedLocalIdentifiersText.has(name.text.toLowerCase())) {
683
683
  this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.cannotUseReservedWordAsIdentifier(name.text)), { range: name.range }));
684
684
  }
685
+ if (this.check(TokenKind_1.TokenKind.As)) {
686
+ // v1 syntax allows type declaration on lhs of assignment
687
+ this.warnIfNotBrighterScriptMode('typed assignment');
688
+ this.advance(); // skip 'as'
689
+ this.typeToken(); // skip typeToken;
690
+ }
685
691
  let operator = this.consume(DiagnosticMessages_1.DiagnosticMessages.expectedOperatorAfterIdentifier(TokenKind_1.AssignmentOperators, name.text), ...TokenKind_1.AssignmentOperators);
686
692
  let value = this.expression();
687
693
  let result;
@@ -786,9 +792,35 @@ class Parser {
786
792
  // BrightScript is like python, in that variables can be declared without a `var`,
787
793
  // `let`, (...) keyword. As such, we must check the token *after* an identifier to figure
788
794
  // out what to do with it.
789
- if (this.checkAny(TokenKind_1.TokenKind.Identifier, ...this.allowedLocalIdentifiers) &&
790
- this.checkAnyNext(...TokenKind_1.AssignmentOperators)) {
791
- return this.assignment();
795
+ if (this.checkAny(TokenKind_1.TokenKind.Identifier, ...this.allowedLocalIdentifiers)) {
796
+ if (this.checkAnyNext(...TokenKind_1.AssignmentOperators)) {
797
+ return this.assignment();
798
+ }
799
+ else if (this.checkNext(TokenKind_1.TokenKind.As)) {
800
+ // may be a typed assignment - this is v1 syntax
801
+ const backtrack = this.current;
802
+ let validTypeExpression = false;
803
+ try {
804
+ // skip the identifier, and check for valid type expression
805
+ this.advance();
806
+ // skip the 'as'
807
+ this.advance();
808
+ // check if there is a valid type
809
+ const typeToken = this.typeToken(true);
810
+ const allowedNameKinds = [TokenKind_1.TokenKind.Identifier, ...TokenKind_1.DeclarableTypes, ...this.allowedLocalIdentifiers];
811
+ validTypeExpression = allowedNameKinds.includes(typeToken.kind);
812
+ }
813
+ catch (e) {
814
+ // ignore any errors
815
+ }
816
+ finally {
817
+ this.current = backtrack;
818
+ }
819
+ if (validTypeExpression) {
820
+ // there is a valid 'as' and type expression
821
+ return this.assignment();
822
+ }
823
+ }
792
824
  }
793
825
  //some BrighterScript keywords are allowed as a local identifiers, so we need to check for them AFTER the assignment check
794
826
  if (this.check(TokenKind_1.TokenKind.Interface)) {
@@ -892,10 +924,11 @@ class Parser {
892
924
  return new Statement_1.ExitForStatement({ exitFor: keyword });
893
925
  }
894
926
  commentStatement() {
927
+ var _a, _b;
895
928
  //if this comment is on the same line as the previous statement,
896
929
  //then this comment should be treated as a single-line comment
897
930
  let prev = this.previous();
898
- if ((prev === null || prev === void 0 ? void 0 : prev.range.end.line) === this.peek().range.start.line) {
931
+ if (((_a = prev === null || prev === void 0 ? void 0 : prev.range) === null || _a === void 0 ? void 0 : _a.end.line) === ((_b = this.peek().range) === null || _b === void 0 ? void 0 : _b.start.line)) {
899
932
  return new Statement_1.CommentStatement([this.advance()]);
900
933
  }
901
934
  else {
@@ -911,7 +944,7 @@ class Parser {
911
944
  this.warnIfNotBrighterScriptMode('namespace');
912
945
  let keyword = this.advance();
913
946
  this.namespaceAndFunctionDepth++;
914
- let name = this.identifyingExpression();
947
+ let name = this.getNamespacedVariableNameExpression();
915
948
  //set the current namespace name
916
949
  let result = new Statement_1.NamespaceStatement(keyword, name, null, null);
917
950
  this.globalTerminators.push([TokenKind_1.TokenKind.EndNamespace]);
@@ -937,9 +970,19 @@ class Parser {
937
970
  /**
938
971
  * Get an expression with identifiers separated by periods. Useful for namespaces and class extends
939
972
  */
940
- identifyingExpression(allowedTokenKinds) {
941
- allowedTokenKinds = allowedTokenKinds !== null && allowedTokenKinds !== void 0 ? allowedTokenKinds : this.allowedLocalIdentifiers;
942
- let firstIdentifier = this.consume(DiagnosticMessages_1.DiagnosticMessages.expectedIdentifierAfterKeyword(this.previous().text), TokenKind_1.TokenKind.Identifier, ...allowedTokenKinds);
973
+ getNamespacedVariableNameExpression(ignoreDiagnostics = false) {
974
+ let firstIdentifier;
975
+ if (ignoreDiagnostics) {
976
+ if (this.checkAny(...this.allowedLocalIdentifiers)) {
977
+ firstIdentifier = this.advance();
978
+ }
979
+ else {
980
+ throw new Error();
981
+ }
982
+ }
983
+ else {
984
+ firstIdentifier = this.consume(DiagnosticMessages_1.DiagnosticMessages.expectedIdentifierAfterKeyword(this.previous().text), TokenKind_1.TokenKind.Identifier, ...this.allowedLocalIdentifiers);
985
+ }
943
986
  let expr;
944
987
  if (firstIdentifier) {
945
988
  // force it into an identifier so the AST makes some sense
@@ -952,7 +995,7 @@ class Parser {
952
995
  if (!dot) {
953
996
  break;
954
997
  }
955
- let identifier = this.tryConsume(DiagnosticMessages_1.DiagnosticMessages.expectedIdentifier(), TokenKind_1.TokenKind.Identifier, ...allowedTokenKinds, ...TokenKind_1.AllowedProperties);
998
+ let identifier = this.tryConsume(DiagnosticMessages_1.DiagnosticMessages.expectedIdentifier(), TokenKind_1.TokenKind.Identifier, ...this.allowedLocalIdentifiers, ...TokenKind_1.AllowedProperties);
956
999
  if (!identifier) {
957
1000
  break;
958
1001
  }
@@ -961,7 +1004,7 @@ class Parser {
961
1004
  expr = new Expression_1.DottedGetExpression(expr, identifier, dot);
962
1005
  }
963
1006
  }
964
- return expr;
1007
+ return new Expression_1.NamespacedVariableNameExpression(expr);
965
1008
  }
966
1009
  /**
967
1010
  * Add an 'unexpected token' diagnostic for any token found between current and the first stopToken found.
@@ -1412,9 +1455,9 @@ class Parser {
1412
1455
  if ((0, reflection_1.isCallExpression)(expr) || (0, reflection_1.isCallfuncExpression)(expr)) {
1413
1456
  return new Statement_1.ExpressionStatement(expr);
1414
1457
  }
1415
- //at this point, it's probably an error. However, we recover a little more gracefully by creating an inclosing ExpressionStatement
1458
+ //at this point, it's probably an error. However, we recover a little more gracefully by creating an assignment
1416
1459
  this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.expectedStatementOrFunctionCallButReceivedExpression()), { range: expressionStart.range }));
1417
- return new Statement_1.ExpressionStatement(expr);
1460
+ throw this.lastDiagnosticAsError();
1418
1461
  }
1419
1462
  setStatement() {
1420
1463
  /**
@@ -1432,7 +1475,7 @@ class Parser {
1432
1475
  if ((0, reflection_1.isIndexedGetExpression)(left)) {
1433
1476
  return new Statement_1.IndexedSetStatement(left.obj, left.index, operator.kind === TokenKind_1.TokenKind.Equal
1434
1477
  ? right
1435
- : new Expression_1.BinaryExpression(left, operator, right), left.openingSquare, left.closingSquare);
1478
+ : new Expression_1.BinaryExpression(left, operator, right), left.openingSquare, left.closingSquare, left.additionalIndexes);
1436
1479
  }
1437
1480
  else if ((0, reflection_1.isDottedGetExpression)(left)) {
1438
1481
  return new Statement_1.DottedSetStatement(left.obj, left.name, operator.kind === TokenKind_1.TokenKind.Equal
@@ -1443,7 +1486,6 @@ class Parser {
1443
1486
  return this.expressionStatement(expr);
1444
1487
  }
1445
1488
  printStatement() {
1446
- var _a;
1447
1489
  let printKeyword = this.advance();
1448
1490
  let values = [];
1449
1491
  while (!this.checkEndOfStatement()) {
@@ -1462,8 +1504,7 @@ class Parser {
1462
1504
  }
1463
1505
  //print statements can be empty, so look for empty print conditions
1464
1506
  if (!values.length) {
1465
- const endOfStatementRange = util_1.util.createRangeFromPositions(printKeyword.range.end, (_a = this.peek()) === null || _a === void 0 ? void 0 : _a.range.end);
1466
- let emptyStringLiteral = (0, creators_1.createStringLiteral)('', endOfStatementRange);
1507
+ let emptyStringLiteral = (0, creators_1.createStringLiteral)('');
1467
1508
  values.push(emptyStringLiteral);
1468
1509
  }
1469
1510
  let last = values[values.length - 1];
@@ -1616,7 +1657,7 @@ class Parser {
1616
1657
  expression(findTypeCast = true) {
1617
1658
  let expression = this.anonymousFunction();
1618
1659
  let asToken;
1619
- let typeExpression;
1660
+ let typeToken;
1620
1661
  if (findTypeCast) {
1621
1662
  do {
1622
1663
  if (this.check(TokenKind_1.TokenKind.As)) {
@@ -1624,15 +1665,16 @@ class Parser {
1624
1665
  // Check if this expression is wrapped in any type casts
1625
1666
  // allows for multiple casts:
1626
1667
  // myVal = foo() as dynamic as string
1627
- [asToken, typeExpression] = this.consumeAsTokenAndTypeExpression();
1628
- if (asToken && typeExpression) {
1629
- expression = new Expression_1.TypeCastExpression(expression, asToken, typeExpression);
1668
+ asToken = this.advance();
1669
+ typeToken = this.typeToken();
1670
+ if (asToken && typeToken) {
1671
+ expression = new Expression_1.TypeCastExpression(expression, asToken, typeToken);
1630
1672
  }
1631
1673
  }
1632
1674
  else {
1633
1675
  break;
1634
1676
  }
1635
- } while (asToken && typeExpression);
1677
+ } while (asToken && typeToken);
1636
1678
  }
1637
1679
  this._references.expressions.add(expression);
1638
1680
  return expression;
@@ -1728,9 +1770,7 @@ class Parser {
1728
1770
  else if (nextKind === TokenKind_1.TokenKind.Minus || nextKind === TokenKind_1.TokenKind.Plus) {
1729
1771
  this.current++; //advance
1730
1772
  let operator = this.previous();
1731
- let right = nextKind === TokenKind_1.TokenKind.Not
1732
- ? this.boolean()
1733
- : this.prefixUnary();
1773
+ let right = this.prefixUnary();
1734
1774
  return new Expression_1.UnaryExpression(operator, right);
1735
1775
  }
1736
1776
  return this.call();
@@ -1738,32 +1778,31 @@ class Parser {
1738
1778
  indexedGet(expr) {
1739
1779
  let openingSquare = this.previous();
1740
1780
  let questionDotToken = this.getMatchingTokenAtOffset(-2, TokenKind_1.TokenKind.QuestionDot);
1741
- let index;
1742
- let closingSquare;
1781
+ let indexes = [];
1782
+ //consume leading newlines
1743
1783
  while (this.match(TokenKind_1.TokenKind.Newline)) { }
1744
1784
  try {
1745
- index = this.expression();
1785
+ indexes.push(this.expression());
1786
+ //consume additional indexes separated by commas
1787
+ while (this.check(TokenKind_1.TokenKind.Comma)) {
1788
+ //discard the comma
1789
+ this.advance();
1790
+ indexes.push(this.expression());
1791
+ }
1746
1792
  }
1747
1793
  catch (error) {
1748
1794
  this.rethrowNonDiagnosticError(error);
1749
1795
  }
1796
+ //consume trailing newlines
1750
1797
  while (this.match(TokenKind_1.TokenKind.Newline)) { }
1751
- closingSquare = this.tryConsume(DiagnosticMessages_1.DiagnosticMessages.expectedRightSquareBraceAfterArrayOrObjectIndex(), TokenKind_1.TokenKind.RightSquareBracket);
1752
- return new Expression_1.IndexedGetExpression(expr, index, openingSquare, closingSquare, questionDotToken);
1798
+ const closingSquare = this.tryConsume(DiagnosticMessages_1.DiagnosticMessages.expectedRightSquareBraceAfterArrayOrObjectIndex(), TokenKind_1.TokenKind.RightSquareBracket);
1799
+ return new Expression_1.IndexedGetExpression(expr, indexes.shift(), openingSquare, closingSquare, questionDotToken, indexes);
1753
1800
  }
1754
1801
  newExpression() {
1755
- var _a;
1756
1802
  this.warnIfNotBrighterScriptMode(`using 'new' keyword to construct a class`);
1757
1803
  let newToken = this.advance();
1758
- let nameExpr = this.identifyingExpression();
1759
- let leftParen = this.tryConsume(DiagnosticMessages_1.DiagnosticMessages.unexpectedToken(this.peek().text), TokenKind_1.TokenKind.LeftParen, TokenKind_1.TokenKind.QuestionLeftParen);
1760
- if (!leftParen) {
1761
- // new expression without a following call expression
1762
- // wrap the name in an expression
1763
- const endOfStatementRange = util_1.util.createRangeFromPositions(newToken.range.end, (_a = this.peek()) === null || _a === void 0 ? void 0 : _a.range.end);
1764
- const exprStmt = nameExpr !== null && nameExpr !== void 0 ? nameExpr : (0, creators_1.createStringLiteral)('', endOfStatementRange);
1765
- return new Statement_1.ExpressionStatement(exprStmt);
1766
- }
1804
+ let nameExpr = this.getNamespacedVariableNameExpression();
1805
+ let leftParen = this.consume(DiagnosticMessages_1.DiagnosticMessages.unexpectedToken(this.peek().text), TokenKind_1.TokenKind.LeftParen, TokenKind_1.TokenKind.QuestionLeftParen);
1767
1806
  let call = this.finishCall(leftParen, nameExpr);
1768
1807
  //pop the call from the callExpressions list because this is technically something else
1769
1808
  this.callExpressions.pop();
@@ -1872,81 +1911,58 @@ class Parser {
1872
1911
  return expression;
1873
1912
  }
1874
1913
  /**
1875
- * Creates a TypeExpression, which wraps standard ASTNodes that represent a BscType
1914
+ * Tries to get the next token as a type
1915
+ * Allows for built-in types (double, string, etc.) or namespaced custom types in Brighterscript mode
1916
+ * Will return a token of whatever is next to be parsed
1917
+ * Will allow v1 type syntax (typed arrays, union types), but there is no validation on types used this way
1876
1918
  */
1877
- typeExpression() {
1878
- const changedTokens = [];
1879
- try {
1880
- let expr = this.getTypeExpressionPart(changedTokens);
1881
- while (this.options.mode === ParseMode.BrighterScript && this.matchAny(TokenKind_1.TokenKind.Or)) {
1882
- // If we're in Brighterscript mode, allow union types with "or" between types
1883
- // TODO: Handle Union types in parens? eg. "(string or integer)"
1884
- let operator = this.previous();
1885
- let right = this.getTypeExpressionPart(changedTokens);
1886
- if (right) {
1887
- expr = new Expression_1.BinaryExpression(expr, operator, right);
1919
+ typeToken(ignoreDiagnostics = false) {
1920
+ let typeToken;
1921
+ let lookForUnions = true;
1922
+ let isAUnion = false;
1923
+ let resultToken;
1924
+ while (lookForUnions) {
1925
+ lookForUnions = false;
1926
+ if (this.checkAny(...TokenKind_1.DeclarableTypes)) {
1927
+ // Token is a built in type
1928
+ typeToken = this.advance();
1929
+ }
1930
+ else if (this.options.mode === ParseMode.BrighterScript) {
1931
+ try {
1932
+ // see if we can get a namespaced identifer
1933
+ const qualifiedType = this.getNamespacedVariableNameExpression(ignoreDiagnostics);
1934
+ typeToken = (0, creators_1.createToken)(TokenKind_1.TokenKind.Identifier, qualifiedType.getName(this.options.mode), qualifiedType.range);
1888
1935
  }
1889
- else {
1890
- break;
1936
+ catch (_a) {
1937
+ //could not get an identifier - just get whatever's next
1938
+ typeToken = this.advance();
1891
1939
  }
1892
1940
  }
1893
- if (expr) {
1894
- return new Expression_1.TypeExpression(expr);
1895
- }
1896
- }
1897
- catch (error) {
1898
- // Something went wrong - reset the kind to what it was previously
1899
- for (const changedToken of changedTokens) {
1900
- changedToken.token.kind = changedToken.oldKind;
1901
- }
1902
- throw error;
1903
- }
1904
- }
1905
- /**
1906
- * Gets a single "part" of a type of a potential Union type
1907
- * Note: this does not NEED to be part of a union type, but the logic is the same
1908
- *
1909
- * @param changedTokens an array that is modified with any tokens that have been changed from their default kind to identifiers - eg. when a keyword is used as type
1910
- * @returns an expression that was successfully parsed
1911
- */
1912
- getTypeExpressionPart(changedTokens) {
1913
- let expr;
1914
- if (this.checkAny(...TokenKind_1.DeclarableTypes)) {
1915
- // if this is just a type, just use directly
1916
- expr = new Expression_1.VariableExpression(this.advance());
1917
- }
1918
- else {
1919
- if (this.checkAny(...TokenKind_1.AllowedTypeIdentifiers)) {
1920
- // Since the next token is allowed as a type identifier, change the kind
1921
- let nextToken = this.peek();
1922
- changedTokens.push({ token: nextToken, oldKind: nextToken.kind });
1923
- nextToken.kind = TokenKind_1.TokenKind.Identifier;
1924
- }
1925
- expr = this.identifyingExpression(TokenKind_1.AllowedTypeIdentifiers);
1926
- if (expr) {
1927
- this._references.expressions.add(expr);
1928
- }
1929
- }
1930
- //Check if it has square brackets, thus making it an array
1931
- if (expr && this.check(TokenKind_1.TokenKind.LeftSquareBracket)) {
1932
- if (this.options.mode === ParseMode.BrightScript) {
1933
- // typed arrays not allowed in Brightscript
1934
- this.warnIfNotBrighterScriptMode('typed arrays');
1935
- return expr;
1936
- }
1937
- // Check if it is an array - that is, if it has `[]` after the type
1938
- // eg. `string[]` or `SomeKlass[]`
1939
- // This is while loop, so it supports multidimensional arrays (eg. integer[][])
1940
- while (this.check(TokenKind_1.TokenKind.LeftSquareBracket)) {
1941
- const leftBracket = this.advance();
1942
- if (this.check(TokenKind_1.TokenKind.RightSquareBracket)) {
1941
+ else {
1942
+ // just get whatever's next
1943
+ typeToken = this.advance();
1944
+ }
1945
+ resultToken = resultToken !== null && resultToken !== void 0 ? resultToken : typeToken;
1946
+ if (resultToken && this.options.mode === ParseMode.BrighterScript) {
1947
+ // check for brackets
1948
+ while (this.check(TokenKind_1.TokenKind.LeftSquareBracket) && this.peekNext().kind === TokenKind_1.TokenKind.RightSquareBracket) {
1949
+ const leftBracket = this.advance();
1943
1950
  const rightBracket = this.advance();
1944
- expr = new Expression_1.TypedArrayExpression(expr, leftBracket, rightBracket);
1945
- this._references.expressions.add(expr);
1951
+ typeToken = (0, creators_1.createToken)(TokenKind_1.TokenKind.Identifier, typeToken.text + leftBracket.text + rightBracket.text, util_1.util.createBoundingRange(typeToken, leftBracket, rightBracket));
1952
+ resultToken = (0, creators_1.createToken)(TokenKind_1.TokenKind.Dynamic, null, typeToken.range);
1953
+ }
1954
+ if (this.check(TokenKind_1.TokenKind.Or)) {
1955
+ lookForUnions = true;
1956
+ let orToken = this.advance();
1957
+ resultToken = (0, creators_1.createToken)(TokenKind_1.TokenKind.Dynamic, null, util_1.util.createBoundingRange(resultToken, typeToken, orToken));
1958
+ isAUnion = true;
1946
1959
  }
1947
1960
  }
1948
1961
  }
1949
- return expr;
1962
+ if (isAUnion) {
1963
+ resultToken = (0, creators_1.createToken)(TokenKind_1.TokenKind.Dynamic, null, util_1.util.createBoundingRange(resultToken, typeToken));
1964
+ }
1965
+ return resultToken;
1950
1966
  }
1951
1967
  primary() {
1952
1968
  switch (true) {
@@ -2217,6 +2233,11 @@ class Parser {
2217
2233
  var _a;
2218
2234
  return ((_a = this.previous()) === null || _a === void 0 ? void 0 : _a.kind) === tokenKind;
2219
2235
  }
2236
+ /**
2237
+ * Check that the next token kind is the expected kind
2238
+ * @param tokenKind the expected next kind
2239
+ * @returns true if the next tokenKind is the expected value
2240
+ */
2220
2241
  check(tokenKind) {
2221
2242
  const nextKind = this.peek().kind;
2222
2243
  if (nextKind === TokenKind_1.TokenKind.Eof) {
@@ -2362,7 +2383,7 @@ class Parser {
2362
2383
  ClassStatement: s => {
2363
2384
  this._references.classStatements.push(s);
2364
2385
  },
2365
- FieldStatement: s => {
2386
+ ClassFieldStatement: s => {
2366
2387
  if (s.initialValue) {
2367
2388
  this._references.expressions.add(s.initialValue);
2368
2389
  }