brighterscript 0.66.0-alpha.9 → 0.67.1

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 +123 -73
  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 +31 -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 +85 -89
  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 +559 -612
  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 -11
  352. package/dist/ActionPipeline.d.ts +0 -10
  353. package/dist/ActionPipeline.js +0 -40
  354. package/dist/ActionPipeline.js.map +0 -1
  355. package/dist/AstValidationSegmenter.d.ts +0 -25
  356. package/dist/AstValidationSegmenter.js +0 -150
  357. package/dist/AstValidationSegmenter.js.map +0 -1
  358. package/dist/CacheVerifier.d.ts +0 -7
  359. package/dist/CacheVerifier.js +0 -20
  360. package/dist/CacheVerifier.js.map +0 -1
  361. package/dist/astUtils/Editor.js.map +0 -1
  362. package/dist/astUtils/Editor.spec.js.map +0 -1
  363. package/dist/bscPlugin/FileWriter.d.ts +0 -6
  364. package/dist/bscPlugin/FileWriter.js +0 -24
  365. package/dist/bscPlugin/FileWriter.js.map +0 -1
  366. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +0 -1658
  367. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +0 -1
  368. package/dist/bscPlugin/fileProviders/FileProvider.d.ts +0 -9
  369. package/dist/bscPlugin/fileProviders/FileProvider.js +0 -51
  370. package/dist/bscPlugin/fileProviders/FileProvider.js.map +0 -1
  371. package/dist/bscPlugin/serialize/BslibInjector.spec.js +0 -19
  372. package/dist/bscPlugin/serialize/BslibInjector.spec.js.map +0 -1
  373. package/dist/bscPlugin/serialize/BslibManager.d.ts +0 -9
  374. package/dist/bscPlugin/serialize/BslibManager.js +0 -40
  375. package/dist/bscPlugin/serialize/BslibManager.js.map +0 -1
  376. package/dist/bscPlugin/serialize/FileSerializer.d.ts +0 -9
  377. package/dist/bscPlugin/serialize/FileSerializer.js +0 -72
  378. package/dist/bscPlugin/serialize/FileSerializer.js.map +0 -1
  379. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +0 -1
  380. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js +0 -41
  381. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +0 -1
  382. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +0 -11
  383. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js +0 -53
  384. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +0 -1
  385. package/dist/bscPlugin/validation/ScopeValidator.spec.js +0 -2004
  386. package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +0 -1
  387. package/dist/files/AssetFile.d.ts +0 -26
  388. package/dist/files/AssetFile.js +0 -26
  389. package/dist/files/AssetFile.js.map +0 -1
  390. package/dist/files/Factory.d.ts +0 -25
  391. package/dist/files/Factory.js +0 -22
  392. package/dist/files/Factory.js.map +0 -1
  393. package/dist/files/File.d.ts +0 -106
  394. package/dist/files/File.js +0 -16
  395. package/dist/files/File.js.map +0 -1
  396. package/dist/files/LazyFileData.d.ts +0 -20
  397. package/dist/files/LazyFileData.js +0 -54
  398. package/dist/files/LazyFileData.js.map +0 -1
  399. package/dist/files/LazyFileData.spec.js +0 -27
  400. package/dist/files/LazyFileData.spec.js.map +0 -1
  401. package/dist/parser/tests/expression/TypeExpression.spec.js +0 -127
  402. package/dist/parser/tests/expression/TypeExpression.spec.js.map +0 -1
  403. package/dist/types/AssociativeArrayType.d.ts +0 -11
  404. package/dist/types/AssociativeArrayType.js +0 -52
  405. package/dist/types/AssociativeArrayType.js.map +0 -1
  406. package/dist/types/BaseFunctionType.d.ts +0 -9
  407. package/dist/types/BaseFunctionType.js +0 -25
  408. package/dist/types/BaseFunctionType.js.map +0 -1
  409. package/dist/types/BscTypeKind.d.ts +0 -25
  410. package/dist/types/BscTypeKind.js +0 -30
  411. package/dist/types/BscTypeKind.js.map +0 -1
  412. package/dist/types/BuiltInInterfaceAdder.d.ts +0 -23
  413. package/dist/types/BuiltInInterfaceAdder.js +0 -160
  414. package/dist/types/BuiltInInterfaceAdder.js.map +0 -1
  415. package/dist/types/BuiltInInterfaceAdder.spec.d.ts +0 -1
  416. package/dist/types/BuiltInInterfaceAdder.spec.js +0 -116
  417. package/dist/types/BuiltInInterfaceAdder.spec.js.map +0 -1
  418. package/dist/types/ClassType.d.ts +0 -17
  419. package/dist/types/ClassType.js +0 -58
  420. package/dist/types/ClassType.js.map +0 -1
  421. package/dist/types/ClassType.spec.d.ts +0 -1
  422. package/dist/types/ClassType.spec.js +0 -77
  423. package/dist/types/ClassType.spec.js.map +0 -1
  424. package/dist/types/ComponentType.d.ts +0 -26
  425. package/dist/types/ComponentType.js +0 -83
  426. package/dist/types/ComponentType.js.map +0 -1
  427. package/dist/types/EnumType.d.ts +0 -40
  428. package/dist/types/EnumType.js +0 -81
  429. package/dist/types/EnumType.js.map +0 -1
  430. package/dist/types/EnumType.spec.d.ts +0 -1
  431. package/dist/types/EnumType.spec.js +0 -33
  432. package/dist/types/EnumType.spec.js.map +0 -1
  433. package/dist/types/InheritableType.d.ts +0 -28
  434. package/dist/types/InheritableType.js +0 -152
  435. package/dist/types/InheritableType.js.map +0 -1
  436. package/dist/types/NamespaceType.d.ts +0 -12
  437. package/dist/types/NamespaceType.js +0 -28
  438. package/dist/types/NamespaceType.js.map +0 -1
  439. package/dist/types/ReferenceType.d.ts +0 -63
  440. package/dist/types/ReferenceType.js +0 -423
  441. package/dist/types/ReferenceType.js.map +0 -1
  442. package/dist/types/ReferenceType.spec.d.ts +0 -1
  443. package/dist/types/ReferenceType.spec.js +0 -137
  444. package/dist/types/ReferenceType.spec.js.map +0 -1
  445. package/dist/types/TypedFunctionType.d.ts +0 -33
  446. package/dist/types/TypedFunctionType.js +0 -106
  447. package/dist/types/TypedFunctionType.js.map +0 -1
  448. package/dist/types/TypedFunctionType.spec.d.ts +0 -1
  449. package/dist/types/TypedFunctionType.spec.js +0 -122
  450. package/dist/types/TypedFunctionType.spec.js.map +0 -1
  451. package/dist/types/UnionType.d.ts +0 -20
  452. package/dist/types/UnionType.js +0 -123
  453. package/dist/types/UnionType.js.map +0 -1
  454. package/dist/types/UnionType.spec.d.ts +0 -1
  455. package/dist/types/UnionType.spec.js +0 -130
  456. package/dist/types/UnionType.spec.js.map +0 -1
  457. package/dist/types/helper.spec.d.ts +0 -1
  458. package/dist/types/helper.spec.js +0 -145
  459. package/dist/types/helper.spec.js.map +0 -1
  460. package/dist/types/helpers.d.ts +0 -24
  461. package/dist/types/helpers.js +0 -178
  462. package/dist/types/helpers.js.map +0 -1
  463. package/dist/types/index.d.ts +0 -22
  464. package/dist/types/index.js +0 -39
  465. package/dist/types/index.js.map +0 -1
  466. /package/dist/astUtils/{Editor.spec.d.ts → AstEditor.spec.d.ts} +0 -0
  467. /package/dist/bscPlugin/{completions/CompletionsProcessor.spec.d.ts → definition/DefinitionProvider.spec.d.ts} +0 -0
  468. /package/dist/bscPlugin/{serialize/BslibInjector.spec.d.ts → references/ReferencesProvider.spec.d.ts} +0 -0
  469. /package/dist/bscPlugin/{transpile/BrsFileTranspileProcessor.spec.d.ts → symbols/DocumentSymbolProcessor.spec.d.ts} +0 -0
  470. /package/dist/bscPlugin/{validation/ScopeValidator.spec.d.ts → symbols/WorkspaceSymbolProcessor.spec.d.ts} +0 -0
  471. /package/dist/{files/LazyFileData.spec.d.ts → bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.d.ts} +0 -0
  472. /package/dist/{parser/tests/expression/TypeExpression.spec.d.ts → types/FunctionType.spec.d.ts} +0 -0
