brighterscript 0.72.0 → 0.72.2

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 (335) hide show
  1. package/bsconfig.schema.json +62 -0
  2. package/dist/BsConfig.d.ts +56 -1
  3. package/dist/CommentFlagProcessor.d.ts +16 -12
  4. package/dist/CommentFlagProcessor.js +141 -59
  5. package/dist/CommentFlagProcessor.js.map +1 -1
  6. package/dist/DiagnosticMessages.d.ts +27 -1
  7. package/dist/DiagnosticMessages.js +32 -2
  8. package/dist/DiagnosticMessages.js.map +1 -1
  9. package/dist/Program.d.ts +4 -0
  10. package/dist/Program.js +2 -0
  11. package/dist/Program.js.map +1 -1
  12. package/dist/ProgramBuilder.d.ts +1 -8
  13. package/dist/ProgramBuilder.js +31 -11
  14. package/dist/ProgramBuilder.js.map +1 -1
  15. package/dist/bscPlugin/codeActions/CodeActionsProcessor.d.ts +38 -0
  16. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +257 -14
  17. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  18. package/dist/bscPlugin/validation/BrsFileValidator.js +13 -0
  19. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
  20. package/dist/cli.js +13 -0
  21. package/dist/cli.js.map +1 -1
  22. package/dist/diagnosticUtils.d.ts +51 -1
  23. package/dist/diagnosticUtils.js +222 -1
  24. package/dist/diagnosticUtils.js.map +1 -1
  25. package/dist/files/BrsFile.js +4 -2
  26. package/dist/files/BrsFile.js.map +1 -1
  27. package/dist/files/XmlFile.js +2 -1
  28. package/dist/files/XmlFile.js.map +1 -1
  29. package/dist/interfaces.d.ts +15 -1
  30. package/dist/lexer/TokenKind.d.ts +8 -0
  31. package/dist/lexer/TokenKind.js +21 -1
  32. package/dist/lexer/TokenKind.js.map +1 -1
  33. package/dist/lsp/LspProject.d.ts +19 -0
  34. package/dist/lsp/Project.d.ts +14 -0
  35. package/dist/lsp/Project.js +9 -1
  36. package/dist/lsp/Project.js.map +1 -1
  37. package/dist/lsp/ProjectManager.js +15 -1
  38. package/dist/lsp/ProjectManager.js.map +1 -1
  39. package/dist/lsp/worker/WorkerThreadProject.d.ts +14 -0
  40. package/dist/lsp/worker/WorkerThreadProject.js +7 -0
  41. package/dist/lsp/worker/WorkerThreadProject.js.map +1 -1
  42. package/dist/parser/Parser.d.ts +13 -1
  43. package/dist/parser/Parser.js +40 -14
  44. package/dist/parser/Parser.js.map +1 -1
  45. package/dist/util.js +20 -9
  46. package/dist/util.js.map +1 -1
  47. package/package.json +17 -14
  48. package/dist/astUtils/AstEditor.spec.d.ts +0 -1
  49. package/dist/astUtils/AstEditor.spec.js +0 -254
  50. package/dist/astUtils/AstEditor.spec.js.map +0 -1
  51. package/dist/astUtils/creators.spec.d.ts +0 -1
  52. package/dist/astUtils/creators.spec.js +0 -21
  53. package/dist/astUtils/creators.spec.js.map +0 -1
  54. package/dist/astUtils/reflection.spec.d.ts +0 -1
  55. package/dist/astUtils/reflection.spec.js +0 -308
  56. package/dist/astUtils/reflection.spec.js.map +0 -1
  57. package/dist/astUtils/stackedVisitor.spec.d.ts +0 -1
  58. package/dist/astUtils/stackedVisitor.spec.js +0 -79
  59. package/dist/astUtils/stackedVisitor.spec.js.map +0 -1
  60. package/dist/astUtils/visitors.spec.d.ts +0 -1
  61. package/dist/astUtils/visitors.spec.js +0 -1197
  62. package/dist/astUtils/visitors.spec.js.map +0 -1
  63. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.d.ts +0 -1
  64. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +0 -887
  65. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +0 -1
  66. package/dist/bscPlugin/definition/DefinitionProvider.spec.d.ts +0 -1
  67. package/dist/bscPlugin/definition/DefinitionProvider.spec.js +0 -171
  68. package/dist/bscPlugin/definition/DefinitionProvider.spec.js.map +0 -1
  69. package/dist/bscPlugin/hover/HoverProcessor.spec.d.ts +0 -1
  70. package/dist/bscPlugin/hover/HoverProcessor.spec.js +0 -201
  71. package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +0 -1
  72. package/dist/bscPlugin/references/ReferencesProvider.spec.d.ts +0 -1
  73. package/dist/bscPlugin/references/ReferencesProvider.spec.js +0 -51
  74. package/dist/bscPlugin/references/ReferencesProvider.spec.js.map +0 -1
  75. package/dist/bscPlugin/selectionRanges/SelectionRangesProcessor.spec.d.ts +0 -1
  76. package/dist/bscPlugin/selectionRanges/SelectionRangesProcessor.spec.js +0 -298
  77. package/dist/bscPlugin/selectionRanges/SelectionRangesProcessor.spec.js.map +0 -1
  78. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.d.ts +0 -1
  79. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +0 -399
  80. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +0 -1
  81. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.d.ts +0 -1
  82. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js +0 -290
  83. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js.map +0 -1
  84. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.d.ts +0 -1
  85. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js +0 -245
  86. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js.map +0 -1
  87. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.d.ts +0 -1
  88. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js +0 -46
  89. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js.map +0 -1
  90. package/dist/bscPlugin/validation/BrsFileValidator.spec.d.ts +0 -1
  91. package/dist/bscPlugin/validation/BrsFileValidator.spec.js +0 -487
  92. package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +0 -1
  93. package/dist/common/Sequencer.spec.d.ts +0 -1
  94. package/dist/common/Sequencer.spec.js +0 -75
  95. package/dist/common/Sequencer.spec.js.map +0 -1
  96. package/dist/files/BrsFile.Class.spec.d.ts +0 -1
  97. package/dist/files/BrsFile.Class.spec.js +0 -1805
  98. package/dist/files/BrsFile.Class.spec.js.map +0 -1
  99. package/dist/files/BrsFile.spec.d.ts +0 -1
  100. package/dist/files/BrsFile.spec.js +0 -4420
  101. package/dist/files/BrsFile.spec.js.map +0 -1
  102. package/dist/files/XmlFile.spec.d.ts +0 -1
  103. package/dist/files/XmlFile.spec.js +0 -1169
  104. package/dist/files/XmlFile.spec.js.map +0 -1
  105. package/dist/files/tests/imports.spec.d.ts +0 -1
  106. package/dist/files/tests/imports.spec.js +0 -241
  107. package/dist/files/tests/imports.spec.js.map +0 -1
  108. package/dist/files/tests/optionalChaning.spec.d.ts +0 -1
  109. package/dist/files/tests/optionalChaning.spec.js +0 -152
  110. package/dist/files/tests/optionalChaning.spec.js.map +0 -1
  111. package/dist/lexer/Character.spec.d.ts +0 -1
  112. package/dist/lexer/Character.spec.js +0 -27
  113. package/dist/lexer/Character.spec.js.map +0 -1
  114. package/dist/lexer/Lexer.spec.d.ts +0 -1
  115. package/dist/lexer/Lexer.spec.js +0 -1300
  116. package/dist/lexer/Lexer.spec.js.map +0 -1
  117. package/dist/lsp/ActionQueue.spec.d.ts +0 -1
  118. package/dist/lsp/ActionQueue.spec.js +0 -80
  119. package/dist/lsp/ActionQueue.spec.js.map +0 -1
  120. package/dist/lsp/DocumentManager.spec.d.ts +0 -1
  121. package/dist/lsp/DocumentManager.spec.js +0 -103
  122. package/dist/lsp/DocumentManager.spec.js.map +0 -1
  123. package/dist/lsp/PathFilterer.spec.d.ts +0 -1
  124. package/dist/lsp/PathFilterer.spec.js +0 -182
  125. package/dist/lsp/PathFilterer.spec.js.map +0 -1
  126. package/dist/lsp/Project.spec.d.ts +0 -1
  127. package/dist/lsp/Project.spec.js +0 -400
  128. package/dist/lsp/Project.spec.js.map +0 -1
  129. package/dist/lsp/ProjectManager.spec.d.ts +0 -1
  130. package/dist/lsp/ProjectManager.spec.js +0 -1147
  131. package/dist/lsp/ProjectManager.spec.js.map +0 -1
  132. package/dist/lsp/worker/MessageHandler.spec.d.ts +0 -1
  133. package/dist/lsp/worker/MessageHandler.spec.js +0 -64
  134. package/dist/lsp/worker/MessageHandler.spec.js.map +0 -1
  135. package/dist/lsp/worker/WorkerPool.spec.d.ts +0 -1
  136. package/dist/lsp/worker/WorkerPool.spec.js +0 -59
  137. package/dist/lsp/worker/WorkerPool.spec.js.map +0 -1
  138. package/dist/lsp/worker/WorkerThreadProject.spec.d.ts +0 -2
  139. package/dist/lsp/worker/WorkerThreadProject.spec.js +0 -72
  140. package/dist/lsp/worker/WorkerThreadProject.spec.js.map +0 -1
  141. package/dist/parser/AstNode.spec.d.ts +0 -1
  142. package/dist/parser/AstNode.spec.js +0 -1452
  143. package/dist/parser/AstNode.spec.js.map +0 -1
  144. package/dist/parser/Expression.spec.d.ts +0 -1
  145. package/dist/parser/Expression.spec.js +0 -40
  146. package/dist/parser/Expression.spec.js.map +0 -1
  147. package/dist/parser/Parser.Class.spec.d.ts +0 -1
  148. package/dist/parser/Parser.Class.spec.js +0 -495
  149. package/dist/parser/Parser.Class.spec.js.map +0 -1
  150. package/dist/parser/Parser.spec.d.ts +0 -4
  151. package/dist/parser/Parser.spec.js +0 -1857
  152. package/dist/parser/Parser.spec.js.map +0 -1
  153. package/dist/parser/SGParser.spec.d.ts +0 -1
  154. package/dist/parser/SGParser.spec.js +0 -131
  155. package/dist/parser/SGParser.spec.js.map +0 -1
  156. package/dist/parser/Statement.spec.d.ts +0 -1
  157. package/dist/parser/Statement.spec.js +0 -118
  158. package/dist/parser/Statement.spec.js.map +0 -1
  159. package/dist/parser/tests/Parser.spec.d.ts +0 -19
  160. package/dist/parser/tests/Parser.spec.js +0 -38
  161. package/dist/parser/tests/Parser.spec.js.map +0 -1
  162. package/dist/parser/tests/controlFlow/For.spec.d.ts +0 -1
  163. package/dist/parser/tests/controlFlow/For.spec.js +0 -161
  164. package/dist/parser/tests/controlFlow/For.spec.js.map +0 -1
  165. package/dist/parser/tests/controlFlow/ForEach.spec.d.ts +0 -1
  166. package/dist/parser/tests/controlFlow/ForEach.spec.js +0 -106
  167. package/dist/parser/tests/controlFlow/ForEach.spec.js.map +0 -1
  168. package/dist/parser/tests/controlFlow/If.spec.d.ts +0 -1
  169. package/dist/parser/tests/controlFlow/If.spec.js +0 -570
  170. package/dist/parser/tests/controlFlow/If.spec.js.map +0 -1
  171. package/dist/parser/tests/controlFlow/While.spec.d.ts +0 -1
  172. package/dist/parser/tests/controlFlow/While.spec.js +0 -107
  173. package/dist/parser/tests/controlFlow/While.spec.js.map +0 -1
  174. package/dist/parser/tests/expression/Additive.spec.d.ts +0 -1
  175. package/dist/parser/tests/expression/Additive.spec.js +0 -99
  176. package/dist/parser/tests/expression/Additive.spec.js.map +0 -1
  177. package/dist/parser/tests/expression/ArrayLiterals.spec.d.ts +0 -1
  178. package/dist/parser/tests/expression/ArrayLiterals.spec.js +0 -291
  179. package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +0 -1
  180. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.d.ts +0 -1
  181. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +0 -401
  182. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +0 -1
  183. package/dist/parser/tests/expression/Boolean.spec.d.ts +0 -1
  184. package/dist/parser/tests/expression/Boolean.spec.js +0 -83
  185. package/dist/parser/tests/expression/Boolean.spec.js.map +0 -1
  186. package/dist/parser/tests/expression/Call.spec.d.ts +0 -1
  187. package/dist/parser/tests/expression/Call.spec.js +0 -242
  188. package/dist/parser/tests/expression/Call.spec.js.map +0 -1
  189. package/dist/parser/tests/expression/Exponential.spec.d.ts +0 -1
  190. package/dist/parser/tests/expression/Exponential.spec.js +0 -37
  191. package/dist/parser/tests/expression/Exponential.spec.js.map +0 -1
  192. package/dist/parser/tests/expression/Function.spec.d.ts +0 -1
  193. package/dist/parser/tests/expression/Function.spec.js +0 -403
  194. package/dist/parser/tests/expression/Function.spec.js.map +0 -1
  195. package/dist/parser/tests/expression/Indexing.spec.d.ts +0 -1
  196. package/dist/parser/tests/expression/Indexing.spec.js +0 -289
  197. package/dist/parser/tests/expression/Indexing.spec.js.map +0 -1
  198. package/dist/parser/tests/expression/Multiplicative.spec.d.ts +0 -1
  199. package/dist/parser/tests/expression/Multiplicative.spec.js +0 -67
  200. package/dist/parser/tests/expression/Multiplicative.spec.js.map +0 -1
  201. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.d.ts +0 -1
  202. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +0 -346
  203. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +0 -1
  204. package/dist/parser/tests/expression/PrefixUnary.spec.d.ts +0 -1
  205. package/dist/parser/tests/expression/PrefixUnary.spec.js +0 -105
  206. package/dist/parser/tests/expression/PrefixUnary.spec.js.map +0 -1
  207. package/dist/parser/tests/expression/Primary.spec.d.ts +0 -1
  208. package/dist/parser/tests/expression/Primary.spec.js +0 -149
  209. package/dist/parser/tests/expression/Primary.spec.js.map +0 -1
  210. package/dist/parser/tests/expression/RegexLiteralExpression.spec.d.ts +0 -1
  211. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +0 -171
  212. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +0 -1
  213. package/dist/parser/tests/expression/Relational.spec.d.ts +0 -1
  214. package/dist/parser/tests/expression/Relational.spec.js +0 -83
  215. package/dist/parser/tests/expression/Relational.spec.js.map +0 -1
  216. package/dist/parser/tests/expression/SourceLiteralExpression.spec.d.ts +0 -1
  217. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +0 -201
  218. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +0 -1
  219. package/dist/parser/tests/expression/TemplateStringExpression.spec.d.ts +0 -1
  220. package/dist/parser/tests/expression/TemplateStringExpression.spec.js +0 -389
  221. package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +0 -1
  222. package/dist/parser/tests/expression/TernaryExpression.spec.d.ts +0 -1
  223. package/dist/parser/tests/expression/TernaryExpression.spec.js +0 -876
  224. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +0 -1
  225. package/dist/parser/tests/expression/UnaryExpression.spec.d.ts +0 -1
  226. package/dist/parser/tests/expression/UnaryExpression.spec.js +0 -52
  227. package/dist/parser/tests/expression/UnaryExpression.spec.js.map +0 -1
  228. package/dist/parser/tests/statement/AssignmentOperators.spec.d.ts +0 -1
  229. package/dist/parser/tests/statement/AssignmentOperators.spec.js +0 -79
  230. package/dist/parser/tests/statement/AssignmentOperators.spec.js.map +0 -1
  231. package/dist/parser/tests/statement/ConstStatement.spec.d.ts +0 -1
  232. package/dist/parser/tests/statement/ConstStatement.spec.js +0 -708
  233. package/dist/parser/tests/statement/ConstStatement.spec.js.map +0 -1
  234. package/dist/parser/tests/statement/Continue.spec.d.ts +0 -1
  235. package/dist/parser/tests/statement/Continue.spec.js +0 -119
  236. package/dist/parser/tests/statement/Continue.spec.js.map +0 -1
  237. package/dist/parser/tests/statement/Declaration.spec.d.ts +0 -1
  238. package/dist/parser/tests/statement/Declaration.spec.js +0 -108
  239. package/dist/parser/tests/statement/Declaration.spec.js.map +0 -1
  240. package/dist/parser/tests/statement/Dim.spec.d.ts +0 -1
  241. package/dist/parser/tests/statement/Dim.spec.js +0 -73
  242. package/dist/parser/tests/statement/Dim.spec.js.map +0 -1
  243. package/dist/parser/tests/statement/Enum.spec.d.ts +0 -1
  244. package/dist/parser/tests/statement/Enum.spec.js +0 -1307
  245. package/dist/parser/tests/statement/Enum.spec.js.map +0 -1
  246. package/dist/parser/tests/statement/For.spec.d.ts +0 -1
  247. package/dist/parser/tests/statement/For.spec.js +0 -45
  248. package/dist/parser/tests/statement/For.spec.js.map +0 -1
  249. package/dist/parser/tests/statement/ForEach.spec.d.ts +0 -1
  250. package/dist/parser/tests/statement/ForEach.spec.js +0 -36
  251. package/dist/parser/tests/statement/ForEach.spec.js.map +0 -1
  252. package/dist/parser/tests/statement/Function.spec.d.ts +0 -1
  253. package/dist/parser/tests/statement/Function.spec.js +0 -342
  254. package/dist/parser/tests/statement/Function.spec.js.map +0 -1
  255. package/dist/parser/tests/statement/Goto.spec.d.ts +0 -1
  256. package/dist/parser/tests/statement/Goto.spec.js +0 -51
  257. package/dist/parser/tests/statement/Goto.spec.js.map +0 -1
  258. package/dist/parser/tests/statement/Increment.spec.d.ts +0 -1
  259. package/dist/parser/tests/statement/Increment.spec.js +0 -117
  260. package/dist/parser/tests/statement/Increment.spec.js.map +0 -1
  261. package/dist/parser/tests/statement/InterfaceStatement.spec.d.ts +0 -1
  262. package/dist/parser/tests/statement/InterfaceStatement.spec.js +0 -102
  263. package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +0 -1
  264. package/dist/parser/tests/statement/LibraryStatement.spec.d.ts +0 -1
  265. package/dist/parser/tests/statement/LibraryStatement.spec.js +0 -74
  266. package/dist/parser/tests/statement/LibraryStatement.spec.js.map +0 -1
  267. package/dist/parser/tests/statement/Misc.spec.d.ts +0 -1
  268. package/dist/parser/tests/statement/Misc.spec.js +0 -335
  269. package/dist/parser/tests/statement/Misc.spec.js.map +0 -1
  270. package/dist/parser/tests/statement/PrintStatement.spec.d.ts +0 -1
  271. package/dist/parser/tests/statement/PrintStatement.spec.js +0 -195
  272. package/dist/parser/tests/statement/PrintStatement.spec.js.map +0 -1
  273. package/dist/parser/tests/statement/ReturnStatement.spec.d.ts +0 -1
  274. package/dist/parser/tests/statement/ReturnStatement.spec.js +0 -94
  275. package/dist/parser/tests/statement/ReturnStatement.spec.js.map +0 -1
  276. package/dist/parser/tests/statement/Set.spec.d.ts +0 -1
  277. package/dist/parser/tests/statement/Set.spec.js +0 -218
  278. package/dist/parser/tests/statement/Set.spec.js.map +0 -1
  279. package/dist/parser/tests/statement/Stop.spec.d.ts +0 -1
  280. package/dist/parser/tests/statement/Stop.spec.js +0 -38
  281. package/dist/parser/tests/statement/Stop.spec.js.map +0 -1
  282. package/dist/parser/tests/statement/Throw.spec.d.ts +0 -1
  283. package/dist/parser/tests/statement/Throw.spec.js +0 -35
  284. package/dist/parser/tests/statement/Throw.spec.js.map +0 -1
  285. package/dist/parser/tests/statement/TryCatch.spec.d.ts +0 -1
  286. package/dist/parser/tests/statement/TryCatch.spec.js +0 -142
  287. package/dist/parser/tests/statement/TryCatch.spec.js.map +0 -1
  288. package/dist/preprocessor/Manifest.spec.d.ts +0 -1
  289. package/dist/preprocessor/Manifest.spec.js +0 -80
  290. package/dist/preprocessor/Manifest.spec.js.map +0 -1
  291. package/dist/preprocessor/Preprocessor.spec.d.ts +0 -1
  292. package/dist/preprocessor/Preprocessor.spec.js +0 -152
  293. package/dist/preprocessor/Preprocessor.spec.js.map +0 -1
  294. package/dist/preprocessor/PreprocessorParser.spec.d.ts +0 -1
  295. package/dist/preprocessor/PreprocessorParser.spec.js +0 -116
  296. package/dist/preprocessor/PreprocessorParser.spec.js.map +0 -1
  297. package/dist/types/ArrayType.spec.d.ts +0 -1
  298. package/dist/types/ArrayType.spec.js +0 -30
  299. package/dist/types/ArrayType.spec.js.map +0 -1
  300. package/dist/types/BooleanType.spec.d.ts +0 -1
  301. package/dist/types/BooleanType.spec.js +0 -12
  302. package/dist/types/BooleanType.spec.js.map +0 -1
  303. package/dist/types/DoubleType.spec.d.ts +0 -1
  304. package/dist/types/DoubleType.spec.js +0 -12
  305. package/dist/types/DoubleType.spec.js.map +0 -1
  306. package/dist/types/DynamicType.spec.d.ts +0 -1
  307. package/dist/types/DynamicType.spec.js +0 -12
  308. package/dist/types/DynamicType.spec.js.map +0 -1
  309. package/dist/types/FloatType.spec.d.ts +0 -1
  310. package/dist/types/FloatType.spec.js +0 -12
  311. package/dist/types/FloatType.spec.js.map +0 -1
  312. package/dist/types/FunctionType.spec.d.ts +0 -1
  313. package/dist/types/FunctionType.spec.js +0 -23
  314. package/dist/types/FunctionType.spec.js.map +0 -1
  315. package/dist/types/IntegerType.spec.d.ts +0 -1
  316. package/dist/types/IntegerType.spec.js +0 -12
  317. package/dist/types/IntegerType.spec.js.map +0 -1
  318. package/dist/types/InterfaceType.spec.d.ts +0 -1
  319. package/dist/types/InterfaceType.spec.js +0 -175
  320. package/dist/types/InterfaceType.spec.js.map +0 -1
  321. package/dist/types/InvalidType.spec.d.ts +0 -1
  322. package/dist/types/InvalidType.spec.js +0 -12
  323. package/dist/types/InvalidType.spec.js.map +0 -1
  324. package/dist/types/LongIntegerType.spec.d.ts +0 -1
  325. package/dist/types/LongIntegerType.spec.js +0 -12
  326. package/dist/types/LongIntegerType.spec.js.map +0 -1
  327. package/dist/types/ObjectType.spec.d.ts +0 -1
  328. package/dist/types/ObjectType.spec.js +0 -12
  329. package/dist/types/ObjectType.spec.js.map +0 -1
  330. package/dist/types/StringType.spec.d.ts +0 -1
  331. package/dist/types/StringType.spec.js +0 -12
  332. package/dist/types/StringType.spec.js.map +0 -1
  333. package/dist/types/VoidType.spec.d.ts +0 -1
  334. package/dist/types/VoidType.spec.js +0 -12
  335. package/dist/types/VoidType.spec.js.map +0 -1
