brighterscript 1.0.0-alpha.23 → 1.0.0-alpha.24
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 +108 -1
- package/dist/DiagnosticMessages.d.ts +19 -3
- package/dist/DiagnosticMessages.js +23 -7
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/LanguageServer.js +74 -20
- package/dist/LanguageServer.js.map +1 -1
- package/dist/Program.d.ts +7 -5
- package/dist/Program.js +84 -49
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.js +2 -1
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +22 -15
- package/dist/Scope.js +108 -122
- package/dist/Scope.js.map +1 -1
- package/dist/SymbolTable.d.ts +17 -6
- package/dist/SymbolTable.js +38 -9
- package/dist/SymbolTable.js.map +1 -1
- package/dist/XmlScope.js +3 -2
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +5 -1
- package/dist/astUtils/reflection.js +15 -2
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +2 -1
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +3 -1
- package/dist/bscPlugin/BscPlugin.js +8 -0
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.d.ts +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +11 -5
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +75 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +6 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.js +53 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.d.ts +17 -0
- package/dist/bscPlugin/hover/HoverProcessor.js +190 -0
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.spec.d.ts +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.spec.js +195 -0
- package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +1 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +19 -8
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +84 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.d.ts +7 -1
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js +81 -22
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.d.ts +14 -1
- package/dist/bscPlugin/validation/BrsFileValidator.js +104 -27
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.d.ts +1 -0
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js +48 -0
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -0
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +24 -3
- package/dist/bscPlugin/validation/ScopeValidator.js +249 -48
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/cli.js +18 -10
- package/dist/cli.js.map +1 -1
- package/dist/files/BrsFile.Class.spec.js +51 -38
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +21 -10
- package/dist/files/BrsFile.js +158 -179
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +222 -126
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.d.ts +2 -2
- package/dist/files/XmlFile.js +1 -0
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/files/tests/imports.spec.js +1 -1
- package/dist/files/tests/imports.spec.js.map +1 -1
- package/dist/files/tests/optionalChaning.spec.js +20 -16
- package/dist/files/tests/optionalChaning.spec.js.map +1 -1
- package/dist/globalCallables.js +3 -0
- package/dist/globalCallables.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +65 -3
- package/dist/lexer/Lexer.spec.js +7 -0
- package/dist/lexer/Lexer.spec.js.map +1 -1
- package/dist/lexer/TokenKind.d.ts +1 -0
- package/dist/lexer/TokenKind.js +8 -3
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/parser/Expression.d.ts +12 -3
- package/dist/parser/Expression.js +16 -4
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +1 -1
- package/dist/parser/Parser.d.ts +10 -3
- package/dist/parser/Parser.js +107 -47
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.js +181 -108
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/Statement.d.ts +41 -7
- package/dist/parser/Statement.js +84 -11
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +73 -31
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js +148 -47
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.js +219 -37
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
- package/dist/parser/tests/statement/ConstStatement.spec.d.ts +1 -0
- package/dist/parser/tests/statement/ConstStatement.spec.js +213 -0
- package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -0
- package/dist/parser/tests/statement/Enum.spec.js +17 -2
- package/dist/parser/tests/statement/Enum.spec.js.map +1 -1
- package/dist/parser/tests/statement/PrintStatement.spec.js +72 -57
- package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
- package/dist/preprocessor/Manifest.js +2 -2
- package/dist/preprocessor/Manifest.js.map +1 -1
- package/dist/preprocessor/Preprocessor.js +10 -6
- package/dist/preprocessor/Preprocessor.js.map +1 -1
- package/dist/roku-types/data.json +1002 -788
- package/dist/roku-types/index.d.ts +64 -239
- package/dist/types/DynamicType.d.ts +1 -0
- package/dist/types/DynamicType.js +1 -0
- package/dist/types/DynamicType.js.map +1 -1
- package/dist/util.d.ts +55 -14
- package/dist/util.js +131 -25
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.d.ts +0 -1
- package/dist/validators/ClassValidator.js +15 -26
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +5 -2
|
@@ -22,10 +22,12 @@ const Logger_1 = require("../Logger");
|
|
|
22
22
|
const Statement_1 = require("../parser/Statement");
|
|
23
23
|
const creators_1 = require("../astUtils/creators");
|
|
24
24
|
const fsExtra = require("fs-extra");
|
|
25
|
+
const undent_1 = require("undent");
|
|
25
26
|
const ArrayType_1 = require("../types/ArrayType");
|
|
26
27
|
const FloatType_1 = require("../types/FloatType");
|
|
27
28
|
const ObjectType_1 = require("../types/ObjectType");
|
|
28
29
|
const VoidType_1 = require("../types/VoidType");
|
|
30
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
29
31
|
let sinon = sinonImport.createSandbox();
|
|
30
32
|
describe('BrsFile', () => {
|
|
31
33
|
let tempDir = (0, util_1.standardizePath) `${process.cwd()}/.tmp`;
|
|
@@ -613,6 +615,26 @@ describe('BrsFile', () => {
|
|
|
613
615
|
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
614
616
|
});
|
|
615
617
|
describe('conditional compile', () => {
|
|
618
|
+
it('supports case-insensitive bs_const variables', () => {
|
|
619
|
+
fsExtra.outputFileSync(`${rootDir}/manifest`, (0, undent_1.default) `
|
|
620
|
+
bs_const=SomeKey=true
|
|
621
|
+
`);
|
|
622
|
+
program.setFile('source/main.brs', `
|
|
623
|
+
sub something()
|
|
624
|
+
#if somekey
|
|
625
|
+
print "lower"
|
|
626
|
+
#end if
|
|
627
|
+
#if SOMEKEY
|
|
628
|
+
print "UPPER"
|
|
629
|
+
#end if
|
|
630
|
+
#if SomeKey
|
|
631
|
+
print "MiXeD"
|
|
632
|
+
#end if
|
|
633
|
+
end sub
|
|
634
|
+
`);
|
|
635
|
+
program.validate();
|
|
636
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
637
|
+
});
|
|
616
638
|
it('works for upper case keywords', () => {
|
|
617
639
|
let file = program.setFile({ src: `${rootDir} /source/main.brs`, dest: 'source/main.brs' }, `
|
|
618
640
|
sub main()
|
|
@@ -1360,7 +1382,7 @@ describe('BrsFile', () => {
|
|
|
1360
1382
|
`);
|
|
1361
1383
|
program.validate();
|
|
1362
1384
|
(0, testHelpers_spec_1.expectDiagnostics)(program, [
|
|
1363
|
-
DiagnosticMessages_1.DiagnosticMessages.
|
|
1385
|
+
DiagnosticMessages_1.DiagnosticMessages.cannotFindName('DoesNotExist')
|
|
1364
1386
|
]);
|
|
1365
1387
|
});
|
|
1366
1388
|
it('finds arguments with variable values', () => {
|
|
@@ -1506,6 +1528,32 @@ describe('BrsFile', () => {
|
|
|
1506
1528
|
]);
|
|
1507
1529
|
});
|
|
1508
1530
|
});
|
|
1531
|
+
it('handles mixed case `then` partions of conditionals', () => {
|
|
1532
|
+
let mainFile = program.setFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
1533
|
+
sub Main()
|
|
1534
|
+
if true then
|
|
1535
|
+
print "works"
|
|
1536
|
+
end if
|
|
1537
|
+
end sub
|
|
1538
|
+
`);
|
|
1539
|
+
(0, chai_1.expect)(mainFile.getDiagnostics()).to.be.lengthOf(0);
|
|
1540
|
+
mainFile = program.setFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
1541
|
+
sub Main()
|
|
1542
|
+
if true Then
|
|
1543
|
+
print "works"
|
|
1544
|
+
end if
|
|
1545
|
+
end sub
|
|
1546
|
+
`);
|
|
1547
|
+
(0, chai_1.expect)(mainFile.getDiagnostics()).to.be.lengthOf(0);
|
|
1548
|
+
mainFile = program.setFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
1549
|
+
sub Main()
|
|
1550
|
+
if true THEN
|
|
1551
|
+
print "works"
|
|
1552
|
+
end if
|
|
1553
|
+
end sub
|
|
1554
|
+
`);
|
|
1555
|
+
(0, chai_1.expect)(mainFile.getDiagnostics()).to.be.lengthOf(0);
|
|
1556
|
+
});
|
|
1509
1557
|
describe('getHover', () => {
|
|
1510
1558
|
it('works for param types', () => {
|
|
1511
1559
|
let file = program.setFile({ src: `${rootDir} /source/main.brs`, dest: 'source/main.brs' }, `
|
|
@@ -1516,11 +1564,11 @@ describe('BrsFile', () => {
|
|
|
1516
1564
|
end sub
|
|
1517
1565
|
`);
|
|
1518
1566
|
//hover over the `name = 1` line
|
|
1519
|
-
let hover =
|
|
1567
|
+
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(2, 24))[0];
|
|
1520
1568
|
(0, chai_1.expect)(hover).to.exist;
|
|
1521
1569
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(2, 20, 2, 24));
|
|
1522
1570
|
//hover over the `name` parameter declaration
|
|
1523
|
-
hover =
|
|
1571
|
+
hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(1, 34))[0];
|
|
1524
1572
|
(0, chai_1.expect)(hover).to.exist;
|
|
1525
1573
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(1, 32, 1, 36));
|
|
1526
1574
|
});
|
|
@@ -1532,10 +1580,10 @@ describe('BrsFile', () => {
|
|
|
1532
1580
|
sub as ()
|
|
1533
1581
|
end sub
|
|
1534
1582
|
`);
|
|
1535
|
-
//hover over the `as
|
|
1536
|
-
(0, chai_1.expect)(
|
|
1583
|
+
//hover over the `as`
|
|
1584
|
+
(0, chai_1.expect)(program.getHover(file.srcPath, vscode_languageserver_1.Position.create(1, 31))).to.be.empty;
|
|
1537
1585
|
//hover over the `string`
|
|
1538
|
-
(0, chai_1.expect)(
|
|
1586
|
+
(0, chai_1.expect)(program.getHover(file.srcPath, vscode_languageserver_1.Position.create(1, 36))).to.be.empty;
|
|
1539
1587
|
});
|
|
1540
1588
|
it('finds declared function', () => {
|
|
1541
1589
|
let file = program.setFile({ src: `${rootDir} /source/main.brs`, dest: 'source/main.brs' }, `
|
|
@@ -1545,7 +1593,7 @@ describe('BrsFile', () => {
|
|
|
1545
1593
|
shoeSize = 10
|
|
1546
1594
|
end function
|
|
1547
1595
|
`);
|
|
1548
|
-
let hover =
|
|
1596
|
+
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(1, 28))[0];
|
|
1549
1597
|
(0, chai_1.expect)(hover).to.exist;
|
|
1550
1598
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(1, 25, 1, 29));
|
|
1551
1599
|
(0, chai_1.expect)(hover.contents).to.equal([
|
|
@@ -1564,7 +1612,7 @@ describe('BrsFile', () => {
|
|
|
1564
1612
|
end function
|
|
1565
1613
|
end namespace
|
|
1566
1614
|
`);
|
|
1567
|
-
let hover =
|
|
1615
|
+
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(2, 28))[0];
|
|
1568
1616
|
(0, chai_1.expect)(hover).to.exist;
|
|
1569
1617
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(2, 25, 2, 29));
|
|
1570
1618
|
(0, chai_1.expect)(hover.contents).to.equal([
|
|
@@ -1582,7 +1630,7 @@ describe('BrsFile', () => {
|
|
|
1582
1630
|
sayMyName()
|
|
1583
1631
|
end sub
|
|
1584
1632
|
`);
|
|
1585
|
-
let hover =
|
|
1633
|
+
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(5, 24))[0];
|
|
1586
1634
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(5, 20, 5, 29));
|
|
1587
1635
|
(0, chai_1.expect)(hover.contents).to.equal([
|
|
1588
1636
|
'```brightscript',
|
|
@@ -1590,25 +1638,25 @@ describe('BrsFile', () => {
|
|
|
1590
1638
|
'```'
|
|
1591
1639
|
].join('\n'));
|
|
1592
1640
|
});
|
|
1593
|
-
it('does not crash when hovering on built-in functions',
|
|
1641
|
+
it('does not crash when hovering on built-in functions', () => {
|
|
1594
1642
|
let file = program.setFile('source/main.brs', `
|
|
1595
1643
|
function doUcase(text)
|
|
1596
1644
|
return ucase(text)
|
|
1597
1645
|
end function
|
|
1598
1646
|
`);
|
|
1599
|
-
(0, chai_1.expect)(
|
|
1647
|
+
(0, chai_1.expect)(program.getHover(file.srcPath, vscode_languageserver_1.Position.create(2, 30))[0].contents).to.equal([
|
|
1600
1648
|
'```brightscript',
|
|
1601
1649
|
'function UCase(s as string) as string',
|
|
1602
1650
|
'```'
|
|
1603
1651
|
].join('\n'));
|
|
1604
1652
|
});
|
|
1605
|
-
it('does not crash when hovering on object method call',
|
|
1653
|
+
it('does not crash when hovering on object method call', () => {
|
|
1606
1654
|
let file = program.setFile('source/main.brs', `
|
|
1607
1655
|
function getInstr(url, text)
|
|
1608
1656
|
return url.instr(text)
|
|
1609
1657
|
end function
|
|
1610
1658
|
`);
|
|
1611
|
-
(0, chai_1.expect)(
|
|
1659
|
+
(0, chai_1.expect)(program.getHover(file.srcPath, vscode_languageserver_1.Position.create(2, 35))[0].contents).to.equal([
|
|
1612
1660
|
'```brightscript',
|
|
1613
1661
|
'instr as dynamic',
|
|
1614
1662
|
'```'
|
|
@@ -1624,7 +1672,7 @@ describe('BrsFile', () => {
|
|
|
1624
1672
|
|
|
1625
1673
|
end sub
|
|
1626
1674
|
`);
|
|
1627
|
-
let hover =
|
|
1675
|
+
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(2, 25))[0];
|
|
1628
1676
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(2, 20, 2, 29));
|
|
1629
1677
|
(0, chai_1.expect)(hover.contents).to.equal([
|
|
1630
1678
|
'```brightscript',
|
|
@@ -1644,7 +1692,7 @@ describe('BrsFile', () => {
|
|
|
1644
1692
|
end sub
|
|
1645
1693
|
end namespace
|
|
1646
1694
|
`);
|
|
1647
|
-
let hover =
|
|
1695
|
+
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(3, 25))[0];
|
|
1648
1696
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(3, 20, 3, 29));
|
|
1649
1697
|
(0, chai_1.expect)(hover.contents).to.equal([
|
|
1650
1698
|
'```brightscript',
|
|
@@ -1667,7 +1715,7 @@ describe('BrsFile', () => {
|
|
|
1667
1715
|
|
|
1668
1716
|
end sub
|
|
1669
1717
|
`);
|
|
1670
|
-
let hover =
|
|
1718
|
+
let hover = program.getHover(mainFile.srcPath, vscode_languageserver_1.Position.create(2, 25))[0];
|
|
1671
1719
|
(0, chai_1.expect)(hover).to.exist;
|
|
1672
1720
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(2, 20, 2, 29));
|
|
1673
1721
|
(0, chai_1.expect)(hover.contents).to.equal([
|
|
@@ -1692,7 +1740,7 @@ describe('BrsFile', () => {
|
|
|
1692
1740
|
end sub
|
|
1693
1741
|
end namespace
|
|
1694
1742
|
`);
|
|
1695
|
-
let hover =
|
|
1743
|
+
let hover = program.getHover(mainFile.srcPath, vscode_languageserver_1.Position.create(2, 34))[0];
|
|
1696
1744
|
(0, chai_1.expect)(hover).to.exist;
|
|
1697
1745
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(2, 28, 2, 37));
|
|
1698
1746
|
(0, chai_1.expect)(hover.contents).to.equal([
|
|
@@ -1701,7 +1749,7 @@ describe('BrsFile', () => {
|
|
|
1701
1749
|
'```'
|
|
1702
1750
|
].join('\n'));
|
|
1703
1751
|
});
|
|
1704
|
-
it('includes markdown comments in hover.',
|
|
1752
|
+
it('includes markdown comments in hover.', () => {
|
|
1705
1753
|
let rootDir = process.cwd();
|
|
1706
1754
|
program = new Program_1.Program({
|
|
1707
1755
|
rootDir: rootDir
|
|
@@ -1723,7 +1771,7 @@ describe('BrsFile', () => {
|
|
|
1723
1771
|
end sub
|
|
1724
1772
|
`);
|
|
1725
1773
|
//hover over log("hello")
|
|
1726
|
-
(0, chai_1.expect)(
|
|
1774
|
+
(0, chai_1.expect)(program.getHover(file.srcPath, vscode_languageserver_1.Position.create(5, 22))[0].contents).to.equal([
|
|
1727
1775
|
'```brightscript',
|
|
1728
1776
|
'sub log(message as string) as void',
|
|
1729
1777
|
'```',
|
|
@@ -1734,7 +1782,7 @@ describe('BrsFile', () => {
|
|
|
1734
1782
|
''
|
|
1735
1783
|
].join('\n'));
|
|
1736
1784
|
//hover over sub ma|in()
|
|
1737
|
-
(0, chai_1.expect)((0, testHelpers_spec_1.trim)(
|
|
1785
|
+
(0, chai_1.expect)((0, testHelpers_spec_1.trim)(program.getHover(file.srcPath, vscode_languageserver_1.Position.create(4, 22))[0].contents.toString())).to.equal((0, testHelpers_spec_1.trim) `
|
|
1738
1786
|
\`\`\`brightscript
|
|
1739
1787
|
sub main() as void
|
|
1740
1788
|
\`\`\`
|
|
@@ -1770,6 +1818,7 @@ describe('BrsFile', () => {
|
|
|
1770
1818
|
(0, testHelpers_spec_1.expectZeroDiagnostics)(mainFile);
|
|
1771
1819
|
});
|
|
1772
1820
|
it('displays the context from multiple scopes', () => {
|
|
1821
|
+
var _a, _b;
|
|
1773
1822
|
let commonFile = program.setFile('source/common.brs', `
|
|
1774
1823
|
sub displayPi()
|
|
1775
1824
|
pi = getPi()
|
|
@@ -1803,14 +1852,14 @@ describe('BrsFile', () => {
|
|
|
1803
1852
|
</component>
|
|
1804
1853
|
`);
|
|
1805
1854
|
program.validate();
|
|
1806
|
-
let funcCallHover =
|
|
1807
|
-
(0, chai_1.expect)(funcCallHover === null ||
|
|
1855
|
+
let funcCallHover = program.getHover(commonFile.srcPath, vscode_languageserver_1.Position.create(2, 27));
|
|
1856
|
+
(0, chai_1.expect)((_a = funcCallHover[0]) === null || _a === void 0 ? void 0 : _a.contents).to.equal([
|
|
1808
1857
|
'```brightscript',
|
|
1809
1858
|
'function getPi() as string | function getPi() as float | getPi as uninitialized',
|
|
1810
1859
|
'```'
|
|
1811
1860
|
].join('\n'));
|
|
1812
|
-
let variableHover =
|
|
1813
|
-
(0, chai_1.expect)(variableHover === null ||
|
|
1861
|
+
let variableHover = program.getHover(commonFile.srcPath, vscode_languageserver_1.Position.create(3, 27));
|
|
1862
|
+
(0, chai_1.expect)((_b = variableHover[0]) === null || _b === void 0 ? void 0 : _b.contents).to.equal([
|
|
1814
1863
|
'```brightscript',
|
|
1815
1864
|
'pi as string | pi as float | pi as uninitialized',
|
|
1816
1865
|
'```'
|
|
@@ -1830,9 +1879,9 @@ describe('BrsFile', () => {
|
|
|
1830
1879
|
class MyKlass
|
|
1831
1880
|
end class
|
|
1832
1881
|
`);
|
|
1833
|
-
let hover =
|
|
1882
|
+
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(3, 29));
|
|
1834
1883
|
(0, chai_1.expect)(hover).to.exist;
|
|
1835
|
-
(0, chai_1.expect)(hover.contents).to.equal([
|
|
1884
|
+
(0, chai_1.expect)(hover[0].contents).to.equal([
|
|
1836
1885
|
'```brightscript',
|
|
1837
1886
|
'function processMyKlass(data as MyKlass) as MyKlass',
|
|
1838
1887
|
'```'
|
|
@@ -1852,9 +1901,9 @@ describe('BrsFile', () => {
|
|
|
1852
1901
|
class MyKlass
|
|
1853
1902
|
end class
|
|
1854
1903
|
`);
|
|
1855
|
-
let hover =
|
|
1904
|
+
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(3, 29));
|
|
1856
1905
|
(0, chai_1.expect)(hover).to.exist;
|
|
1857
|
-
(0, chai_1.expect)(hover.contents).to.equal([
|
|
1906
|
+
(0, chai_1.expect)(hover[0].contents).to.equal([
|
|
1858
1907
|
'```brightscript',
|
|
1859
1908
|
'function processData(data as MyKlass[]) as MyKlass[]',
|
|
1860
1909
|
'```'
|
|
@@ -1872,9 +1921,9 @@ describe('BrsFile', () => {
|
|
|
1872
1921
|
print value
|
|
1873
1922
|
end sub
|
|
1874
1923
|
`);
|
|
1875
|
-
let hover =
|
|
1924
|
+
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(7, 38)); // 'myEnum.foo' in value assignnmnt
|
|
1876
1925
|
(0, chai_1.expect)(hover).to.exist;
|
|
1877
|
-
(0, chai_1.expect)(hover.contents).to.equal([
|
|
1926
|
+
(0, chai_1.expect)(hover[0].contents).to.equal([
|
|
1878
1927
|
'```brightscript',
|
|
1879
1928
|
'MyEnum.foo as MyEnum',
|
|
1880
1929
|
'```'
|
|
@@ -1892,9 +1941,9 @@ describe('BrsFile', () => {
|
|
|
1892
1941
|
print value
|
|
1893
1942
|
end sub
|
|
1894
1943
|
`);
|
|
1895
|
-
let hover =
|
|
1944
|
+
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(8, 30)); // 'value' in print statement
|
|
1896
1945
|
(0, chai_1.expect)(hover).to.exist;
|
|
1897
|
-
(0, chai_1.expect)(hover.contents).to.equal([
|
|
1946
|
+
(0, chai_1.expect)(hover[0].contents).to.equal([
|
|
1898
1947
|
'```brightscript',
|
|
1899
1948
|
'value as MyEnum',
|
|
1900
1949
|
'```'
|
|
@@ -1915,9 +1964,9 @@ describe('BrsFile', () => {
|
|
|
1915
1964
|
printEnum(MyEnum.foo)
|
|
1916
1965
|
end sub
|
|
1917
1966
|
`);
|
|
1918
|
-
let hover =
|
|
1967
|
+
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(7, 30)); // 'enumParamVal' in print statement
|
|
1919
1968
|
(0, chai_1.expect)(hover).to.exist;
|
|
1920
|
-
(0, chai_1.expect)(hover.contents).to.equal([
|
|
1969
|
+
(0, chai_1.expect)(hover[0].contents).to.equal([
|
|
1921
1970
|
'```brightscript',
|
|
1922
1971
|
'enumParamVal as MyEnum',
|
|
1923
1972
|
'```'
|
|
@@ -1965,49 +2014,56 @@ describe('BrsFile', () => {
|
|
|
1965
2014
|
});
|
|
1966
2015
|
it('transpiles if statement keywords as provided', () => {
|
|
1967
2016
|
const code = `
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
2017
|
+
sub main()
|
|
2018
|
+
If True Then
|
|
2019
|
+
Print True
|
|
2020
|
+
Else If True Then
|
|
2021
|
+
print True
|
|
2022
|
+
Else If False Then
|
|
2023
|
+
Print False
|
|
2024
|
+
Else
|
|
2025
|
+
Print False
|
|
2026
|
+
End If
|
|
2027
|
+
end sub
|
|
1977
2028
|
`;
|
|
1978
2029
|
testTranspile(code);
|
|
1979
2030
|
testTranspile(code.toLowerCase());
|
|
1980
2031
|
testTranspile(code.toUpperCase());
|
|
1981
2032
|
});
|
|
1982
2033
|
it('does not transpile `then` tokens', () => {
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
2034
|
+
testTranspile(`
|
|
2035
|
+
sub main()
|
|
2036
|
+
if true
|
|
2037
|
+
print true
|
|
2038
|
+
else if true
|
|
2039
|
+
print false
|
|
2040
|
+
end if
|
|
2041
|
+
end sub
|
|
2042
|
+
`);
|
|
1991
2043
|
});
|
|
1992
2044
|
it('honors spacing between multi-word tokens', () => {
|
|
1993
2045
|
testTranspile(`
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
2046
|
+
sub main()
|
|
2047
|
+
if true
|
|
2048
|
+
print true
|
|
2049
|
+
elseif true
|
|
2050
|
+
print false
|
|
2051
|
+
endif
|
|
2052
|
+
end sub
|
|
1999
2053
|
`);
|
|
2000
2054
|
});
|
|
2001
2055
|
it('handles when only some of the statements have `then`', () => {
|
|
2002
2056
|
testTranspile(`
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
if true then
|
|
2008
|
-
|
|
2057
|
+
sub main()
|
|
2058
|
+
if true
|
|
2059
|
+
else if true then
|
|
2060
|
+
else if true
|
|
2061
|
+
else if true then
|
|
2062
|
+
if true then
|
|
2063
|
+
return true
|
|
2064
|
+
end if
|
|
2009
2065
|
end if
|
|
2010
|
-
end
|
|
2066
|
+
end sub
|
|
2011
2067
|
`);
|
|
2012
2068
|
});
|
|
2013
2069
|
it('retains casing of parameter types', () => {
|
|
@@ -2080,7 +2136,7 @@ describe('BrsFile', () => {
|
|
|
2080
2136
|
testTranspile(`
|
|
2081
2137
|
sub main()
|
|
2082
2138
|
try
|
|
2083
|
-
print
|
|
2139
|
+
print m.b.c
|
|
2084
2140
|
catch e
|
|
2085
2141
|
print e
|
|
2086
2142
|
end try
|
|
@@ -2098,7 +2154,7 @@ describe('BrsFile', () => {
|
|
|
2098
2154
|
sub main()
|
|
2099
2155
|
sayHello = NameA.NameB.Speak
|
|
2100
2156
|
sayHello()
|
|
2101
|
-
someOtherObject =
|
|
2157
|
+
someOtherObject = m.other.object
|
|
2102
2158
|
end sub
|
|
2103
2159
|
`, `
|
|
2104
2160
|
sub NameA_NameB_Speak()
|
|
@@ -2107,7 +2163,7 @@ describe('BrsFile', () => {
|
|
|
2107
2163
|
sub main()
|
|
2108
2164
|
sayHello = NameA_NameB_Speak
|
|
2109
2165
|
sayHello()
|
|
2110
|
-
someOtherObject =
|
|
2166
|
+
someOtherObject = m.other.object
|
|
2111
2167
|
end sub
|
|
2112
2168
|
`);
|
|
2113
2169
|
});
|
|
@@ -2231,27 +2287,42 @@ describe('BrsFile', () => {
|
|
|
2231
2287
|
`, 'trim', 'source/main.bs');
|
|
2232
2288
|
});
|
|
2233
2289
|
it('transpiles dim', () => {
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2290
|
+
function doTest(code) {
|
|
2291
|
+
testTranspile(`
|
|
2292
|
+
sub main()
|
|
2293
|
+
requestList = []
|
|
2294
|
+
${code}
|
|
2295
|
+
end sub
|
|
2296
|
+
`, `
|
|
2297
|
+
sub main()
|
|
2298
|
+
requestList = []
|
|
2299
|
+
${code}
|
|
2300
|
+
end sub
|
|
2301
|
+
`);
|
|
2302
|
+
}
|
|
2303
|
+
doTest(`Dim c[5]`);
|
|
2304
|
+
doTest(`Dim c[5, 4]`);
|
|
2305
|
+
doTest(`Dim c[5, 4, 6]`);
|
|
2306
|
+
doTest(`Dim requestData[requestList.count()]`);
|
|
2307
|
+
doTest(`Dim requestData[1, requestList.count()]`);
|
|
2308
|
+
doTest(`Dim requestData[1, requestList.count(), 2]`);
|
|
2309
|
+
doTest(`Dim requestData[requestList[2]]`);
|
|
2310
|
+
doTest(`Dim requestData[1, requestList[2]]`);
|
|
2311
|
+
doTest(`Dim requestData[1, requestList[2], 2]`);
|
|
2312
|
+
doTest(`Dim requestData[requestList["2"]]`);
|
|
2313
|
+
doTest(`Dim requestData[1, requestList["2"]]`);
|
|
2314
|
+
doTest(`Dim requestData[1, requestList["2"], 2]`);
|
|
2315
|
+
doTest(`Dim requestData[1, StrToI("1"), 2]`);
|
|
2247
2316
|
testTranspile(`
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2317
|
+
function getValue(param1)
|
|
2318
|
+
end function
|
|
2319
|
+
|
|
2320
|
+
sub main()
|
|
2321
|
+
requestList = []
|
|
2322
|
+
Dim requestData[1, getValue({
|
|
2323
|
+
key: "value"
|
|
2324
|
+
}), 2]
|
|
2325
|
+
end sub
|
|
2255
2326
|
`);
|
|
2256
2327
|
});
|
|
2257
2328
|
it('transpiles calls to fully-qualified namespaced functions', () => {
|
|
@@ -2365,49 +2436,55 @@ describe('BrsFile', () => {
|
|
|
2365
2436
|
});
|
|
2366
2437
|
it('handles empty if block', () => {
|
|
2367
2438
|
testTranspile(`
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2439
|
+
sub main()
|
|
2440
|
+
if true then
|
|
2441
|
+
end if
|
|
2442
|
+
if true then
|
|
2443
|
+
else
|
|
2444
|
+
print "else"
|
|
2445
|
+
end if
|
|
2446
|
+
if true then
|
|
2447
|
+
else if true then
|
|
2448
|
+
print "else"
|
|
2449
|
+
end if
|
|
2450
|
+
if true then
|
|
2451
|
+
else if true then
|
|
2452
|
+
print "elseif"
|
|
2453
|
+
else
|
|
2454
|
+
print "else"
|
|
2455
|
+
end if
|
|
2456
|
+
end sub
|
|
2384
2457
|
`);
|
|
2385
2458
|
});
|
|
2386
2459
|
it('handles empty elseif block', () => {
|
|
2387
2460
|
testTranspile(`
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2461
|
+
sub main()
|
|
2462
|
+
if true then
|
|
2463
|
+
print "if"
|
|
2464
|
+
else if true then
|
|
2465
|
+
end if
|
|
2466
|
+
if true then
|
|
2467
|
+
print "if"
|
|
2468
|
+
else if true then
|
|
2469
|
+
else if true then
|
|
2470
|
+
end if
|
|
2471
|
+
end sub
|
|
2397
2472
|
`);
|
|
2398
2473
|
});
|
|
2399
2474
|
it('handles empty else block', () => {
|
|
2400
2475
|
testTranspile(`
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2476
|
+
sub main()
|
|
2477
|
+
if true then
|
|
2478
|
+
print "if"
|
|
2479
|
+
else
|
|
2480
|
+
end if
|
|
2481
|
+
if true then
|
|
2482
|
+
print "if"
|
|
2483
|
+
else if true then
|
|
2484
|
+
print "elseif"
|
|
2485
|
+
else
|
|
2486
|
+
end if
|
|
2487
|
+
end sub
|
|
2411
2488
|
`);
|
|
2412
2489
|
});
|
|
2413
2490
|
it('works for function parameters', () => {
|
|
@@ -2517,7 +2594,7 @@ describe('BrsFile', () => {
|
|
|
2517
2594
|
3 'comment
|
|
2518
2595
|
] 'comment
|
|
2519
2596
|
firstIndex = indexes[0] 'comment
|
|
2520
|
-
for each idx in
|
|
2597
|
+
for each idx in indexes 'comment
|
|
2521
2598
|
indexes[idx] = idx + 1 'comment
|
|
2522
2599
|
end for 'comment
|
|
2523
2600
|
if not true then 'comment
|
|
@@ -2597,8 +2674,9 @@ describe('BrsFile', () => {
|
|
|
2597
2674
|
describe('transpile', () => {
|
|
2598
2675
|
it('does not produce diagnostics', () => {
|
|
2599
2676
|
program.setFile('source/main.bs', `
|
|
2600
|
-
sub
|
|
2601
|
-
|
|
2677
|
+
sub test()
|
|
2678
|
+
someNode = createObject("roSGNode", "Rectangle")
|
|
2679
|
+
someNode@.someFunction(test.value)
|
|
2602
2680
|
end sub
|
|
2603
2681
|
`);
|
|
2604
2682
|
program.validate();
|
|
@@ -3304,10 +3382,28 @@ describe('BrsFile', () => {
|
|
|
3304
3382
|
end sub
|
|
3305
3383
|
`);
|
|
3306
3384
|
program.validate();
|
|
3385
|
+
const symbolTable = file.parser.references.functionExpressions[0].symbolTable;
|
|
3307
3386
|
//sanity check
|
|
3308
|
-
(0, chai_1.expect)(
|
|
3387
|
+
(0, chai_1.expect)(symbolTable.getSymbolType('name')).be.instanceof(StringType_1.StringType);
|
|
3309
3388
|
//this complex expression should resolve to dynamic type when not known
|
|
3310
|
-
(0, chai_1.expect)(
|
|
3389
|
+
(0, chai_1.expect)(symbolTable.getSymbolType('thing')).be.instanceof(DynamicType_1.DynamicType);
|
|
3390
|
+
});
|
|
3391
|
+
describe('getDefinition', () => {
|
|
3392
|
+
it('returns const locations', () => {
|
|
3393
|
+
const file = program.setFile('source/main.bs', `
|
|
3394
|
+
sub main()
|
|
3395
|
+
print alpha.beta.charlie
|
|
3396
|
+
end sub
|
|
3397
|
+
namespace alpha.beta
|
|
3398
|
+
const CHARLIE = true
|
|
3399
|
+
end namespace
|
|
3400
|
+
`);
|
|
3401
|
+
//print alpha.beta.char|lie
|
|
3402
|
+
(0, chai_1.expect)(program.getDefinition(file.srcPath, vscode_languageserver_1.Position.create(2, 41))).to.eql([{
|
|
3403
|
+
uri: vscode_uri_1.URI.file(file.srcPath).toString(),
|
|
3404
|
+
range: util_1.default.createRange(5, 26, 5, 33)
|
|
3405
|
+
}]);
|
|
3406
|
+
});
|
|
3311
3407
|
});
|
|
3312
3408
|
});
|
|
3313
3409
|
//# sourceMappingURL=BrsFile.spec.js.map
|