brighterscript 0.66.0-alpha.9 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (472) hide show
  1. package/CHANGELOG.md +116 -73
  2. package/README.md +14 -418
  3. package/dist/BsConfig.d.ts +25 -2
  4. package/dist/Cache.js +3 -3
  5. package/dist/Cache.js.map +1 -1
  6. package/dist/CodeActionUtil.d.ts +3 -3
  7. package/dist/CodeActionUtil.js.map +1 -1
  8. package/dist/CommentFlagProcessor.d.ts +3 -4
  9. package/dist/CommentFlagProcessor.js +4 -3
  10. package/dist/CommentFlagProcessor.js.map +1 -1
  11. package/dist/DependencyGraph.js +8 -8
  12. package/dist/DependencyGraph.js.map +1 -1
  13. package/dist/DiagnosticFilterer.d.ts +8 -4
  14. package/dist/DiagnosticFilterer.js +71 -38
  15. package/dist/DiagnosticFilterer.js.map +1 -1
  16. package/dist/DiagnosticMessages.d.ts +15 -36
  17. package/dist/DiagnosticMessages.js +15 -61
  18. package/dist/DiagnosticMessages.js.map +1 -1
  19. package/dist/DiagnosticSeverityAdjuster.js +3 -0
  20. package/dist/DiagnosticSeverityAdjuster.js.map +1 -1
  21. package/dist/FunctionScope.d.ts +2 -3
  22. package/dist/FunctionScope.js +0 -3
  23. package/dist/FunctionScope.js.map +1 -1
  24. package/dist/LanguageServer.d.ts +1 -2
  25. package/dist/LanguageServer.js +29 -35
  26. package/dist/LanguageServer.js.map +1 -1
  27. package/dist/Logger.d.ts +5 -9
  28. package/dist/Logger.js +18 -22
  29. package/dist/Logger.js.map +1 -1
  30. package/dist/PluginInterface.d.ts +13 -15
  31. package/dist/PluginInterface.js +16 -70
  32. package/dist/PluginInterface.js.map +1 -1
  33. package/dist/Program.d.ts +105 -138
  34. package/dist/Program.js +479 -702
  35. package/dist/Program.js.map +1 -1
  36. package/dist/ProgramBuilder.d.ts +8 -19
  37. package/dist/ProgramBuilder.js +82 -87
  38. package/dist/ProgramBuilder.js.map +1 -1
  39. package/dist/Scope.d.ts +56 -46
  40. package/dist/Scope.js +281 -217
  41. package/dist/Scope.js.map +1 -1
  42. package/dist/Stopwatch.js +1 -1
  43. package/dist/Stopwatch.js.map +1 -1
  44. package/dist/SymbolTable.d.ts +12 -68
  45. package/dist/SymbolTable.js +28 -213
  46. package/dist/SymbolTable.js.map +1 -1
  47. package/dist/XmlScope.d.ts +5 -7
  48. package/dist/XmlScope.js +36 -76
  49. package/dist/XmlScope.js.map +1 -1
  50. package/dist/astUtils/{Editor.d.ts → AstEditor.d.ts} +1 -6
  51. package/dist/astUtils/{Editor.js → AstEditor.js} +3 -9
  52. package/dist/astUtils/AstEditor.js.map +1 -0
  53. package/dist/astUtils/{Editor.spec.js → AstEditor.spec.js} +6 -10
  54. package/dist/astUtils/AstEditor.spec.js.map +1 -0
  55. package/dist/astUtils/creators.d.ts +8 -19
  56. package/dist/astUtils/creators.js +22 -54
  57. package/dist/astUtils/creators.js.map +1 -1
  58. package/dist/astUtils/creators.spec.js +0 -10
  59. package/dist/astUtils/creators.spec.js.map +1 -1
  60. package/dist/astUtils/reflection.d.ts +45 -81
  61. package/dist/astUtils/reflection.js +157 -220
  62. package/dist/astUtils/reflection.js.map +1 -1
  63. package/dist/astUtils/reflection.spec.js +19 -96
  64. package/dist/astUtils/reflection.spec.js.map +1 -1
  65. package/dist/astUtils/stackedVisitor.spec.js.map +1 -1
  66. package/dist/astUtils/visitors.d.ts +14 -18
  67. package/dist/astUtils/visitors.js +9 -22
  68. package/dist/astUtils/visitors.js.map +1 -1
  69. package/dist/astUtils/visitors.spec.js +9 -62
  70. package/dist/astUtils/visitors.spec.js.map +1 -1
  71. package/dist/astUtils/xml.d.ts +9 -9
  72. package/dist/astUtils/xml.js +6 -6
  73. package/dist/astUtils/xml.js.map +1 -1
  74. package/dist/bscPlugin/BscPlugin.d.ts +8 -11
  75. package/dist/bscPlugin/BscPlugin.js +21 -29
  76. package/dist/bscPlugin/BscPlugin.js.map +1 -1
  77. package/dist/bscPlugin/CallExpressionInfo.d.ts +6 -5
  78. package/dist/bscPlugin/CallExpressionInfo.js +2 -2
  79. package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
  80. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +11 -11
  81. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  82. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +4 -4
  83. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
  84. package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +1 -49
  85. package/dist/bscPlugin/completions/CompletionsProcessor.js +23 -424
  86. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
  87. package/dist/bscPlugin/definition/DefinitionProvider.d.ts +13 -0
  88. package/dist/bscPlugin/definition/DefinitionProvider.js +200 -0
  89. package/dist/bscPlugin/definition/DefinitionProvider.js.map +1 -0
  90. package/dist/bscPlugin/definition/DefinitionProvider.spec.js +87 -0
  91. package/dist/bscPlugin/definition/DefinitionProvider.spec.js.map +1 -0
  92. package/dist/bscPlugin/hover/HoverProcessor.d.ts +3 -7
  93. package/dist/bscPlugin/hover/HoverProcessor.js +88 -128
  94. package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
  95. package/dist/bscPlugin/hover/HoverProcessor.spec.js +24 -336
  96. package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
  97. package/dist/bscPlugin/references/ReferencesProvider.d.ts +12 -0
  98. package/dist/bscPlugin/references/ReferencesProvider.js +56 -0
  99. package/dist/bscPlugin/references/ReferencesProvider.js.map +1 -0
  100. package/dist/bscPlugin/references/ReferencesProvider.spec.js +51 -0
  101. package/dist/bscPlugin/references/ReferencesProvider.spec.js.map +1 -0
  102. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +0 -1
  103. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +5 -49
  104. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
  105. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +0 -22
  106. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -1
  107. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.d.ts +7 -0
  108. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.js +22 -0
  109. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.js.map +1 -0
  110. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js +290 -0
  111. package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js.map +1 -0
  112. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.d.ts +7 -0
  113. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.js +26 -0
  114. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.js.map +1 -0
  115. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js +245 -0
  116. package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js.map +1 -0
  117. package/dist/bscPlugin/symbols/symbolUtils.d.ts +5 -0
  118. package/dist/bscPlugin/symbols/symbolUtils.js +140 -0
  119. package/dist/bscPlugin/symbols/symbolUtils.js.map +1 -0
  120. package/dist/bscPlugin/transpile/{BrsFileTranspileProcessor.d.ts → BrsFilePreTranspileProcessor.d.ts} +2 -4
  121. package/dist/bscPlugin/transpile/{BrsFileTranspileProcessor.js → BrsFilePreTranspileProcessor.js} +15 -36
  122. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +1 -0
  123. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js +46 -0
  124. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js.map +1 -0
  125. package/dist/bscPlugin/validation/BrsFileValidator.d.ts +1 -0
  126. package/dist/bscPlugin/validation/BrsFileValidator.js +30 -41
  127. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
  128. package/dist/bscPlugin/validation/BrsFileValidator.spec.js +2 -2
  129. package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -1
  130. package/dist/bscPlugin/validation/ProgramValidator.d.ts +3 -3
  131. package/dist/bscPlugin/validation/ProgramValidator.js +6 -6
  132. package/dist/bscPlugin/validation/ProgramValidator.js.map +1 -1
  133. package/dist/bscPlugin/validation/ScopeValidator.d.ts +6 -28
  134. package/dist/bscPlugin/validation/ScopeValidator.js +166 -387
  135. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
  136. package/dist/bscPlugin/validation/XmlFileValidator.js +9 -9
  137. package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -1
  138. package/dist/diagnosticUtils.d.ts +2 -3
  139. package/dist/diagnosticUtils.js +5 -5
  140. package/dist/diagnosticUtils.js.map +1 -1
  141. package/dist/examples/plugins/removePrint.js +1 -1
  142. package/dist/examples/plugins/removePrint.js.map +1 -1
  143. package/dist/files/BrsFile.Class.spec.js +143 -114
  144. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  145. package/dist/files/BrsFile.d.ts +61 -83
  146. package/dist/files/BrsFile.js +552 -607
  147. package/dist/files/BrsFile.js.map +1 -1
  148. package/dist/files/BrsFile.spec.js +1365 -1201
  149. package/dist/files/BrsFile.spec.js.map +1 -1
  150. package/dist/files/XmlFile.d.ts +28 -56
  151. package/dist/files/XmlFile.js +103 -89
  152. package/dist/files/XmlFile.js.map +1 -1
  153. package/dist/files/XmlFile.spec.js +179 -122
  154. package/dist/files/XmlFile.spec.js.map +1 -1
  155. package/dist/files/tests/imports.spec.js +19 -29
  156. package/dist/files/tests/imports.spec.js.map +1 -1
  157. package/dist/files/tests/optionalChaning.spec.js +14 -14
  158. package/dist/files/tests/optionalChaning.spec.js.map +1 -1
  159. package/dist/globalCallables.js +83 -88
  160. package/dist/globalCallables.js.map +1 -1
  161. package/dist/index.d.ts +1 -9
  162. package/dist/index.js +1 -9
  163. package/dist/index.js.map +1 -1
  164. package/dist/interfaces.d.ts +173 -423
  165. package/dist/interfaces.js +0 -24
  166. package/dist/interfaces.js.map +1 -1
  167. package/dist/lexer/Lexer.d.ts +9 -15
  168. package/dist/lexer/Lexer.js +35 -46
  169. package/dist/lexer/Lexer.js.map +1 -1
  170. package/dist/lexer/Lexer.spec.js +48 -40
  171. package/dist/lexer/Lexer.spec.js.map +1 -1
  172. package/dist/lexer/Token.d.ts +1 -5
  173. package/dist/lexer/Token.js +1 -1
  174. package/dist/lexer/Token.js.map +1 -1
  175. package/dist/lexer/TokenKind.d.ts +0 -6
  176. package/dist/lexer/TokenKind.js +2 -14
  177. package/dist/lexer/TokenKind.js.map +1 -1
  178. package/dist/logging.d.ts +9 -0
  179. package/dist/logging.js +16 -0
  180. package/dist/logging.js.map +1 -0
  181. package/dist/parser/AstNode.d.ts +6 -90
  182. package/dist/parser/AstNode.js +5 -96
  183. package/dist/parser/AstNode.js.map +1 -1
  184. package/dist/parser/AstNode.spec.js.map +1 -1
  185. package/dist/parser/BrsTranspileState.d.ts +3 -4
  186. package/dist/parser/BrsTranspileState.js +2 -3
  187. package/dist/parser/BrsTranspileState.js.map +1 -1
  188. package/dist/parser/Expression.d.ts +114 -137
  189. package/dist/parser/Expression.js +244 -373
  190. package/dist/parser/Expression.js.map +1 -1
  191. package/dist/parser/Parser.Class.spec.js +19 -46
  192. package/dist/parser/Parser.Class.spec.js.map +1 -1
  193. package/dist/parser/Parser.d.ts +18 -14
  194. package/dist/parser/Parser.js +196 -175
  195. package/dist/parser/Parser.js.map +1 -1
  196. package/dist/parser/Parser.spec.d.ts +0 -2
  197. package/dist/parser/Parser.spec.js +10 -674
  198. package/dist/parser/Parser.spec.js.map +1 -1
  199. package/dist/parser/SGParser.d.ts +6 -44
  200. package/dist/parser/SGParser.js +198 -194
  201. package/dist/parser/SGParser.js.map +1 -1
  202. package/dist/parser/SGParser.spec.js +11 -14
  203. package/dist/parser/SGParser.spec.js.map +1 -1
  204. package/dist/parser/SGTypes.d.ts +52 -280
  205. package/dist/parser/SGTypes.js +185 -562
  206. package/dist/parser/SGTypes.js.map +1 -1
  207. package/dist/parser/Statement.d.ts +140 -172
  208. package/dist/parser/Statement.js +201 -337
  209. package/dist/parser/Statement.js.map +1 -1
  210. package/dist/parser/Statement.spec.js.map +1 -1
  211. package/dist/parser/TranspileState.d.ts +3 -2
  212. package/dist/parser/TranspileState.js +8 -10
  213. package/dist/parser/TranspileState.js.map +1 -1
  214. package/dist/parser/tests/Parser.spec.js +3 -5
  215. package/dist/parser/tests/Parser.spec.js.map +1 -1
  216. package/dist/parser/tests/controlFlow/For.spec.js +8 -16
  217. package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
  218. package/dist/parser/tests/controlFlow/ForEach.spec.js +6 -12
  219. package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
  220. package/dist/parser/tests/controlFlow/While.spec.js +4 -8
  221. package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
  222. package/dist/parser/tests/expression/Call.spec.js +4 -4
  223. package/dist/parser/tests/expression/Call.spec.js.map +1 -1
  224. package/dist/parser/tests/expression/Indexing.spec.js +25 -0
  225. package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
  226. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +73 -29
  227. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
  228. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +10 -10
  229. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -1
  230. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +24 -24
  231. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +1 -1
  232. package/dist/parser/tests/expression/TemplateStringExpression.spec.js +47 -35
  233. package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
  234. package/dist/parser/tests/expression/TernaryExpression.spec.js +83 -36
  235. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
  236. package/dist/parser/tests/expression/UnaryExpression.spec.js +2 -2
  237. package/dist/parser/tests/expression/UnaryExpression.spec.js.map +1 -1
  238. package/dist/parser/tests/statement/ConstStatement.spec.js +26 -27
  239. package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -1
  240. package/dist/parser/tests/statement/Continue.spec.js +2 -2
  241. package/dist/parser/tests/statement/Continue.spec.js.map +1 -1
  242. package/dist/parser/tests/statement/Dim.spec.js.map +1 -1
  243. package/dist/parser/tests/statement/Enum.spec.js +393 -90
  244. package/dist/parser/tests/statement/Enum.spec.js.map +1 -1
  245. package/dist/parser/tests/statement/For.spec.js +6 -6
  246. package/dist/parser/tests/statement/For.spec.js.map +1 -1
  247. package/dist/parser/tests/statement/ForEach.spec.js +4 -4
  248. package/dist/parser/tests/statement/ForEach.spec.js.map +1 -1
  249. package/dist/parser/tests/statement/Function.spec.js +1 -1
  250. package/dist/parser/tests/statement/Function.spec.js.map +1 -1
  251. package/dist/parser/tests/statement/InterfaceStatement.spec.js +18 -18
  252. package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
  253. package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
  254. package/dist/parser/tests/statement/PrintStatement.spec.js +13 -16
  255. package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
  256. package/dist/parser/tests/statement/ReturnStatement.spec.js +3 -5
  257. package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
  258. package/dist/parser/tests/statement/Set.spec.js +13 -26
  259. package/dist/parser/tests/statement/Set.spec.js.map +1 -1
  260. package/dist/parser/tests/statement/Throw.spec.js.map +1 -1
  261. package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
  262. package/dist/preprocessor/Chunk.js +1 -2
  263. package/dist/preprocessor/Chunk.js.map +1 -1
  264. package/dist/preprocessor/Preprocessor.d.ts +3 -4
  265. package/dist/preprocessor/Preprocessor.js +3 -3
  266. package/dist/preprocessor/Preprocessor.js.map +1 -1
  267. package/dist/preprocessor/PreprocessorParser.js +8 -1
  268. package/dist/preprocessor/PreprocessorParser.js.map +1 -1
  269. package/dist/roku-types/data.json +293 -243
  270. package/dist/roku-types/index.d.ts +38 -17
  271. package/dist/types/ArrayType.d.ts +4 -9
  272. package/dist/types/ArrayType.js +24 -72
  273. package/dist/types/ArrayType.js.map +1 -1
  274. package/dist/types/ArrayType.spec.js +10 -39
  275. package/dist/types/ArrayType.spec.js.map +1 -1
  276. package/dist/types/BooleanType.d.ts +4 -8
  277. package/dist/types/BooleanType.js +8 -19
  278. package/dist/types/BooleanType.js.map +1 -1
  279. package/dist/types/BooleanType.spec.js +3 -9
  280. package/dist/types/BooleanType.spec.js.map +1 -1
  281. package/dist/types/BscType.d.ts +2 -29
  282. package/dist/types/BscType.js +0 -113
  283. package/dist/types/BscType.js.map +1 -1
  284. package/dist/types/CustomType.d.ts +9 -0
  285. package/dist/types/CustomType.js +32 -0
  286. package/dist/types/CustomType.js.map +1 -0
  287. package/dist/types/DoubleType.d.ts +4 -8
  288. package/dist/types/DoubleType.js +20 -23
  289. package/dist/types/DoubleType.js.map +1 -1
  290. package/dist/types/DoubleType.spec.js +3 -11
  291. package/dist/types/DoubleType.spec.js.map +1 -1
  292. package/dist/types/DynamicType.d.ts +3 -9
  293. package/dist/types/DynamicType.js +2 -18
  294. package/dist/types/DynamicType.js.map +1 -1
  295. package/dist/types/DynamicType.spec.js +4 -15
  296. package/dist/types/DynamicType.spec.js.map +1 -1
  297. package/dist/types/FloatType.d.ts +4 -8
  298. package/dist/types/FloatType.js +20 -23
  299. package/dist/types/FloatType.js.map +1 -1
  300. package/dist/types/FloatType.spec.js +3 -3
  301. package/dist/types/FloatType.spec.js.map +1 -1
  302. package/dist/types/FunctionType.d.ts +20 -10
  303. package/dist/types/FunctionType.js +52 -27
  304. package/dist/types/FunctionType.js.map +1 -1
  305. package/dist/types/FunctionType.spec.js +23 -0
  306. package/dist/types/FunctionType.spec.js.map +1 -0
  307. package/dist/types/IntegerType.d.ts +4 -8
  308. package/dist/types/IntegerType.js +20 -23
  309. package/dist/types/IntegerType.js.map +1 -1
  310. package/dist/types/IntegerType.spec.js +3 -7
  311. package/dist/types/IntegerType.spec.js.map +1 -1
  312. package/dist/types/InterfaceType.d.ts +10 -12
  313. package/dist/types/InterfaceType.js +48 -23
  314. package/dist/types/InterfaceType.js.map +1 -1
  315. package/dist/types/InterfaceType.spec.js +45 -82
  316. package/dist/types/InterfaceType.spec.js.map +1 -1
  317. package/dist/types/InvalidType.d.ts +4 -7
  318. package/dist/types/InvalidType.js +8 -18
  319. package/dist/types/InvalidType.js.map +1 -1
  320. package/dist/types/InvalidType.spec.js +3 -7
  321. package/dist/types/InvalidType.spec.js.map +1 -1
  322. package/dist/types/LongIntegerType.d.ts +4 -8
  323. package/dist/types/LongIntegerType.js +20 -23
  324. package/dist/types/LongIntegerType.js.map +1 -1
  325. package/dist/types/LongIntegerType.spec.js +3 -9
  326. package/dist/types/LongIntegerType.spec.js.map +1 -1
  327. package/dist/types/ObjectType.d.ts +4 -8
  328. package/dist/types/ObjectType.js +7 -21
  329. package/dist/types/ObjectType.js.map +1 -1
  330. package/dist/types/ObjectType.spec.js +2 -2
  331. package/dist/types/ObjectType.spec.js.map +1 -1
  332. package/dist/types/StringType.d.ts +4 -11
  333. package/dist/types/StringType.js +8 -23
  334. package/dist/types/StringType.js.map +1 -1
  335. package/dist/types/StringType.spec.js +2 -2
  336. package/dist/types/StringType.spec.js.map +1 -1
  337. package/dist/types/UninitializedType.d.ts +3 -7
  338. package/dist/types/UninitializedType.js +3 -14
  339. package/dist/types/UninitializedType.js.map +1 -1
  340. package/dist/types/VoidType.d.ts +4 -8
  341. package/dist/types/VoidType.js +8 -18
  342. package/dist/types/VoidType.js.map +1 -1
  343. package/dist/types/VoidType.spec.js +2 -2
  344. package/dist/types/VoidType.spec.js.map +1 -1
  345. package/dist/util.d.ts +43 -104
  346. package/dist/util.js +243 -640
  347. package/dist/util.js.map +1 -1
  348. package/dist/validators/ClassValidator.d.ts +6 -1
  349. package/dist/validators/ClassValidator.js +61 -20
  350. package/dist/validators/ClassValidator.js.map +1 -1
  351. package/package.json +13 -11
  352. package/dist/ActionPipeline.d.ts +0 -10
  353. package/dist/ActionPipeline.js +0 -40
  354. package/dist/ActionPipeline.js.map +0 -1
  355. package/dist/AstValidationSegmenter.d.ts +0 -25
  356. package/dist/AstValidationSegmenter.js +0 -150
  357. package/dist/AstValidationSegmenter.js.map +0 -1
  358. package/dist/CacheVerifier.d.ts +0 -7
  359. package/dist/CacheVerifier.js +0 -20
  360. package/dist/CacheVerifier.js.map +0 -1
  361. package/dist/astUtils/Editor.js.map +0 -1
  362. package/dist/astUtils/Editor.spec.js.map +0 -1
  363. package/dist/bscPlugin/FileWriter.d.ts +0 -6
  364. package/dist/bscPlugin/FileWriter.js +0 -24
  365. package/dist/bscPlugin/FileWriter.js.map +0 -1
  366. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +0 -1658
  367. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +0 -1
  368. package/dist/bscPlugin/fileProviders/FileProvider.d.ts +0 -9
  369. package/dist/bscPlugin/fileProviders/FileProvider.js +0 -51
  370. package/dist/bscPlugin/fileProviders/FileProvider.js.map +0 -1
  371. package/dist/bscPlugin/serialize/BslibInjector.spec.js +0 -19
  372. package/dist/bscPlugin/serialize/BslibInjector.spec.js.map +0 -1
  373. package/dist/bscPlugin/serialize/BslibManager.d.ts +0 -9
  374. package/dist/bscPlugin/serialize/BslibManager.js +0 -40
  375. package/dist/bscPlugin/serialize/BslibManager.js.map +0 -1
  376. package/dist/bscPlugin/serialize/FileSerializer.d.ts +0 -9
  377. package/dist/bscPlugin/serialize/FileSerializer.js +0 -72
  378. package/dist/bscPlugin/serialize/FileSerializer.js.map +0 -1
  379. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +0 -1
  380. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js +0 -41
  381. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +0 -1
  382. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +0 -11
  383. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js +0 -53
  384. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +0 -1
  385. package/dist/bscPlugin/validation/ScopeValidator.spec.js +0 -2004
  386. package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +0 -1
  387. package/dist/files/AssetFile.d.ts +0 -26
  388. package/dist/files/AssetFile.js +0 -26
  389. package/dist/files/AssetFile.js.map +0 -1
  390. package/dist/files/Factory.d.ts +0 -25
  391. package/dist/files/Factory.js +0 -22
  392. package/dist/files/Factory.js.map +0 -1
  393. package/dist/files/File.d.ts +0 -106
  394. package/dist/files/File.js +0 -16
  395. package/dist/files/File.js.map +0 -1
  396. package/dist/files/LazyFileData.d.ts +0 -20
  397. package/dist/files/LazyFileData.js +0 -54
  398. package/dist/files/LazyFileData.js.map +0 -1
  399. package/dist/files/LazyFileData.spec.js +0 -27
  400. package/dist/files/LazyFileData.spec.js.map +0 -1
  401. package/dist/parser/tests/expression/TypeExpression.spec.js +0 -127
  402. package/dist/parser/tests/expression/TypeExpression.spec.js.map +0 -1
  403. package/dist/types/AssociativeArrayType.d.ts +0 -11
  404. package/dist/types/AssociativeArrayType.js +0 -52
  405. package/dist/types/AssociativeArrayType.js.map +0 -1
  406. package/dist/types/BaseFunctionType.d.ts +0 -9
  407. package/dist/types/BaseFunctionType.js +0 -25
  408. package/dist/types/BaseFunctionType.js.map +0 -1
  409. package/dist/types/BscTypeKind.d.ts +0 -25
  410. package/dist/types/BscTypeKind.js +0 -30
  411. package/dist/types/BscTypeKind.js.map +0 -1
  412. package/dist/types/BuiltInInterfaceAdder.d.ts +0 -23
  413. package/dist/types/BuiltInInterfaceAdder.js +0 -160
  414. package/dist/types/BuiltInInterfaceAdder.js.map +0 -1
  415. package/dist/types/BuiltInInterfaceAdder.spec.d.ts +0 -1
  416. package/dist/types/BuiltInInterfaceAdder.spec.js +0 -116
  417. package/dist/types/BuiltInInterfaceAdder.spec.js.map +0 -1
  418. package/dist/types/ClassType.d.ts +0 -17
  419. package/dist/types/ClassType.js +0 -58
  420. package/dist/types/ClassType.js.map +0 -1
  421. package/dist/types/ClassType.spec.d.ts +0 -1
  422. package/dist/types/ClassType.spec.js +0 -77
  423. package/dist/types/ClassType.spec.js.map +0 -1
  424. package/dist/types/ComponentType.d.ts +0 -26
  425. package/dist/types/ComponentType.js +0 -83
  426. package/dist/types/ComponentType.js.map +0 -1
  427. package/dist/types/EnumType.d.ts +0 -40
  428. package/dist/types/EnumType.js +0 -81
  429. package/dist/types/EnumType.js.map +0 -1
  430. package/dist/types/EnumType.spec.d.ts +0 -1
  431. package/dist/types/EnumType.spec.js +0 -33
  432. package/dist/types/EnumType.spec.js.map +0 -1
  433. package/dist/types/InheritableType.d.ts +0 -28
  434. package/dist/types/InheritableType.js +0 -152
  435. package/dist/types/InheritableType.js.map +0 -1
  436. package/dist/types/NamespaceType.d.ts +0 -12
  437. package/dist/types/NamespaceType.js +0 -28
  438. package/dist/types/NamespaceType.js.map +0 -1
  439. package/dist/types/ReferenceType.d.ts +0 -63
  440. package/dist/types/ReferenceType.js +0 -423
  441. package/dist/types/ReferenceType.js.map +0 -1
  442. package/dist/types/ReferenceType.spec.d.ts +0 -1
  443. package/dist/types/ReferenceType.spec.js +0 -137
  444. package/dist/types/ReferenceType.spec.js.map +0 -1
  445. package/dist/types/TypedFunctionType.d.ts +0 -33
  446. package/dist/types/TypedFunctionType.js +0 -106
  447. package/dist/types/TypedFunctionType.js.map +0 -1
  448. package/dist/types/TypedFunctionType.spec.d.ts +0 -1
  449. package/dist/types/TypedFunctionType.spec.js +0 -122
  450. package/dist/types/TypedFunctionType.spec.js.map +0 -1
  451. package/dist/types/UnionType.d.ts +0 -20
  452. package/dist/types/UnionType.js +0 -123
  453. package/dist/types/UnionType.js.map +0 -1
  454. package/dist/types/UnionType.spec.d.ts +0 -1
  455. package/dist/types/UnionType.spec.js +0 -130
  456. package/dist/types/UnionType.spec.js.map +0 -1
  457. package/dist/types/helper.spec.d.ts +0 -1
  458. package/dist/types/helper.spec.js +0 -145
  459. package/dist/types/helper.spec.js.map +0 -1
  460. package/dist/types/helpers.d.ts +0 -24
  461. package/dist/types/helpers.js +0 -178
  462. package/dist/types/helpers.js.map +0 -1
  463. package/dist/types/index.d.ts +0 -22
  464. package/dist/types/index.js +0 -39
  465. package/dist/types/index.js.map +0 -1
  466. /package/dist/astUtils/{Editor.spec.d.ts → AstEditor.spec.d.ts} +0 -0
  467. /package/dist/bscPlugin/{completions/CompletionsProcessor.spec.d.ts → definition/DefinitionProvider.spec.d.ts} +0 -0
  468. /package/dist/bscPlugin/{serialize/BslibInjector.spec.d.ts → references/ReferencesProvider.spec.d.ts} +0 -0
  469. /package/dist/bscPlugin/{transpile/BrsFileTranspileProcessor.spec.d.ts → symbols/DocumentSymbolProcessor.spec.d.ts} +0 -0
  470. /package/dist/bscPlugin/{validation/ScopeValidator.spec.d.ts → symbols/WorkspaceSymbolProcessor.spec.d.ts} +0 -0
  471. /package/dist/{files/LazyFileData.spec.d.ts → bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.d.ts} +0 -0
  472. /package/dist/{parser/tests/expression/TypeExpression.spec.d.ts → types/FunctionType.spec.d.ts} +0 -0
