brighterscript 1.0.0-alpha.2 → 1.0.0-alpha.22

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 (388) hide show
  1. package/CHANGELOG.md +643 -253
  2. package/README.md +33 -9
  3. package/bsconfig.schema.json +22 -2
  4. package/dist/BsConfig.d.ts +9 -0
  5. package/dist/Cache.d.ts +5 -6
  6. package/dist/Cache.js +12 -11
  7. package/dist/Cache.js.map +1 -1
  8. package/dist/CodeActionUtil.d.ts +11 -2
  9. package/dist/CodeActionUtil.js +17 -3
  10. package/dist/CodeActionUtil.js.map +1 -1
  11. package/dist/CommentFlagProcessor.d.ts +4 -4
  12. package/dist/CommentFlagProcessor.js +5 -3
  13. package/dist/CommentFlagProcessor.js.map +1 -1
  14. package/dist/DependencyGraph.d.ts +2 -2
  15. package/dist/DependencyGraph.js +20 -7
  16. package/dist/DependencyGraph.js.map +1 -1
  17. package/dist/DiagnosticCollection.d.ts +3 -3
  18. package/dist/DiagnosticCollection.js +11 -11
  19. package/dist/DiagnosticCollection.js.map +1 -1
  20. package/dist/DiagnosticFilterer.js +5 -4
  21. package/dist/DiagnosticFilterer.js.map +1 -1
  22. package/dist/DiagnosticMessages.d.ts +59 -4
  23. package/dist/DiagnosticMessages.js +65 -7
  24. package/dist/DiagnosticMessages.js.map +1 -1
  25. package/dist/LanguageServer.d.ts +51 -39
  26. package/dist/LanguageServer.js +316 -232
  27. package/dist/LanguageServer.js.map +1 -1
  28. package/dist/Logger.d.ts +2 -0
  29. package/dist/Logger.js +10 -8
  30. package/dist/Logger.js.map +1 -1
  31. package/dist/PluginInterface.d.ts +7 -3
  32. package/dist/PluginInterface.js +9 -0
  33. package/dist/PluginInterface.js.map +1 -1
  34. package/dist/Program.d.ts +43 -25
  35. package/dist/Program.js +212 -95
  36. package/dist/Program.js.map +1 -1
  37. package/dist/ProgramBuilder.d.ts +4 -0
  38. package/dist/ProgramBuilder.js +36 -20
  39. package/dist/ProgramBuilder.js.map +1 -1
  40. package/dist/Scope.d.ts +126 -29
  41. package/dist/Scope.js +433 -156
  42. package/dist/Scope.js.map +1 -1
  43. package/dist/SemanticTokenUtils.d.ts +14 -0
  44. package/dist/SemanticTokenUtils.js +81 -0
  45. package/dist/SemanticTokenUtils.js.map +1 -0
  46. package/dist/SymbolTable.d.ts +10 -4
  47. package/dist/SymbolTable.js +55 -13
  48. package/dist/SymbolTable.js.map +1 -1
  49. package/dist/XmlScope.d.ts +7 -2
  50. package/dist/XmlScope.js +65 -27
  51. package/dist/XmlScope.js.map +1 -1
  52. package/dist/astUtils/AstEditor.d.ts +65 -0
  53. package/dist/astUtils/AstEditor.js +239 -0
  54. package/dist/astUtils/AstEditor.js.map +1 -0
  55. package/dist/{types/FunctionType.spec.d.ts → astUtils/AstEditor.spec.d.ts} +0 -0
  56. package/dist/astUtils/AstEditor.spec.js +254 -0
  57. package/dist/astUtils/AstEditor.spec.js.map +1 -0
  58. package/dist/astUtils/creators.d.ts +28 -6
  59. package/dist/astUtils/creators.js +137 -19
  60. package/dist/astUtils/creators.js.map +1 -1
  61. package/dist/astUtils/creators.spec.js +14 -4
  62. package/dist/astUtils/creators.spec.js.map +1 -1
  63. package/dist/astUtils/reflection.d.ts +32 -10
  64. package/dist/astUtils/reflection.js +82 -7
  65. package/dist/astUtils/reflection.js.map +1 -1
  66. package/dist/astUtils/reflection.spec.js +130 -119
  67. package/dist/astUtils/reflection.spec.js.map +1 -1
  68. package/dist/astUtils/stackedVisitor.js.map +1 -1
  69. package/dist/astUtils/stackedVisitor.spec.js +13 -13
  70. package/dist/astUtils/stackedVisitor.spec.js.map +1 -1
  71. package/dist/astUtils/visitors.d.ts +76 -51
  72. package/dist/astUtils/visitors.js +31 -11
  73. package/dist/astUtils/visitors.js.map +1 -1
  74. package/dist/astUtils/visitors.spec.js +126 -32
  75. package/dist/astUtils/visitors.spec.js.map +1 -1
  76. package/dist/astUtils/xml.d.ts +4 -3
  77. package/dist/astUtils/xml.js +8 -3
  78. package/dist/astUtils/xml.js.map +1 -1
  79. package/dist/bscPlugin/BscPlugin.d.ts +7 -1
  80. package/dist/bscPlugin/BscPlugin.js +28 -0
  81. package/dist/bscPlugin/BscPlugin.js.map +1 -1
  82. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +4 -4
  83. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  84. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +26 -26
  85. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
  86. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +9 -0
  87. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +108 -0
  88. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -0
  89. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.d.ts +1 -0
  90. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +130 -0
  91. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -0
  92. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.d.ts +8 -0
  93. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js +52 -0
  94. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +1 -0
  95. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.d.ts +1 -0
  96. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js +32 -0
  97. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js.map +1 -0
  98. package/dist/bscPlugin/validation/BrsFileValidator.d.ts +9 -0
  99. package/dist/bscPlugin/validation/BrsFileValidator.js +66 -0
  100. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -0
  101. package/dist/bscPlugin/validation/ScopeValidator.d.ts +29 -0
  102. package/dist/bscPlugin/validation/ScopeValidator.js +183 -0
  103. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -0
  104. package/dist/cli.js +10 -3
  105. package/dist/cli.js.map +1 -1
  106. package/dist/diagnosticUtils.d.ts +1 -0
  107. package/dist/diagnosticUtils.js +15 -8
  108. package/dist/diagnosticUtils.js.map +1 -1
  109. package/dist/examples/plugins/removePrint.js +12 -14
  110. package/dist/examples/plugins/removePrint.js.map +1 -1
  111. package/dist/files/BrsFile.Class.spec.js +717 -147
  112. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  113. package/dist/files/BrsFile.d.ts +70 -30
  114. package/dist/files/BrsFile.js +719 -353
  115. package/dist/files/BrsFile.js.map +1 -1
  116. package/dist/files/BrsFile.spec.js +1238 -449
  117. package/dist/files/BrsFile.spec.js.map +1 -1
  118. package/dist/files/XmlFile.d.ts +6 -5
  119. package/dist/files/XmlFile.js +38 -30
  120. package/dist/files/XmlFile.js.map +1 -1
  121. package/dist/files/XmlFile.spec.js +302 -237
  122. package/dist/files/XmlFile.spec.js.map +1 -1
  123. package/dist/files/tests/imports.spec.js +44 -42
  124. package/dist/files/tests/imports.spec.js.map +1 -1
  125. package/dist/files/tests/optionalChaning.spec.d.ts +1 -0
  126. package/dist/files/tests/optionalChaning.spec.js +88 -0
  127. package/dist/files/tests/optionalChaning.spec.js.map +1 -0
  128. package/dist/globalCallables.d.ts +3 -1
  129. package/dist/globalCallables.js +424 -152
  130. package/dist/globalCallables.js.map +1 -1
  131. package/dist/index.d.ts +13 -3
  132. package/dist/index.js +28 -5
  133. package/dist/index.js.map +1 -1
  134. package/dist/interfaces.d.ts +133 -16
  135. package/dist/lexer/Lexer.d.ts +19 -1
  136. package/dist/lexer/Lexer.js +127 -21
  137. package/dist/lexer/Lexer.js.map +1 -1
  138. package/dist/lexer/Lexer.spec.js +657 -536
  139. package/dist/lexer/Lexer.spec.js.map +1 -1
  140. package/dist/lexer/Token.d.ts +2 -2
  141. package/dist/lexer/TokenKind.d.ts +13 -1
  142. package/dist/lexer/TokenKind.js +60 -3
  143. package/dist/lexer/TokenKind.js.map +1 -1
  144. package/dist/parser/BrsTranspileState.d.ts +9 -0
  145. package/dist/parser/BrsTranspileState.js +14 -0
  146. package/dist/parser/BrsTranspileState.js.map +1 -1
  147. package/dist/parser/Expression.d.ts +150 -34
  148. package/dist/parser/Expression.js +335 -165
  149. package/dist/parser/Expression.js.map +1 -1
  150. package/dist/parser/Parser.Class.spec.js +189 -89
  151. package/dist/parser/Parser.Class.spec.js.map +1 -1
  152. package/dist/parser/Parser.d.ts +153 -30
  153. package/dist/parser/Parser.js +1100 -503
  154. package/dist/parser/Parser.js.map +1 -1
  155. package/dist/parser/Parser.spec.js +687 -266
  156. package/dist/parser/Parser.spec.js.map +1 -1
  157. package/dist/parser/SGParser.d.ts +41 -4
  158. package/dist/parser/SGParser.js +186 -175
  159. package/dist/parser/SGParser.js.map +1 -1
  160. package/dist/parser/SGParser.spec.js +35 -22
  161. package/dist/parser/SGParser.spec.js.map +1 -1
  162. package/dist/parser/SGTypes.d.ts +206 -38
  163. package/dist/parser/SGTypes.js +470 -161
  164. package/dist/parser/SGTypes.js.map +1 -1
  165. package/dist/parser/SGTypes.spec.d.ts +1 -0
  166. package/dist/parser/SGTypes.spec.js +351 -0
  167. package/dist/parser/SGTypes.spec.js.map +1 -0
  168. package/dist/parser/Statement.d.ts +202 -48
  169. package/dist/parser/Statement.js +648 -193
  170. package/dist/parser/Statement.js.map +1 -1
  171. package/dist/parser/Statement.spec.js +11 -11
  172. package/dist/parser/Statement.spec.js.map +1 -1
  173. package/dist/parser/TranspileState.d.ts +1 -1
  174. package/dist/parser/TranspileState.js +15 -7
  175. package/dist/parser/TranspileState.js.map +1 -1
  176. package/dist/parser/tests/Parser.spec.d.ts +10 -9
  177. package/dist/parser/tests/Parser.spec.js +15 -11
  178. package/dist/parser/tests/Parser.spec.js.map +1 -1
  179. package/dist/parser/tests/controlFlow/For.spec.js +60 -60
  180. package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
  181. package/dist/parser/tests/controlFlow/ForEach.spec.js +40 -39
  182. package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
  183. package/dist/parser/tests/controlFlow/If.spec.js +213 -194
  184. package/dist/parser/tests/controlFlow/If.spec.js.map +1 -1
  185. package/dist/parser/tests/controlFlow/While.spec.js +37 -37
  186. package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
  187. package/dist/parser/tests/expression/Additive.spec.js +30 -30
  188. package/dist/parser/tests/expression/Additive.spec.js.map +1 -1
  189. package/dist/parser/tests/expression/ArrayLiterals.spec.js +119 -119
  190. package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +1 -1
  191. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +162 -138
  192. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
  193. package/dist/parser/tests/expression/Boolean.spec.js +24 -24
  194. package/dist/parser/tests/expression/Boolean.spec.js.map +1 -1
  195. package/dist/parser/tests/expression/Call.spec.js +41 -40
  196. package/dist/parser/tests/expression/Call.spec.js.map +1 -1
  197. package/dist/parser/tests/expression/Exponential.spec.js +17 -17
  198. package/dist/parser/tests/expression/Exponential.spec.js.map +1 -1
  199. package/dist/parser/tests/expression/Function.spec.js +256 -256
  200. package/dist/parser/tests/expression/Function.spec.js.map +1 -1
  201. package/dist/parser/tests/expression/Indexing.spec.js +87 -87
  202. package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
  203. package/dist/parser/tests/expression/Multiplicative.spec.js +37 -37
  204. package/dist/parser/tests/expression/Multiplicative.spec.js.map +1 -1
  205. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +75 -63
  206. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
  207. package/dist/parser/tests/expression/PrefixUnary.spec.js +41 -41
  208. package/dist/parser/tests/expression/PrefixUnary.spec.js.map +1 -1
  209. package/dist/parser/tests/expression/Primary.spec.js +41 -41
  210. package/dist/parser/tests/expression/Primary.spec.js.map +1 -1
  211. package/dist/parser/tests/expression/RegexLiteralExpression.spec.d.ts +1 -0
  212. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +171 -0
  213. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -0
  214. package/dist/parser/tests/expression/Relational.spec.js +43 -43
  215. package/dist/parser/tests/expression/Relational.spec.js.map +1 -1
  216. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +9 -9
  217. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +1 -1
  218. package/dist/parser/tests/expression/TemplateStringExpression.spec.js +28 -28
  219. package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
  220. package/dist/parser/tests/expression/TernaryExpression.spec.js +102 -102
  221. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
  222. package/dist/parser/tests/statement/AssignmentOperators.spec.js +36 -36
  223. package/dist/parser/tests/statement/AssignmentOperators.spec.js.map +1 -1
  224. package/dist/parser/tests/statement/Declaration.spec.js +44 -44
  225. package/dist/parser/tests/statement/Declaration.spec.js.map +1 -1
  226. package/dist/parser/tests/statement/Dim.spec.js +21 -21
  227. package/dist/parser/tests/statement/Dim.spec.js.map +1 -1
  228. package/dist/parser/tests/statement/Enum.spec.d.ts +1 -0
  229. package/dist/parser/tests/statement/Enum.spec.js +840 -0
  230. package/dist/parser/tests/statement/Enum.spec.js.map +1 -0
  231. package/dist/parser/tests/statement/For.spec.d.ts +1 -0
  232. package/dist/parser/tests/statement/For.spec.js +46 -0
  233. package/dist/parser/tests/statement/For.spec.js.map +1 -0
  234. package/dist/parser/tests/statement/ForEach.spec.d.ts +1 -0
  235. package/dist/parser/tests/statement/ForEach.spec.js +37 -0
  236. package/dist/parser/tests/statement/ForEach.spec.js.map +1 -0
  237. package/dist/parser/tests/statement/Function.spec.js +198 -197
  238. package/dist/parser/tests/statement/Function.spec.js.map +1 -1
  239. package/dist/parser/tests/statement/Goto.spec.js +15 -14
  240. package/dist/parser/tests/statement/Goto.spec.js.map +1 -1
  241. package/dist/parser/tests/statement/Increment.spec.js +50 -50
  242. package/dist/parser/tests/statement/Increment.spec.js.map +1 -1
  243. package/dist/parser/tests/statement/InterfaceStatement.spec.d.ts +1 -0
  244. package/dist/parser/tests/statement/InterfaceStatement.spec.js +254 -0
  245. package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -0
  246. package/dist/parser/tests/statement/LibraryStatement.spec.js +17 -17
  247. package/dist/parser/tests/statement/LibraryStatement.spec.js.map +1 -1
  248. package/dist/parser/tests/statement/Misc.spec.js +108 -106
  249. package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
  250. package/dist/parser/tests/statement/PrintStatement.spec.js +40 -40
  251. package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
  252. package/dist/parser/tests/statement/ReturnStatement.spec.js +46 -46
  253. package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
  254. package/dist/parser/tests/statement/Set.spec.js +83 -83
  255. package/dist/parser/tests/statement/Set.spec.js.map +1 -1
  256. package/dist/parser/tests/statement/Stop.spec.js +12 -11
  257. package/dist/parser/tests/statement/Stop.spec.js.map +1 -1
  258. package/dist/parser/tests/statement/Throw.spec.js +5 -5
  259. package/dist/parser/tests/statement/Throw.spec.js.map +1 -1
  260. package/dist/parser/tests/statement/TryCatch.spec.js +15 -13
  261. package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
  262. package/dist/preprocessor/Chunk.d.ts +1 -1
  263. package/dist/preprocessor/Chunk.js.map +1 -1
  264. package/dist/preprocessor/Manifest.d.ts +5 -5
  265. package/dist/preprocessor/Manifest.js +14 -35
  266. package/dist/preprocessor/Manifest.js.map +1 -1
  267. package/dist/preprocessor/Manifest.spec.d.ts +1 -0
  268. package/dist/preprocessor/Manifest.spec.js +78 -103
  269. package/dist/preprocessor/Manifest.spec.js.map +1 -1
  270. package/dist/preprocessor/Preprocessor.d.ts +1 -1
  271. package/dist/preprocessor/Preprocessor.js +8 -8
  272. package/dist/preprocessor/Preprocessor.js.map +1 -1
  273. package/dist/preprocessor/Preprocessor.spec.js +49 -49
  274. package/dist/preprocessor/Preprocessor.spec.js.map +1 -1
  275. package/dist/preprocessor/PreprocessorParser.spec.js +72 -72
  276. package/dist/preprocessor/PreprocessorParser.spec.js.map +1 -1
  277. package/dist/roku-types/data.json +21891 -0
  278. package/dist/roku-types/index.d.ts +6776 -0
  279. package/dist/roku-types/index.js +11 -0
  280. package/dist/roku-types/index.js.map +1 -0
  281. package/dist/types/ArrayType.d.ts +8 -5
  282. package/dist/types/ArrayType.js +52 -12
  283. package/dist/types/ArrayType.js.map +1 -1
  284. package/dist/types/ArrayType.spec.js +72 -11
  285. package/dist/types/ArrayType.spec.js.map +1 -1
  286. package/dist/types/BooleanType.d.ts +4 -2
  287. package/dist/types/BooleanType.js +9 -4
  288. package/dist/types/BooleanType.js.map +1 -1
  289. package/dist/types/BooleanType.spec.js +5 -3
  290. package/dist/types/BooleanType.spec.js.map +1 -1
  291. package/dist/types/BscType.d.ts +20 -5
  292. package/dist/types/BscType.js +24 -0
  293. package/dist/types/BscType.js.map +1 -1
  294. package/dist/types/CustomType.d.ts +8 -6
  295. package/dist/types/CustomType.js +20 -11
  296. package/dist/types/CustomType.js.map +1 -1
  297. package/dist/types/DoubleType.d.ts +2 -0
  298. package/dist/types/DoubleType.js +14 -9
  299. package/dist/types/DoubleType.js.map +1 -1
  300. package/dist/types/DoubleType.spec.js +5 -3
  301. package/dist/types/DoubleType.spec.js.map +1 -1
  302. package/dist/types/DynamicType.d.ts +2 -0
  303. package/dist/types/DynamicType.js +6 -2
  304. package/dist/types/DynamicType.js.map +1 -1
  305. package/dist/types/DynamicType.spec.js +2 -2
  306. package/dist/types/DynamicType.spec.js.map +1 -1
  307. package/dist/types/EnumType.d.ts +22 -0
  308. package/dist/types/EnumType.js +55 -0
  309. package/dist/types/EnumType.js.map +1 -0
  310. package/dist/types/FloatType.d.ts +2 -0
  311. package/dist/types/FloatType.js +14 -9
  312. package/dist/types/FloatType.js.map +1 -1
  313. package/dist/types/FloatType.spec.js +4 -2
  314. package/dist/types/FloatType.spec.js.map +1 -1
  315. package/dist/types/FunctionType.d.ts +7 -31
  316. package/dist/types/FunctionType.js +11 -57
  317. package/dist/types/FunctionType.js.map +1 -1
  318. package/dist/types/IntegerType.d.ts +2 -0
  319. package/dist/types/IntegerType.js +14 -9
  320. package/dist/types/IntegerType.js.map +1 -1
  321. package/dist/types/IntegerType.spec.js +5 -3
  322. package/dist/types/IntegerType.spec.js.map +1 -1
  323. package/dist/types/InterfaceType.d.ts +13 -4
  324. package/dist/types/InterfaceType.js +48 -8
  325. package/dist/types/InterfaceType.js.map +1 -1
  326. package/dist/types/InterfaceType.spec.d.ts +1 -0
  327. package/dist/types/InterfaceType.spec.js +194 -0
  328. package/dist/types/InterfaceType.spec.js.map +1 -0
  329. package/dist/types/InvalidType.d.ts +4 -2
  330. package/dist/types/InvalidType.js +10 -5
  331. package/dist/types/InvalidType.js.map +1 -1
  332. package/dist/types/InvalidType.spec.js +4 -2
  333. package/dist/types/InvalidType.spec.js.map +1 -1
  334. package/dist/types/LazyType.d.ts +8 -7
  335. package/dist/types/LazyType.js +22 -10
  336. package/dist/types/LazyType.js.map +1 -1
  337. package/dist/types/LongIntegerType.d.ts +2 -0
  338. package/dist/types/LongIntegerType.js +14 -9
  339. package/dist/types/LongIntegerType.js.map +1 -1
  340. package/dist/types/LongIntegerType.spec.js +4 -2
  341. package/dist/types/LongIntegerType.spec.js.map +1 -1
  342. package/dist/types/ObjectType.d.ts +8 -4
  343. package/dist/types/ObjectType.js +9 -4
  344. package/dist/types/ObjectType.js.map +1 -1
  345. package/dist/types/ObjectType.spec.js +2 -2
  346. package/dist/types/ObjectType.spec.js.map +1 -1
  347. package/dist/types/StringType.d.ts +4 -2
  348. package/dist/types/StringType.js +9 -4
  349. package/dist/types/StringType.js.map +1 -1
  350. package/dist/types/StringType.spec.js +4 -2
  351. package/dist/types/StringType.spec.js.map +1 -1
  352. package/dist/types/TypedFunctionType.d.ts +28 -0
  353. package/dist/types/TypedFunctionType.js +88 -0
  354. package/dist/types/TypedFunctionType.js.map +1 -0
  355. package/dist/types/TypedFunctionType.spec.d.ts +1 -0
  356. package/dist/types/TypedFunctionType.spec.js +37 -0
  357. package/dist/types/TypedFunctionType.spec.js.map +1 -0
  358. package/dist/types/UninitializedType.js +3 -3
  359. package/dist/types/UninitializedType.js.map +1 -1
  360. package/dist/types/VoidType.d.ts +4 -2
  361. package/dist/types/VoidType.js +8 -4
  362. package/dist/types/VoidType.js.map +1 -1
  363. package/dist/types/VoidType.spec.js +2 -2
  364. package/dist/types/VoidType.spec.js.map +1 -1
  365. package/dist/types/helpers.d.ts +42 -0
  366. package/dist/types/helpers.js +118 -0
  367. package/dist/types/helpers.js.map +1 -0
  368. package/dist/util.d.ts +91 -21
  369. package/dist/util.js +364 -114
  370. package/dist/util.js.map +1 -1
  371. package/dist/validators/ClassValidator.d.ts +19 -2
  372. package/dist/validators/ClassValidator.js +164 -103
  373. package/dist/validators/ClassValidator.js.map +1 -1
  374. package/package.json +30 -19
  375. package/dist/astUtils/index.d.ts +0 -7
  376. package/dist/astUtils/index.js +0 -26
  377. package/dist/astUtils/index.js.map +0 -1
  378. package/dist/lexer/index.d.ts +0 -3
  379. package/dist/lexer/index.js +0 -17
  380. package/dist/lexer/index.js.map +0 -1
  381. package/dist/parser/index.d.ts +0 -3
  382. package/dist/parser/index.js +0 -16
  383. package/dist/parser/index.js.map +0 -1
  384. package/dist/preprocessor/index.d.ts +0 -3
  385. package/dist/preprocessor/index.js +0 -16
  386. package/dist/preprocessor/index.js.map +0 -1
  387. package/dist/types/FunctionType.spec.js +0 -23
  388. package/dist/types/FunctionType.spec.js.map +0 -1
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypedFunctionType = void 0;
4
+ const reflection_1 = require("../astUtils/reflection");
5
+ const DynamicType_1 = require("./DynamicType");
6
+ class TypedFunctionType {
7
+ constructor(returnType,
8
+ /**
9
+ * Determines if this is a sub or not
10
+ */
11
+ isSub = false, params = [], isNew = false, isVariadic = false) {
12
+ this.returnType = returnType;
13
+ this.isSub = isSub;
14
+ this.params = params;
15
+ this.isNew = isNew;
16
+ this.isVariadic = isVariadic;
17
+ }
18
+ setName(name) {
19
+ this.name = name;
20
+ return this;
21
+ }
22
+ addParameter(paramOrName, type, isOptional) {
23
+ if (typeof paramOrName === 'string') {
24
+ this.params.push({
25
+ name: paramOrName,
26
+ type: type !== null && type !== void 0 ? type : new DynamicType_1.DynamicType(),
27
+ isOptional: isOptional === true ? true : false,
28
+ isRestArgument: false
29
+ });
30
+ }
31
+ else {
32
+ this.params.push(paramOrName);
33
+ }
34
+ return this;
35
+ }
36
+ isAssignableTo(targetType, context) {
37
+ if ((0, reflection_1.isObjectType)(targetType)) {
38
+ return true;
39
+ }
40
+ else if ((0, reflection_1.isTypedFunctionType)(targetType)) {
41
+ if (!targetType.isVariadic) {
42
+ //compare all parameters
43
+ let len = Math.max(this.params.length, targetType.params.length);
44
+ for (let i = 0; i < len; i++) {
45
+ let myParam = this.params[i];
46
+ let targetParam = targetType.params[i];
47
+ if (!myParam || !targetParam || !myParam.type.isAssignableTo(targetParam.type, context)) {
48
+ return false;
49
+ }
50
+ }
51
+ }
52
+ //compare return type
53
+ if (!this.returnType || !targetType.returnType || !this.returnType.isAssignableTo(targetType.returnType, context)) {
54
+ return false;
55
+ }
56
+ //made it here, all params and return type are equivalent
57
+ return true;
58
+ }
59
+ else if ((0, reflection_1.isDynamicType)(targetType)) {
60
+ return true;
61
+ }
62
+ else {
63
+ return false;
64
+ }
65
+ }
66
+ isConvertibleTo(targetType, context) {
67
+ return this.isAssignableTo(targetType, context);
68
+ }
69
+ toString(context) {
70
+ var _a, _b;
71
+ let paramTexts = [];
72
+ for (let param of this.params) {
73
+ paramTexts.push(`${param.name}${param.isOptional ? '?' : ''} as ${param.type.toString(context)}`);
74
+ }
75
+ if (this.isNew) {
76
+ return `new ${(_a = this.name) !== null && _a !== void 0 ? _a : ''}(${paramTexts.join(', ')})`;
77
+ }
78
+ return `${this.isSub ? 'sub' : 'function'} ${(_b = this.name) !== null && _b !== void 0 ? _b : ''}(${paramTexts.join(', ')}) as ${this.returnType.toString(context)}`;
79
+ }
80
+ toTypeString() {
81
+ return 'Function';
82
+ }
83
+ equals(targetType, context) {
84
+ return ((0, reflection_1.isTypedFunctionType)(targetType)) && this.isAssignableTo(targetType, context);
85
+ }
86
+ }
87
+ exports.TypedFunctionType = TypedFunctionType;
88
+ //# sourceMappingURL=TypedFunctionType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypedFunctionType.js","sourceRoot":"","sources":["../../src/types/TypedFunctionType.ts"],"names":[],"mappings":";;;AAAA,uDAA0F;AAG1F,+CAA4C;AAE5C,MAAa,iBAAiB;IAC1B,YACW,UAAmB;IAC1B;;OAEG;IACI,QAAQ,KAAK,EACb,SAA0B,EAAE,EAC5B,QAAQ,KAAK,EACb,aAAa,KAAK;QAPlB,eAAU,GAAV,UAAU,CAAS;QAInB,UAAK,GAAL,KAAK,CAAQ;QACb,WAAM,GAAN,MAAM,CAAsB;QAC5B,UAAK,GAAL,KAAK,CAAQ;QACb,eAAU,GAAV,UAAU,CAAQ;IAE7B,CAAC;IAOM,OAAO,CAAC,IAAY;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,OAAO,IAAI,CAAC;IAChB,CAAC;IACM,YAAY,CAAC,WAAmC,EAAE,IAAc,EAAE,UAAoB;QACzF,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;YACjC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;gBACb,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,IAAI,yBAAW,EAAE;gBAC/B,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAA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_1 = require("chai");
4
+ const DynamicType_1 = require("./DynamicType");
5
+ const FloatType_1 = require("./FloatType");
6
+ const TypedFunctionType_1 = require("./TypedFunctionType");
7
+ const IntegerType_1 = require("./IntegerType");
8
+ const StringType_1 = require("./StringType");
9
+ const FunctionType_1 = require("./FunctionType");
10
+ const VoidType_1 = require("./VoidType");
11
+ const ObjectType_1 = require("./ObjectType");
12
+ describe('FunctionType', () => {
13
+ it('is equivalent to proper type', () => {
14
+ (0, chai_1.expect)(new TypedFunctionType_1.TypedFunctionType(new VoidType_1.VoidType()).isAssignableTo(new DynamicType_1.DynamicType())).to.be.true;
15
+ (0, chai_1.expect)(new TypedFunctionType_1.TypedFunctionType(new VoidType_1.VoidType()).isAssignableTo(new ObjectType_1.ObjectType())).to.be.true;
16
+ });
17
+ it('validates using param and return types', () => {
18
+ (0, chai_1.expect)(new TypedFunctionType_1.TypedFunctionType(new VoidType_1.VoidType()).isAssignableTo(new TypedFunctionType_1.TypedFunctionType(new VoidType_1.VoidType()))).to.be.true;
19
+ //different parameter count
20
+ (0, chai_1.expect)(new TypedFunctionType_1.TypedFunctionType(new VoidType_1.VoidType()).addParameter('a', new IntegerType_1.IntegerType(), false).isAssignableTo(new TypedFunctionType_1.TypedFunctionType(new VoidType_1.VoidType()))).to.be.false;
21
+ //different parameter types
22
+ (0, chai_1.expect)(new TypedFunctionType_1.TypedFunctionType(new VoidType_1.VoidType()).addParameter('a', new IntegerType_1.IntegerType(), false).isAssignableTo(new TypedFunctionType_1.TypedFunctionType(new VoidType_1.VoidType()).addParameter('a', new StringType_1.StringType(), false))).to.be.false;
23
+ //different return type
24
+ (0, chai_1.expect)(new TypedFunctionType_1.TypedFunctionType(new VoidType_1.VoidType()).isAssignableTo(new TypedFunctionType_1.TypedFunctionType(new IntegerType_1.IntegerType()))).to.be.false;
25
+ });
26
+ it('adds a callableParam object as a parameter', () => {
27
+ const myFunc = new TypedFunctionType_1.TypedFunctionType(new IntegerType_1.IntegerType(), false, [{ name: 'a', type: new StringType_1.StringType(), isOptional: false }, { name: 'b', type: new DynamicType_1.DynamicType(), isOptional: true }]);
28
+ myFunc.addParameter({ name: 'c', type: new FloatType_1.FloatType(), isOptional: true });
29
+ (0, chai_1.expect)(myFunc.params.length).to.equal(3);
30
+ });
31
+ it('is assignable to a universal function', () => {
32
+ (0, chai_1.expect)(new TypedFunctionType_1.TypedFunctionType(new StringType_1.StringType()).setName('myFunc').addParameter('p1', new IntegerType_1.IntegerType()).isAssignableTo(new FunctionType_1.FunctionType()));
33
+ (0, chai_1.expect)(new TypedFunctionType_1.TypedFunctionType(new DynamicType_1.DynamicType()).isAssignableTo(new FunctionType_1.FunctionType()));
34
+ (0, chai_1.expect)(new TypedFunctionType_1.TypedFunctionType(new VoidType_1.VoidType()).isAssignableTo(new FunctionType_1.FunctionType()));
35
+ });
36
+ });
37
+ //# sourceMappingURL=TypedFunctionType.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypedFunctionType.spec.js","sourceRoot":"","sources":["../../src/types/TypedFunctionType.spec.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAE9B,+CAA4C;AAC5C,2CAAwC;AACxC,2DAAwD;AACxD,+CAA4C;AAC5C,6CAA0C;AAC1C,iDAA8C;AAC9C,yCAAsC;AACtC,6CAA0C;AAE1C,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACpC,IAAA,aAAM,EAAC,IAAI,qCAAiB,CAAC,IAAI,mBAAQ,EAAE,CAAC,CAAC,cAAc,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAC3F,IAAA,aAAM,EAAC,IAAI,qCAAiB,CAAC,IAAI,mBAAQ,EAAE,CAAC,CAAC,cAAc,CAAC,IAAI,uBAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IAC9F,CAAC,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I,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,uBAAU,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,yBAAW,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACrL,MAAM,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,qBAAS,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5E,IAAA,aAAM,EAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC7C,IAAA,aAAM,EAAC,IAAI,qCAAiB,CAAC,IAAI,uBAAU,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,yBAAW,EAAE,CAAC,CAAC,cAAc,CAAC,IAAI,2BAAY,EAAE,CAAC,CAAC,CAAC;QAC3I,IAAA,aAAM,EAAC,IAAI,qCAAiB,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC,cAAc,CAAC,IAAI,2BAAY,EAAE,CAAC,CAAC,CAAC;QACpF,IAAA,aAAM,EAAC,IAAI,qCAAiB,CAAC,IAAI,mBAAQ,EAAE,CAAC,CAAC,cAAc,CAAC,IAAI,2BAAY,EAAE,CAAC,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -6,8 +6,8 @@ class UninitializedType {
6
6
  // eslint-disable-next-line @typescript-eslint/no-useless-constructor
