brighterscript 0.66.0-alpha.1 → 0.66.0-alpha.11

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 (380) hide show
  1. package/CHANGELOG.md +224 -10
  2. package/README.md +13 -3
  3. package/bsconfig.schema.json +15 -0
  4. package/dist/ActionPipeline.d.ts +10 -0
  5. package/dist/ActionPipeline.js +40 -0
  6. package/dist/ActionPipeline.js.map +1 -0
  7. package/dist/AstValidationSegmenter.d.ts +25 -0
  8. package/dist/AstValidationSegmenter.js +150 -0
  9. package/dist/AstValidationSegmenter.js.map +1 -0
  10. package/dist/BsConfig.d.ts +13 -4
  11. package/dist/BusyStatusTracker.d.ts +31 -0
  12. package/dist/BusyStatusTracker.js +83 -0
  13. package/dist/BusyStatusTracker.js.map +1 -0
  14. package/dist/Cache.js +3 -3
  15. package/dist/Cache.js.map +1 -1
  16. package/dist/CacheVerifier.d.ts +0 -1
  17. package/dist/CodeActionUtil.d.ts +2 -2
  18. package/dist/CommentFlagProcessor.d.ts +4 -3
  19. package/dist/CommentFlagProcessor.js.map +1 -1
  20. package/dist/DiagnosticCollection.js +8 -5
  21. package/dist/DiagnosticCollection.js.map +1 -1
  22. package/dist/DiagnosticMessages.d.ts +34 -4
  23. package/dist/DiagnosticMessages.js +59 -4
  24. package/dist/DiagnosticMessages.js.map +1 -1
  25. package/dist/FunctionScope.d.ts +1 -1
  26. package/dist/LanguageServer.d.ts +23 -1
  27. package/dist/LanguageServer.js +139 -57
  28. package/dist/LanguageServer.js.map +1 -1
  29. package/dist/Logger.d.ts +3 -2
  30. package/dist/Logger.js +10 -2
  31. package/dist/Logger.js.map +1 -1
  32. package/dist/PluginInterface.d.ts +11 -2
  33. package/dist/PluginInterface.js +69 -10
  34. package/dist/PluginInterface.js.map +1 -1
  35. package/dist/Program.d.ts +138 -49
  36. package/dist/Program.js +644 -349
  37. package/dist/Program.js.map +1 -1
  38. package/dist/ProgramBuilder.d.ts +10 -4
  39. package/dist/ProgramBuilder.js +76 -74
  40. package/dist/ProgramBuilder.js.map +1 -1
  41. package/dist/Scope.d.ts +52 -49
  42. package/dist/Scope.js +298 -274
  43. package/dist/Scope.js.map +1 -1
  44. package/dist/SymbolTable.d.ts +35 -14
  45. package/dist/SymbolTable.js +90 -29
  46. package/dist/SymbolTable.js.map +1 -1
  47. package/dist/Throttler.d.ts +12 -0
  48. package/dist/Throttler.js +39 -0
  49. package/dist/Throttler.js.map +1 -1
  50. package/dist/XmlScope.d.ts +7 -4
  51. package/dist/XmlScope.js +52 -12
  52. package/dist/XmlScope.js.map +1 -1
  53. package/dist/astUtils/{AstEditor.d.ts → Editor.d.ts} +6 -1
  54. package/dist/astUtils/{AstEditor.js → Editor.js} +9 -3
  55. package/dist/astUtils/Editor.js.map +1 -0
  56. package/dist/astUtils/{AstEditor.spec.js → Editor.spec.js} +10 -6
  57. package/dist/astUtils/Editor.spec.js.map +1 -0
  58. package/dist/astUtils/creators.d.ts +3 -1
  59. package/dist/astUtils/creators.js +14 -4
  60. package/dist/astUtils/creators.js.map +1 -1
  61. package/dist/astUtils/reflection.d.ts +37 -9
  62. package/dist/astUtils/reflection.js +83 -14
  63. package/dist/astUtils/reflection.js.map +1 -1
  64. package/dist/astUtils/reflection.spec.js +87 -5
  65. package/dist/astUtils/reflection.spec.js.map +1 -1
  66. package/dist/astUtils/visitors.d.ts +14 -3
  67. package/dist/astUtils/visitors.js +22 -2
  68. package/dist/astUtils/visitors.js.map +1 -1
  69. package/dist/astUtils/visitors.spec.js +58 -7
  70. package/dist/astUtils/visitors.spec.js.map +1 -1
  71. package/dist/bscPlugin/BscPlugin.d.ts +10 -2
  72. package/dist/bscPlugin/BscPlugin.js +24 -4
  73. package/dist/bscPlugin/BscPlugin.js.map +1 -1
  74. package/dist/bscPlugin/CallExpressionInfo.d.ts +3 -3
  75. package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
  76. package/dist/bscPlugin/FileWriter.d.ts +6 -0
  77. package/dist/bscPlugin/FileWriter.js +24 -0
  78. package/dist/bscPlugin/FileWriter.js.map +1 -0
  79. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +8 -8
  80. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  81. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +4 -4
  82. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
  83. package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +50 -1
  84. package/dist/bscPlugin/completions/CompletionsProcessor.js +445 -23
  85. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
  86. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +1737 -0
  87. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -0
  88. package/dist/bscPlugin/fileProviders/FileProvider.d.ts +9 -0
  89. package/dist/bscPlugin/fileProviders/FileProvider.js +51 -0
  90. package/dist/bscPlugin/fileProviders/FileProvider.js.map +1 -0
  91. package/dist/bscPlugin/hover/HoverProcessor.d.ts +7 -3
  92. package/dist/bscPlugin/hover/HoverProcessor.js +133 -103
  93. package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
  94. package/dist/bscPlugin/hover/HoverProcessor.spec.js +241 -29
  95. package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
  96. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +1 -0
  97. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +43 -0
  98. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
  99. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +22 -0
  100. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -1
  101. package/dist/bscPlugin/serialize/BslibInjector.spec.js +19 -0
  102. package/dist/bscPlugin/serialize/BslibInjector.spec.js.map +1 -0
  103. package/dist/bscPlugin/serialize/BslibManager.d.ts +9 -0
  104. package/dist/bscPlugin/serialize/BslibManager.js +40 -0
  105. package/dist/bscPlugin/serialize/BslibManager.js.map +1 -0
  106. package/dist/bscPlugin/serialize/FileSerializer.d.ts +9 -0
  107. package/dist/bscPlugin/serialize/FileSerializer.js +72 -0
  108. package/dist/bscPlugin/serialize/FileSerializer.js.map +1 -0
  109. package/dist/bscPlugin/transpile/{BrsFilePreTranspileProcessor.d.ts → BrsFileTranspileProcessor.d.ts} +4 -2
  110. package/dist/bscPlugin/transpile/{BrsFilePreTranspileProcessor.js → BrsFileTranspileProcessor.js} +29 -5
  111. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -0
  112. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.d.ts +1 -0
  113. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js +41 -0
  114. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +1 -0
  115. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +2 -2
  116. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +1 -1
  117. package/dist/bscPlugin/validation/BrsFileValidator.d.ts +0 -4
  118. package/dist/bscPlugin/validation/BrsFileValidator.js +34 -29
  119. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
  120. package/dist/bscPlugin/validation/BrsFileValidator.spec.js +1 -1
  121. package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -1
  122. package/dist/bscPlugin/validation/ScopeValidator.d.ts +28 -7
  123. package/dist/bscPlugin/validation/ScopeValidator.js +393 -205
  124. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
  125. package/dist/bscPlugin/validation/ScopeValidator.spec.d.ts +1 -0
  126. package/dist/bscPlugin/validation/ScopeValidator.spec.js +2038 -0
  127. package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -0
  128. package/dist/bscPlugin/validation/XmlFileValidator.js +2 -2
  129. package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -1
  130. package/dist/cli.js +104 -13
  131. package/dist/cli.js.map +1 -1
  132. package/dist/deferred.d.ts +3 -3
  133. package/dist/deferred.js.map +1 -1
  134. package/dist/diagnosticUtils.d.ts +8 -2
  135. package/dist/diagnosticUtils.js +45 -16
  136. package/dist/diagnosticUtils.js.map +1 -1
  137. package/dist/examples/plugins/removePrint.js +1 -1
  138. package/dist/examples/plugins/removePrint.js.map +1 -1
  139. package/dist/files/AssetFile.d.ts +26 -0
  140. package/dist/files/AssetFile.js +26 -0
  141. package/dist/files/AssetFile.js.map +1 -0
  142. package/dist/files/BrsFile.Class.spec.js +383 -56
  143. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  144. package/dist/files/BrsFile.d.ts +73 -46
  145. package/dist/files/BrsFile.js +370 -534
  146. package/dist/files/BrsFile.js.map +1 -1
  147. package/dist/files/BrsFile.spec.js +1139 -682
  148. package/dist/files/BrsFile.spec.js.map +1 -1
  149. package/dist/files/Factory.d.ts +25 -0
  150. package/dist/files/Factory.js +22 -0
  151. package/dist/files/Factory.js.map +1 -0
  152. package/dist/files/File.d.ts +106 -0
  153. package/dist/files/File.js +16 -0
  154. package/dist/files/File.js.map +1 -0
  155. package/dist/files/LazyFileData.d.ts +20 -0
  156. package/dist/files/LazyFileData.js +54 -0
  157. package/dist/files/LazyFileData.js.map +1 -0
  158. package/dist/files/LazyFileData.spec.d.ts +1 -0
  159. package/dist/files/LazyFileData.spec.js +27 -0
  160. package/dist/files/LazyFileData.spec.js.map +1 -0
  161. package/dist/files/XmlFile.d.ts +56 -23
  162. package/dist/files/XmlFile.js +88 -60
  163. package/dist/files/XmlFile.js.map +1 -1
  164. package/dist/files/XmlFile.spec.js +64 -93
  165. package/dist/files/XmlFile.spec.js.map +1 -1
  166. package/dist/files/tests/imports.spec.js +21 -8
  167. package/dist/files/tests/imports.spec.js.map +1 -1
  168. package/dist/files/tests/optionalChaning.spec.js +14 -14
  169. package/dist/files/tests/optionalChaning.spec.js.map +1 -1
  170. package/dist/globalCallables.js +88 -84
  171. package/dist/globalCallables.js.map +1 -1
  172. package/dist/index.d.ts +9 -1
  173. package/dist/index.js +9 -1
  174. package/dist/index.js.map +1 -1
  175. package/dist/interfaces.d.ts +389 -94
  176. package/dist/interfaces.js +13 -2
  177. package/dist/interfaces.js.map +1 -1
  178. package/dist/lexer/Lexer.d.ts +12 -0
  179. package/dist/lexer/Lexer.js +28 -8
  180. package/dist/lexer/Lexer.js.map +1 -1
  181. package/dist/lexer/Lexer.spec.js +40 -0
  182. package/dist/lexer/Lexer.spec.js.map +1 -1
  183. package/dist/lexer/Token.d.ts +4 -0
  184. package/dist/lexer/Token.js.map +1 -1
  185. package/dist/lexer/TokenKind.d.ts +5 -0
  186. package/dist/lexer/TokenKind.js +14 -2
  187. package/dist/lexer/TokenKind.js.map +1 -1
  188. package/dist/parser/AstNode.d.ts +9 -2
  189. package/dist/parser/AstNode.js +16 -0
  190. package/dist/parser/AstNode.js.map +1 -1
  191. package/dist/parser/BrsTranspileState.d.ts +3 -2
  192. package/dist/parser/BrsTranspileState.js +3 -2
  193. package/dist/parser/BrsTranspileState.js.map +1 -1
  194. package/dist/parser/Expression.d.ts +21 -5
  195. package/dist/parser/Expression.js +130 -35
  196. package/dist/parser/Expression.js.map +1 -1
  197. package/dist/parser/Parser.Class.spec.js +103 -1
  198. package/dist/parser/Parser.Class.spec.js.map +1 -1
  199. package/dist/parser/Parser.d.ts +7 -0
  200. package/dist/parser/Parser.js +117 -21
  201. package/dist/parser/Parser.js.map +1 -1
  202. package/dist/parser/Parser.spec.js +557 -5
  203. package/dist/parser/Parser.spec.js.map +1 -1
  204. package/dist/parser/SGParser.d.ts +4 -4
  205. package/dist/parser/SGParser.js +3 -3
  206. package/dist/parser/SGParser.js.map +1 -1
  207. package/dist/parser/SGParser.spec.js +2 -2
  208. package/dist/parser/SGParser.spec.js.map +1 -1
  209. package/dist/parser/SGTypes.d.ts +2 -2
  210. package/dist/parser/Statement.d.ts +37 -12
  211. package/dist/parser/Statement.js +153 -46
  212. package/dist/parser/Statement.js.map +1 -1
  213. package/dist/parser/tests/Parser.spec.js +2 -1
  214. package/dist/parser/tests/Parser.spec.js.map +1 -1
  215. package/dist/parser/tests/controlFlow/For.spec.js +16 -8
  216. package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
  217. package/dist/parser/tests/controlFlow/ForEach.spec.js +12 -6
  218. package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
  219. package/dist/parser/tests/controlFlow/While.spec.js +8 -4
  220. package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
  221. package/dist/parser/tests/expression/Call.spec.js +4 -4
  222. package/dist/parser/tests/expression/Call.spec.js.map +1 -1
  223. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +29 -29
  224. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
  225. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +10 -10
  226. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -1
  227. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +24 -24
  228. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +1 -1
  229. package/dist/parser/tests/expression/TemplateStringExpression.spec.js +75 -36
  230. package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
  231. package/dist/parser/tests/expression/TernaryExpression.spec.js +36 -36
  232. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
  233. package/dist/parser/tests/expression/UnaryExpression.spec.d.ts +1 -0
  234. package/dist/parser/tests/expression/UnaryExpression.spec.js +52 -0
  235. package/dist/parser/tests/expression/UnaryExpression.spec.js.map +1 -0
  236. package/dist/parser/tests/statement/ConstStatement.spec.js +71 -22
  237. package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -1
  238. package/dist/parser/tests/statement/Continue.spec.js +2 -2
  239. package/dist/parser/tests/statement/Continue.spec.js.map +1 -1
  240. package/dist/parser/tests/statement/Enum.spec.js +38 -285
  241. package/dist/parser/tests/statement/Enum.spec.js.map +1 -1
  242. package/dist/parser/tests/statement/For.spec.js +6 -6
  243. package/dist/parser/tests/statement/For.spec.js.map +1 -1
  244. package/dist/parser/tests/statement/ForEach.spec.js +4 -4
  245. package/dist/parser/tests/statement/ForEach.spec.js.map +1 -1
  246. package/dist/parser/tests/statement/InterfaceStatement.spec.js +26 -10
  247. package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
  248. package/dist/parser/tests/statement/PrintStatement.spec.js +16 -13
  249. package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
  250. package/dist/parser/tests/statement/ReturnStatement.spec.js +5 -3
  251. package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
  252. package/dist/parser/tests/statement/Set.spec.js +26 -13
  253. package/dist/parser/tests/statement/Set.spec.js.map +1 -1
  254. package/dist/preprocessor/Manifest.d.ts +1 -1
  255. package/dist/preprocessor/Manifest.js +2 -2
  256. package/dist/preprocessor/Manifest.js.map +1 -1
  257. package/dist/roku-types/data.json +244 -294
  258. package/dist/roku-types/index.d.ts +17 -38
  259. package/dist/types/ArrayType.d.ts +4 -1
  260. package/dist/types/ArrayType.js +46 -6
  261. package/dist/types/ArrayType.js.map +1 -1
  262. package/dist/types/ArrayType.spec.js +32 -3
  263. package/dist/types/ArrayType.spec.js.map +1 -1
  264. package/dist/types/AssociativeArrayType.d.ts +11 -0
  265. package/dist/types/AssociativeArrayType.js +52 -0
  266. package/dist/types/AssociativeArrayType.js.map +1 -0
  267. package/dist/types/BaseFunctionType.d.ts +9 -0
  268. package/dist/types/BaseFunctionType.js +25 -0
  269. package/dist/types/BaseFunctionType.js.map +1 -0
  270. package/dist/types/BooleanType.d.ts +2 -1
  271. package/dist/types/BooleanType.js +8 -2
  272. package/dist/types/BooleanType.js.map +1 -1
  273. package/dist/types/BscType.d.ts +10 -6
  274. package/dist/types/BscType.js +69 -16
  275. package/dist/types/BscType.js.map +1 -1
  276. package/dist/types/BscTypeKind.d.ts +3 -0
  277. package/dist/types/BscTypeKind.js +3 -0
  278. package/dist/types/BscTypeKind.js.map +1 -1
  279. package/dist/types/BuiltInInterfaceAdder.d.ts +23 -0
  280. package/dist/types/BuiltInInterfaceAdder.js +164 -0
  281. package/dist/types/BuiltInInterfaceAdder.js.map +1 -0
  282. package/dist/types/BuiltInInterfaceAdder.spec.d.ts +1 -0
  283. package/dist/types/BuiltInInterfaceAdder.spec.js +116 -0
  284. package/dist/types/BuiltInInterfaceAdder.spec.js.map +1 -0
  285. package/dist/types/ClassType.d.ts +10 -4
  286. package/dist/types/ClassType.js +32 -5
  287. package/dist/types/ClassType.js.map +1 -1
  288. package/dist/types/ClassType.spec.js +5 -3
  289. package/dist/types/ClassType.spec.js.map +1 -1
  290. package/dist/types/ComponentType.d.ts +26 -0
  291. package/dist/types/ComponentType.js +83 -0
  292. package/dist/types/ComponentType.js.map +1 -0
  293. package/dist/types/DoubleType.d.ts +2 -1
  294. package/dist/types/DoubleType.js +9 -2
  295. package/dist/types/DoubleType.js.map +1 -1
  296. package/dist/types/DynamicType.d.ts +2 -2
  297. package/dist/types/DynamicType.js +3 -1
  298. package/dist/types/DynamicType.js.map +1 -1
  299. package/dist/types/EnumType.d.ts +24 -6
  300. package/dist/types/EnumType.js +29 -7
  301. package/dist/types/EnumType.js.map +1 -1
  302. package/dist/types/FloatType.d.ts +2 -1
  303. package/dist/types/FloatType.js +9 -2
  304. package/dist/types/FloatType.js.map +1 -1
  305. package/dist/types/FunctionType.d.ts +8 -20
  306. package/dist/types/FunctionType.js +17 -45
  307. package/dist/types/FunctionType.js.map +1 -1
  308. package/dist/types/InheritableType.d.ts +7 -4
  309. package/dist/types/InheritableType.js +67 -3
  310. package/dist/types/InheritableType.js.map +1 -1
  311. package/dist/types/IntegerType.d.ts +2 -1
  312. package/dist/types/IntegerType.js +9 -2
  313. package/dist/types/IntegerType.js.map +1 -1
  314. package/dist/types/InterfaceType.d.ts +6 -4
  315. package/dist/types/InterfaceType.js +8 -11
  316. package/dist/types/InterfaceType.js.map +1 -1
  317. package/dist/types/InterfaceType.spec.js +30 -2
  318. package/dist/types/InterfaceType.spec.js.map +1 -1
  319. package/dist/types/InvalidType.d.ts +2 -1
  320. package/dist/types/InvalidType.js +7 -1
  321. package/dist/types/InvalidType.js.map +1 -1
  322. package/dist/types/LongIntegerType.d.ts +2 -1
  323. package/dist/types/LongIntegerType.js +9 -2
  324. package/dist/types/LongIntegerType.js.map +1 -1
  325. package/dist/types/NamespaceType.d.ts +2 -1
  326. package/dist/types/NamespaceType.js +3 -0
  327. package/dist/types/NamespaceType.js.map +1 -1
  328. package/dist/types/ObjectType.d.ts +2 -2
  329. package/dist/types/ObjectType.js +5 -10
  330. package/dist/types/ObjectType.js.map +1 -1
  331. package/dist/types/ReferenceType.d.ts +15 -3
  332. package/dist/types/ReferenceType.js +173 -24
  333. package/dist/types/ReferenceType.js.map +1 -1
  334. package/dist/types/ReferenceType.spec.js +21 -6
  335. package/dist/types/ReferenceType.spec.js.map +1 -1
  336. package/dist/types/StringType.d.ts +2 -1
  337. package/dist/types/StringType.js +9 -2
  338. package/dist/types/StringType.js.map +1 -1
  339. package/dist/types/TypedFunctionType.d.ts +33 -0
  340. package/dist/types/TypedFunctionType.js +106 -0
  341. package/dist/types/TypedFunctionType.js.map +1 -0
  342. package/dist/types/TypedFunctionType.spec.d.ts +1 -0
  343. package/dist/types/TypedFunctionType.spec.js +122 -0
  344. package/dist/types/TypedFunctionType.spec.js.map +1 -0
  345. package/dist/types/UninitializedType.d.ts +2 -1
  346. package/dist/types/UninitializedType.js +1 -1
  347. package/dist/types/UninitializedType.js.map +1 -1
  348. package/dist/types/UnionType.d.ts +4 -2
  349. package/dist/types/UnionType.js +36 -4
  350. package/dist/types/UnionType.js.map +1 -1
  351. package/dist/types/UnionType.spec.js +46 -19
  352. package/dist/types/UnionType.spec.js.map +1 -1
  353. package/dist/types/VoidType.d.ts +2 -1
  354. package/dist/types/VoidType.js +7 -2
  355. package/dist/types/VoidType.js.map +1 -1
  356. package/dist/types/helper.spec.js +15 -0
  357. package/dist/types/helper.spec.js.map +1 -1
  358. package/dist/types/helpers.d.ts +5 -0
  359. package/dist/types/helpers.js +50 -3
  360. package/dist/types/helpers.js.map +1 -1
  361. package/dist/types/index.d.ts +1 -1
  362. package/dist/types/index.js +1 -1
  363. package/dist/types/index.js.map +1 -1
  364. package/dist/util.d.ts +71 -15
  365. package/dist/util.js +578 -150
  366. package/dist/util.js.map +1 -1
  367. package/dist/validators/ClassValidator.d.ts +0 -1
  368. package/dist/validators/ClassValidator.js +0 -22
  369. package/dist/validators/ClassValidator.js.map +1 -1
  370. package/package.json +3 -2
  371. package/dist/astUtils/AstEditor.js.map +0 -1
  372. package/dist/astUtils/AstEditor.spec.js.map +0 -1
  373. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +0 -1
  374. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js +0 -31
  375. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js.map +0 -1
  376. package/dist/types/FunctionType.spec.js +0 -23
  377. package/dist/types/FunctionType.spec.js.map +0 -1
  378. /package/dist/astUtils/{AstEditor.spec.d.ts → Editor.spec.d.ts} +0 -0
  379. /package/dist/bscPlugin/{transpile/BrsFilePreTranspileProcessor.spec.d.ts → completions/CompletionsProcessor.spec.d.ts} +0 -0
  380. /package/dist/{types/FunctionType.spec.d.ts → bscPlugin/serialize/BslibInjector.spec.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KeywordCompletions = exports.BrsFile = void 0;
3
+ exports.BrsFile = void 0;
4
4
  const source_map_1 = require("source-map");
5
5
  const vscode_languageserver_1 = require("vscode-languageserver");
6
6
  const vscode_languageserver_2 = require("vscode-languageserver");
@@ -22,23 +22,15 @@ const visitors_1 = require("../astUtils/visitors");
22
22
  const CommentFlagProcessor_1 = require("../CommentFlagProcessor");
23
23
  const vscode_uri_1 = require("vscode-uri");
24
24
  const SymbolTable_1 = require("../SymbolTable");
25
- const ClassType_1 = require("../types/ClassType");
26
- const creators_1 = require("../astUtils/creators");
27
- const FunctionType_1 = require("../types/FunctionType");
28
- const VoidType_1 = require("../types/VoidType");
25
+ const Editor_1 = require("../astUtils/Editor");
26
+ const AstValidationSegmenter_1 = require("../AstValidationSegmenter");
29
27
  /**
30
28
  * Holds all details about this file within the scope of the whole program
31
29
  */
32
30
  class BrsFile {
33
- constructor(srcPath,
34
- /**
35
- * The full pkg path to this file
36
- */
37
- pkgPath, program) {
38
- var _a, _b;
39
- this.srcPath = srcPath;
40
- this.pkgPath = pkgPath;
41
- this.program = program;
31
+ constructor(options) {
32
+ var _a, _b, _c;
33
+ this.type = 'BrsFile';
42
34
  /**
43
35
  * The parseMode used for the parser for this file
44
36
  */
@@ -55,31 +47,44 @@ class BrsFile {
55
47
  this.commentFlags = [];
56
48
  this.callables = [];
57
49
  this.functionCalls = [];
58
- /**
59
- * Does this file need to be transpiled?
60
- */
61
- this.needsTranspiled = false;
62
50
  this.scopesByFunc = new Map();
63
- this.srcPath = (0, util_1.standardizePath) `${this.srcPath}`;
64
- this.pkgPath = (0, util_1.standardizePath) `${this.pkgPath}`;
65
- this.dependencyGraphKey = this.pkgPath.toLowerCase();
66
- this.extension = util_1.util.getExtension(this.srcPath);
67
- //all BrighterScript files need to be transpiled
68
- if (((_a = this.extension) === null || _a === void 0 ? void 0 : _a.endsWith('.bs')) || ((_b = program === null || program === void 0 ? void 0 : program.options) === null || _b === void 0 ? void 0 : _b.allowBrighterScriptInBrightScript)) {
69
- this.needsTranspiled = true;
70
- this.parseMode = Parser_1.ParseMode.BrighterScript;
71
- }
72
- this.isTypedef = this.extension === '.d.bs';
73
- if (!this.isTypedef) {
74
- this.typedefKey = util_1.util.getTypedefPath(this.srcPath);
75
- }
76
- //global file doesn't have a program, so only resolve typedef info if we have a program
77
- if (this.program) {
78
- this.resolveTypedef();
51
+ this.validationSegmenter = new AstValidationSegmenter_1.AstValidationSegmenter();
52
+ if (options) {
53
+ this.srcPath = (0, util_1.standardizePath) `${options.srcPath}`;
54
+ this.destPath = (0, util_1.standardizePath) `${options.destPath}`;
55
+ this.program = options.program;
56
+ this.extension = util_1.util.getExtension(this.srcPath);
57
+ if (options.pkgPath) {
58
+ this.pkgPath = options.pkgPath;
59
+ }
60
+ else {
61
+ //don't rename .d.bs files to .d.brs
62
+ if (this.extension === '.d.bs') {
63
+ this.pkgPath = this.destPath;
64
+ }
65
+ else {
66
+ this.pkgPath = this.destPath.replace(/\.bs$/i, '.brs');
67
+ }
68
+ }
69
+ //all BrighterScript files need to be transpiled
70
+ if (((_a = this.extension) === null || _a === void 0 ? void 0 : _a.endsWith('.bs')) || ((_c = (_b = this.program) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.allowBrighterScriptInBrightScript)) {
71
+ this.parseMode = Parser_1.ParseMode.BrighterScript;
72
+ }
73
+ this.isTypedef = this.extension === '.d.bs';
74
+ if (!this.isTypedef) {
75
+ this.typedefKey = util_1.util.getTypedefPath(this.srcPath);
76
+ }
77
+ //global file doesn't have a program, so only resolve typedef info if we have a program
78
+ if (this.program) {
79
+ this.resolveTypedef();
80
+ }
79
81
  }
80
82
  }
83
+ /**
84
+ * @deprecated use `.diagnostics` instead
85
+ */
81
86
  getDiagnostics() {
82
- return [...this.diagnostics];
87
+ return this.diagnostics;
83
88
  }
84
89
  addDiagnostic(diagnostic) {
85
90
  if (!diagnostic.file) {
@@ -114,7 +119,7 @@ class BrsFile {
114
119
  if ((0, reflection_1.isImportStatement)(statement) && statement.filePathToken) {
115
120
  result.push({
116
121
  filePathRange: statement.filePathToken.range,
117
- pkgPath: util_1.util.getPkgPathFromTarget(this.pkgPath, statement.filePath),
122
+ destPath: util_1.util.getPkgPathFromTarget(this.destPath, statement.filePath),
118
123
  sourceFile: this,
119
124
  text: (_d = statement.filePathToken) === null || _d === void 0 ? void 0 : _d.text
120
125
  });
@@ -124,11 +129,26 @@ class BrsFile {
124
129
  })) !== null && _b !== void 0 ? _b : [];
125
130
  return result;
126
131
  }
132
+ /**
133
+ * Does this file need to be transpiled?
134
+ * @deprecated use the `.editor` property to push changes to the file, which will force transpilation
135
+ */
136
+ get needsTranspiled() {
137
+ var _a, _b, _c, _d;
138
+ if (this._needsTranspiled !== undefined) {
139
+ return this._needsTranspiled;
140
+ }
141
+ return !!(((_a = this.extension) === null || _a === void 0 ? void 0 : _a.endsWith('.bs')) || ((_c = (_b = this.program) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.allowBrighterScriptInBrightScript) || ((_d = this.editor) === null || _d === void 0 ? void 0 : _d.hasChanges));
142
+ }
143
+ set needsTranspiled(value) {
144
+ this._needsTranspiled = value;
145
+ }
127
146
  /**
128
147
  * The AST for this file
129
148
  */
130
149
  get ast() {
131
- return this.parser.ast;
150
+ var _a;
151
+ return (_a = this.parser) === null || _a === void 0 ? void 0 : _a.ast;
132
152
  }
133
153
  /**
134
154
  * Get the token at the specified position
@@ -182,23 +202,25 @@ class BrsFile {
182
202
  this.typedefFile = this.program.getFile(this.typedefKey);
183
203
  this.hasTypedef = !!this.typedefFile;
184
204
  }
205
+ onDependenciesChanged() {
206
+ this.resolveTypedef();
207
+ }
185
208
  /**
186
209
  * Attach the file to the dependency graph so it can monitor changes.
187
210
  * Also notify the dependency graph of our current dependencies so other dependents can be notified.
211
+ * @deprecated this does nothing. This functionality is now handled by the file api and will be deleted in v1
188
212
  */
189
- attachDependencyGraph(dependencyGraph) {
190
- var _a;
191
- (_a = this.unsubscribeFromDependencyGraph) === null || _a === void 0 ? void 0 : _a.call(this);
192
- //event that fires anytime a dependency changes
193
- this.unsubscribeFromDependencyGraph = dependencyGraph.onchange(this.dependencyGraphKey, () => {
194
- this.resolveTypedef();
195
- });
196
- const dependencies = this.ownScriptImports.filter(x => !!x.pkgPath).map(x => x.pkgPath.toLowerCase());
213
+ attachDependencyGraph(dependencyGraph) { }
214
+ /**
215
+ * The list of files that this file depends on
216
+ */
217
+ get dependencies() {
218
+ const result = this.ownScriptImports.filter(x => !!x.destPath).map(x => x.destPath.toLowerCase());
197
219
  //if this is a .brs file, watch for typedef changes
198
220
  if (this.extension === '.brs') {
199
- dependencies.push(util_1.util.getTypedefPath(this.pkgPath));
221
+ result.push(util_1.util.getTypedefPath(this.destPath));
200
222
  }
201
- dependencyGraph.addOrReplace(this.dependencyGraphKey, dependencies);
223
+ return result;
202
224
  }
203
225
  /**
204
226
  * Calculate the AST for this file
@@ -335,17 +357,12 @@ class BrsFile {
335
357
  }
336
358
  //add every parameter
337
359
  for (let param of func.parameters) {
338
- let paramType;
339
360
  scope.variableDeclarations.push({
340
361
  nameRange: param.name.range,
341
362
  lineIndex: param.name.range.start.line,
342
363
  name: param.name.text,
343
364
  getType: () => {
344
- if (this.program.options.enableTypeValidation) {
345
- return param.getType({ flags: SymbolTable_1.SymbolTypeFlag.typetime });
346
- }
347
- paramType = paramType !== null && paramType !== void 0 ? paramType : this.getBscTypeFromTypeExpression(param.typeExpression);
348
- return paramType;
365
+ return param.getType({ flags: SymbolTable_1.SymbolTypeFlag.typetime });
349
366
  }
350
367
  });
351
368
  }
@@ -381,106 +398,24 @@ class BrsFile {
381
398
  let scope = this.scopesByFunc.get(statement.findAncestor(reflection_1.isFunctionExpression));
382
399
  //skip variable declarations that are outside of any scope
383
400
  if (scope) {
384
- let assignmentType;
385
401
  scope.variableDeclarations.push({
386
402
  nameRange: statement.name.range,
387
403
  lineIndex: statement.name.range.start.line,
388
404
  name: statement.name.text,
389
405
  getType: () => {
390
- if (this.program.options.enableTypeValidation) {
391
- return statement.getType({ flags: SymbolTable_1.SymbolTypeFlag.runtime });
392
- }
393
- assignmentType = assignmentType !== null && assignmentType !== void 0 ? assignmentType : this.getBscTypeFromAssignment(statement, scope);
394
- return assignmentType;
406
+ return statement.getType({ flags: SymbolTable_1.SymbolTypeFlag.runtime });
395
407
  }
396
408
  });
397
409
  }
398
410
  }
399
411
  }
400
- /**
401
- * Short circuit full `node.getType()` calls - used when enableTypeValidation is false
402
- */
403
- getBscTypeFromTypeExpression(typeExpr, defaultValue) {
404
- var _a;
405
- const typeAsString = typeExpr === null || typeExpr === void 0 ? void 0 : typeExpr.getName();
406
- if (typeAsString) {
407
- return (_a = util_1.util.tokenToBscType((0, creators_1.createIdentifier)(typeAsString, typeExpr.range))) !== null && _a !== void 0 ? _a : new ClassType_1.ClassType(typeAsString);
408
- }
409
- if ((0, reflection_1.isLiteralExpression)(defaultValue)) {
410
- return defaultValue.getType({ flags: SymbolTable_1.SymbolTypeFlag.typetime });
411
- }
412
- return DynamicType_1.DynamicType.instance;
413
- }
414
- getFunctionTypeFromFuncExpr(expression, name) {
415
- let functionType = new FunctionType_1.FunctionType(this.getBscTypeFromTypeExpression(expression.returnTypeExpression));
416
- functionType.isSub = expression.functionType.text === 'sub';
417
- if (functionType.isSub) {
418
- functionType.returnType = new VoidType_1.VoidType();
419
- }
420
- functionType.setName(name);
421
- for (let param of expression.parameters) {
422
- let isOptional = !!param.defaultValue;
423
- functionType.addParameter(param.name.text, this.getBscTypeFromTypeExpression(param.typeExpression, param.defaultValue), isOptional);
424
- }
425
- return functionType;
426
- }
427
- /**
428
- * Short circuit full `node.getType()` calls - used when enableTypeValidation is false
429
- */
430
- getBscTypeFromAssignment(assignment, scope) {
431
- var _a, _b, _c, _d;
432
- const getTypeOptions = { flags: SymbolTable_1.SymbolTypeFlag.runtime };
433
- try {
434
- //function
435
- if ((0, reflection_1.isFunctionExpression)(assignment.value)) {
436
- return this.getFunctionTypeFromFuncExpr(assignment.value, assignment.name.text);
437
- //literal
438
- }
439
- else if ((0, reflection_1.isLiteralExpression)(assignment.value)) {
440
- return assignment.value.getType(getTypeOptions);
441
- //function call
442
- }
443
- else if ((0, reflection_1.isCallExpression)(assignment.value)) {
444
- let calleeName = (_b = (_a = assignment.value.callee) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.text;
445
- if (calleeName) {
446
- let func = this.getCallableByName(calleeName);
447
- if (func) {
448
- return func.type.returnType;
449
- }
450
- }
451
- }
452
- else if ((0, reflection_1.isVariableExpression)(assignment.value)) {
453
- let variableName = (_d = (_c = assignment.value) === null || _c === void 0 ? void 0 : _c.name) === null || _d === void 0 ? void 0 : _d.text;
454
- let variable = scope.getVariableByName(variableName);
455
- return variable.getType();
456
- }
457
- }
458
- catch (e) {
459
- //do nothing. Just return dynamic
460
- }
461
- //fallback to dynamic
462
- return DynamicType_1.DynamicType.instance;
463
- }
464
- getCallableByName(name) {
465
- name = name ? name.toLowerCase() : undefined;
466
- if (!name) {
467
- return;
468
- }
469
- for (let func of this.callables) {
470
- if (func.name.toLowerCase() === name) {
471
- return func;
472
- }
473
- }
474
- }
475
412
  findCallables() {
476
413
  var _a;
477
414
  for (let statement of (_a = this.parser.references.functionStatements) !== null && _a !== void 0 ? _a : []) {
478
415
  //extract the parameters
479
416
  let params = [];
480
417
  for (let param of statement.func.parameters) {
481
- const paramType = this.program.options.enableTypeValidation
482
- ? param.getType({ flags: SymbolTable_1.SymbolTypeFlag.typetime })
483
- : this.getBscTypeFromTypeExpression(param.typeExpression, param.defaultValue);
418
+ const paramType = param.getType({ flags: SymbolTable_1.SymbolTypeFlag.typetime });
484
419
  let callableParam = {
485
420
  name: param.name.text,
486
421
  type: paramType,
@@ -489,9 +424,7 @@ class BrsFile {
489
424
  };
490
425
  params.push(callableParam);
491
426
  }
492
- const funcType = this.program.options.enableTypeValidation
493
- ? statement.getType({ flags: SymbolTable_1.SymbolTypeFlag.typetime })
494
- : this.getFunctionTypeFromFuncExpr(statement.func, statement.name.text);
427
+ const funcType = statement.getType({ flags: SymbolTable_1.SymbolTypeFlag.typetime });
495
428
  this.callables.push({
496
429
  isSub: statement.func.functionType.text.toLowerCase() === 'sub',
497
430
  name: statement.name.text,
@@ -588,7 +521,8 @@ class BrsFile {
588
521
  name: functionName,
589
522
  nameRange: util_1.util.createRange(callee.range.start.line, columnIndexBegin, callee.range.start.line, columnIndexEnd),
590
523
  //TODO keep track of parameters
591
- args: args
524
+ args: args,
525
+ expression: expression
592
526
  };
593
527
  this.functionCalls.push(functionCall);
594
528
  }
@@ -634,346 +568,6 @@ class BrsFile {
634
568
  });
635
569
  }
636
570
  }
637
- /**
638
- * Get completions available at the given cursor. This aggregates all values from this file and the current scope.
639
- */
640
- getCompletions(position, scope) {
641
- let result = [];
642
- //a map of lower-case names of all added options
643
- let names = {};
644
- //handle script import completions
645
- let scriptImport = util_1.util.getScriptImportAtPosition(this.ownScriptImports, position);
646
- if (scriptImport) {
647
- return this.program.getScriptImportCompletions(this.pkgPath, scriptImport);
648
- }
649
- //if cursor is within a comment, disable completions
650
- let currentToken = this.getTokenAt(position);
651
- const tokenKind = currentToken === null || currentToken === void 0 ? void 0 : currentToken.kind;
652
- if (tokenKind === TokenKind_1.TokenKind.Comment) {
653
- return [];
654
- }
655
- else if (tokenKind === TokenKind_1.TokenKind.StringLiteral || tokenKind === TokenKind_1.TokenKind.TemplateStringQuasi) {
656
- const match = /^("?)(pkg|libpkg):/.exec(currentToken.text);
657
- if (match) {
658
- const [, openingQuote, fileProtocol] = match;
659
- //include every absolute file path from this scope
660
- for (const file of scope.getAllFiles()) {
661
- const pkgPath = `${fileProtocol}:/${file.pkgPath.replace(/\\/g, '/')}`;
662
- result.push({
663
- label: pkgPath,
664
- textEdit: vscode_languageserver_2.TextEdit.replace(util_1.util.createRange(currentToken.range.start.line,
665
- //+1 to step past the opening quote
666
- currentToken.range.start.character + (openingQuote ? 1 : 0), currentToken.range.end.line,
667
- //-1 to exclude the closing quotemark (or the end character if there is no closing quotemark)
668
- currentToken.range.end.character + (currentToken.text.endsWith('"') ? -1 : 0)), pkgPath),
669
- kind: vscode_languageserver_2.CompletionItemKind.File
670
- });
671
- }
672
- return result;
673
- }
674
- else {
675
- //do nothing. we don't want to show completions inside of strings...
676
- return [];
677
- }
678
- }
679
- const namespaceCompletions = this.getNamespaceCompletions(currentToken, this.parseMode, scope);
680
- if (namespaceCompletions.length > 0) {
681
- return [...namespaceCompletions];
682
- }
683
- const enumMemberCompletions = this.getEnumMemberStatementCompletions(currentToken, this.parseMode, scope);
684
- if (enumMemberCompletions.length > 0) {
685
- // no other completion is valid in this case
686
- return enumMemberCompletions;
687
- }
688
- //determine if cursor is inside a function
689
- let functionScope = this.getFunctionScopeAtPosition(position);
690
- if (!functionScope) {
691
- //we aren't in any function scope, so return the keyword completions and namespaces
692
- if (this.getTokenBefore(currentToken, TokenKind_1.TokenKind.New)) {
693
- // there's a new keyword, so only class types are viable here
694
- return [...this.getGlobalClassStatementCompletions(currentToken, this.parseMode)];
695
- }
696
- else {
697
- return [
698
- ...exports.KeywordCompletions,
699
- ...this.getGlobalClassStatementCompletions(currentToken, this.parseMode),
700
- ...namespaceCompletions,
701
- ...this.getNonNamespacedEnumStatementCompletions(currentToken, this.parseMode, scope)
702
- ];
703
- }
704
- }
705
- const classNameCompletions = this.getGlobalClassStatementCompletions(currentToken, this.parseMode);
706
- const newToken = this.getTokenBefore(currentToken, TokenKind_1.TokenKind.New);
707
- if (newToken) {
708
- //we are after a new keyword; so we can only be top-level namespaces or classes at this point
709
- result.push(...classNameCompletions);
710
- result.push(...namespaceCompletions);
711
- return result;
712
- }
713
- if (this.tokenFollows(currentToken, TokenKind_1.TokenKind.Goto)) {
714
- return this.getLabelCompletion(functionScope);
715
- }
716
- if (this.isPositionNextToTokenKind(position, TokenKind_1.TokenKind.Dot)) {
717
- const selfClassMemberCompletions = this.getClassMemberCompletions(position, currentToken, functionScope, scope);
718
- if (selfClassMemberCompletions.size > 0) {
719
- return [...selfClassMemberCompletions.values()].filter((i) => i.label !== 'new');
720
- }
721
- if (!this.getClassFromMReference(position, currentToken, functionScope)) {
722
- //and anything from any class in scope to a non m class
723
- let classMemberCompletions = scope.getAllClassMemberCompletions();
724
- result.push(...classMemberCompletions.values());
725
- result.push(...scope.getPropertyNameCompletions().filter((i) => !classMemberCompletions.has(i.label)));
726
- }
727
- else {
728
- result.push(...scope.getPropertyNameCompletions());
729
- }
730
- }
731
- else {
732
- result.push(
733
- //include namespaces
734
- ...namespaceCompletions,
735
- //include class names
736
- ...classNameCompletions,
737
- //include enums
738
- ...this.getNonNamespacedEnumStatementCompletions(currentToken, this.parseMode, scope),
739
- //include constants
740
- ...this.getNonNamespacedConstStatementCompletions(currentToken, this.parseMode, scope),
741
- //include the global callables
742
- ...scope.getCallablesAsCompletions(this.parseMode));
743
- //add `m` because that's always valid within a function
744
- result.push({
745
- label: 'm',
746
- kind: vscode_languageserver_2.CompletionItemKind.Variable
747
- });
748
- names.m = true;
749
- result.push(...exports.KeywordCompletions);
750
- //include local variables
751
- let variables = functionScope.variableDeclarations;
752
- for (let variable of variables) {
753
- //skip duplicate variable names
754
- if (names[variable.name.toLowerCase()]) {
755
- continue;
756
- }
757
- names[variable.name.toLowerCase()] = true;
758
- result.push({
759
- label: variable.name,
760
- kind: (0, reflection_1.isFunctionType)(variable.getType()) ? vscode_languageserver_2.CompletionItemKind.Function : vscode_languageserver_2.CompletionItemKind.Variable
761
- });
762
- }
763
- if (this.parseMode === Parser_1.ParseMode.BrighterScript) {
764
- //include the first part of namespaces
765
- let namespaces = scope.getAllNamespaceStatements();
766
- for (let stmt of namespaces) {
767
- let firstPart = util_1.util.getAllDottedGetParts(stmt.nameExpression).shift().text;
768
- //skip duplicate namespace names
769
- if (names[firstPart.toLowerCase()]) {
770
- continue;
771
- }
772
- names[firstPart.toLowerCase()] = true;
773
- result.push({
774
- label: firstPart,
775
- kind: vscode_languageserver_2.CompletionItemKind.Module
776
- });
777
- }
778
- }
779
- }
780
- return result;
781
- }
782
- getLabelCompletion(functionScope) {
783
- return functionScope.labelStatements.map(label => ({
784
- label: label.name,
785
- kind: vscode_languageserver_2.CompletionItemKind.Reference
786
- }));
787
- }
788
- getClassMemberCompletions(position, currentToken, functionScope, scope) {
789
- var _a, _b, _c, _d;
790
- let classStatement = this.getClassFromMReference(position, currentToken, functionScope);
791
- let results = new Map();
792
- if (classStatement) {
793
- let classes = scope.getClassHierarchy(classStatement.item.getName(Parser_1.ParseMode.BrighterScript).toLowerCase());
794
- for (let cs of classes) {
795
- for (let member of [...(_b = (_a = cs === null || cs === void 0 ? void 0 : cs.item) === null || _a === void 0 ? void 0 : _a.fields) !== null && _b !== void 0 ? _b : [], ...(_d = (_c = cs === null || cs === void 0 ? void 0 : cs.item) === null || _c === void 0 ? void 0 : _c.methods) !== null && _d !== void 0 ? _d : []]) {
796
- if (!results.has(member.name.text.toLowerCase())) {
797
- results.set(member.name.text.toLowerCase(), {
798
- label: member.name.text,
799
- kind: (0, reflection_1.isFieldStatement)(member) ? vscode_languageserver_2.CompletionItemKind.Field : vscode_languageserver_2.CompletionItemKind.Function
800
- });
801
- }
802
- }
803
- }
804
- }
805
- return results;
806
- }
807
- getClassFromMReference(position, currentToken, functionScope) {
808
- let previousToken = this.getPreviousToken(currentToken);
809
- if ((previousToken === null || previousToken === void 0 ? void 0 : previousToken.kind) === TokenKind_1.TokenKind.Dot) {
810
- previousToken = this.getPreviousToken(previousToken);
811
- }
812
- if ((previousToken === null || previousToken === void 0 ? void 0 : previousToken.kind) === TokenKind_1.TokenKind.Identifier && (previousToken === null || previousToken === void 0 ? void 0 : previousToken.text.toLowerCase()) === 'm' && (0, reflection_1.isMethodStatement)(functionScope.func.functionStatement)) {
813
- return { item: this.parser.references.classStatements.find((cs) => util_1.util.rangeContains(cs.range, position)), file: this };
814
- }
815
- return undefined;
816
- }
817
- getGlobalClassStatementCompletions(currentToken, parseMode) {
818
- var _a;
819
- if (parseMode === Parser_1.ParseMode.BrightScript) {
820
- return [];
821
- }
822
- let results = new Map();
823
- let completionName = (_a = this.getPartialVariableName(currentToken, [TokenKind_1.TokenKind.New])) === null || _a === void 0 ? void 0 : _a.toLowerCase();
824
- if (completionName === null || completionName === void 0 ? void 0 : completionName.includes('.')) {
825
- return [];
826
- }
827
- let scopes = this.program.getScopesForFile(this);
828
- for (let scope of scopes) {
829
- let classMap = scope.getClassMap();
830
- for (const key of [...classMap.keys()]) {
831
- let cs = classMap.get(key).item;
832
- if (!results.has(cs.name.text)) {
833
- results.set(cs.name.text, {
834
- label: cs.name.text,
835
- kind: vscode_languageserver_2.CompletionItemKind.Class
836
- });
837
- }
838
- }
839
- }
840
- return [...results.values()];
841
- }
842
- getNonNamespacedEnumStatementCompletions(currentToken, parseMode, scope) {
843
- var _a, _b;
844
- if (parseMode !== Parser_1.ParseMode.BrighterScript) {
845
- return [];
846
- }
847
- const containingNamespaceName = ((_b = this.getNamespaceStatementForPosition((_a = currentToken === null || currentToken === void 0 ? void 0 : currentToken.range) === null || _a === void 0 ? void 0 : _a.start)) === null || _b === void 0 ? void 0 : _b.name) + '.';
848
- const results = new Map();
849
- const enumMap = scope.getEnumMap();
850
- for (const key of [...enumMap.keys()]) {
851
- const enumStatement = enumMap.get(key).item;
852
- const fullName = enumStatement.fullName;
853
- //if the enum is contained within our own namespace, or if it's a non-namespaced enum
854
- if (fullName.startsWith(containingNamespaceName) || !fullName.includes('.')) {
855
- results.set(fullName, {
856
- label: enumStatement.name,
857
- kind: vscode_languageserver_2.CompletionItemKind.Enum
858
- });
859
- }
860
- }
861
- return [...results.values()];
862
- }
863
- getNonNamespacedConstStatementCompletions(currentToken, parseMode, scope) {
864
- var _a, _b;
865
- if (parseMode !== Parser_1.ParseMode.BrighterScript) {
866
- return [];
867
- }
868
- const containingNamespaceName = ((_b = this.getNamespaceStatementForPosition((_a = currentToken === null || currentToken === void 0 ? void 0 : currentToken.range) === null || _a === void 0 ? void 0 : _a.start)) === null || _b === void 0 ? void 0 : _b.name) + '.';
869
- const results = new Map();
870
- const map = scope.getConstMap();
871
- for (const key of [...map.keys()]) {
872
- const statement = map.get(key).item;
873
- const fullName = statement.fullName;
874
- //if the item is contained within our own namespace, or if it's non-namespaced
875
- if (fullName.startsWith(containingNamespaceName) || !fullName.includes('.')) {
876
- results.set(fullName, {
877
- label: statement.name,
878
- kind: vscode_languageserver_2.CompletionItemKind.Constant
879
- });
880
- }
881
- }
882
- return [...results.values()];
883
- }
884
- getEnumMemberStatementCompletions(currentToken, parseMode, scope) {
885
- var _a, _b, _c, _d, _e;
886
- if (parseMode === Parser_1.ParseMode.BrightScript || !currentToken) {
887
- return [];
888
- }
889
- const results = new Map();
890
- const completionName = (_a = this.getPartialVariableName(currentToken)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
891
- //if we don't have a completion name, or if there's no period in the name, then this is not to the right of an enum name
892
- if (!completionName || !completionName.includes('.')) {
893
- return [];
894
- }
895
- const enumNameLower = (_b = completionName === null || completionName === void 0 ? void 0 : completionName.split(/\.(\w+)?$/)[0]) === null || _b === void 0 ? void 0 : _b.toLowerCase();
896
- const namespaceNameLower = (_c = this.getNamespaceStatementForPosition(currentToken.range.end)) === null || _c === void 0 ? void 0 : _c.name.toLowerCase();
897
- const enumMap = scope.getEnumMap();
898
- //get the enum statement with this name (check without namespace prefix first, then with inferred namespace prefix next)
899
- const enumStatement = (_e = ((_d = enumMap.get(enumNameLower)) !== null && _d !== void 0 ? _d : enumMap.get(namespaceNameLower + '.' + enumNameLower))) === null || _e === void 0 ? void 0 : _e.item;
900
- //if we found an enum with this name
901
- if (enumStatement) {
902
- for (const member of enumStatement.getMembers()) {
903
- const name = enumStatement.fullName + '.' + member.name;
904
- const nameLower = name.toLowerCase();
905
- results.set(nameLower, {
906
- label: member.name,
907
- kind: vscode_languageserver_2.CompletionItemKind.EnumMember
908
- });
909
- }
910
- }
911
- return [...results.values()];
912
- }
913
- getNamespaceCompletions(currentToken, parseMode, scope) {
914
- //BrightScript does not support namespaces, so return an empty list in that case
915
- if (parseMode === Parser_1.ParseMode.BrightScript) {
916
- return [];
917
- }
918
- const completionName = this.getPartialVariableName(currentToken, [TokenKind_1.TokenKind.New]);
919
- //if we don't have a completion name, or if there's no period in the name, then this is not a namespaced variable
920
- if (!completionName || !completionName.includes('.')) {
921
- return [];
922
- }
923
- //remove any trailing identifer and then any trailing dot, to give us the
924
- //name of its immediate parent namespace
925
- let closestParentNamespaceName = completionName.replace(/\.([a-z0-9_]*)?$/gi, '').toLowerCase();
926
- let newToken = this.getTokenBefore(currentToken, TokenKind_1.TokenKind.New);
927
- let result = new Map();
928
- for (let [, namespace] of scope.namespaceLookup) {
929
- //completionName = "NameA."
930
- //completionName = "NameA.Na
931
- //NameA
932
- //NameA.NameB
933
- //NameA.NameB.NameC
934
- if (namespace.fullName.toLowerCase() === closestParentNamespaceName) {
935
- //add all of this namespace's immediate child namespaces, bearing in mind if we are after a new keyword
936
- for (let [, ns] of namespace.namespaces) {
937
- if (!newToken || ns.statements.find((s) => (0, reflection_1.isClassStatement)(s))) {
938
- if (!result.has(ns.lastPartName)) {
939
- result.set(ns.lastPartName, {
940
- label: ns.lastPartName,
941
- kind: vscode_languageserver_2.CompletionItemKind.Module
942
- });
943
- }
944
- }
945
- }
946
- //add function and class statement completions
947
- for (let stmt of namespace.statements) {
948
- if ((0, reflection_1.isClassStatement)(stmt)) {
949
- result.set(stmt.name.text, {
950
- label: stmt.name.text,
951
- kind: vscode_languageserver_2.CompletionItemKind.Class
952
- });
953
- }
954
- else if ((0, reflection_1.isFunctionStatement)(stmt) && !newToken) {
955
- result.set(stmt.name.text, {
956
- label: stmt.name.text,
957
- kind: vscode_languageserver_2.CompletionItemKind.Function
958
- });
959
- }
960
- else if ((0, reflection_1.isEnumStatement)(stmt) && !newToken) {
961
- result.set(stmt.name, {
962
- label: stmt.name,
963
- kind: vscode_languageserver_2.CompletionItemKind.Enum
964
- });
965
- }
966
- else if ((0, reflection_1.isConstStatement)(stmt) && !newToken) {
967
- result.set(stmt.name, {
968
- label: stmt.name,
969
- kind: vscode_languageserver_2.CompletionItemKind.Constant
970
- });
971
- }
972
- }
973
- }
974
- }
975
- return [...result.values()];
976
- }
977
571
  getNamespaceDefinitions(token, file) {
978
572
  //BrightScript does not support namespaces, so return an empty list in that case
979
573
  if (!token) {
@@ -1033,6 +627,9 @@ class BrsFile {
1033
627
  }
1034
628
  isPositionNextToTokenKind(position, tokenKind) {
1035
629
  const closestToken = this.getClosestToken(position);
630
+ return this.isTokenNextToTokenKind(closestToken, tokenKind);
631
+ }
632
+ isTokenNextToTokenKind(closestToken, tokenKind) {
1036
633
  const previousToken = this.getPreviousToken(closestToken);
1037
634
  const previousTokenKind = previousToken === null || previousToken === void 0 ? void 0 : previousToken.kind;
1038
635
  //next to matched token
@@ -1055,6 +652,9 @@ class BrsFile {
1055
652
  }
1056
653
  getTokenBefore(currentToken, tokenKind) {
1057
654
  const index = this.parser.tokens.indexOf(currentToken);
655
+ if (!tokenKind) {
656
+ return this.parser.tokens[index - 1];
657
+ }
1058
658
  for (let i = index - 1; i >= 0; i--) {
1059
659
  currentToken = this.parser.tokens[i];
1060
660
  if (currentToken.kind === TokenKind_1.TokenKind.Newline) {
@@ -1122,7 +722,10 @@ class BrsFile {
1122
722
  let scopes = this.program.getScopesForFile(this);
1123
723
  for (let scope of scopes) {
1124
724
  let namespace = scope.namespaceLookup.get(namespaceName.toLowerCase());
1125
- if (namespace.functionStatements[lowerCalleeName]) {
725
+ if (namespace.functionStatements.has(lowerCalleeName)) {
726
+ return true;
727
+ }
728
+ if (namespace.classStatements.has(lowerCalleeName)) {
1126
729
  return true;
1127
730
  }
1128
731
  }
@@ -1130,6 +733,29 @@ class BrsFile {
1130
733
  }
1131
734
  return false;
1132
735
  }
736
+ /**
737
+ * Determine if the callee (i.e. function name) is a known function
738
+ */
739
+ calleeIsKnownFunction(callee, namespaceName) {
740
+ var _a, _b;
741
+ //if we have a variable and a namespace
742
+ if ((0, reflection_1.isVariableExpression)(callee)) {
743
+ if (namespaceName) {
744
+ return this.calleeIsKnownNamespaceFunction(callee, namespaceName);
745
+ }
746
+ let scopes = this.program.getScopesForFile(this);
747
+ let lowerCalleeName = (_b = (_a = callee === null || callee === void 0 ? void 0 : callee.name) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.toLowerCase();
748
+ for (let scope of scopes) {
749
+ if (scope.getCallableByName(lowerCalleeName)) {
750
+ return true;
751
+ }
752
+ if (scope.getClass(lowerCalleeName)) {
753
+ return true;
754
+ }
755
+ }
756
+ }
757
+ return false;
758
+ }
1133
759
  /**
1134
760
  * Get the token closest to the position. if no token is found, the previous token is returned
1135
761
  */
@@ -1290,7 +916,7 @@ class BrsFile {
1290
916
  results.push(util_1.util.createLocation(vscode_uri_1.URI.file(constant.file.srcPath).toString(), constant.item.tokens.name.range));
1291
917
  return results;
1292
918
  }
1293
- if ((0, reflection_1.isDottedGetExpression)(expression)) {
919
+ if ((0, reflection_1.isDottedGetExpression)(expression) || (0, reflection_1.isVariableExpression)(expression)) {
1294
920
  const enumLink = scope.getEnumFileLink(fullName, containingNamespace);
1295
921
  if (enumLink) {
1296
922
  results.push(util_1.util.createLocation(vscode_uri_1.URI.file(enumLink.file.srcPath).toString(), enumLink.item.tokens.name.range));
@@ -1301,6 +927,16 @@ class BrsFile {
1301
927
  results.push(util_1.util.createLocation(vscode_uri_1.URI.file(enumMemberLink.file.srcPath).toString(), enumMemberLink.item.tokens.name.range));
1302
928
  return results;
1303
929
  }
930
+ const interfaceFileLink = scope.getInterfaceFileLink(fullName, containingNamespace);
931
+ if (interfaceFileLink) {
932
+ results.push(util_1.util.createLocation(vscode_uri_1.URI.file(interfaceFileLink.file.srcPath).toString(), interfaceFileLink.item.tokens.name.range));
933
+ return results;
934
+ }
935
+ const classFileLink = scope.getClassFileLink(fullName, containingNamespace);
936
+ if (classFileLink) {
937
+ results.push(util_1.util.createLocation(vscode_uri_1.URI.file(classFileLink.file.srcPath).toString(), classFileLink.item.name.range));
938
+ return results;
939
+ }
1304
940
  }
1305
941
  }
1306
942
  let textToSearchFor = token.text.toLowerCase();
@@ -1360,28 +996,27 @@ class BrsFile {
1360
996
  //look through all files in scope for matches
1361
997
  for (const scope of scopesForFile) {
1362
998
  for (const file of scope.getAllFiles()) {
1363
- if ((0, reflection_1.isXmlFile)(file) || filesSearched.has(file)) {
1364
- continue;
1365
- }
1366
- filesSearched.add(file);
1367
- if ((previousToken === null || previousToken === void 0 ? void 0 : previousToken.kind) === TokenKind_1.TokenKind.Dot && file.parseMode === Parser_1.ParseMode.BrighterScript) {
1368
- results.push(...this.getClassMemberDefinitions(textToSearchFor, file));
1369
- const namespaceDefinition = this.getNamespaceDefinitions(token, file);
1370
- if (namespaceDefinition) {
1371
- results.push(namespaceDefinition);
999
+ if ((0, reflection_1.isBrsFile)(file) && !filesSearched.has(file)) {
1000
+ filesSearched.add(file);
1001
+ if ((previousToken === null || previousToken === void 0 ? void 0 : previousToken.kind) === TokenKind_1.TokenKind.Dot && file.parseMode === Parser_1.ParseMode.BrighterScript) {
1002
+ results.push(...this.getClassMemberDefinitions(textToSearchFor, file));
1003
+ const namespaceDefinition = this.getNamespaceDefinitions(token, file);
1004
+ if (namespaceDefinition) {
1005
+ results.push(namespaceDefinition);
1006
+ }
1372
1007
  }
1008
+ const statementHandler = (statement) => {
1009
+ if (statement.getName(this.parseMode).toLowerCase() === textToSearchFor) {
1010
+ const uri = util_1.util.pathToUri(file.srcPath);
1011
+ results.push(util_1.util.createLocation(uri, statement.range));
1012
+ }
1013
+ };
1014
+ file.parser.ast.walk((0, visitors_1.createVisitor)({
1015
+ FunctionStatement: statementHandler
1016
+ }), {
1017
+ walkMode: visitors_1.WalkMode.visitStatements
1018
+ });
1373
1019
  }
1374
- const statementHandler = (statement) => {
1375
- if (statement.getName(this.parseMode).toLowerCase() === textToSearchFor) {
1376
- const uri = util_1.util.pathToUri(file.srcPath);
1377
- results.push(util_1.util.createLocation(uri, statement.range));
1378
- }
1379
- };
1380
- file.parser.ast.walk((0, visitors_1.createVisitor)({
1381
- FunctionStatement: statementHandler
1382
- }), {
1383
- walkMode: visitors_1.WalkMode.visitStatements
1384
- });
1385
1020
  }
1386
1021
  }
1387
1022
  return results;
@@ -1443,28 +1078,47 @@ class BrsFile {
1443
1078
  for (const scope of scopes) {
1444
1079
  const processedFiles = new Set();
1445
1080
  for (const file of scope.getAllFiles()) {
1446
- if ((0, reflection_1.isXmlFile)(file) || processedFiles.has(file)) {
1447
- continue;
1448
- }
1449
- processedFiles.add(file);
1450
- file.ast.walk((0, visitors_1.createVisitor)({
1451
- VariableExpression: (e) => {
1452
- if (e.name.text.toLowerCase() === searchFor) {
1453
- locations.push(util_1.util.createLocation(util_1.util.pathToUri(file.srcPath), e.range));
1081
+ if ((0, reflection_1.isBrsFile)(file) && !processedFiles.has(file)) {
1082
+ processedFiles.add(file);
1083
+ file.ast.walk((0, visitors_1.createVisitor)({
1084
+ VariableExpression: (e) => {
1085
+ if (e.name.text.toLowerCase() === searchFor) {
1086
+ locations.push(util_1.util.createLocation(util_1.util.pathToUri(file.srcPath), e.range));
1087
+ }
1454
1088
  }
1455
- }
1456
- }), {
1457
- walkMode: visitors_1.WalkMode.visitExpressionsRecursive
1458
- });
1089
+ }), {
1090
+ walkMode: visitors_1.WalkMode.visitExpressionsRecursive
1091
+ });
1092
+ }
1459
1093
  }
1460
1094
  }
1461
1095
  return locations;
1462
1096
  }
1097
+ /**
1098
+ * Generate the code, map, and typedef for this file
1099
+ */
1100
+ serialize() {
1101
+ const result = {};
1102
+ const transpiled = this.transpile();
1103
+ if (typeof transpiled.code === 'string') {
1104
+ result.code = transpiled.code;
1105
+ }
1106
+ if (transpiled.map) {
1107
+ result.map = transpiled.map.toString();
1108
+ }
1109
+ //generate the typedef (if this is not a typedef itself, and if enabled)
1110
+ if (!this.isTypedef && this.program.options.emitDefinitions) {
1111
+ result.typedef = this.getTypedef();
1112
+ }
1113
+ return result;
1114
+ }
1463
1115
  /**
1464
1116
  * Convert the brightscript/brighterscript source code into valid brightscript
1465
1117
  */
1466
1118
  transpile() {
1119
+ var _a;
1467
1120
  const state = new BrsTranspileState_1.BrsTranspileState(this);
1121
+ state.editor = (_a = this.editor) !== null && _a !== void 0 ? _a : new Editor_1.Editor();
1468
1122
  let transpileResult;
1469
1123
  if (this.needsTranspiled) {
1470
1124
  transpileResult = new source_map_1.SourceNode(null, null, state.srcPath, this.ast.transpile(state));
@@ -1477,8 +1131,11 @@ class BrsFile {
1477
1131
  //simple SourceNode wrapping the entire file to simplify the logic below
1478
1132
  transpileResult = new source_map_1.SourceNode(null, null, state.srcPath, this.fileContents);
1479
1133
  }
1480
- //undo any AST edits that the transpile cycle has made
1481
- state.editor.undoAll();
1134
+ //if we created an editor for this flow, undo the edits now
1135
+ if (!this.editor) {
1136
+ //undo any AST edits that the transpile cycle has made
1137
+ state.editor.undoAll();
1138
+ }
1482
1139
  if (this.program.options.sourceMap) {
1483
1140
  return new source_map_1.SourceNode(null, null, null, [
1484
1141
  transpileResult,
@@ -1493,6 +1150,201 @@ class BrsFile {
1493
1150
  };
1494
1151
  }
1495
1152
  }
1153
+ processSymbolInformation() {
1154
+ this.validationSegmenter.processTree(this.ast);
1155
+ this.program.addFileSymbolInfo(this);
1156
+ }
1157
+ getValidationSegments(changedSymbols) {
1158
+ const segments = this.validationSegmenter.getSegments(changedSymbols);
1159
+ return segments;
1160
+ }
1161
+ get requiredSymbols() {
1162
+ return this.cache.getOrAdd(`requiredSymbols`, () => {
1163
+ var _a;
1164
+ const allNeededSymbolSets = this.validationSegmenter.unresolvedSegmentsSymbols.values();
1165
+ const requiredSymbols = [];
1166
+ const addedSymbols = new Map();
1167
+ addedSymbols.set(SymbolTable_1.SymbolTypeFlag.runtime, new Set());
1168
+ addedSymbols.set(SymbolTable_1.SymbolTypeFlag.typetime, new Set());
1169
+ for (const setOfSymbols of allNeededSymbolSets) {
1170
+ for (const symbol of setOfSymbols) {
1171
+ const fullSymbolKey = symbol.typeChain.map(tce => tce.name).join('.').toLowerCase();
1172
+ if ((_a = this.providedSymbols.symbolMap.get(symbol.flags)) === null || _a === void 0 ? void 0 : _a.has(fullSymbolKey)) {
1173
+ // this catches namespaced things
1174
+ continue;
1175
+ }
1176
+ if (!addedSymbols.get(symbol.flags).has(fullSymbolKey)) {
1177
+ requiredSymbols.push(symbol);
1178
+ addedSymbols.get(symbol.flags).add(fullSymbolKey);
1179
+ }
1180
+ }
1181
+ }
1182
+ return requiredSymbols;
1183
+ });
1184
+ }
1185
+ get providedSymbols() {
1186
+ var _a;
1187
+ return (_a = this.cache) === null || _a === void 0 ? void 0 : _a.getOrAdd(`providedSymbols`, () => {
1188
+ return this.getProvidedSymbols();
1189
+ });
1190
+ }
1191
+ getProvidedSymbols() {
1192
+ var _a, _b;
1193
+ const symbolMap = new Map();
1194
+ const runTimeSymbolMap = new Map();
1195
+ const typeTimeSymbolMap = new Map();
1196
+ const tablesToGetSymbolsFrom = [{
1197
+ table: this.parser.symbolTable
1198
+ }];
1199
+ for (const namespaceStatement of this.parser.references.namespaceStatements) {
1200
+ tablesToGetSymbolsFrom.push({
1201
+ table: namespaceStatement.body.getSymbolTable(),
1202
+ namePrefixLower: namespaceStatement.getName(Parser_1.ParseMode.BrighterScript).toLowerCase()
1203
+ });
1204
+ }
1205
+ for (const symbolTable of tablesToGetSymbolsFrom) {
1206
+ const runTimeSymbols = symbolTable.table.getOwnSymbols(SymbolTable_1.SymbolTypeFlag.runtime);
1207
+ const typeTimeSymbols = symbolTable.table.getOwnSymbols(SymbolTable_1.SymbolTypeFlag.typetime);
1208
+ for (const symbol of runTimeSymbols) {
1209
+ if (!(0, reflection_1.isAnyReferenceType)(symbol.type)) {
1210
+ const symbolNameLower = symbolTable.namePrefixLower
1211
+ ? `${symbolTable.namePrefixLower}.${symbol.name.toLowerCase()}`
1212
+ : symbol.name.toLowerCase();
1213
+ runTimeSymbolMap.set(symbolNameLower, symbol);
1214
+ }
1215
+ }
1216
+ for (const symbol of typeTimeSymbols) {
1217
+ if (!(0, reflection_1.isAnyReferenceType)(symbol.type)) {
1218
+ const symbolNameLower = symbolTable.namePrefixLower
1219
+ ? `${symbolTable.namePrefixLower}.${symbol.name.toLowerCase()}`
1220
+ : symbol.name.toLowerCase();
1221
+ typeTimeSymbolMap.set(symbolNameLower, symbol);
1222
+ }
1223
+ }
1224
+ }
1225
+ symbolMap.set(SymbolTable_1.SymbolTypeFlag.runtime, runTimeSymbolMap);
1226
+ symbolMap.set(SymbolTable_1.SymbolTypeFlag.typetime, typeTimeSymbolMap);
1227
+ const changes = new Map();
1228
+ changes.set(SymbolTable_1.SymbolTypeFlag.runtime, new Set());
1229
+ changes.set(SymbolTable_1.SymbolTypeFlag.typetime, new Set());
1230
+ const previouslyProvidedSymbols = (_a = this.program.getFileSymbolInfo(this)) === null || _a === void 0 ? void 0 : _a.provides.symbolMap;
1231
+ const previousSymbolsChecked = new Map();
1232
+ previousSymbolsChecked.set(SymbolTable_1.SymbolTypeFlag.runtime, new Set());
1233
+ previousSymbolsChecked.set(SymbolTable_1.SymbolTypeFlag.typetime, new Set());
1234
+ for (const flag of [SymbolTable_1.SymbolTypeFlag.runtime, SymbolTable_1.SymbolTypeFlag.typetime]) {
1235
+ const newSymbolMapForFlag = symbolMap.get(flag);
1236
+ const oldSymbolMapForFlag = previouslyProvidedSymbols === null || previouslyProvidedSymbols === void 0 ? void 0 : previouslyProvidedSymbols.get(flag);
1237
+ const previousSymbolsCheckedForFlag = previousSymbolsChecked.get(flag);
1238
+ const changesForFlag = changes.get(flag);
1239
+ if (!oldSymbolMapForFlag) {
1240
+ for (const key of newSymbolMapForFlag.keys()) {
1241
+ changesForFlag.add(key);
1242
+ }
1243
+ continue;
1244
+ }
1245
+ for (const [symbolKey, symbol] of newSymbolMapForFlag) {
1246
+ const symbolType = symbol.type;
1247
+ const previousType = (_b = oldSymbolMapForFlag === null || oldSymbolMapForFlag === void 0 ? void 0 : oldSymbolMapForFlag.get(symbolKey)) === null || _b === void 0 ? void 0 : _b.type;
1248
+ previousSymbolsCheckedForFlag.add(symbolKey);
1249
+ if (!previousType) {
1250
+ changesForFlag.add(symbolKey);
1251
+ continue;
1252
+ }
1253
+ const data = {};
1254
+ if (!symbolType.isEqual(previousType, data)) {
1255
+ changesForFlag.add(symbolKey);
1256
+ }
1257
+ }
1258
+ for (const [symbolKey] of previouslyProvidedSymbols.get(flag)) {
1259
+ if (!previousSymbolsCheckedForFlag.has(symbolKey)) {
1260
+ changesForFlag.add(symbolKey);
1261
+ }
1262
+ }
1263
+ }
1264
+ return {
1265
+ symbolMap: symbolMap,
1266
+ changes: changes
1267
+ };
1268
+ }
1269
+ markSegmentAsValidated(node) {
1270
+ this.validationSegmenter.markSegmentAsValidated(node);
1271
+ }
1272
+ getNamespaceLookupObject() {
1273
+ if (!this.isValidated) {
1274
+ return this.buildNamespaceLookup();
1275
+ }
1276
+ return this.cache.getOrAdd(`namespaceLookup`, () => {
1277
+ const nsLookup = this.buildNamespaceLookup();
1278
+ return nsLookup;
1279
+ });
1280
+ }
1281
+ buildNamespaceLookup() {
1282
+ const namespaceLookup = new Map();
1283
+ for (let namespaceStatement of this.parser.references.namespaceStatements) {
1284
+ let nameParts = namespaceStatement.getNameParts();
1285
+ let loopName = null;
1286
+ let lowerLoopName = null;
1287
+ let parentNameLower = null;
1288
+ //ensure each namespace section is represented in the results
1289
+ //(so if the namespace name is A.B.C, this will make an entry for "A", an entry for "A.B", and an entry for "A.B.C"
1290
+ for (let i = 0; i < nameParts.length; i++) {
1291
+ let part = nameParts[i];
1292
+ let lowerPartName = part.text.toLowerCase();
1293
+ if (i === 0) {
1294
+ loopName = part.text;
1295
+ lowerLoopName = lowerPartName;
1296
+ }
1297
+ else {
1298
+ parentNameLower = lowerLoopName;
1299
+ loopName += '.' + part.text;
1300
+ lowerLoopName += '.' + lowerPartName;
1301
+ }
1302
+ if (!namespaceLookup.has(lowerLoopName)) {
1303
+ namespaceLookup.set(lowerLoopName, {
1304
+ isTopLevel: i === 0,
1305
+ file: this,
1306
+ fullName: loopName,
1307
+ fullNameLower: lowerLoopName,
1308
+ parentNameLower: parentNameLower,
1309
+ nameParts: nameParts.slice(0, i),
1310
+ nameRange: namespaceStatement.nameExpression.range,
1311
+ lastPartName: part.text,
1312
+ lastPartNameLower: lowerPartName,
1313
+ functionStatements: new Map(),
1314
+ namespaceStatements: [],
1315
+ namespaces: new Map(),
1316
+ classStatements: new Map(),
1317
+ enumStatements: new Map(),
1318
+ constStatements: new Map(),
1319
+ statements: [],
1320
+ // the aggregate symbol table should have no parent. It should include just the symbols of the namespace.
1321
+ symbolTable: new SymbolTable_1.SymbolTable(`Namespace Aggregate: '${loopName}'`)
1322
+ });
1323
+ }
1324
+ }
1325
+ let ns = namespaceLookup.get(lowerLoopName);
1326
+ ns.namespaceStatements.push(namespaceStatement);
1327
+ ns.statements.push(...namespaceStatement.body.statements);
1328
+ for (let statement of namespaceStatement.body.statements) {
1329
+ if ((0, reflection_1.isClassStatement)(statement) && statement.name) {
1330
+ ns.classStatements.set(statement.name.text.toLowerCase(), statement);
1331
+ }
1332
+ else if ((0, reflection_1.isFunctionStatement)(statement) && statement.name) {
1333
+ ns.functionStatements.set(statement.name.text.toLowerCase(), statement);
1334
+ }
1335
+ else if ((0, reflection_1.isEnumStatement)(statement) && statement.fullName) {
1336
+ ns.enumStatements.set(statement.fullName.toLowerCase(), statement);
1337
+ }
1338
+ else if ((0, reflection_1.isConstStatement)(statement) && statement.fullName) {
1339
+ ns.constStatements.set(statement.fullName.toLowerCase(), statement);
1340
+ }
1341
+ }
1342
+ // Merges all the symbol tables of the namespace statements into the new symbol table created above.
1343
+ // Set those symbol tables to have this new merged table as a parent
1344
+ ns.symbolTable.mergeSymbolTable(namespaceStatement.body.getSymbolTable());
1345
+ }
1346
+ return namespaceLookup;
1347
+ }
1496
1348
  getTypedef() {
1497
1349
  const state = new BrsTranspileState_1.BrsTranspileState(this);
1498
1350
  const typedef = this.ast.getTypedef(state);
@@ -1500,10 +1352,8 @@ class BrsFile {
1500
1352
  return programNode.toString();
1501
1353
  }
1502
1354
  dispose() {
1503
- var _a, _b;
1355
+ var _a;
1504
1356
  (_a = this._parser) === null || _a === void 0 ? void 0 : _a.dispose();
1505
- //unsubscribe from any DependencyGraph subscriptions
1506
- (_b = this.unsubscribeFromDependencyGraph) === null || _b === void 0 ? void 0 : _b.call(this);
1507
1357
  //deleting these properties result in lower memory usage (garbage collection is magic!)
1508
1358
  delete this.fileContents;
1509
1359
  delete this._parser;
@@ -1514,18 +1364,4 @@ class BrsFile {
1514
1364
  }
1515
1365
  }
1516
1366
  exports.BrsFile = BrsFile;
1517
- /**
1518
- * List of completions for all valid keywords/reserved words.
1519
- * Build this list once because it won't change for the lifetime of this process
1520
- */
1521
- exports.KeywordCompletions = Object.keys(TokenKind_1.Keywords)
1522
- //remove any keywords with whitespace
1523
- .filter(x => !x.includes(' '))
1524
- //create completions
1525
- .map(x => {
1526
- return {
1527
- label: x,
1528
- kind: vscode_languageserver_2.CompletionItemKind.Keyword
1529
- };
1530
- });
1531
1367
  //# sourceMappingURL=BrsFile.js.map