brighterscript 1.0.0-alpha.27 → 1.0.0-alpha.29

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 (168) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/README.md +1 -1
  3. package/dist/AstValidationSegmenter.d.ts +12 -2
  4. package/dist/AstValidationSegmenter.js +74 -16
  5. package/dist/AstValidationSegmenter.js.map +1 -1
  6. package/dist/DependencyGraph.d.ts +4 -0
  7. package/dist/DependencyGraph.js +19 -0
  8. package/dist/DependencyGraph.js.map +1 -1
  9. package/dist/DiagnosticFilterer.d.ts +7 -4
  10. package/dist/DiagnosticFilterer.js +67 -37
  11. package/dist/DiagnosticFilterer.js.map +1 -1
  12. package/dist/DiagnosticMessages.d.ts +1 -1
  13. package/dist/PluginInterface.js +1 -1
  14. package/dist/PluginInterface.js.map +1 -1
  15. package/dist/Program.d.ts +19 -15
  16. package/dist/Program.js +153 -88
  17. package/dist/Program.js.map +1 -1
  18. package/dist/Scope.d.ts +27 -28
  19. package/dist/Scope.js +174 -361
  20. package/dist/Scope.js.map +1 -1
  21. package/dist/Stopwatch.d.ts +4 -0
  22. package/dist/Stopwatch.js +7 -0
  23. package/dist/Stopwatch.js.map +1 -1
  24. package/dist/SymbolTable.d.ts +2 -1
  25. package/dist/SymbolTable.js +26 -0
  26. package/dist/SymbolTable.js.map +1 -1
  27. package/dist/{SymbolTableFlag.js → SymbolTypeFlag.js} +1 -1
  28. package/dist/SymbolTypeFlag.js.map +1 -0
  29. package/dist/XmlScope.d.ts +0 -8
  30. package/dist/XmlScope.js +0 -77
  31. package/dist/XmlScope.js.map +1 -1
  32. package/dist/astUtils/CachedLookups.js +4 -8
  33. package/dist/astUtils/CachedLookups.js.map +1 -1
  34. package/dist/astUtils/creators.d.ts +1 -0
  35. package/dist/astUtils/creators.js +3 -2
  36. package/dist/astUtils/creators.js.map +1 -1
  37. package/dist/astUtils/creators.spec.js +0 -10
  38. package/dist/astUtils/creators.spec.js.map +1 -1
  39. package/dist/astUtils/reflection.d.ts +4 -4
  40. package/dist/astUtils/reflection.js +8 -7
  41. package/dist/astUtils/reflection.js.map +1 -1
  42. package/dist/astUtils/reflection.spec.js +10 -15
  43. package/dist/astUtils/reflection.spec.js.map +1 -1
  44. package/dist/astUtils/visitors.d.ts +1 -2
  45. package/dist/astUtils/visitors.js.map +1 -1
  46. package/dist/astUtils/visitors.spec.js +1 -5
  47. package/dist/astUtils/visitors.spec.js.map +1 -1
  48. package/dist/bscPlugin/BscPlugin.d.ts +3 -1
  49. package/dist/bscPlugin/BscPlugin.js +10 -0
  50. package/dist/bscPlugin/BscPlugin.js.map +1 -1
  51. package/dist/bscPlugin/SignatureHelpUtil.js +4 -3
  52. package/dist/bscPlugin/SignatureHelpUtil.js.map +1 -1
  53. package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +1 -0
  54. package/dist/bscPlugin/completions/CompletionsProcessor.js +31 -11
  55. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
  56. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +39 -0
  57. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -1
  58. package/dist/bscPlugin/hover/HoverProcessor.js +5 -5
  59. package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
  60. package/dist/bscPlugin/hover/HoverProcessor.spec.js +51 -5
  61. package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
  62. package/dist/bscPlugin/references/ReferencesProvider.d.ts +12 -0
  63. package/dist/bscPlugin/references/ReferencesProvider.js +56 -0
  64. package/dist/bscPlugin/references/ReferencesProvider.js.map +1 -0
  65. package/dist/bscPlugin/references/ReferencesProvider.spec.d.ts +1 -0
  66. package/dist/bscPlugin/references/ReferencesProvider.spec.js +51 -0
  67. package/dist/bscPlugin/references/ReferencesProvider.spec.js.map +1 -0
  68. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js +1 -1
  69. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -1
  70. package/dist/bscPlugin/validation/BrsFileAfterValidatior.d.ts +7 -0
  71. package/dist/bscPlugin/validation/BrsFileAfterValidatior.js +18 -0
  72. package/dist/bscPlugin/validation/BrsFileAfterValidatior.js.map +1 -0
  73. package/dist/bscPlugin/validation/BrsFileValidator.d.ts +1 -0
  74. package/dist/bscPlugin/validation/BrsFileValidator.js +17 -10
  75. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
  76. package/dist/bscPlugin/validation/ScopeValidator.d.ts +37 -1
  77. package/dist/bscPlugin/validation/ScopeValidator.js +434 -25
  78. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
  79. package/dist/bscPlugin/validation/ScopeValidator.spec.js +91 -4
  80. package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -1
  81. package/dist/files/BrsFile.Class.spec.js +11 -4
  82. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  83. package/dist/files/BrsFile.d.ts +23 -5
  84. package/dist/files/BrsFile.js +189 -51
  85. package/dist/files/BrsFile.js.map +1 -1
  86. package/dist/files/BrsFile.spec.js +589 -97
  87. package/dist/files/BrsFile.spec.js.map +1 -1
  88. package/dist/files/BscFile.d.ts +2 -1
  89. package/dist/files/BscFile.js.map +1 -1
  90. package/dist/files/XmlFile.d.ts +2 -2
  91. package/dist/files/XmlFile.js +2 -2
  92. package/dist/files/XmlFile.js.map +1 -1
  93. package/dist/index.d.ts +1 -0
  94. package/dist/index.js +1 -0
  95. package/dist/index.js.map +1 -1
  96. package/dist/interfaces.d.ts +43 -4
  97. package/dist/interfaces.js.map +1 -1
  98. package/dist/lexer/Lexer.d.ts +9 -3
  99. package/dist/lexer/Lexer.js +36 -15
  100. package/dist/lexer/Lexer.js.map +1 -1
  101. package/dist/lexer/Lexer.spec.js +76 -38
  102. package/dist/lexer/Lexer.spec.js.map +1 -1
  103. package/dist/lexer/Token.js +1 -1
  104. package/dist/lexer/Token.js.map +1 -1
  105. package/dist/lexer/TokenKind.d.ts +1 -0
  106. package/dist/lexer/TokenKind.js +4 -1
  107. package/dist/lexer/TokenKind.js.map +1 -1
  108. package/dist/parser/AstNode.d.ts +1 -2
  109. package/dist/parser/AstNode.js +0 -1
  110. package/dist/parser/AstNode.js.map +1 -1
  111. package/dist/parser/BrsTranspileState.d.ts +1 -1
  112. package/dist/parser/Expression.d.ts +77 -47
  113. package/dist/parser/Expression.js +162 -88
  114. package/dist/parser/Expression.js.map +1 -1
  115. package/dist/parser/Parser.d.ts +7 -2
  116. package/dist/parser/Parser.js +40 -90
  117. package/dist/parser/Parser.js.map +1 -1
  118. package/dist/parser/Parser.spec.js +21 -44
  119. package/dist/parser/Parser.spec.js.map +1 -1
  120. package/dist/parser/SGTypes.js +5 -5
  121. package/dist/parser/SGTypes.js.map +1 -1
  122. package/dist/parser/Statement.d.ts +92 -84
  123. package/dist/parser/Statement.js +199 -133
  124. package/dist/parser/Statement.js.map +1 -1
  125. package/dist/parser/Statement.spec.js +0 -13
  126. package/dist/parser/Statement.spec.js.map +1 -1
  127. package/dist/parser/TranspileState.d.ts +17 -8
  128. package/dist/parser/TranspileState.js +67 -8
  129. package/dist/parser/TranspileState.js.map +1 -1
  130. package/dist/parser/tests/Parser.spec.d.ts +1 -1
  131. package/dist/parser/tests/Parser.spec.js +1 -2
  132. package/dist/parser/tests/Parser.spec.js.map +1 -1
  133. package/dist/parser/tests/controlFlow/If.spec.js +1 -1
  134. package/dist/parser/tests/controlFlow/If.spec.js.map +1 -1
  135. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +1 -3
  136. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
  137. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +44 -0
  138. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
  139. package/dist/parser/tests/expression/TemplateStringExpression.spec.js +6 -6
  140. package/dist/parser/tests/expression/TernaryExpression.spec.js +47 -0
  141. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
  142. package/dist/parser/tests/statement/ConstStatement.spec.js +2 -2
  143. package/dist/parser/tests/statement/InterfaceStatement.spec.js +8 -1
  144. package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
  145. package/dist/parser/tests/statement/Misc.spec.js +25 -5
  146. package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
  147. package/dist/preprocessor/Chunk.js +1 -2
  148. package/dist/preprocessor/Chunk.js.map +1 -1
  149. package/dist/preprocessor/PreprocessorParser.js +2 -1
  150. package/dist/preprocessor/PreprocessorParser.js.map +1 -1
  151. package/dist/types/AssociativeArrayType.d.ts +3 -0
  152. package/dist/types/AssociativeArrayType.js +9 -0
  153. package/dist/types/AssociativeArrayType.js.map +1 -1
  154. package/dist/types/BscType.d.ts +1 -1
  155. package/dist/types/BscType.js +1 -0
  156. package/dist/types/BscType.js.map +1 -1
  157. package/dist/types/ComponentType.d.ts +1 -1
  158. package/dist/types/ReferenceType.d.ts +9 -1
  159. package/dist/types/ReferenceType.js +45 -1
  160. package/dist/types/ReferenceType.js.map +1 -1
  161. package/dist/types/ReferenceType.spec.js +15 -0
  162. package/dist/types/ReferenceType.spec.js.map +1 -1
  163. package/dist/util.d.ts +23 -9
  164. package/dist/util.js +115 -21
  165. package/dist/util.js.map +1 -1
  166. package/package.json +6 -3
  167. package/dist/SymbolTableFlag.js.map +0 -1
  168. /package/dist/{SymbolTableFlag.d.ts → SymbolTypeFlag.d.ts} +0 -0
