brighterscript 1.0.0-alpha.5 → 1.0.0-alpha.51

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 (652) hide show
  1. package/README.md +79 -138
  2. package/bsconfig.schema.json +196 -5
  3. package/dist/ActionPipeline.d.ts +10 -0
  4. package/dist/ActionPipeline.js +40 -0
  5. package/dist/ActionPipeline.js.map +1 -0
  6. package/dist/AstValidationSegmenter.d.ts +45 -0
  7. package/dist/AstValidationSegmenter.js +322 -0
  8. package/dist/AstValidationSegmenter.js.map +1 -0
  9. package/dist/BsConfig.d.ts +161 -43
  10. package/dist/BusyStatusTracker.d.ts +61 -0
  11. package/dist/BusyStatusTracker.js +148 -0
  12. package/dist/BusyStatusTracker.js.map +1 -0
  13. package/dist/Cache.d.ts +3 -8
  14. package/dist/Cache.js +9 -14
  15. package/dist/Cache.js.map +1 -1
  16. package/dist/CacheVerifier.d.ts +7 -0
  17. package/dist/CacheVerifier.js +20 -0
  18. package/dist/CacheVerifier.js.map +1 -0
  19. package/dist/CodeActionUtil.d.ts +29 -4
  20. package/dist/CodeActionUtil.js +22 -5
  21. package/dist/CodeActionUtil.js.map +1 -1
  22. package/dist/CommentFlagProcessor.d.ts +20 -15
  23. package/dist/CommentFlagProcessor.js +143 -58
  24. package/dist/CommentFlagProcessor.js.map +1 -1
  25. package/dist/CrossScopeValidator.d.ts +68 -0
  26. package/dist/CrossScopeValidator.js +650 -0
  27. package/dist/CrossScopeValidator.js.map +1 -0
  28. package/dist/DependencyGraph.d.ts +8 -3
  29. package/dist/DependencyGraph.js +49 -16
  30. package/dist/DependencyGraph.js.map +1 -1
  31. package/dist/DiagnosticCollection.d.ts +21 -5
  32. package/dist/DiagnosticCollection.js +77 -24
  33. package/dist/DiagnosticCollection.js.map +1 -1
  34. package/dist/DiagnosticFilterer.d.ts +27 -6
  35. package/dist/DiagnosticFilterer.js +273 -60
  36. package/dist/DiagnosticFilterer.js.map +1 -1
  37. package/dist/DiagnosticManager.d.ts +83 -0
  38. package/dist/DiagnosticManager.js +422 -0
  39. package/dist/DiagnosticManager.js.map +1 -0
  40. package/dist/DiagnosticMessages.d.ts +602 -196
  41. package/dist/DiagnosticMessages.js +926 -342
  42. package/dist/DiagnosticMessages.js.map +1 -1
  43. package/dist/DiagnosticSeverityAdjuster.d.ts +7 -0
  44. package/dist/DiagnosticSeverityAdjuster.js +45 -0
  45. package/dist/DiagnosticSeverityAdjuster.js.map +1 -0
  46. package/dist/FunctionScope.d.ts +28 -0
  47. package/dist/FunctionScope.js +52 -0
  48. package/dist/FunctionScope.js.map +1 -0
  49. package/dist/KeyedThrottler.d.ts +3 -3
  50. package/dist/KeyedThrottler.js +3 -3
  51. package/dist/KeyedThrottler.js.map +1 -1
  52. package/dist/LanguageServer.d.ts +136 -104
  53. package/dist/LanguageServer.js +577 -741
  54. package/dist/LanguageServer.js.map +1 -1
  55. package/dist/Logger.d.ts +17 -13
  56. package/dist/Logger.js +64 -34
  57. package/dist/Logger.js.map +1 -1
  58. package/dist/PluginInterface.d.ts +32 -10
  59. package/dist/PluginInterface.js +117 -7
  60. package/dist/PluginInterface.js.map +1 -1
  61. package/dist/Program.d.ts +302 -98
  62. package/dist/Program.js +1613 -726
  63. package/dist/Program.js.map +1 -1
  64. package/dist/ProgramBuilder.d.ts +39 -22
  65. package/dist/ProgramBuilder.js +245 -179
  66. package/dist/ProgramBuilder.js.map +1 -1
  67. package/dist/Scope.d.ts +227 -106
  68. package/dist/Scope.js +609 -557
  69. package/dist/Scope.js.map +1 -1
  70. package/dist/ScopeNamespaceLookup.d.ts +73 -0
  71. package/dist/ScopeNamespaceLookup.js +242 -0
  72. package/dist/ScopeNamespaceLookup.js.map +1 -0
  73. package/dist/SemanticTokenUtils.js +5 -1
  74. package/dist/SemanticTokenUtils.js.map +1 -1
  75. package/dist/Stopwatch.d.ts +4 -0
  76. package/dist/Stopwatch.js +8 -1
  77. package/dist/Stopwatch.js.map +1 -1
  78. package/dist/SymbolTable.d.ts +145 -26
  79. package/dist/SymbolTable.js +575 -64
  80. package/dist/SymbolTable.js.map +1 -1
  81. package/dist/SymbolTypeFlag.d.ts +9 -0
  82. package/dist/SymbolTypeFlag.js +14 -0
  83. package/dist/SymbolTypeFlag.js.map +1 -0
  84. package/dist/Throttler.d.ts +12 -0
  85. package/dist/Throttler.js +39 -0
  86. package/dist/Throttler.js.map +1 -1
  87. package/dist/Watcher.d.ts +0 -3
  88. package/dist/Watcher.js +0 -3
  89. package/dist/Watcher.js.map +1 -1
  90. package/dist/XmlScope.d.ts +5 -15
  91. package/dist/XmlScope.js +34 -90
  92. package/dist/XmlScope.js.map +1 -1
  93. package/dist/astUtils/CachedLookups.d.ts +50 -0
  94. package/dist/astUtils/CachedLookups.js +337 -0
  95. package/dist/astUtils/CachedLookups.js.map +1 -0
  96. package/dist/astUtils/Editor.d.ts +69 -0
  97. package/dist/astUtils/Editor.js +245 -0
  98. package/dist/astUtils/Editor.js.map +1 -0
  99. package/dist/astUtils/creators.d.ts +54 -19
  100. package/dist/astUtils/creators.js +242 -42
  101. package/dist/astUtils/creators.js.map +1 -1
  102. package/dist/astUtils/reflection.d.ts +199 -85
  103. package/dist/astUtils/reflection.js +518 -145
  104. package/dist/astUtils/reflection.js.map +1 -1
  105. package/dist/astUtils/stackedVisitor.js.map +1 -1
  106. package/dist/astUtils/visitors.d.ts +117 -53
  107. package/dist/astUtils/visitors.js +95 -15
  108. package/dist/astUtils/visitors.js.map +1 -1
  109. package/dist/astUtils/xml.d.ts +9 -8
  110. package/dist/astUtils/xml.js +12 -7
  111. package/dist/astUtils/xml.js.map +1 -1
  112. package/dist/bscPlugin/BscPlugin.d.ts +26 -4
  113. package/dist/bscPlugin/BscPlugin.js +96 -4
  114. package/dist/bscPlugin/BscPlugin.js.map +1 -1
  115. package/dist/bscPlugin/CallExpressionInfo.d.ts +36 -0
  116. package/dist/bscPlugin/CallExpressionInfo.js +142 -0
  117. package/dist/bscPlugin/CallExpressionInfo.js.map +1 -0
  118. package/dist/bscPlugin/FileWriter.d.ts +19 -0
  119. package/dist/bscPlugin/FileWriter.js +79 -0
  120. package/dist/bscPlugin/FileWriter.js.map +1 -0
  121. package/dist/bscPlugin/SignatureHelpUtil.d.ts +10 -0
  122. package/dist/bscPlugin/SignatureHelpUtil.js +137 -0
  123. package/dist/bscPlugin/SignatureHelpUtil.js.map +1 -0
  124. package/dist/bscPlugin/codeActions/CodeActionsProcessor.d.ts +109 -7
  125. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +676 -26
  126. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  127. package/dist/bscPlugin/codeActions/FixAllCodeActionsProcessor.d.ts +17 -0
  128. package/dist/bscPlugin/codeActions/FixAllCodeActionsProcessor.js +66 -0
  129. package/dist/bscPlugin/codeActions/FixAllCodeActionsProcessor.js.map +1 -0
  130. package/dist/bscPlugin/codeActions/codeActionHelpers.d.ts +18 -0
  131. package/dist/bscPlugin/codeActions/codeActionHelpers.js +31 -0
  132. package/dist/bscPlugin/codeActions/codeActionHelpers.js.map +1 -0
  133. package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +65 -0
  134. package/dist/bscPlugin/completions/CompletionsProcessor.js +633 -0
  135. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -0
  136. package/dist/bscPlugin/definition/DefinitionProvider.d.ts +13 -0
  137. package/dist/bscPlugin/definition/DefinitionProvider.js +220 -0
  138. package/dist/bscPlugin/definition/DefinitionProvider.js.map +1 -0
  139. package/dist/bscPlugin/fileProviders/FileProvider.d.ts +9 -0
  140. package/dist/bscPlugin/fileProviders/FileProvider.js +51 -0
  141. package/dist/bscPlugin/fileProviders/FileProvider.js.map +1 -0
  142. package/dist/bscPlugin/hover/HoverProcessor.d.ts +18 -0
  143. package/dist/bscPlugin/hover/HoverProcessor.js +238 -0
  144. package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -0
  145. package/dist/bscPlugin/references/ReferencesProvider.d.ts +12 -0
  146. package/dist/bscPlugin/references/ReferencesProvider.js +57 -0
  147. package/dist/bscPlugin/references/ReferencesProvider.js.map +1 -0
  148. package/dist/bscPlugin/selectionRanges/SelectionRangesProcessor.d.ts +7 -0
  149. package/dist/bscPlugin/selectionRanges/SelectionRangesProcessor.js +77 -0
  150. package/dist/bscPlugin/selectionRanges/SelectionRangesProcessor.js.map +1 -0
  151. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +14 -0
  152. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +164 -0
  153. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -0
  154. package/dist/bscPlugin/serialize/BslibManager.d.ts +12 -0
  155. package/dist/bscPlugin/serialize/BslibManager.js +46 -0
  156. package/dist/bscPlugin/serialize/BslibManager.js.map +1 -0
  157. package/dist/bscPlugin/serialize/FileSerializer.d.ts +9 -0
  158. package/dist/bscPlugin/serialize/FileSerializer.js +80 -0
  159. package/dist/bscPlugin/serialize/FileSerializer.js.map +1 -0
  160. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.d.ts +7 -0
  161. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.js +22 -0
  162. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.js.map +1 -0
  163. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.d.ts +7 -0
  164. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.js +26 -0
  165. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.js.map +1 -0
  166. package/dist/bscPlugin/symbols/symbolUtils.d.ts +5 -0
  167. package/dist/bscPlugin/symbols/symbolUtils.js +141 -0
  168. package/dist/bscPlugin/symbols/symbolUtils.js.map +1 -0
  169. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.d.ts +34 -0
  170. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js +504 -0
  171. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -0
  172. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +12 -0
  173. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js +99 -0
  174. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +1 -0
  175. package/dist/bscPlugin/validation/BrsFileAfterValidator.d.ts +7 -0
  176. package/dist/bscPlugin/validation/BrsFileAfterValidator.js +18 -0
  177. package/dist/bscPlugin/validation/BrsFileAfterValidator.js.map +1 -0
  178. package/dist/bscPlugin/validation/BrsFileValidator.d.ts +51 -0
  179. package/dist/bscPlugin/validation/BrsFileValidator.js +714 -0
  180. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -0
  181. package/dist/bscPlugin/validation/ProgramValidator.d.ts +11 -0
  182. package/dist/bscPlugin/validation/ProgramValidator.js +33 -0
  183. package/dist/bscPlugin/validation/ProgramValidator.js.map +1 -0
  184. package/dist/bscPlugin/validation/ScopeValidator.d.ts +158 -0
  185. package/dist/bscPlugin/validation/ScopeValidator.js +1481 -0
  186. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -0
  187. package/dist/bscPlugin/validation/XmlFileValidator.d.ts +8 -0
  188. package/dist/bscPlugin/validation/XmlFileValidator.js +50 -0
  189. package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -0
  190. package/dist/cli.js +140 -28
  191. package/dist/cli.js.map +1 -1
  192. package/dist/common/Sequencer.d.ts +53 -0
  193. package/dist/common/Sequencer.js +233 -0
  194. package/dist/common/Sequencer.js.map +1 -0
  195. package/dist/deferred.d.ts +5 -3
  196. package/dist/deferred.js +10 -0
  197. package/dist/deferred.js.map +1 -1
  198. package/dist/diagnosticUtils.d.ts +61 -4
  199. package/dist/diagnosticUtils.js +285 -25
  200. package/dist/diagnosticUtils.js.map +1 -1
  201. package/dist/examples/plugins/removePrint.d.ts +2 -2
  202. package/dist/examples/plugins/removePrint.js +8 -12
  203. package/dist/examples/plugins/removePrint.js.map +1 -1
  204. package/dist/files/AssetFile.d.ts +24 -0
  205. package/dist/files/AssetFile.js +25 -0
  206. package/dist/files/AssetFile.js.map +1 -0
  207. package/dist/files/BrsFile.d.ts +161 -87
  208. package/dist/files/BrsFile.js +919 -936
  209. package/dist/files/BrsFile.js.map +1 -1
  210. package/dist/files/BscFile.d.ts +102 -0
  211. package/dist/files/BscFile.js +15 -0
  212. package/dist/files/BscFile.js.map +1 -0
  213. package/dist/files/Factory.d.ts +25 -0
  214. package/dist/files/Factory.js +22 -0
  215. package/dist/files/Factory.js.map +1 -0
  216. package/dist/files/LazyFileData.d.ts +21 -0
  217. package/dist/files/LazyFileData.js +54 -0
  218. package/dist/files/LazyFileData.js.map +1 -0
  219. package/dist/files/XmlFile.d.ts +80 -41
  220. package/dist/files/XmlFile.js +162 -137
  221. package/dist/files/XmlFile.js.map +1 -1
  222. package/dist/globalCallables.d.ts +3 -1
  223. package/dist/globalCallables.js +424 -184
  224. package/dist/globalCallables.js.map +1 -1
  225. package/dist/index.d.ts +32 -4
  226. package/dist/index.js +54 -7
  227. package/dist/index.js.map +1 -1
  228. package/dist/interfaces.d.ts +987 -125
  229. package/dist/interfaces.js +21 -0
  230. package/dist/interfaces.js.map +1 -1
  231. package/dist/lexer/Lexer.d.ts +51 -12
  232. package/dist/lexer/Lexer.js +214 -65
  233. package/dist/lexer/Lexer.js.map +1 -1
  234. package/dist/lexer/Token.d.ts +27 -11
  235. package/dist/lexer/Token.js +10 -2
  236. package/dist/lexer/Token.js.map +1 -1
  237. package/dist/lexer/TokenKind.d.ts +48 -2
  238. package/dist/lexer/TokenKind.js +167 -10
  239. package/dist/lexer/TokenKind.js.map +1 -1
  240. package/dist/logging.d.ts +14 -0
  241. package/dist/logging.js +29 -0
  242. package/dist/logging.js.map +1 -0
  243. package/dist/lsp/ActionQueue.d.ts +35 -0
  244. package/dist/lsp/ActionQueue.js +115 -0
  245. package/dist/lsp/ActionQueue.js.map +1 -0
  246. package/dist/lsp/DocumentManager.d.ts +63 -0
  247. package/dist/lsp/DocumentManager.js +122 -0
  248. package/dist/lsp/DocumentManager.js.map +1 -0
  249. package/dist/lsp/LspProject.d.ts +287 -0
  250. package/dist/lsp/LspProject.js +3 -0
  251. package/dist/lsp/LspProject.js.map +1 -0
  252. package/dist/lsp/PathFilterer.d.ts +75 -0
  253. package/dist/lsp/PathFilterer.js +196 -0
  254. package/dist/lsp/PathFilterer.js.map +1 -0
  255. package/dist/lsp/Project.d.ts +200 -0
  256. package/dist/lsp/Project.js +562 -0
  257. package/dist/lsp/Project.js.map +1 -0
  258. package/dist/lsp/ProjectManager.d.ts +288 -0
  259. package/dist/lsp/ProjectManager.js +967 -0
  260. package/dist/lsp/ProjectManager.js.map +1 -0
  261. package/dist/lsp/ReaderWriterManager.d.ts +21 -0
  262. package/dist/lsp/ReaderWriterManager.js +60 -0
  263. package/dist/lsp/ReaderWriterManager.js.map +1 -0
  264. package/dist/lsp/worker/MessageHandler.d.ts +99 -0
  265. package/dist/lsp/worker/MessageHandler.js +138 -0
  266. package/dist/lsp/worker/MessageHandler.js.map +1 -0
  267. package/dist/lsp/worker/WorkerPool.d.ts +38 -0
  268. package/dist/lsp/worker/WorkerPool.js +78 -0
  269. package/dist/lsp/worker/WorkerPool.js.map +1 -0
  270. package/dist/lsp/worker/WorkerThreadProject.d.ts +168 -0
  271. package/dist/lsp/worker/WorkerThreadProject.js +205 -0
  272. package/dist/lsp/worker/WorkerThreadProject.js.map +1 -0
  273. package/dist/lsp/worker/WorkerThreadProjectRunner.d.ts +15 -0
  274. package/dist/lsp/worker/WorkerThreadProjectRunner.js +58 -0
  275. package/dist/lsp/worker/WorkerThreadProjectRunner.js.map +1 -0
  276. package/dist/lsp/worker/run.js +14 -0
  277. package/dist/lsp/worker/run.js.map +1 -0
  278. package/dist/parser/AstNode.d.ts +205 -0
  279. package/dist/parser/AstNode.js +305 -0
  280. package/dist/parser/AstNode.js.map +1 -0
  281. package/dist/parser/BrightScriptDocParser.d.ts +56 -0
  282. package/dist/parser/BrightScriptDocParser.js +294 -0
  283. package/dist/parser/BrightScriptDocParser.js.map +1 -0
  284. package/dist/parser/BrsTranspileState.d.ts +22 -3
  285. package/dist/parser/BrsTranspileState.js +19 -0
  286. package/dist/parser/BrsTranspileState.js.map +1 -1
  287. package/dist/parser/Expression.d.ts +601 -220
  288. package/dist/parser/Expression.js +1516 -502
  289. package/dist/parser/Expression.js.map +1 -1
  290. package/dist/parser/Parser.d.ts +137 -121
  291. package/dist/parser/Parser.js +1808 -982
  292. package/dist/parser/Parser.js.map +1 -1
  293. package/dist/parser/SGParser.d.ts +30 -13
  294. package/dist/parser/SGParser.js +94 -56
  295. package/dist/parser/SGParser.js.map +1 -1
  296. package/dist/parser/SGTypes.d.ts +134 -46
  297. package/dist/parser/SGTypes.js +206 -115
  298. package/dist/parser/SGTypes.js.map +1 -1
  299. package/dist/parser/Statement.d.ts +854 -267
  300. package/dist/parser/Statement.js +2416 -621
  301. package/dist/parser/Statement.js.map +1 -1
  302. package/dist/parser/TranspileState.d.ts +30 -14
  303. package/dist/parser/TranspileState.js +124 -27
  304. package/dist/parser/TranspileState.js.map +1 -1
  305. package/dist/preprocessor/Manifest.d.ts +6 -6
  306. package/dist/preprocessor/Manifest.js +17 -38
  307. package/dist/preprocessor/Manifest.js.map +1 -1
  308. package/dist/roku-types/data.json +20554 -0
  309. package/dist/roku-types/index.d.ts +5726 -0
  310. package/dist/roku-types/index.js +11 -0
  311. package/dist/roku-types/index.js.map +1 -0
  312. package/dist/types/ArrayType.d.ts +12 -5
  313. package/dist/types/ArrayType.js +95 -25
  314. package/dist/types/ArrayType.js.map +1 -1
  315. package/dist/types/AssociativeArrayType.d.ts +15 -0
  316. package/dist/types/AssociativeArrayType.js +64 -0
  317. package/dist/types/AssociativeArrayType.js.map +1 -0
  318. package/dist/types/BaseFunctionType.d.ts +10 -0
  319. package/dist/types/BaseFunctionType.js +26 -0
  320. package/dist/types/BaseFunctionType.js.map +1 -0
  321. package/dist/types/BooleanType.d.ts +9 -5
  322. package/dist/types/BooleanType.js +19 -8
  323. package/dist/types/BooleanType.js.map +1 -1
  324. package/dist/types/BscType.d.ts +41 -3
  325. package/dist/types/BscType.js +152 -0
  326. package/dist/types/BscType.js.map +1 -1
  327. package/dist/types/BscTypeKind.d.ts +28 -0
  328. package/dist/types/BscTypeKind.js +33 -0
  329. package/dist/types/BscTypeKind.js.map +1 -0
  330. package/dist/types/BuiltInInterfaceAdder.d.ts +28 -0
  331. package/dist/types/BuiltInInterfaceAdder.js +212 -0
  332. package/dist/types/BuiltInInterfaceAdder.js.map +1 -0
  333. package/dist/types/CallFuncableType.d.ts +24 -0
  334. package/dist/types/CallFuncableType.js +91 -0
  335. package/dist/types/CallFuncableType.js.map +1 -0
  336. package/dist/types/ClassType.d.ts +17 -0
  337. package/dist/types/ClassType.js +63 -0
  338. package/dist/types/ClassType.js.map +1 -0
  339. package/dist/types/ComponentType.d.ts +22 -0
  340. package/dist/types/ComponentType.js +110 -0
  341. package/dist/types/ComponentType.js.map +1 -0
  342. package/dist/types/DoubleType.d.ts +10 -5
  343. package/dist/types/DoubleType.js +21 -17
  344. package/dist/types/DoubleType.js.map +1 -1
  345. package/dist/types/DynamicType.d.ts +13 -5
  346. package/dist/types/DynamicType.js +26 -5
  347. package/dist/types/DynamicType.js.map +1 -1
  348. package/dist/types/EnumType.d.ts +42 -0
  349. package/dist/types/EnumType.js +101 -0
  350. package/dist/types/EnumType.js.map +1 -0
  351. package/dist/types/FloatType.d.ts +10 -5
  352. package/dist/types/FloatType.js +21 -17
  353. package/dist/types/FloatType.js.map +1 -1
  354. package/dist/types/FunctionType.d.ts +8 -22
  355. package/dist/types/FunctionType.js +25 -63
  356. package/dist/types/FunctionType.js.map +1 -1
  357. package/dist/types/InheritableType.d.ts +29 -0
  358. package/dist/types/InheritableType.js +173 -0
  359. package/dist/types/InheritableType.js.map +1 -0
  360. package/dist/types/InlineInterfaceType.d.ts +5 -0
  361. package/dist/types/InlineInterfaceType.js +17 -0
  362. package/dist/types/InlineInterfaceType.js.map +1 -0
  363. package/dist/types/IntegerType.d.ts +10 -5
  364. package/dist/types/IntegerType.js +21 -17
  365. package/dist/types/IntegerType.js.map +1 -1
  366. package/dist/types/InterfaceType.d.ts +14 -6
  367. package/dist/types/InterfaceType.js +30 -15
  368. package/dist/types/InterfaceType.js.map +1 -1
  369. package/dist/types/IntersectionType.d.ts +29 -0
  370. package/dist/types/IntersectionType.js +256 -0
  371. package/dist/types/IntersectionType.js.map +1 -0
  372. package/dist/types/InvalidType.d.ts +10 -5
  373. package/dist/types/InvalidType.js +21 -9
  374. package/dist/types/InvalidType.js.map +1 -1
  375. package/dist/types/LongIntegerType.d.ts +10 -5
  376. package/dist/types/LongIntegerType.js +21 -17
  377. package/dist/types/LongIntegerType.js.map +1 -1
  378. package/dist/types/NamespaceType.d.ts +12 -0
  379. package/dist/types/NamespaceType.js +28 -0
  380. package/dist/types/NamespaceType.js.map +1 -0
  381. package/dist/types/ObjectType.d.ts +12 -5
  382. package/dist/types/ObjectType.js +25 -8
  383. package/dist/types/ObjectType.js.map +1 -1
  384. package/dist/types/ReferenceType.d.ts +123 -0
  385. package/dist/types/ReferenceType.js +726 -0
  386. package/dist/types/ReferenceType.js.map +1 -0
  387. package/dist/types/StringType.d.ts +12 -5
  388. package/dist/types/StringType.js +23 -8
  389. package/dist/types/StringType.js.map +1 -1
  390. package/dist/types/TypeStatementType.d.ts +19 -0
  391. package/dist/types/TypeStatementType.js +56 -0
  392. package/dist/types/TypeStatementType.js.map +1 -0
  393. package/dist/types/TypedFunctionType.d.ts +34 -0
  394. package/dist/types/TypedFunctionType.js +157 -0
  395. package/dist/types/TypedFunctionType.js.map +1 -0
  396. package/dist/types/UninitializedType.d.ts +11 -6
  397. package/dist/types/UninitializedType.js +20 -11
  398. package/dist/types/UninitializedType.js.map +1 -1
  399. package/dist/types/UnionType.d.ts +27 -0
  400. package/dist/types/UnionType.js +196 -0
  401. package/dist/types/UnionType.js.map +1 -0
  402. package/dist/types/VoidType.d.ts +11 -5
  403. package/dist/types/VoidType.js +22 -8
  404. package/dist/types/VoidType.js.map +1 -1
  405. package/dist/types/helpers.d.ts +51 -0
  406. package/dist/types/helpers.js +329 -0
  407. package/dist/types/helpers.js.map +1 -0
  408. package/dist/types/index.d.ts +22 -0
  409. package/dist/types/index.js +39 -0
  410. package/dist/types/index.js.map +1 -0
  411. package/dist/types/roFunctionType.d.ts +11 -0
  412. package/dist/types/roFunctionType.js +37 -0
  413. package/dist/types/roFunctionType.js.map +1 -0
  414. package/dist/util.d.ts +325 -185
  415. package/dist/util.js +2135 -568
  416. package/dist/util.js.map +1 -1
  417. package/dist/validators/ClassValidator.d.ts +9 -15
  418. package/dist/validators/ClassValidator.js +93 -138
  419. package/dist/validators/ClassValidator.js.map +1 -1
  420. package/package.json +183 -138
  421. package/CHANGELOG.md +0 -1188
  422. package/dist/astUtils/creators.spec.js +0 -21
  423. package/dist/astUtils/creators.spec.js.map +0 -1
  424. package/dist/astUtils/index.d.ts +0 -7
  425. package/dist/astUtils/index.js +0 -26
  426. package/dist/astUtils/index.js.map +0 -1
  427. package/dist/astUtils/reflection.spec.d.ts +0 -1
  428. package/dist/astUtils/reflection.spec.js +0 -292
  429. package/dist/astUtils/reflection.spec.js.map +0 -1
  430. package/dist/astUtils/stackedVisitor.spec.d.ts +0 -1
  431. package/dist/astUtils/stackedVisitor.spec.js +0 -79
  432. package/dist/astUtils/stackedVisitor.spec.js.map +0 -1
  433. package/dist/astUtils/visitors.spec.d.ts +0 -1
  434. package/dist/astUtils/visitors.spec.js +0 -854
  435. package/dist/astUtils/visitors.spec.js.map +0 -1
  436. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.d.ts +0 -1
  437. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +0 -194
  438. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +0 -1
  439. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.d.ts +0 -7
  440. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.js +0 -63
  441. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.js.map +0 -1
  442. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.d.ts +0 -1
  443. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.js +0 -45
  444. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.js.map +0 -1
  445. package/dist/files/BrsFile.Class.spec.d.ts +0 -1
  446. package/dist/files/BrsFile.Class.spec.js +0 -1081
  447. package/dist/files/BrsFile.Class.spec.js.map +0 -1
  448. package/dist/files/BrsFile.spec.d.ts +0 -1
  449. package/dist/files/BrsFile.spec.js +0 -2524
  450. package/dist/files/BrsFile.spec.js.map +0 -1
  451. package/dist/files/XmlFile.spec.d.ts +0 -1
  452. package/dist/files/XmlFile.spec.js +0 -1065
  453. package/dist/files/XmlFile.spec.js.map +0 -1
  454. package/dist/files/tests/imports.spec.d.ts +0 -1
  455. package/dist/files/tests/imports.spec.js +0 -241
  456. package/dist/files/tests/imports.spec.js.map +0 -1
  457. package/dist/lexer/Character.spec.d.ts +0 -1
  458. package/dist/lexer/Character.spec.js +0 -27
  459. package/dist/lexer/Character.spec.js.map +0 -1
  460. package/dist/lexer/Lexer.spec.d.ts +0 -1
  461. package/dist/lexer/Lexer.spec.js +0 -1101
  462. package/dist/lexer/Lexer.spec.js.map +0 -1
  463. package/dist/lexer/index.d.ts +0 -3
  464. package/dist/lexer/index.js +0 -17
  465. package/dist/lexer/index.js.map +0 -1
  466. package/dist/parser/Parser.Class.spec.d.ts +0 -1
  467. package/dist/parser/Parser.Class.spec.js +0 -390
  468. package/dist/parser/Parser.Class.spec.js.map +0 -1
  469. package/dist/parser/Parser.spec.d.ts +0 -4
  470. package/dist/parser/Parser.spec.js +0 -1216
  471. package/dist/parser/Parser.spec.js.map +0 -1
  472. package/dist/parser/SGParser.spec.d.ts +0 -1
  473. package/dist/parser/SGParser.spec.js +0 -145
  474. package/dist/parser/SGParser.spec.js.map +0 -1
  475. package/dist/parser/SGTypes.spec.d.ts +0 -1
  476. package/dist/parser/SGTypes.spec.js +0 -351
  477. package/dist/parser/SGTypes.spec.js.map +0 -1
  478. package/dist/parser/Statement.spec.d.ts +0 -1
  479. package/dist/parser/Statement.spec.js +0 -94
  480. package/dist/parser/Statement.spec.js.map +0 -1
  481. package/dist/parser/index.d.ts +0 -3
  482. package/dist/parser/index.js +0 -16
  483. package/dist/parser/index.js.map +0 -1
  484. package/dist/parser/tests/Parser.spec.d.ts +0 -18
  485. package/dist/parser/tests/Parser.spec.js +0 -35
  486. package/dist/parser/tests/Parser.spec.js.map +0 -1
  487. package/dist/parser/tests/controlFlow/For.spec.d.ts +0 -1
  488. package/dist/parser/tests/controlFlow/For.spec.js +0 -161
  489. package/dist/parser/tests/controlFlow/For.spec.js.map +0 -1
  490. package/dist/parser/tests/controlFlow/ForEach.spec.d.ts +0 -1
  491. package/dist/parser/tests/controlFlow/ForEach.spec.js +0 -106
  492. package/dist/parser/tests/controlFlow/ForEach.spec.js.map +0 -1
  493. package/dist/parser/tests/controlFlow/If.spec.d.ts +0 -1
  494. package/dist/parser/tests/controlFlow/If.spec.js +0 -551
  495. package/dist/parser/tests/controlFlow/If.spec.js.map +0 -1
  496. package/dist/parser/tests/controlFlow/While.spec.d.ts +0 -1
  497. package/dist/parser/tests/controlFlow/While.spec.js +0 -107
  498. package/dist/parser/tests/controlFlow/While.spec.js.map +0 -1
  499. package/dist/parser/tests/expression/Additive.spec.d.ts +0 -1
  500. package/dist/parser/tests/expression/Additive.spec.js +0 -99
  501. package/dist/parser/tests/expression/Additive.spec.js.map +0 -1
  502. package/dist/parser/tests/expression/ArrayLiterals.spec.d.ts +0 -1
  503. package/dist/parser/tests/expression/ArrayLiterals.spec.js +0 -254
  504. package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +0 -1
  505. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.d.ts +0 -1
  506. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +0 -266
  507. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +0 -1
  508. package/dist/parser/tests/expression/Boolean.spec.d.ts +0 -1
  509. package/dist/parser/tests/expression/Boolean.spec.js +0 -83
  510. package/dist/parser/tests/expression/Boolean.spec.js.map +0 -1
  511. package/dist/parser/tests/expression/Call.spec.d.ts +0 -1
  512. package/dist/parser/tests/expression/Call.spec.js +0 -134
  513. package/dist/parser/tests/expression/Call.spec.js.map +0 -1
  514. package/dist/parser/tests/expression/Exponential.spec.d.ts +0 -1
  515. package/dist/parser/tests/expression/Exponential.spec.js +0 -37
  516. package/dist/parser/tests/expression/Exponential.spec.js.map +0 -1
  517. package/dist/parser/tests/expression/Function.spec.d.ts +0 -1
  518. package/dist/parser/tests/expression/Function.spec.js +0 -403
  519. package/dist/parser/tests/expression/Function.spec.js.map +0 -1
  520. package/dist/parser/tests/expression/Indexing.spec.d.ts +0 -1
  521. package/dist/parser/tests/expression/Indexing.spec.js +0 -219
  522. package/dist/parser/tests/expression/Indexing.spec.js.map +0 -1
  523. package/dist/parser/tests/expression/Multiplicative.spec.d.ts +0 -1
  524. package/dist/parser/tests/expression/Multiplicative.spec.js +0 -67
  525. package/dist/parser/tests/expression/Multiplicative.spec.js.map +0 -1
  526. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.d.ts +0 -1
  527. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +0 -201
  528. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +0 -1
  529. package/dist/parser/tests/expression/PrefixUnary.spec.d.ts +0 -1
  530. package/dist/parser/tests/expression/PrefixUnary.spec.js +0 -105
  531. package/dist/parser/tests/expression/PrefixUnary.spec.js.map +0 -1
  532. package/dist/parser/tests/expression/Primary.spec.d.ts +0 -1
  533. package/dist/parser/tests/expression/Primary.spec.js +0 -149
  534. package/dist/parser/tests/expression/Primary.spec.js.map +0 -1
  535. package/dist/parser/tests/expression/Relational.spec.d.ts +0 -1
  536. package/dist/parser/tests/expression/Relational.spec.js +0 -83
  537. package/dist/parser/tests/expression/Relational.spec.js.map +0 -1
  538. package/dist/parser/tests/expression/SourceLiteralExpression.spec.d.ts +0 -1
  539. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +0 -201
  540. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +0 -1
  541. package/dist/parser/tests/expression/TemplateStringExpression.spec.d.ts +0 -1
  542. package/dist/parser/tests/expression/TemplateStringExpression.spec.js +0 -202
  543. package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +0 -1
  544. package/dist/parser/tests/expression/TernaryExpression.spec.d.ts +0 -1
  545. package/dist/parser/tests/expression/TernaryExpression.spec.js +0 -323
  546. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +0 -1
  547. package/dist/parser/tests/statement/AssignmentOperators.spec.d.ts +0 -1
  548. package/dist/parser/tests/statement/AssignmentOperators.spec.js +0 -79
  549. package/dist/parser/tests/statement/AssignmentOperators.spec.js.map +0 -1
  550. package/dist/parser/tests/statement/Declaration.spec.d.ts +0 -1
  551. package/dist/parser/tests/statement/Declaration.spec.js +0 -108
  552. package/dist/parser/tests/statement/Declaration.spec.js.map +0 -1
  553. package/dist/parser/tests/statement/Dim.spec.d.ts +0 -1
  554. package/dist/parser/tests/statement/Dim.spec.js +0 -73
  555. package/dist/parser/tests/statement/Dim.spec.js.map +0 -1
  556. package/dist/parser/tests/statement/Function.spec.d.ts +0 -1
  557. package/dist/parser/tests/statement/Function.spec.js +0 -332
  558. package/dist/parser/tests/statement/Function.spec.js.map +0 -1
  559. package/dist/parser/tests/statement/Goto.spec.d.ts +0 -1
  560. package/dist/parser/tests/statement/Goto.spec.js +0 -50
  561. package/dist/parser/tests/statement/Goto.spec.js.map +0 -1
  562. package/dist/parser/tests/statement/Increment.spec.d.ts +0 -1
  563. package/dist/parser/tests/statement/Increment.spec.js +0 -117
  564. package/dist/parser/tests/statement/Increment.spec.js.map +0 -1
  565. package/dist/parser/tests/statement/LibraryStatement.spec.d.ts +0 -1
  566. package/dist/parser/tests/statement/LibraryStatement.spec.js +0 -74
  567. package/dist/parser/tests/statement/LibraryStatement.spec.js.map +0 -1
  568. package/dist/parser/tests/statement/Misc.spec.d.ts +0 -1
  569. package/dist/parser/tests/statement/Misc.spec.js +0 -333
  570. package/dist/parser/tests/statement/Misc.spec.js.map +0 -1
  571. package/dist/parser/tests/statement/PrintStatement.spec.d.ts +0 -1
  572. package/dist/parser/tests/statement/PrintStatement.spec.js +0 -181
  573. package/dist/parser/tests/statement/PrintStatement.spec.js.map +0 -1
  574. package/dist/parser/tests/statement/ReturnStatement.spec.d.ts +0 -1
  575. package/dist/parser/tests/statement/ReturnStatement.spec.js +0 -94
  576. package/dist/parser/tests/statement/ReturnStatement.spec.js.map +0 -1
  577. package/dist/parser/tests/statement/Set.spec.d.ts +0 -1
  578. package/dist/parser/tests/statement/Set.spec.js +0 -218
  579. package/dist/parser/tests/statement/Set.spec.js.map +0 -1
  580. package/dist/parser/tests/statement/Stop.spec.d.ts +0 -1
  581. package/dist/parser/tests/statement/Stop.spec.js +0 -37
  582. package/dist/parser/tests/statement/Stop.spec.js.map +0 -1
  583. package/dist/parser/tests/statement/Throw.spec.d.ts +0 -1
  584. package/dist/parser/tests/statement/Throw.spec.js +0 -35
  585. package/dist/parser/tests/statement/Throw.spec.js.map +0 -1
  586. package/dist/parser/tests/statement/TryCatch.spec.d.ts +0 -1
  587. package/dist/parser/tests/statement/TryCatch.spec.js +0 -140
  588. package/dist/parser/tests/statement/TryCatch.spec.js.map +0 -1
  589. package/dist/preprocessor/Chunk.d.ts +0 -82
  590. package/dist/preprocessor/Chunk.js +0 -77
  591. package/dist/preprocessor/Chunk.js.map +0 -1
  592. package/dist/preprocessor/Manifest.spec.d.ts +0 -0
  593. package/dist/preprocessor/Manifest.spec.js +0 -105
  594. package/dist/preprocessor/Manifest.spec.js.map +0 -1
  595. package/dist/preprocessor/Preprocessor.d.ts +0 -60
  596. package/dist/preprocessor/Preprocessor.js +0 -156
  597. package/dist/preprocessor/Preprocessor.js.map +0 -1
  598. package/dist/preprocessor/Preprocessor.spec.d.ts +0 -1
  599. package/dist/preprocessor/Preprocessor.spec.js +0 -152
  600. package/dist/preprocessor/Preprocessor.spec.js.map +0 -1
  601. package/dist/preprocessor/PreprocessorParser.d.ts +0 -61
  602. package/dist/preprocessor/PreprocessorParser.js +0 -194
  603. package/dist/preprocessor/PreprocessorParser.js.map +0 -1
  604. package/dist/preprocessor/PreprocessorParser.spec.d.ts +0 -1
  605. package/dist/preprocessor/PreprocessorParser.spec.js +0 -116
  606. package/dist/preprocessor/PreprocessorParser.spec.js.map +0 -1
  607. package/dist/preprocessor/index.d.ts +0 -3
  608. package/dist/preprocessor/index.js +0 -16
  609. package/dist/preprocessor/index.js.map +0 -1
  610. package/dist/types/ArrayType.spec.d.ts +0 -1
  611. package/dist/types/ArrayType.spec.js +0 -30
  612. package/dist/types/ArrayType.spec.js.map +0 -1
  613. package/dist/types/BooleanType.spec.d.ts +0 -1
  614. package/dist/types/BooleanType.spec.js +0 -12
  615. package/dist/types/BooleanType.spec.js.map +0 -1
  616. package/dist/types/CustomType.d.ts +0 -10
  617. package/dist/types/CustomType.js +0 -35
  618. package/dist/types/CustomType.js.map +0 -1
  619. package/dist/types/DoubleType.spec.d.ts +0 -1
  620. package/dist/types/DoubleType.spec.js +0 -12
  621. package/dist/types/DoubleType.spec.js.map +0 -1
  622. package/dist/types/DynamicType.spec.d.ts +0 -1
  623. package/dist/types/DynamicType.spec.js +0 -12
  624. package/dist/types/DynamicType.spec.js.map +0 -1
  625. package/dist/types/FloatType.spec.d.ts +0 -1
  626. package/dist/types/FloatType.spec.js +0 -12
  627. package/dist/types/FloatType.spec.js.map +0 -1
  628. package/dist/types/FunctionType.spec.d.ts +0 -1
  629. package/dist/types/FunctionType.spec.js +0 -29
  630. package/dist/types/FunctionType.spec.js.map +0 -1
  631. package/dist/types/IntegerType.spec.d.ts +0 -1
  632. package/dist/types/IntegerType.spec.js +0 -12
  633. package/dist/types/IntegerType.spec.js.map +0 -1
  634. package/dist/types/InvalidType.spec.d.ts +0 -1
  635. package/dist/types/InvalidType.spec.js +0 -12
  636. package/dist/types/InvalidType.spec.js.map +0 -1
  637. package/dist/types/LazyType.d.ts +0 -15
  638. package/dist/types/LazyType.js +0 -32
  639. package/dist/types/LazyType.js.map +0 -1
  640. package/dist/types/LongIntegerType.spec.d.ts +0 -1
  641. package/dist/types/LongIntegerType.spec.js +0 -12
  642. package/dist/types/LongIntegerType.spec.js.map +0 -1
  643. package/dist/types/ObjectType.spec.d.ts +0 -1
  644. package/dist/types/ObjectType.spec.js +0 -12
  645. package/dist/types/ObjectType.spec.js.map +0 -1
  646. package/dist/types/StringType.spec.d.ts +0 -1
  647. package/dist/types/StringType.spec.js +0 -12
  648. package/dist/types/StringType.spec.js.map +0 -1
  649. package/dist/types/VoidType.spec.d.ts +0 -1
  650. package/dist/types/VoidType.spec.js +0 -12
  651. package/dist/types/VoidType.spec.js.map +0 -1
  652. /package/dist/{astUtils/creators.spec.d.ts → lsp/worker/run.d.ts} +0 -0