package/dist/Scope.js CHANGED
@@ -2,28 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Scope = void 0;
4
4
  const path = require("path");
5
+ const vscode_languageserver_1 = require("vscode-languageserver");
5
6
  const chalk_1 = require("chalk");
6
7
  const DiagnosticMessages_1 = require("./DiagnosticMessages");
7
- const interfaces_1 = require("./interfaces");
8
8
  const ClassValidator_1 = require("./validators/ClassValidator");
9
9
  const Parser_1 = require("./parser/Parser");
10
10
  const util_1 = require("./util");
11
11
  const globalCallables_1 = require("./globalCallables");
12
12
  const Cache_1 = require("./Cache");
13
13
  const vscode_uri_1 = require("vscode-uri");
14
- const Logger_1 = require("./Logger");
15
14
  const reflection_1 = require("./astUtils/reflection");
16
15
  const SymbolTable_1 = require("./SymbolTable");
17
- const NamespaceType_1 = require("./types/NamespaceType");
18
- const ReferenceType_1 = require("./types/ReferenceType");
19
- const UnionType_1 = require("./types/UnionType");
20
- const AssociativeArrayType_1 = require("./types/AssociativeArrayType");
21
- /**
22
- * Assign some few factories to the SymbolTable to prevent cyclical imports. This file seems like the most intuitive place to do the linking
23
- * since Scope will be used by pretty much everything
24
- */
25
- SymbolTable_1.SymbolTable.referenceTypeFactory = ReferenceType_1.referenceTypeFactory;
26
- SymbolTable_1.SymbolTable.unionTypeFactory = UnionType_1.unionTypeFactory;
16
+ const logging_1 = require("./logging");
27
17
  /**
28
18
  * A class to keep track of all declarations within a given scope (like source scope, component scope)
29
19
  */