package/dist/Scope.d.ts CHANGED
@@ -1,13 +1,12 @@
1
- import type { CallableContainer, BsDiagnosticWithOrigin, CallableContainerMap, FileLink, Callable, NamespaceContainer, ScopeValidationOptions, BsDiagnostic } from './interfaces';
1
+ import type { CallableContainer, BsDiagnosticWithOrigin, FileReference, FileLink, Callable, NamespaceContainer, ScopeValidationOptions, BsDiagnostic } from './interfaces';
2
2
  import type { Program } from './Program';
3
- import type { NamespaceStatement, ClassStatement, EnumStatement, InterfaceStatement, EnumMemberStatement, ConstStatement } from './parser/Statement';
3
+ import { type NamespaceStatement, type ClassStatement, type EnumStatement, type InterfaceStatement, type EnumMemberStatement, type ConstStatement } from './parser/Statement';
4
4
  import { Cache } from './Cache';
5
5
  import type { BrsFile } from './files/BrsFile';
6
6
  import type { DependencyGraph, DependencyChangedEvent } from './DependencyGraph';
7
7
  import { SymbolTable } from './SymbolTable';
8
8
  import type { BscFile } from './files/BscFile';
9
9
  import type { AstNode, Statement } from './parser/AstNode';
10
- import type { Token } from './lexer/Token';
11
10
  /**
12
11
  * A class to keep track of all declarations within a given scope (like source scope, component scope)
13
12
  */