@@ -1,887 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const chai_config_spec_1 = require("../../chai-config.spec");
4
- const vscode_uri_1 = require("vscode-uri");
5
- const Program_1 = require("../../Program");
6
- const testHelpers_spec_1 = require("../../testHelpers.spec");
7
- const util_1 = require("../../util");
8
- const testHelpers_spec_2 = require("../../testHelpers.spec");
9
- const CodeActionsProcessor_1 = require("./CodeActionsProcessor");
10
- describe('CodeActionsProcessor', () => {
11
- let program;
12
- beforeEach(() => {
13
- program = new Program_1.Program({
14
- rootDir: testHelpers_spec_2.rootDir,
15
- autoImportComponentScript: true
16
- });
17
- });
18
- afterEach(() => {
19
- program.dispose();
20
- });
21
- /**
22
- * Helper function for testing code actions
23
- */
24
- function testGetCodeActions(file, range, expected) {
25
- program.validate();
26
- (0, chai_config_spec_1.expect)(program.getCodeActions(typeof file === 'string' ? file : file.srcPath, range).map(x => x.title).sort()).to.eql(expected);
27
- }
28
- describe('getCodeActions', () => {
29
- it('suggests `extends=Group`', () => {
30
- const file = program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
31
- <?xml version="1.0" encoding="utf-8" ?>
32
- <component name="comp1">
33
- </component>
34
- `);
35
- program.validate();
36
- (0, testHelpers_spec_1.expectCodeActions)(() => {
37
- program.getCodeActions(file.srcPath,
38
- //<comp|onent name="comp1">
39
- util_1.util.createRange(1, 5, 1, 5));
40
- }, [{
41
- title: `Extend "Group"`,
42
- isPreferred: true,
43
- kind: 'quickfix',
44
- changes: [{
45
- filePath: (0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/components/comp1.xml`,
46
- newText: ' extends="Group"',
47
- type: 'insert',
48
- //<component name="comp1"|>
49
- position: util_1.util.createPosition(1, 23)
50
- }]
51
- }, {
52
- title: `Extend "Task"`,
53
- kind: 'quickfix',
54
- changes: [{
55
- filePath: (0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/components/comp1.xml`,
56
- newText: ' extends="Task"',
57
- type: 'insert',
58
- //<component name="comp1"|>
59
- position: util_1.util.createPosition(1, 23)
60
- }]
61
- }, {
62
- title: `Extend "ContentNode"`,
63
- kind: 'quickfix',
64
- changes: [{
65
- filePath: (0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/components/comp1.xml`,
66
- newText: ' extends="ContentNode"',
67
- type: 'insert',
68
- //<component name="comp1"|>
69
- position: util_1.util.createPosition(1, 23)
70
- }]
71
- }]);
72
- });
73
- it('adds attribute at end of component with multiple attributes`', () => {
74
- const file = program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
75
- <?xml version="1.0" encoding="utf-8" ?>
76
- <component name="comp1" attr2="attr3" attr3="attr3">
77
- </component>
78
- `);
79
- program.validate();
80
- const codeActions = program.getCodeActions(file.srcPath,
81
- //<comp|onent name="comp1">
82
- util_1.util.createRange(1, 5, 1, 5));
83
- (0, chai_config_spec_1.expect)(codeActions[0].edit.changes[vscode_uri_1.URI.file((0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/components/comp1.xml`).toString()][0].range).to.eql(util_1.util.createRange(1, 51, 1, 51));
84
- });
85
- it('does not produce duplicate code actions for bs imports', () => {
86
- //define the function in two files
87
- program.setFile('components/lib1.brs', `
88
- sub doSomething()
89
- end sub
90
- `);
91
- program.setFile('components/lib2.brs', `
92
- sub doSomething()
93
- end sub
94
- `);
95
- //use the function in this file
96
- const componentCommonFile = program.setFile('components/ComponentCommon.bs', `
97
- sub init()
98
- doSomething()
99
- end sub
100
- `);
101
- //import the file in two scopes
102
- program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
103
- <?xml version="1.0" encoding="utf-8" ?>
104
- <component name="ChildScene">
105
- <script uri="ComponentCommon.bs" />
106
- </component>
107
- `);
108
- program.setFile('components/comp2.xml', (0, testHelpers_spec_1.trim) `
109
- <?xml version="1.0" encoding="utf-8" ?>
110
- <component name="ChildScene">
111
- <script uri="ComponentCommon.bs" />
112
- </component>
113
- `);
114
- program.validate();
115
- //we should only get each file import suggestion exactly once
116
- const codeActions = program.getCodeActions(componentCommonFile.srcPath,
117
- // doSome|thing()
118
- util_1.util.createRange(2, 22, 2, 22));
119
- (0, chai_config_spec_1.expect)(codeActions.map(x => x.title).sort()).to.eql([
120
- `import "pkg:/components/lib1.brs"`,
121
- `import "pkg:/components/lib2.brs"`
122
- ]);
123
- });
124
- it('does not suggest imports for brs files', () => {
125
- //import the file in two scopes
126
- program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
127
- <?xml version="1.0" encoding="utf-8" ?>
128
- <component name="ChildScene">
129
- <script uri="comp1.brs" />
130
- </component>
131
- `);
132
- //import the function here
133
- const file = program.setFile('components/comp1.brs', `
134
- sub init()
135
- DoSomething()
136
- end sub
137
- `);
138
- //define the function here
139
- program.setFile('source/lib.brs', `
140
- sub DoSomething()
141
- end sub
142
- `);
143
- program.validate();
144
- //there should be no code actions since this is a brs file
145
- const codeActions = program.getCodeActions(file.srcPath,
146
- // DoSometh|ing()
147
- util_1.util.createRange(2, 28, 2, 28));
148
- (0, chai_config_spec_1.expect)(codeActions).to.be.empty;
149
- });
150
- it('suggests class imports', () => {
151
- //import the file in two scopes
152
- program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
153
- <?xml version="1.0" encoding="utf-8" ?>
154
- <component name="ChildScene">
155
- <script uri="comp1.bs" />
156
- </component>
157
- `);
158
- const file = program.setFile('components/comp1.bs', `
159
- sub init()
160
- dude = new Person()
161
- end sub
162
- `);
163
- program.setFile('source/Person.bs', `
164
- class Person
165
- end class
166
- `);
167
- program.validate();
168
- (0, chai_config_spec_1.expect)(program.getCodeActions(file.srcPath,
169
- // new Per|son()
170
- util_1.util.createRange(2, 34, 2, 34)).map(x => x.title).sort()).to.eql([
171
- `import "pkg:/source/Person.bs"`
172
- ]);
173
- });
174
- it('suggests class imports', () => {
175
- //import the file in two scopes
176
- program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
177
- <?xml version="1.0" encoding="utf-8" ?>
178
- <component name="ChildScene">
179
- <script uri="comp1.bs" />
180
- </component>
181
- `);
182
- //import the function here
183
- const file = program.setFile('components/comp1.bs', `
184
- sub init()
185
- kitty = new Animals.Cat()
186
- end sub
187
- `);
188
- program.setFile('source/Animals.bs', `
189
- namespace Animals
190
- class Cat
191
- end class
192
- end namespace
193
- `);
194
- program.validate();
195
- (0, chai_config_spec_1.expect)(program.getCodeActions(file.srcPath,
196
- // new Anim|als.Cat()
197
- util_1.util.createRange(2, 36, 2, 36)).map(x => x.title).sort()).to.eql([
198
- `import "pkg:/source/Animals.bs"`
199
- ]);
200
- });
201
- it('suggests all files for a root namespace name', () => {
202
- program.setFile('source/first.bs', `
203
- namespace alpha
204
- function firstAction()
205
- end function
206
- end namespace
207
- `);
208
- program.setFile('source/second.bs', `
209
- namespace alpha.beta
210
- function secondAction()
211
- end function
212
- end namespace
213
- `);
214
- program.setFile('components/MainScene.xml', (0, testHelpers_spec_1.trim) `<component name="MainScene"></component>`);
215
- const file = program.setFile('components/MainScene.bs', `
216
- sub init()
217
- print alpha.secondAction()
218
- end sub
219
- `);
220
- // print al|pha.secondAction()
221
- testGetCodeActions(file, util_1.util.createRange(2, 28, 2, 28), [
222
- `import "pkg:/source/first.bs"`,
223
- `import "pkg:/source/second.bs"`
224
- ]);
225
- });
226
- it('clears suggestedImports after process() so the same instance could be reused in the future', () => {
227
- program.setFile('source/lib.bs', `
228
- function doSomething()
229
- end function
230
- `);
231
- program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
232
- <?xml version="1.0" encoding="utf-8" ?>
233
- <component name="comp1" extends="Scene">
234
- <script uri="comp1.bs" />
235
- </component>
236
- `);
237
- const file = program.setFile('components/comp1.bs', `
238
- sub init()
239
- doSomething()
240
- end sub
241
- `);
242
- program.validate();
243
- const range = util_1.util.createRange(2, 24, 2, 24);
244
- const event = {
245
- program: program,
246
- file: file,
247
- range: range,
248
- scopes: program.getScopesForFile(file),
249
- diagnostics: program.getDiagnostics().filter(d => d.file === file && util_1.util.rangesIntersectOrTouch(d.range, range)),
250
- codeActions: []
251
- };
252
- const processor = new CodeActionsProcessor_1.CodeActionsProcessor(event);
253
- processor.process();
254
- const firstCallTitles = event.codeActions.map(x => x.title).sort();
255
- // Reset codeActions and call process() again on the same instance.
256
- // If suggestedImports were NOT cleared, the second call would return no import suggestions.
257
- event.codeActions = [];
258
- processor.process();
259
- const secondCallTitles = event.codeActions.map(x => x.title).sort();
260
- (0, chai_config_spec_1.expect)(secondCallTitles).to.eql(firstCallTitles);
261
- });
262
- it('suggests files for second part of missing namespace', () => {
263
- program.setFile('source/first.bs', `
264
- namespace alpha
265
- function firstAction()
266
- end function
267
- end namespace
268
- `);
269
- program.setFile('source/second.bs', `
270
- namespace alpha.beta
271
- function secondAction()
272
- end function
273
- end namespace
274
- `);
275
- program.setFile('components/MainScene.xml', (0, testHelpers_spec_1.trim) `<component name="MainScene"></component>`);
276
- const file = program.setFile('components/MainScene.bs', `
277
- import "pkg:/source/first.bs"
278
- sub init()
279
- print alpha.beta.secondAction()
280
- end sub
281
- `);
282
- // print alpha.be|ta.secondAction()
283
- testGetCodeActions(file, util_1.util.createRange(3, 34, 3, 34), [`import "pkg:/source/second.bs"`]);
284
- });
285
- });
286
- describe('Fix all: Auto fixable missing imports', () => {
287
- it('offers fix-all when multiple unambiguous imports are missing', () => {
288
- program.setFile('source/lib1.bs', `
289
- function doSomething()
290
- end function
291
- `);
292
- program.setFile('source/lib2.bs', `
293
- function doSomethingElse()
294
- end function
295
- `);
296
- program.setFile('components/MainScene.xml', (0, testHelpers_spec_1.trim) `<component name="MainScene"></component>`);
297
- const file = program.setFile('components/MainScene.bs', `
298
- sub init()
299
- doSomething()
300
- doSomethingElse()
301
- end sub
302
- `);
303
- // doSome|thing()
304
- testGetCodeActions(file, util_1.util.createRange(2, 26, 2, 26), [
305
- `Fix all: Auto fixable missing imports`,
306
- `import "pkg:/source/lib1.bs"`
307
- ]);
308
- });
309
- it('does not offer fix-all when only one import is missing', () => {
310
- program.setFile('source/lib1.bs', `
311
- function doSomething()
312
- end function
313
- `);
314
- program.setFile('components/MainScene.xml', (0, testHelpers_spec_1.trim) `<component name="MainScene"></component>`);
315
- const file = program.setFile('components/MainScene.bs', `
316
- sub init()
317
- doSomething()
318
- end sub
319
- `);
320
- // doSome|thing()
321
- testGetCodeActions(file, util_1.util.createRange(2, 26, 2, 26), [
322
- `import "pkg:/source/lib1.bs"`
323
- ]);
324
- });
325
- it('excludes ambiguous names from fix-all', () => {
326
- program.setFile('source/lib1.bs', `
327
- function doSomething()
328
- end function
329
- `);
330
- program.setFile('source/lib2.bs', `
331
- function doSomething()
332
- end function
333
- `);
334
- program.setFile('source/lib3.bs', `
335
- function doSomethingUnambiguous()
336
- end function
337
- `);
338
- program.setFile('components/MainScene.xml', (0, testHelpers_spec_1.trim) `<component name="MainScene"></component>`);
339
- const file = program.setFile('components/MainScene.bs', `
340
- sub init()
341
- doSomething()
342
- doSomethingUnambiguous()
343
- end sub
344
- `);
345
- program.validate();
346
- const actions = program.getCodeActions(file.srcPath, util_1.util.createRange(2, 26, 2, 26));
347
- // fix-all only has the unambiguous import, not doSomething (which has 2 options)
348
- const fixAll = actions.find(a => a.title === 'Fix all: Auto fixable missing imports');
349
- (0, chai_config_spec_1.expect)(fixAll).to.be.undefined;
350
- });
351
- it('includes class imports in fix-all', () => {
352
- program.setFile('source/lib1.bs', `
353
- function doSomething()
354
- end function
355
- `);
356
- program.setFile('source/MyClass.bs', `
357
- class MyClass
358
- end class
359
- `);
360
- program.setFile('components/MainScene.xml', (0, testHelpers_spec_1.trim) `<component name="MainScene"></component>`);
361
- const file = program.setFile('components/MainScene.bs', `
362
- sub init()
363
- doSomething()
364
- obj = new MyClass()
365
- end sub
366
- `);
367
- // doSome|thing()
368
- testGetCodeActions(file, util_1.util.createRange(2, 26, 2, 26), [
369
- `Fix all: Auto fixable missing imports`,
370
- `import "pkg:/source/lib1.bs"`
371
- ]);
372
- });
373
- it('deduplicates when multiple missing names resolve to the same file', () => {
374
- program.setFile('source/lib1.bs', `
375
- function doSomething()
376
- end function
377
- function doSomethingElse()
378
- end function
379
- `);
380
- program.setFile('source/lib2.bs', `
381
- function doThird()
382
- end function
383
- `);
384
- program.setFile('components/MainScene.xml', (0, testHelpers_spec_1.trim) `<component name="MainScene"></component>`);
385
- const file = program.setFile('components/MainScene.bs', `
386
- sub init()
387
- doSomething()
388
- doSomethingElse()
389
- doThird()
390
- end sub
391
- `);
392
- program.validate();
393
- const actions = program.getCodeActions(file.srcPath, util_1.util.createRange(2, 26, 2, 26));
394
- const fixAll = actions.find(a => a.title === 'Fix all: Auto fixable missing imports');
395
- // lib1.bs and lib2.bs — only 2 changes despite 3 missing names
396
- (0, chai_config_spec_1.expect)(Object.values(fixAll.edit.changes)[0]).to.have.lengthOf(2);
397
- });
398
- });
399
- it('suggests imports at very start and very end of diagnostic', () => {
400
- program.setFile('source/first.bs', `
401
- namespace alpha
402
- function firstAction()
403
- end function
404
- end namespace
405
- `);
406
- program.setFile('components/MainScene.xml', (0, testHelpers_spec_1.trim) `<component name="MainScene"></component>`);
407
- const file = program.setFile('components/MainScene.bs', `
408
- sub init()
409
- print alpha.firstAction()
410
- end sub
411
- `);
412
- // print |alpha.firstAction()
413
- testGetCodeActions(file, util_1.util.createRange(2, 22, 2, 22), [`import "pkg:/source/first.bs"`]);
414
- // print alpha|.firstAction()
415
- testGetCodeActions(file, util_1.util.createRange(2, 27, 2, 27), [`import "pkg:/source/first.bs"`]);
416
- });
417
- describe('void function return value', () => {
418
- it('suggests deleting the return value and converting the sub to a function', () => {
419
- const file = program.setFile('source/main.brs', `
420
- sub test()
421
- 'should not have a return value here...
422
- return true
423
- end sub
424
- `);
425
- // return tr|ue
426
- testGetCodeActions(file, util_1.util.createRange(3, 29, 3, 29), [`Convert sub to function`, `Remove return value`]);
427
- });
428
- it('suggests converting sub to function with inline body', () => {
429
- const file = program.setFile('source/main.brs', `
430
- sub test() : print "onItemContentChange"
431
- return true
432
- end sub
433
- `);
434
- // return tr|ue
435
- testGetCodeActions(file, util_1.util.createRange(2, 28, 2, 28), [`Convert sub to function`, `Remove return value`]);
436
- // verify only the `sub` and `end sub` keywords are replaced, not the `: print ...` inline body
437
- program.validate();
438
- const actions = program.getCodeActions(file.srcPath, util_1.util.createRange(2, 28, 2, 28));
439
- const convertAction = actions.find(a => a.title === 'Convert sub to function');
440
- const changes = Object.values(convertAction.edit.changes)[0];
441
- // change[0] replaces `sub` keyword only
442
- (0, chai_config_spec_1.expect)(changes[0].range).to.eql(util_1.util.createRange(1, 16, 1, 19));
443
- (0, chai_config_spec_1.expect)(changes[0].newText).to.eql('function');
444
- // change[1] replaces `end sub` keyword only
445
- (0, chai_config_spec_1.expect)(changes[1].range).to.eql(util_1.util.createRange(3, 16, 3, 23));
446
- (0, chai_config_spec_1.expect)(changes[1].newText).to.eql('end function');
447
- });
448
- it('suggests deleting the return type from void function', () => {
449
- const file = program.setFile('source/main.brs', `
450
- function test() as void
451
- 'should not have a return value here...
452
- return true
453
- end function
454
- `);
455
- // return tr|ue
456
- testGetCodeActions(file, util_1.util.createRange(3, 29, 3, 29), [`Remove return type from function declaration`, `Remove return value`]);
457
- });
458
- it('suggests deleting only the return type from void function with inline body', () => {
459
- const file = program.setFile('source/main.brs', `
460
- function test() as void : print "onItemContentChange"
461
- return "test"
462
- end function
463
- `);
464
- // return |"test"
465
- testGetCodeActions(file, util_1.util.createRange(2, 28, 2, 28), [`Remove return type from function declaration`, `Remove return value`]);
466
- // verify only ` as void` is deleted, not the `: print ...` inline body
467
- program.validate();
468
- const actions = program.getCodeActions(file.srcPath, util_1.util.createRange(2, 28, 2, 28));
469
- const removeTypeAction = actions.find(a => a.title === 'Remove return type from function declaration');
470
- const changes = Object.values(removeTypeAction.edit.changes)[0];
471
- // range should span ` as void` only, starting after `)` and ending at the close of `void`
472
- (0, chai_config_spec_1.expect)(changes[0].range).to.eql(util_1.util.createRange(1, 31, 1, 39));
473
- });
474
- it('offers fix-all when multiple void-return violations exist in the file', () => {
475
- const file = program.setFile('source/main.brs', `
476
- sub test1()
477
- return true
478
- end sub
479
- sub test2()
480
- return false
481
- end sub
482
- `);
483
- // return tr|ue (first violation)
484
- testGetCodeActions(file, util_1.util.createRange(2, 27, 2, 27), [
485
- `Convert sub to function`,
486
- `Fix all: Remove void return values`,
487
- `Remove return value`
488
- ]);
489
- });
490
- it('does not offer fix-all when only one void-return violation exists', () => {
491
- const file = program.setFile('source/main.brs', `
492
- sub test1()
493
- return true
494
- end sub
495
- sub test2()
496
- end sub
497
- `);
498
- // return tr|ue
499
- testGetCodeActions(file, util_1.util.createRange(2, 27, 2, 27), [`Convert sub to function`, `Remove return value`]);
500
- });
501
- it('does not duplicate fix-all when multiple violations are at the cursor range', () => {
502
- const file = program.setFile('source/main.brs', `
503
- sub test1()
504
- return true
505
- end sub
506
- sub test2()
507
- return false
508
- end sub
509
- `);
510
- program.validate();
511
- const actions = program.getCodeActions(file.srcPath, util_1.util.createRange(2, 20, 4, 20));
512
- (0, chai_config_spec_1.expect)(actions.filter(a => a.title === 'Fix all: Remove void return values')).to.have.lengthOf(1);
513
- });
514
- });
515
- describe('typed function/sub empty return', () => {
516
- it('suggests deleting the return value and converting the sub to a function', () => {
517
- const file = program.setFile('source/main.brs', `
518
- function test()
519
- 'need a return value here...
520
- return
521
- end function
522
- `);
523
- // ret|urn
524
- testGetCodeActions(file, util_1.util.createRange(3, 23, 3, 23), [`Add void return type to function declaration`, `Convert function to sub`]);
525
- });
526
- it('suggests adding void return type to function with inline body', () => {
527
- const file = program.setFile('source/main.brs', `
528
- function test() : print "onItemContentChange"
529
- return
530
- end function
531
- `);
532
- // ret|urn
533
- testGetCodeActions(file, util_1.util.createRange(2, 23, 2, 23), [`Add void return type to function declaration`, `Convert function to sub`]);
534
- // verify ` as void` is inserted after `)`, not after the inline body
535
- program.validate();
536
- const actions = program.getCodeActions(file.srcPath, util_1.util.createRange(2, 23, 2, 23));
537
- const addVoidAction = actions.find(a => a.title === 'Add void return type to function declaration');
538
- const changes = Object.values(addVoidAction.edit.changes)[0];
539
- // insert position should be immediately after `)`, before ` : print ...`
540
- (0, chai_config_spec_1.expect)(changes[0].range).to.eql(util_1.util.createRange(1, 31, 1, 31));
541
- (0, chai_config_spec_1.expect)(changes[0].newText).to.eql(' as void');
542
- });
543
- it('suggests deleting the return type from void function', () => {
544
- const file = program.setFile('source/main.brs', `
545
- sub test() as integer
546
- 'need a return value here...
547
- return
548
- end sub
549
- `);
550
- // ret|urn
551
- testGetCodeActions(file, util_1.util.createRange(3, 23, 3, 23), [`Remove return type from sub declaration`]);
552
- });
553
- it('suggests deleting only the return type from sub with inline body', () => {
554
- const file = program.setFile('source/main.brs', `
555
- sub test() as integer : print "onItemContentChange"
556
- return
557
- end sub
558
- `);
559
- // ret|urn
560
- testGetCodeActions(file, util_1.util.createRange(2, 23, 2, 23), [`Remove return type from sub declaration`]);
561
- // verify only ` as integer` is deleted, not the `: print ...` inline body
562
- program.validate();
563
- const actions = program.getCodeActions(file.srcPath, util_1.util.createRange(2, 23, 2, 23));
564
- const removeTypeAction = actions.find(a => a.title === 'Remove return type from sub declaration');
565
- const changes = Object.values(removeTypeAction.edit.changes)[0];
566
- // range should span ` as integer` only, starting after `)` and ending at the close of `integer`
567
- (0, chai_config_spec_1.expect)(changes[0].range).to.eql(util_1.util.createRange(1, 26, 1, 37));
568
- });
569
- it('offers fix-all for multiple subs with return types', () => {
570
- const file = program.setFile('source/main.brs', `
571
- sub test1() as integer
572
- return
573
- end sub
574
- sub test2() as string
575
- return
576
- end sub
577
- `);
578
- // ret|urn (first violation)
579
- testGetCodeActions(file, util_1.util.createRange(2, 24, 2, 24), [
580
- `Fix all: Remove return type from sub declarations`,
581
- `Remove return type from sub declaration`
582
- ]);
583
- });
584
- it('offers fix-all for multiple functions with missing return types', () => {
585
- const file = program.setFile('source/main.brs', `
586
- function test1()
587
- return
588
- end function
589
- function test2()
590
- return
591
- end function
592
- `);
593
- // ret|urn (first violation)
594
- testGetCodeActions(file, util_1.util.createRange(2, 24, 2, 24), [
595
- `Add void return type to function declaration`,
596
- `Convert function to sub`,
597
- `Fix all: Add void return type to function declarations`
598
- ]);
599
- });
600
- it('does not offer fix-all when only one non-void-return violation exists', () => {
601
- const file = program.setFile('source/main.brs', `
602
- sub test1() as integer
603
- return
604
- end sub
605
- `);
606
- // ret|urn
607
- testGetCodeActions(file, util_1.util.createRange(2, 24, 2, 24), [`Remove return type from sub declaration`]);
608
- });
609
- it('deduplicates fix-all changes when one function has multiple bare returns', () => {
610
- const file = program.setFile('source/main.brs', `
611
- sub test1() as integer
612
- return
613
- return
614
- end sub
615
- sub test2() as string
616
- return
617
- end sub
618
- `);
619
- program.validate();
620
- const actions = program.getCodeActions(file.srcPath, util_1.util.createRange(2, 24, 2, 24));
621
- const fixAll = actions.find(a => a.title === 'Fix all: Remove return type from sub declarations');
622
- // Two unique functions → two changes (not three)
623
- (0, chai_config_spec_1.expect)(Object.values(fixAll.edit.changes)[0]).to.have.lengthOf(2);
624
- });
625
- });
626
- describe('referencedFileDoesNotExist', () => {
627
- it('offers to remove the script import line', () => {
628
- const file = program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
629
- <?xml version="1.0" encoding="utf-8" ?>
630
- <component name="comp1" extends="Scene">
631
- <script type="text/brightscript" uri="pkg:/source/missing.brs" />
632
- </component>
633
- `);
634
- // uri="pkg:/source/missing.brs" is on line 2
635
- testGetCodeActions(file, util_1.util.createRange(2, 50, 2, 50), ['Remove script import']);
636
- });
637
- it('deletes the entire script tag line', () => {
638
- const file = program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
639
- <?xml version="1.0" encoding="utf-8" ?>
640
- <component name="comp1" extends="Scene">
641
- <script type="text/brightscript" uri="pkg:/source/missing.brs" />
642
- </component>
643
- `);
644
- program.validate();
645
- (0, testHelpers_spec_1.expectCodeActions)(() => {
646
- program.getCodeActions(file.srcPath, util_1.util.createRange(2, 50, 2, 50));
647
- }, [{
648
- title: 'Remove script import',
649
- kind: 'quickfix',
650
- changes: [{
651
- type: 'delete',
652
- filePath: (0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/components/comp1.xml`,
653
- range: util_1.util.createRange(2, 0, 3, 0)
654
- }]
655
- }]);
656
- });
657
- it('offers fix-all when multiple missing imports exist', () => {
658
- const file = program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
659
- <?xml version="1.0" encoding="utf-8" ?>
660
- <component name="comp1" extends="Scene">
661
- <script type="text/brightscript" uri="pkg:/source/missing1.brs" />
662
- <script type="text/brightscript" uri="pkg:/source/missing2.brs" />
663
- </component>
664
- `);
665
- testGetCodeActions(file, util_1.util.createRange(2, 50, 2, 50), [
666
- 'Fix all: Remove script imports',
667
- 'Remove script import'
668
- ]);
669
- });
670
- });
671
- describe('unnecessaryScriptImportInChildFromParent', () => {
672
- it('offers to remove the redundant script import', () => {
673
- program.setFile('components/parent.xml', (0, testHelpers_spec_1.trim) `
674
- <?xml version="1.0" encoding="utf-8" ?>
675
- <component name="ParentScene" extends="Scene">
676
- <script type="text/brightscript" uri="pkg:/source/lib.brs" />
677
- </component>
678
- `);
679
- program.setFile('source/lib.brs', '');
680
- const file = program.setFile('components/child.xml', (0, testHelpers_spec_1.trim) `
681
- <?xml version="1.0" encoding="utf-8" ?>
682
- <component name="ChildScene" extends="ParentScene">
683
- <script type="text/brightscript" uri="pkg:/source/lib.brs" />
684
- </component>
685
- `);
686
- // uri on line 2 of child.xml
687
- testGetCodeActions(file, util_1.util.createRange(2, 50, 2, 50), ['Remove redundant script import']);
688
- });
689
- it('offers fix-all when multiple redundant imports exist', () => {
690
- program.setFile('components/parent.xml', (0, testHelpers_spec_1.trim) `
691
- <?xml version="1.0" encoding="utf-8" ?>
692
- <component name="ParentScene" extends="Scene">
693
- <script type="text/brightscript" uri="pkg:/source/lib1.brs" />
694
- <script type="text/brightscript" uri="pkg:/source/lib2.brs" />
695
- </component>
696
- `);
697
- program.setFile('source/lib1.brs', '');
698
- program.setFile('source/lib2.brs', '');
699
- const file = program.setFile('components/child.xml', (0, testHelpers_spec_1.trim) `
700
- <?xml version="1.0" encoding="utf-8" ?>
701
- <component name="ChildScene" extends="ParentScene">
702
- <script type="text/brightscript" uri="pkg:/source/lib1.brs" />
703
- <script type="text/brightscript" uri="pkg:/source/lib2.brs" />
704
- </component>
705
- `);
706
- testGetCodeActions(file, util_1.util.createRange(2, 50, 2, 50), [
707
- 'Fix all: Remove redundant script imports',
708
- 'Remove redundant script import'
709
- ]);
710
- });
711
- });
712
- describe('unnecessaryCodebehindScriptImport', () => {
713
- it('offers to remove the unnecessary codebehind import', () => {
714
- const file = program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
715
- <?xml version="1.0" encoding="utf-8" ?>
716
- <component name="comp1" extends="Scene">
717
- <script type="text/brightscript" uri="pkg:/components/comp1.brs" />
718
- </component>
719
- `);
720
- program.setFile('components/comp1.brs', '');
721
- // uri on line 2
722
- testGetCodeActions(file, util_1.util.createRange(2, 50, 2, 50), ['Remove unnecessary codebehind import']);
723
- });
724
- });
725
- describe('scriptImportCaseMismatch', () => {
726
- it('offers to fix the casing of the script import path', () => {
727
- const file = program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
728
- <?xml version="1.0" encoding="utf-8" ?>
729
- <component name="comp1" extends="Scene">
730
- <script type="text/brightscript" uri="pkg:/SOURCE/lib.brs" />
731
- </component>
732
- `);
733
- program.setFile('source/lib.brs', '');
734
- testGetCodeActions(file, util_1.util.createRange(2, 50, 2, 50), ['Fix script import path casing']);
735
- });
736
- it('replaces the URI value with the correctly-cased path', () => {
737
- const file = program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
738
- <?xml version="1.0" encoding="utf-8" ?>
739
- <component name="comp1" extends="Scene">
740
- <script type="text/brightscript" uri="pkg:/SOURCE/lib.brs" />
741
- </component>
742
- `);
743
- program.setFile('source/lib.brs', '');
744
- program.validate();
745
- const actions = program.getCodeActions(file.srcPath, util_1.util.createRange(2, 50, 2, 50));
746
- const fix = actions.find(a => a.title === 'Fix script import path casing');
747
- const changes = Object.values(fix.edit.changes)[0];
748
- (0, chai_config_spec_1.expect)(changes[0].newText).to.equal('pkg:/source/lib.brs');
749
- });
750
- it('offers fix-all when multiple case-mismatched imports exist', () => {
751
- const file = program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
752
- <?xml version="1.0" encoding="utf-8" ?>
753
- <component name="comp1" extends="Scene">
754
- <script type="text/brightscript" uri="pkg:/SOURCE/lib1.brs" />
755
- <script type="text/brightscript" uri="pkg:/SOURCE/lib2.brs" />
756
- </component>
757
- `);
758
- program.setFile('source/lib1.brs', '');
759
- program.setFile('source/lib2.brs', '');
760
- testGetCodeActions(file, util_1.util.createRange(2, 50, 2, 50), [
761
- 'Fix all: Fix script import path casing',
762
- 'Fix script import path casing'
763
- ]);
764
- });
765
- it('offers to fix the casing of a relative script import path', () => {
766
- const file = program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
767
- <?xml version="1.0" encoding="utf-8" ?>
768
- <component name="comp1" extends="Scene">
769
- <script type="text/brightscript" uri="LIB.brs" />
770
- </component>
771
- `);
772
- program.setFile('components/lib.brs', '');
773
- testGetCodeActions(file, util_1.util.createRange(2, 45, 2, 45), ['Fix script import path casing']);
774
- });
775
- it('replaces a relative URI with the correctly-cased relative path', () => {
776
- const file = program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
777
- <?xml version="1.0" encoding="utf-8" ?>
778
- <component name="comp1" extends="Scene">
779
- <script type="text/brightscript" uri="LIB.brs" />
780
- </component>
781
- `);
782
- program.setFile('components/lib.brs', '');
783
- program.validate();
784
- const actions = program.getCodeActions(file.srcPath, util_1.util.createRange(2, 45, 2, 45));
785
- const fix = actions.find(a => a.title === 'Fix script import path casing');
786
- const changes = Object.values(fix.edit.changes)[0];
787
- (0, chai_config_spec_1.expect)(changes[0].newText).to.equal('lib.brs');
788
- });
789
- it('replaces a cross-directory relative URI with the correctly-cased relative path', () => {
790
- const file = program.setFile('components/sub/comp1.xml', (0, testHelpers_spec_1.trim) `
791
- <?xml version="1.0" encoding="utf-8" ?>
792
- <component name="comp1" extends="Scene">
793
- <script type="text/brightscript" uri="../utils/HELPER.brs" />
794
- </component>
795
- `);
796
- program.setFile('components/utils/helper.brs', '');
797
- program.validate();
798
- const actions = program.getCodeActions(file.srcPath, util_1.util.createRange(2, 50, 2, 50));
799
- const fix = actions.find(a => a.title === 'Fix script import path casing');
800
- const changes = Object.values(fix.edit.changes)[0];
801
- (0, chai_config_spec_1.expect)(changes[0].newText).to.equal('../utils/helper.brs');
802
- });
803
- });
804
- describe('missingOverrideKeyword', () => {
805
- it('offers to add the override keyword', () => {
806
- program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `<component name="comp1" extends="Scene"></component>`);
807
- const file = program.setFile('components/comp1.bs', `
808
- class Animal
809
- function speak()
810
- end function
811
- end class
812
- class Dog extends Animal
813
- function speak()
814
- end function
815
- end class
816
- `);
817
- // "function speak()" in Dog — diagnostic starts at the function keyword on line 6
818
- testGetCodeActions(file, util_1.util.createRange(6, 20, 6, 20), [`Add missing 'override' keyword`]);
819
- });
820
- it('inserts override before the function keyword', () => {
821
- program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `<component name="comp1" extends="Scene"></component>`);
822
- const file = program.setFile('components/comp1.bs', `
823
- class Animal
824
- function speak()
825
- end function
826
- end class
827
- class Dog extends Animal
828
- function speak()
829
- end function
830
- end class
831
- `);
832
- program.validate();
833
- const actions = program.getCodeActions(file.srcPath, util_1.util.createRange(6, 20, 6, 20));
834
- const fix = actions.find(a => a.title === `Add missing 'override' keyword`);
835
- const changes = Object.values(fix.edit.changes)[0];
836
- (0, chai_config_spec_1.expect)(changes[0].newText).to.equal('override ');
837
- });
838
- it('offers fix-all when multiple methods are missing override', () => {
839
- program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `<component name="comp1" extends="Scene"></component>`);
840
- const file = program.setFile('components/comp1.bs', `
841
- class Animal
842
- function speak()
843
- end function
844
- function move()
845
- end function
846
- end class
847
- class Dog extends Animal
848
- function speak()
849
- end function
850
- function move()
851
- end function
852
- end class
853
- `);
854
- testGetCodeActions(file, util_1.util.createRange(8, 20, 8, 20), [
855
- `Add missing 'override' keyword`,
856
- `Fix all: Add missing 'override' keywords`
857
- ]);
858
- });
859
- });
860
- describe('cannotUseOverrideKeywordOnConstructorFunction', () => {
861
- it('offers to remove override from constructor', () => {
862
- const file = program.setFile('source/main.bs', `
863
- class Dog
864
- override function new()
865
- end function
866
- end class
867
- `);
868
- // "override" is on line 2
869
- testGetCodeActions(file, util_1.util.createRange(2, 20, 2, 20), [`Remove 'override' from constructor`]);
870
- });
871
- it('deletes the override keyword and trailing space', () => {
872
- const file = program.setFile('source/main.bs', `
873
- class Dog
874
- override function new()
875
- end function
876
- end class
877
- `);
878
- program.validate();
879
- const actions = program.getCodeActions(file.srcPath, util_1.util.createRange(2, 20, 2, 20));
880
- const fix = actions.find(a => a.title === `Remove 'override' from constructor`);
881
- const changes = Object.values(fix.edit.changes)[0];
882
- // range covers "override " (8 chars + 1 space)
883
- (0, chai_config_spec_1.expect)(changes[0].range.start.character).to.equal(changes[0].range.end.character - 9);
884
- });
885
- });
886
- });
887
- //# sourceMappingURL=CodeActionsProcessor.spec.js.map