brighterscript 1.0.0-alpha.28 → 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 (68) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/AstValidationSegmenter.d.ts +11 -1
  3. package/dist/AstValidationSegmenter.js +72 -14
  4. package/dist/AstValidationSegmenter.js.map +1 -1
  5. package/dist/DependencyGraph.d.ts +4 -0
  6. package/dist/DependencyGraph.js +19 -0
  7. package/dist/DependencyGraph.js.map +1 -1
  8. package/dist/Program.d.ts +18 -14
  9. package/dist/Program.js +143 -82
  10. package/dist/Program.js.map +1 -1
  11. package/dist/Scope.d.ts +22 -2
  12. package/dist/Scope.js +162 -91
  13. package/dist/Scope.js.map +1 -1
  14. package/dist/Stopwatch.d.ts +4 -0
  15. package/dist/Stopwatch.js +7 -0
  16. package/dist/Stopwatch.js.map +1 -1
  17. package/dist/SymbolTable.d.ts +1 -0
  18. package/dist/SymbolTable.js +26 -0
  19. package/dist/SymbolTable.js.map +1 -1
  20. package/dist/astUtils/reflection.d.ts +3 -2
  21. package/dist/astUtils/reflection.js +8 -3
  22. package/dist/astUtils/reflection.js.map +1 -1
  23. package/dist/bscPlugin/BscPlugin.d.ts +2 -1
  24. package/dist/bscPlugin/BscPlugin.js +6 -0
  25. package/dist/bscPlugin/BscPlugin.js.map +1 -1
  26. package/dist/bscPlugin/completions/CompletionsProcessor.js +5 -2
  27. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
  28. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js +1 -1
  29. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -1
  30. package/dist/bscPlugin/validation/BrsFileAfterValidatior.d.ts +7 -0
  31. package/dist/bscPlugin/validation/BrsFileAfterValidatior.js +18 -0
  32. package/dist/bscPlugin/validation/BrsFileAfterValidatior.js.map +1 -0
  33. package/dist/bscPlugin/validation/BrsFileValidator.d.ts +1 -0
  34. package/dist/bscPlugin/validation/BrsFileValidator.js +16 -4
  35. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
  36. package/dist/bscPlugin/validation/ScopeValidator.d.ts +11 -2
  37. package/dist/bscPlugin/validation/ScopeValidator.js +114 -63
  38. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
  39. package/dist/bscPlugin/validation/ScopeValidator.spec.js +2 -1
  40. package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -1
  41. package/dist/files/BrsFile.d.ts +11 -3
  42. package/dist/files/BrsFile.js +125 -13
  43. package/dist/files/BrsFile.js.map +1 -1
  44. package/dist/files/BrsFile.spec.js +216 -91
  45. package/dist/files/BrsFile.spec.js.map +1 -1
  46. package/dist/files/BscFile.d.ts +2 -1
  47. package/dist/files/BscFile.js.map +1 -1
  48. package/dist/files/XmlFile.d.ts +2 -2
  49. package/dist/files/XmlFile.js +1 -1
  50. package/dist/files/XmlFile.js.map +1 -1
  51. package/dist/interfaces.d.ts +2 -1
  52. package/dist/interfaces.js.map +1 -1
  53. package/dist/parser/Expression.d.ts +6 -0
  54. package/dist/parser/Expression.js +7 -1
  55. package/dist/parser/Expression.js.map +1 -1
  56. package/dist/parser/Parser.js +0 -3
  57. package/dist/parser/Parser.js.map +1 -1
  58. package/dist/parser/TranspileState.js +3 -2
  59. package/dist/parser/TranspileState.js.map +1 -1
  60. package/dist/types/ReferenceType.d.ts +8 -0
  61. package/dist/types/ReferenceType.js +45 -1
  62. package/dist/types/ReferenceType.js.map +1 -1
  63. package/dist/types/ReferenceType.spec.js +15 -0
  64. package/dist/types/ReferenceType.spec.js.map +1 -1
  65. package/dist/util.d.ts +5 -1
  66. package/dist/util.js +19 -3
  67. package/dist/util.js.map +1 -1
  68. package/package.json +1 -1