@@ -37,6 +36,10 @@ export declare class Scope {
37
36
  * Get a NamespaceContainer by its name, looking for a fully qualified version first, then global version next if not found
38
37
  */
39
38
  getNamespacesWithRoot(rootName: string, containingNamespace?: string): NamespaceContainer[];
39
+ /**
40
+ * Get a NamespaceContainer by its name, looking for a fully qualified version first, then global version next if not found
41
+ */
42
+ getFirstNamespaceWithRoot(rootName: string, containingNamespace?: string): NamespaceContainer;
40
43
  /**
41
44
  * Get the class with the specified name.
42
45
  * @param className - The class name, including the namespace of the class if possible
@@ -55,6 +58,8 @@ export declare class Scope {
55
58
  * @param containingNamespace - The namespace used to resolve relative enum names. (i.e. the namespace around the current statement trying to find an enum)
56
59
  */
57
60
  getEnum(enumName: string, containingNamespace?: string): EnumStatement;
61
+ private useFileCachesForFileLinkLookups;
62
+ private getFileLinkFromFileMap;
58
63
  /**
59
64
  * Get a class and its containing file by the class name
60
65
  * @param className - The class name, including the namespace of the class if possible
@@ -85,7 +90,7 @@ export declare class Scope {
85
90
  * @param containingNamespace - The namespace used to resolve relative constant names. (i.e. the namespace around the current statement trying to find a constant)
86
91
  */
87
92
  getConstFileLink(constName: string, containingNamespace?: string): FileLink<ConstStatement>;
88
- getAllFileLinks(name: string, containingNamespace?: string): FileLink<Statement>[];
93
+ getAllFileLinks(name: string, containingNamespace?: string, includeNamespaces?: boolean, includeNameShadowsOutsideNamespace?: boolean): FileLink<Statement>[];
89
94
  /**
90
95
  * Get a map of all enums by their member name.
91
96
  * The keys are lower-case fully-qualified paths to the enum and its member. For example:
@@ -172,6 +177,10 @@ export declare class Scope {
172
177
  * Includes files from this scope and all ancestor scopes
173
178
  */
174
179
  getAllFiles(): BscFile[];
180
+ /**
181
+ * Gets a list of all files in this scope, but not imported files, and not from ancestor scopes
182
+ */
183
+ getImmediateFiles(): BscFile[];
175
184
  /**
176
185
  * Get the list of errors for this scope. It's calculated on the fly, so call this sparingly.
177
186
  */
@@ -187,10 +196,15 @@ export declare class Scope {
187
196
  */
188
197
  getCallableByName(name: string): Callable;
189
198
  getCallableMap(): Map<string, Callable>;
199
+ getCallableContainerMap(): import("./interfaces").CallableContainerMap;
190
200
  /**
191
201
  * Iterate over Brs files not shadowed by typedefs
192
202
  */
193
203
  enumerateBrsFiles(callback: (file: BrsFile) => void): void;
204
+ /**
205
+ * Iterate over Brs files not shadowed by typedefs
206
+ */
207
+ enumerateBrsFilesWithBreak(callback: (file: BrsFile) => boolean): void;
194
208
  /**
195
209
  * Call a function for each file directly included in this scope (excluding files found only in parent scopes).
196
210
  */
@@ -209,8 +223,11 @@ export declare class Scope {
209
223
  getAllNamespaceStatements(): NamespaceStatement[];
210
224
  protected logDebug(...args: any[]): void;
211
225
  private _debugLogComponentName;
212
- validate(validationOptions?: ScopeValidationOptions): void;
213
- protected _validate(callableContainerMap: CallableContainerMap): void;
226
+ validationMetrics: {
227
+ linkTime: number;
228
+ validationTime: number;
229
+ };
230
+ validate(validationOptions?: ScopeValidationOptions): boolean;
214
231
  clearAstSegmentDiagnostics(astSegment: AstNode): void;
215
232
  clearAstSegmentDiagnosticsByFile(file: BscFile): void;
216
233
  clearScopeLevelDiagnostics(): void;
@@ -224,6 +241,8 @@ export declare class Scope {
224
241
  */
225
242
  private linkSymbolTableDisposables;
226
243
  private symbolsAddedDuringLinking;
244
+ get allNamespaceTypeTable(): SymbolTable;
245
+ private _allNamespaceTypeTable;
227
246
  /**
228
247
  * Builds the current symbol table for the scope, by merging the tables for all the files in this scope.
229
248
  * Also links all file symbols tables to this new table
@@ -245,34 +264,14 @@ export declare class Scope {
245
264
  */
246
265
  linkSymbolTable(): void;
247
266
  unlinkSymbolTable(): void;
248
- private detectVariableNamespaceCollisions;
249
- /**
250
- * Find various function collisions
251
- */
252
- private diagnosticDetectFunctionCollisions;
253
- private detectNameCollisions;
254
- validateNameCollision(file: BrsFile, node: AstNode, nameIdentifier: Token): void;
255
- private validateClasses;
256
- /**
257
- * Detect local variables (function scope) that have the same name as scope calls
258
- */
259
- private diagnosticDetectShadowedLocalVars;
260
- /**
261
- * Create diagnostics for any duplicate function declarations
262
- */
263
- private diagnosticFindDuplicateFunctionDeclarations;
264
267
  /**
265
268
  * Get the list of all script imports for this scope
266
269
  */
267
- private getOwnScriptImports;
268
- /**
269
- * Verify that all of the scripts imported by each file in this scope actually exist
270
- */
271
- private diagnosticValidateScriptImportPaths;
270
+ getOwnScriptImports(): FileReference[];
272
271
  /**
273
272
  * Find the file with the specified relative path
274
273
  */
275
- protected getFileByRelativePath(relativePath: string): BscFile;
274
+ getFileByRelativePath(relativePath: string): BscFile;
276
275
  /**
277
276
  * Determine if this file is included in this scope (excluding parent scopes)
278
277
  */