@@ -1,12 +1,19 @@
1
1
  import type { CompilerPlugin } from './interfaces';
2
- import type { Logger } from './Logger';
3
- export declare type Arguments<T> = [T] extends [(...args: infer U) => any] ? U : [T] extends [void] ? [] : [T];
2
+ import { type Logger } from './logging';
3
+ export declare type PluginEventArgs<T> = {
4
+ [K in keyof Required<T> as Required<T>[K] extends (...args: any[]) => any ? K : never]: Required<T>[K] extends (...args: any[]) => any ? Parameters<Required<T>[K]> : never;
5
+ };
4
6
  export default class PluginInterface<T extends CompilerPlugin = CompilerPlugin> {
5
- constructor(plugins: CompilerPlugin[], options: {
6
- logger: Logger;
7
+ private plugins?;
8
+ constructor();
9
+ /**
10
+ * @deprecated use the `options` parameter pattern instead
11
+ */
12
+ constructor(plugins?: CompilerPlugin[], logger?: Logger);
13
+ constructor(plugins?: CompilerPlugin[], options?: {
14
+ logger?: Logger;
7
15
  suppressErrors?: boolean;
8
16
  });
9
- private plugins;
10
17
  private logger;
11
18
  /**
12
19
  * Should plugin errors cause the program to fail, or should they be caught and simply logged
@@ -15,11 +22,7 @@ export default class PluginInterface<T extends CompilerPlugin = CompilerPlugin>
15
22
  /**
16
23
  * Call `event` on plugins
17
24
  */
18
- emit<K extends keyof T & string>(event: K, ...args: Arguments<T[K]>): Arguments<T[K]>[0];
19
- /**
20
- * Call `event` on plugins, but allow the plugins to return promises that will be awaited before the next plugin is notified
21
- */
22
- emitAsync<K extends keyof T & string>(event: K, ...args: Arguments<T[K]>): Promise<Arguments<T[K]>[0]>;
25
+ emit<K extends keyof PluginEventArgs<T> & string>(event: K, ...args: PluginEventArgs<T>[K]): void;
23
26
  /**
24
27
  * Add a plugin to the beginning of the list of plugins
25
28
  */
@@ -28,11 +31,6 @@ export default class PluginInterface<T extends CompilerPlugin = CompilerPlugin>
28
31
  * Add a plugin to the end of the list of plugins
29
32
  */
30
33
  add<T extends CompilerPlugin = CompilerPlugin>(plugin: T): T;
31
- /**
32
- * Find deprecated or removed historic plugin hooks, and warn about them.
33
- * Some events can be forwards-converted
34
- */
35
- private sanitizePlugin;
36
34
  has(plugin: CompilerPlugin): boolean;
37
35
  remove<T extends CompilerPlugin = CompilerPlugin>(plugin: T): T;
38
36
  /**
@@ -1,55 +1,41 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const Logger_1 = require("./Logger");
3
+ const logging_1 = require("./logging");
4
4
  class PluginInterface {
5
5
  constructor(plugins, options) {
6
- this.plugins = [];
7
- this.logger = options === null || options === void 0 ? void 0 : options.logger;
8
- this.suppressErrors = (options === null || options === void 0 ? void 0 : options.suppressErrors) === false ? false : true;
9
- for (const plugin of plugins) {
10
- this.add(plugin);
6
+ var _a;
7
+ this.plugins = plugins;
8
+ (_a = this.plugins) !== null && _a !== void 0 ? _a : (this.plugins = []);
9
+ if ((options === null || options === void 0 ? void 0 : options.constructor.name) === 'Logger') {
10
+ this.logger = options;
11
+ }
12
+ else {
13
+ this.logger = options === null || options === void 0 ? void 0 : options.logger;
14
+ this.suppressErrors = (options === null || options === void 0 ? void 0 : options.suppressErrors) === false ? false : true;
15
+ }
16
+ if (!this.logger) {
17
+ this.logger = (0, logging_1.createLogger)();
11
18
  }
12
19
  }
13
20
  /**
14
21
  * Call `event` on plugins
15
22
  */
16
23
  emit(event, ...args) {
17
- var _a, _b;
18
24
  for (let plugin of this.plugins) {
19
25
  if (plugin[event]) {
20
26
  try {
21
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.time(Logger_1.LogLevel.debug, [plugin.name, event], () => {
27
+ this.logger.time(logging_1.LogLevel.debug, [plugin.name, event], () => {
22
28
  plugin[event](...args);
23
29
  });
24
30
  }
25
31
  catch (err) {
26
- (_b = this.logger) === null || _b === void 0 ? void 0 : _b.error(`Error when calling plugin ${plugin.name}.${event}:`, err);
32
+ this.logger.error(`Error when calling plugin ${plugin.name}.${event}:`, err);
27
33
  if (!this.suppressErrors) {
28
34
  throw err;
29
35
  }
30
36
  }
31
37
  }
32
38
  }
33
- return args[0];
34
- }
35
- /**
36
- * Call `event` on plugins, but allow the plugins to return promises that will be awaited before the next plugin is notified
37
- */
38
- async emitAsync(event, ...args) {
39
- var _a, _b;
40
- for (let plugin of this.plugins) {
41
- if (plugin[event]) {
42
- try {
43
- await ((_a = this.logger) === null || _a === void 0 ? void 0 : _a.time(Logger_1.LogLevel.debug, [plugin.name, event], async () => {
44
- await Promise.resolve(plugin[event](...args));
45
- }));
46
- }
47
- catch (err) {
48
- (_b = this.logger) === null || _b === void 0 ? void 0 : _b.error(`Error when calling plugin ${plugin.name}.${event}:`, err);
49
- }
50
- }
51
- }
52
- return args[0];
53
39
  }
54
40
  /**
55
41
  * Add a plugin to the beginning of the list of plugins
@@ -65,56 +51,16 @@ class PluginInterface {
65
51
  */
66
52
  add(plugin) {
67
53
  if (!this.has(plugin)) {
68
- this.sanitizePlugin(plugin);
69
54
  this.plugins.push(plugin);
70
55
  }
71
56
  return plugin;
72
57
  }
73
- /**
74
- * Find deprecated or removed historic plugin hooks, and warn about them.
75
- * Some events can be forwards-converted
76
- */
77
- sanitizePlugin(plugin) {
78
- var _a, _b, _c;
79
- const removedHooks = [
80
- 'beforePrepublish',
81
- 'afterPrepublish'
82
- ];
83
- for (const removedHook of removedHooks) {
84
- if (plugin[removedHook]) {
85
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.error(`Plugin "${plugin.name}": event ${removedHook} is no longer supported and will never be called`);
86
- }
87
- }
88
- const upgradeWithWarn = {
89
- beforePublish: 'beforeSerializeProgram',
90
- afterPublish: 'afterSerializeProgram',
91
- beforeProgramTranspile: 'beforeBuildProgram',
92
- afterProgramTranspile: 'afterBuildProgram',
93
- beforeFileParse: 'beforeProvideFile',
94
- afterFileParse: 'afterProvideFile',
95
- beforeFileTranspile: 'beforePrepareFile',
96
- afterFileTranspile: 'afterPrepareFile',
97
- beforeFileDispose: 'beforeFileRemove',
98
- afterFileDispose: 'afterFileRemove'
99
- };
100
- for (const [oldEvent, newEvent] of Object.entries(upgradeWithWarn)) {
101
- if (plugin[oldEvent]) {
102
- if (!plugin[newEvent]) {
103
- plugin[newEvent] = plugin[oldEvent];
104
- (_b = this.logger) === null || _b === void 0 ? void 0 : _b.warn(`Plugin '${plugin.name}': event '${oldEvent}' is no longer supported. It has been converted to '${newEvent}' but you may encounter issues as their signatures do not match.`);
105
- }
106
- else {
107
- (_c = this.logger) === null || _c === void 0 ? void 0 : _c.warn(`Plugin "${plugin.name}": event '${oldEvent}' is no longer supported and will never be called`);
108
- }
109
- }
110
- }
111
- }
112
58
  has(plugin) {
113
59
  return this.plugins.includes(plugin);
114
60
  }
115
61
  remove(plugin) {
116
62
  if (this.has(plugin)) {
117
- this.plugins.splice(this.plugins.indexOf(plugin), 1);
63
+ this.plugins.splice(this.plugins.indexOf(plugin));
118
64
  }
119
65
  return plugin;
120
66
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PluginInterface.js","sourceRoot":"","sources":["../src/PluginInterface.ts"],"names":[],"mappings":";;AAEA,qCAAoC;AAOpC,MAAqB,eAAe;IAChC,YACI,OAAyB,EACzB,OAGC;QASG,YAAO,GAAqB,EAAE,CAAC;QAPnC,IAAI,CAAC,MAAM,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,CAAC;QAC9B,IAAI,CAAC,cAAc,GAAG,CAAC,OAAe,aAAf,OAAO,uBAAP,OAAO,CAAU,cAAc,MAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QAChF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC1B,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;SACpB;IACL,CAAC;IAUD;;OAEG;IACI,IAAI,CAA6B,KAAQ,EAAE,GAAG,IAAqB;;QACtE,KAAK,IAAI,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE;YAC7B,IAAK,MAAc,CAAC,KAAK,CAAC,EAAE;gBACxB,IAAI;oBACA,MAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,CAAC,iBAAQ,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE;wBACxD,MAAc,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;oBACpC,CAAC,CAAC,CAAC;iBACN;gBAAC,OAAO,GAAG,EAAE;oBACV,MAAA,IAAI,CAAC,MAAM,0CAAE,KAAK,CAAC,6BAA6B,MAAM,CAAC,IAAI,IAAI,KAAK,GAAG,EAAE,GAAG,CAAC,CAAC;oBAC9E,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;wBACtB,MAAM,GAAG,CAAC;qBACb;iBACJ;aACJ;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AC,OAAO,GAAG,EAAE,CAAC;IACtB,CAAC;CACJ;AApGD,kCAoGC"}
package/dist/Program.d.ts CHANGED
@@ -1,48 +1,42 @@
1
- import type { CodeAction, Position, Range, SignatureInformation, Location } from 'vscode-languageserver';
2
- import type { BsConfig } from './BsConfig';
1
+ import type { CodeAction, CompletionItem, Position, Range, SignatureInformation, Location, DocumentSymbol } from 'vscode-languageserver';
2
+ import type { BsConfig, FinalizedBsConfig } from './BsConfig';
3
3
  import { Scope } from './Scope';
4
- import type { BrsFile, ProvidedSymbolInfo } from './files/BrsFile';
5
- import type { XmlFile } from './files/XmlFile';
6
- import type { BsDiagnostic, FileObj, SemanticToken, FileLink, Hover } from './interfaces';
7
- import type { File } from './files/File';
4
+ import { BrsFile } from './files/BrsFile';
5
+ import { XmlFile } from './files/XmlFile';
6
+ import type { BsDiagnostic, File, FileReference, FileObj, BscFile, SemanticToken, FileLink, Hover } from './interfaces';
8
7
  import { XmlScope } from './XmlScope';
9
- import { Logger } from './Logger';
8
+ import type { Logger } from './logging';
10
9
  import PluginInterface from './PluginInterface';
11
10
  import type { FunctionStatement } from './parser/Statement';
12
- import { Editor } from './astUtils/Editor';
11
+ import type { SourceMapGenerator } from 'source-map';
13
12
  import type { Statement } from './parser/AstNode';
14
- import type { FileData } from './files/LazyFileData';
15
- import type { UnresolvedSymbol } from './AstValidationSegmenter';
13
+ export interface SourceObj {
14
+ /**
15
+ * @deprecated use `srcPath` instead
16
+ */
17
+ pathAbsolute: string;
18
+ srcPath: string;
19
+ source: string;
20
+ definitions?: string;
21
+ }
22
+ export interface TranspileObj {
23
+ file: BscFile;
24
+ outputPath: string;
25
+ }
16
26
  export interface SignatureInfoObj {
17
27
  index: number;
18
28
  key: string;
19
29
  signature: SignatureInformation;
20
30
  }
21
31
  export declare class Program {
22
- /**
23
- * The root directory for this program
24
- */
25
- options: BsConfig;
26
32
  constructor(
27
33
  /**
28
34
  * The root directory for this program
29
35
  */
30
36
  options: BsConfig, logger?: Logger, plugins?: PluginInterface);
37
+ options: FinalizedBsConfig;
31
38
  logger: Logger;
32
- /**
33
- * An editor that plugins can use to modify program-level things during the build flow. Don't use this to edit files (they have their own `.editor`)
34
- */
35
- editor: Editor;
36
- /**
37
- * A factory that creates `File` instances
38
- */
39
- private fileFactory;
40
39
  private createGlobalScope;
41
- private recursivelyAddNodeToSymbolTable;
42
- /**
43
- * Do all setup required for the global symbol table.
44
- */
45
- private populateGlobalSymbolTable;
46
40
  /**
47
41
  * A graph of all files and their dependencies.
48
42
  * For example:
@@ -66,12 +60,6 @@ export declare class Program {
66
60
  * Should only be set from `this.validate()`
67
61
  */
68
62
  private diagnostics;
69
- private fileSymbolInformation;
70
- addFileSymbolInfo(file: BrsFile): void;
71
- getFileSymbolInfo(file: BrsFile): {
72
- provides: ProvidedSymbolInfo;
73
- requires: UnresolvedSymbol[];
74
- };
75
63
  /**
76
64
  * The path to bslib.brs (the BrightScript runtime for certain BrighterScript features)
77
65
  */
@@ -80,17 +68,8 @@ export declare class Program {
80
68
  /**
81
69
  * A map of every file loaded into this program, indexed by its original file location
82
70
  */
83
- files: Record<string, File>;
84
- /**
85
- * A map of every file loaded into this program, indexed by its destPath
86
- */
87
- private destMap;
88
- /**
89
- * Plugins can contribute multiple virtual files for a single physical file.
90
- * This collection links the virtual files back to the physical file that produced them.
91
- * The key is the standardized and lower-cased srcPath
92
- */
93
- private fileClusters;
71
+ files: Record<string, BscFile>;
72
+ private pkgMap;
94
73
  private scopes;
95
74
  protected addScope(scope: Scope): void;
96
75
  /**
@@ -107,10 +86,6 @@ export declare class Program {
107
86
  file: XmlFile;
108
87
  scope: XmlScope;
109
88
  };
110
- /**
111
- * Keeps a set of all the components that need to have their types updated during the current validation cycle
112
- */
113
- private componentSymbolsToUpdate;
114
89
  /**
115
90
  * Register (or replace) the reference to a component in the component map
116
91
  */
@@ -119,18 +94,6 @@ export declare class Program {
119
94
  * Remove the specified component from the components map
120
95
  */
121
96
  private unregisterComponent;
122
- /**
123
- * Adds a component described in an XML to the set of components that needs to be updated this validation cycle.
124
- * @param xmlFile XML file with <component> tag
125
- */
126
- private addDeferredComponentTypeSymbolCreation;
127
- private getComponentKey;
128
- /**
129
- * Updates the global symbol table with the first component in this.components to have the same name as the component in the file
130
- * @param componentKey key getting a component from `this.components`
131
- * @param componentName the unprefixed name of the component that will be added (e.g. 'MyLabel' NOT 'roSgNodeMyLabel')
132
- */
133
- private updateComponentSymbolInGlobalScope;
134
97
  /**
135
98
  * re-attach the dependency graph with a new key for any component who changed
136
99
  * their position in their own named array (only matters when there are multiple
@@ -154,11 +117,11 @@ export declare class Program {
154
117
  * @param normalizePath should the provided path be normalized before use
155
118
  */
156
119
  hasFile(filePath: string, normalizePath?: boolean): boolean;
120
+ getPkgPath(...args: any[]): any;
157
121
  /**
158
122
  * roku filesystem is case INsensitive, so find the scope by key case insensitive
159
- * @param scopeName xml scope names are their `destPath`. Source scope is stored with the key `"source"`
160
123
  */
161
- getScopeByName(scopeName: string): Scope;
124
+ getScopeByName(scopeName: string): Scope | undefined;
162
125
  /**
163
126
  * Return all scopes
164
127
  */
@@ -175,21 +138,36 @@ export declare class Program {
175
138
  * Remove this file from internal maps
176
139
  */
177
140
  private unassignFile;
141
+ /**
142
+ * Load a file into the program. If that file already exists, it is replaced.
143
+ * If file contents are provided, those are used, Otherwise, the file is loaded from the file system
144
+ * @param srcPath the file path relative to the root dir
145
+ * @param fileContents the file contents
146
+ * @deprecated use `setFile` instead
147
+ */
148
+ addOrReplaceFile<T extends BscFile>(srcPath: string, fileContents: string): T;
149
+ /**
150
+ * Load a file into the program. If that file already exists, it is replaced.
151
+ * @param fileEntry an object that specifies src and dest for the file.
152
+ * @param fileContents the file contents. If not provided, the file will be loaded from disk
153
+ * @deprecated use `setFile` instead
154
+ */
155
+ addOrReplaceFile<T extends BscFile>(fileEntry: FileObj, fileContents: string): T;
178
156
  /**
179
157
  * Load a file into the program. If that file already exists, it is replaced.
180
158
  * If file contents are provided, those are used, Otherwise, the file is loaded from the file system
181
159
  * @param srcDestOrPkgPath the absolute path, the pkg path (i.e. `pkg:/path/to/file.brs`), or the destPath (i.e. `path/to/file.brs` relative to `pkg:/`)
182
- * @param fileData the file contents. omit or pass `undefined` to prevent loading the data at this time
160
+ * @param fileContents the file contents
183
161
  */
184
- setFile<T extends File>(srcDestOrPkgPath: string, fileData?: FileData): T;
162
+ setFile<T extends BscFile>(srcDestOrPkgPath: string, fileContents: string): T;
185
163
  /**
186
164
  * Load a file into the program. If that file already exists, it is replaced.
187
165
  * @param fileEntry an object that specifies src and dest for the file.
188
- * @param fileData the file contents. omit or pass `undefined` to prevent loading the data at this time
166
+ * @param fileContents the file contents. If not provided, the file will be loaded from disk
189
167
  */
190
- setFile<T extends File>(fileEntry: FileObj, fileData: FileData): T;
168
+ setFile<T extends BscFile>(fileEntry: FileObj, fileContents: string): T;
191
169
  /**
192
- * Given a srcPath, a destPath, or both, resolve whichever is missing, relative to rootDir.
170
+ * Given a srcPath, a pkgPath, or both, resolve whichever is missing, relative to rootDir.
193
171
  * @param fileParam an object representing file paths
194
172
  * @param rootDir must be a pre-normalized path
195
173
  */
@@ -199,18 +177,30 @@ export declare class Program {
199
177
  */
200
178
  private removePkgPrefix;
201
179
  /**
202
- * Is this file a .brs file found somewhere within the `pkg:/source/` folder?
180
+ * Ensure source scope is created.
181
+ * Note: automatically called internally, and no-op if it exists already.
203
182
  */
204
- private isSourceBrsFile;
183
+ createSourceScope(): void;
205
184
  /**
206
- * Is this file a .brs file found somewhere within the `pkg:/source/` folder?
185
+ * Find the file by its absolute path. This is case INSENSITIVE, since
186
+ * Roku is a case insensitive file system. It is an error to have multiple files
187
+ * with the same path with only case being different.
188
+ * @param srcPath the absolute path to the file
189
+ * @deprecated use `getFile` instead, which auto-detects the path type
207
190
  */
208
- private isComponentsXmlFile;
191
+ getFileByPathAbsolute<T extends BrsFile | XmlFile>(srcPath: string): T;
209
192
  /**
210
- * Ensure source scope is created.
211
- * Note: automatically called internally, and no-op if it exists already.
193
+ * Get a list of files for the given (platform-normalized) pkgPath array.
194
+ * Missing files are just ignored.
195
+ * @deprecated use `getFiles` instead, which auto-detects the path types
212
196
  */
213
- createSourceScope(): void;
197
+ getFilesByPkgPaths<T extends BscFile[]>(pkgPaths: string[]): T;
198
+ /**
199
+ * Get a file with the specified (platform-normalized) pkg path.
200
+ * If not found, return undefined
201
+ * @deprecated use `getFile` instead, which auto-detects the path type
202
+ */
203
+ getFileByPkgPath<T extends BscFile>(pkgPath: string): T;
214
204
  /**
215
205
  * Remove a set of files from the program
216
206
  * @param srcPaths can be an array of srcPath or destPath strings
@@ -219,29 +209,14 @@ export declare class Program {
219
209
  removeFiles(srcPaths: string[], normalizePath?: boolean): void;
220
210
  /**
221
211
  * Remove a file from the program
222
- * @param filePath can be a srcPath, a destPath, or a destPath with leading `pkg:/`
212
+ * @param filePath can be a srcPath, a pkgPath, or a destPath (same as pkgPath but without `pkg:/`)
223
213
  * @param normalizePath should this function repair and standardize the path? Passing false should have a performance boost if you can guarantee your path is already sanitized
224
214
  */
225
- removeFile(filePath: string, normalizePath?: boolean, keepSymbolInformation?: boolean): void;
226
- lastValidationInfo: Map<string, {
227
- symbolsNotDefinedInEveryScope: {
228
- symbol: UnresolvedSymbol;
229
- scope: Scope;
230
- }[];
231
- duplicateSymbolsInSameScope: {
232
- symbol: UnresolvedSymbol;
233
- scope: Scope;
234
- }[];
235
- symbolsNotConsistentAcrossScopes: {
236
- symbol: UnresolvedSymbol;
237
- scopes: Scope[];
238
- }[];
239
- }>;
215
+ removeFile(filePath: string, normalizePath?: boolean): void;
240
216
  /**
241
217
  * Traverse the entire project, and validate all scopes
242
218
  */
243
219
  validate(): void;
244
- private detectIncompatibleSymbolsAcrossScopes;
245
220
  /**
246
221
  * Flag all duplicate component names
247
222
  */
@@ -251,22 +226,22 @@ export declare class Program {
251
226
  * @param filePaths can be an array of srcPath or a destPath strings
252
227
  * @param normalizePath should this function repair and standardize the paths? Passing false should have a performance boost if you can guarantee your paths are already sanitized
253
228
  */
254
- getFiles<T extends File>(filePaths: string[], normalizePath?: boolean): T[];
229
+ getFiles<T extends BscFile>(filePaths: string[], normalizePath?: boolean): T[];
255
230
  /**
256
231
  * Get the file at the given path
257
232
  * @param filePath can be a srcPath or a destPath
258
233
  * @param normalizePath should this function repair and standardize the path? Passing false should have a performance boost if you can guarantee your path is already sanitized
259
234
  */
260
- getFile<T extends File>(filePath: string, normalizePath?: boolean): T;
235
+ getFile<T extends BscFile>(filePath: string, normalizePath?: boolean): T;
261
236
  /**
262
237
  * Get a list of all scopes the file is loaded into
263
238
  * @param file the file
264
239
  */
265
- getScopesForFile(file: File | string): Scope[];
240
+ getScopesForFile(file: XmlFile | BrsFile | string): Scope[];
266
241
  /**
267
242
  * Get the first found scope for a file.
268
243
  */
269
- getFirstScopeForFile(file: File): Scope;
244
+ getFirstScopeForFile(file: XmlFile | BrsFile): Scope | undefined;
270
245
  getStatementsByName(name: string, originFile: BrsFile, namespaceName?: string): FileLink<Statement>[];
271
246
  getStatementsForXmlFile(scope: XmlScope, filterName?: string): FileLink<FunctionStatement>[];
272
247
  /**
@@ -274,11 +249,11 @@ export declare class Program {
274
249
  * @param filePath can be a srcPath or a destPath
275
250
  * @param position the position (line & column) where completions should be found
276
251
  */
277
- getCompletions(filePath: string, position: Position): import("vscode-languageserver").CompletionItem[];
252
+ getCompletions(filePath: string, position: Position): CompletionItem[];
278
253
  /**
279
254
  * Goes through each file and builds a list of workspace symbols for the program. Used by LanguageServer's onWorkspaceSymbol functionality
280
255
  */
281
- getWorkspaceSymbols(): import("vscode-languageserver").SymbolInformation[];
256
+ getWorkspaceSymbols(): import("vscode-languageserver-types").WorkspaceSymbol[];
282
257
  /**
283
258
  * Given a position in a file, if the position is sitting on some type of identifier,
284
259
  * go to the definition of that identifier (where this thing was first defined)
@@ -288,6 +263,11 @@ export declare class Program {
288
263
  * Get hover information for a file and position
289
264
  */
290
265
  getHover(srcPath: string, position: Position): Hover[];
266
+ /**
267
+ * Get full list of document symbols for a file
268
+ * @param srcPath path to the file
269
+ */
270
+ getDocumentSymbols(srcPath: string): DocumentSymbol[] | undefined;
291
271
  /**
292
272
  * Compute code actions for the given file and range
293
273
  */
@@ -295,9 +275,14 @@ export declare class Program {
295
275
  /**
296
276
  * Get semantic tokens for the specified file
297
277
  */
298
- getSemanticTokens(srcPath: string): SemanticToken[];
278
+ getSemanticTokens(srcPath: string): SemanticToken[] | undefined;
299
279
  getSignatureHelp(filepath: string, position: Position): SignatureInfoObj[];
300
- getReferences(srcPath: string, position: Position): Location[] | Promise<Location[]>;
280
+ getReferences(srcPath: string, position: Position): Location[];
281
+ /**
282
+ * Get a list of all script imports, relative to the specified pkgPath
283
+ * @param sourcePkgPath - the pkgPath of the source that wants to resolve script imports.
284
+ */
285
+ getScriptImportCompletions(sourcePkgPath: string, scriptImport: FileReference): CompletionItem[];
301
286
  /**
302
287
  * Transpile a single file and get the result as a string.
303
288
  * This does not write anything to the file system.
@@ -307,64 +292,46 @@ export declare class Program {
307
292
  * @param filePath can be a srcPath or a destPath
308
293
  */
309
294
  getTranspiledFileContents(filePath: string): Promise<FileTranspileResult>;
310
- private getTranspiledFileContentsPipeline;
311
295
  /**
312
- * Get the absolute output path for a file
296
+ * Internal function used to transpile files.
297
+ * This does not write anything to the file system
313
298
  */
314
- private getOutputPath;
315
- private getStagingDir;
299
+ private _getTranspiledFileContents;
300
+ private beforeProgramTranspile;
301
+ transpile(fileEntries: FileObj[], stagingDir: string): Promise<void>;
302
+ private afterProgramTranspile;
316
303
  /**
317
- * Prepare the program for building
318
- * @param files the list of files that should be prepared
319
- */
320
- private prepare;
321
- /**
322
- * Generate the contents of every file
304
+ * Find a list of files in the program that have a function with the given name (case INsensitive)
323
305
  */
324
- private serialize;
306
+ findFilesForFunction(functionName: string): BscFile[];
325
307
  /**
326
- * Write the entire project to disk
308
+ * Find a list of files in the program that have a class with the given name (case INsensitive)
327
309
  */
328
- private write;
329
- private buildPipeline;
310
+ findFilesForClass(className: string): BscFile[];
311
+ findFilesForNamespace(name: string): BscFile[];
312
+ findFilesForEnum(name: string): BscFile[];
313
+ private _manifest;
330
314
  /**
331
- * Build the project. This transpiles/transforms/copies all files and moves them to the staging directory
332
- * @param options the list of options used to build the program
315
+ * Modify a parsed manifest map by reading `bs_const` and injecting values from `options.manifest.bs_const`
316
+ * @param parsedManifest The manifest map to read from and modify
333
317
  */
334
- build(options?: ProgramBuildOptions): Promise<void>;
318
+ private buildBsConstsIntoParsedManifest;
335
319
  /**
336
- * Find a list of files in the program that have a function with the given name (case INsensitive)
320
+ * Try to find and load the manifest into memory
321
+ * @param manifestFileObj A pointer to a potential manifest file object found during loading
322
+ * @param replaceIfAlreadyLoaded should we overwrite the internal `_manifest` if it already exists
337
323
  */
338
- findFilesForFunction(functionName: string): File[];
339
- /**
340
- * Find a list of files in the program that have a class with the given name (case INsensitive)
341
- */
342
- findFilesForClass(className: string): File[];
343
- findFilesForNamespace(name: string): File[];
344
- findFilesForEnum(name: string): File[];
324
+ loadManifest(manifestFileObj?: FileObj, replaceIfAlreadyLoaded?: boolean): void;
345
325
  /**
346
326
  * Get a map of the manifest information
347
327
  */
348
328
  getManifest(): Map<string, string>;
349
- private _manifest;
350
329
  dispose(): void;
351
330
  }
352
331
  export interface FileTranspileResult {
353
332
  srcPath: string;
354
- destPath: string;
355
333
  pkgPath: string;
356
334
  code: string;
357
- map: string;
335
+ map: SourceMapGenerator;
358
336
  typedef: string;
359
337
  }
360
- export interface ProgramBuildOptions {
361
- /**
362
- * The directory where the final built files should be placed. This directory will be cleared before running
363
- */
364
- stagingDir?: string;
365
- /**
366
- * An array of files to build. If omitted, the entire list of files from the program will be used instead.
367
- * Typically you will want to leave this blank
368
- */
369
- files?: File[];
370
- }