@@ -37,11 +27,6 @@ class Scope {
37
27
  * The list of diagnostics found specifically for this scope. Individual file diagnostics are stored on the files themselves.
38
28
  */
39
29
  this.diagnostics = [];
40
- /**
41
- * A list of functions that will be called whenever `unlinkSymbolTable` is called
42
- */
43
- this.linkSymbolTableDisposables = [];
44
- this.symbolsAddedDuringLinking = [];
45
30
  this.isValidated = false;
46
31
  //used for improved logging performance
47
32
  this._debugLogComponentName = `Scope '${chalk_1.default.redBright(this.name)}'`;
@@ -55,20 +40,6 @@ class Scope {
55
40
  * "namea", "namea.nameb", "namea.nameb.namec"
56
41
  */
57
42
  get namespaceLookup() {
58
- let allFilesValidated = true;
59
- for (const file of this.getAllFiles()) {
60
- if ((0, reflection_1.isBrsFile)(file) && !file.hasTypedef) {
61
- allFilesValidated = allFilesValidated && file.isValidated;
62
- if (!allFilesValidated) {
63
- break;
64
- }
65
- }
66
- }
67
- if (!allFilesValidated) {
68
- // This is not fit to cache
69
- // Since the files have not been validated, all namespace info might not have been available
70
- return this.buildNamespaceLookup();
71
- }
72
43
  return this.cache.getOrAdd('namespaceLookup', () => this.buildNamespaceLookup());
73
44
  }
74
45
  /**
@@ -168,7 +139,7 @@ class Scope {
168
139
  var _a, _b;
169
140
  let lowerNameParts = (_a = enumMemberName === null || enumMemberName === void 0 ? void 0 : enumMemberName.toLowerCase()) === null || _a === void 0 ? void 0 : _a.split('.');
170
141
  let memberName = (_b = lowerNameParts === null || lowerNameParts === void 0 ? void 0 : lowerNameParts.splice(lowerNameParts.length - 1, 1)) === null || _b === void 0 ? void 0 : _b[0];
171
- let lowerName = lowerNameParts === null || lowerNameParts === void 0 ? void 0 : lowerNameParts.join('.');
142
+ let lowerName = lowerNameParts === null || lowerNameParts === void 0 ? void 0 : lowerNameParts.join('.').toLowerCase();
172
143
  const enumMap = this.getEnumMap();
173
144
  let enumeration = enumMap.get(util_1.util.getFullyQualifiedClassName(lowerName, containingNamespace === null || containingNamespace === void 0 ? void 0 : containingNamespace.toLowerCase()));
174
145
  //if we couldn't find the enum by its full namespaced name, look for a global enum with that name
@@ -179,7 +150,6 @@ class Scope {
179
150
  let member = enumeration.item.findChild((child) => { var _a; return (0, reflection_1.isEnumMemberStatement)(child) && ((_a = child.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === memberName; });
180
151
  return member ? { item: member, file: enumeration.file } : undefined;
181
152
  }
182
- return enumeration;
183
153
  }
184
154
  /**
185
155
  * Get a constant and its containing file by the constant name
@@ -244,12 +214,13 @@ class Scope {
244
214
  return this.cache.getOrAdd('classMap', () => {
245
215
  const map = new Map();
246
216
  this.enumerateBrsFiles((file) => {
217
+ var _a;
247
218
  if ((0, reflection_1.isBrsFile)(file)) {
248
219
  for (let cls of file.parser.references.classStatements) {
249
- const className = cls.getName(Parser_1.ParseMode.BrighterScript);
220
+ const lowerClassName = (_a = cls.getName(Parser_1.ParseMode.BrighterScript)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
250
221
  //only track classes with a defined name (i.e. exclude nameless malformed classes)
251
- if (className) {
252
- map.set(className.toLowerCase(), { item: cls, file: file });
222
+ if (lowerClassName) {
223
+ map.set(lowerClassName, { item: cls, file: file });
253
224
  }
254
225
  }
255
226
  }
@@ -265,12 +236,13 @@ class Scope {
265
236
  return this.cache.getOrAdd('interfaceMap', () => {
266
237
  const map = new Map();
267
238
  this.enumerateBrsFiles((file) => {
239
+ var _a;
268
240
  if ((0, reflection_1.isBrsFile)(file)) {
269
241
  for (let iface of file.parser.references.interfaceStatements) {
270
- const ifaceName = iface.getName(Parser_1.ParseMode.BrighterScript);
242
+ const lowerIfaceName = (_a = iface.getName(Parser_1.ParseMode.BrighterScript)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
271
243
  //only track classes with a defined name (i.e. exclude nameless malformed classes)
272
- if (ifaceName) {
273
- map.set(ifaceName.toLowerCase(), { item: iface, file: file });
244
+ if (lowerIfaceName) {
245
+ map.set(lowerIfaceName, { item: iface, file: file });
274
246
  }
275
247
  }
276
248
  }
@@ -287,9 +259,10 @@ class Scope {
287
259
  const map = new Map();
288
260
  this.enumerateBrsFiles((file) => {
289
261
  for (let enumStmt of file.parser.references.enumStatements) {
262
+ const lowerEnumName = enumStmt.fullName.toLowerCase();
290
263
  //only track enums with a defined name (i.e. exclude nameless malformed enums)
291
- if (enumStmt.fullName) {
292
- map.set(enumStmt.fullName.toLowerCase(), { item: enumStmt, file: file });
264
+ if (lowerEnumName) {
265
+ map.set(lowerEnumName, { item: enumStmt, file: file });
293
266
  }
294
267
  }
295
268
  });
@@ -305,9 +278,10 @@ class Scope {
305
278
  const map = new Map();
306
279
  this.enumerateBrsFiles((file) => {
307
280
  for (let stmt of file.parser.references.constStatements) {
281
+ const lowerEnumName = stmt.fullName.toLowerCase();
308
282
  //only track enums with a defined name (i.e. exclude nameless malformed enums)
309
- if (stmt.fullName) {
310
- map.set(stmt.fullName.toLowerCase(), { item: stmt, file: file });
283
+ if (lowerEnumName) {
284
+ map.set(lowerEnumName, { item: stmt, file: file });
311
285
  }
312
286
  }
313
287
  });
@@ -372,14 +346,14 @@ class Scope {
372
346
  }
373
347
  /**
374
348
  * Get the file from this scope with the given path.
375
- * @param filePath can be a srcPath or destPath
349
+ * @param filePath can be a srcPath or pkgPath
376
350
  * @param normalizePath should this function repair and standardize the path? Passing false should have a performance boost if you can guarantee your path is already sanitized
377
351
  */
378
352
  getFile(filePath, normalizePath = true) {
379
353
  if (typeof filePath !== 'string') {
380
354
  return undefined;
381
355
  }
382
- const key = path.isAbsolute(filePath) ? 'srcPath' : 'destPath';
356
+ const key = path.isAbsolute(filePath) ? 'srcPath' : 'pkgPath';
383
357
  let map = this.cache.getOrAdd('fileMaps-srcPath', () => {
384
358
  const result = new Map();
385
359
  for (const file of this.getAllFiles()) {
@@ -420,26 +394,26 @@ class Scope {
420
394
  }
421
395
  }
422
396
  }
423
- this.logDebug('getAllFiles', () => result.map(x => x.destPath));
397
+ this.logDebug('getAllFiles', () => result.map(x => x.pkgPath));
424
398
  return result;
425
399
  });
426
400
  }
427
401
  /**
428
- * Get the list of errors for this scope. It's calculated on the fly, so call this sparingly.
402
+ * Get the list of errors for this scope. It's calculated on the fly, so
403
+ * call this sparingly.
429
404
  */
430
405
  getDiagnostics() {
406
+ let diagnosticLists = [this.diagnostics];
431
407
  //add diagnostics from every referenced file
432
- const diagnostics = [
433
- //diagnostics raised on this scope
434
- ...this.diagnostics,
435
- //get diagnostics from all files
436
- ...this.getOwnFiles().map(x => { var _a; return (_a = x.diagnostics) !== null && _a !== void 0 ? _a : []; }).flat()
437
- ]
438
- //exclude diagnostics that match any of the comment flags
439
- .filter((x) => {
408
+ this.enumerateOwnFiles((file) => {
409
+ diagnosticLists.push(file.getDiagnostics());
410
+ });
411
+ let allDiagnostics = Array.prototype.concat.apply([], diagnosticLists);
412
+ let filteredDiagnostics = allDiagnostics.filter((x) => {
440
413
  return !util_1.util.diagnosticIsSuppressed(x);
441
414
  });
442
- return diagnostics;
415
+ //filter out diangostics that match any of the comment flags
416
+ return filteredDiagnostics;
443
417
  }
444
418
  addDiagnostics(diagnostics) {
445
419
  this.diagnostics.push(...diagnostics);
@@ -497,7 +471,7 @@ class Scope {
497
471
  const files = this.getOwnFiles();
498
472
  for (const file of files) {
499
473
  //either XML components or files without a typedef
500
- if ((0, reflection_1.isXmlFile)(file) || ((0, reflection_1.isBrsFile)(file) && !file.hasTypedef)) {
474
+ if ((0, reflection_1.isXmlFile)(file) || !file.hasTypedef) {
501
475
  callback(file);
502
476
  }
503
477
  }
@@ -508,16 +482,14 @@ class Scope {
508
482
  */
509
483
  getOwnCallables() {
510
484
  let result = [];
511
- this.logDebug('getOwnCallables() files: ', () => this.getOwnFiles().map(x => x.destPath));
485
+ this.logDebug('getOwnCallables() files: ', () => this.getOwnFiles().map(x => x.pkgPath));
512
486
  //get callables from own files
513
487
  this.enumerateOwnFiles((file) => {
514
- if ((0, reflection_1.isBrsFile)(file)) {
515
- for (let callable of file.callables) {
516
- result.push({
517
- callable: callable,
518
- scope: this
519
- });
520
- }
488
+ for (let callable of file.callables) {
489
+ result.push({
490
+ callable: callable,
491
+ scope: this
492
+ });
521
493
  }
522
494
  });
523
495
  return result;
@@ -525,27 +497,64 @@ class Scope {
525
497
  /**
526
498
  * Builds a tree of namespace objects
527
499
  */
528
- buildNamespaceLookup(options = { okToCache: true }) {
500
+ buildNamespaceLookup() {
529
501
  let namespaceLookup = new Map();
530
- options.okToCache = true;
531
502
  this.enumerateBrsFiles((file) => {
532
- options.okToCache = options.okToCache && file.isValidated;
533
- const fileNamespaceLookup = file.getNamespaceLookupObject();
534
- for (const [lowerNamespaceName, nsContainer] of fileNamespaceLookup) {
535
- if (!namespaceLookup.has(lowerNamespaceName)) {
536
- const clonedNsContainer = Object.assign(Object.assign({}, nsContainer), { namespaceStatements: [...nsContainer.namespaceStatements], symbolTable: new SymbolTable_1.SymbolTable(`Namespace Aggregate: '${nsContainer.fullName}'`) });
537
- clonedNsContainer.symbolTable.mergeSymbolTable(nsContainer.symbolTable);
538
- namespaceLookup.set(lowerNamespaceName, clonedNsContainer);
503
+ for (let namespaceStatement of file.parser.references.namespaceStatements) {
504
+ //TODO should we handle non-brighterscript?
505
+ let name = namespaceStatement.getName(Parser_1.ParseMode.BrighterScript);
506
+ let nameParts = name.split('.');
507
+ let loopName = null;
508
+ //ensure each namespace section is represented in the results
509
+ //(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"
510
+ for (let part of nameParts) {
511
+ loopName = loopName === null ? part : `${loopName}.${part}`;
512
+ let lowerLoopName = loopName.toLowerCase();
513
+ if (!namespaceLookup.has(lowerLoopName)) {
514
+ namespaceLookup.set(lowerLoopName, {
515
+ file: file,
516
+ fullName: loopName,
517
+ nameRange: namespaceStatement.nameExpression.range,
518
+ lastPartName: part,
519
+ namespaces: new Map(),
520
+ classStatements: {},
521
+ functionStatements: {},
522
+ enumStatements: new Map(),
523
+ constStatements: new Map(),
524
+ statements: [],
525
+ symbolTable: new SymbolTable_1.SymbolTable(`Namespace Aggregate: '${loopName}'`, () => this.symbolTable)
526
+ });
527
+ }
539
528
  }
540
- else {
541
- const existingContainer = namespaceLookup.get(lowerNamespaceName);
542
- existingContainer.classStatements = new Map([...existingContainer.classStatements, ...nsContainer.classStatements]);
543
- existingContainer.constStatements = new Map([...existingContainer.constStatements, ...nsContainer.constStatements]);
544
- existingContainer.enumStatements = new Map([...existingContainer.enumStatements, ...nsContainer.enumStatements]);
545
- existingContainer.functionStatements = new Map([...existingContainer.functionStatements, ...nsContainer.functionStatements]);
546
- existingContainer.namespaces = new Map([...existingContainer.namespaces, ...nsContainer.namespaces]);
547
- existingContainer.namespaceStatements.push(...nsContainer.namespaceStatements);
548
- existingContainer.symbolTable.mergeSymbolTable(nsContainer.symbolTable);
529
+ let ns = namespaceLookup.get(name.toLowerCase());
530
+ ns.statements.push(...namespaceStatement.body.statements);
531
+ for (let statement of namespaceStatement.body.statements) {
532
+ if ((0, reflection_1.isClassStatement)(statement) && statement.name) {
533
+ ns.classStatements[statement.name.text.toLowerCase()] = statement;
534
+ }
535
+ else if ((0, reflection_1.isFunctionStatement)(statement) && statement.name) {
536
+ ns.functionStatements[statement.name.text.toLowerCase()] = statement;
537
+ }
538
+ else if ((0, reflection_1.isEnumStatement)(statement) && statement.fullName) {
539
+ ns.enumStatements.set(statement.fullName.toLowerCase(), statement);
540
+ }
541
+ else if ((0, reflection_1.isConstStatement)(statement) && statement.fullName) {
542
+ ns.constStatements.set(statement.fullName.toLowerCase(), statement);
543
+ }
544
+ }
545
+ // Merges all the symbol tables of the namespace statements into the new symbol table created above.
546
+ // Set those symbol tables to have this new merged table as a parent
547
+ ns.symbolTable.mergeSymbolTable(namespaceStatement.body.getSymbolTable());
548
+ }
549
+ //associate child namespaces with their parents
550
+ for (let [, ns] of namespaceLookup) {
551
+ let parts = ns.fullName.split('.');
552
+ if (parts.length > 1) {
553
+ //remove the last part
554
+ parts.pop();
555
+ let parentName = parts.join('.');
556
+ const parent = namespaceLookup.get(parentName.toLowerCase());
557
+ parent.namespaces.set(ns.lastPartName.toLowerCase(), ns);
549
558
  }
550
559
  }
551
560
  });
@@ -561,21 +570,21 @@ class Scope {
561
570
  logDebug(...args) {
562
571
  this.program.logger.debug(this._debugLogComponentName, ...args);
563
572
  }
564
- validate(validationOptions = { force: false }) {
573
+ validate(force = false) {
565
574
  //if this scope is already validated, no need to revalidate
566
- if (this.isValidated === true && !validationOptions.force) {
575
+ if (this.isValidated === true && !force) {
567
576
  this.logDebug('validate(): already validated');
568
577
  return;
569
578
  }
570
- this.program.logger.time(Logger_1.LogLevel.debug, [this._debugLogComponentName, 'validate()'], () => {
579
+ this.program.logger.time(logging_1.LogLevel.debug, [this._debugLogComponentName, 'validate()'], () => {
571
580
  let parentScope = this.getParentScope();
572
581
  //validate our parent before we validate ourself
573
582
  if (parentScope && parentScope.isValidated === false) {
574
583
  this.logDebug('validate(): validating parent first');
575
- parentScope.validate(validationOptions);
584
+ parentScope.validate(force);
576
585
  }
577
586
  //clear the scope's errors list (we will populate them from this method)
578
- this.clearScopeLevelDiagnostics();
587
+ this.diagnostics = [];
579
588
  let callables = this.getAllCallables();
580
589
  //sort the callables by filepath and then method name, so the errors will be consistent
581
590
  // eslint-disable-next-line prefer-arrow-callback
@@ -602,18 +611,16 @@ class Scope {
602
611
  });
603
612
  //get a list of all callables, indexed by their lower case names
604
613
  let callableContainerMap = util_1.util.getCallableContainersByLowerName(callables);
614
+ let files = this.getOwnFiles();
605
615
  //Since statements from files are shared across multiple scopes, we need to link those statements to the current scope
606
616
  this.linkSymbolTable();
607
- const scopeValidateEvent = {
617
+ this.program.plugins.emit('beforeScopeValidate', this, files, callableContainerMap);
618
+ this.program.plugins.emit('onScopeValidate', {
608
619
  program: this.program,
609
- scope: this,
610
- changedFiles: validationOptions === null || validationOptions === void 0 ? void 0 : validationOptions.changedFiles,
611
- changedSymbols: validationOptions === null || validationOptions === void 0 ? void 0 : validationOptions.changedSymbols
612
- };
613
- this.program.plugins.emit('beforeScopeValidate', scopeValidateEvent);
614
- this.program.plugins.emit('onScopeValidate', scopeValidateEvent);
620
+ scope: this
621
+ });
615
622
  this._validate(callableContainerMap);
616
- this.program.plugins.emit('afterScopeValidate', scopeValidateEvent);
623
+ this.program.plugins.emit('afterScopeValidate', this, files, callableContainerMap);
617
624
  //unlink all symbol tables from this scope (so they don't accidentally stick around)
618
625
  this.unlinkSymbolTable();
619
626
  this.isValidated = true;
@@ -628,21 +635,13 @@ class Scope {
628
635
  this.validateClasses();
629
636
  //do many per-file checks
630
637
  this.enumerateBrsFiles((file) => {
638
+ this.diagnosticDetectFunctionCallsWithWrongParamCount(file, callableContainerMap);
631
639
  this.diagnosticDetectShadowedLocalVars(file, callableContainerMap);
632
640
  this.diagnosticDetectFunctionCollisions(file);
633
641
  this.detectVariableNamespaceCollisions(file);
642
+ this.diagnosticDetectInvalidFunctionExpressionTypes(file);
634
643
  });
635
644
  }
636
- clearAstSegmentDiagnostics(astSegment) {
637
- this.diagnostics = this.diagnostics.filter(diag => !(diag.origin === interfaces_1.DiagnosticOrigin.ASTSegment && diag.astSegment === astSegment));
638
- }
639
- clearAstSegmentDiagnosticsByFile(file) {
640
- const lowerSrcPath = file.srcPath.toLowerCase();
641
- this.diagnostics = this.diagnostics.filter(diag => !(diag.origin === interfaces_1.DiagnosticOrigin.ASTSegment && diag.file.srcPath.toLowerCase() === lowerSrcPath));
642
- }
643
- clearScopeLevelDiagnostics() {
644
- this.diagnostics = this.diagnostics.filter(diag => diag.origin !== interfaces_1.DiagnosticOrigin.Scope);
645
- }
646
645
  /**
647
646
  * Mark this scope as invalid, which means its `validate()` function needs to be called again before use.
648
647
  */
@@ -655,7 +654,6 @@ class Scope {
655
654
  return this.cache.getOrAdd('symbolTable', () => {
656
655
  var _a;
657
656
  const result = new SymbolTable_1.SymbolTable(`Scope: '${this.name}'`, () => { var _a; return (_a = this.getParentScope()) === null || _a === void 0 ? void 0 : _a.symbolTable; });
658
- result.addSymbol('m', undefined, new AssociativeArrayType_1.AssociativeArrayType(), SymbolTable_1.SymbolTypeFlag.runtime);
659
657
  for (let file of this.getOwnFiles()) {
660
658
  if ((0, reflection_1.isBrsFile)(file)) {
661
659
  result.mergeSymbolTable((_a = file.parser) === null || _a === void 0 ? void 0 : _a.symbolTable);
@@ -668,88 +666,30 @@ class Scope {
668
666
  * Builds the current symbol table for the scope, by merging the tables for all the files in this scope.
669
667
  * Also links all file symbols tables to this new table
670
668
  * This will only rebuilt if the symbol table has not been built before
671
- *
672
- * Tree of symbol tables:
673
- * ```
674
- * Global Scope Symbol Table
675
- * - Source Scope Symbol Table :: Aggregate Namespaces Symbol Table (Siblings)
676
- * - File 1 Symbol Table
677
- * - File 2 Symbol Table
678
- * - Component A Scope Symbol Table :: Aggregate Namespaces Symbol Table (Siblings)
679
- * - File 1 Symbol Table
680
- * - File 2 Symbol Table
681
- * - Component B Scope Symbol Table :: Aggregate Namespaces Symbol Table (Siblings)
682
- * - File 1 Symbol Table
683
- * - File 2 Symbol Table
684
- * ```
685
669
  */
686
670
  linkSymbolTable() {
687
- var _a;
688
- SymbolTable_1.SymbolTable.cacheVerifier.generateToken();
689
671
  for (const file of this.getAllFiles()) {
690
672
  if ((0, reflection_1.isBrsFile)(file)) {
691
- this.linkSymbolTableDisposables.push(file.parser.symbolTable.pushParentProvider(() => this.symbolTable));
692
- }
693
- }
694
- //Add namespace aggregates to namespace member tables
695
- const namespaceTypesKnown = new Map();
696
- // eslint-disable-next-line no-bitwise
697
- let getTypeOptions = { flags: SymbolTable_1.SymbolTypeFlag.runtime | SymbolTable_1.SymbolTypeFlag.typetime };
698
- for (const [nsName, nsContainer] of this.namespaceLookup) {
699
- let currentNSType = null;
700
- let parentNSType = null;
701
- const existingNsStmt = (_a = nsContainer.namespaceStatements) === null || _a === void 0 ? void 0 : _a[0];
702
- if (!nsContainer.isTopLevel) {
703
- parentNSType = namespaceTypesKnown.get(nsContainer.parentNameLower);
704
- if (!parentNSType) {
705
- // we don't know about the parent namespace... uh, oh!
706
- break;
707
- }
708
- currentNSType = parentNSType.getMemberType(nsContainer.fullNameLower, getTypeOptions);
709
- }
710
- else {
711
- currentNSType = this.symbolTable.getSymbolType(nsContainer.fullNameLower, getTypeOptions);
712
- }
713
- if (!(0, reflection_1.isNamespaceType)(currentNSType)) {
714
- if (!currentNSType || (0, reflection_1.isReferenceType)(currentNSType)) {
715
- currentNSType = existingNsStmt
716
- ? existingNsStmt.getType(getTypeOptions)
717
- : new NamespaceType_1.NamespaceType(nsName);
718
- if (parentNSType) {
719
- // adding as a member of existing NS
720
- parentNSType.addMember(nsContainer.lastPartName, { definingNode: existingNsStmt }, currentNSType, getTypeOptions.flags);
721
- this.symbolsAddedDuringLinking.push({ symbolTable: parentNSType.getMemberTable(), name: nsContainer.lastPartName, flags: getTypeOptions.flags });
722
- }
723
- else {
724
- this.symbolTable.addSymbol(nsContainer.lastPartName, { definingNode: existingNsStmt }, currentNSType, getTypeOptions.flags);
725
- this.symbolsAddedDuringLinking.push({ symbolTable: this.symbolTable, name: nsContainer.lastPartName, flags: getTypeOptions.flags });
726
- }
673
+ file.parser.symbolTable.pushParentProvider(() => this.symbolTable);
674
+ //link each NamespaceStatement's SymbolTable with the aggregate NamespaceLookup SymbolTable
675
+ for (const namespace of file.parser.references.namespaceStatements) {
676
+ const namespaceNameLower = namespace.getName(Parser_1.ParseMode.BrighterScript).toLowerCase();
677
+ namespace.getSymbolTable().addSibling(this.namespaceLookup.get(namespaceNameLower).symbolTable);
727
678
  }
728
- else {
729
- break;
730
- }
731
- }
732
- else {
733
- // Existing known namespace
734
- }
735
- if (!namespaceTypesKnown.has(nsName)) {
736
- namespaceTypesKnown.set(nsName, currentNSType);
737
679
  }
738
- for (let nsStmt of nsContainer.namespaceStatements) {
739
- this.linkSymbolTableDisposables.push(nsStmt === null || nsStmt === void 0 ? void 0 : nsStmt.getSymbolTable().addSibling(nsContainer.symbolTable));
740
- }
741
- this.linkSymbolTableDisposables.push(currentNSType.memberTable.addSibling(nsContainer.symbolTable));
742
680
  }
743
681
  }
744
682
  unlinkSymbolTable() {
745
- for (const symbolToRemove of this.symbolsAddedDuringLinking) {
746
- this.symbolTable.removeSymbol(symbolToRemove.name);
747
- }
748
- this.symbolsAddedDuringLinking = [];
749
- for (const dispose of this.linkSymbolTableDisposables) {
750
- dispose();
683
+ var _a;
684
+ for (let file of this.getOwnFiles()) {
685
+ if ((0, reflection_1.isBrsFile)(file)) {
686
+ (_a = file.parser) === null || _a === void 0 ? void 0 : _a.symbolTable.popParentProvider();
687
+ for (const namespace of file.parser.references.namespaceStatements) {
688
+ const namespaceNameLower = namespace.getName(Parser_1.ParseMode.BrighterScript).toLowerCase();
689
+ namespace.getSymbolTable().removeSibling(this.namespaceLookup.get(namespaceNameLower).symbolTable);
690
+ }
691
+ }
751
692
  }
752
- this.linkSymbolTableDisposables = [];
753
693
  }
754
694
  detectVariableNamespaceCollisions(file) {
755
695
  var _a, _b;
@@ -760,7 +700,7 @@ class Scope {
760
700
  let namespace = this.getNamespace(lowerParamName, (_a = param.findAncestor(reflection_1.isNamespaceStatement)) === null || _a === void 0 ? void 0 : _a.getName(Parser_1.ParseMode.BrighterScript).toLowerCase());
761
701
  //see if the param matches any starting namespace part
762
702
  if (namespace) {
763
- this.diagnostics.push(Object.assign(Object.assign({ origin: interfaces_1.DiagnosticOrigin.Scope, file: file }, DiagnosticMessages_1.DiagnosticMessages.parameterMayNotHaveSameNameAsNamespace(param.name.text)), { range: param.name.range, relatedInformation: [{
703
+ this.diagnostics.push(Object.assign(Object.assign({ file: file }, DiagnosticMessages_1.DiagnosticMessages.parameterMayNotHaveSameNameAsNamespace(param.name.text)), { range: param.name.range, relatedInformation: [{
764
704
  message: 'Namespace declared here',
765
705
  location: util_1.util.createLocation(vscode_uri_1.URI.file(namespace.file.srcPath).toString(), namespace.nameRange)
766
706
  }] }));
@@ -772,7 +712,7 @@ class Scope {
772
712
  let namespace = this.getNamespace(lowerAssignmentName, (_b = assignment.findAncestor(reflection_1.isNamespaceStatement)) === null || _b === void 0 ? void 0 : _b.getName(Parser_1.ParseMode.BrighterScript).toLowerCase());
773
713
  //see if the param matches any starting namespace part
774
714
  if (namespace) {
775
- this.diagnostics.push(Object.assign(Object.assign({ origin: interfaces_1.DiagnosticOrigin.Scope, file: file }, DiagnosticMessages_1.DiagnosticMessages.variableMayNotHaveSameNameAsNamespace(assignment.name.text)), { range: assignment.name.range, relatedInformation: [{
715
+ this.diagnostics.push(Object.assign(Object.assign({ file: file }, DiagnosticMessages_1.DiagnosticMessages.variableMayNotHaveSameNameAsNamespace(assignment.name.text)), { range: assignment.name.range, relatedInformation: [{
776
716
  message: 'Namespace declared here',
777
717
  location: util_1.util.createLocation(vscode_uri_1.URI.file(namespace.file.srcPath).toString(), namespace.nameRange)
778
718
  }] }));
@@ -789,11 +729,40 @@ class Scope {
789
729
  if (lowerFuncName) {
790
730
  //find function declarations with the same name as a stdlib function
791
731
  if (globalCallables_1.globalCallableMap.has(lowerFuncName)) {
792
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.scopeFunctionShadowedByBuiltInFunction()), { range: func.nameRange, file: file, origin: interfaces_1.DiagnosticOrigin.Scope }));
732
+ this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.scopeFunctionShadowedByBuiltInFunction()), { range: func.nameRange, file: file }));
793
733
  }
794
734
  //find any functions that have the same name as a class
795
735
  if (this.hasClass(lowerFuncName)) {
796
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.functionCannotHaveSameNameAsClass(funcName)), { range: func.nameRange, file: file, origin: interfaces_1.DiagnosticOrigin.Scope }));
736
+ this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.functionCannotHaveSameNameAsClass(funcName)), { range: func.nameRange, file: file }));
737
+ }
738
+ }
739
+ }
740
+ }
741
+ /**
742
+ * Find function parameters and function return types that are neither built-in types or known Class references
743
+ */
744
+ diagnosticDetectInvalidFunctionExpressionTypes(file) {
745
+ var _a, _b;
746
+ for (let func of file.parser.references.functionExpressions) {
747
+ if ((0, reflection_1.isCustomType)(func.returnType) && func.returnTypeToken) {
748
+ // check if this custom type is in our class map
749
+ const returnTypeName = func.returnType.name;
750
+ const currentNamespaceName = (_a = func.findAncestor(reflection_1.isNamespaceStatement)) === null || _a === void 0 ? void 0 : _a.getName(Parser_1.ParseMode.BrighterScript);
751
+ // check for built in types
752
+ const isBuiltInType = util_1.util.isBuiltInType(returnTypeName);
753
+ if (!isBuiltInType && !this.hasClass(returnTypeName, currentNamespaceName) && !this.hasInterface(returnTypeName) && !this.hasEnum(returnTypeName)) {
754
+ this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.invalidFunctionReturnType(returnTypeName)), { range: func.returnTypeToken.range, file: file }));
755
+ }
756
+ }
757
+ for (let param of func.parameters) {
758
+ if ((0, reflection_1.isCustomType)(param.type) && param.typeToken) {
759
+ const paramTypeName = param.type.name;
760
+ const currentNamespaceName = (_b = func.findAncestor(reflection_1.isNamespaceStatement)) === null || _b === void 0 ? void 0 : _b.getName(Parser_1.ParseMode.BrighterScript);
761
+ // check for built in types
762
+ const isBuiltInType = util_1.util.isBuiltInType(paramTypeName);
763
+ if (!isBuiltInType && !this.hasClass(paramTypeName, currentNamespaceName) && !this.hasInterface(paramTypeName) && !this.hasEnum(paramTypeName)) {
764
+ this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.functionParameterTypeIsInvalid(param.name.text, paramTypeName)), { range: param.typeToken.range, file: file }));
765
+ }
797
766
  }
798
767
  }
799
768
  }
@@ -810,11 +779,40 @@ class Scope {
810
779
  return result;
811
780
  }
812
781
  validateClasses() {
813
- let validator = new ClassValidator_1.BsClassValidator();
814
- validator.validate(this);
815
- this.diagnostics.push(...validator.diagnostics.map(diag => {
816
- return Object.assign(Object.assign({}, diag), { origin: interfaces_1.DiagnosticOrigin.Scope });
817
- }));
782
+ let validator = new ClassValidator_1.BsClassValidator(this);
783
+ validator.validate();
784
+ this.diagnostics.push(...validator.diagnostics);
785
+ }
786
+ /**
787
+ * Detect calls to functions with the incorrect number of parameters
788
+ */
789
+ diagnosticDetectFunctionCallsWithWrongParamCount(file, callableContainersByLowerName) {
790
+ //validate all function calls
791
+ for (let expCall of file.functionCalls) {
792
+ let callableContainersWithThisName = callableContainersByLowerName.get(expCall.name.toLowerCase());
793
+ //use the first item from callablesByLowerName, because if there are more, that's a separate error
794
+ let knownCallableContainer = callableContainersWithThisName ? callableContainersWithThisName[0] : undefined;
795
+ if (knownCallableContainer) {
796
+ //get min/max parameter count for callable
797
+ let minParams = 0;
798
+ let maxParams = 0;
799
+ for (let param of knownCallableContainer.callable.params) {
800
+ maxParams++;
801
+ //optional parameters must come last, so we can assume that minParams won't increase once we hit
802
+ //the first isOptional
803
+ if (param.isOptional !== true) {
804
+ minParams++;
805
+ }
806
+ }
807
+ let expCallArgCount = expCall.args.length;
808
+ if (expCall.args.length > maxParams || expCall.args.length < minParams) {
809
+ let minMaxParamsText = minParams === maxParams ? maxParams : `${minParams}-${maxParams}`;
810
+ this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.mismatchArgumentCount(minMaxParamsText, expCallArgCount)), { range: expCall.nameRange,
811
+ //TODO detect end of expression call
812
+ file: file }));
813
+ }
814
+ }
815
+ }
818
816
  }
819
817
  /**
820
818
  * Detect local variables (function scope) that have the same name as scope calls
@@ -823,34 +821,39 @@ class Scope {
823
821
  var _a;
824
822
  const classMap = this.getClassMap();
825
823
  //loop through every function scope
826
- for (let funcScope of file.functionScopes) {
824
+ for (let scope of file.functionScopes) {
827
825
  //every var declaration in this function scope
828
- for (let varDeclaration of funcScope.variableDeclarations) {
826
+ for (let varDeclaration of scope.variableDeclarations) {
829
827
  const varName = varDeclaration.name;
830
828
  const lowerVarName = varName.toLowerCase();
831
- const varIsFunction = () => {
832
- return (0, reflection_1.isCallableType)(varDeclaration.getType());
833
- };
834
- if (
835
- //has same name as stdlib
836
- globalCallables_1.globalCallableMap.has(lowerVarName)) {
829
+ //if the var is a function
830
+ if ((0, reflection_1.isFunctionType)(varDeclaration.type)) {
837
831
  //local var function with same name as stdlib function
838
- if (varIsFunction()) {
839
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarFunctionShadowsParentFunction('stdlib')), { range: varDeclaration.nameRange, file: file, origin: interfaces_1.DiagnosticOrigin.Scope }));
832
+ if (
833
+ //has same name as stdlib
834
+ globalCallables_1.globalCallableMap.has(lowerVarName)) {
835
+ this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarFunctionShadowsParentFunction('stdlib')), { range: varDeclaration.nameRange, file: file }));
836
+ //this check needs to come after the stdlib one, because the stdlib functions are included
837
+ //in the scope function list
840
838
  }
839
+ else if (
840
+ //has same name as scope function
841
+ callableContainerMap.has(lowerVarName)) {
842
+ this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarFunctionShadowsParentFunction('scope')), { range: varDeclaration.nameRange, file: file }));
843
+ }
844
+ //var is not a function
841
845
  }
842
- else if (callableContainerMap.has(lowerVarName)) {
846
+ else if (
847
+ //is NOT a callable from stdlib (because non-function local vars can have same name as stdlib names)
848
+ !globalCallables_1.globalCallableMap.has(lowerVarName)) {
843
849
  //is same name as a callable
844
- if (varIsFunction()) {
845
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarFunctionShadowsParentFunction('scope')), { range: varDeclaration.nameRange, file: file, origin: interfaces_1.DiagnosticOrigin.Scope }));
850
+ if (callableContainerMap.has(lowerVarName)) {
851
+ this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarShadowedByScopedFunction()), { range: varDeclaration.nameRange, file: file }));
852
+ //has the same name as an in-scope class
846
853
  }
847
- else {
848
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarShadowedByScopedFunction()), { range: varDeclaration.nameRange, file: file, origin: interfaces_1.DiagnosticOrigin.Scope }));
854
+ else if (classMap.has(lowerVarName)) {
855
+ this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarSameNameAsClass((_a = classMap.get(lowerVarName)) === null || _a === void 0 ? void 0 : _a.item.getName(Parser_1.ParseMode.BrighterScript))), { range: varDeclaration.nameRange, file: file }));
849
856
  }
850
- //has the same name as an in-scope class
851
- }
852
- else if (classMap.has(lowerVarName)) {
853
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarSameNameAsClass((_a = classMap.get(lowerVarName)) === null || _a === void 0 ? void 0 : _a.item.getName(Parser_1.ParseMode.BrighterScript))), { range: varDeclaration.nameRange, file: file, origin: interfaces_1.DiagnosticOrigin.Scope }));
854
857
  }
855
858
  }
856
859
  }
@@ -889,9 +892,9 @@ class Scope {
889
892
  //same file: skip redundant imports
890
893
  continue;
891
894
  }
892
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.overridesAncestorFunction(container.callable.name, container.scope.name, shadowedCallable.callable.file.destPath,
895
+ this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.overridesAncestorFunction(container.callable.name, container.scope.name, shadowedCallable.callable.file.pkgPath,
893
896
  //grab the last item in the list, which should be the closest ancestor's version
894
- shadowedCallable.scope.name)), { range: container.callable.nameRange, file: container.callable.file, origin: interfaces_1.DiagnosticOrigin.Scope }));
897
+ shadowedCallable.scope.name)), { range: container.callable.nameRange, file: container.callable.file }));
895
898
  }
896
899
  }
897
900
  }
@@ -899,7 +902,7 @@ class Scope {
899
902
  if (ownCallables.length > 1) {
900
903
  for (let callableContainer of ownCallables) {
901
904
  let callable = callableContainer.callable;
902
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.duplicateFunctionImplementation(callable.name, callableContainer.scope.name)), { range: util_1.util.createRange(callable.nameRange.start.line, callable.nameRange.start.character, callable.nameRange.start.line, callable.nameRange.end.character), file: callable.file, origin: interfaces_1.DiagnosticOrigin.Scope }));
905
+ this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.duplicateFunctionImplementation(callable.name, callableContainer.scope.name)), { range: util_1.util.createRange(callable.nameRange.start.line, callable.nameRange.start.character, callable.nameRange.start.line, callable.nameRange.end.character), file: callable.file }));
903
906
  }
904
907
  }
905
908
  }
@@ -926,11 +929,11 @@ class Scope {
926
929
  let scriptImports = this.getOwnScriptImports();
927
930
  //verify every script import
928
931
  for (let scriptImport of scriptImports) {
929
- let referencedFile = this.getFileByRelativePath(scriptImport.destPath);
932
+ let referencedFile = this.getFileByRelativePath(scriptImport.pkgPath);
930
933
  //if we can't find the file
931
934
  if (!referencedFile) {
932
935
  //skip the default bslib file, it will exist at transpile time but should not show up in the program during validation cycle
933
- if (scriptImport.destPath === this.program.bslibPkgPath) {
936
+ if (scriptImport.pkgPath === `source${path.sep}bslib.brs`) {
934
937
  continue;
935
938
  }
936
939
  let dInfo;
@@ -940,11 +943,11 @@ class Scope {
940
943
  else {
941
944
  dInfo = DiagnosticMessages_1.DiagnosticMessages.referencedFileDoesNotExist();
942
945
  }
943
- this.diagnostics.push(Object.assign(Object.assign({}, dInfo), { range: scriptImport.filePathRange, file: scriptImport.sourceFile, origin: interfaces_1.DiagnosticOrigin.Scope }));
946
+ this.diagnostics.push(Object.assign(Object.assign({}, dInfo), { range: scriptImport.filePathRange, file: scriptImport.sourceFile }));
944
947
  //if the character casing of the script import path does not match that of the actual path
945
948
  }
946
- else if (scriptImport.destPath !== referencedFile.destPath) {
947
- this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.scriptImportCaseMismatch(referencedFile.destPath)), { range: scriptImport.filePathRange, file: scriptImport.sourceFile, origin: interfaces_1.DiagnosticOrigin.Scope }));
949
+ else if (scriptImport.pkgPath !== referencedFile.pkgPath) {
950
+ this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.scriptImportCaseMismatch(referencedFile.pkgPath)), { range: scriptImport.filePathRange, file: scriptImport.sourceFile }));
948
951
  }
949
952
  }
950
953
  }
@@ -957,7 +960,7 @@ class Scope {
957
960
  }
958
961
  let files = this.getAllFiles();
959
962
  for (let file of files) {
960
- if (file.destPath.toLowerCase() === relativePath.toLowerCase()) {
963
+ if (file.pkgPath.toLowerCase() === relativePath.toLowerCase()) {
961
964
  return file;
962
965
  }
963
966
  }
@@ -970,13 +973,74 @@ class Scope {
970
973
  let hasFile = files.includes(file);
971
974
  return hasFile;
972
975
  }
976
+ /**
977
+ * Get all callables as completionItems
978
+ */
979
+ getCallablesAsCompletions(parseMode) {
980
+ let completions = [];
981
+ let callables = this.getAllCallables();
982
+ if (parseMode === Parser_1.ParseMode.BrighterScript) {
983
+ //throw out the namespaced callables (they will be handled by another method)
984
+ callables = callables.filter(x => x.callable.hasNamespace === false);
985
+ }
986
+ for (let callableContainer of callables) {
987
+ completions.push(this.createCompletionFromCallable(callableContainer));
988
+ }
989
+ return completions;
990
+ }
991
+ createCompletionFromCallable(callableContainer) {
992
+ return {
993
+ label: callableContainer.callable.getName(Parser_1.ParseMode.BrighterScript),
994
+ kind: vscode_languageserver_1.CompletionItemKind.Function,
995
+ detail: callableContainer.callable.shortDescription,
996
+ documentation: callableContainer.callable.documentation ? { kind: 'markdown', value: callableContainer.callable.documentation } : undefined
997
+ };
998
+ }
999
+ createCompletionFromFunctionStatement(statement) {
1000
+ return {
1001
+ label: statement.getName(Parser_1.ParseMode.BrighterScript),
1002
+ kind: vscode_languageserver_1.CompletionItemKind.Function
1003
+ };
1004
+ }
973
1005
  /**
974
1006
  * Get the definition (where was this thing first defined) of the symbol under the position
1007
+ * @deprecated use `DefinitionProvider.process()`
975
1008
  */
976
1009
  getDefinition(file, position) {
977
1010
  // Overridden in XMLScope. Brs files use implementation in BrsFile
978
1011
  return [];
979
1012
  }
1013
+ /**
1014
+ * Scan all files for property names, and return them as completions
1015
+ */
1016
+ getPropertyNameCompletions() {
1017
+ let results = [];
1018
+ this.enumerateBrsFiles((file) => {
1019
+ results.push(...file.propertyNameCompletions);
1020
+ });
1021
+ return results;
1022
+ }
1023
+ getAllClassMemberCompletions() {
1024
+ let results = new Map();
1025
+ let filesSearched = new Set();
1026
+ for (const file of this.getAllFiles()) {
1027
+ if ((0, reflection_1.isXmlFile)(file) || filesSearched.has(file)) {
1028
+ continue;
1029
+ }
1030
+ filesSearched.add(file);
1031
+ for (let cs of file.parser.references.classStatements) {
1032
+ for (let s of [...cs.methods, ...cs.fields]) {
1033
+ if (!results.has(s.name.text) && s.name.text.toLowerCase() !== 'new') {
1034
+ results.set(s.name.text, {
1035
+ label: s.name.text,
1036
+ kind: (0, reflection_1.isMethodStatement)(s) ? vscode_languageserver_1.CompletionItemKind.Method : vscode_languageserver_1.CompletionItemKind.Field
1037
+ });
1038
+ }
1039
+ }
1040
+ }
1041
+ }
1042
+ return results;
1043
+ }
980
1044
  /**
981
1045
  * @param className - The name of the class (including namespace if possible)
982
1046
  * @param callsiteNamespace - the name of the namespace where the call site resides (this is NOT the known namespace of the class).
@@ -988,7 +1052,7 @@ class Scope {
988
1052
  let link = this.getClassFileLink(className, callsiteNamespace);
989
1053
  while (link) {
990
1054
  items.push(link);
991
- link = this.getClassFileLink((_b = (_a = link.item.parentClassName) === null || _a === void 0 ? void 0 : _a.getName()) === null || _b === void 0 ? void 0 : _b.toLowerCase(), callsiteNamespace);
1055
+ link = this.getClassFileLink((_b = (_a = link.item.parentClassName) === null || _a === void 0 ? void 0 : _a.getName(Parser_1.ParseMode.BrighterScript)) === null || _b === void 0 ? void 0 : _b.toLowerCase(), callsiteNamespace);
992
1056
  }
993
1057
  return items;
994
1058
  }