@@ -24,6 +24,7 @@ const undent_1 = require("undent");
24
24
  const testHelpers_spec_2 = require("../testHelpers.spec");
25
25
  const types_1 = require("../types");
26
26
  const fileUrl = require("file-url");
27
+ const reflection_1 = require("../astUtils/reflection");
27
28
  let sinon = sinonImport.createSandbox();
28
29
  describe('BrsFile', () => {
29
30
  let program;
@@ -32,6 +33,14 @@ describe('BrsFile', () => {
32
33
  let file;
33
34
  let testTranspile = (0, testHelpers_spec_1.getTestTranspile)(() => [program, testHelpers_spec_2.rootDir]);
34
35
  let testGetTypedef = (0, testHelpers_spec_1.getTestGetTypedef)(() => [program, testHelpers_spec_2.rootDir]);
36
+ function validateFile(...files) {
37
+ for (const file of files) {
38
+ program.plugins.emit('onFileValidate', { program: program, file: file });
39
+ }
40
+ for (const file of files) {
41
+ program.plugins.emit('afterFileValidate', { program: program, file: file });
42
+ }
43
+ }
35
44
  beforeEach(() => {
36
45
  fsExtra.emptyDirSync(testHelpers_spec_2.tempDir);
37
46
  program = new Program_1.Program({ rootDir: testHelpers_spec_2.rootDir, sourceMap: true });
@@ -1512,6 +1521,21 @@ describe('BrsFile', () => {
1512
1521
  //this test will throw an exception if something went wrong
1513
1522
  });
1514
1523
  describe('transpile', () => {
1524
+ it('does not crash when AA is missing closing curly token', async () => {
1525
+ const file = program.setFile('source/main.bs', `
1526
+ sub main()
1527
+ aa = {}
1528
+ end sub
1529
+ `);
1530
+ //delete the ending token `}`
1531
+ const aa = file.ast.findChild(reflection_1.isAALiteralExpression);
1532
+ delete aa.tokens.close;
1533
+ await testTranspile(file, `
1534
+ sub main()
1535
+ aa = {}
1536
+ end sub
1537
+ `, undefined, undefined, false);
1538
+ });
1515
1539
  describe('null tokens', () => {
1516
1540
  it('succeeds when token locations are omitted', () => {
1517
1541
  doTest(`
@@ -3384,11 +3408,7 @@ describe('BrsFile', () => {
3384
3408
  return arg.getTwo()
3385
3409
  end function
3386
3410
  `);
3387
- const validateFileEvent = {
3388
- program: program,
3389
- file: mainFile
3390
- };
3391
- program.plugins.emit('onFileValidate', validateFileEvent);
3411
+ validateFile(mainFile);
3392
3412
  (0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(2);
3393
3413
  (0, chai_config_spec_1.expect)(mainFile.requiredSymbols.map(x => x.typeChain[0].name)).to.have.same.members([
3394
3414
  'TwoType', 'OneType'
@@ -3426,11 +3446,7 @@ describe('BrsFile', () => {
3426
3446
  end function
3427
3447
  end class
3428
3448
  `);
3429
- const validateFileEvent = {
3430
- program: program,
3431
- file: mainFile
3432
- };
3433
- program.plugins.emit('onFileValidate', validateFileEvent);
3449
+ validateFile(mainFile);
3434
3450
  (0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(2);
3435
3451
  (0, chai_config_spec_1.expect)(mainFile.requiredSymbols.map(x => x.typeChain[0].name)).to.have.same.members([
3436
3452
  'TwoType', 'OneType'
@@ -3443,11 +3459,7 @@ describe('BrsFile', () => {
3443
3459
  print x+1
3444
3460
  end sub
3445
3461
  `);
3446
- const validateFileEvent = {
3447
- program: program,
3448
- file: mainFile
3449
- };
3450
- program.plugins.emit('onFileValidate', validateFileEvent);
3462
+ validateFile(mainFile);
3451
3463
  (0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(1);
3452
3464
  // x and arg are assigned.. they are not included in the required symbols
3453
3465
  (0, chai_config_spec_1.expect)(mainFile.requiredSymbols[0].typeChain[0].name).to.equal('SomeOtherType');
@@ -3466,11 +3478,7 @@ describe('BrsFile', () => {
3466
3478
  return y-otherFileFunc4()
3467
3479
  end function
3468
3480
  `);
3469
- const validateFileEvent = {
3470
- program: program,
3471
- file: mainFile
3472
- };
3473
- program.plugins.emit('onFileValidate', validateFileEvent);
3481
+ validateFile(mainFile);
3474
3482
  (0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(4);
3475
3483
  (0, chai_config_spec_1.expect)(mainFile.requiredSymbols.map(x => x.typeChain[0].name)).to.have.same.members([
3476
3484
  'otherFileFunc1', 'otherFileFunc2', 'otherFileFunc3', 'otherFileFunc4'
@@ -3483,11 +3491,7 @@ describe('BrsFile', () => {
3483
3491
  return other.getThing(x)
3484
3492
  end function
3485
3493
  `);
3486
- const validateFileEvent = {
3487
- program: program,
3488
- file: mainFile
3489
- };
3490
- program.plugins.emit('onFileValidate', validateFileEvent);
3494
+ validateFile(mainFile);
3491
3495
  (0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(3);
3492
3496
  const requiredTypeChains = mainFile.requiredSymbols.map(x => x.typeChain.map(tc => tc.name).join('.'));
3493
3497
  (0, chai_config_spec_1.expect)(requiredTypeChains).to.have.same.members([
@@ -3510,11 +3514,7 @@ describe('BrsFile', () => {
3510
3514
  end if
3511
3515
  end sub
3512
3516
  `);
3513
- const validateFileEvent = {
3514
- program: program,
3515
- file: mainFile
3516
- };
3517
- program.plugins.emit('onFileValidate', validateFileEvent);
3517
+ validateFile(mainFile);
3518
3518
  (0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(4);
3519
3519
  const requiredTypeChains = mainFile.requiredSymbols.map(x => x.typeChain.map(tc => tc.name).join('.'));
3520
3520
  (0, chai_config_spec_1.expect)(requiredTypeChains).to.have.same.members([
@@ -3540,11 +3540,7 @@ describe('BrsFile', () => {
3540
3540
  end function
3541
3541
  end class
3542
3542
  `);
3543
- const validateFileEvent = {
3544
- program: program,
3545
- file: mainFile
3546
- };
3547
- program.plugins.emit('onFileValidate', validateFileEvent);
3543
+ validateFile(mainFile);
3548
3544
  (0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(5);
3549
3545
  const requiredTypeChains = mainFile.requiredSymbols.map(x => x.typeChain.map(tc => tc.name).join('.'));
3550
3546
  (0, chai_config_spec_1.expect)(requiredTypeChains).to.have.same.members([
@@ -3573,11 +3569,7 @@ describe('BrsFile', () => {
3573
3569
  end namespace
3574
3570
  end namespace
3575
3571
  `);
3576
- const validateFileEvent = {
3577
- program: program,
3578
- file: mainFile
3579
- };
3580
- program.plugins.emit('onFileValidate', validateFileEvent);
3572
+ validateFile(mainFile);
3581
3573
  (0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(2);
3582
3574
  const requiredTypeChains = mainFile.requiredSymbols.map(x => x.typeChain.map(tc => tc.name).join('.'));
3583
3575
  (0, chai_config_spec_1.expect)(requiredTypeChains).to.have.same.members([
@@ -3598,7 +3590,7 @@ describe('BrsFile', () => {
3598
3590
  end namespace
3599
3591
  end namespace
3600
3592
  `);
3601
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
3593
+ validateFile(mainFile);
3602
3594
  (0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(0);
3603
3595
  });
3604
3596
  it('should put types from typecasts as typetime required', () => {
@@ -3607,10 +3599,104 @@ describe('BrsFile', () => {
3607
3599
  return (z as MyInterface).name
3608
3600
  end function
3609
3601
  `);
3610
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
3602
+ validateFile(mainFile);
3611
3603
  (0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(1);
3612
3604
  (0, chai_config_spec_1.expect)(mainFile.requiredSymbols[0].flags).to.eq(2 /* SymbolTypeFlag.typetime */);
3613
3605
  });
3606
+ it('should not include symbols in same namespace', () => {
3607
+ const mainFile = program.setFile('source/main.bs', `
3608
+ namespace alpha
3609
+ const PI = 3.14
3610
+ function area(r as float) as float
3611
+ return alpha.PI * r * r
3612
+ end function
3613
+ end namespace
3614
+ `);
3615
+ validateFile(mainFile);
3616
+ (0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(0);
3617
+ });
3618
+ it('should not include symbols in same namespace, but different statements', () => {
3619
+ const mainFile = program.setFile('source/main.bs', `
3620
+ namespace alpha
3621
+ function area(r as float) as float
3622
+ return alpha.PI * r * r
3623
+ end function
3624
+ end namespace
3625
+
3626
+ namespace alpha
3627
+ const PI = 3.14
3628
+ end namespace
3629
+ `);
3630
+ validateFile(mainFile);
3631
+ (0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(0);
3632
+ });
3633
+ it('should not include symbols in imported file', () => {
3634
+ const otherFile = program.setFile('source/other.bs', `
3635
+ namespace alpha
3636
+ const PI = 3.14
3637
+ end namespace
3638
+ `);
3639
+ const mainFile = program.setFile('source/main.bs', `
3640
+ import "pkg:/source/other.bs"
3641
+ namespace alpha
3642
+ function area(r as float) as float
3643
+ return alpha.PI * r * r
3644
+ end function
3645
+ end namespace
3646
+ `);
3647
+ validateFile(otherFile, mainFile);
3648
+ (0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(0);
3649
+ });
3650
+ it('should not include symbols in imported file of imported file', () => {
3651
+ const deepFile = program.setFile('source/deep.bs', `
3652
+ namespace alpha
3653
+ const SOME_VALUE = 2
3654
+ end namespace
3655
+ `);
3656
+ const otherFile = program.setFile('source/other.bs', `
3657
+ import "pkg:/source/deep.bs"
3658
+ namespace alpha
3659
+ const PI = 3.14
3660
+ end namespace
3661
+ `);
3662
+ const mainFile = program.setFile('source/main.bs', `
3663
+ import "pkg:/source/other.bs"
3664
+ namespace alpha
3665
+ function area(r as float) as float
3666
+ return alpha.PI * r * r * alpha.SOME_VALUE
3667
+ end function
3668
+ end namespace
3669
+ `);
3670
+ validateFile(otherFile, mainFile, deepFile);
3671
+ (0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(0);
3672
+ });
3673
+ it('should not have problems with circular references of imports', () => {
3674
+ const deepFile = program.setFile('source/deep.bs', `
3675
+ import "pkg:/source/main.bs"
3676
+ namespace alpha
3677
+ function getMyValue()
3678
+ return alpha.MY_VALUE
3679
+ end function
3680
+ end namespace
3681
+ `);
3682
+ const otherFile = program.setFile('source/other.bs', `
3683
+ import "pkg:/source/deep.bs"
3684
+ namespace alpha
3685
+ const PI = 3.14
3686
+ end namespace
3687
+ `);
3688
+ const mainFile = program.setFile('source/main.bs', `
3689
+ import "pkg:/source/other.bs"
3690
+ namespace alpha
3691
+ function area(r as float) as float
3692
+ return alpha.PI * r * r * alpha.getMyValue()
3693
+ end function
3694
+ const MY_VALUE = 2
3695
+ end namespace
3696
+ `);
3697
+ validateFile(otherFile, mainFile, deepFile);
3698
+ (0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(0);
3699
+ });
3614
3700
  });
3615
3701
  describe('providedSymbols', () => {
3616
3702
  it('includes functions defined in the file', () => {
@@ -3623,11 +3709,7 @@ describe('BrsFile', () => {
3623
3709
  return 2.3
3624
3710
  end function
3625
3711
  `);
3626
- const validateFileEvent = {
3627
- program: program,
3628
- file: mainFile
3629
- };
3630
- program.plugins.emit('onFileValidate', validateFileEvent);
3712
+ validateFile(mainFile);
3631
3713
  const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3632
3714
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
3633
3715
  const someFuncType = runtimeSymbols.get('somefunc').type;
@@ -3641,11 +3723,7 @@ describe('BrsFile', () => {
3641
3723
  return new OtherFileType()
3642
3724
  end function
3643
3725
  `);
3644
- const validateFileEvent = {
3645
- program: program,
3646
- file: mainFile
3647
- };
3648
- program.plugins.emit('onFileValidate', validateFileEvent);
3726
+ validateFile(mainFile);
3649
3727
  const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3650
3728
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
3651
3729
  const someFuncType = runtimeSymbols.get('somefunc').type;
@@ -3673,11 +3751,7 @@ describe('BrsFile', () => {
3673
3751
  propClass = new Klass2()
3674
3752
  end class
3675
3753
  `);
3676
- const validateFileEvent = {
3677
- program: program,
3678
- file: mainFile
3679
- };
3680
- program.plugins.emit('onFileValidate', validateFileEvent);
3754
+ validateFile(mainFile);
3681
3755
  const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3682
3756
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(3);
3683
3757
  (0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('klass').type, types_1.ClassType);
@@ -3704,11 +3778,7 @@ describe('BrsFile', () => {
3704
3778
  const MyConst = 3.14
3705
3779
  end namespace
3706
3780
  `);
3707
- const validateFileEvent = {
3708
- program: program,
3709
- file: mainFile
3710
- };
3711
- program.plugins.emit('onFileValidate', validateFileEvent);
3781
+ validateFile(mainFile);
3712
3782
  const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3713
3783
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
3714
3784
  (0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('myenum').type, types_1.EnumType);
@@ -3725,7 +3795,7 @@ describe('BrsFile', () => {
3725
3795
  print 1
3726
3796
  end sub
3727
3797
  `);
3728
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
3798
+ validateFile(mainFile);
3729
3799
  let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3730
3800
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
3731
3801
  mainFile = program.setFile('source/main.bs', `
@@ -3737,7 +3807,7 @@ describe('BrsFile', () => {
3737
3807
  print 2
3738
3808
  end sub
3739
3809
  `);
3740
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
3810
+ validateFile(mainFile);
3741
3811
  runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3742
3812
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
3743
3813
  let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
@@ -3754,7 +3824,7 @@ describe('BrsFile', () => {
3754
3824
  print 2
3755
3825
  end sub
3756
3826
  `);
3757
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
3827
+ validateFile(mainFile);
3758
3828
  let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3759
3829
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
3760
3830
  mainFile = program.setFile('source/main.bs', `
@@ -3762,7 +3832,7 @@ describe('BrsFile', () => {
3762
3832
  print 1
3763
3833
  end sub
3764
3834
  `);
3765
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
3835
+ validateFile(mainFile);
3766
3836
  runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3767
3837
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
3768
3838
  let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
@@ -3774,7 +3844,7 @@ describe('BrsFile', () => {
3774
3844
  namespace Alpha
3775
3845
  end namespace
3776
3846
  `);
3777
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
3847
+ validateFile(mainFile);
3778
3848
  let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3779
3849
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(0);
3780
3850
  mainFile = program.setFile('source/main.bs', `
@@ -3782,7 +3852,7 @@ describe('BrsFile', () => {
3782
3852
  const ABC = "abc"
3783
3853
  end namespace
3784
3854
  `);
3785
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
3855
+ validateFile(mainFile);
3786
3856
  runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3787
3857
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
3788
3858
  let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
@@ -3799,7 +3869,7 @@ describe('BrsFile', () => {
3799
3869
  const PI = 3.14
3800
3870
  end namespace
3801
3871
  `);
3802
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
3872
+ validateFile(mainFile);
3803
3873
  let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3804
3874
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
3805
3875
  mainFile = program.setFile('source/main.bs', `
@@ -3811,7 +3881,7 @@ describe('BrsFile', () => {
3811
3881
  const PI = 3.14159
3812
3882
  end namespace
3813
3883
  `);
3814
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
3884
+ validateFile(mainFile);
3815
3885
  runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3816
3886
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
3817
3887
  let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
@@ -3823,7 +3893,7 @@ describe('BrsFile', () => {
3823
3893
  return x
3824
3894
  end function
3825
3895
  `);
3826
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
3896
+ validateFile(mainFile);
3827
3897
  let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3828
3898
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
3829
3899
  mainFile = program.setFile('source/main.bs', `
@@ -3831,7 +3901,7 @@ describe('BrsFile', () => {
3831
3901
  return x+y
3832
3902
  end function
3833
3903
  `);
3834
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
3904
+ validateFile(mainFile);
3835
3905
  runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3836
3906
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
3837
3907
  let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
@@ -3847,7 +3917,7 @@ describe('BrsFile', () => {
3847
3917
  end function
3848
3918
  end class
3849
3919
  `);
3850
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
3920
+ validateFile(mainFile);
3851
3921
  let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3852
3922
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
3853
3923
  mainFile = program.setFile('source/main.bs', `
@@ -3858,7 +3928,7 @@ describe('BrsFile', () => {
3858
3928
  end function
3859
3929
  end class
3860
3930
  `);
3861
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
3931
+ validateFile(mainFile);
3862
3932
  runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3863
3933
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
3864
3934
  let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
@@ -3875,7 +3945,7 @@ describe('BrsFile', () => {
3875
3945
  function doStuff() as float
3876
3946
  end interface
3877
3947
  `);
3878
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
3948
+ validateFile(mainFile);
3879
3949
  let typetimeSymbols = mainFile.providedSymbols.symbolMap.get(2 /* SymbolTypeFlag.typetime */);
3880
3950
  (0, chai_config_spec_1.expect)(typetimeSymbols.size).to.eq(1);
3881
3951
  let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
@@ -3887,7 +3957,7 @@ describe('BrsFile', () => {
3887
3957
  function doStuff() as float
3888
3958
  end interface
3889
3959
  `);
3890
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
3960
+ validateFile(mainFile);
3891
3961
  typetimeSymbols = mainFile.providedSymbols.symbolMap.get(2 /* SymbolTypeFlag.typetime */);
3892
3962
  (0, chai_config_spec_1.expect)(typetimeSymbols.size).to.eq(1);
3893
3963
  let typeTimeChanges = mainFile.providedSymbols.changes.get(2 /* SymbolTypeFlag.typetime */);
@@ -3905,7 +3975,7 @@ describe('BrsFile', () => {
3905
3975
  west = 1
3906
3976
  end enum
3907
3977
  `);
3908
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
3978
+ validateFile(mainFile);
3909
3979
  let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3910
3980
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
3911
3981
  mainFile = program.setFile('source/main.bs', `
@@ -3916,7 +3986,7 @@ describe('BrsFile', () => {
3916
3986
  west = 4
3917
3987
  end enum
3918
3988
  `);
3919
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
3989
+ validateFile(mainFile);
3920
3990
  runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3921
3991
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
3922
3992
  let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
@@ -3947,7 +4017,7 @@ describe('BrsFile', () => {
3947
4017
  purple
3948
4018
  end enum
3949
4019
  `);
3950
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
4020
+ validateFile(mainFile);
3951
4021
  let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3952
4022
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(3);
3953
4023
  mainFile = program.setFile('source/main.bs', `
@@ -3970,7 +4040,7 @@ describe('BrsFile', () => {
3970
4040
  green
3971
4041
  end enum
3972
4042
  `);
3973
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
4043
+ validateFile(mainFile);
3974
4044
  runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3975
4045
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(3);
3976
4046
  let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
@@ -3987,7 +4057,7 @@ describe('BrsFile', () => {
3987
4057
  west = 4
3988
4058
  end enum
3989
4059
  `);
3990
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
4060
+ validateFile(mainFile);
3991
4061
  let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
3992
4062
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
3993
4063
  mainFile = program.setFile('source/main.bs', `
@@ -4011,7 +4081,7 @@ describe('BrsFile', () => {
4011
4081
  const PI = 3.14
4012
4082
  end namespace
4013
4083
  `);
4014
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
4084
+ validateFile(mainFile);
4015
4085
  let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
4016
4086
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
4017
4087
  mainFile = program.setFile('source/main.bs', `
@@ -4019,7 +4089,7 @@ describe('BrsFile', () => {
4019
4089
  const PI = "lemon chiffon"
4020
4090
  end namespace
4021
4091
  `);
4022
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
4092
+ validateFile(mainFile);
4023
4093
  runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
4024
4094
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
4025
4095
  let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
@@ -4039,7 +4109,7 @@ describe('BrsFile', () => {
4039
4109
  print myLabel.getChildren(0, -1)
4040
4110
  end sub
4041
4111
  `);
4042
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
4112
+ validateFile(mainFile);
4043
4113
  let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
4044
4114
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
4045
4115
  mainFile = program.setFile('source/main.bs', `
@@ -4054,7 +4124,7 @@ describe('BrsFile', () => {
4054
4124
  print myLabel.getChildren(0, -1)
4055
4125
  end sub
4056
4126
  `);
4057
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
4127
+ validateFile(mainFile);
4058
4128
  runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
4059
4129
  (0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
4060
4130
  let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
@@ -4069,10 +4139,10 @@ describe('BrsFile', () => {
4069
4139
  end class
4070
4140
  `;
4071
4141
  let mainFile = program.setFile('source/class.bs', classFileContent);
4072
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
4142
+ validateFile(mainFile);
4073
4143
  // No changes!
4074
4144
  mainFile = program.setFile('source/class.bs', classFileContent);
4075
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
4145
+ validateFile(mainFile);
4076
4146
  let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
4077
4147
  (0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
4078
4148
  });
@@ -4095,10 +4165,10 @@ describe('BrsFile', () => {
4095
4165
  end namespace
4096
4166
  `;
4097
4167
  let mainFile = program.setFile('source/class.bs', fileContent);
4098
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
4168
+ validateFile(mainFile);
4099
4169
  // No changes!
4100
4170
  mainFile = program.setFile('source/class.bs', fileContent);
4101
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
4171
+ validateFile(mainFile);
4102
4172
  let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
4103
4173
  (0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
4104
4174
  });
@@ -4119,10 +4189,29 @@ describe('BrsFile', () => {
4119
4189
  end namespace
4120
4190
  `;
4121
4191
  let mainFile = program.setFile('source/class.bs', fileContent);
4122
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
4192
+ validateFile(mainFile);
4123
4193
  // No changes!
4124
4194
  mainFile = program.setFile('source/class.bs', fileContent);
4125
- program.plugins.emit('onFileValidate', { program: program, file: mainFile });
4195
+ validateFile(mainFile);
4196
+ let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
4197
+ (0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
4198
+ });
4199
+ it('should not include namespaces in changes if no symbols in namespace changed', () => {
4200
+ const fileContent = `
4201
+ namespace Alpha.Beta
4202
+ const PI = 3.14
4203
+ end namespace
4204
+ `;
4205
+ const fileContentWithComment = `
4206
+ namespace Alpha.Beta
4207
+ const PI = 3.14 ' comment
4208
+ end namespace
4209
+ `;
4210
+ let mainFile = program.setFile('source/namespace.bs', fileContent);
4211
+ validateFile(mainFile);
4212
+ // Just added a comment!
4213
+ mainFile = program.setFile('source/namespace.bs', fileContentWithComment);
4214
+ validateFile(mainFile);
4126
4215
  let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
4127
4216
  (0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
4128
4217
  });
@@ -4221,6 +4310,42 @@ describe('BrsFile', () => {
4221
4310
  end sub
4222
4311
  `);
4223
4312
  });
4313
+ //fails at the specific length of statement including leading tabs and spaces
4314
+ it('allows long statements', () => {
4315
+ program.setFile('source/main.bs', `function request()\r\nhzzzzandleInterceptedScreenDataaaaaaaaaaainterceptedScreenData() 'bs:disable-line \r\nend function`);
4316
+ program.validate();
4317
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
4318
+ program.setFile('source/main.bs', `function request()\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\thandleInterceptedScreenDataaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(m._aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaainterceptedScreenData) 'bs:disable-line \r\nend function`);
4319
+ program.validate();
4320
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
4321
+ program.setFile('source/main.bs', `function request()\r\n\t\t\t\thandleInterceptedScreenData(m._aaaaaaainterceptedScreenData) 'bs:disable-line 1001\r\nend function`);
4322
+ program.validate();
4323
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
4324
+ });
4325
+ });
4326
+ it('allows up to 63 function params', () => {
4327
+ program.setFile('source/main.bs', `
4328
+ function test(p1 = 1, p2 = 2, p3 = 3, p4 = 4, p5 = 5, p6 = 6, p7 = 7, p8 = 8, p9 = 9, p10 = 10, p11 = 11, p12 = 12, p13 = 13, p14 = 14, p15 = 15, p16 = 16, p17 = 17, p18 = 18, p19 = 19, p20 = 20, p21 = 21, p22 = 22, p23 = 23, p24 = 24, p25 = 25, p26 = 26, p27 = 27, p28 = 28, p29 = 29, p30 = 30, p31 = 31, p32 = 32, p33 = 33, p34 = 34, p35 = 35, p36 = 36, p37 = 37, p38 = 38, p39 = 39, p40 = 40, p41 = 41, p42 = 42, p43 = 43, p44 = 44, p45 = 45, p46 = 46, p47 = 47, p48 = 48, p49 = 49, p50 = 50, p51 = 51, p52 = 52, p53 = 53, p54 = 54, p55 = 55, p56 = 56, p57 = 57, p58 = 58, p59 = 59, p60 = 60, p61 = 61, p62 = 62, p63 = 63)
4329
+ end function
4330
+ `);
4331
+ program.validate();
4332
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
4333
+ });
4334
+ it('flags functions having 64 parameters', () => {
4335
+ program.setFile('source/main.bs', `
4336
+ function test(p1 = 1, p2 = 2, p3 = 3, p4 = 4, p5 = 5, p6 = 6, p7 = 7, p8 = 8, p9 = 9, p10 = 10, p11 = 11, p12 = 12, p13 = 13, p14 = 14, p15 = 15, p16 = 16, p17 = 17, p18 = 18, p19 = 19, p20 = 20, p21 = 21, p22 = 22, p23 = 23, p24 = 24, p25 = 25, p26 = 26, p27 = 27, p28 = 28, p29 = 29, p30 = 30, p31 = 31, p32 = 32, p33 = 33, p34 = 34, p35 = 35, p36 = 36, p37 = 37, p38 = 38, p39 = 39, p40 = 40, p41 = 41, p42 = 42, p43 = 43, p44 = 44, p45 = 45, p46 = 46, p47 = 47, p48 = 48, p49 = 49, p50 = 50, p51 = 51, p52 = 52, p53 = 53, p54 = 54, p55 = 55, p56 = 56, p57 = 57, p58 = 58, p59 = 59, p60 = 60, p61 = 61, p62 = 62, p63 = 63, p64 = 64)
4337
+ end function
4338
+ `);
4339
+ program.validate();
4340
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.tooManyCallableParameters(64, 63)), { range: util_1.default.createRange(1, 638, 1, 641) })]);
4341
+ });
4342
+ it('flags functions having 65 parameters', () => {
4343
+ program.setFile('source/main.bs', `
4344
+ function test(p1 = 1, p2 = 2, p3 = 3, p4 = 4, p5 = 5, p6 = 6, p7 = 7, p8 = 8, p9 = 9, p10 = 10, p11 = 11, p12 = 12, p13 = 13, p14 = 14, p15 = 15, p16 = 16, p17 = 17, p18 = 18, p19 = 19, p20 = 20, p21 = 21, p22 = 22, p23 = 23, p24 = 24, p25 = 25, p26 = 26, p27 = 27, p28 = 28, p29 = 29, p30 = 30, p31 = 31, p32 = 32, p33 = 33, p34 = 34, p35 = 35, p36 = 36, p37 = 37, p38 = 38, p39 = 39, p40 = 40, p41 = 41, p42 = 42, p43 = 43, p44 = 44, p45 = 45, p46 = 46, p47 = 47, p48 = 48, p49 = 49, p50 = 50, p51 = 51, p52 = 52, p53 = 53, p54 = 54, p55 = 55, p56 = 56, p57 = 57, p58 = 58, p59 = 59, p60 = 60, p61 = 61, p62 = 62, p63 = 63, p64 = 64, p65 = 65)
4345
+ end function
4346
+ `);
4347
+ program.validate();
4348
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.tooManyCallableParameters(65, 63)), { range: util_1.default.createRange(1, 638, 1, 641) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.tooManyCallableParameters(65, 63)), { range: util_1.default.createRange(1, 648, 1, 651) })]);
4224
4349
  });
4225
4350
  });
4226
4351
  //# sourceMappingURL=BrsFile.spec.js.map