brighterscript 0.66.0-alpha.5 → 0.66.0-alpha.7

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 (298) hide show
  1. package/CHANGELOG.md +64 -10
  2. package/README.md +16 -0
  3. package/bsconfig.schema.json +15 -0
  4. package/dist/ActionPipeline.d.ts +10 -0
  5. package/dist/ActionPipeline.js +40 -0
  6. package/dist/ActionPipeline.js.map +1 -0
  7. package/dist/BsConfig.d.ts +15 -1
  8. package/dist/CommentFlagProcessor.d.ts +4 -3
  9. package/dist/CommentFlagProcessor.js.map +1 -1
  10. package/dist/DiagnosticMessages.d.ts +19 -4
  11. package/dist/DiagnosticMessages.js +45 -5
  12. package/dist/DiagnosticMessages.js.map +1 -1
  13. package/dist/LanguageServer.js.map +1 -1
  14. package/dist/PluginInterface.d.ts +11 -2
  15. package/dist/PluginInterface.js +69 -10
  16. package/dist/PluginInterface.js.map +1 -1
  17. package/dist/Program.d.ts +101 -37
  18. package/dist/Program.js +492 -274
  19. package/dist/Program.js.map +1 -1
  20. package/dist/ProgramBuilder.d.ts +10 -4
  21. package/dist/ProgramBuilder.js +44 -54
  22. package/dist/ProgramBuilder.js.map +1 -1
  23. package/dist/Scope.d.ts +27 -13
  24. package/dist/Scope.js +44 -26
  25. package/dist/Scope.js.map +1 -1
  26. package/dist/SymbolTable.d.ts +5 -0
  27. package/dist/SymbolTable.js +15 -2
  28. package/dist/SymbolTable.js.map +1 -1
  29. package/dist/XmlScope.d.ts +7 -4
  30. package/dist/XmlScope.js +47 -8
  31. package/dist/XmlScope.js.map +1 -1
  32. package/dist/astUtils/{AstEditor.d.ts → Editor.d.ts} +6 -1
  33. package/dist/astUtils/{AstEditor.js → Editor.js} +9 -3
  34. package/dist/astUtils/Editor.js.map +1 -0
  35. package/dist/astUtils/{AstEditor.spec.js → Editor.spec.js} +10 -6
  36. package/dist/astUtils/Editor.spec.js.map +1 -0
  37. package/dist/astUtils/creators.d.ts +3 -1
  38. package/dist/astUtils/creators.js +9 -1
  39. package/dist/astUtils/creators.js.map +1 -1
  40. package/dist/astUtils/reflection.d.ts +30 -8
  41. package/dist/astUtils/reflection.js +64 -14
  42. package/dist/astUtils/reflection.js.map +1 -1
  43. package/dist/astUtils/reflection.spec.js +85 -4
  44. package/dist/astUtils/reflection.spec.js.map +1 -1
  45. package/dist/astUtils/visitors.d.ts +3 -3
  46. package/dist/astUtils/visitors.spec.js +7 -7
  47. package/dist/astUtils/visitors.spec.js.map +1 -1
  48. package/dist/bscPlugin/BscPlugin.d.ts +10 -2
  49. package/dist/bscPlugin/BscPlugin.js +24 -4
  50. package/dist/bscPlugin/BscPlugin.js.map +1 -1
  51. package/dist/bscPlugin/FileWriter.d.ts +6 -0
  52. package/dist/bscPlugin/FileWriter.js +24 -0
  53. package/dist/bscPlugin/FileWriter.js.map +1 -0
  54. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +8 -8
  55. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  56. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +4 -4
  57. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
  58. package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +11 -1
  59. package/dist/bscPlugin/completions/CompletionsProcessor.js +112 -58
  60. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
  61. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +151 -6
  62. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -1
  63. package/dist/bscPlugin/fileProviders/FileProvider.d.ts +9 -0
  64. package/dist/bscPlugin/fileProviders/FileProvider.js +51 -0
  65. package/dist/bscPlugin/fileProviders/FileProvider.js.map +1 -0
  66. package/dist/bscPlugin/hover/HoverProcessor.d.ts +1 -7
  67. package/dist/bscPlugin/hover/HoverProcessor.js +2 -8
  68. package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
  69. package/dist/bscPlugin/hover/HoverProcessor.spec.js +55 -0
  70. package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
  71. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +1 -0
  72. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +43 -0
  73. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
  74. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +22 -0
  75. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -1
  76. package/dist/bscPlugin/serialize/BslibInjector.spec.js +19 -0
  77. package/dist/bscPlugin/serialize/BslibInjector.spec.js.map +1 -0
  78. package/dist/bscPlugin/serialize/BslibManager.d.ts +9 -0
  79. package/dist/bscPlugin/serialize/BslibManager.js +40 -0
  80. package/dist/bscPlugin/serialize/BslibManager.js.map +1 -0
  81. package/dist/bscPlugin/serialize/FileSerializer.d.ts +9 -0
  82. package/dist/bscPlugin/serialize/FileSerializer.js +72 -0
  83. package/dist/bscPlugin/serialize/FileSerializer.js.map +1 -0
  84. package/dist/bscPlugin/transpile/{BrsFilePreTranspileProcessor.d.ts → BrsFileTranspileProcessor.d.ts} +4 -2
  85. package/dist/bscPlugin/transpile/{BrsFilePreTranspileProcessor.js → BrsFileTranspileProcessor.js} +25 -4
  86. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -0
  87. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.d.ts +1 -0
  88. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js +41 -0
  89. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +1 -0
  90. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +2 -2
  91. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +1 -1
  92. package/dist/bscPlugin/validation/BrsFileValidator.js +2 -1
  93. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
  94. package/dist/bscPlugin/validation/ScopeValidator.d.ts +12 -0
  95. package/dist/bscPlugin/validation/ScopeValidator.js +137 -19
  96. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
  97. package/dist/bscPlugin/validation/ScopeValidator.spec.js +671 -1
  98. package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -1
  99. package/dist/bscPlugin/validation/XmlFileValidator.js +2 -2
  100. package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -1
  101. package/dist/cli.js +1 -0
  102. package/dist/cli.js.map +1 -1
  103. package/dist/deferred.d.ts +2 -2
  104. package/dist/deferred.js.map +1 -1
  105. package/dist/diagnosticUtils.d.ts +1 -0
  106. package/dist/diagnosticUtils.js +4 -3
  107. package/dist/diagnosticUtils.js.map +1 -1
  108. package/dist/examples/plugins/removePrint.js +1 -1
  109. package/dist/examples/plugins/removePrint.js.map +1 -1
  110. package/dist/files/AssetFile.d.ts +26 -0
  111. package/dist/files/AssetFile.js +26 -0
  112. package/dist/files/AssetFile.js.map +1 -0
  113. package/dist/files/BrsFile.Class.spec.js +40 -40
  114. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  115. package/dist/files/BrsFile.d.ts +42 -15
  116. package/dist/files/BrsFile.js +120 -78
  117. package/dist/files/BrsFile.js.map +1 -1
  118. package/dist/files/BrsFile.spec.js +266 -167
  119. package/dist/files/BrsFile.spec.js.map +1 -1
  120. package/dist/files/Factory.d.ts +25 -0
  121. package/dist/files/Factory.js +22 -0
  122. package/dist/files/Factory.js.map +1 -0
  123. package/dist/files/File.d.ts +106 -0
  124. package/dist/files/File.js +16 -0
  125. package/dist/files/File.js.map +1 -0
  126. package/dist/files/LazyFileData.d.ts +20 -0
  127. package/dist/files/LazyFileData.js +54 -0
  128. package/dist/files/LazyFileData.js.map +1 -0
  129. package/dist/files/LazyFileData.spec.d.ts +1 -0
  130. package/dist/files/LazyFileData.spec.js +27 -0
  131. package/dist/files/LazyFileData.spec.js.map +1 -0
  132. package/dist/files/XmlFile.d.ts +55 -17
  133. package/dist/files/XmlFile.js +88 -47
  134. package/dist/files/XmlFile.js.map +1 -1
  135. package/dist/files/XmlFile.spec.js +64 -57
  136. package/dist/files/XmlFile.spec.js.map +1 -1
  137. package/dist/files/tests/imports.spec.js +21 -8
  138. package/dist/files/tests/imports.spec.js.map +1 -1
  139. package/dist/files/tests/optionalChaning.spec.js +14 -14
  140. package/dist/files/tests/optionalChaning.spec.js.map +1 -1
  141. package/dist/globalCallables.js +2 -6
  142. package/dist/globalCallables.js.map +1 -1
  143. package/dist/index.d.ts +4 -1
  144. package/dist/index.js +4 -1
  145. package/dist/index.js.map +1 -1
  146. package/dist/interfaces.d.ts +326 -85
  147. package/dist/interfaces.js +4 -1
  148. package/dist/interfaces.js.map +1 -1
  149. package/dist/lexer/Lexer.js +1 -1
  150. package/dist/lexer/TokenKind.js +0 -1
  151. package/dist/lexer/TokenKind.js.map +1 -1
  152. package/dist/parser/AstNode.d.ts +2 -2
  153. package/dist/parser/AstNode.js +1 -1
  154. package/dist/parser/AstNode.js.map +1 -1
  155. package/dist/parser/BrsTranspileState.d.ts +3 -2
  156. package/dist/parser/BrsTranspileState.js +3 -2
  157. package/dist/parser/BrsTranspileState.js.map +1 -1
  158. package/dist/parser/Expression.d.ts +1 -1
  159. package/dist/parser/Expression.js +35 -19
  160. package/dist/parser/Expression.js.map +1 -1
  161. package/dist/parser/Parser.js +12 -1
  162. package/dist/parser/Parser.js.map +1 -1
  163. package/dist/parser/Parser.spec.js +18 -2
  164. package/dist/parser/Parser.spec.js.map +1 -1
  165. package/dist/parser/SGParser.d.ts +2 -2
  166. package/dist/parser/SGParser.js +3 -3
  167. package/dist/parser/SGParser.js.map +1 -1
  168. package/dist/parser/SGParser.spec.js +2 -2
  169. package/dist/parser/SGParser.spec.js.map +1 -1
  170. package/dist/parser/SGTypes.d.ts +1 -1
  171. package/dist/parser/Statement.js +1 -1
  172. package/dist/parser/Statement.js.map +1 -1
  173. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +10 -10
  174. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
  175. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +10 -10
  176. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -1
  177. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +24 -24
  178. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +1 -1
  179. package/dist/parser/tests/expression/TemplateStringExpression.spec.js +64 -36
  180. package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
  181. package/dist/parser/tests/expression/TernaryExpression.spec.js +34 -34
  182. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
  183. package/dist/parser/tests/statement/ConstStatement.spec.js +17 -17
  184. package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -1
  185. package/dist/parser/tests/statement/Continue.spec.js +2 -2
  186. package/dist/parser/tests/statement/Continue.spec.js.map +1 -1
  187. package/dist/parser/tests/statement/Enum.spec.js +26 -26
  188. package/dist/parser/tests/statement/Enum.spec.js.map +1 -1
  189. package/dist/parser/tests/statement/For.spec.js +6 -6
  190. package/dist/parser/tests/statement/For.spec.js.map +1 -1
  191. package/dist/parser/tests/statement/ForEach.spec.js +4 -4
  192. package/dist/parser/tests/statement/ForEach.spec.js.map +1 -1
  193. package/dist/parser/tests/statement/InterfaceStatement.spec.js +18 -10
  194. package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
  195. package/dist/parser/tests/statement/PrintStatement.spec.js +10 -10
  196. package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
  197. package/dist/preprocessor/Manifest.d.ts +1 -1
  198. package/dist/preprocessor/Manifest.js +2 -2
  199. package/dist/preprocessor/Manifest.js.map +1 -1
  200. package/dist/roku-types/data.json +111 -149
  201. package/dist/roku-types/index.d.ts +27 -13
  202. package/dist/types/ArrayType.d.ts +2 -1
  203. package/dist/types/ArrayType.js +6 -2
  204. package/dist/types/ArrayType.js.map +1 -1
  205. package/dist/types/ArrayType.spec.js +11 -1
  206. package/dist/types/ArrayType.spec.js.map +1 -1
  207. package/dist/types/AssociativeArrayType.d.ts +11 -0
  208. package/dist/types/AssociativeArrayType.js +52 -0
  209. package/dist/types/AssociativeArrayType.js.map +1 -0
  210. package/dist/types/BaseFunctionType.d.ts +2 -1
  211. package/dist/types/BaseFunctionType.js +1 -1
  212. package/dist/types/BaseFunctionType.js.map +1 -1
  213. package/dist/types/BooleanType.d.ts +2 -1
  214. package/dist/types/BooleanType.js +3 -2
  215. package/dist/types/BooleanType.js.map +1 -1
  216. package/dist/types/BscType.d.ts +3 -3
  217. package/dist/types/BscType.js +26 -12
  218. package/dist/types/BscType.js.map +1 -1
  219. package/dist/types/BscTypeKind.d.ts +2 -0
  220. package/dist/types/BscTypeKind.js +2 -0
  221. package/dist/types/BscTypeKind.js.map +1 -1
  222. package/dist/types/BuiltInInterfaceAdder.d.ts +8 -0
  223. package/dist/types/BuiltInInterfaceAdder.js +88 -23
  224. package/dist/types/BuiltInInterfaceAdder.js.map +1 -1
  225. package/dist/types/ClassType.d.ts +2 -1
  226. package/dist/types/ClassType.js +2 -2
  227. package/dist/types/ClassType.js.map +1 -1
  228. package/dist/types/ComponentType.d.ts +26 -0
  229. package/dist/types/ComponentType.js +83 -0
  230. package/dist/types/ComponentType.js.map +1 -0
  231. package/dist/types/DoubleType.d.ts +2 -1
  232. package/dist/types/DoubleType.js +4 -2
  233. package/dist/types/DoubleType.js.map +1 -1
  234. package/dist/types/DynamicType.d.ts +2 -2
  235. package/dist/types/DynamicType.js +1 -1
  236. package/dist/types/DynamicType.js.map +1 -1
  237. package/dist/types/EnumType.d.ts +3 -2
  238. package/dist/types/EnumType.js +3 -3
  239. package/dist/types/EnumType.js.map +1 -1
  240. package/dist/types/FloatType.d.ts +2 -1
  241. package/dist/types/FloatType.js +4 -2
  242. package/dist/types/FloatType.js.map +1 -1
  243. package/dist/types/FunctionType.d.ts +2 -1
  244. package/dist/types/FunctionType.js +2 -2
  245. package/dist/types/FunctionType.js.map +1 -1
  246. package/dist/types/IntegerType.d.ts +2 -1
  247. package/dist/types/IntegerType.js +4 -2
  248. package/dist/types/IntegerType.js.map +1 -1
  249. package/dist/types/InterfaceType.d.ts +2 -1
  250. package/dist/types/InterfaceType.js +3 -7
  251. package/dist/types/InterfaceType.js.map +1 -1
  252. package/dist/types/InterfaceType.spec.js +25 -2
  253. package/dist/types/InterfaceType.spec.js.map +1 -1
  254. package/dist/types/LongIntegerType.d.ts +2 -1
  255. package/dist/types/LongIntegerType.js +4 -2
  256. package/dist/types/LongIntegerType.js.map +1 -1
  257. package/dist/types/ObjectType.d.ts +2 -2
  258. package/dist/types/ObjectType.js +1 -1
  259. package/dist/types/ObjectType.js.map +1 -1
  260. package/dist/types/ReferenceType.d.ts +2 -0
  261. package/dist/types/ReferenceType.js +45 -1
  262. package/dist/types/ReferenceType.js.map +1 -1
  263. package/dist/types/StringType.d.ts +2 -1
  264. package/dist/types/StringType.js +4 -4
  265. package/dist/types/StringType.js.map +1 -1
  266. package/dist/types/TypedFunctionType.d.ts +7 -1
  267. package/dist/types/TypedFunctionType.js +47 -17
  268. package/dist/types/TypedFunctionType.js.map +1 -1
  269. package/dist/types/TypedFunctionType.spec.js +99 -0
  270. package/dist/types/TypedFunctionType.spec.js.map +1 -1
  271. package/dist/types/UninitializedType.d.ts +2 -1
  272. package/dist/types/UninitializedType.js +1 -1
  273. package/dist/types/UninitializedType.js.map +1 -1
  274. package/dist/types/UnionType.d.ts +2 -2
  275. package/dist/types/UnionType.js +10 -3
  276. package/dist/types/UnionType.js.map +1 -1
  277. package/dist/types/UnionType.spec.js +3 -2
  278. package/dist/types/UnionType.spec.js.map +1 -1
  279. package/dist/types/VoidType.d.ts +2 -1
  280. package/dist/types/VoidType.js +2 -2
  281. package/dist/types/VoidType.js.map +1 -1
  282. package/dist/types/helper.spec.js +15 -0
  283. package/dist/types/helper.spec.js.map +1 -1
  284. package/dist/types/helpers.d.ts +5 -1
  285. package/dist/types/helpers.js +31 -3
  286. package/dist/types/helpers.js.map +1 -1
  287. package/dist/util.d.ts +26 -6
  288. package/dist/util.js +181 -52
  289. package/dist/util.js.map +1 -1
  290. package/dist/validators/ClassValidator.js.map +1 -1
  291. package/package.json +1 -1
  292. package/dist/astUtils/AstEditor.js.map +0 -1
  293. package/dist/astUtils/AstEditor.spec.js.map +0 -1
  294. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +0 -1
  295. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js +0 -31
  296. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js.map +0 -1
  297. /package/dist/astUtils/{AstEditor.spec.d.ts → Editor.spec.d.ts} +0 -0
  298. /package/dist/bscPlugin/{transpile/BrsFilePreTranspileProcessor.spec.d.ts → serialize/BslibInjector.spec.d.ts} +0 -0