7
7
  constructor() { }
8
8
  isAssignableTo(targetType) {
9
- return (reflection_1.isUninitializedType(targetType) ||
10
- reflection_1.isDynamicType(targetType));
9
+ return ((0, reflection_1.isUninitializedType)(targetType) ||
10
+ (0, reflection_1.isDynamicType)(targetType));
11
11
  }
12
12
  isConvertibleTo(targetType) {
13
13
  return this.isAssignableTo(targetType);
@@ -19,7 +19,7 @@ class UninitializedType {
19
19
  return this.toString();
20
20
  }
21
21
  equals(targetType) {
22
- return reflection_1.isUninitializedType(targetType);
22
+ return (0, reflection_1.isUninitializedType)(targetType);
23
23
  }
24
24
  }
25
25
  exports.UninitializedType = UninitializedType;
@@ -1 +1 @@
1
- {"version":3,"file":"UninitializedType.js","sourceRoot":"","sources":["../../src/types/UninitializedType.ts"],"names":[],"mappings":";;;AAAA,uDAA4E;AAG5E,MAAa,iBAAiB;IAE1B,qEAAqE;IACrE,gBAAgB,CAAC;IAEV,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,gCAAmB,CAAC,UAAU,CAAC;YAC/B,0BAAa,CAAC,UAAU,CAAC,CAC5B,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAEM,QAAQ;QACX,OAAO,eAAe,CAAC;IAC3B,CAAC;IAGM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,UAAmB;QAC7B,OAAO,gCAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;CACJ;AA5BD,8CA4BC"}
1
+ {"version":3,"file":"UninitializedType.js","sourceRoot":"","sources":["../../src/types/UninitializedType.ts"],"names":[],"mappings":";;;AAAA,uDAA4E;AAG5E,MAAa,iBAAiB;IAE1B,qEAAqE;IACrE,gBAAgB,CAAC;IAEV,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,IAAA,gCAAmB,EAAC,UAAU,CAAC;YAC/B,IAAA,0BAAa,EAAC,UAAU,CAAC,CAC5B,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAEM,QAAQ;QACX,OAAO,eAAe,CAAC;IAC3B,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,UAAmB;QAC7B,OAAO,IAAA,gCAAmB,EAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;CACJ;AA3BD,8CA2BC"}
@@ -1,7 +1,9 @@
1
1
  import type { BscType } from './BscType';
