brighterscript 1.0.0-alpha.26 → 1.0.0-alpha.28
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 +82 -5
- package/README.md +1 -1
- package/dist/AstValidationSegmenter.d.ts +1 -1
- package/dist/AstValidationSegmenter.js +4 -5
- package/dist/AstValidationSegmenter.js.map +1 -1
- package/dist/DiagnosticFilterer.d.ts +7 -4
- package/dist/DiagnosticFilterer.js +67 -37
- package/dist/DiagnosticFilterer.js.map +1 -1
- package/dist/DiagnosticMessages.d.ts +1 -3
- package/dist/DiagnosticMessages.js +5 -8
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/PluginInterface.js +1 -1
- package/dist/PluginInterface.js.map +1 -1
- package/dist/Program.d.ts +1 -1
- package/dist/Program.js +34 -31
- package/dist/Program.js.map +1 -1
- package/dist/Scope.d.ts +7 -34
- package/dist/Scope.js +45 -305
- package/dist/Scope.js.map +1 -1
- package/dist/SymbolTable.d.ts +1 -8
- package/dist/SymbolTable.js +1 -10
- package/dist/SymbolTable.js.map +1 -1
- package/dist/SymbolTypeFlag.d.ts +8 -0
- package/dist/SymbolTypeFlag.js +13 -0
- package/dist/SymbolTypeFlag.js.map +1 -0
- package/dist/XmlScope.d.ts +0 -8
- package/dist/XmlScope.js +6 -84
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/CachedLookups.d.ts +1 -2
- package/dist/astUtils/CachedLookups.js +4 -19
- package/dist/astUtils/CachedLookups.js.map +1 -1
- package/dist/astUtils/creators.d.ts +1 -0
- package/dist/astUtils/creators.js +48 -8
- package/dist/astUtils/creators.js.map +1 -1
- package/dist/astUtils/creators.spec.js +0 -10
- package/dist/astUtils/creators.spec.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +3 -2
- package/dist/astUtils/reflection.js +11 -7
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +11 -16
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +1 -2
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +1 -5
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +2 -1
- package/dist/bscPlugin/BscPlugin.js +4 -0
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/SignatureHelpUtil.js +4 -3
- package/dist/bscPlugin/SignatureHelpUtil.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +1 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.js +46 -29
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +39 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.d.ts +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.js +30 -10
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.spec.js +125 -7
- package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/references/ReferencesProvider.d.ts +12 -0
- package/dist/bscPlugin/references/ReferencesProvider.js +56 -0
- package/dist/bscPlugin/references/ReferencesProvider.js.map +1 -0
- package/dist/bscPlugin/references/ReferencesProvider.spec.d.ts +1 -0
- package/dist/bscPlugin/references/ReferencesProvider.spec.js +51 -0
- package/dist/bscPlugin/references/ReferencesProvider.spec.js.map +1 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +2 -3
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.js +25 -31
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +34 -1
- package/dist/bscPlugin/validation/ScopeValidator.js +435 -27
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.spec.js +178 -10
- package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -1
- package/dist/diagnosticUtils.d.ts +1 -1
- package/dist/files/BrsFile.Class.spec.js +15 -7
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +14 -5
- package/dist/files/BrsFile.js +83 -150
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +429 -162
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.d.ts +2 -3
- package/dist/files/XmlFile.js +1 -3
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +117 -85
- package/dist/interfaces.js +9 -9
- package/dist/interfaces.js.map +1 -1
- package/dist/lexer/Lexer.d.ts +9 -3
- package/dist/lexer/Lexer.js +36 -15
- package/dist/lexer/Lexer.js.map +1 -1
- package/dist/lexer/Lexer.spec.js +76 -38
- package/dist/lexer/Lexer.spec.js.map +1 -1
- package/dist/lexer/Token.js +1 -1
- package/dist/lexer/Token.js.map +1 -1
- package/dist/lexer/TokenKind.d.ts +1 -0
- package/dist/lexer/TokenKind.js +4 -1
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/parser/AstNode.d.ts +1 -2
- package/dist/parser/AstNode.js +0 -1
- package/dist/parser/AstNode.js.map +1 -1
- package/dist/parser/BrsTranspileState.d.ts +1 -1
- package/dist/parser/Expression.d.ts +153 -135
- package/dist/parser/Expression.js +204 -114
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +15 -16
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.d.ts +8 -4
- package/dist/parser/Parser.js +108 -149
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.js +48 -72
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/SGParser.js +49 -35
- package/dist/parser/SGParser.js.map +1 -1
- package/dist/parser/SGTypes.d.ts +36 -24
- package/dist/parser/SGTypes.js +31 -60
- package/dist/parser/SGTypes.js.map +1 -1
- package/dist/parser/Statement.d.ts +214 -207
- package/dist/parser/Statement.js +248 -169
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/Statement.spec.js +0 -13
- package/dist/parser/Statement.spec.js.map +1 -1
- package/dist/parser/TranspileState.d.ts +17 -8
- package/dist/parser/TranspileState.js +64 -6
- package/dist/parser/TranspileState.js.map +1 -1
- package/dist/parser/tests/Parser.spec.d.ts +1 -1
- package/dist/parser/tests/Parser.spec.js +1 -2
- package/dist/parser/tests/Parser.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/If.spec.js +1 -1
- package/dist/parser/tests/controlFlow/If.spec.js.map +1 -1
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +1 -3
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +44 -0
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js +6 -6
- package/dist/parser/tests/expression/TernaryExpression.spec.js +47 -0
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TypeExpression.spec.js +8 -9
- package/dist/parser/tests/expression/TypeExpression.spec.js.map +1 -1
- package/dist/parser/tests/statement/ConstStatement.spec.js +2 -2
- package/dist/parser/tests/statement/InterfaceStatement.spec.js +8 -1
- package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Misc.spec.js +25 -5
- package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
- package/dist/parser/tests/statement/TryCatch.spec.js +9 -2
- package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
- package/dist/preprocessor/Chunk.js +1 -2
- package/dist/preprocessor/Chunk.js.map +1 -1
- package/dist/preprocessor/PreprocessorParser.js +2 -1
- package/dist/preprocessor/PreprocessorParser.js.map +1 -1
- package/dist/roku-types/data.json +70 -52
- package/dist/roku-types/index.d.ts +43 -21
- package/dist/types/ArrayType.js +1 -2
- package/dist/types/ArrayType.js.map +1 -1
- package/dist/types/ArrayType.spec.js +7 -8
- package/dist/types/ArrayType.spec.js.map +1 -1
- package/dist/types/AssociativeArrayType.d.ts +3 -0
- package/dist/types/AssociativeArrayType.js +10 -2
- package/dist/types/AssociativeArrayType.js.map +1 -1
- package/dist/types/BscType.d.ts +1 -1
- package/dist/types/BscType.js +3 -3
- package/dist/types/BscType.js.map +1 -1
- package/dist/types/BuiltInInterfaceAdder.js +7 -8
- package/dist/types/BuiltInInterfaceAdder.js.map +1 -1
- package/dist/types/BuiltInInterfaceAdder.spec.js +31 -32
- package/dist/types/BuiltInInterfaceAdder.spec.js.map +1 -1
- package/dist/types/ClassType.spec.js +10 -11
- package/dist/types/ClassType.spec.js.map +1 -1
- package/dist/types/ComponentType.d.ts +2 -1
- package/dist/types/ComponentType.js.map +1 -1
- package/dist/types/EnumType.js +2 -3
- package/dist/types/EnumType.js.map +1 -1
- package/dist/types/InheritableType.js +3 -4
- package/dist/types/InheritableType.js.map +1 -1
- package/dist/types/InterfaceType.js +2 -3
- package/dist/types/InterfaceType.js.map +1 -1
- package/dist/types/InterfaceType.spec.js +3 -4
- package/dist/types/InterfaceType.spec.js.map +1 -1
- package/dist/types/ObjectType.js +1 -2
- package/dist/types/ObjectType.js.map +1 -1
- package/dist/types/ReferenceType.d.ts +1 -1
- package/dist/types/ReferenceType.spec.js +21 -22
- package/dist/types/ReferenceType.spec.js.map +1 -1
- package/dist/types/UnionType.js +3 -3
- package/dist/types/UnionType.js.map +1 -1
- package/dist/types/UnionType.spec.js +37 -38
- package/dist/types/UnionType.spec.js.map +1 -1
- package/dist/types/helper.spec.js +4 -5
- package/dist/types/helper.spec.js.map +1 -1
- package/dist/util.d.ts +21 -11
- package/dist/util.js +116 -37
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.d.ts +0 -9
- package/dist/validators/ClassValidator.js +3 -46
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +6 -3
|
@@ -12,7 +12,6 @@ const DiagnosticMessages_1 = require("../DiagnosticMessages");
|
|
|
12
12
|
const reflection_1 = require("../astUtils/reflection");
|
|
13
13
|
const testHelpers_spec_1 = require("../testHelpers.spec");
|
|
14
14
|
const visitors_1 = require("../astUtils/visitors");
|
|
15
|
-
const SymbolTable_1 = require("../SymbolTable");
|
|
16
15
|
const IntegerType_1 = require("../types/IntegerType");
|
|
17
16
|
const FloatType_1 = require("../types/FloatType");
|
|
18
17
|
const StringType_1 = require("../types/StringType");
|
|
@@ -518,17 +517,17 @@ describe('parser', () => {
|
|
|
518
517
|
});
|
|
519
518
|
});
|
|
520
519
|
describe('comments', () => {
|
|
521
|
-
it('
|
|
520
|
+
it('does not include comments', () => {
|
|
522
521
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
523
522
|
'line 1
|
|
524
523
|
'line 2
|
|
525
524
|
'line 3
|
|
526
525
|
`);
|
|
527
526
|
let { diagnostics, statements } = Parser_1.Parser.parse(tokens);
|
|
528
|
-
(0,
|
|
529
|
-
(0, chai_config_spec_1.expect)(statements
|
|
527
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(diagnostics);
|
|
528
|
+
(0, chai_config_spec_1.expect)(statements.length).to.equal(0);
|
|
530
529
|
});
|
|
531
|
-
it('does
|
|
530
|
+
it('does matter if comments separated by newlines', () => {
|
|
532
531
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
533
532
|
'line 1
|
|
534
533
|
|
|
@@ -537,11 +536,8 @@ describe('parser', () => {
|
|
|
537
536
|
'line 3
|
|
538
537
|
`);
|
|
539
538
|
let { diagnostics, statements } = Parser_1.Parser.parse(tokens);
|
|
540
|
-
(0,
|
|
541
|
-
(0, chai_config_spec_1.expect)(statements).to.be.lengthOf(
|
|
542
|
-
(0, chai_config_spec_1.expect)(statements[0].text).to.equal(`'line 1`);
|
|
543
|
-
(0, chai_config_spec_1.expect)(statements[1].text).to.equal(`'line 2`);
|
|
544
|
-
(0, chai_config_spec_1.expect)(statements[2].text).to.equal(`'line 3`);
|
|
539
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(diagnostics);
|
|
540
|
+
(0, chai_config_spec_1.expect)(statements).to.be.lengthOf(0);
|
|
545
541
|
});
|
|
546
542
|
it('works after print statement', () => {
|
|
547
543
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -550,10 +546,10 @@ describe('parser', () => {
|
|
|
550
546
|
end sub
|
|
551
547
|
`);
|
|
552
548
|
let { diagnostics, statements } = Parser_1.Parser.parse(tokens);
|
|
553
|
-
(0,
|
|
554
|
-
(0, chai_config_spec_1.expect)(statements[0].func.body.statements
|
|
549
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(diagnostics);
|
|
550
|
+
(0, chai_config_spec_1.expect)(statements[0].func.body.statements.length).to.equal(1);
|
|
555
551
|
});
|
|
556
|
-
it('declaration-level', () => {
|
|
552
|
+
it('declaration-level should be set as leading trivia', () => {
|
|
557
553
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
558
554
|
'comment 1
|
|
559
555
|
function a()
|
|
@@ -562,8 +558,7 @@ describe('parser', () => {
|
|
|
562
558
|
`);
|
|
563
559
|
let { diagnostics, statements } = Parser_1.Parser.parse(tokens);
|
|
564
560
|
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(0, 'Error count should be 0');
|
|
565
|
-
(0, chai_config_spec_1.expect)(statements[0].text).to.equal(`'comment 1`);
|
|
566
|
-
(0, chai_config_spec_1.expect)(statements[2].text).to.equal(`'comment 2`);
|
|
561
|
+
(0, chai_config_spec_1.expect)(statements[0].getLeadingTrivia()[2].text).to.equal(`'comment 1`);
|
|
567
562
|
});
|
|
568
563
|
it('works in aa literal as its own statement', () => {
|
|
569
564
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -582,9 +577,8 @@ describe('parser', () => {
|
|
|
582
577
|
DoSomething(name) 'comment 1
|
|
583
578
|
end sub
|
|
584
579
|
`);
|
|
585
|
-
let { diagnostics
|
|
580
|
+
let { diagnostics } = Parser_1.Parser.parse(tokens);
|
|
586
581
|
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(0, 'Should have zero diagnostics');
|
|
587
|
-
(0, chai_config_spec_1.expect)(statements[0].func.body.statements[2].text).to.equal(`'comment 1`);
|
|
588
582
|
});
|
|
589
583
|
it('function', () => {
|
|
590
584
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -596,10 +590,7 @@ describe('parser', () => {
|
|
|
596
590
|
`);
|
|
597
591
|
let { diagnostics, statements } = Parser_1.Parser.parse(tokens);
|
|
598
592
|
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(0, 'Should have zero diagnostics');
|
|
599
|
-
(0, chai_config_spec_1.expect)(statements[0].func.body.statements[0].
|
|
600
|
-
(0, chai_config_spec_1.expect)(statements[0].func.body.statements[1].text).to.equal(`'comment 2`);
|
|
601
|
-
(0, chai_config_spec_1.expect)(statements[0].func.body.statements[3].text).to.equal(`'comment 3`);
|
|
602
|
-
(0, chai_config_spec_1.expect)(statements[1].text).to.equal(`'comment 4`);
|
|
593
|
+
(0, chai_config_spec_1.expect)(statements[0].func.body.statements[0].getLeadingTrivia().filter(x => x.kind === TokenKind_1.TokenKind.Comment).map(x => x.text)).members([`'comment 1`, `'comment 2`]);
|
|
603
594
|
});
|
|
604
595
|
it('if statement`', () => {
|
|
605
596
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -625,19 +616,13 @@ describe('parser', () => {
|
|
|
625
616
|
if ((0, reflection_1.isFunctionStatement)(fnSmt)) {
|
|
626
617
|
let ifStmt = fnSmt.func.body.statements[0];
|
|
627
618
|
if ((0, reflection_1.isIfStatement)(ifStmt)) {
|
|
628
|
-
expectCommentWithText(ifStmt.thenBranch.statements[0], `'comment 1`);
|
|
629
|
-
expectCommentWithText(ifStmt.thenBranch.statements[1], `'comment 2`);
|
|
630
|
-
expectCommentWithText(ifStmt.thenBranch.statements[3], `'comment 3`);
|
|
619
|
+
expectCommentWithText(ifStmt.thenBranch.statements[0], `'comment 1\n'comment 2`);
|
|
631
620
|
let elseIfBranch = ifStmt.elseBranch;
|
|
632
621
|
if ((0, reflection_1.isIfStatement)(elseIfBranch)) {
|
|
633
|
-
expectCommentWithText(elseIfBranch.thenBranch.statements[0], `'comment 4`);
|
|
634
|
-
expectCommentWithText(elseIfBranch.thenBranch.statements[1], `'comment 5`);
|
|
635
|
-
expectCommentWithText(elseIfBranch.thenBranch.statements[3], `'comment 6`);
|
|
622
|
+
expectCommentWithText(elseIfBranch.thenBranch.statements[0], `'comment 4\n'comment 5`);
|
|
636
623
|
let elseBranch = elseIfBranch.elseBranch;
|
|
637
624
|
if ((0, reflection_1.isBlock)(elseBranch)) {
|
|
638
|
-
expectCommentWithText(elseBranch.statements[0], `'comment 7`);
|
|
639
|
-
expectCommentWithText(elseBranch.statements[1], `'comment 8`);
|
|
640
|
-
expectCommentWithText(elseBranch.statements[3], `'comment 9`);
|
|
625
|
+
expectCommentWithText(elseBranch.statements[0], `'comment 7\n'comment 8`);
|
|
641
626
|
}
|
|
642
627
|
else {
|
|
643
628
|
failStatementType(elseBranch, 'Block');
|
|
@@ -646,7 +631,6 @@ describe('parser', () => {
|
|
|
646
631
|
else {
|
|
647
632
|
failStatementType(elseIfBranch, 'If');
|
|
648
633
|
}
|
|
649
|
-
expectCommentWithText(fnSmt.func.body.statements[1], `'comment 10`);
|
|
650
634
|
}
|
|
651
635
|
else {
|
|
652
636
|
failStatementType(ifStmt, 'If');
|
|
@@ -669,10 +653,7 @@ describe('parser', () => {
|
|
|
669
653
|
let { diagnostics, statements } = Parser_1.Parser.parse(tokens);
|
|
670
654
|
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(0, 'Error count should be zero');
|
|
671
655
|
let stmt = statements[0].func.body.statements[0];
|
|
672
|
-
(
|
|
673
|
-
(0, chai_config_spec_1.expect)(stmt.body.statements[1].text).to.equal(`'comment 2`);
|
|
674
|
-
(0, chai_config_spec_1.expect)(stmt.body.statements[3].text).to.equal(`'comment 3`);
|
|
675
|
-
(0, chai_config_spec_1.expect)(statements[0].func.body.statements[1].text).to.equal(`'comment 4`);
|
|
656
|
+
expectCommentWithText(stmt.body.statements[0], `'comment 1\n'comment 2`);
|
|
676
657
|
});
|
|
677
658
|
it('for', () => {
|
|
678
659
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -687,10 +668,7 @@ describe('parser', () => {
|
|
|
687
668
|
let { diagnostics, statements } = Parser_1.Parser.parse(tokens);
|
|
688
669
|
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(0, 'Error count should be zero');
|
|
689
670
|
let stmt = statements[0].func.body.statements[0];
|
|
690
|
-
(
|
|
691
|
-
(0, chai_config_spec_1.expect)(stmt.body.statements[1].text).to.equal(`'comment 2`);
|
|
692
|
-
(0, chai_config_spec_1.expect)(stmt.body.statements[3].text).to.equal(`'comment 3`);
|
|
693
|
-
(0, chai_config_spec_1.expect)(statements[0].func.body.statements[1].text).to.equal(`'comment 4`);
|
|
671
|
+
expectCommentWithText(stmt.body.statements[0], `'comment 1\n'comment 2`);
|
|
694
672
|
});
|
|
695
673
|
it('for each', () => {
|
|
696
674
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -705,10 +683,7 @@ describe('parser', () => {
|
|
|
705
683
|
let { diagnostics, statements } = Parser_1.Parser.parse(tokens);
|
|
706
684
|
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(0, 'Error count should be zero');
|
|
707
685
|
let stmt = statements[0].func.body.statements[0];
|
|
708
|
-
(
|
|
709
|
-
(0, chai_config_spec_1.expect)(stmt.body.statements[1].text).to.equal(`'comment 2`);
|
|
710
|
-
(0, chai_config_spec_1.expect)(stmt.body.statements[3].text).to.equal(`'comment 3`);
|
|
711
|
-
(0, chai_config_spec_1.expect)(statements[0].func.body.statements[1].text).to.equal(`'comment 4`);
|
|
686
|
+
expectCommentWithText(stmt.body.statements[0], `'comment 1\n'comment 2`);
|
|
712
687
|
});
|
|
713
688
|
});
|
|
714
689
|
});
|
|
@@ -1181,7 +1156,7 @@ describe('parser', () => {
|
|
|
1181
1156
|
(0, chai_config_spec_1.expect)((0, reflection_1.isAssignmentStatement)(assignment)).to.be.true;
|
|
1182
1157
|
(0, chai_config_spec_1.expect)((0, reflection_1.isTypeCastExpression)(assignment.value)).to.be.true;
|
|
1183
1158
|
(0, chai_config_spec_1.expect)((0, reflection_1.isCallExpression)(assignment.value.obj)).to.be.true;
|
|
1184
|
-
(0, testHelpers_spec_1.expectTypeToBe)(assignment.getType({ flags:
|
|
1159
|
+
(0, testHelpers_spec_1.expectTypeToBe)(assignment.getType({ flags: 2 /* SymbolTypeFlag.typetime */ }), IntegerType_1.IntegerType);
|
|
1185
1160
|
});
|
|
1186
1161
|
it('allows type casts in the middle of expressions', () => {
|
|
1187
1162
|
var _a;
|
|
@@ -1205,7 +1180,7 @@ describe('parser', () => {
|
|
|
1205
1180
|
(0, chai_config_spec_1.expect)((0, reflection_1.isGroupingExpression)(assignment.value.callee.obj)).to.be.true;
|
|
1206
1181
|
(0, chai_config_spec_1.expect)((0, reflection_1.isTypeCastExpression)(assignment.value.callee.obj.expression)).to.be.true;
|
|
1207
1182
|
//grouping expression is an integer
|
|
1208
|
-
(0, testHelpers_spec_1.expectTypeToBe)(assignment.value.callee.obj.getType({ flags:
|
|
1183
|
+
(0, testHelpers_spec_1.expectTypeToBe)(assignment.value.callee.obj.getType({ flags: 2 /* SymbolTypeFlag.typetime */ }), IntegerType_1.IntegerType);
|
|
1209
1184
|
});
|
|
1210
1185
|
it('allows type casts in a function call', () => {
|
|
1211
1186
|
var _a;
|
|
@@ -1229,7 +1204,7 @@ describe('parser', () => {
|
|
|
1229
1204
|
(0, chai_config_spec_1.expect)((0, reflection_1.isTypeCastExpression)(fnCall.args[0])).to.be.true;
|
|
1230
1205
|
let arg = fnCall.args[0];
|
|
1231
1206
|
//argument type is float
|
|
1232
|
-
(0, testHelpers_spec_1.expectTypeToBe)(arg.getType({ flags:
|
|
1207
|
+
(0, testHelpers_spec_1.expectTypeToBe)(arg.getType({ flags: 2 /* SymbolTypeFlag.typetime */ }), FloatType_1.FloatType);
|
|
1233
1208
|
});
|
|
1234
1209
|
it('allows multiple type casts', () => {
|
|
1235
1210
|
var _a;
|
|
@@ -1246,7 +1221,7 @@ describe('parser', () => {
|
|
|
1246
1221
|
(0, chai_config_spec_1.expect)((0, reflection_1.isPrintStatement)(print)).to.be.true;
|
|
1247
1222
|
(0, chai_config_spec_1.expect)((0, reflection_1.isTypeCastExpression)(print.expressions[0])).to.be.true;
|
|
1248
1223
|
//argument type is float
|
|
1249
|
-
(0, testHelpers_spec_1.expectTypeToBe)(print.expressions[0].getType({ flags:
|
|
1224
|
+
(0, testHelpers_spec_1.expectTypeToBe)(print.expressions[0].getType({ flags: 2 /* SymbolTypeFlag.typetime */ }), StringType_1.StringType);
|
|
1250
1225
|
});
|
|
1251
1226
|
it('flags invalid type cast syntax - multiple as', () => {
|
|
1252
1227
|
var _a;
|
|
@@ -1331,7 +1306,7 @@ describe('parser', () => {
|
|
|
1331
1306
|
end sub
|
|
1332
1307
|
`, Parser_1.ParseMode.BrighterScript);
|
|
1333
1308
|
(0, testHelpers_spec_1.expectZeroDiagnostics)(diagnostics);
|
|
1334
|
-
const paramType = statements[0].func.parameters[0].getType({ flags:
|
|
1309
|
+
const paramType = statements[0].func.parameters[0].getType({ flags: 2 /* SymbolTypeFlag.typetime */ });
|
|
1335
1310
|
(0, testHelpers_spec_1.expectTypeToBe)(paramType, types_1.ArrayType);
|
|
1336
1311
|
(0, testHelpers_spec_1.expectTypeToBe)(paramType.defaultType, StringType_1.StringType);
|
|
1337
1312
|
});
|
|
@@ -1342,7 +1317,7 @@ describe('parser', () => {
|
|
|
1342
1317
|
end sub
|
|
1343
1318
|
`, Parser_1.ParseMode.BrighterScript);
|
|
1344
1319
|
(0, testHelpers_spec_1.expectZeroDiagnostics)(diagnostics);
|
|
1345
|
-
const paramType = statements[0].func.parameters[0].getType({ flags:
|
|
1320
|
+
const paramType = statements[0].func.parameters[0].getType({ flags: 2 /* SymbolTypeFlag.typetime */ });
|
|
1346
1321
|
(0, testHelpers_spec_1.expectTypeToBe)(paramType, types_1.ArrayType);
|
|
1347
1322
|
(0, testHelpers_spec_1.expectTypeToBe)(paramType.defaultType, types_1.ArrayType);
|
|
1348
1323
|
(0, testHelpers_spec_1.expectTypeToBe)(paramType.defaultType.defaultType, StringType_1.StringType);
|
|
@@ -1354,7 +1329,7 @@ describe('parser', () => {
|
|
|
1354
1329
|
end function
|
|
1355
1330
|
`, Parser_1.ParseMode.BrighterScript);
|
|
1356
1331
|
(0, testHelpers_spec_1.expectZeroDiagnostics)(diagnostics);
|
|
1357
|
-
const paramType = statements[0].func.returnTypeExpression.getType({ flags:
|
|
1332
|
+
const paramType = statements[0].func.returnTypeExpression.getType({ flags: 2 /* SymbolTypeFlag.typetime */ });
|
|
1358
1333
|
(0, testHelpers_spec_1.expectTypeToBe)(paramType, types_1.ArrayType);
|
|
1359
1334
|
(0, testHelpers_spec_1.expectTypeToBe)(paramType.defaultType, IntegerType_1.IntegerType);
|
|
1360
1335
|
});
|
|
@@ -1365,7 +1340,7 @@ describe('parser', () => {
|
|
|
1365
1340
|
end sub
|
|
1366
1341
|
`, Parser_1.ParseMode.BrighterScript);
|
|
1367
1342
|
(0, testHelpers_spec_1.expectZeroDiagnostics)(diagnostics);
|
|
1368
|
-
const paramType = statements[0].func.parameters[0].getType({ flags:
|
|
1343
|
+
const paramType = statements[0].func.parameters[0].getType({ flags: 2 /* SymbolTypeFlag.typetime */ });
|
|
1369
1344
|
(0, testHelpers_spec_1.expectTypeToBe)(paramType, types_1.UnionType);
|
|
1370
1345
|
(0, chai_config_spec_1.expect)(paramType.toString().includes('Array<string>')).to.be.true;
|
|
1371
1346
|
(0, chai_config_spec_1.expect)(paramType.toString().includes('Array<integer>')).to.be.true;
|
|
@@ -1408,9 +1383,9 @@ describe('parser', () => {
|
|
|
1408
1383
|
(0, chai_config_spec_1.expect)((0, reflection_1.isInterfaceStatement)(statements[0])).to.be.true;
|
|
1409
1384
|
const iface = statements[0];
|
|
1410
1385
|
iface.fields.forEach(f => (0, chai_config_spec_1.expect)(f.isOptional).to.be.true);
|
|
1411
|
-
const ifaceType = iface.getType({ flags:
|
|
1386
|
+
const ifaceType = iface.getType({ flags: 2 /* SymbolTypeFlag.typetime */ });
|
|
1412
1387
|
// eslint-disable-next-line no-bitwise
|
|
1413
|
-
ifaceType.getMemberTable().getAllSymbols(
|
|
1388
|
+
ifaceType.getMemberTable().getAllSymbols(1 /* SymbolTypeFlag.runtime */).forEach(sym => (0, chai_config_spec_1.expect)(sym.flags & 4 /* SymbolTypeFlag.optional */).to.eq(4 /* SymbolTypeFlag.optional */));
|
|
1414
1389
|
});
|
|
1415
1390
|
it('allows fields named optional', () => {
|
|
1416
1391
|
let { statements, diagnostics } = parse(`
|
|
@@ -1424,11 +1399,11 @@ describe('parser', () => {
|
|
|
1424
1399
|
(0, chai_config_spec_1.expect)((0, reflection_1.isInterfaceStatement)(statements[0])).to.be.true;
|
|
1425
1400
|
const iface = statements[0];
|
|
1426
1401
|
iface.fields.forEach(f => (0, chai_config_spec_1.expect)(f.isOptional).to.be.false);
|
|
1427
|
-
const ifaceType = iface.getType({ flags:
|
|
1428
|
-
const iFaceMembers = ifaceType.getMemberTable().getAllSymbols(
|
|
1402
|
+
const ifaceType = iface.getType({ flags: 2 /* SymbolTypeFlag.typetime */ });
|
|
1403
|
+
const iFaceMembers = ifaceType.getMemberTable().getAllSymbols(1 /* SymbolTypeFlag.runtime */);
|
|
1429
1404
|
(0, chai_config_spec_1.expect)(iFaceMembers.length).to.eq(2);
|
|
1430
1405
|
// eslint-disable-next-line no-bitwise
|
|
1431
|
-
iFaceMembers.forEach(sym => (0, chai_config_spec_1.expect)(sym.flags &
|
|
1406
|
+
iFaceMembers.forEach(sym => (0, chai_config_spec_1.expect)(sym.flags & 4 /* SymbolTypeFlag.optional */).to.eq(0));
|
|
1432
1407
|
});
|
|
1433
1408
|
it('allows fields named optional that are also optional', () => {
|
|
1434
1409
|
let { statements, diagnostics } = parse(`
|
|
@@ -1441,11 +1416,11 @@ describe('parser', () => {
|
|
|
1441
1416
|
(0, chai_config_spec_1.expect)((0, reflection_1.isInterfaceStatement)(statements[0])).to.be.true;
|
|
1442
1417
|
const iface = statements[0];
|
|
1443
1418
|
iface.fields.forEach(f => (0, chai_config_spec_1.expect)(f.isOptional).to.be.true);
|
|
1444
|
-
const ifaceType = iface.getType({ flags:
|
|
1445
|
-
const iFaceMembers = ifaceType.getMemberTable().getAllSymbols(
|
|
1419
|
+
const ifaceType = iface.getType({ flags: 2 /* SymbolTypeFlag.typetime */ });
|
|
1420
|
+
const iFaceMembers = ifaceType.getMemberTable().getAllSymbols(1 /* SymbolTypeFlag.runtime */);
|
|
1446
1421
|
(0, chai_config_spec_1.expect)(iFaceMembers.length).to.eq(1);
|
|
1447
1422
|
// eslint-disable-next-line no-bitwise
|
|
1448
|
-
iFaceMembers.forEach(sym => (0, chai_config_spec_1.expect)(sym.flags &
|
|
1423
|
+
iFaceMembers.forEach(sym => (0, chai_config_spec_1.expect)(sym.flags & 4 /* SymbolTypeFlag.optional */).to.eq(4 /* SymbolTypeFlag.optional */));
|
|
1449
1424
|
});
|
|
1450
1425
|
it('allows optional methods', () => {
|
|
1451
1426
|
let { statements, diagnostics } = parse(`
|
|
@@ -1460,9 +1435,9 @@ describe('parser', () => {
|
|
|
1460
1435
|
(0, chai_config_spec_1.expect)((0, reflection_1.isInterfaceStatement)(statements[0])).to.be.true;
|
|
1461
1436
|
const iface = statements[0];
|
|
1462
1437
|
iface.methods.forEach(m => (0, chai_config_spec_1.expect)(m.isOptional).to.equal(true));
|
|
1463
|
-
const ifaceType = iface.getType({ flags:
|
|
1438
|
+
const ifaceType = iface.getType({ flags: 2 /* SymbolTypeFlag.typetime */ });
|
|
1464
1439
|
// eslint-disable-next-line no-bitwise
|
|
1465
|
-
ifaceType.getMemberTable().getAllSymbols(
|
|
1440
|
+
ifaceType.getMemberTable().getAllSymbols(1 /* SymbolTypeFlag.runtime */).forEach(sym => (0, chai_config_spec_1.expect)(sym.flags & 4 /* SymbolTypeFlag.optional */).to.eq(4 /* SymbolTypeFlag.optional */));
|
|
1466
1441
|
});
|
|
1467
1442
|
it('allows fields named `as` that are also optional', () => {
|
|
1468
1443
|
let { statements, diagnostics } = parse(`
|
|
@@ -1475,11 +1450,11 @@ describe('parser', () => {
|
|
|
1475
1450
|
(0, chai_config_spec_1.expect)((0, reflection_1.isInterfaceStatement)(statements[0])).to.be.true;
|
|
1476
1451
|
const iface = statements[0];
|
|
1477
1452
|
iface.fields.forEach(f => (0, chai_config_spec_1.expect)(f.isOptional).to.be.true);
|
|
1478
|
-
const ifaceType = iface.getType({ flags:
|
|
1479
|
-
const iFaceMembers = ifaceType.getMemberTable().getAllSymbols(
|
|
1453
|
+
const ifaceType = iface.getType({ flags: 2 /* SymbolTypeFlag.typetime */ });
|
|
1454
|
+
const iFaceMembers = ifaceType.getMemberTable().getAllSymbols(1 /* SymbolTypeFlag.runtime */);
|
|
1480
1455
|
(0, chai_config_spec_1.expect)(iFaceMembers.length).to.eq(1);
|
|
1481
1456
|
// eslint-disable-next-line no-bitwise
|
|
1482
|
-
iFaceMembers.forEach(sym => (0, chai_config_spec_1.expect)(sym.flags &
|
|
1457
|
+
iFaceMembers.forEach(sym => (0, chai_config_spec_1.expect)(sym.flags & 4 /* SymbolTypeFlag.optional */).to.eq(4 /* SymbolTypeFlag.optional */));
|
|
1483
1458
|
});
|
|
1484
1459
|
it('allows fields named `as` that are also typed', () => {
|
|
1485
1460
|
let { statements, diagnostics } = parse(`
|
|
@@ -1492,11 +1467,11 @@ describe('parser', () => {
|
|
|
1492
1467
|
(0, chai_config_spec_1.expect)((0, reflection_1.isInterfaceStatement)(statements[0])).to.be.true;
|
|
1493
1468
|
const iface = statements[0];
|
|
1494
1469
|
iface.fields.forEach(f => (0, chai_config_spec_1.expect)(f.isOptional).to.be.true);
|
|
1495
|
-
const ifaceType = iface.getType({ flags:
|
|
1496
|
-
const iFaceMembers = ifaceType.getMemberTable().getAllSymbols(
|
|
1470
|
+
const ifaceType = iface.getType({ flags: 2 /* SymbolTypeFlag.typetime */ });
|
|
1471
|
+
const iFaceMembers = ifaceType.getMemberTable().getAllSymbols(1 /* SymbolTypeFlag.runtime */);
|
|
1497
1472
|
(0, chai_config_spec_1.expect)(iFaceMembers.length).to.eq(1);
|
|
1498
1473
|
// eslint-disable-next-line no-bitwise
|
|
1499
|
-
iFaceMembers.forEach(sym => (0, chai_config_spec_1.expect)(sym.flags &
|
|
1474
|
+
iFaceMembers.forEach(sym => (0, chai_config_spec_1.expect)(sym.flags & 4 /* SymbolTypeFlag.optional */).to.eq(4 /* SymbolTypeFlag.optional */));
|
|
1500
1475
|
});
|
|
1501
1476
|
it('allows fields named `optional` that are also typed', () => {
|
|
1502
1477
|
let { statements, diagnostics } = parse(`
|
|
@@ -1509,11 +1484,11 @@ describe('parser', () => {
|
|
|
1509
1484
|
(0, chai_config_spec_1.expect)((0, reflection_1.isInterfaceStatement)(statements[0])).to.be.true;
|
|
1510
1485
|
const iface = statements[0];
|
|
1511
1486
|
iface.fields.forEach(f => (0, chai_config_spec_1.expect)(f.isOptional).to.be.false);
|
|
1512
|
-
const ifaceType = iface.getType({ flags:
|
|
1513
|
-
const iFaceMembers = ifaceType.getMemberTable().getAllSymbols(
|
|
1487
|
+
const ifaceType = iface.getType({ flags: 2 /* SymbolTypeFlag.typetime */ });
|
|
1488
|
+
const iFaceMembers = ifaceType.getMemberTable().getAllSymbols(1 /* SymbolTypeFlag.runtime */);
|
|
1514
1489
|
(0, chai_config_spec_1.expect)(iFaceMembers.length).to.eq(1);
|
|
1515
1490
|
// eslint-disable-next-line no-bitwise
|
|
1516
|
-
iFaceMembers.forEach(sym => (0, chai_config_spec_1.expect)(sym.flags &
|
|
1491
|
+
iFaceMembers.forEach(sym => (0, chai_config_spec_1.expect)(sym.flags & 4 /* SymbolTypeFlag.optional */).to.eq(0));
|
|
1517
1492
|
});
|
|
1518
1493
|
});
|
|
1519
1494
|
describe('leadingTrivia', () => {
|
|
@@ -1753,8 +1728,9 @@ function rangeToArray(range) {
|
|
|
1753
1728
|
}
|
|
1754
1729
|
exports.rangeToArray = rangeToArray;
|
|
1755
1730
|
function expectCommentWithText(stat, text) {
|
|
1756
|
-
|
|
1757
|
-
|
|
1731
|
+
const trivia = stat.getLeadingTrivia();
|
|
1732
|
+
if (trivia) {
|
|
1733
|
+
(0, chai_config_spec_1.expect)(trivia.filter(tok => tok.kind === TokenKind_1.TokenKind.Comment).map(t => t.text).join('\n')).to.equal(text);
|
|
1758
1734
|
}
|
|
1759
1735
|
else {
|
|
1760
1736
|
failStatementType(stat, 'Comment');
|