@@ -15,10 +15,8 @@ const Lexer_1 = require("../lexer/Lexer");
15
15
  const TokenKind_1 = require("../lexer/TokenKind");
16
16
  const DiagnosticMessages_1 = require("../DiagnosticMessages");
17
17
  const util_1 = require("../util");
18
- const PluginInterface_1 = require("../PluginInterface");
19
18
  const testHelpers_spec_1 = require("../testHelpers.spec");
20
19
  const Parser_1 = require("../parser/Parser");
21
- const Logger_1 = require("../Logger");
22
20
  const Statement_1 = require("../parser/Statement");
23
21
  const creators_1 = require("../astUtils/creators");
24
22
  const fsExtra = require("fs-extra");
@@ -36,12 +34,41 @@ describe('BrsFile', () => {
36
34
  beforeEach(() => {
37
35
  fsExtra.emptyDirSync(testHelpers_spec_2.tempDir);
38
36
  program = new Program_1.Program({ rootDir: testHelpers_spec_2.rootDir, sourceMap: true });
39
- file = new BrsFile_1.BrsFile(srcPath, destPath, program);
37
+ file = new BrsFile_1.BrsFile({
38
+ srcPath: srcPath,
39
+ destPath: destPath,
40
+ program: program
41
+ });
40
42
  });
41
43
  afterEach(() => {
42
44
  sinon.restore();
43
45
  program.dispose();
44
46
  });
47
+ describe('constructor', () => {
48
+ it('calculates correct paths when no pkgPath specified', () => {
49
+ (0, chai_config_spec_1.expect)(new BrsFile_1.BrsFile({
50
+ srcPath: (0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/source/main.bs`,
51
+ destPath: (0, util_1.standardizePath) `source/main.bs`,
52
+ program: program
53
+ })).to.include({
54
+ srcPath: (0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/source/main.bs`,
55
+ destPath: (0, util_1.standardizePath) `source/main.bs`,
56
+ pkgPath: (0, util_1.standardizePath) `source/main.brs`
57
+ });
58
+ });
59
+ it('uses supplied pkgPath', () => {
60
+ (0, chai_config_spec_1.expect)(new BrsFile_1.BrsFile({
61
+ srcPath: (0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/source/main.bs`,
62
+ destPath: (0, util_1.standardizePath) `source/main.bs`,
63
+ pkgPath: (0, util_1.standardizePath) `source/main.transpiled.brs`,
64
+ program: program
65
+ })).to.include({
66
+ srcPath: (0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/source/main.bs`,
67
+ destPath: (0, util_1.standardizePath) `source/main.bs`,
68
+ pkgPath: (0, util_1.standardizePath) `source/main.transpiled.brs`
69
+ });
70
+ });
71
+ });
45
72
  describe('allowBrighterScriptInBrightScript', () => {
46
73
  it('is false by default', () => {
47
74
  program.setFile('source/main.brs', `
@@ -125,9 +152,17 @@ describe('BrsFile', () => {
125
152
  });
126
153
  it('sets needsTranspiled to true for .bs files', () => {
127
154
  //BrightScript
128
- (0, chai_config_spec_1.expect)(new BrsFile_1.BrsFile(`${testHelpers_spec_2.rootDir}/source/main.brs`, 'source/main.brs', program).needsTranspiled).to.be.false;
155
+ (0, chai_config_spec_1.expect)(new BrsFile_1.BrsFile({
156
+ srcPath: `${testHelpers_spec_2.rootDir}/source/main.brs`,
157
+ destPath: 'source/main.brs',
158
+ program: program
159
+ })['needsTranspiled']).to.be.false;
129
160
  //BrighterScript
130
- (0, chai_config_spec_1.expect)(new BrsFile_1.BrsFile(`${testHelpers_spec_2.rootDir}/source/main.bs`, 'source/main.bs', program).needsTranspiled).to.be.true;
161
+ (0, chai_config_spec_1.expect)(new BrsFile_1.BrsFile({
162
+ srcPath: `${testHelpers_spec_2.rootDir}/source/main.bs`,
163
+ destPath: 'source/main.bs',
164
+ program: program
165
+ })['needsTranspiled']).to.be.true;
131
166
  });
132
167
  it('computes new import statements after clearing parser references', () => {
133
168
  const file = program.setFile('source/main.bs', ``);
@@ -235,12 +270,12 @@ describe('BrsFile', () => {
235
270
  something = true 'bs:disable-line: LINT1005
236
271
  end sub
237
272
  `);
238
- file.addDiagnostics([{
239
- code: 'LINT1005',
240
- file: file,
241
- message: 'Something is not right',
242
- range: util_1.default.createRange(2, 16, 2, 26)
243
- }]);
273
+ file.diagnostics.push({
274
+ code: 'LINT1005',
275
+ file: file,
276
+ message: 'Something is not right',
277
+ range: util_1.default.createRange(2, 16, 2, 26)
278
+ });
244
279
  const scope = program.getScopesForFile(file)[0];
245
280
  (0, testHelpers_spec_1.expectZeroDiagnostics)(scope);
246
281
  });
@@ -925,7 +960,11 @@ describe('BrsFile', () => {
925
960
  `);
926
961
  });
927
962
  it('finds line and column numbers for functions', () => {
928
- let file = new BrsFile_1.BrsFile('absolute_path/file.brs', 'relative_path/file.brs', program);
963
+ let file = new BrsFile_1.BrsFile({
964
+ srcPath: 'absolute_path/file.brs',
965
+ destPath: 'relative_path/file.brs',
966
+ program: program
967
+ });
929
968
  file.parse(`
930
969
  function DoA()
931
970
  print "A"
@@ -941,7 +980,11 @@ describe('BrsFile', () => {
941
980
  (0, chai_config_spec_1.expect)(file.callables[1].nameRange).to.eql(vscode_languageserver_1.Range.create(5, 26, 5, 29));
942
981
  });
943
982
  it('throws an error if the file has already been parsed', () => {
944
- let file = new BrsFile_1.BrsFile('abspath', 'relpath', program);
983
+ let file = new BrsFile_1.BrsFile({
984
+ srcPath: 'abspath',
985
+ destPath: 'relpath',
986
+ program: program
987
+ });
945
988
  file.parse(`'a comment`);
946
989
  try {
947
990
  file.parse(`'a new comment`);
@@ -952,7 +995,11 @@ describe('BrsFile', () => {
952
995
  }
953
996
  });
954
997
  it('finds and registers duplicate callables', () => {
955
- let file = new BrsFile_1.BrsFile('absolute_path/file.brs', 'relative_path/file.brs', program);
998
+ let file = new BrsFile_1.BrsFile({
999
+ srcPath: 'absolute_path/file.brs',
1000
+ destPath: 'relative_path/file.brs',
1001
+ program: program
1002
+ });
956
1003
  file.parse(`
957
1004
  function DoA()
958
1005
  print "A"
@@ -969,7 +1016,11 @@ describe('BrsFile', () => {
969
1016
  (0, chai_config_spec_1.expect)(file.callables[1].nameRange.start.line).to.equal(5);
970
1017
  });
971
1018
  it('finds function call line and column numbers', () => {
972
- let file = new BrsFile_1.BrsFile('absolute_path/file.brs', 'relative_path/file.brs', program);
1019
+ let file = new BrsFile_1.BrsFile({
1020
+ srcPath: 'absolute_path/file.brs',
1021
+ destPath: 'relative_path/file.brs',
1022
+ program: program
1023
+ });
973
1024
  file.parse(`
974
1025
  function DoA()
975
1026
  DoB("a")
@@ -985,7 +1036,11 @@ describe('BrsFile', () => {
985
1036
  (0, chai_config_spec_1.expect)(file.functionCalls[1].nameRange).to.eql(vscode_languageserver_1.Range.create(5, 20, 5, 23));
986
1037
  });
987
1038
  it('finds function calls that are unfinished', () => {
988
- let file = new BrsFile_1.BrsFile('absolute_path/file.brs', 'relative_path/file.brs', program);
1039
+ let file = new BrsFile_1.BrsFile({
1040
+ srcPath: 'absolute_path/file.brs',
1041
+ destPath: 'relative_path/file.brs',
1042
+ program: program
1043
+ });
989
1044
  file.parse(`
990
1045
  function DoA()
991
1046
  DoB("a"
@@ -1008,7 +1063,11 @@ describe('BrsFile', () => {
1008
1063
  (0, chai_config_spec_1.expect)(file.functionCalls[1].nameRange).to.eql(vscode_languageserver_1.Range.create(5, 20, 5, 23));
1009
1064
  });
1010
1065
  it('sanitizes brs errors', () => {
1011
- let file = new BrsFile_1.BrsFile('absolute_path/file.brs', 'relative_path/file.brs', program);
1066
+ let file = new BrsFile_1.BrsFile({
1067
+ srcPath: 'absolute_path/file.brs',
1068
+ destPath: 'relative_path/file.brs',
1069
+ program: program
1070
+ });
1012
1071
  file.parse(`
1013
1072
  function DoSomething
1014
1073
  end function
@@ -1018,7 +1077,11 @@ describe('BrsFile', () => {
1018
1077
  (0, chai_config_spec_1.expect)(file.getDiagnostics()[0].range.start.line).to.equal(1);
1019
1078
  });
1020
1079
  it('supports using the `next` keyword in a for loop', () => {
1021
- let file = new BrsFile_1.BrsFile('absolute_path/file.brs', 'relative_path/file.brs', program);
1080
+ let file = new BrsFile_1.BrsFile({
1081
+ srcPath: 'absolute_path/file.brs',
1082
+ destPath: 'relative_path/file.brs',
1083
+ program: program
1084
+ });
1022
1085
  file.parse(`
1023
1086
  sub countit()
1024
1087
  for each num in [1,2,3]
@@ -1030,7 +1093,11 @@ describe('BrsFile', () => {
1030
1093
  });
1031
1094
  //test is not working yet, but will be enabled when brs supports this syntax
1032
1095
  it('supports assigning functions to objects', () => {
1033
- let file = new BrsFile_1.BrsFile('absolute_path/file.brs', 'relative_path/file.brs', program);
1096
+ let file = new BrsFile_1.BrsFile({
1097
+ srcPath: 'absolute_path/file.brs',
1098
+ destPath: 'relative_path/file.brs',
1099
+ program: program
1100
+ });
1034
1101
  file.parse(`
1035
1102
  function main()
1036
1103
  o = CreateObject("roAssociativeArray")
@@ -1058,7 +1125,11 @@ describe('BrsFile', () => {
1058
1125
  });
1059
1126
  describe('findCallables', () => {
1060
1127
  it('finds range', () => {
1061
- let file = new BrsFile_1.BrsFile('absolute_path/file.brs', 'relative_path/file.brs', program);
1128
+ let file = new BrsFile_1.BrsFile({
1129
+ srcPath: 'absolute_path/file.brs',
1130
+ destPath: 'relative_path/file.brs',
1131
+ program: program
1132
+ });
1062
1133
  file.parse(`
1063
1134
  sub Sum()
1064
1135
  print "hello world"
@@ -1068,7 +1139,11 @@ describe('BrsFile', () => {
1068
1139
  (0, chai_config_spec_1.expect)(callable.range).to.eql(vscode_languageserver_1.Range.create(1, 16, 3, 23));
1069
1140
  });
1070
1141
  it('finds correct body range even with inner function', () => {
1071
- let file = new BrsFile_1.BrsFile('absolute_path/file.brs', 'relative_path/file.brs', program);
1142
+ let file = new BrsFile_1.BrsFile({
1143
+ srcPath: 'absolute_path/file.brs',
1144
+ destPath: 'relative_path/file.brs',
1145
+ program: program
1146
+ });
1072
1147
  file.parse(`
1073
1148
  sub Sum()
1074
1149
  sayHi = sub()
@@ -1081,7 +1156,11 @@ describe('BrsFile', () => {
1081
1156
  (0, chai_config_spec_1.expect)(callable.range).to.eql(vscode_languageserver_1.Range.create(1, 16, 6, 23));
1082
1157
  });
1083
1158
  it('finds callable parameters', () => {
1084
- let file = new BrsFile_1.BrsFile('absolute_path/file.brs', 'relative_path/file.brs', program);
1159
+ let file = new BrsFile_1.BrsFile({
1160
+ srcPath: 'absolute_path/file.brs',
1161
+ destPath: 'relative_path/file.brs',
1162
+ program: program
1163
+ });
1085
1164
  file.parse(`
1086
1165
  function Sum(a, b, c)
1087
1166
 
@@ -1108,7 +1187,11 @@ describe('BrsFile', () => {
1108
1187
  (0, chai_config_spec_1.expect)(callable.params[2].type).instanceof(DynamicType_1.DynamicType);
1109
1188
  });
1110
1189
  it('finds optional parameters', () => {
1111
- let file = new BrsFile_1.BrsFile('absolute_path/file.brs', 'relative_path/file.brs', program);
1190
+ let file = new BrsFile_1.BrsFile({
1191
+ srcPath: 'absolute_path/file.brs',
1192
+ destPath: 'relative_path/file.brs',
1193
+ program: program
1194
+ });
1112
1195
  file.parse(`
1113
1196
  function Sum(a=2)
1114
1197
 
@@ -1123,7 +1206,11 @@ describe('BrsFile', () => {
1123
1206
  (0, chai_config_spec_1.expect)(callable.params[0].type).instanceof(IntegerType_1.IntegerType);
1124
1207
  });
1125
1208
  it('finds parameter types', () => {
1126
- let file = new BrsFile_1.BrsFile('absolute_path/file.brs', 'relative_path/file.brs', program);
1209
+ let file = new BrsFile_1.BrsFile({
1210
+ srcPath: 'absolute_path/file.brs',
1211
+ destPath: 'relative_path/file.brs',
1212
+ program: program
1213
+ });
1127
1214
  file.parse(`
1128
1215
  function Sum(a, b as integer, c as string)
1129
1216
 
@@ -1152,7 +1239,11 @@ describe('BrsFile', () => {
1152
1239
  });
1153
1240
  describe('findCallableInvocations', () => {
1154
1241
  it('finds arguments with literal values', () => {
1155
- let file = new BrsFile_1.BrsFile('absolute_path/file.brs', 'relative_path/file.brs', program);
1242
+ let file = new BrsFile_1.BrsFile({
1243
+ srcPath: 'absolute_path/file.brs',
1244
+ destPath: 'relative_path/file.brs',
1245
+ program: program
1246
+ });
1156
1247
  file.parse(`
1157
1248
  function Sum()
1158
1249
  DoSomething("name", 12, true)
@@ -1191,7 +1282,11 @@ describe('BrsFile', () => {
1191
1282
  ]);
1192
1283
  });
1193
1284
  it('finds arguments with variable values', () => {
1194
- let file = new BrsFile_1.BrsFile('absolute_path/file.brs', 'relative_path/file.brs', program);
1285
+ let file = new BrsFile_1.BrsFile({
1286
+ srcPath: 'absolute_path/file.brs',
1287
+ destPath: 'relative_path/file.brs',
1288
+ program: program
1289
+ });
1195
1290
  file.parse(`
1196
1291
  function Sum()
1197
1292
  count = 1
@@ -1218,7 +1313,11 @@ describe('BrsFile', () => {
1218
1313
  describe('findCallables', () => {
1219
1314
  //this test is to help with code coverage
1220
1315
  it('skips top-level statements', () => {
1221
- let file = new BrsFile_1.BrsFile('absolute', 'relative', program);
1316
+ let file = new BrsFile_1.BrsFile({
1317
+ srcPath: 'absolute',
1318
+ destPath: 'relative',
1319
+ program: program
1320
+ });
1222
1321
  file.parse('name = "Bob"');
1223
1322
  (0, chai_config_spec_1.expect)(file.callables.length).to.equal(0);
1224
1323
  });
@@ -1373,7 +1472,7 @@ describe('BrsFile', () => {
1373
1472
  end if
1374
1473
  end sub
1375
1474
  `);
1376
- (0, chai_config_spec_1.expect)(mainFile.getDiagnostics()).to.be.lengthOf(0);
1475
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(mainFile);
1377
1476
  mainFile = program.setFile('source/main.brs', `
1378
1477
  sub Main()
1379
1478
  if true Then
@@ -1381,7 +1480,7 @@ describe('BrsFile', () => {
1381
1480
  end if
1382
1481
  end sub
1383
1482
  `);
1384
- (0, chai_config_spec_1.expect)(mainFile.getDiagnostics()).to.be.lengthOf(0);
1483
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(mainFile);
1385
1484
  mainFile = program.setFile('source/main.brs', `
1386
1485
  sub Main()
1387
1486
  if true THEN
@@ -1389,7 +1488,7 @@ describe('BrsFile', () => {
1389
1488
  end if
1390
1489
  end sub
1391
1490
  `);
1392
- (0, chai_config_spec_1.expect)(mainFile.getDiagnostics()).to.be.lengthOf(0);
1491
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(mainFile);
1393
1492
  });
1394
1493
  it('does not throw when encountering incomplete import statement', () => {
1395
1494
  program.setFile('source/main.brs', `
@@ -1401,8 +1500,8 @@ describe('BrsFile', () => {
1401
1500
  //this test will throw an exception if something went wrong
1402
1501
  });
1403
1502
  describe('transpile', () => {
1404
- it('excludes trailing commas in array literals', () => {
1405
- testTranspile(`
1503
+ it('excludes trailing commas in array literals', async () => {
1504
+ await testTranspile(`
1406
1505
  sub main()
1407
1506
  arr = [
1408
1507
  1,
@@ -1430,7 +1529,7 @@ describe('BrsFile', () => {
1430
1529
  end sub
1431
1530
  `);
1432
1531
  });
1433
- it('transpiles if statement keywords as provided', () => {
1532
+ it('transpiles if statement keywords as provided', async () => {
1434
1533
  const code = `
1435
1534
  sub main()
1436
1535
  If True Then
@@ -1444,12 +1543,12 @@ describe('BrsFile', () => {
1444
1543
  End If
1445
1544
  end sub
1446
1545
  `;
1447
- testTranspile(code);
1448
- testTranspile(code.toLowerCase());
1449
- testTranspile(code.toUpperCase());
1546
+ await testTranspile(code);
1547
+ await testTranspile(code.toLowerCase());
1548
+ await testTranspile(code.toUpperCase());
1450
1549
  });
1451
- it('does not transpile `then` tokens', () => {
1452
- testTranspile(`
1550
+ it('does not transpile `then` tokens', async () => {
1551
+ await testTranspile(`
1453
1552
  sub main()
1454
1553
  if true
1455
1554
  print true
@@ -1459,8 +1558,8 @@ describe('BrsFile', () => {
1459
1558
  end sub
1460
1559
  `);
1461
1560
  });
1462
- it('honors spacing between multi-word tokens', () => {
1463
- testTranspile(`
1561
+ it('honors spacing between multi-word tokens', async () => {
1562
+ await testTranspile(`
1464
1563
  sub main()
1465
1564
  if true
1466
1565
  print true
@@ -1470,8 +1569,8 @@ describe('BrsFile', () => {
1470
1569
  end sub
1471
1570
  `);
1472
1571
  });
1473
- it('handles when only some of the statements have `then`', () => {
1474
- testTranspile(`
1572
+ it('handles when only some of the statements have `then`', async () => {
1573
+ await testTranspile(`
1475
1574
  sub main()
1476
1575
  if true
1477
1576
  else if true then
@@ -1484,25 +1583,25 @@ describe('BrsFile', () => {
1484
1583
  end sub
1485
1584
  `);
1486
1585
  });
1487
- it('retains casing of parameter types', () => {
1488
- function test(type) {
1489
- testTranspile(`
1586
+ it('retains casing of parameter types', async () => {
1587
+ async function test(type) {
1588
+ await testTranspile(`
1490
1589
  sub one(a as ${type}, b as ${type.toUpperCase()}, c as ${type.toLowerCase()})
1491
1590
  end sub
1492
1591
  `);
1493
1592
  }
1494
- test('Boolean');
1495
- test('Double');
1496
- test('Dynamic');
1497
- test('Float');
1498
- test('Integer');
1499
- test('LongInteger');
1500
- test('Object');
1501
- test('String');
1502
- });
1503
- it('retains casing of return types', () => {
1504
- function test(type) {
1505
- testTranspile(`
1593
+ await test('Boolean');
1594
+ await test('Double');
1595
+ await test('Dynamic');
1596
+ await test('Float');
1597
+ await test('Integer');
1598
+ await test('LongInteger');
1599
+ await test('Object');
1600
+ await test('String');
1601
+ });
1602
+ it('retains casing of return types', async () => {
1603
+ async function test(type) {
1604
+ await testTranspile(`
1506
1605
  sub one() as ${type}
1507
1606
  end sub
1508
1607
 
@@ -1513,19 +1612,19 @@ describe('BrsFile', () => {
1513
1612
  end sub
1514
1613
  `);
1515
1614
  }
1516
- test('Boolean');
1517
- test('Double');
1518
- test('Dynamic');
1519
- test('Float');
1520
- test('Integer');
1521
- test('LongInteger');
1522
- test('Object');
1523
- test('String');
1524
- test('Void');
1525
- });
1526
- it('retains casing of literal types', () => {
1527
- function test(type) {
1528
- testTranspile(`
1615
+ await test('Boolean');
1616
+ await test('Double');
1617
+ await test('Dynamic');
1618
+ await test('Float');
1619
+ await test('Integer');
1620
+ await test('LongInteger');
1621
+ await test('Object');
1622
+ await test('String');
1623
+ await test('Void');
1624
+ });
1625
+ it('retains casing of literal types', async () => {
1626
+ async function test(type) {
1627
+ await testTranspile(`
1529
1628
  sub main()
1530
1629
  thing = ${type}
1531
1630
  thing = ${type.toLowerCase()}
@@ -1533,13 +1632,13 @@ describe('BrsFile', () => {
1533
1632
  end sub
1534
1633
  `);
1535
1634
  }
1536
- test('Invalid');
1537
- test('True');
1538
- test('False');
1635
+ await test('Invalid');
1636
+ await test('True');
1637
+ await test('False');
1539
1638
  });
1540
1639
  describe('throwStatement', () => {
1541
- it('transpiles properly', () => {
1542
- testTranspile(`
1640
+ it('transpiles properly', async () => {
1641
+ await testTranspile(`
1543
1642
  sub main()
1544
1643
  try
1545
1644
  throw "some message"
@@ -1550,8 +1649,8 @@ describe('BrsFile', () => {
1550
1649
  });
1551
1650
  });
1552
1651
  describe('try/catch', () => {
1553
- it('transpiles properly', () => {
1554
- testTranspile(`
1652
+ it('transpiles properly', async () => {
1653
+ await testTranspile(`
1555
1654
  sub main()
1556
1655
  try
1557
1656
  print m.b.c
@@ -1563,8 +1662,8 @@ describe('BrsFile', () => {
1563
1662
  });
1564
1663
  });
1565
1664
  describe('namespaces', () => {
1566
- it('properly transpiles namespace functions for assignments', () => {
1567
- testTranspile(`
1665
+ it('properly transpiles namespace functions for assignments', async () => {
1666
+ await testTranspile(`
1568
1667
  namespace NameA.NameB
1569
1668
  sub Speak()
1570
1669
  end sub
@@ -1585,8 +1684,8 @@ describe('BrsFile', () => {
1585
1684
  end sub
1586
1685
  `);
1587
1686
  });
1588
- it('properly transpiles inferred namespace function for assignment', () => {
1589
- testTranspile(`
1687
+ it('properly transpiles inferred namespace function for assignment', async () => {
1688
+ await testTranspile(`
1590
1689
  namespace NameA.NameB
1591
1690
  sub Speak()
1592
1691
  end sub
@@ -1606,26 +1705,26 @@ describe('BrsFile', () => {
1606
1705
  `);
1607
1706
  });
1608
1707
  });
1609
- it('includes all text to end of line for a non-terminated string', () => {
1610
- testTranspile('sub main()\n name = "john \nend sub', 'sub main()\n name = "john "\nend sub', null, 'source/main.bs', false);
1708
+ it('includes all text to end of line for a non-terminated string', async () => {
1709
+ await testTranspile('sub main()\n name = "john \nend sub', 'sub main()\n name = "john "\nend sub', null, 'source/main.bs', false);
1611
1710
  });
1612
- it('escapes quotes in string literals', () => {
1613
- testTranspile(`
1711
+ it('escapes quotes in string literals', async () => {
1712
+ await testTranspile(`
1614
1713
  sub main()
1615
1714
  expected = "Hello"
1616
1715
  expected += chr(10) + " version=""2.0"""
1617
1716
  end sub
1618
1717
  `);
1619
1718
  });
1620
- it('keeps function parameter types in proper order', () => {
1621
- testTranspile(`
1719
+ it('keeps function parameter types in proper order', async () => {
1720
+ await testTranspile(`
1622
1721
  function CreateTestStatistic(name as string, result = "Success" as string, time = 0 as integer, errorCode = 0 as integer, errorMessage = "" as string) as object
1623
1722
  end function
1624
1723
  `);
1625
1724
  });
1626
- it('discard parameter types when removeParameterTypes is true', () => {
1725
+ it('discard parameter types when removeParameterTypes is true', async () => {
1627
1726
  program.options.removeParameterTypes = true;
1628
- testTranspile(`
1727
+ await testTranspile(`
1629
1728
  sub one(a as integer, b = "" as string, c = invalid as dynamic)
1630
1729
  end sub
1631
1730
  `, `
@@ -1633,9 +1732,9 @@ describe('BrsFile', () => {
1633
1732
  end sub
1634
1733
  `);
1635
1734
  });
1636
- it('discard return type when removeParameterTypes is true', () => {
1735
+ it('discard return type when removeParameterTypes is true', async () => {
1637
1736
  program.options.removeParameterTypes = true;
1638
- testTranspile(`
1737
+ await testTranspile(`
1639
1738
  function one() as string
1640
1739
  return ""
1641
1740
  end function
@@ -1645,8 +1744,8 @@ describe('BrsFile', () => {
1645
1744
  end function
1646
1745
  `);
1647
1746
  });
1648
- it('transpiles local var assignment operators', () => {
1649
- testTranspile(`
1747
+ it('transpiles local var assignment operators', async () => {
1748
+ await testTranspile(`
1650
1749
  sub main()
1651
1750
  count = 0
1652
1751
  count += 1
@@ -1659,8 +1758,8 @@ describe('BrsFile', () => {
1659
1758
  end sub
1660
1759
  `);
1661
1760
  });
1662
- it('transpiles AA property assignment operators', () => {
1663
- testTranspile(`
1761
+ it('transpiles AA property assignment operators', async () => {
1762
+ await testTranspile(`
1664
1763
  sub main()
1665
1764
  person = {
1666
1765
  count: 0
@@ -1669,8 +1768,8 @@ describe('BrsFile', () => {
1669
1768
  end sub
1670
1769
  `);
1671
1770
  });
1672
- it('transpiles AA indexed assignment operators', () => {
1673
- testTranspile(`
1771
+ it('transpiles AA indexed assignment operators', async () => {
1772
+ await testTranspile(`
1674
1773
  sub main()
1675
1774
  person = {
1676
1775
  count: 0
@@ -1679,8 +1778,8 @@ describe('BrsFile', () => {
1679
1778
  end sub
1680
1779
  `);
1681
1780
  });
1682
- it('relative-referenced namespaced functions get prefixed', () => {
1683
- testTranspile(`
1781
+ it('relative-referenced namespaced functions get prefixed', async () => {
1782
+ await testTranspile(`
1684
1783
  namespace Vertibrates.Birds
1685
1784
  function GetAllBirds()
1686
1785
  return [
@@ -1710,8 +1809,8 @@ describe('BrsFile', () => {
1710
1809
  end function
1711
1810
  `, 'trim', 'source/main.bs');
1712
1811
  });
1713
- it('transpiles namespaced functions', () => {
1714
- testTranspile(`
1812
+ it('transpiles namespaced functions', async () => {
1813
+ await testTranspile(`
1715
1814
  namespace NameA
1716
1815
  sub alert()
1717
1816
  end sub
@@ -1727,9 +1826,9 @@ describe('BrsFile', () => {
1727
1826
  end sub
1728
1827
  `, 'trim', 'source/main.bs');
1729
1828
  });
1730
- it('transpiles dim', () => {
1731
- function doTest(code) {
1732
- testTranspile(`
1829
+ it('transpiles dim', async () => {
1830
+ async function doTest(code) {
1831
+ await testTranspile(`
1733
1832
  sub main()
1734
1833
  requestList = []
1735
1834
  ${code}
@@ -1741,20 +1840,20 @@ describe('BrsFile', () => {
1741
1840
  end sub
1742
1841
  `);
1743
1842
  }
1744
- doTest(`Dim c[5]`);
1745
- doTest(`Dim c[5, 4]`);
1746
- doTest(`Dim c[5, 4, 6]`);
1747
- doTest(`Dim requestData[requestList.count()]`);
1748
- doTest(`Dim requestData[1, requestList.count()]`);
1749
- doTest(`Dim requestData[1, requestList.count(), 2]`);
1750
- doTest(`Dim requestData[requestList[2]]`);
1751
- doTest(`Dim requestData[1, requestList[2]]`);
1752
- doTest(`Dim requestData[1, requestList[2], 2]`);
1753
- doTest(`Dim requestData[requestList["2"]]`);
1754
- doTest(`Dim requestData[1, requestList["2"]]`);
1755
- doTest(`Dim requestData[1, requestList["2"], 2]`);
1756
- doTest(`Dim requestData[1, StrToI("1"), 2]`);
1757
- testTranspile(`
1843
+ await doTest(`Dim c[5]`);
1844
+ await doTest(`Dim c[5, 4]`);
1845
+ await doTest(`Dim c[5, 4, 6]`);
1846
+ await doTest(`Dim requestData[requestList.count()]`);
1847
+ await doTest(`Dim requestData[1, requestList.count()]`);
1848
+ await doTest(`Dim requestData[1, requestList.count(), 2]`);
1849
+ await doTest(`Dim requestData[requestList[2]]`);
1850
+ await doTest(`Dim requestData[1, requestList[2]]`);
1851
+ await doTest(`Dim requestData[1, requestList[2], 2]`);
1852
+ await doTest(`Dim requestData[requestList["2"]]`);
1853
+ await doTest(`Dim requestData[1, requestList["2"]]`);
1854
+ await doTest(`Dim requestData[1, requestList["2"], 2]`);
1855
+ await doTest(`Dim requestData[1, StrToI("1"), 2]`);
1856
+ await testTranspile(`
1758
1857
  function getValue(param1)
1759
1858
  end function
1760
1859
 
@@ -1766,8 +1865,8 @@ describe('BrsFile', () => {
1766
1865
  end sub
1767
1866
  `);
1768
1867
  });
1769
- it('transpiles calls to fully-qualified namespaced functions', () => {
1770
- testTranspile(`
1868
+ it('transpiles calls to fully-qualified namespaced functions', async () => {
1869
+ await testTranspile(`
1771
1870
  namespace NameA
1772
1871
  sub alert()
1773
1872
  end sub
@@ -1792,15 +1891,15 @@ describe('BrsFile', () => {
1792
1891
  end sub
1793
1892
  `, 'trim', 'source/main.bs');
1794
1893
  });
1795
- it('keeps end-of-line comments with their line', () => {
1796
- testTranspile(`
1894
+ it('keeps end-of-line comments with their line', async () => {
1895
+ await testTranspile(`
1797
1896
  function DoSomething() 'comment 1
1798
1897
  name = "bob" 'comment 2
1799
1898
  end function 'comment 3
1800
1899
  `);
1801
1900
  });
1802
- it('works for functions', () => {
1803
- testTranspile(`
1901
+ it('works for functions', async () => {
1902
+ await testTranspile(`
1804
1903
  function DoSomething()
1805
1904
  'lots of empty white space
1806
1905
  'that will be removed during transpile
@@ -1815,16 +1914,16 @@ describe('BrsFile', () => {
1815
1914
  end function
1816
1915
  `);
1817
1916
  });
1818
- it('keeps empty AAs and arrays on same line', () => {
1819
- testTranspile(`
1917
+ it('keeps empty AAs and arrays on same line', async () => {
1918
+ await testTranspile(`
1820
1919
  sub a()
1821
1920
  person = {}
1822
1921
  stuff = []
1823
1922
  end sub
1824
1923
  `, null, 'trim');
1825
1924
  });
1826
- it('does not add leading or trailing newlines', () => {
1827
- testTranspile(`function abc()\nend function`, undefined, 'none');
1925
+ it('does not add leading or trailing newlines', async () => {
1926
+ await testTranspile(`function abc()\nend function`, undefined, 'none');
1828
1927
  });
1829
1928
  it('handles sourcemap edge case', async () => {
1830
1929
  let source = 'sub main()\n' +
@@ -1833,9 +1932,9 @@ describe('BrsFile', () => {
1833
1932
  '\n' +
1834
1933
  'end sub';
1835
1934
  program.options.sourceMap = true;
1836
- let result = testTranspile(source, `sub main()\n print 1\nend sub`, 'none', 'source/main.bs');
1935
+ let result = await testTranspile(source, `sub main()\n print 1\nend sub`, 'none', 'source/main.bs');
1837
1936
  //load the source map
1838
- let location = await source_map_1.SourceMapConsumer.with(result.map.toJSON(), null, (consumer) => {
1937
+ let location = await source_map_1.SourceMapConsumer.with(result.map, null, (consumer) => {
1839
1938
  return consumer.generatedPositionFor({
1840
1939
  line: 3,
1841
1940
  column: 0,
@@ -1852,7 +1951,7 @@ describe('BrsFile', () => {
1852
1951
  //remove newlines and EOF
1853
1952
  .filter(x => x.kind !== TokenKind_1.TokenKind.Eof && x.kind !== TokenKind_1.TokenKind.Newline);
1854
1953
  program.options.sourceMap = true;
1855
- let result = testTranspile(source, source, 'none');
1954
+ let result = await testTranspile(source, source, 'none');
1856
1955
  //load the source map
1857
1956
  await source_map_1.SourceMapConsumer.with(result.map.toString(), null, (consumer) => {
1858
1957
  let tokenResult = tokens.map(token => ({
@@ -1875,8 +1974,8 @@ describe('BrsFile', () => {
1875
1974
  (0, chai_config_spec_1.expect)(sourcemapResult).to.eql(tokenResult);
1876
1975
  });
1877
1976
  });
1878
- it('handles empty if block', () => {
1879
- testTranspile(`
1977
+ it('handles empty if block', async () => {
1978
+ await testTranspile(`
1880
1979
  sub main()
1881
1980
  if true then
1882
1981
  end if
@@ -1897,8 +1996,8 @@ describe('BrsFile', () => {
1897
1996
  end sub
1898
1997
  `);
1899
1998
  });
1900
- it('handles empty elseif block', () => {
1901
- testTranspile(`
1999
+ it('handles empty elseif block', async () => {
2000
+ await testTranspile(`
1902
2001
  sub main()
1903
2002
  if true then
1904
2003
  print "if"
@@ -1912,8 +2011,8 @@ describe('BrsFile', () => {
1912
2011
  end sub
1913
2012
  `);
1914
2013
  });
1915
- it('handles empty else block', () => {
1916
- testTranspile(`
2014
+ it('handles empty else block', async () => {
2015
+ await testTranspile(`
1917
2016
  sub main()
1918
2017
  if true then
1919
2018
  print "if"
@@ -1928,8 +2027,8 @@ describe('BrsFile', () => {
1928
2027
  end sub
1929
2028
  `);
1930
2029
  });
1931
- it('handles else block with a leading comment', () => {
1932
- testTranspile(`
2030
+ it('handles else block with a leading comment', async () => {
2031
+ await testTranspile(`
1933
2032
  sub main()
1934
2033
  if true then
1935
2034
  print "if"
@@ -1940,8 +2039,8 @@ describe('BrsFile', () => {
1940
2039
  end sub
1941
2040
  `);
1942
2041
  });
1943
- it('works for function parameters', () => {
1944
- testTranspile(`
2042
+ it('works for function parameters', async () => {
2043
+ await testTranspile(`
1945
2044
  function DoSomething(name, age as integer, text as string)
1946
2045
  end function
1947
2046
  `, `
@@ -1949,8 +2048,8 @@ describe('BrsFile', () => {
1949
2048
  end function
1950
2049
  `);
1951
2050
  });
1952
- it('adds newlines between top-level statements', () => {
1953
- testTranspile(`
2051
+ it('adds newlines between top-level statements', async () => {
2052
+ await testTranspile(`
1954
2053
  function a()
1955
2054
  end function
1956
2055
 
@@ -1958,8 +2057,8 @@ describe('BrsFile', () => {
1958
2057
  end function
1959
2058
  `);
1960
2059
  });
1961
- it('properly indents nested AA literals', () => {
1962
- testTranspile(`
2060
+ it('properly indents nested AA literals', async () => {
2061
+ await testTranspile(`
1963
2062
  sub doSomething()
1964
2063
  grandparent = {
1965
2064
  parent: {
@@ -1973,8 +2072,8 @@ describe('BrsFile', () => {
1973
2072
  end sub
1974
2073
  `);
1975
2074
  });
1976
- it('does not add comma after final object property even when comments are present', () => {
1977
- testTranspile(`
2075
+ it('does not add comma after final object property even when comments are present', async () => {
2076
+ await testTranspile(`
1978
2077
  sub doSomething()
1979
2078
  person = {
1980
2079
  age: 12 'comment
@@ -1997,8 +2096,8 @@ describe('BrsFile', () => {
1997
2096
  end sub
1998
2097
  `);
1999
2098
  });
2000
- it('works for a complex function with comments all over the place', () => {
2001
- testTranspile(`
2099
+ it('works for a complex function with comments all over the place', async () => {
2100
+ await testTranspile(`
2002
2101
  'import some library
2003
2102
  library "v30/bslCore.brs" 'comment
2004
2103
 
@@ -2088,7 +2187,7 @@ describe('BrsFile', () => {
2088
2187
  sub logInfo()
2089
2188
  end sub
2090
2189
  `);
2091
- file.needsTranspiled = false;
2190
+ file['needsTranspiled'] = false;
2092
2191
  const { code } = file.transpile();
2093
2192
  (0, chai_config_spec_1.expect)(code.endsWith(`'//# sourceMappingURL=./logger.brs.map`)).to.be.true;
2094
2193
  });
@@ -2097,16 +2196,16 @@ describe('BrsFile', () => {
2097
2196
  sub logInfo()
2098
2197
  end sub
2099
2198
  `);
2100
- file.needsTranspiled = true;
2199
+ file['needsTranspiled'] = true;
2101
2200
  const { code } = file.transpile();
2102
2201
  (0, chai_config_spec_1.expect)(code.endsWith(`'//# sourceMappingURL=./logger.brs.map`)).to.be.true;
2103
2202
  });
2104
- it('replaces custom types in parameter types and return types', () => {
2203
+ it('replaces custom types in parameter types and return types', async () => {
2105
2204
  program.setFile('source/SomeKlass.bs', `
2106
2205
  class SomeKlass
2107
2206
  end class
2108
2207
  `);
2109
- testTranspile(`
2208
+ await testTranspile(`
2110
2209
  function foo() as SomeKlass
2111
2210
  return new SomeKlass()
2112
2211
  end function
@@ -2135,8 +2234,8 @@ describe('BrsFile', () => {
2135
2234
  program.validate();
2136
2235
  (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
2137
2236
  });
2138
- it('sets invalid on empty callfunc', () => {
2139
- testTranspile(`
2237
+ it('sets invalid on empty callfunc', async () => {
2238
+ await testTranspile(`
2140
2239
  sub main()
2141
2240
  node = invalid
2142
2241
  node@.doSomething()
@@ -2152,8 +2251,8 @@ describe('BrsFile', () => {
2152
2251
  end sub
2153
2252
  `);
2154
2253
  });
2155
- it('includes original arguments', () => {
2156
- testTranspile(`
2254
+ it('includes original arguments', async () => {
2255
+ await testTranspile(`
2157
2256
  sub main()
2158
2257
  node = invalid
2159
2258
  node@.doSomething(1, true, m.top.someVal)
@@ -2255,8 +2354,8 @@ describe('BrsFile', () => {
2255
2354
  });
2256
2355
  });
2257
2356
  describe('typedef', () => {
2258
- it('includes enum and interface types', () => {
2259
- testGetTypedef(`
2357
+ it('includes enum and interface types', async () => {
2358
+ await testGetTypedef(`
2260
2359
  interface Foo
2261
2360
  field as string
2262
2361
  end interface
@@ -2632,8 +2731,8 @@ describe('BrsFile', () => {
2632
2731
  function plugin() {
2633
2732
  return {
2634
2733
  name: 'lower-file-name',
2635
- afterFileParse: (evt) => {
2636
- evt.file._customProp = true;
2734
+ afterProvideFile: (evt) => {
2735
+ evt.files[0]._customProp = true;
2637
2736
  }
2638
2737
  };
2639
2738
  }
@@ -2641,16 +2740,16 @@ describe('BrsFile', () => {
2641
2740
  `);
2642
2741
  });
2643
2742
  it('can load an absolute plugin which receives callbacks', () => {
2644
- program.plugins = new PluginInterface_1.default(util_1.default.loadPlugins(testHelpers_spec_2.tempDir, [
2645
- (0, util_1.standardizePath) `${testHelpers_spec_2.tempDir}/plugins/${pluginFileName}`
2646
- ]), { logger: new Logger_1.Logger() });
2743
+ for (const plugin of util_1.default.loadPlugins(testHelpers_spec_2.tempDir, [(0, util_1.standardizePath) `${testHelpers_spec_2.tempDir}/plugins/${pluginFileName}`])) {
2744
+ program.plugins.add(plugin);
2745
+ }
2647
2746
  const file = program.setFile('source/MAIN.brs', '');
2648
2747
  (0, chai_config_spec_1.expect)(file._customProp).to.exist;
2649
2748
  });
2650
2749
  it('can load a relative plugin which receives callbacks', () => {
2651
- program.plugins = new PluginInterface_1.default(util_1.default.loadPlugins(testHelpers_spec_2.tempDir, [
2652
- `./plugins/${pluginFileName}`
2653
- ]), { logger: new Logger_1.Logger() });
2750
+ for (const plugin of util_1.default.loadPlugins(testHelpers_spec_2.tempDir, [`./plugins/${pluginFileName}`])) {
2751
+ program.plugins.add(plugin);
2752
+ }
2654
2753
  const file = program.setFile('source/MAIN.brs', '');
2655
2754
  (0, chai_config_spec_1.expect)(file._customProp).to.exist;
2656
2755
  });