2
2
  export declare class VoidType implements BscType {
3
- isAssignableTo(targetType: BscType): any;
4
- isConvertibleTo(targetType: BscType): any;
3
+ typeText?: string;
4
+ constructor(typeText?: string);
5
+ isAssignableTo(targetType: BscType): boolean;
6
+ isConvertibleTo(targetType: BscType): boolean;
5
7
  toString(): string;
6
8
  toTypeString(): string;
7
9
  equals(targetType: BscType): boolean;
@@ -3,21 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VoidType = void 0;
4
4
  const reflection_1 = require("../astUtils/reflection");
5
5
  class VoidType {
6
+ constructor(typeText) {
7
+ this.typeText = typeText;
8
+ }
6
9
  isAssignableTo(targetType) {
7
- return (reflection_1.isVoidType(targetType) ||
8
- reflection_1.isDynamicType(targetType));
10
+ return ((0, reflection_1.isVoidType)(targetType) ||
11
+ (0, reflection_1.isDynamicType)(targetType));
9
12
  }
10
13
  isConvertibleTo(targetType) {
11
14
  return this.isAssignableTo(targetType);
12
15
  }
13
16
  toString() {
14
- return 'void';
17
+ var _a;
18
+ return (_a = this.typeText) !== null && _a !== void 0 ? _a : 'void';
15
19
  }
16
20
  toTypeString() {
17
21
  return this.toString();
18
22
  }
19
23
  equals(targetType) {
20
- return reflection_1.isVoidType(targetType);
24
+ return (0, reflection_1.isVoidType)(targetType);
21
25
  }
22
26
  }
23
27
  exports.VoidType = VoidType;
@@ -1 +1 @@
1
- {"version":3,"file":"VoidType.js","sourceRoot":"","sources":["../../src/types/VoidType.ts"],"names":[],"mappings":";;;AAAA,uDAAmE;AAGnE,MAAa,QAAQ;IACV,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,uBAAU,CAAC,UAAU,CAAC;YACtB,0BAAa,CAAC,UAAU,CAAC,CAC5B,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAEM,QAAQ;QACX,OAAO,MAAM,CAAC;IAClB,CAAC;IAGM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,UAAmB;QAC7B,OAAO,uBAAU,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;CACJ;AAxBD,4BAwBC"}
1
+ {"version":3,"file":"VoidType.js","sourceRoot":"","sources":["../../src/types/VoidType.ts"],"names":[],"mappings":";;;AAAA,uDAAmE;AAGnE,MAAa,QAAQ;IACjB,YACW,QAAiB;QAAjB,aAAQ,GAAR,QAAQ,CAAS;IACxB,CAAC;IAEE,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,IAAA,uBAAU,EAAC,UAAU,CAAC;YACtB,IAAA,0BAAa,EAAC,UAAU,CAAC,CAC5B,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAEM,QAAQ;;QACX,OAAO,MAAA,IAAI,CAAC,QAAQ,mCAAI,MAAM,CAAC;IACnC,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,UAAmB;QAC7B,OAAO,IAAA,uBAAU,EAAC,UAAU,CAAC,CAAC;IAClC,CAAC;CACJ;AA3BD,4BA2BC"}
@@ -5,8 +5,8 @@ const DynamicType_1 = require("./DynamicType");
5
5
  const VoidType_1 = require("./VoidType");
6
6
  describe('VoidType', () => {
7
7
  it('is equivalent to dynamic types', () => {
8
- chai_1.expect(new VoidType_1.VoidType().isAssignableTo(new VoidType_1.VoidType())).to.be.true;
9
- chai_1.expect(new VoidType_1.VoidType().isAssignableTo(new DynamicType_1.DynamicType())).to.be.true;
8
+ (0, chai_1.expect)(new VoidType_1.VoidType().isAssignableTo(new VoidType_1.VoidType())).to.be.true;
9
+ (0, chai_1.expect)(new VoidType_1.VoidType().isAssignableTo(new DynamicType_1.DynamicType())).to.be.true;
10
10
  });
11
11
  });
12
12
  //# sourceMappingURL=VoidType.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"VoidType.spec.js","sourceRoot":"","sources":["../../src/types/VoidType.spec.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAE9B,+CAA4C;AAC5C,yCAAsC;AAEtC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACtB,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACtC,aAAM,CAAC,IAAI,mBAAQ,EAAE,CAAC,cAAc,CAAC,IAAI,mBAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACjE,aAAM,CAAC,IAAI,mBAAQ,EAAE,CAAC,cAAc,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IACxE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"VoidType.spec.js","sourceRoot":"","sources":["../../src/types/VoidType.spec.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAE9B,+CAA4C;AAC5C,yCAAsC;AAEtC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACtB,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACtC,IAAA,aAAM,EAAC,IAAI,mBAAQ,EAAE,CAAC,cAAc,CAAC,IAAI,mBAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACjE,IAAA,aAAM,EAAC,IAAI,mBAAQ,EAAE,CAAC,cAAc,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IACxE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { CallExpression, DottedGetExpression, FunctionExpression, NewExpression, VariableExpression } from '../parser/Expression';
2
+ import type { BscType } from './BscType';
3
+ /**
4
+ * Gets the return type of a function, taking into account that the function may not have been declared yet
5
+ * If the callee already exists in symbol table, use that return type
6
+ * otherwise, make a lazy type which will not compute its type until the file is done parsing
7
+ *
8
+ * @param call the Expression to process
9
+ * @param functionExpression the wrapping function expression
10
+ * @return the best guess type of that expression
11
+ */
12
+ export declare function getTypeFromCallExpression(call: CallExpression, functionExpression: FunctionExpression): BscType;
13
+ /**
14
+ * Gets the type of a variable
15
+ * if it already exists in symbol table, use that type
16
+ * otherwise defer the type until first read, which will allow us to derive types from variables defined after this one (like from a loop perhaps)
17
+ *
18
+ * @param variable the Expression to process
19
+ * @param functionExpression the wrapping function expression
20
+ * @return the best guess type of that expression
21
+ */
22
+ export declare function getTypeFromVariableExpression(variable: VariableExpression, functionExpression: FunctionExpression): BscType;
23
+ /**
24
+ * Gets the type of a variable
25
+ * if it already exists in symbol table, use that type
26
+ * otherwise defer the type until first read, which will allow us to derive types from variables defined after this one (like from a loop perhaps)
27
+ *
28
+ * @param newExp the Expression to process
29
+ * @param functionExpression the wrapping function expression
30
+ * @return the best guess type of that expression
31
+ */
32
+ export declare function getTypeFromNewExpression(newExp: NewExpression, functionExpression: FunctionExpression): BscType;
33
+ /**
34
+ * Gets the type of a variable
35
+ * if it already exists in symbol table, use that type
36
+ * otherwise defer the type until first read, which will allow us to derive types from variables defined after this one (like from a loop perhaps)
37
+ *
38
+ * @param variable the Expression to process
39
+ * @param functionExpression the wrapping function expression
40
+ * @return the best guess type of that expression
41
+ */
42
+ export declare function getTypeFromDottedGetExpression(expr: DottedGetExpression, functionExpression: FunctionExpression): BscType;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTypeFromDottedGetExpression = exports.getTypeFromNewExpression = exports.getTypeFromVariableExpression = exports.getTypeFromCallExpression = void 0;
4
+ const reflection_1 = require("../astUtils/reflection");
5
+ const LazyType_1 = require("./LazyType");
6
+ const UninitializedType_1 = require("./UninitializedType");
7
+ const Parser_1 = require("../parser/Parser");
8
+ const CustomType_1 = require("./CustomType");
9
+ const DynamicType_1 = require("./DynamicType");
10
+ /**
11
+ * Gets the return type of a function, taking into account that the function may not have been declared yet
12
+ * If the callee already exists in symbol table, use that return type
13
+ * otherwise, make a lazy type which will not compute its type until the file is done parsing
14
+ *
15
+ * @param call the Expression to process
16
+ * @param functionExpression the wrapping function expression
17
+ * @return the best guess type of that expression
18
+ */
19
+ function getTypeFromCallExpression(call, functionExpression) {
20
+ let calleeName = call.callee.name;
21
+ if (calleeName) {
22
+ const currentKnownType = functionExpression.symbolTable.getSymbolType(calleeName.text.toLowerCase());
23
+ if ((0, reflection_1.isTypedFunctionType)(currentKnownType)) {
24
+ return currentKnownType.returnType;
25
+ }
26
+ if (currentKnownType) {
27
+ // this will probably only happen if a functionName has been assigned to something else previously?
28
+ return currentKnownType;
29
+ }
30
+ return new LazyType_1.LazyType((context) => {
31
+ var _a;
32
+ let futureType;
33
+ if ((0, reflection_1.isBrsFile)(context === null || context === void 0 ? void 0 : context.file)) {
34
+ const file = context.file;
35
+ futureType = (_a = file.getSymbolTypeFromToken(calleeName, functionExpression, context.scope)) === null || _a === void 0 ? void 0 : _a.type;
36
+ }
37
+ else {
38
+ // Give best guess if there is no file context
39
+ futureType = functionExpression.symbolTable.getSymbolType(calleeName.text);
40
+ }
41
+ if ((0, reflection_1.isTypedFunctionType)(futureType)) {
42
+ return futureType.returnType;
43
+ }
44
+ return futureType;
45
+ });
46
+ }
47
+ else {
48
+ //return dynamic if we can't figure out the type
49
+ return new DynamicType_1.DynamicType();
50
+ }
51
+ }
52
+ exports.getTypeFromCallExpression = getTypeFromCallExpression;
53
+ /**
54
+ * Gets the type of a variable
55
+ * if it already exists in symbol table, use that type
56
+ * otherwise defer the type until first read, which will allow us to derive types from variables defined after this one (like from a loop perhaps)
57
+ *
58
+ * @param variable the Expression to process
59
+ * @param functionExpression the wrapping function expression
60
+ * @return the best guess type of that expression
61
+ */
62
+ function getTypeFromVariableExpression(variable, functionExpression) {
63
+ let variableName = variable.name.text.toLowerCase();
64
+ const currentKnownType = functionExpression.symbolTable.getSymbolType(variableName);
65
+ if ((0, reflection_1.isPrimitiveType)(currentKnownType) || (0, reflection_1.isArrayType)(currentKnownType)) {
66
+ // for "contextless" types, eg. myVar = 3.14
67
+ return currentKnownType;
68
+ }
69
+ return resolveLazyType(variable.name, functionExpression);
70
+ }
71
+ exports.getTypeFromVariableExpression = getTypeFromVariableExpression;
72
+ /**
73
+ * Gets the type of a variable
74
+ * if it already exists in symbol table, use that type
75
+ * otherwise defer the type until first read, which will allow us to derive types from variables defined after this one (like from a loop perhaps)
76
+ *
77
+ * @param newExp the Expression to process
78
+ * @param functionExpression the wrapping function expression
79
+ * @return the best guess type of that expression
80
+ */
81
+ function getTypeFromNewExpression(newExp, functionExpression) {
82
+ let className = newExp.className.getName(Parser_1.ParseMode.BrighterScript);
83
+ return new LazyType_1.LazyType((context) => {
84
+ var _a, _b, _c;
85
+ return new CustomType_1.CustomType(className, (_c = (_a = context === null || context === void 0 ? void 0 : context.scope) === null || _a === void 0 ? void 0 : _a.getClass(className, (_b = functionExpression.namespaceName) === null || _b === void 0 ? void 0 : _b.getName())) === null || _c === void 0 ? void 0 : _c.memberTable);
86
+ });
87
+ }
88
+ exports.getTypeFromNewExpression = getTypeFromNewExpression;
89
+ function resolveLazyType(currentToken, functionExpression) {
90
+ return new LazyType_1.LazyType((context) => {
91
+ var _a, _b;
92
+ let futureType;
93
+ if ((0, reflection_1.isBrsFile)(context === null || context === void 0 ? void 0 : context.file)) {
94
+ const file = context.file;
95
+ futureType = (_a = file.getSymbolTypeFromToken(currentToken, functionExpression, context.scope)) === null || _a === void 0 ? void 0 : _a.type;
96
+ }
97
+ else {
98
+ // Give best guess if there is no file context
99
+ futureType = (_b = functionExpression.symbolTable.getSymbolType(currentToken.text)) !== null && _b !== void 0 ? _b : new UninitializedType_1.UninitializedType();
100
+ }
101
+ return futureType;
102
+ });
103
+ }
104
+ /**
105
+ * Gets the type of a variable
106
+ * if it already exists in symbol table, use that type
107
+ * otherwise defer the type until first read, which will allow us to derive types from variables defined after this one (like from a loop perhaps)
108
+ *
109
+ * @param variable the Expression to process
110
+ * @param functionExpression the wrapping function expression
111
+ * @return the best guess type of that expression
112
+ */
113
+ function getTypeFromDottedGetExpression(expr, functionExpression) {
114
+ const currentToken = (0, reflection_1.isCallExpression)(expr) ? (expr.callee).name : expr.name;
115
+ return resolveLazyType(currentToken, functionExpression);
116
+ }
117
+ exports.getTypeFromDottedGetExpression = getTypeFromDottedGetExpression;
118
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/types/helpers.ts"],"names":[],"mappings":";;;AAAA,uDAAwH;AAGxH,yCAAsC;AAEtC,2DAAwD;AACxD,6CAA6C;AAC7C,6CAA0C;AAC1C,+CAA4C;AAE5C;;;;;;;;GAQG;AACH,SAAgB,yBAAyB,CAAC,IAAoB,EAAE,kBAAsC;IAClG,IAAI,UAAU,GAAK,IAAI,CAAC,MAAc,CAAC,IAAc,CAAC;IACtD,IAAI,UAAU,EAAE;QACZ,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,WAAW,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACrG,IAAI,IAAA,gCAAmB,EAAC,gBAAgB,CAAC,EAAE;YACvC,OAAO,gBAAgB,CAAC,UAAU,CAAC;SACtC;QACD,IAAI,gBAAgB,EAAE;YAClB,m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AAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;IAEtF,OAAO,eAAe,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAC;AAC7D,CAAC;AAJD,wEAIC"}
package/dist/util.d.ts CHANGED
@@ -1,23 +1,21 @@
1
- import * as rokuDeploy from 'roku-deploy';
2
1
  import type { Diagnostic, Position, Range } from 'vscode-languageserver';
3
2
  import type { BsConfig } from './BsConfig';
4
- import type { CallableContainer, BsDiagnostic, FileReference, CallableContainerMap, CompilerPlugin, ExpressionInfo, FunctionCall } from './interfaces';
3
+ import type { CallableContainer, BsDiagnostic, FileReference, CallableContainerMap, CompilerPlugin, ExpressionInfo, FunctionCall, CallableParam, TranspileResult } from './interfaces';
5
4
  import { BooleanType } from './types/BooleanType';
6
5
  import { DoubleType } from './types/DoubleType';
7
6
  import { DynamicType } from './types/DynamicType';
8
7
  import { FloatType } from './types/FloatType';
9
- import { FunctionType } from './types/FunctionType';
10
8
  import { IntegerType } from './types/IntegerType';
11
9
  import { InvalidType } from './types/InvalidType';
12
10
  import { LongIntegerType } from './types/LongIntegerType';
13
- import { ObjectType } from './types/ObjectType';
14
11
  import { StringType } from './types/StringType';
15
12
  import { VoidType } from './types/VoidType';
16
- import type { DottedGetExpression, Expression, VariableExpression } from './parser/Expression';
17
- import type { Token } from './lexer';
18
- import { CustomType } from './types/CustomType';
13
+ import type { DottedGetExpression, Expression, NamespacedVariableNameExpression, VariableExpression } from './parser/Expression';
14
+ import type { Locatable, Token } from './lexer/Token';
19
15
  import { SourceNode } from 'source-map';
20
- import type { SGAttribute } from './parser/SGTypes';
16
+ import { SGAttribute } from './parser/SGTypes';
17
+ import type { BscType } from './types/BscType';
18
+ import { FunctionType } from './types/FunctionType';
21
19
  export declare class Util {
22
20
  clearConsole(): void;
23
21
  /**
@@ -62,12 +60,11 @@ export declare class Util {
62
60
  */
63
61
  loadConfigFile(configFilePath: string, parentProjectPaths?: string[], cwd?: string): BsConfig;
64
62
  /**
65
- * Relative paths to scripts in plugins should be resolved relatively to the bsconfig file
66
- * and de-duplicated
67
- * @param config Parsed configuration
68
- * @param configFilePath Path of the configuration file
63
+ * Convert relative paths to absolute paths, relative to the given directory. Also de-dupes the paths. Modifies the array in-place
64
+ * @param paths the list of paths to be resolved and deduped
65
+ * @param relativeDir the path to the folder where the paths should be resolved relative to. This should be an absolute path
69
66
  */
70
- resolvePluginPaths(config: BsConfig, configFilePath: string): void;
67
+ resolvePathsRelativeTo(collection: any, key: string, relativeDir: string): void;
71
68
  /**
72
69
  * Do work within the scope of a changed current working directory
73
70
  * @param targetCwd
@@ -116,10 +113,10 @@ export declare class Util {
116
113
  getPkgPathFromTarget(sourcePkgPath: string, targetPath: string): string;
117
114
  /**
118
115
  * Compute the relative path from the source file to the target file
119
- * @param pkgSourcePathAbsolute - the absolute path to the source relative to the package location
120
- * @param pkgTargetPathAbsolute - the absolute path ro the target relative to the package location
116
+ * @param pkgSrcPath - the absolute path to the source, where cwd is the package location
117
+ * @param pkgTargetPath - the absolute path to the target, where cwd is the package location
121
118
  */
122
- getRelativePath(pkgSourcePathAbsolute: string, pkgTargetPathAbsolute: string): string;
119
+ getRelativePath(pkgSrcPath: string, pkgTargetPath: string): string;
123
120
  /**
124
121
  * Walks left in a DottedGetExpression and returns a VariableExpression if found, or undefined if not found
125
122
  */
@@ -171,7 +168,7 @@ export declare class Util {
171
168
  /**
172
169
  * Get paths to all files on disc that match this project's source list
173
170
  */
174
- getFilePaths(options: BsConfig): Promise<rokuDeploy.StandardizedFileEntry[]>;
171
+ getFilePaths(options: BsConfig): Promise<import("roku-deploy").StandardizedFileEntry[]>;
175
172
  /**
176
173
  * Given a path to a brs file, compute the path to a theoretical d.bs file.
177
174
  * Only `.brs` files can have a typedef, so return undefined for everything else
@@ -258,6 +255,13 @@ export declare class Util {
258
255
  * Create a `Range` from two `Position`s
259
256
  */
260
257
  createRangeFromPositions(startPosition: Position, endPosition: Position): Range;
258
+ /**
259
+ * Given a list of ranges, create a range that starts with the first non-null lefthand range, and ends with the first non-null
260
+ * righthand range. Returns undefined if none of the items have a range.
261
+ */
262
+ createBoundingRange(...locatables: Array<{
263
+ range?: Range;
264
+ }>): Range;
261
265
  /**
262
266
  * Create a `Position` object. Prefer this over `Position.create` for performance reasons
263
267
  */
@@ -272,7 +276,7 @@ export declare class Util {
272
276
  /**
273
277
  * Convert a token into a BscType
274
278
  */
275
- tokenToBscType(token: Token, allowCustomType?: boolean): DynamicType | ObjectType | CustomType | BooleanType | DoubleType | FloatType | FunctionType | IntegerType | InvalidType | LongIntegerType | StringType | VoidType;
279
+ tokenToBscType(token: Token, allowBrighterscriptTypes?: boolean, currentNamespaceName?: NamespacedVariableNameExpression): DynamicType | BscType | FloatType | IntegerType | DoubleType | LongIntegerType | StringType | BooleanType | FunctionType | InvalidType | VoidType;
276
280
  /**
277
281
  * Get the extension for the given file path. Basically the part after the final dot, except for
278
282
  * `d.bs` which is treated as single extension
@@ -294,14 +298,26 @@ export declare class Util {
294
298
  */
295
299
  simpleMap(source: string, src: string): SourceNode;
296
300
  /**
297
- * Creates a new SGAttribute object, but keeps the existing Range references (since those shouldn't ever get changed directly)
301
+ * Creates a new SGAttribute object, but keeps the existing Range references (since those should be immutable)
298
302
  */
299
303
  cloneSGAttribute(attr: SGAttribute, value: string): SGAttribute;
304
+ /**
305
+ * Shorthand for creating a new source node
306
+ */
307
+ sourceNode(source: string, locatable: {
308
+ range: Range;
309
+ }, code: string | SourceNode | TranspileResult): SourceNode | undefined;
300
310
  /**
301
311
  * Remove leading simple protocols from a path (if present)
302
312
  */
303
313
  removeProtocol(pkgPath: string): string;
314
+ /**
315
+ * Converts a path into a standardized format (drive letter to lower, remove extra slashes, use single slash type, resolve relative parts, etc...)
316
+ */
304
317
  standardizePath(thePath: string): string;
318
+ /**
319
+ * Copy the version of bslib from local node_modules to the staging folder
320
+ */
305
321
  copyBslibToStaging(stagingDir: string): Promise<void>;
306
322
  /**
307
323
  * Given a Diagnostic or BsDiagnostic, return a copy of the diagnostic
@@ -318,11 +334,60 @@ export declare class Util {
318
334
  source: string;
319
335
  };
320
336
  /**
321
- * Finds the array of callables from a container map, taking into account the function from which it was called
337
+ * Gets the minimum and maximum number of allowed params
338
+ * @param params The list of callable parameters to check
339
+ * @returns the minimum and maximum number of allowed params
340
+ */
341
+ getMinMaxParamCount(params: CallableParam[]): MinMax;
342
+ /**
343
+ * Gets the minimum and maximum number of allowed params for ALL functions with the name of the function call
344
+ * @param callablesByLowerName The map of callable containers
345
+ * @param expCall function call expression to use for the name
346
+ * @returns the minimum and maximum number of allowed params
347
+ */
348
+ getMinMaxParamCountByFunctionCall(callablesByLowerName: CallableContainerMap, expCall: FunctionCall): MinMax;
349
+ /**
350
+ * Finds the array of callables from a container map, based on the name of the function call
322
351
  * If the callable was called in a function in a namespace, functions in that namespace are preferred
352
+ * @param callablesByLowerName The map of callable containers
353
+ * @param expCall function call expression to use for the name
323
354
  * @return an array with callable containers - could be empty if nothing was found
324
355
  */
325
- getCallableContainersFromContainerMapByFunctionCall(callablesByLowerName: CallableContainerMap, expCall: FunctionCall): CallableContainer[];
356
+ getCallableContainersByName(callablesByLowerName: CallableContainerMap, expCall: FunctionCall): CallableContainer[];
357
+ /**
358
+ * Sort an array of objects that have a Range
359
+ */
360
+ sortByRange(locatables: Locatable[]): Locatable[];
361
+ /**
362
+ * Split the given text and return ranges for each chunk.
363
+ * Only works for single-line strings
364
+ */
365
+ splitGetRange(separator: string, text: string, range: Range): {
366
+ text: string;
367
+ range: Range;
368
+ }[];
369
+ mdFence(code: string, language?: string): string;
370
+ /**
371
+ * Finds a callable from a container map based on the name AND number of arguments
372
+ * If the callable was called in a function in a namespace, functions in that namespace are preferred
373
+ * The first callable that matches the name AND will accept the number of arguments given is returned
374
+ * @return a callable containers that matches the call
375
+ */
376
+ getCallableContainerByFunctionCall(callablesByLowerName: CallableContainerMap, expCall: FunctionCall): CallableContainer;
377
+ /**
378
+ * Gets each part of the dotted get.
379
+ * @param expression
380
+ * @returns an array of the parts of the dotted get. If not fully a dotted get, then returns undefined
381
+ */
382
+ getAllDottedGetParts(expression: Expression): string[] | undefined;
383
+ /**
384
+ * Returns an integer if valid, or undefined. Eliminates checking for NaN
385
+ */
386
+ parseInt(value: any): number;
387
+ /**
388
+ * Converts a range to a string in the format 1:2-3:4
389
+ */
390
+ rangeToString(range: Range): string;
326
391
  }
327
392
  /**
328
393
  * A tagged template literal function for standardizing the path. This has to be defined as standalone function since it's a tagged template literal function,
@@ -331,3 +396,8 @@ export declare class Util {
331
396
  export declare function standardizePath(stringParts: any, ...expressions: any[]): string;
332
397
  export declare let util: Util;
333
398
  export default util;
399
+ export interface MinMax {
400
+ min: number;
401
+ max: number;
402
+ }
403
+ export declare const MAX_PARAM_COUNT = 32;