brighterscript 0.61.3 → 0.63.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.
- package/CHANGELOG.md +20 -0
- package/README.md +15 -1
- package/bsconfig.schema.json +10 -0
- package/dist/BsConfig.d.ts +4 -0
- package/dist/DiagnosticMessages.d.ts +6 -1
- package/dist/DiagnosticMessages.js +5 -0
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/DiagnosticSeverityAdjuster.d.ts +7 -0
- package/dist/DiagnosticSeverityAdjuster.js +38 -0
- package/dist/DiagnosticSeverityAdjuster.js.map +1 -0
- package/dist/Program.d.ts +1 -4
- package/dist/Program.js +7 -18
- package/dist/Program.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.js +2 -0
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.d.ts +4 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js +43 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ProgramValidator.d.ts +10 -0
- package/dist/bscPlugin/validation/ProgramValidator.js +32 -0
- package/dist/bscPlugin/validation/ProgramValidator.js.map +1 -0
- package/dist/files/tests/optionalChaning.spec.js +62 -0
- package/dist/files/tests/optionalChaning.spec.js.map +1 -1
- package/dist/parser/Expression.js +23 -26
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.js +7 -7
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Statement.d.ts +6 -5
- package/dist/parser/Statement.js +38 -65
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js +12 -12
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
- package/dist/parser/tests/statement/Function.spec.js +9 -0
- package/dist/parser/tests/statement/Function.spec.js.map +1 -1
- package/dist/util.js +5 -4
- package/dist/util.js.map +1 -1
- package/package.json +2 -2
|
@@ -295,7 +295,8 @@ export declare class DottedSetStatement extends Statement {
|
|
|
295
295
|
readonly obj: Expression;
|
|
296
296
|
readonly name: Identifier;
|
|
297
297
|
readonly value: Expression;
|
|
298
|
-
|
|
298
|
+
readonly dot?: Token;
|
|
299
|
+
constructor(obj: Expression, name: Identifier, value: Expression, dot?: Token);
|
|
299
300
|
readonly range: Range;
|
|
300
301
|
transpile(state: BrsTranspileState): TranspileResult;
|
|
301
302
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
@@ -394,7 +395,7 @@ export declare class InterfaceFieldStatement extends Statement implements Typede
|
|
|
394
395
|
type: BscType;
|
|
395
396
|
transpile(state: BrsTranspileState): TranspileResult;
|
|
396
397
|
constructor(nameToken: Identifier, asToken: Token, typeToken: Token, type: BscType);
|
|
397
|
-
|
|
398
|
+
range: Range;
|
|
398
399
|
tokens: {
|
|
399
400
|
name: Identifier;
|
|
400
401
|
as: Token;
|
|
@@ -550,7 +551,7 @@ export declare class TryCatchStatement extends Statement {
|
|
|
550
551
|
try: Token;
|
|
551
552
|
endTry?: Token;
|
|
552
553
|
}, tryBranch?: Block, catchStatement?: CatchStatement);
|
|
553
|
-
|
|
554
|
+
readonly range: Range;
|
|
554
555
|
transpile(state: BrsTranspileState): TranspileResult;
|
|
555
556
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
556
557
|
}
|
|
@@ -563,7 +564,7 @@ export declare class CatchStatement extends Statement {
|
|
|
563
564
|
constructor(tokens: {
|
|
564
565
|
catch: Token;
|
|
565
566
|
}, exceptionVariable?: Identifier, catchBranch?: Block);
|
|
566
|
-
|
|
567
|
+
range: Range;
|
|
567
568
|
transpile(state: BrsTranspileState): TranspileResult;
|
|
568
569
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
569
570
|
}
|
|
@@ -662,7 +663,7 @@ export declare class ContinueStatement extends Statement {
|
|
|
662
663
|
continue: Token;
|
|
663
664
|
loopType: Token;
|
|
664
665
|
});
|
|
665
|
-
|
|
666
|
+
range: Range;
|
|
666
667
|
transpile(state: BrsTranspileState): (string | SourceNode)[];
|
|
667
668
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
668
669
|
}
|
package/dist/parser/Statement.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.ContinueStatement = exports.ConstStatement = exports.EnumMemberStatement
|
|
|
4
4
|
const TokenKind_1 = require("../lexer/TokenKind");
|
|
5
5
|
const Expression_1 = require("./Expression");
|
|
6
6
|
const util_1 = require("../util");
|
|
7
|
-
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
8
7
|
const Parser_1 = require("./Parser");
|
|
9
8
|
const visitors_1 = require("../astUtils/visitors");
|
|
10
9
|
const reflection_1 = require("../astUtils/reflection");
|
|
@@ -39,8 +38,9 @@ class Body extends AstNode_1.Statement {
|
|
|
39
38
|
this.symbolTable = new SymbolTable_1.SymbolTable('Body', () => { var _a; return (_a = this.parent) === null || _a === void 0 ? void 0 : _a.getSymbolTable(); });
|
|
40
39
|
}
|
|
41
40
|
get range() {
|
|
42
|
-
var _a
|
|
43
|
-
|
|
41
|
+
var _a;
|
|
42
|
+
//this needs to be a getter because the body has its statements pushed to it after being constructed
|
|
43
|
+
return util_1.util.createBoundingRange(...((_a = this.statements) !== null && _a !== void 0 ? _a : []));
|
|
44
44
|
}
|
|
45
45
|
transpile(state) {
|
|
46
46
|
let result = [];
|
|
@@ -94,7 +94,7 @@ class AssignmentStatement extends AstNode_1.Statement {
|
|
|
94
94
|
this.equals = equals;
|
|
95
95
|
this.name = name;
|
|
96
96
|
this.value = value;
|
|
97
|
-
this.range = util_1.util.
|
|
97
|
+
this.range = util_1.util.createBoundingRange(name, equals, value);
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
100
|
* Get the name of the wrapping namespace (if it exists)
|
|
@@ -131,9 +131,7 @@ class Block extends AstNode_1.Statement {
|
|
|
131
131
|
super();
|
|
132
132
|
this.statements = statements;
|
|
133
133
|
this.startingRange = startingRange;
|
|
134
|
-
this.range = util_1.util.
|
|
135
|
-
? this.statements[this.statements.length - 1].range.end
|
|
136
|
-
: this.startingRange.start);
|
|
134
|
+
this.range = util_1.util.createBoundingRange({ range: this.startingRange }, ...(statements !== null && statements !== void 0 ? statements : []));
|
|
137
135
|
}
|
|
138
136
|
transpile(state) {
|
|
139
137
|
state.blockDepth++;
|
|
@@ -189,7 +187,7 @@ class CommentStatement extends AstNode_1.Statement {
|
|
|
189
187
|
this.comments = comments;
|
|
190
188
|
this.visitMode = visitors_1.InternalWalkMode.visitStatements | visitors_1.InternalWalkMode.visitExpressions;
|
|
191
189
|
if (((_a = this.comments) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
192
|
-
this.range = util_1.util.
|
|
190
|
+
this.range = util_1.util.createBoundingRange(...this.comments);
|
|
193
191
|
}
|
|
194
192
|
}
|
|
195
193
|
get text() {
|
|
@@ -303,14 +301,13 @@ class FunctionStatement extends AstNode_1.Statement {
|
|
|
303
301
|
exports.FunctionStatement = FunctionStatement;
|
|
304
302
|
class IfStatement extends AstNode_1.Statement {
|
|
305
303
|
constructor(tokens, condition, thenBranch, elseBranch, isInline) {
|
|
306
|
-
var _a, _b;
|
|
307
304
|
super();
|
|
308
305
|
this.tokens = tokens;
|
|
309
306
|
this.condition = condition;
|
|
310
307
|
this.thenBranch = thenBranch;
|
|
311
308
|
this.elseBranch = elseBranch;
|
|
312
309
|
this.isInline = isInline;
|
|
313
|
-
this.range = util_1.util.
|
|
310
|
+
this.range = util_1.util.createBoundingRange(tokens.if, condition, tokens.then, thenBranch, tokens.else, elseBranch, tokens.endIf);
|
|
314
311
|
}
|
|
315
312
|
transpile(state) {
|
|
316
313
|
let results = [];
|
|
@@ -393,7 +390,7 @@ class IncrementStatement extends AstNode_1.Statement {
|
|
|
393
390
|
super();
|
|
394
391
|
this.value = value;
|
|
395
392
|
this.operator = operator;
|
|
396
|
-
this.range = util_1.util.
|
|
393
|
+
this.range = util_1.util.createBoundingRange(value, operator);
|
|
397
394
|
}
|
|
398
395
|
transpile(state) {
|
|
399
396
|
return [
|
|
@@ -422,9 +419,7 @@ class PrintStatement extends AstNode_1.Statement {
|
|
|
422
419
|
super();
|
|
423
420
|
this.tokens = tokens;
|
|
424
421
|
this.expressions = expressions;
|
|
425
|
-
this.range = util_1.util.
|
|
426
|
-
? this.expressions[this.expressions.length - 1].range.end
|
|
427
|
-
: this.tokens.print.range.end);
|
|
422
|
+
this.range = util_1.util.createBoundingRange(tokens.print, ...(expressions !== null && expressions !== void 0 ? expressions : []));
|
|
428
423
|
}
|
|
429
424
|
transpile(state) {
|
|
430
425
|
var _a;
|
|
@@ -457,14 +452,13 @@ class PrintStatement extends AstNode_1.Statement {
|
|
|
457
452
|
exports.PrintStatement = PrintStatement;
|
|
458
453
|
class DimStatement extends AstNode_1.Statement {
|
|
459
454
|
constructor(dimToken, identifier, openingSquare, dimensions, closingSquare) {
|
|
460
|
-
var _a, _b, _c, _d;
|
|
461
455
|
super();
|
|
462
456
|
this.dimToken = dimToken;
|
|
463
457
|
this.identifier = identifier;
|
|
464
458
|
this.openingSquare = openingSquare;
|
|
465
459
|
this.dimensions = dimensions;
|
|
466
460
|
this.closingSquare = closingSquare;
|
|
467
|
-
this.range = util_1.util.
|
|
461
|
+
this.range = util_1.util.createBoundingRange(dimToken, identifier, openingSquare, ...(dimensions !== null && dimensions !== void 0 ? dimensions : []), closingSquare);
|
|
468
462
|
}
|
|
469
463
|
transpile(state) {
|
|
470
464
|
let result = [
|
|
@@ -494,7 +488,7 @@ class GotoStatement extends AstNode_1.Statement {
|
|
|
494
488
|
constructor(tokens) {
|
|
495
489
|
super();
|
|
496
490
|
this.tokens = tokens;
|
|
497
|
-
this.range = util_1.util.
|
|
491
|
+
this.range = util_1.util.createBoundingRange(tokens.goto, tokens.label);
|
|
498
492
|
}
|
|
499
493
|
transpile(state) {
|
|
500
494
|
return [
|
|
@@ -512,7 +506,7 @@ class LabelStatement extends AstNode_1.Statement {
|
|
|
512
506
|
constructor(tokens) {
|
|
513
507
|
super();
|
|
514
508
|
this.tokens = tokens;
|
|
515
|
-
this.range = util_1.util.
|
|
509
|
+
this.range = util_1.util.createBoundingRange(tokens.identifier, tokens.colon);
|
|
516
510
|
}
|
|
517
511
|
transpile(state) {
|
|
518
512
|
return [
|
|
@@ -527,11 +521,10 @@ class LabelStatement extends AstNode_1.Statement {
|
|
|
527
521
|
exports.LabelStatement = LabelStatement;
|
|
528
522
|
class ReturnStatement extends AstNode_1.Statement {
|
|
529
523
|
constructor(tokens, value) {
|
|
530
|
-
var _a;
|
|
531
524
|
super();
|
|
532
525
|
this.tokens = tokens;
|
|
533
526
|
this.value = value;
|
|
534
|
-
this.range = util_1.util.
|
|
527
|
+
this.range = util_1.util.createBoundingRange(tokens.return, value);
|
|
535
528
|
}
|
|
536
529
|
transpile(state) {
|
|
537
530
|
let result = [];
|
|
@@ -553,7 +546,7 @@ class EndStatement extends AstNode_1.Statement {
|
|
|
553
546
|
constructor(tokens) {
|
|
554
547
|
super();
|
|
555
548
|
this.tokens = tokens;
|
|
556
|
-
this.range =
|
|
549
|
+
this.range = tokens.end.range;
|
|
557
550
|
}
|
|
558
551
|
transpile(state) {
|
|
559
552
|
return [
|
|
@@ -567,9 +560,10 @@ class EndStatement extends AstNode_1.Statement {
|
|
|
567
560
|
exports.EndStatement = EndStatement;
|
|
568
561
|
class StopStatement extends AstNode_1.Statement {
|
|
569
562
|
constructor(tokens) {
|
|
563
|
+
var _a;
|
|
570
564
|
super();
|
|
571
565
|
this.tokens = tokens;
|
|
572
|
-
this.range =
|
|
566
|
+
this.range = (_a = tokens === null || tokens === void 0 ? void 0 : tokens.stop) === null || _a === void 0 ? void 0 : _a.range;
|
|
573
567
|
}
|
|
574
568
|
transpile(state) {
|
|
575
569
|
return [
|
|
@@ -583,7 +577,6 @@ class StopStatement extends AstNode_1.Statement {
|
|
|
583
577
|
exports.StopStatement = StopStatement;
|
|
584
578
|
class ForStatement extends AstNode_1.Statement {
|
|
585
579
|
constructor(forToken, counterDeclaration, toToken, finalValue, body, endForToken, stepToken, increment) {
|
|
586
|
-
var _a, _b;
|
|
587
580
|
super();
|
|
588
581
|
this.forToken = forToken;
|
|
589
582
|
this.counterDeclaration = counterDeclaration;
|
|
@@ -593,8 +586,7 @@ class ForStatement extends AstNode_1.Statement {
|
|
|
593
586
|
this.endForToken = endForToken;
|
|
594
587
|
this.stepToken = stepToken;
|
|
595
588
|
this.increment = increment;
|
|
596
|
-
|
|
597
|
-
this.range = util_1.util.createRangeFromPositions(this.forToken.range.start, lastRange.end);
|
|
589
|
+
this.range = util_1.util.createBoundingRange(forToken, counterDeclaration, toToken, finalValue, stepToken, increment, body, endForToken);
|
|
598
590
|
}
|
|
599
591
|
transpile(state) {
|
|
600
592
|
let result = [];
|
|
@@ -636,14 +628,12 @@ class ForStatement extends AstNode_1.Statement {
|
|
|
636
628
|
exports.ForStatement = ForStatement;
|
|
637
629
|
class ForEachStatement extends AstNode_1.Statement {
|
|
638
630
|
constructor(tokens, item, target, body) {
|
|
639
|
-
var _a, _b;
|
|
640
631
|
super();
|
|
641
632
|
this.tokens = tokens;
|
|
642
633
|
this.item = item;
|
|
643
634
|
this.target = target;
|
|
644
635
|
this.body = body;
|
|
645
|
-
|
|
646
|
-
this.range = util_1.util.createRangeFromPositions(this.tokens.forEach.range.start, lastRange.end);
|
|
636
|
+
this.range = util_1.util.createBoundingRange(tokens.forEach, item, tokens.in, target, body, tokens.endFor);
|
|
647
637
|
}
|
|
648
638
|
transpile(state) {
|
|
649
639
|
let result = [];
|
|
@@ -677,13 +667,11 @@ class ForEachStatement extends AstNode_1.Statement {
|
|
|
677
667
|
exports.ForEachStatement = ForEachStatement;
|
|
678
668
|
class WhileStatement extends AstNode_1.Statement {
|
|
679
669
|
constructor(tokens, condition, body) {
|
|
680
|
-
var _a, _b;
|
|
681
670
|
super();
|
|
682
671
|
this.tokens = tokens;
|
|
683
672
|
this.condition = condition;
|
|
684
673
|
this.body = body;
|
|
685
|
-
|
|
686
|
-
this.range = util_1.util.createRangeFromPositions(this.tokens.while.range.start, lastRange.end);
|
|
674
|
+
this.range = util_1.util.createBoundingRange(tokens.while, condition, body, tokens.endWhile);
|
|
687
675
|
}
|
|
688
676
|
transpile(state) {
|
|
689
677
|
let result = [];
|
|
@@ -712,12 +700,13 @@ class WhileStatement extends AstNode_1.Statement {
|
|
|
712
700
|
}
|
|
713
701
|
exports.WhileStatement = WhileStatement;
|
|
714
702
|
class DottedSetStatement extends AstNode_1.Statement {
|
|
715
|
-
constructor(obj, name, value) {
|
|
703
|
+
constructor(obj, name, value, dot) {
|
|
716
704
|
super();
|
|
717
705
|
this.obj = obj;
|
|
718
706
|
this.name = name;
|
|
719
707
|
this.value = value;
|
|
720
|
-
this.
|
|
708
|
+
this.dot = dot;
|
|
709
|
+
this.range = util_1.util.createBoundingRange(obj, dot, name, value);
|
|
721
710
|
}
|
|
722
711
|
transpile(state) {
|
|
723
712
|
var _a, _b;
|
|
@@ -729,7 +718,7 @@ class DottedSetStatement extends AstNode_1.Statement {
|
|
|
729
718
|
return [
|
|
730
719
|
//object
|
|
731
720
|
...this.obj.transpile(state),
|
|
732
|
-
'.',
|
|
721
|
+
this.dot ? state.tokenToSourceNode(this.dot) : '.',
|
|
733
722
|
//name
|
|
734
723
|
state.transpileToken(this.name),
|
|
735
724
|
' = ',
|
|
@@ -754,7 +743,7 @@ class IndexedSetStatement extends AstNode_1.Statement {
|
|
|
754
743
|
this.value = value;
|
|
755
744
|
this.openingSquare = openingSquare;
|
|
756
745
|
this.closingSquare = closingSquare;
|
|
757
|
-
this.range = util_1.util.
|
|
746
|
+
this.range = util_1.util.createBoundingRange(obj, openingSquare, index, closingSquare, value);
|
|
758
747
|
}
|
|
759
748
|
transpile(state) {
|
|
760
749
|
var _a, _b;
|
|
@@ -792,7 +781,7 @@ class LibraryStatement extends AstNode_1.Statement {
|
|
|
792
781
|
constructor(tokens) {
|
|
793
782
|
super();
|
|
794
783
|
this.tokens = tokens;
|
|
795
|
-
this.range = util_1.util.
|
|
784
|
+
this.range = util_1.util.createBoundingRange(this.tokens.library, this.tokens.filePath);
|
|
796
785
|
}
|
|
797
786
|
transpile(state) {
|
|
798
787
|
let result = [];
|
|
@@ -873,7 +862,7 @@ class ImportStatement extends AstNode_1.Statement {
|
|
|
873
862
|
super();
|
|
874
863
|
this.importToken = importToken;
|
|
875
864
|
this.filePathToken = filePathToken;
|
|
876
|
-
this.range = util_1.util.
|
|
865
|
+
this.range = util_1.util.createBoundingRange(importToken, filePathToken);
|
|
877
866
|
if (this.filePathToken) {
|
|
878
867
|
//remove quotes
|
|
879
868
|
this.filePath = this.filePathToken.text.replace(/"/g, '');
|
|
@@ -1025,14 +1014,11 @@ class InterfaceFieldStatement extends AstNode_1.Statement {
|
|
|
1025
1014
|
this.tokens.name = nameToken;
|
|
1026
1015
|
this.tokens.as = asToken;
|
|
1027
1016
|
this.tokens.type = typeToken;
|
|
1017
|
+
this.range = util_1.util.createBoundingRange(nameToken, asToken, typeToken);
|
|
1028
1018
|
}
|
|
1029
1019
|
transpile(state) {
|
|
1030
1020
|
throw new Error('Method not implemented.');
|
|
1031
1021
|
}
|
|
1032
|
-
get range() {
|
|
1033
|
-
var _a, _b;
|
|
1034
|
-
return util_1.util.createRangeFromPositions(this.tokens.name.range.start, ((_b = (_a = this.tokens.type) !== null && _a !== void 0 ? _a : this.tokens.as) !== null && _b !== void 0 ? _b : this.tokens.name).range.end);
|
|
1035
|
-
}
|
|
1036
1022
|
get name() {
|
|
1037
1023
|
return this.tokens.name.text;
|
|
1038
1024
|
}
|
|
@@ -1070,8 +1056,8 @@ class InterfaceMethodStatement extends AstNode_1.Statement {
|
|
|
1070
1056
|
throw new Error('Method not implemented.');
|
|
1071
1057
|
}
|
|
1072
1058
|
get range() {
|
|
1073
|
-
var _a
|
|
1074
|
-
return util_1.util.
|
|
1059
|
+
var _a;
|
|
1060
|
+
return util_1.util.createBoundingRange(this.tokens.functionType, this.tokens.name, this.tokens.leftParen, ...((_a = this.params) !== null && _a !== void 0 ? _a : []), this.tokens.rightParen, this.tokens.as, this.tokens.returnType);
|
|
1075
1061
|
}
|
|
1076
1062
|
walk(visitor, options) {
|
|
1077
1063
|
//nothing to walk
|
|
@@ -1130,7 +1116,7 @@ class ClassStatement extends AstNode_1.Statement {
|
|
|
1130
1116
|
this.memberMap[(_c = statement === null || statement === void 0 ? void 0 : statement.name) === null || _c === void 0 ? void 0 : _c.text.toLowerCase()] = statement;
|
|
1131
1117
|
}
|
|
1132
1118
|
}
|
|
1133
|
-
this.range = util_1.util.
|
|
1119
|
+
this.range = util_1.util.createBoundingRange(classKeyword, name, extendsKeyword, parentClassName, ...(body !== null && body !== void 0 ? body : []), end);
|
|
1134
1120
|
}
|
|
1135
1121
|
/**
|
|
1136
1122
|
* Get the name of the wrapping namespace (if it exists)
|
|
@@ -1405,7 +1391,6 @@ const accessModifiers = [
|
|
|
1405
1391
|
];
|
|
1406
1392
|
class MethodStatement extends FunctionStatement {
|
|
1407
1393
|
constructor(modifiers, name, func, override) {
|
|
1408
|
-
var _a;
|
|
1409
1394
|
super(name, func);
|
|
1410
1395
|
this.override = override;
|
|
1411
1396
|
this.modifiers = [];
|
|
@@ -1417,7 +1402,7 @@ class MethodStatement extends FunctionStatement {
|
|
|
1417
1402
|
this.modifiers.push(modifiers);
|
|
1418
1403
|
}
|
|
1419
1404
|
}
|
|
1420
|
-
this.range = util_1.util.
|
|
1405
|
+
this.range = util_1.util.createBoundingRange(...(this.modifiers), override, func);
|
|
1421
1406
|
}
|
|
1422
1407
|
get accessModifier() {
|
|
1423
1408
|
return this.modifiers.find(x => accessModifiers.includes(x.kind));
|
|
@@ -1550,7 +1535,6 @@ class ClassMethodStatement extends MethodStatement {
|
|
|
1550
1535
|
exports.ClassMethodStatement = ClassMethodStatement;
|
|
1551
1536
|
class FieldStatement extends AstNode_1.Statement {
|
|
1552
1537
|
constructor(accessModifier, name, as, type, equal, initialValue) {
|
|
1553
|
-
var _a, _b, _c, _d;
|
|
1554
1538
|
super();
|
|
1555
1539
|
this.accessModifier = accessModifier;
|
|
1556
1540
|
this.name = name;
|
|
@@ -1558,7 +1542,7 @@ class FieldStatement extends AstNode_1.Statement {
|
|
|
1558
1542
|
this.type = type;
|
|
1559
1543
|
this.equal = equal;
|
|
1560
1544
|
this.initialValue = initialValue;
|
|
1561
|
-
this.range = util_1.util.
|
|
1545
|
+
this.range = util_1.util.createBoundingRange(accessModifier, name, as, type, equal, initialValue);
|
|
1562
1546
|
}
|
|
1563
1547
|
/**
|
|
1564
1548
|
* Derive a ValueKind from the type token, or the initial value.
|
|
@@ -1612,10 +1596,7 @@ class TryCatchStatement extends AstNode_1.Statement {
|
|
|
1612
1596
|
this.tokens = tokens;
|
|
1613
1597
|
this.tryBranch = tryBranch;
|
|
1614
1598
|
this.catchStatement = catchStatement;
|
|
1615
|
-
|
|
1616
|
-
get range() {
|
|
1617
|
-
var _a, _b, _c;
|
|
1618
|
-
return util_1.util.createRangeFromPositions(this.tokens.try.range.start, ((_c = (_b = (_a = this.tokens.endTry) !== null && _a !== void 0 ? _a : this.catchStatement) !== null && _b !== void 0 ? _b : this.tryBranch) !== null && _c !== void 0 ? _c : this.tokens.try).range.end);
|
|
1599
|
+
this.range = util_1.util.createBoundingRange(tokens.try, tryBranch, catchStatement, tokens.endTry);
|
|
1619
1600
|
}
|
|
1620
1601
|
transpile(state) {
|
|
1621
1602
|
var _a, _b;
|
|
@@ -1644,10 +1625,7 @@ class CatchStatement extends AstNode_1.Statement {
|
|
|
1644
1625
|
this.tokens = tokens;
|
|
1645
1626
|
this.exceptionVariable = exceptionVariable;
|
|
1646
1627
|
this.catchBranch = catchBranch;
|
|
1647
|
-
|
|
1648
|
-
get range() {
|
|
1649
|
-
var _a, _b;
|
|
1650
|
-
return util_1.util.createRangeFromPositions(this.tokens.catch.range.start, ((_b = (_a = this.catchBranch) !== null && _a !== void 0 ? _a : this.exceptionVariable) !== null && _b !== void 0 ? _b : this.tokens.catch).range.end);
|
|
1628
|
+
this.range = util_1.util.createBoundingRange(tokens.catch, exceptionVariable, catchBranch);
|
|
1651
1629
|
}
|
|
1652
1630
|
transpile(state) {
|
|
1653
1631
|
var _a, _b, _c, _d;
|
|
@@ -1667,11 +1645,10 @@ class CatchStatement extends AstNode_1.Statement {
|
|
|
1667
1645
|
exports.CatchStatement = CatchStatement;
|
|
1668
1646
|
class ThrowStatement extends AstNode_1.Statement {
|
|
1669
1647
|
constructor(throwToken, expression) {
|
|
1670
|
-
var _a;
|
|
1671
1648
|
super();
|
|
1672
1649
|
this.throwToken = throwToken;
|
|
1673
1650
|
this.expression = expression;
|
|
1674
|
-
this.range = util_1.util.
|
|
1651
|
+
this.range = util_1.util.createBoundingRange(throwToken, expression);
|
|
1675
1652
|
}
|
|
1676
1653
|
transpile(state) {
|
|
1677
1654
|
const result = [
|
|
@@ -1704,8 +1681,7 @@ class EnumStatement extends AstNode_1.Statement {
|
|
|
1704
1681
|
this.body = (_a = this.body) !== null && _a !== void 0 ? _a : [];
|
|
1705
1682
|
}
|
|
1706
1683
|
get range() {
|
|
1707
|
-
|
|
1708
|
-
return util_1.util.createRangeFromPositions((_a = this.tokens.enum.range.start) !== null && _a !== void 0 ? _a : vscode_languageserver_1.Position.create(0, 0), ((_c = (_b = this.tokens.endEnum) !== null && _b !== void 0 ? _b : this.tokens.name) !== null && _c !== void 0 ? _c : this.tokens.enum).range.end);
|
|
1684
|
+
return util_1.util.createBoundingRange(this.tokens.enum, this.tokens.name, ...this.body, this.tokens.endEnum);
|
|
1709
1685
|
}
|
|
1710
1686
|
/**
|
|
1711
1687
|
* Get the name of the wrapping namespace (if it exists)
|
|
@@ -1833,8 +1809,7 @@ class EnumMemberStatement extends AstNode_1.Statement {
|
|
|
1833
1809
|
return this.tokens.name.text;
|
|
1834
1810
|
}
|
|
1835
1811
|
get range() {
|
|
1836
|
-
|
|
1837
|
-
return util_1.util.createRangeFromPositions((_c = ((_b = (_a = this.tokens.name) !== null && _a !== void 0 ? _a : this.tokens.equal) !== null && _b !== void 0 ? _b : this.value).range.start) !== null && _c !== void 0 ? _c : vscode_languageserver_1.Position.create(0, 0), ((_e = (_d = this.value) !== null && _d !== void 0 ? _d : this.tokens.equal) !== null && _e !== void 0 ? _e : this.tokens.name).range.end);
|
|
1812
|
+
return util_1.util.createBoundingRange(this.tokens.name, this.tokens.equal, this.value);
|
|
1838
1813
|
}
|
|
1839
1814
|
transpile(state) {
|
|
1840
1815
|
return [];
|
|
@@ -1915,9 +1890,7 @@ class ContinueStatement extends AstNode_1.Statement {
|
|
|
1915
1890
|
constructor(tokens) {
|
|
1916
1891
|
super();
|
|
1917
1892
|
this.tokens = tokens;
|
|
1918
|
-
|
|
1919
|
-
get range() {
|
|
1920
|
-
return this.tokens.continue.range;
|
|
1893
|
+
this.range = util_1.util.createBoundingRange(tokens.continue, tokens.loopType);
|
|
1921
1894
|
}
|
|
1922
1895
|
transpile(state) {
|
|
1923
1896
|
var _a, _b, _c, _d, _e;
|