brighterscript 1.0.0-alpha.51 → 1.0.0-alpha.53

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/README.md +12 -5
  2. package/bsconfig.schema.json +151 -0
  3. package/dist/BsConfig.d.ts +158 -44
  4. package/dist/BsConfig.js +24 -0
  5. package/dist/BsConfig.js.map +1 -1
  6. package/dist/BusyStatusTracker.js +3 -0
  7. package/dist/BusyStatusTracker.js.map +1 -1
  8. package/dist/CrossScopeValidator.js +5 -0
  9. package/dist/CrossScopeValidator.js.map +1 -1
  10. package/dist/DiagnosticFilterer.d.ts +17 -1
  11. package/dist/DiagnosticFilterer.js +69 -6
  12. package/dist/DiagnosticFilterer.js.map +1 -1
  13. package/dist/DiagnosticManager.d.ts +11 -1
  14. package/dist/DiagnosticManager.js +22 -3
  15. package/dist/DiagnosticManager.js.map +1 -1
  16. package/dist/DiagnosticMessages.d.ts +93 -4
  17. package/dist/DiagnosticMessages.js +91 -5
  18. package/dist/DiagnosticMessages.js.map +1 -1
  19. package/dist/LanguageServer.d.ts +17 -4
  20. package/dist/LanguageServer.js +65 -6
  21. package/dist/LanguageServer.js.map +1 -1
  22. package/dist/Logger.d.ts +7 -7
  23. package/dist/Logger.js +2 -2
  24. package/dist/Logger.js.map +1 -1
  25. package/dist/PluginInterface.js +2 -1
  26. package/dist/PluginInterface.js.map +1 -1
  27. package/dist/Program.d.ts +110 -9
  28. package/dist/Program.js +293 -23
  29. package/dist/Program.js.map +1 -1
  30. package/dist/ProgramBuilder.js +6 -0
  31. package/dist/ProgramBuilder.js.map +1 -1
  32. package/dist/RokuConstants.d.ts +123 -0
  33. package/dist/RokuConstants.js +87 -0
  34. package/dist/RokuConstants.js.map +1 -0
  35. package/dist/ScopeNamespaceLookup.js.map +1 -1
  36. package/dist/Stopwatch.js +2 -2
  37. package/dist/Stopwatch.js.map +1 -1
  38. package/dist/SymbolTable.d.ts +1 -0
  39. package/dist/SymbolTable.js +20 -12
  40. package/dist/SymbolTable.js.map +1 -1
  41. package/dist/Throttler.d.ts +1 -1
  42. package/dist/Throttler.js.map +1 -1
  43. package/dist/astUtils/reflection.d.ts +6 -1
  44. package/dist/astUtils/reflection.js +15 -4
  45. package/dist/astUtils/reflection.js.map +1 -1
  46. package/dist/astUtils/visitors.d.ts +1 -1
  47. package/dist/astUtils/visitors.js +2 -0
  48. package/dist/astUtils/visitors.js.map +1 -1
  49. package/dist/bscPlugin/BscPlugin.d.ts +3 -2
  50. package/dist/bscPlugin/BscPlugin.js +5 -1
  51. package/dist/bscPlugin/BscPlugin.js.map +1 -1
  52. package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
  53. package/dist/bscPlugin/SignatureHelpUtil.js.map +1 -1
  54. package/dist/bscPlugin/codeActions/FixAllCodeActionsProcessor.d.ts +3 -3
  55. package/dist/bscPlugin/codeActions/FixAllCodeActionsProcessor.js.map +1 -1
  56. package/dist/bscPlugin/completions/CompletionsProcessor.js +2 -3
  57. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
  58. package/dist/bscPlugin/definition/DefinitionProvider.d.ts +67 -2
  59. package/dist/bscPlugin/definition/DefinitionProvider.js +244 -5
  60. package/dist/bscPlugin/definition/DefinitionProvider.js.map +1 -1
  61. package/dist/bscPlugin/inlayHints/InlayHintProcessor.d.ts +23 -0
  62. package/dist/bscPlugin/inlayHints/InlayHintProcessor.js +186 -0
  63. package/dist/bscPlugin/inlayHints/InlayHintProcessor.js.map +1 -0
  64. package/dist/bscPlugin/references/ReferencesProvider.js +7 -1
  65. package/dist/bscPlugin/references/ReferencesProvider.js.map +1 -1
  66. package/dist/bscPlugin/validation/BrsFileValidator.d.ts +40 -6
  67. package/dist/bscPlugin/validation/BrsFileValidator.js +109 -18
  68. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
  69. package/dist/bscPlugin/validation/ProgramValidator.d.ts +10 -0
  70. package/dist/bscPlugin/validation/ProgramValidator.js +54 -0
  71. package/dist/bscPlugin/validation/ProgramValidator.js.map +1 -1
  72. package/dist/bscPlugin/validation/ScopeValidator.js +55 -30
  73. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
  74. package/dist/bscPlugin/validation/XmlFileValidator.d.ts +18 -0
  75. package/dist/bscPlugin/validation/XmlFileValidator.js +51 -0
  76. package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -1
  77. package/dist/cli.js.map +1 -1
  78. package/dist/diagnosticUtils.d.ts +1 -1
  79. package/dist/diagnosticUtils.js.map +1 -1
  80. package/dist/files/BrsFile.d.ts +2 -2
  81. package/dist/files/BrsFile.js +2 -2
  82. package/dist/files/BrsFile.js.map +1 -1
  83. package/dist/files/XmlFile.d.ts +51 -1
  84. package/dist/files/XmlFile.js +264 -0
  85. package/dist/files/XmlFile.js.map +1 -1
  86. package/dist/formatUtils.d.ts +20 -0
  87. package/dist/formatUtils.js +38 -0
  88. package/dist/formatUtils.js.map +1 -0
  89. package/dist/globalCallables.d.ts +1 -1
  90. package/dist/globalCallables.js +4 -1
  91. package/dist/globalCallables.js.map +1 -1
  92. package/dist/interfaces.d.ts +93 -5
  93. package/dist/interfaces.js.map +1 -1
  94. package/dist/lexer/Lexer.d.ts +26 -0
  95. package/dist/lexer/Lexer.js +140 -15
  96. package/dist/lexer/Lexer.js.map +1 -1
  97. package/dist/lexer/TokenKind.d.ts +27 -0
  98. package/dist/lexer/TokenKind.js +77 -3
  99. package/dist/lexer/TokenKind.js.map +1 -1
  100. package/dist/lsp/ActionQueue.js +1 -2
  101. package/dist/lsp/ActionQueue.js.map +1 -1
  102. package/dist/lsp/DocumentManager.js +4 -0
  103. package/dist/lsp/DocumentManager.js.map +1 -1
  104. package/dist/lsp/LspProject.d.ts +9 -2
  105. package/dist/lsp/Project.d.ts +6 -2
  106. package/dist/lsp/Project.js +8 -0
  107. package/dist/lsp/Project.js.map +1 -1
  108. package/dist/lsp/ProjectManager.d.ts +11 -2
  109. package/dist/lsp/ProjectManager.js +15 -1
  110. package/dist/lsp/ProjectManager.js.map +1 -1
  111. package/dist/lsp/worker/MessageHandler.d.ts +1 -0
  112. package/dist/lsp/worker/MessageHandler.js +9 -0
  113. package/dist/lsp/worker/MessageHandler.js.map +1 -1
  114. package/dist/lsp/worker/WorkerPool.d.ts +51 -17
  115. package/dist/lsp/worker/WorkerPool.js +118 -40
  116. package/dist/lsp/worker/WorkerPool.js.map +1 -1
  117. package/dist/lsp/worker/WorkerThreadProject.d.ts +20 -3
  118. package/dist/lsp/worker/WorkerThreadProject.js +53 -10
  119. package/dist/lsp/worker/WorkerThreadProject.js.map +1 -1
  120. package/dist/lsp/worker/WorkerThreadProjectRunner.js +6 -0
  121. package/dist/lsp/worker/WorkerThreadProjectRunner.js.map +1 -1
  122. package/dist/lsp/worker/run.js +20 -3
  123. package/dist/lsp/worker/run.js.map +1 -1
  124. package/dist/parser/AstNode.d.ts +59 -2
  125. package/dist/parser/AstNode.js +63 -5
  126. package/dist/parser/AstNode.js.map +1 -1
  127. package/dist/parser/BrsTranspileState.d.ts +44 -0
  128. package/dist/parser/BrsTranspileState.js +49 -0
  129. package/dist/parser/BrsTranspileState.js.map +1 -1
  130. package/dist/parser/Expression.d.ts +56 -8
  131. package/dist/parser/Expression.js +91 -8
  132. package/dist/parser/Expression.js.map +1 -1
  133. package/dist/parser/Parser.d.ts +0 -5
  134. package/dist/parser/Parser.js +5 -9
  135. package/dist/parser/Parser.js.map +1 -1
  136. package/dist/parser/SGParser.d.ts +7 -1
  137. package/dist/parser/SGParser.js +20 -10
  138. package/dist/parser/SGParser.js.map +1 -1
  139. package/dist/parser/SGTypes.js +8 -2
  140. package/dist/parser/SGTypes.js.map +1 -1
  141. package/dist/parser/Statement.d.ts +21 -10
  142. package/dist/parser/Statement.js +61 -1
  143. package/dist/parser/Statement.js.map +1 -1
  144. package/dist/parser/TranspileState.js +3 -0
  145. package/dist/parser/TranspileState.js.map +1 -1
  146. package/dist/preprocessor/Manifest.d.ts +16 -0
  147. package/dist/preprocessor/Manifest.js +21 -5
  148. package/dist/preprocessor/Manifest.js.map +1 -1
  149. package/dist/roku-types/index.d.ts +3 -0
  150. package/dist/types/BuiltInInterfaceAdder.js +1 -1
  151. package/dist/types/BuiltInInterfaceAdder.js.map +1 -1
  152. package/dist/types/InheritableType.d.ts +0 -1
  153. package/dist/types/InheritableType.js +12 -11
  154. package/dist/types/InheritableType.js.map +1 -1
  155. package/dist/types/InterfaceType.js +6 -0
  156. package/dist/types/InterfaceType.js.map +1 -1
  157. package/dist/types/IntersectionType.d.ts +1 -1
  158. package/dist/types/IntersectionType.js +7 -7
  159. package/dist/types/IntersectionType.js.map +1 -1
  160. package/dist/types/ReferenceType.js +1 -1
  161. package/dist/types/ReferenceType.js.map +1 -1
  162. package/dist/types/helpers.d.ts +2 -2
  163. package/dist/types/helpers.js +8 -5
  164. package/dist/types/helpers.js.map +1 -1
  165. package/dist/util.d.ts +38 -4
  166. package/dist/util.js +296 -29
  167. package/dist/util.js.map +1 -1
  168. package/package.json +14 -19