@@ -4,43 +4,327 @@ exports.CodeActionsProcessor = void 0;
4
4
  const vscode_languageserver_1 = require("vscode-languageserver");
5
5
  const CodeActionUtil_1 = require("../../CodeActionUtil");
6
6
  const DiagnosticMessages_1 = require("../../DiagnosticMessages");
7
- const parser_1 = require("../../parser");
7
+ const Parser_1 = require("../../parser/Parser");
8
8
  const util_1 = require("../../util");
9
+ const reflection_1 = require("../../astUtils/reflection");
10
+ const visitors_1 = require("../../astUtils/visitors");
11
+ const TokenKind_1 = require("../../lexer/TokenKind");
12
+ const codeActionHelpers_1 = require("./codeActionHelpers");
13
+ const SGParser_1 = require("../../parser/SGParser");
9
14
  class CodeActionsProcessor {
10
15
  constructor(event) {
11
16
  this.event = event;
12
17
  this.suggestedImports = new Set();
13
18
  }
19
+ /**
20
+ * Processes all diagnostics in the event and emits code actions for each recognized diagnostic code.
21
+ */
14
22
  process() {
23
+ // First pass: individual fixes for each diagnostic at the cursor position
15
24
  for (const diagnostic of this.event.diagnostics) {
16
- if (diagnostic.code === DiagnosticMessages_1.DiagnosticCodeMap.callToUnknownFunction) {
17
- this.suggestFunctionImports(diagnostic);
18
- }
19
- else if (diagnostic.code === DiagnosticMessages_1.DiagnosticCodeMap.classCouldNotBeFound) {
20
- this.suggestClassImports(diagnostic);
25
+ if (diagnostic.code === DiagnosticMessages_1.DiagnosticCodeMap.cannotFindName || diagnostic.code === DiagnosticMessages_1.DiagnosticCodeMap.cannotFindFunction) {
26
+ this.suggestCannotFindNameQuickFix(diagnostic);
21
27
  }
22
28
  else if (diagnostic.code === DiagnosticMessages_1.DiagnosticCodeMap.xmlComponentMissingExtendsAttribute) {
23
- this.addMissingExtends(diagnostic);
29
+ this.suggestMissingExtendsQuickFix(diagnostic);
30
+ }
31
+ else if (diagnostic.code === DiagnosticMessages_1.DiagnosticCodeMap.voidFunctionMayNotReturnValue) {
32
+ this.suggestVoidFunctionReturnQuickFixes([diagnostic]);
33
+ }
34
+ else if (diagnostic.code === DiagnosticMessages_1.DiagnosticCodeMap.nonVoidFunctionMustReturnValue) {
35
+ this.suggestNonVoidFunctionReturnQuickFixes([diagnostic]);
36
+ }
37
+ else if (diagnostic.code === DiagnosticMessages_1.DiagnosticCodeMap.referencedFileDoesNotExist) {
38
+ this.suggestRemoveScriptImportQuickFixes([diagnostic]);
39
+ }
40
+ else if (diagnostic.code === DiagnosticMessages_1.DiagnosticCodeMap.unnecessaryScriptImportInChildFromParent) {
41
+ this.suggestRemoveScriptImportQuickFixes([diagnostic]);
42
+ }
43
+ else if (diagnostic.code === DiagnosticMessages_1.DiagnosticCodeMap.unnecessaryCodebehindScriptImport) {
44
+ this.suggestRemoveScriptImportQuickFixes([diagnostic]);
45
+ }
46
+ else if (diagnostic.code === DiagnosticMessages_1.DiagnosticCodeMap.scriptImportCaseMismatch) {
47
+ this.suggestScriptImportCasingQuickFixes([diagnostic]);
48
+ }
49
+ else if (diagnostic.code === DiagnosticMessages_1.DiagnosticCodeMap.missingOverrideKeyword) {
50
+ this.suggestMissingOverrideQuickFixes([diagnostic]);
24
51
  }
52
+ else if (diagnostic.code === DiagnosticMessages_1.DiagnosticCodeMap.cannotUseOverrideKeywordOnConstructorFunction) {
53
+ this.suggestRemoveOverrideFromConstructorQuickFixes([diagnostic]);
54
+ }
55
+ else if ((0, DiagnosticMessages_1.isDiagnosticOfType)(diagnostic, 'mismatchedEndingToken')) {
56
+ this.suggestMismatchedEndingTokenQuickFixes([diagnostic]);
57
+ }
58
+ }
59
+ // Second pass: fix-all actions for any code that appeared in the event.
60
+ // Also makes sure that fix-all actions appear after individual fixes
61
+ const eventCodes = new Set(this.event.diagnostics.map(d => d.code));
62
+ const fixAllDiagsByCode = this.collectFixAllDiagnostics(eventCodes);
63
+ // only offer fix-all when there are multiple instances of the same issue in the file
64
+ for (const [code, allInFile] of fixAllDiagsByCode) {
65
+ if (allInFile.length > 1) {
66
+ if (code === DiagnosticMessages_1.DiagnosticCodeMap.voidFunctionMayNotReturnValue) {
67
+ this.suggestVoidFunctionReturnQuickFixes(allInFile);
68
+ }
69
+ else if (code === DiagnosticMessages_1.DiagnosticCodeMap.nonVoidFunctionMustReturnValue) {
70
+ this.suggestNonVoidFunctionReturnQuickFixes(allInFile);
71
+ }
72
+ else if (code === DiagnosticMessages_1.DiagnosticCodeMap.cannotUseOverrideKeywordOnConstructorFunction) {
73
+ this.suggestRemoveOverrideFromConstructorQuickFixes(allInFile);
74
+ }
75
+ else if (code === DiagnosticMessages_1.DiagnosticCodeMap.referencedFileDoesNotExist) {
76
+ this.suggestRemoveScriptImportQuickFixes(allInFile);
77
+ }
78
+ else if (code === DiagnosticMessages_1.DiagnosticCodeMap.unnecessaryScriptImportInChildFromParent) {
79
+ this.suggestRemoveScriptImportQuickFixes(allInFile);
80
+ }
81
+ else if (code === DiagnosticMessages_1.DiagnosticCodeMap.unnecessaryCodebehindScriptImport) {
82
+ this.suggestRemoveScriptImportQuickFixes(allInFile);
83
+ }
84
+ else if (code === DiagnosticMessages_1.DiagnosticCodeMap.scriptImportCaseMismatch) {
85
+ this.suggestScriptImportCasingQuickFixes(allInFile);
86
+ }
87
+ else if (code === DiagnosticMessages_1.DiagnosticCodeMap.missingOverrideKeyword) {
88
+ this.suggestMissingOverrideQuickFixes(allInFile);
89
+ }
90
+ else if (code === DiagnosticMessages_1.DiagnosticCodeMap.mismatchedEndingToken) {
91
+ this.suggestMismatchedEndingTokenQuickFixes(allInFile);
92
+ }
93
+ }
94
+ }
95
+ // Import fix-all aggregates across multiple codes so it runs as its own step
96
+ if (eventCodes.has(DiagnosticMessages_1.DiagnosticCodeMap.cannotFindName) ||
97
+ eventCodes.has(DiagnosticMessages_1.DiagnosticCodeMap.cannotFindFunction)) {
98
+ this.suggestMissingImportsFixAllQuickFix();
99
+ }
100
+ // Suppression actions appear last so real fixes are surfaced first
101
+ for (const diagnostic of this.event.diagnostics) {
102
+ this.suggestDisableDiagnosticQuickFixes(diagnostic);
103
+ }
104
+ this.suggestedImports.clear();
105
+ }
106
+ /**
107
+ * For any diagnostic with a code, offers two quick-fix actions:
108
+ * - "Disable {code} for this line": adds the code to an existing `bs:disable-line` or
109
+ * `bs:disable-next-line` directive on/above the diagnostic if present, otherwise inserts
110
+ * a new `bs:disable-next-line: {code}` comment on the line above.
111
+ * - "Disable {code} for this file": adds the code to an existing header-level `bs:disable`
112
+ * directive if present, otherwise inserts a new `bs:disable: {code}` at the top of the file.
113
+ *
114
+ * Comment placement and the line-vs-next-line preference are centralized here so they can be
115
+ * revisited without touching the directive parser.
116
+ */
117
+ suggestDisableDiagnosticQuickFixes(diagnostic) {
118
+ var _a;
119
+ const code = diagnostic.code;
120
+ if (code === undefined || code === null) {
121
+ return;
122
+ }
123
+ const file = this.event.file;
124
+ if (!(0, reflection_1.isBrsFile)(file) && !(0, reflection_1.isXmlFile)(file)) {
125
+ return;
126
+ }
127
+ const codeStr = String(code);
128
+ const isXml = (0, reflection_1.isXmlFile)(file);
129
+ //existing.forLine: any line/next-line directive on or above the diagnostic line that the line action could extend
130
+ //existing.forFile: any header-level bs:disable that the file action could extend
131
+ const existing = this.findExistingDisableDirectives(file, (_a = diagnostic.location) === null || _a === void 0 ? void 0 : _a.range.start.line);
132
+ //format helpers wrap the directive body in the right comment syntax (`'` for brs, `<!-- -->` for xml)
133
+ const formatLineDirective = (token, codes) => {
134
+ const body = `bs:disable-${token}: ${codes.join(' ')}`;
135
+ return isXml ? `<!-- ${body} -->` : `' ${body}`;
136
+ };
137
+ const formatBlockDirective = (codes) => {
138
+ const body = `bs:disable: ${codes.join(' ')}`;
139
+ return isXml ? `<!-- ${body} -->` : `' ${body}`;
140
+ };
141
+ // ---- "disable for this line" ----
142
+ //the two lambdas passed to getDiagnosticSuppressionChange are the "extend existing" and "insert fresh" branches:
143
+ // 1) rebuild the existing directive comment with the new code merged into its code list (preserving line vs next-line)
144
+ // 2) insert a fresh `bs:disable-next-line: {code}` on the line above the diagnostic, matching its indent
145
+ const indent = ' '.repeat(diagnostic.location.range.start.character);
146
+ const lineAction = this.getDiagnosticSuppressionChange(existing.forLine, codeStr, () => { var _a; return formatLineDirective(existing.forLine.type, this.mergeCodes((_a = existing.forLine) === null || _a === void 0 ? void 0 : _a.codes, codeStr)); }, () => ({
147
+ position: util_1.util.createPosition(diagnostic.location.range.start.line, 0),
148
+ newText: `${indent}${formatLineDirective('next-line', [codeStr])}\n`
149
+ }));
150
+ if (lineAction) {
151
+ this.event.codeActions.push(CodeActionUtil_1.codeActionUtil.createCodeAction({
152
+ title: `Disable ${code} for this line: ${diagnostic.message}`,
153
+ diagnostics: [diagnostic],
154
+ kind: vscode_languageserver_1.CodeActionKind.QuickFix,
155
+ changes: [lineAction]
156
+ }));
157
+ }
158
+ // ---- "disable for this file" ----
159
+ //same pattern as above, but operating on the header-level bs:disable directive:
160
+ // 1) rebuild the existing header directive with the new code appended
161
+ // 2) insert a fresh `bs:disable: {code}` at the file header (top of brs, or after `<?xml ?>` for xml)
162
+ const fileAction = this.getDiagnosticSuppressionChange(existing.forFile, codeStr, () => { var _a; return formatBlockDirective(this.mergeCodes((_a = existing.forFile) === null || _a === void 0 ? void 0 : _a.codes, codeStr)); }, () => {
163
+ const headerInsert = this.getDisableFileInsertion(file);
164
+ return {
165
+ position: headerInsert.position,
166
+ newText: headerInsert.prefix + formatBlockDirective([codeStr]) + headerInsert.suffix
167
+ };
168
+ });
169
+ if (fileAction) {
170
+ this.event.codeActions.push(CodeActionUtil_1.codeActionUtil.createCodeAction({
171
+ title: `Disable ${code} for this file: ${diagnostic.message}`,
172
+ diagnostics: [diagnostic],
173
+ kind: vscode_languageserver_1.CodeActionKind.QuickFix,
174
+ changes: [fileAction]
175
+ }));
25
176
  }
26
177
  }
178
+ /**
179
+ * Returns the file change that suppresses `codeStr` via a directive comment, or `null` when no
180
+ * change is needed (the existing directive already covers the code, or already suppresses
181
+ * everything). When `existing` is set, the result is a replace that swaps the directive comment
182
+ * for the text from `buildReplacementText`. When `existing` is null, the result is an insert
183
+ * built from `buildInsert`.
184
+ */
185
+ getDiagnosticSuppressionChange(existing, codeStr, buildReplacementText, buildInsert) {
186
+ if (existing) {
187
+ //existing directive without specific codes already suppresses everything; no-op
188
+ if (existing.codes.length === 0) {
189
+ return null;
190
+ }
191
+ //the new code is already in the directive; no-op
192
+ if (existing.codes.some(c => c.toLowerCase() === codeStr.toLowerCase())) {
193
+ return null;
194
+ }
195
+ return {
196
+ type: 'replace',
197
+ filePath: this.event.file.srcPath,
198
+ range: existing.range,
199
+ newText: buildReplacementText()
200
+ };
201
+ }
202
+ const insert = buildInsert();
203
+ return {
204
+ type: 'insert',
205
+ filePath: this.event.file.srcPath,
206
+ position: insert.position,
207
+ newText: insert.newText
208
+ };
209
+ }
210
+ mergeCodes(existingCodes, newCode) {
211
+ return [...(existingCodes !== null && existingCodes !== void 0 ? existingCodes : []), newCode];
212
+ }
213
+ /**
214
+ * Walks the file's tokens and returns existing `bs:disable-{line,next-line}` and header-level
215
+ * `bs:disable` directives that would cover the diagnostic on `diagLine`. Used so the suppression
216
+ * quick fixes can extend an existing directive instead of stacking new ones.
217
+ */
218
+ findExistingDisableDirectives(file, diagLine) {
219
+ var _a, _b, _c, _d, _e;
220
+ const isXml = (0, reflection_1.isXmlFile)(file);
221
+ const tokens = (_b = (_a = file.parser) === null || _a === void 0 ? void 0 : _a.tokens) !== null && _b !== void 0 ? _b : [];
222
+ let inHeader = true;
223
+ let forLine = null;
224
+ let forFile = null;
225
+ for (const token of tokens) {
226
+ const isComment = isXml ? ((_c = token.tokenType) === null || _c === void 0 ? void 0 : _c.name) === 'Comment' : (_d = token.leadingTrivia) === null || _d === void 0 ? void 0 : _d.some(t => t.kind === TokenKind_1.TokenKind.Comment);
227
+ if (!isComment) {
228
+ if (isXml) {
229
+ if (((_e = token.tokenType) === null || _e === void 0 ? void 0 : _e.name) === 'OPEN') {
230
+ inHeader = false;
231
+ }
232
+ }
233
+ else if (token.kind !== TokenKind_1.TokenKind.Newline && token.kind !== TokenKind_1.TokenKind.Whitespace && token.kind !== TokenKind_1.TokenKind.Eof) {
234
+ inHeader = false;
235
+ }
236
+ continue;
237
+ }
238
+ const commentTokens = isXml ? [token] : token.leadingTrivia.filter(t => t.kind === TokenKind_1.TokenKind.Comment);
239
+ for (const commentToken of commentTokens) {
240
+ const tokenRange = isXml ? (0, SGParser_1.rangeFromTokenValue)(commentToken) : commentToken.location.range;
241
+ const tokenText = isXml ? commentToken.image : commentToken.text;
242
+ const parsed = parseDisableComment(tokenText);
243
+ if (!parsed) {
244
+ continue;
245
+ }
246
+ const directive = { type: parsed.directiveType, codes: parsed.codes, range: tokenRange };
247
+ if (!forLine && parsed.directiveType === 'line' && tokenRange.start.line === diagLine) {
248
+ forLine = directive;
249
+ }
250
+ else if (!forLine && parsed.directiveType === 'next-line' && tokenRange.start.line === diagLine - 1) {
251
+ forLine = directive;
252
+ }
253
+ else if (!forFile && parsed.directiveType === 'block' && inHeader) {
254
+ //only header-level `bs:disable` directives are extended for the file-level quick fix
255
+ forFile = directive;
256
+ }
257
+ }
258
+ }
259
+ return { forLine: forLine, forFile: forFile };
260
+ }
261
+ /**
262
+ * Decides where in the file a header-level `bs:disable` directive should be inserted, returning
263
+ * the position plus any prefix/suffix needed so the directive lands on its own line in
264
+ * the header (before the first executable statement / root XML element).
265
+ */
266
+ getDisableFileInsertion(file) {
267
+ var _a;
268
+ if ((0, reflection_1.isXmlFile)(file)) {
269
+ //insert after the `<?xml ?>` declaration if present, otherwise at the very top
270
+ const declCloseToken = (_a = file.parser.tokens) === null || _a === void 0 ? void 0 : _a.find(t => { var _a; return ((_a = t.tokenType) === null || _a === void 0 ? void 0 : _a.name) === 'SPECIAL_CLOSE'; });
271
+ if (declCloseToken) {
272
+ const endLine = declCloseToken.endLine - 1;
273
+ const endColumn = declCloseToken.endColumn;
274
+ return {
275
+ position: util_1.util.createPosition(endLine, endColumn),
276
+ prefix: '\n',
277
+ suffix: ''
278
+ };
279
+ }
280
+ }
281
+ return {
282
+ position: util_1.util.createPosition(0, 0),
283
+ prefix: '',
284
+ suffix: '\n'
285
+ };
286
+ }
287
+ /**
288
+ * Builds a map of diagnostic code → all matching diagnostics in the current file for each
289
+ * code in `eventCodes`. Scope-level codes are not present in `file.getDiagnostics()` so they
290
+ * are sourced from `program.getDiagnostics()` (fetched lazily, only when needed).
291
+ */
292
+ collectFixAllDiagnostics(eventCodes) {
293
+ var _a;
294
+ const fileUri = util_1.util.pathToUri(this.event.file.srcPath);
295
+ const fileDiagnostics = this.event.program.getDiagnostics().filter(d => { var _a; return ((_a = d.location) === null || _a === void 0 ? void 0 : _a.uri) === fileUri; });
296
+ const fileDiagsByCode = new Map();
297
+ for (const d of fileDiagnostics) {
298
+ if (!fileDiagsByCode.has(d.code)) {
299
+ fileDiagsByCode.set(d.code, []);
300
+ }
301
+ fileDiagsByCode.get(d.code).push(d);
302
+ }
303
+ const result = new Map();
304
+ for (const code of eventCodes) {
305
+ result.set(code, (_a = fileDiagsByCode.get(code)) !== null && _a !== void 0 ? _a : []);
306
+ }
307
+ return result;
308
+ }
27
309
  /**
28
310
  * Generic import suggestion function. Shouldn't be called directly from the main loop, but instead called by more specific diagnostic handlers
29
311
  */
30
- suggestImports(diagnostic, key, files) {
312
+ suggestImportQuickFix(diagnostic, key, files) {
31
313
  var _a, _b, _c;
32
314
  //skip if we already have this suggestion
33
315
  if (this.suggestedImports.has(key)) {
34
316
  return;
35
317
  }
36
318
  this.suggestedImports.add(key);
37
- const importStatements = this.event.file.parser.references.importStatements;
319
+ // eslint-disable-next-line @typescript-eslint/dot-notation
320
+ const importStatements = this.event.file['_cachedLookups'].importStatements;
38
321
  //find the position of the first import statement, or the top of the file if there is none
39
- const insertPosition = (_c = (_b = (_a = importStatements[importStatements.length - 1]) === null || _a === void 0 ? void 0 : _a.importToken.range) === null || _b === void 0 ? void 0 : _b.start) !== null && _c !== void 0 ? _c : util_1.util.createPosition(0, 0);
322
+ const insertPosition = (_c = (_b = (_a = importStatements[importStatements.length - 1]) === null || _a === void 0 ? void 0 : _a.tokens.import.location.range) === null || _b === void 0 ? void 0 : _b.start) !== null && _c !== void 0 ? _c : util_1.util.createPosition(0, 0);
40
323
  //find all files that reference this function
41
324
  for (const file of files) {
325
+ const pkgPath = util_1.util.sanitizePkgPath(file.destPath);
42
326
  this.event.codeActions.push(CodeActionUtil_1.codeActionUtil.createCodeAction({
43
- title: `import "${file.pkgPath}"`,
327
+ title: `import "${pkgPath}"`,
44
328
  diagnostics: [diagnostic],
45
329
  isPreferred: false,
46
330
  kind: vscode_languageserver_1.CodeActionKind.QuickFix,
@@ -48,33 +332,93 @@ class CodeActionsProcessor {
48
332
  type: 'insert',
49
333
  filePath: this.event.file.srcPath,
50
334
  position: insertPosition,
51
- newText: `import "${file.pkgPath}"\n`
335
+ newText: `import "${pkgPath}"\n`
52
336
  }]
53
337
  }));
54
338
  }
55
339
  }
56
- suggestFunctionImports(diagnostic) {
340
+ /**
341
+ * Suggests import statements for an unresolved name (function, class, namespace, or enum).
342
+ */
343
+ suggestCannotFindNameQuickFix(diagnostic) {
344
+ var _a;
57
345
  //skip if not a BrighterScript file
58
- if (diagnostic.file.parseMode !== parser_1.ParseMode.BrighterScript) {
346
+ if (!(0, reflection_1.isBrsFile)(this.event.file) || this.event.file.parseMode !== Parser_1.ParseMode.BrighterScript) {
59
347
  return;
60
348
  }
61
- const lowerFunctionName = diagnostic.data.functionName.toLowerCase();
62
- this.suggestImports(diagnostic, lowerFunctionName, this.event.file.program.findFilesForFunction(lowerFunctionName));
349
+ const lowerName = ((_a = diagnostic.data.fullName) !== null && _a !== void 0 ? _a : diagnostic.data.name).toLowerCase();
350
+ this.suggestImportQuickFix(diagnostic, lowerName, [
351
+ ...this.event.program.findFilesForFunction(lowerName),
352
+ ...this.event.program.findFilesForClass(lowerName),
353
+ ...this.event.program.findFilesForNamespace(lowerName),
354
+ ...this.event.program.findFilesForEnum(lowerName)
355
+ ]);
63
356
  }
64
- suggestClassImports(diagnostic) {
65
- //skip if not a BrighterScript file
66
- if (diagnostic.file.parseMode !== parser_1.ParseMode.BrighterScript) {
357
+ /**
358
+ * Scans all import-related diagnostics in the file and emits a single composite
359
+ * "Fix all: Add missing imports" action when 2+ unambiguous imports are needed.
360
+ * Ambiguous names (multiple possible source files) are excluded since we cannot
361
+ * automatically choose one.
362
+ */
363
+ suggestMissingImportsFixAllQuickFix() {
364
+ var _a, _b, _c, _d, _e, _f, _g;
365
+ if (!(0, reflection_1.isBrsFile)(this.event.file) || this.event.file.parseMode !== Parser_1.ParseMode.BrighterScript) {
67
366
  return;
68
367
  }
69
- const lowerClassName = diagnostic.data.className.toLowerCase();
70
- this.suggestImports(diagnostic, lowerClassName, this.event.file.program.findFilesForClass(lowerClassName));
368
+ const file = this.event.file;
369
+ // eslint-disable-next-line @typescript-eslint/dot-notation
370
+ const importStatements = file['_cachedLookups'].importStatements;
371
+ const insertPosition = (_c = (_b = (_a = importStatements[importStatements.length - 1]) === null || _a === void 0 ? void 0 : _a.tokens.import.location.range) === null || _b === void 0 ? void 0 : _b.start) !== null && _c !== void 0 ? _c : util_1.util.createPosition(0, 0);
372
+ const changes = [];
373
+ const addedPaths = new Set();
374
+ // cannotFindName/classCouldNotBeFound are scope-level diagnostics, so we must
375
+ // use program.getDiagnostics() (filtered by file) rather than file.getDiagnostics().
376
+ const fileUri = util_1.util.pathToUri(file.srcPath);
377
+ const allFileDiagnostics = this.event.program.getDiagnostics().filter(d => { var _a; return ((_a = d.location) === null || _a === void 0 ? void 0 : _a.uri) === fileUri; });
378
+ for (const diagnostic of allFileDiagnostics) {
379
+ let files = [];
380
+ if (diagnostic.code === DiagnosticMessages_1.DiagnosticCodeMap.cannotFindName || diagnostic.code === DiagnosticMessages_1.DiagnosticCodeMap.cannotFindFunction) {
381
+ const cannotFindNameDiagnostic = diagnostic;
382
+ const lowerName = (_g = ((_e = (_d = cannotFindNameDiagnostic.data) === null || _d === void 0 ? void 0 : _d.fullName) !== null && _e !== void 0 ? _e : (_f = cannotFindNameDiagnostic.data) === null || _f === void 0 ? void 0 : _f.name)) === null || _g === void 0 ? void 0 : _g.toLowerCase();
383
+ if (lowerName) {
384
+ files = [
385
+ ...this.event.program.findFilesForFunction(lowerName),
386
+ ...this.event.program.findFilesForClass(lowerName),
387
+ ...this.event.program.findFilesForNamespace(lowerName),
388
+ ...this.event.program.findFilesForEnum(lowerName)
389
+ ];
390
+ }
391
+ }
392
+ //skip ambiguous names; we can't choose a file automatically
393
+ if (files.length !== 1) {
394
+ continue;
395
+ }
396
+ const pkgPath = util_1.util.sanitizePkgPath(files[0].destPath);
397
+ if (!addedPaths.has(pkgPath)) {
398
+ addedPaths.add(pkgPath);
399
+ changes.push({
400
+ type: 'insert',
401
+ filePath: file.srcPath,
402
+ position: insertPosition,
403
+ newText: `import "${pkgPath}"\n`
404
+ });
405
+ }
406
+ }
407
+ if (changes.length > 1) {
408
+ this.event.codeActions.push(CodeActionUtil_1.codeActionUtil.createCodeAction({
409
+ title: `Fix all: Auto fixable missing imports`,
410
+ kind: vscode_languageserver_1.CodeActionKind.QuickFix,
411
+ changes: changes
412
+ }));
413
+ }
71
414
  }
72
- addMissingExtends(diagnostic) {
73
- var _a;
415
+ /**
416
+ * Adds code actions to insert a missing `extends` attribute on an XML component tag.
417
+ * Offers Group, Task, and ContentNode as common choices.
418
+ */
419
+ suggestMissingExtendsQuickFix(diagnostic) {
74
420
  const srcPath = this.event.file.srcPath;
75
- const { component } = this.event.file.parser.ast;
76
- //inject new attribute after the final attribute, or after the `<component` if there are no attributes
77
- const pos = ((_a = component.attributes[component.attributes.length - 1]) !== null && _a !== void 0 ? _a : component.tokens.startTagOpen).range.end;
421
+ const pos = (0, codeActionHelpers_1.getMissingExtendsInsertPosition)(this.event.file);
78
422
  this.event.codeActions.push(CodeActionUtil_1.codeActionUtil.createCodeAction({
79
423
  title: `Extend "Group"`,
80
424
  diagnostics: [diagnostic],
@@ -110,6 +454,312 @@ class CodeActionsProcessor {
110
454
  }]
111
455
  }));
112
456
  }
457
+ /**
458
+ * Adds code actions to resolve a `voidFunctionMayNotReturnValue` diagnostic.
459
+ * Offers removing the return value, converting sub→function, or removing an `as void` return type.
460
+ */
461
+ suggestVoidFunctionReturnQuickFixes(diagnostics) {
462
+ var _a, _b, _c;
463
+ const changes = diagnostics.map(d => this.getRemoveReturnValueChange(d));
464
+ this.emitOrFixAll(`Remove return value`, `Fix all: Remove void return values`, changes, diagnostics[0]);
465
+ //contextual BrsFile actions only apply to the individual (single-violation) case
466
+ if (changes.length === 1 && (0, reflection_1.isBrsFile)(this.event.file)) {
467
+ const diagnostic = diagnostics[0];
468
+ const expression = this.event.file.getClosestExpression(diagnostic.location.range.start);
469
+ const func = expression.findAncestor(reflection_1.isFunctionExpression);
470
+ //if we're in a sub and we do not have a return type, suggest converting to a function
471
+ if (func.tokens.functionType.kind === TokenKind_1.TokenKind.Sub && !func.returnTypeExpression) {
472
+ //find the first function in a file that uses the `function` keyword
473
+ const referenceFunction = this.event.file.parser.ast.findChild((node) => {
474
+ return (0, reflection_1.isFunctionExpression)(node) && node.tokens.functionType.kind === TokenKind_1.TokenKind.Function;
475
+ });
476
+ const functionTypeText = (_a = referenceFunction === null || referenceFunction === void 0 ? void 0 : referenceFunction.tokens.functionType.text) !== null && _a !== void 0 ? _a : 'function';
477
+ const endFunctionTypeText = (_c = (_b = referenceFunction === null || referenceFunction === void 0 ? void 0 : referenceFunction.tokens.endFunctionType) === null || _b === void 0 ? void 0 : _b.text) !== null && _c !== void 0 ? _c : 'end function';
478
+ this.event.codeActions.push(CodeActionUtil_1.codeActionUtil.createCodeAction({
479
+ title: `Convert ${func.tokens.functionType.text} to ${functionTypeText}`,
480
+ diagnostics: [diagnostic],
481
+ kind: vscode_languageserver_1.CodeActionKind.QuickFix,
482
+ changes: [
483
+ //function
484
+ { type: 'replace', filePath: this.event.file.srcPath, range: func.tokens.functionType.location.range, newText: functionTypeText },
485
+ //end function
486
+ { type: 'replace', filePath: this.event.file.srcPath, range: func.tokens.endFunctionType.location.range, newText: endFunctionTypeText }
487
+ ]
488
+ }));
489
+ }
490
+ //function `as void` return type. Suggest removing the return type
491
+ if (func.tokens.functionType.kind === TokenKind_1.TokenKind.Function && func.returnTypeExpression && (0, reflection_1.isVoidType)(func.returnTypeExpression.getType({ flags: 2 /* SymbolTypeFlag.typetime */ }))) {
492
+ this.event.codeActions.push(CodeActionUtil_1.codeActionUtil.createCodeAction({
493
+ title: `Remove return type from function declaration`,
494
+ diagnostics: [diagnostic],
495
+ kind: vscode_languageserver_1.CodeActionKind.QuickFix,
496
+ changes: [this.getRemoveFunctionReturnTypeChange(func)]
497
+ }));
498
+ }
499
+ }
500
+ }
501
+ /**
502
+ * Adds code actions to resolve a `nonVoidFunctionMustReturnValue` diagnostic.
503
+ * Offers removing the return type from a sub, adding `as void` to a function, or converting function→sub.
504
+ */
505
+ suggestNonVoidFunctionReturnQuickFixes(diagnostics) {
506
+ if (!(0, reflection_1.isBrsFile)(this.event.file)) {
507
+ return;
508
+ }
509
+ const file = this.event.file;
510
+ //find tokens for `as`, `void`, `sub`, `end sub` in the file if possible
511
+ let asText;
512
+ let voidText;
513
+ let subText;
514
+ let endSubText;
515
+ for (const token of file.parser.tokens) {
516
+ if (asText && voidText && subText && endSubText) {
517
+ break;
518
+ }
519
+ if ((token === null || token === void 0 ? void 0 : token.kind) === TokenKind_1.TokenKind.As) {
520
+ asText = token === null || token === void 0 ? void 0 : token.text;
521
+ }
522
+ else if ((token === null || token === void 0 ? void 0 : token.kind) === TokenKind_1.TokenKind.Void) {
523
+ voidText = token === null || token === void 0 ? void 0 : token.text;
524
+ }
525
+ else if ((token === null || token === void 0 ? void 0 : token.kind) === TokenKind_1.TokenKind.Sub) {
526
+ subText = token === null || token === void 0 ? void 0 : token.text;
527
+ }
528
+ else if ((token === null || token === void 0 ? void 0 : token.kind) === TokenKind_1.TokenKind.EndSub) {
529
+ endSubText = token === null || token === void 0 ? void 0 : token.text;
530
+ }
531
+ }
532
+ // Build per-fix-type change arrays, deduplicating by enclosing function so that one
533
+ // function with multiple bare returns only contributes one change.
534
+ const removeReturnTypeChanges = [];
535
+ const addVoidChanges = [];
536
+ const seenFunctions = new Set();
537
+ for (const d of diagnostics) {
538
+ const expr = file.getClosestExpression(d.location.range.start);
539
+ const fn = expr === null || expr === void 0 ? void 0 : expr.findAncestor(reflection_1.isFunctionExpression);
540
+ if (!fn) {
541
+ continue;
542
+ }
543
+ const fnKey = `${fn.location.range.start.line}:${fn.location.range.start.character}`;
544
+ if (seenFunctions.has(fnKey)) {
545
+ continue;
546
+ }
547
+ seenFunctions.add(fnKey);
548
+ if (fn.tokens.functionType.kind === TokenKind_1.TokenKind.Sub && fn.returnTypeExpression && !(0, reflection_1.isVoidType)(fn.returnTypeExpression.getType({ flags: 2 /* SymbolTypeFlag.typetime */ }))) {
549
+ removeReturnTypeChanges.push(this.getRemoveFunctionReturnTypeChange(fn));
550
+ }
551
+ else if (fn.tokens.functionType.kind === TokenKind_1.TokenKind.Function && !fn.returnTypeExpression) {
552
+ addVoidChanges.push({
553
+ type: 'insert',
554
+ filePath: this.event.file.srcPath,
555
+ position: fn.tokens.rightParen.location.range.end,
556
+ newText: ` ${asText !== null && asText !== void 0 ? asText : 'as'} ${voidText !== null && voidText !== void 0 ? voidText : 'void'}`
557
+ });
558
+ }
559
+ }
560
+ this.emitOrFixAll(`Remove return type from sub declaration`, `Fix all: Remove return type from sub declarations`, removeReturnTypeChanges, diagnostics[0]);
561
+ this.emitOrFixAll(`Add void return type to function declaration`, `Fix all: Add void return type to function declarations`, addVoidChanges, diagnostics[0]);
562
+ //'Convert function to sub' has no fix-all variant; only add it for the individual case
563
+ if (addVoidChanges.length === 1 && diagnostics.length === 1) {
564
+ const func = file.getClosestExpression(diagnostics[0].location.range.start).findAncestor(reflection_1.isFunctionExpression);
565
+ this.event.codeActions.push(CodeActionUtil_1.codeActionUtil.createCodeAction({
566
+ title: `Convert function to sub`,
567
+ diagnostics: [diagnostics[0]],
568
+ kind: vscode_languageserver_1.CodeActionKind.QuickFix,
569
+ changes: [
570
+ { type: 'replace', filePath: file.srcPath, range: func.tokens.functionType.location.range, newText: subText !== null && subText !== void 0 ? subText : 'sub' },
571
+ { type: 'replace', filePath: file.srcPath, range: func.tokens.endFunctionType.location.range, newText: endSubText !== null && endSubText !== void 0 ? endSubText : 'end sub' }
572
+ ]
573
+ }));
574
+ }
575
+ }
576
+ // ---- script import fixes ----
577
+ /**
578
+ * Adds code actions to delete one or more unnecessary or broken script import lines.
579
+ */
580
+ suggestRemoveScriptImportQuickFixes(diagnostics) {
581
+ var _a, _b;
582
+ const titles = {
583
+ [DiagnosticMessages_1.DiagnosticCodeMap.unnecessaryScriptImportInChildFromParent]: ['Remove redundant script import', 'Fix all: Remove redundant script imports'],
584
+ [DiagnosticMessages_1.DiagnosticCodeMap.unnecessaryCodebehindScriptImport]: ['Remove unnecessary codebehind import', 'Fix all: Remove unnecessary codebehind imports']
585
+ };
586
+ const [singleTitle, fixAllTitle] = (_b = titles[(_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.code]) !== null && _b !== void 0 ? _b : ['Remove script import', 'Fix all: Remove script imports'];
587
+ const changes = diagnostics.map(diagnostic => {
588
+ return {
589
+ type: 'delete',
590
+ filePath: this.event.file.srcPath,
591
+ range: util_1.util.createRange(diagnostic.location.range.start.line, 0, diagnostic.location.range.start.line + 1, 0)
592
+ };
593
+ });
594
+ this.emitOrFixAll(singleTitle, fixAllTitle, changes, diagnostics[0]);
595
+ }
596
+ /**
597
+ * Adds code actions to correct the casing of script import paths to match the actual file name on disk.
598
+ */
599
+ suggestScriptImportCasingQuickFixes(diagnostics) {
600
+ var _a;
601
+ const changes = [];
602
+ for (const diagnostic of diagnostics) {
603
+ const correctFilePath = (_a = diagnostic.data) === null || _a === void 0 ? void 0 : _a.correctFilePath;
604
+ if (!correctFilePath) {
605
+ continue;
606
+ }
607
+ changes.push({
608
+ type: 'replace',
609
+ filePath: this.event.file.srcPath,
610
+ range: diagnostic.location.range,
611
+ newText: correctFilePath
612
+ });
613
+ }
614
+ this.emitOrFixAll('Fix script import path casing', 'Fix all: Fix script import path casing', changes, diagnostics[0]);
615
+ }
616
+ // ---- override keyword fixes ----
617
+ /**
618
+ * Adds code actions to insert the missing `override` keyword before a method declaration.
619
+ */
620
+ suggestMissingOverrideQuickFixes(diagnostics) {
621
+ if (!(0, reflection_1.isBrsFile)(this.event.file)) {
622
+ return;
623
+ }
624
+ const file = this.event.file;
625
+ const changes = [];
626
+ for (const diagnostic of diagnostics) {
627
+ let insertPosition;
628
+ file.ast.walk((node) => {
629
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
630
+ if ((0, reflection_1.isMethodStatement)(node) &&
631
+ ((_c = (_b = (_a = node.location) === null || _a === void 0 ? void 0 : _a.range) === null || _b === void 0 ? void 0 : _b.start) === null || _c === void 0 ? void 0 : _c.line) === diagnostic.location.range.start.line &&
632
+ ((_f = (_e = (_d = node.location) === null || _d === void 0 ? void 0 : _d.range) === null || _e === void 0 ? void 0 : _e.start) === null || _f === void 0 ? void 0 : _f.character) === diagnostic.location.range.start.character) {
633
+ insertPosition = (_j = (_h = (_g = node.func.tokens.functionType) === null || _g === void 0 ? void 0 : _g.location) === null || _h === void 0 ? void 0 : _h.range) === null || _j === void 0 ? void 0 : _j.start;
634
+ }
635
+ }, { walkMode: visitors_1.WalkMode.visitStatementsRecursive });
636
+ if (insertPosition) {
637
+ changes.push({
638
+ type: 'insert',
639
+ filePath: file.srcPath,
640
+ position: insertPosition,
641
+ newText: 'override '
642
+ });
643
+ }
644
+ }
645
+ this.emitOrFixAll(`Add missing 'override' keyword`, `Fix all: Add missing 'override' keywords`, changes, diagnostics[0]);
646
+ }
647
+ /**
648
+ * Adds one code action per legal terminator. The first entry of `expected` is marked
649
+ * `isPreferred`, matching the parser's convention of listing the canonical terminator first.
650
+ */
651
+ suggestMismatchedEndingTokenQuickFixes(diagnostics) {
652
+ const { expected, found } = diagnostics[0].data;
653
+ for (let index = 0; index < expected.length; index++) {
654
+ const replacement = expected[index];
655
+ const changes = diagnostics.map(diagnostic => ({
656
+ type: 'replace',
657
+ filePath: this.event.file.srcPath,
658
+ range: diagnostic.location.range,
659
+ newText: replacement
660
+ }));
661
+ this.emitOrFixAll(`Convert '${found}' to '${replacement}'`, `Fix all: Convert '${found}' to '${replacement}'`, changes, diagnostics[0], index === 0);
662
+ }
663
+ }
664
+ /**
665
+ * Adds code actions to remove the invalid `override` keyword from a constructor method.
666
+ */
667
+ suggestRemoveOverrideFromConstructorQuickFixes(diagnostics) {
668
+ const changes = diagnostics.map(d => ({
669
+ type: 'delete',
670
+ filePath: this.event.file.srcPath,
671
+ // delete "override " (the keyword token plus the trailing space before function/sub)
672
+ range: util_1.util.createRange(d.location.range.start.line, d.location.range.start.character, d.location.range.end.line, d.location.range.end.character + 1)
673
+ }));
674
+ this.emitOrFixAll(`Remove 'override' from constructor`, `Fix all: Remove 'override' from constructors`, changes, diagnostics[0]);
675
+ }
676
+ // ---- change helpers ----
677
+ /**
678
+ * Builds a delete change that removes the return value from a `return <expr>` statement,
679
+ * leaving just a bare `return`.
680
+ */
681
+ getRemoveReturnValueChange(diagnostic) {
682
+ return {
683
+ type: 'delete',
684
+ filePath: this.event.file.srcPath,
685
+ range: util_1.util.createRange(diagnostic.location.range.start.line, diagnostic.location.range.start.character + 'return'.length, diagnostic.location.range.end.line, diagnostic.location.range.end.character)
686
+ };
687
+ }
688
+ /**
689
+ * Builds the change that deletes `) as <type>` from a function/sub declaration.
690
+ * Used for both `as void` on a function and any return type on a sub.
691
+ */
692
+ getRemoveFunctionReturnTypeChange(func) {
693
+ return {
694
+ type: 'delete',
695
+ filePath: this.event.file.srcPath,
696
+ // )| as <type>|
697
+ range: util_1.util.createRange(func.tokens.rightParen.location.range.start.line, func.tokens.rightParen.location.range.start.character + 1, func.returnTypeExpression.location.range.end.line, func.returnTypeExpression.location.range.end.character)
698
+ };
699
+ }
700
+ /**
701
+ * Emits a single code action when there is exactly one change, or a "fix all" composite
702
+ * action when there are multiple changes (same pattern as ESLint's "Fix all X problems").
703
+ * Does nothing when the changes array is empty.
704
+ */
705
+ emitOrFixAll(singleTitle, fixAllTitle, changes, diagnostic, isPreferred) {
706
+ if (changes.length === 0) {
707
+ return;
708
+ }
709
+ if (changes.length === 1) {
710
+ this.event.codeActions.push(CodeActionUtil_1.codeActionUtil.createCodeAction(Object.assign(Object.assign({ title: singleTitle, diagnostics: [diagnostic] }, (isPreferred ? { isPreferred: true } : {})), { kind: vscode_languageserver_1.CodeActionKind.QuickFix, changes: changes })));
711
+ }
712
+ else {
713
+ this.event.codeActions.push(CodeActionUtil_1.codeActionUtil.createCodeAction(Object.assign(Object.assign({ title: fixAllTitle }, (isPreferred ? { isPreferred: true } : {})), { kind: vscode_languageserver_1.CodeActionKind.QuickFix, changes: changes })));
714
+ }
715
+ }
113
716
  }
114
717
  exports.CodeActionsProcessor = CodeActionsProcessor;
718
+ /**
719
+ * Parses a comment's text and returns the directive details if it is one. Recognizes
720
+ * `'`, `rem`, and `<!-- -->` comment styles. Returns `null` for comments that aren't directives.
721
+ * `block` covers `bs:disable`. The `bs:enable` partner isn't surfaced since the quick fix only
722
+ * extends `bs:disable` directives.
723
+ */
724
+ function parseDisableComment(text) {
725
+ let inner = text;
726
+ if (inner.startsWith('<!--')) {
727
+ inner = inner.slice('<!--'.length);
728
+ if (inner.endsWith('-->')) {
729
+ inner = inner.slice(0, -('-->'.length));
730
+ }
731
+ }
732
+ else if (inner.startsWith(`'`)) {
733
+ inner = inner.slice(1);
734
+ }
735
+ else if (/^rem\b/i.test(inner)) {
736
+ inner = inner.slice('rem'.length);
737
+ }
738
+ inner = inner.trimStart();
739
+ const lower = inner.toLowerCase();
740
+ //match longest-prefix first so `bs:disable-line` doesn't get parsed as `bs:disable`
741
+ let directiveType;
742
+ let prefixLength;
743
+ if (lower.startsWith('bs:disable-next-line')) {
744
+ directiveType = 'next-line';
745
+ prefixLength = 'bs:disable-next-line'.length;
746
+ }
747
+ else if (lower.startsWith('bs:disable-line')) {
748
+ directiveType = 'line';
749
+ prefixLength = 'bs:disable-line'.length;
750
+ }
751
+ else if (lower.startsWith('bs:disable')) {
752
+ directiveType = 'block';
753
+ prefixLength = 'bs:disable'.length;
754
+ }
755
+ else {
756
+ return null;
757
+ }
758
+ inner = inner.slice(prefixLength);
759
+ if (inner.startsWith(':')) {
760
+ inner = inner.slice(1);
761
+ }
762
+ const codes = inner.trim().length === 0 ? [] : inner.trim().split(/\s+/);
763
+ return { directiveType: directiveType, codes: codes };
764
+ }
115
765
  //# sourceMappingURL=CodeActionsProcessor.js.map