@@ -61,6 +61,8 @@ export declare class CallExpression extends Expression {
61
61
  };
62
62
  readonly kind = AstNodeKind.CallExpression;
63
63
  readonly location: Location | undefined;
64
+ /** `a.b()` -> `a.b` (not the args) */
65
+ get previousInChain(): Expression;
64
66
  transpile(state: BrsTranspileState, nameOverride?: string): TranspileResult;
65
67
  walk(visitor: WalkVisitor, options: WalkOptions): void;
66
68
  getType(options: GetTypeOptions): BscType;
@@ -97,11 +99,11 @@ export declare class FunctionExpression extends Expression implements TypedefPro
97
99
  */
98
100
  get location(): Location;
99
101
  transpile(state: BrsTranspileState, name?: Identifier, includeBody?: boolean): TranspileResult;
100
- getTypedef(state: BrsTranspileState): SourceNode[];
102
+ getTypedef(state: BrsTranspileState): any;
101
103
  walk(visitor: WalkVisitor, options: WalkOptions): void;
102
104
  getType(options: GetTypeOptions): TypedFunctionType;
103
105
  private get requiresReturnType();
104
- clone(): FunctionExpression;
106
+ clone(): any;
105
107
  }
106
108
  export declare class FunctionParameterExpression extends Expression {
107
109
  constructor(options: {
@@ -141,10 +143,20 @@ export declare class DottedGetExpression extends Expression {
141
143
  readonly dot?: Token;
142
144
  };
143
145
  readonly obj: Expression;
146
+ /**
147
+ * @deprecated use `tokens.name` instead
148
+ */
149
+ get name(): Identifier;
150
+ /**
151
+ * @deprecated use `tokens.dot` instead
152
+ */
153
+ get dot(): Token | undefined;
144
154
  readonly kind = AstNodeKind.DottedGetExpression;
145
155
  readonly location: Location | undefined;
146
- transpile(state: BrsTranspileState): (string | SourceNode | TranspileResult)[];
147
- getTypedef(state: BrsTranspileState): (string | SourceNode | TranspileResult)[];
156
+ /** `a.b` -> `a` */
157
+ get previousInChain(): Expression;
158
+ transpile(state: BrsTranspileState): (string | TranspileResult | SourceNode)[];
159
+ getTypedef(state: BrsTranspileState): (string | TranspileResult | SourceNode)[];
148
160
  walk(visitor: WalkVisitor, options: WalkOptions): void;
149
161
  getType(options: GetTypeOptions): BscType;
150
162
  getName(parseMode: ParseMode): string;
@@ -167,7 +179,9 @@ export declare class XmlAttributeGetExpression extends Expression {
167
179
  };
168
180
  readonly obj: Expression;
169
181
  readonly location: Location | undefined;
170
- transpile(state: BrsTranspileState): (string | SourceNode | TranspileResult)[];
182
+ /** `a@b` -> `a` */
183
+ get previousInChain(): Expression;
184
+ transpile(state: BrsTranspileState): (string | TranspileResult | SourceNode)[];
171
185
  walk(visitor: WalkVisitor, options: WalkOptions): void;
172
186
  get leadingTrivia(): Token[];
173
187
  clone(): XmlAttributeGetExpression;
@@ -194,7 +208,21 @@ export declare class IndexedGetExpression extends Expression {
194
208
  readonly closingSquare?: Token;
195
209
  readonly questionDot?: Token;
196
210
  };
211
+ /**
212
+ * @deprecated use `tokens.questionDot` instead
213
+ */
214
+ get questionDotToken(): Token | undefined;
215
+ /**
216
+ * @deprecated use `tokens.openingSquare` instead
217
+ */
218
+ get openingSquare(): Token | undefined;
219
+ /**
220
+ * @deprecated use `indexes[0]` instead
221
+ */
222
+ get index(): Expression | undefined;
197
223
  readonly location: Location | undefined;
224
+ /** `a[i]` -> `a` (not the index) */
225
+ get previousInChain(): Expression;
198
226
  transpile(state: BrsTranspileState): any[];
199
227
  walk(visitor: WalkVisitor, options: WalkOptions): void;
200
228
  getType(options: GetTypeOptions): BscType;
@@ -248,7 +276,7 @@ export declare class PrintSeparatorExpression extends Expression {
248
276
  };
249
277
  readonly kind = AstNodeKind.PrintSeparatorExpression;
250
278
  location: Location;
251
- transpile(state: BrsTranspileState): (string | SourceNode | TranspileResult)[];
279
+ transpile(state: BrsTranspileState): (string | TranspileResult | SourceNode)[];
252
280
  walk(visitor: WalkVisitor, options: WalkOptions): void;
253
281
  get leadingTrivia(): Token[];
254
282
  clone(): PrintSeparatorExpression;
@@ -373,7 +401,7 @@ export declare class UnaryExpression extends Expression {
373
401
  readonly operator: Token;
374
402
  };
375
403
  readonly right: Expression;
376
- transpile(state: BrsTranspileState): (string | SourceNode | TranspileResult)[];
404
+ transpile(state: BrsTranspileState): (string | TranspileResult | SourceNode)[];
377
405
  walk(visitor: WalkVisitor, options: WalkOptions): void;
378
406
  getType(options: GetTypeOptions): BscType;
379
407
  get leadingTrivia(): Token[];
@@ -388,6 +416,10 @@ export declare class VariableExpression extends Expression {
388
416
  };
389
417
  readonly kind = AstNodeKind.VariableExpression;
390
418
  readonly location: Location;
419
+ /**
420
+ * @deprecated use `tokens.name` instead
421
+ */
422
+ get name(): Identifier;
391
423
  getName(parseMode?: ParseMode): string;
392
424
  transpile(state: BrsTranspileState): TranspileResult;
393
425
  getTypedef(state: BrsTranspileState): TranspileResult[];
@@ -439,6 +471,8 @@ export declare class NewExpression extends Expression {
439
471
  * The name of the class to initialize (with optional namespace prefixed)
440
472
  */
441
473
  get className(): DottedGetExpression | VariableExpression;
474
+ /** `new Alpha.Beta()` -> `Alpha.Beta()` */
475
+ get previousInChain(): CallExpression;
442
476
  transpile(state: BrsTranspileState): TranspileResult;
443
477
  walk(visitor: WalkVisitor, options: WalkOptions): void;
444
478
  getType(options: GetTypeOptions): BscType;
@@ -464,6 +498,8 @@ export declare class CallfuncExpression extends Expression {
464
498
  };
465
499
  readonly kind = AstNodeKind.CallfuncExpression;
466
500
  readonly location: Location | undefined;
501
+ /** `a@.b()` -> `a` (not the args) */
502
+ get previousInChain(): Expression;
467
503
  transpile(state: BrsTranspileState): TranspileResult;
468
504
  walk(visitor: WalkVisitor, options: WalkOptions): void;
469
505
  getType(options: GetTypeOptions): BscType;
@@ -548,7 +584,7 @@ export declare class AnnotationExpression extends Expression {
548
584
  get leadingTrivia(): Token[];
549
585
  transpile(state: BrsTranspileState): (string | SourceNode)[];
550
586
  walk(visitor: WalkVisitor, options: WalkOptions): void;
551
- getTypedef(state: BrsTranspileState): (string | SourceNode | TranspileResult)[];
587
+ getTypedef(state: BrsTranspileState): (string | TranspileResult | SourceNode)[];
552
588
  clone(): AnnotationExpression;
553
589
  }
554
590
  export declare class TernaryExpression extends Expression {
@@ -614,12 +650,23 @@ export declare class TypeExpression extends Expression implements TypedefProvide
614
650
  * The standard AST expression that represents the type for this TypeExpression.
615
651
  */
616
652
  expression: Expression;
653
+ /**
654
+ * An already-known type for this TypeExpression, bypassing resolution of `expression`
655
+ * via symbol table lookup. Useful when `expression` is not attached to (or can't resolve
656
+ * against) a real symbol table - e.g. a type reference synthesized for a detached AST node.
657
+ */
658
+ resolvedType?: BscType;
617
659
  });
618
660
  readonly kind = AstNodeKind.TypeExpression;
619
661
  /**
620
662
  * The standard AST expression that represents the type for this TypeExpression.
621
663
  */
622
664
  readonly expression: Expression;
665
+ /**
666
+ * An already-known type for this TypeExpression. When set, `getType()` returns this
667
+ * directly instead of resolving `expression` via symbol table lookup.
668
+ */
669
+ readonly resolvedType?: BscType;
623
670
  readonly location: Location;
624
671
  transpile(state: BrsTranspileState): TranspileResult;
625
672
  walk(visitor: WalkVisitor, options: WalkOptions): void;
@@ -726,6 +773,7 @@ export declare class TypedFunctionTypeExpression extends Expression {
726
773
  readonly returnType?: TypeExpression;
727
774
  readonly location: Location;
728
775
  transpile(state: BrsTranspileState): TranspileResult;
776
+ getTypedef(state: BrsTranspileState): TranspileResult;
729
777
  walk(visitor: WalkVisitor, options: WalkOptions): void;
730
778
  getType(options: GetTypeOptions): BscType;
731
779
  clone(): TypedFunctionTypeExpression;
@@ -4,7 +4,6 @@ exports.TypedFunctionTypeExpression = exports.InlineInterfaceMemberExpression =
4
4
  const TokenKind_1 = require("../lexer/TokenKind");
5
5
  const util_1 = require("../util");
6
6
  const Parser_1 = require("./Parser");
7
- const fileUrl = require("file-url");
8
7
  const visitors_1 = require("../astUtils/visitors");
9
8
  const visitors_2 = require("../astUtils/visitors");
10
9
  const reflection_1 = require("../astUtils/reflection");
@@ -96,6 +95,10 @@ class CallExpression extends AstNode_1.Expression {
96
95
  this.args = (_a = options.args) !== null && _a !== void 0 ? _a : [];
97
96
  this.location = util_1.default.createBoundingLocation(this.callee, this.tokens.openingParen, ...(_b = this.args) !== null && _b !== void 0 ? _b : [], this.tokens.closingParen);
98
97
  }
98
+ /** `a.b()` -> `a.b` (not the args) */
99
+ get previousInChain() {
100
+ return this.callee;
101
+ }
99
102
  transpile(state, nameOverride) {
100
103
  let result = [];
101
104
  //transpile the name
@@ -486,6 +489,22 @@ class DottedGetExpression extends AstNode_1.Expression {
486
489
  this.obj = options.obj;
487
490
  this.location = util_1.default.createBoundingLocation(this.obj, this.tokens.dot, this.tokens.name);
488
491
  }
492
+ /**
493
+ * @deprecated use `tokens.name` instead
494
+ */
495
+ get name() {
496
+ return this.tokens.name;
497
+ }
498
+ /**
499
+ * @deprecated use `tokens.dot` instead
500
+ */
501
+ get dot() {
502
+ return this.tokens.dot;
503
+ }
504
+ /** `a.b` -> `a` */
505
+ get previousInChain() {
506
+ return this.obj;
507
+ }
489
508
  transpile(state) {
490
509
  //if the callee starts with a namespace name, transpile the name
491
510
  if (state.file.calleeStartsWithNamespace(this)) {
@@ -564,6 +583,10 @@ class XmlAttributeGetExpression extends AstNode_1.Expression {
564
583
  this.tokens = { at: options.at, name: options.name };
565
584
  this.location = util_1.default.createBoundingLocation(this.obj, this.tokens.at, this.tokens.name);
566
585
  }
586
+ /** `a@b` -> `a` */
587
+ get previousInChain() {
588
+ return this.obj;
589
+ }
567
590
  transpile(state) {
568
591
  return [
569
592
  ...this.obj.transpile(state),
@@ -603,6 +626,29 @@ class IndexedGetExpression extends AstNode_1.Expression {
603
626
  this.indexes = options.indexes;
604
627
  this.location = util_1.default.createBoundingLocation(this.obj, this.tokens.openingSquare, this.tokens.questionDot, this.tokens.openingSquare, ...(_a = this.indexes) !== null && _a !== void 0 ? _a : [], this.tokens.closingSquare);
605
628
  }
629
+ /**
630
+ * @deprecated use `tokens.questionDot` instead
631
+ */
632
+ get questionDotToken() {
633
+ return this.tokens.questionDot;
634
+ }
635
+ /**
636
+ * @deprecated use `tokens.openingSquare` instead
637
+ */
638
+ get openingSquare() {
639
+ return this.tokens.openingSquare;
640
+ }
641
+ /**
642
+ * @deprecated use `indexes[0]` instead
643
+ */
644
+ get index() {
645
+ var _a;
646
+ return (_a = this.indexes) === null || _a === void 0 ? void 0 : _a[0];
647
+ }
648
+ /** `a[i]` -> `a` (not the index) */
649
+ get previousInChain() {
650
+ return this.obj;
651
+ }
606
652
  transpile(state) {
607
653
  var _a;
608
654
  const result = [];
@@ -1083,6 +1129,12 @@ class VariableExpression extends AstNode_1.Expression {
1083
1129
  };
1084
1130
  this.location = util_1.default.cloneLocation((_a = this.tokens.name) === null || _a === void 0 ? void 0 : _a.location);
1085
1131
  }
1132
+ /**
1133
+ * @deprecated use `tokens.name` instead
1134
+ */
1135
+ get name() {
1136
+ return this.tokens.name;
1137
+ }
1086
1138
  getName(parseMode) {
1087
1139
  return this.tokens.name.text;
1088
1140
  }
@@ -1198,7 +1250,7 @@ class SourceLiteralExpression extends AstNode_1.Expression {
1198
1250
  let text;
1199
1251
  switch (this.tokens.value.kind) {
1200
1252
  case TokenKind_1.TokenKind.SourceFilePathLiteral:
1201
- const pathUrl = fileUrl(state.srcPath);
1253
+ const pathUrl = util_1.default.fileUrl(state.srcPath);
1202
1254
  text = `"${pathUrl.substring(0, 4)}" + "${pathUrl.substring(4)}"`;
1203
1255
  break;
1204
1256
  case TokenKind_1.TokenKind.SourceLineNumLiteral:
@@ -1223,7 +1275,7 @@ class SourceLiteralExpression extends AstNode_1.Expression {
1223
1275
  text = `"${rootNamespace}"`;
1224
1276
  break;
1225
1277
  case TokenKind_1.TokenKind.SourceLocationLiteral:
1226
- const locationUrl = fileUrl(state.srcPath);
1278
+ const locationUrl = util_1.default.fileUrl(state.srcPath);
1227
1279
  //TODO find first parent that has range, or default to -1
1228
1280
  text = `"${locationUrl.substring(0, 4)}" + "${locationUrl.substring(4)}:${this.getClosestLineNumber()}"`;
1229
1281
  break;
@@ -1279,6 +1331,10 @@ class NewExpression extends AstNode_1.Expression {
1279
1331
  //either a VariableExpression or a DottedGet
1280
1332
  return this.call.callee;
1281
1333
  }
1334
+ /** `new Alpha.Beta()` -> `Alpha.Beta()` */
1335
+ get previousInChain() {
1336
+ return this.call;
1337
+ }
1282
1338
  transpile(state) {
1283
1339
  var _a;
1284
1340
  const namespace = this.findAncestor(reflection_1.isNamespaceStatement);
@@ -1330,6 +1386,10 @@ class CallfuncExpression extends AstNode_1.Expression {
1330
1386
  this.args = (_a = options.args) !== null && _a !== void 0 ? _a : [];
1331
1387
  this.location = util_1.default.createBoundingLocation(this.callee, this.tokens.operator, this.tokens.methodName, this.tokens.openingParen, ...(_b = this.args) !== null && _b !== void 0 ? _b : [], this.tokens.closingParen);
1332
1388
  }
1389
+ /** `a@.b()` -> `a` (not the args) */
1390
+ get previousInChain() {
1391
+ return this.callee;
1392
+ }
1333
1393
  transpile(state) {
1334
1394
  var _a;
1335
1395
  let result = [];
@@ -1839,6 +1899,7 @@ class TypeExpression extends AstNode_1.Expression {
1839
1899
  super();
1840
1900
  this.kind = AstNode_1.AstNodeKind.TypeExpression;
1841
1901
  this.expression = options.expression;
1902
+ this.resolvedType = options.resolvedType;
1842
1903
  this.location = util_1.default.cloneLocation((_a = this.expression) === null || _a === void 0 ? void 0 : _a.location);
1843
1904
  }
1844
1905
  transpile(state) {
@@ -1861,15 +1922,31 @@ class TypeExpression extends AstNode_1.Expression {
1861
1922
  }
1862
1923
  }
1863
1924
  getType(options) {
1864
- return this.expression.getType(Object.assign(Object.assign({}, options), { flags: 2 /* SymbolTypeFlag.typetime */ }));
1925
+ var _a;
1926
+ return (_a = this.resolvedType) !== null && _a !== void 0 ? _a : this.expression.getType(Object.assign(Object.assign({}, options), { flags: 2 /* SymbolTypeFlag.typetime */ }));
1865
1927
  }
1866
1928
  getTypedef(state) {
1929
+ // classes and enums always know their own fully-namespace-qualified name, regardless
1930
+ // of how they were referenced in source (bare same-namespace shorthand, fully-qualified,
1931
+ // etc.) - use that instead of the raw written text, which would otherwise be flattened
1932
+ // to the type's compiled runtime symbol name (e.g. `Namespace_Type`) for class references
1933
+ const exprType = this.getType({ flags: 2 /* SymbolTypeFlag.typetime */ });
1934
+ if ((0, reflection_1.isClassType)(exprType) || (0, reflection_1.isEnumType)(exprType)) {
1935
+ return [exprType.toString()];
1936
+ }
1867
1937
  // TypeDefs should pass through any valid type names
1868
- return this.expression.transpile(state);
1938
+ return this.expression.getTypedef
1939
+ ? this.expression.getTypedef(state)
1940
+ : this.expression.transpile(state);
1869
1941
  }
1870
1942
  getName(parseMode = Parser_1.ParseMode.BrighterScript) {
1871
- //TODO: this may not support Complex Types, eg. generics or Unions
1872
- return util_1.default.getAllDottedGetPartsAsString(this.expression, parseMode);
1943
+ const dottedName = util_1.default.getAllDottedGetPartsAsString(this.expression, parseMode);
1944
+ if (dottedName !== undefined) {
1945
+ return dottedName;
1946
+ }
1947
+ //complex types (unions/intersections, inline interfaces, typed arrays, typed function
1948
+ //types, groupings) aren't dotted-get chains, so reconstruct their written name instead
1949
+ return util_1.default.getTypeExpressionName(this.expression, parseMode);
1873
1950
  }
1874
1951
  getNameParts() {
1875
1952
  //TODO: really, this code is only used to get Namespaces. It could be more clear.
@@ -1878,7 +1955,8 @@ class TypeExpression extends AstNode_1.Expression {
1878
1955
  clone() {
1879
1956
  var _a;
1880
1957
  return this.finalizeClone(new TypeExpression({
1881
- expression: (_a = this.expression) === null || _a === void 0 ? void 0 : _a.clone()
1958
+ expression: (_a = this.expression) === null || _a === void 0 ? void 0 : _a.clone(),
1959
+ resolvedType: this.resolvedType
1882
1960
  }), ['expression']);
1883
1961
  }
1884
1962
  }
@@ -2069,6 +2147,11 @@ class TypedFunctionTypeExpression extends AstNode_1.Expression {
2069
2147
  transpile(state) {
2070
2148
  return [this.getType({ flags: 2 /* SymbolTypeFlag.typetime */ }).toTypeString()];
2071
2149
  }
2150
+ getTypedef(state) {
2151
+ //preserve the full signature (param names/types, return type) in typedefs,
2152
+ //rather than the generic runtime type name used by `transpile()`
2153
+ return [this.getType({ flags: 2 /* SymbolTypeFlag.typetime */ }).toString()];
2154
+ }
2072
2155
  walk(visitor, options) {
2073
2156
  if (options.walkMode & visitors_2.InternalWalkMode.walkExpressions) {
2074
2157
  (0, visitors_2.walkArray)(this.params, visitor, options, this);