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
|
@@ -15,17 +15,18 @@ const BrsTranspileState_1 = require("./BrsTranspileState");
|
|
|
15
15
|
const source_map_1 = require("source-map");
|
|
16
16
|
const BrsFile_1 = require("../files/BrsFile");
|
|
17
17
|
const Program_1 = require("../Program");
|
|
18
|
+
const visitors_1 = require("../astUtils/visitors");
|
|
18
19
|
const SymbolTable_1 = require("../SymbolTable");
|
|
19
|
-
const
|
|
20
|
-
const
|
|
20
|
+
const ArrayType_1 = require("../types/ArrayType");
|
|
21
|
+
const CustomType_1 = require("../types/CustomType");
|
|
22
|
+
const DynamicType_1 = require("../types/DynamicType");
|
|
21
23
|
const IntegerType_1 = require("../types/IntegerType");
|
|
22
|
-
const
|
|
24
|
+
const LazyType_1 = require("../types/LazyType");
|
|
23
25
|
const ObjectType_1 = require("../types/ObjectType");
|
|
24
|
-
const
|
|
26
|
+
const StringType_1 = require("../types/StringType");
|
|
27
|
+
const TypedFunctionType_1 = require("../types/TypedFunctionType");
|
|
25
28
|
const VoidType_1 = require("../types/VoidType");
|
|
26
|
-
const DynamicType_1 = require("../types/DynamicType");
|
|
27
29
|
const util_1 = require("../util");
|
|
28
|
-
const ArrayType_1 = require("../types/ArrayType");
|
|
29
30
|
describe('parser', () => {
|
|
30
31
|
it('emits empty object when empty token list is provided', () => {
|
|
31
32
|
(0, chai_1.expect)(Parser_1.Parser.parse([])).to.deep.include({
|
|
@@ -119,6 +120,7 @@ describe('parser', () => {
|
|
|
119
120
|
}
|
|
120
121
|
it('works for references.expressions', () => {
|
|
121
122
|
const parser = Parser_1.Parser.parse(`
|
|
123
|
+
b += "plus-equal"
|
|
122
124
|
a += 1 + 2
|
|
123
125
|
b += getValue1() + getValue2()
|
|
124
126
|
increment++
|
|
@@ -143,6 +145,9 @@ describe('parser', () => {
|
|
|
143
145
|
end function
|
|
144
146
|
`);
|
|
145
147
|
const expected = [
|
|
148
|
+
'"plus-equal"',
|
|
149
|
+
'b',
|
|
150
|
+
'b += "plus-equal"',
|
|
146
151
|
'1',
|
|
147
152
|
'2',
|
|
148
153
|
'a',
|
|
@@ -471,7 +476,7 @@ describe('parser', () => {
|
|
|
471
476
|
const strFunctionType = namespaceStmt.symbolTable.getSymbolType('funcStr');
|
|
472
477
|
(0, chai_1.expect)(strFunctionType.returnType.toString()).to.equal('string');
|
|
473
478
|
});
|
|
474
|
-
it('adds a
|
|
479
|
+
it('adds a transpiled name of a function in a namespace to the parsers symbol table', () => {
|
|
475
480
|
let parser = parse(`
|
|
476
481
|
namespace Name.Space
|
|
477
482
|
function funcInt() as integer
|
|
@@ -483,8 +488,8 @@ describe('parser', () => {
|
|
|
483
488
|
end function
|
|
484
489
|
end namespace
|
|
485
490
|
`, Parser_1.ParseMode.BrighterScript);
|
|
486
|
-
(0, chai_1.expect)(parser.symbolTable.getSymbolType('
|
|
487
|
-
(0, chai_1.expect)(parser.symbolTable.getSymbolType('
|
|
491
|
+
(0, chai_1.expect)(parser.symbolTable.getSymbolType('Name_Space_funcInt')).to.be.instanceof(TypedFunctionType_1.TypedFunctionType);
|
|
492
|
+
(0, chai_1.expect)(parser.symbolTable.getSymbolType('Name_Space_funcStr')).to.be.instanceof(TypedFunctionType_1.TypedFunctionType);
|
|
488
493
|
});
|
|
489
494
|
});
|
|
490
495
|
it('supports << operator', () => {
|
|
@@ -853,6 +858,38 @@ describe('parser', () => {
|
|
|
853
858
|
`);
|
|
854
859
|
(0, chai_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
855
860
|
});
|
|
861
|
+
it('allows `mod` as an AA literal property', () => {
|
|
862
|
+
const parser = parse(`
|
|
863
|
+
sub main()
|
|
864
|
+
person = {
|
|
865
|
+
mod: true
|
|
866
|
+
}
|
|
867
|
+
person.mod = false
|
|
868
|
+
print person.mod
|
|
869
|
+
end sub
|
|
870
|
+
`);
|
|
871
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(parser);
|
|
872
|
+
});
|
|
873
|
+
it('converts aa literal property TokenKind to Identifier', () => {
|
|
874
|
+
const parser = parse(`
|
|
875
|
+
sub main()
|
|
876
|
+
person = {
|
|
877
|
+
mod: true
|
|
878
|
+
and: true
|
|
879
|
+
}
|
|
880
|
+
end sub
|
|
881
|
+
`);
|
|
882
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(parser);
|
|
883
|
+
const elements = [];
|
|
884
|
+
parser.ast.walk((0, visitors_1.createVisitor)({
|
|
885
|
+
AAMemberExpression: (node) => {
|
|
886
|
+
elements.push(node);
|
|
887
|
+
}
|
|
888
|
+
}), {
|
|
889
|
+
walkMode: visitors_1.WalkMode.visitAllRecursive
|
|
890
|
+
});
|
|
891
|
+
(0, chai_1.expect)(elements.map(x => x.keyToken.kind)).to.eql([TokenKind_1.TokenKind.Identifier, TokenKind_1.TokenKind.Identifier]);
|
|
892
|
+
});
|
|
856
893
|
});
|
|
857
894
|
it('"end" is not allowed as a local identifier', () => {
|
|
858
895
|
let { diagnostics } = parse(`
|
|
@@ -1493,23 +1530,23 @@ describe('parser', () => {
|
|
|
1493
1530
|
describe('tokenChain', () => {
|
|
1494
1531
|
it('can find a chain of tokens', () => {
|
|
1495
1532
|
const parser = parse(`
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
const childFieldToken = parser.getTokenAt(vscode_languageserver_1.Position.create(2,
|
|
1533
|
+
sub someFunc(var)
|
|
1534
|
+
print var.field.childField
|
|
1535
|
+
end sub
|
|
1536
|
+
`);
|
|
1537
|
+
const childFieldToken = parser.getTokenAt(vscode_languageserver_1.Position.create(2, 42));
|
|
1501
1538
|
const tokenChain = parser.getTokenChain(childFieldToken).chain;
|
|
1502
1539
|
const tokenChainTokens = tokenChain.map(tcm => tcm.token);
|
|
1503
1540
|
(0, chai_1.expect)(tokenChain.length).to.equal(3);
|
|
1504
|
-
(0, chai_1.expect)(tokenChainTokens.map(token => token.text)).to.eql(['
|
|
1541
|
+
(0, chai_1.expect)(tokenChainTokens.map(token => token.text)).to.eql(['var', 'field', 'childField']);
|
|
1505
1542
|
(0, chai_1.expect)(tokenChain.map(tcm => tcm.usage)).to.eql([Parser_1.TokenUsage.Direct, Parser_1.TokenUsage.Direct, Parser_1.TokenUsage.Direct]);
|
|
1506
1543
|
});
|
|
1507
1544
|
it('can find a chain of tokens with function call with no args in the middle', () => {
|
|
1508
1545
|
const parser = parse(`
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1546
|
+
sub someFunc(var)
|
|
1547
|
+
print var.field.funcCall().childField
|
|
1548
|
+
end sub
|
|
1549
|
+
`);
|
|
1513
1550
|
const childFieldToken = parser.getTokenAt(vscode_languageserver_1.Position.create(2, 49));
|
|
1514
1551
|
const tokenChain = parser.getTokenChain(childFieldToken).chain;
|
|
1515
1552
|
const tokenChainTokens = tokenChain.map(tcm => tcm.token);
|
|
@@ -1519,10 +1556,10 @@ describe('parser', () => {
|
|
|
1519
1556
|
});
|
|
1520
1557
|
it('can find a chain of tokens with function call with multiple args in the middle', () => {
|
|
1521
1558
|
const parser = parse(`
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1559
|
+
sub someFunc(var)
|
|
1560
|
+
print var.field.funcCall(1, "string", {key: value}).childField
|
|
1561
|
+
end sub
|
|
1562
|
+
`);
|
|
1526
1563
|
const childFieldToken = parser.getTokenAt(vscode_languageserver_1.Position.create(2, 75));
|
|
1527
1564
|
const tokenChain = parser.getTokenChain(childFieldToken).chain;
|
|
1528
1565
|
const tokenChainTokens = tokenChain.map(tcm => tcm.token);
|
|
@@ -1532,10 +1569,10 @@ describe('parser', () => {
|
|
|
1532
1569
|
});
|
|
1533
1570
|
it('can find a chain of tokens with function call with function call inside', () => {
|
|
1534
1571
|
const parser = parse(`
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1572
|
+
sub someFunc(var)
|
|
1573
|
+
print var.field.funcCall(a(), b(), otherFunc2(c(), {d: func3(e)})).childField
|
|
1574
|
+
end sub
|
|
1575
|
+
`);
|
|
1539
1576
|
const childFieldToken = parser.getTokenAt(vscode_languageserver_1.Position.create(2, 90));
|
|
1540
1577
|
const tokenChain = parser.getTokenChain(childFieldToken).chain;
|
|
1541
1578
|
const tokenChainTokens = tokenChain.map(tcm => tcm.token);
|
|
@@ -1545,10 +1582,10 @@ describe('parser', () => {
|
|
|
1545
1582
|
});
|
|
1546
1583
|
it('can find a chain of tokens with array references inside', () => {
|
|
1547
1584
|
const parser = parse(`
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1585
|
+
sub someFunc(var)
|
|
1586
|
+
print var.field.myArray[0].childField
|
|
1587
|
+
end sub
|
|
1588
|
+
`);
|
|
1552
1589
|
const childFieldToken = parser.getTokenAt(vscode_languageserver_1.Position.create(2, 50));
|
|
1553
1590
|
const tokenChain = parser.getTokenChain(childFieldToken).chain;
|
|
1554
1591
|
const tokenChainTokens = tokenChain.map(tcm => tcm.token);
|
|
@@ -1558,97 +1595,133 @@ describe('parser', () => {
|
|
|
1558
1595
|
});
|
|
1559
1596
|
it('includes unknown when an expression in brackets is part of the chain', () => {
|
|
1560
1597
|
const parser = parse(`
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
const toStrToken = parser.getTokenAt(vscode_languageserver_1.Position.create(2,
|
|
1598
|
+
sub someFunc()
|
|
1599
|
+
print (1 + 1).toStr()
|
|
1600
|
+
end sub
|
|
1601
|
+
`);
|
|
1602
|
+
const toStrToken = parser.getTokenAt(vscode_languageserver_1.Position.create(2, 38));
|
|
1566
1603
|
const tokenChainResponse = parser.getTokenChain(toStrToken);
|
|
1567
1604
|
(0, chai_1.expect)(tokenChainResponse.includesUnknowableTokenType).to.be.true;
|
|
1568
1605
|
});
|
|
1569
1606
|
it('includes unknown when an expression in double brackets is part of the chain', () => {
|
|
1570
1607
|
const parser = parse(`
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
const toStrToken = parser.getTokenAt(vscode_languageserver_1.Position.create(2,
|
|
1608
|
+
sub someFunc()
|
|
1609
|
+
print ((2 + 1)*3).toStr()
|
|
1610
|
+
end sub
|
|
1611
|
+
`);
|
|
1612
|
+
const toStrToken = parser.getTokenAt(vscode_languageserver_1.Position.create(2, 42));
|
|
1576
1613
|
const tokenChainResponse = parser.getTokenChain(toStrToken);
|
|
1577
1614
|
(0, chai_1.expect)(tokenChainResponse.includesUnknowableTokenType).to.be.true;
|
|
1578
1615
|
});
|
|
1579
1616
|
it('includes unknown when a complicated expression in brackets is part of the chain', () => {
|
|
1580
1617
|
const parser = parse(`
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1618
|
+
sub someFunc(currentDate, lastUpdate)
|
|
1619
|
+
print (INT((currentDate.asSeconds() - lastUpdate) / 86400)).toStr()
|
|
1620
|
+
end sub
|
|
1621
|
+
`);
|
|
1585
1622
|
const toStrToken = parser.getTokenAt(vscode_languageserver_1.Position.create(2, 81));
|
|
1586
1623
|
const tokenChainResponse = parser.getTokenChain(toStrToken);
|
|
1587
1624
|
(0, chai_1.expect)(tokenChainResponse.includesUnknowableTokenType).to.be.true;
|
|
1588
1625
|
});
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1626
|
+
it('indicates IndexedGet when referenced via brackets', () => {
|
|
1627
|
+
const parser = parse(`
|
|
1628
|
+
sub someFunc()
|
|
1629
|
+
complexObj = {prop: "hello", subObj: {prop: "foo", grandChildObj:{prop:"bar"}}}
|
|
1630
|
+
print complexObj.subObj.prop
|
|
1631
|
+
print complexObj["subObj"].prop
|
|
1632
|
+
print complexObj["subObj"]["grandChildObj"].prop
|
|
1633
|
+
end sub
|
|
1634
|
+
`);
|
|
1635
|
+
const propAsChainToken = parser.getTokenAt(vscode_languageserver_1.Position.create(3, 48)); // complexObj.subObj.prop
|
|
1636
|
+
const propAsAsBracketToken = parser.getTokenAt(vscode_languageserver_1.Position.create(4, 51)); // complexObj["subObj"].prop
|
|
1637
|
+
const propAsAsDoubleBracketToken = parser.getTokenAt(vscode_languageserver_1.Position.create(5, 68)); // complexObj["subObj"]["grandChildObj"].prop
|
|
1638
|
+
let tokenChainResponse = parser.getTokenChain(propAsChainToken);
|
|
1639
|
+
(0, chai_1.expect)(tokenChainResponse.includesUnknowableTokenType).to.be.false;
|
|
1640
|
+
(0, chai_1.expect)(tokenChainResponse.chain.map(tcm => tcm.token).map(token => token.text)).to.eql(['complexObj', 'subObj', 'prop']);
|
|
1641
|
+
tokenChainResponse = parser.getTokenChain(propAsAsBracketToken);
|
|
1642
|
+
(0, chai_1.expect)(tokenChainResponse.includesUnknowableTokenType).to.be.false;
|
|
1643
|
+
(0, chai_1.expect)(tokenChainResponse.chain[0].usage).to.eql(Parser_1.TokenUsage.ArrayReference);
|
|
1644
|
+
tokenChainResponse = parser.getTokenChain(propAsAsDoubleBracketToken);
|
|
1645
|
+
(0, chai_1.expect)(tokenChainResponse.chain[0].usage).to.equal(Parser_1.TokenUsage.Direct);
|
|
1646
|
+
});
|
|
1647
|
+
it('allows token kinds from AllowedLocalIdentifiers as start of a chain', () => {
|
|
1648
|
+
const parser = parse(`
|
|
1649
|
+
sub testLocalIdentifiers(override, string, float)
|
|
1650
|
+
override.someProp.someFunc()
|
|
1651
|
+
string.someProp.someFunc()
|
|
1652
|
+
float.someProp.someFunc()
|
|
1653
|
+
end sub
|
|
1654
|
+
`);
|
|
1655
|
+
const overrideFuncToken = parser.getTokenAt(vscode_languageserver_1.Position.create(2, 40)); // override.someProp.someFunc()
|
|
1656
|
+
const stringFuncToken = parser.getTokenAt(vscode_languageserver_1.Position.create(3, 40)); // string.someProp.someFunc()
|
|
1657
|
+
const floatFuncToken = parser.getTokenAt(vscode_languageserver_1.Position.create(4, 38)); // float.someProp.someFunc()
|
|
1658
|
+
let tokenChainResponse = parser.getTokenChain(overrideFuncToken);
|
|
1659
|
+
(0, chai_1.expect)(tokenChainResponse.includesUnknowableTokenType).to.be.false;
|
|
1660
|
+
(0, chai_1.expect)(tokenChainResponse.chain.map(tcm => tcm.token).map(token => token.text)).to.eql(['override', 'someProp', 'someFunc']);
|
|
1661
|
+
tokenChainResponse = parser.getTokenChain(stringFuncToken);
|
|
1662
|
+
(0, chai_1.expect)(tokenChainResponse.includesUnknowableTokenType).to.be.false;
|
|
1663
|
+
(0, chai_1.expect)(tokenChainResponse.chain.map(tcm => tcm.token).map(token => token.text)).to.eql(['string', 'someProp', 'someFunc']);
|
|
1664
|
+
tokenChainResponse = parser.getTokenChain(floatFuncToken);
|
|
1665
|
+
(0, chai_1.expect)(tokenChainResponse.includesUnknowableTokenType).to.be.false;
|
|
1666
|
+
(0, chai_1.expect)(tokenChainResponse.chain.map(tcm => tcm.token).map(token => token.text)).to.eql(['float', 'someProp', 'someFunc']);
|
|
1667
|
+
});
|
|
1668
|
+
it('allows token kinds from AllowedProperties in middle of a chain', () => {
|
|
1669
|
+
const parser = parse(`
|
|
1670
|
+
sub testAllowedProperties(someObj)
|
|
1671
|
+
someObj.override.someFunc()
|
|
1672
|
+
someObj.string.someFunc()
|
|
1673
|
+
someObj.float.someFunc()
|
|
1674
|
+
end sub
|
|
1675
|
+
`);
|
|
1676
|
+
const overrideFuncToken = parser.getTokenAt(vscode_languageserver_1.Position.create(2, 40)); // someObj.override.someFunc()
|
|
1677
|
+
const stringFuncToken = parser.getTokenAt(vscode_languageserver_1.Position.create(3, 40)); // someObj.string.someFunc()
|
|
1678
|
+
const floatFuncToken = parser.getTokenAt(vscode_languageserver_1.Position.create(4, 40)); // someObj.float.someFunc()
|
|
1679
|
+
let tokenChainResponse = parser.getTokenChain(overrideFuncToken);
|
|
1680
|
+
(0, chai_1.expect)(tokenChainResponse.includesUnknowableTokenType).to.be.false;
|
|
1681
|
+
(0, chai_1.expect)(tokenChainResponse.chain.map(tcm => tcm.token).map(token => token.text)).to.eql(['someObj', 'override', 'someFunc']);
|
|
1682
|
+
tokenChainResponse = parser.getTokenChain(stringFuncToken);
|
|
1683
|
+
(0, chai_1.expect)(tokenChainResponse.includesUnknowableTokenType).to.be.false;
|
|
1684
|
+
(0, chai_1.expect)(tokenChainResponse.chain.map(tcm => tcm.token).map(token => token.text)).to.eql(['someObj', 'string', 'someFunc']);
|
|
1685
|
+
tokenChainResponse = parser.getTokenChain(floatFuncToken);
|
|
1686
|
+
(0, chai_1.expect)(tokenChainResponse.includesUnknowableTokenType).to.be.false;
|
|
1687
|
+
(0, chai_1.expect)(tokenChainResponse.chain.map(tcm => tcm.token).map(token => token.text)).to.eql(['someObj', 'float', 'someFunc']);
|
|
1688
|
+
});
|
|
1689
|
+
it('finds tokens in the middle of a chain', () => {
|
|
1690
|
+
const parser = parse(`
|
|
1691
|
+
sub testMiddleOfChain()
|
|
1692
|
+
print m.nodes[8].label.text
|
|
1693
|
+
print alpha.bravo(charlie.delta)
|
|
1694
|
+
print m.otherFunc().name
|
|
1695
|
+
end sub
|
|
1696
|
+
`);
|
|
1697
|
+
const labelToken = parser.getTokenAt(vscode_languageserver_1.Position.create(2, 40)); // 'label'
|
|
1698
|
+
const nodesToken = parser.getTokenAt(vscode_languageserver_1.Position.create(2, 31)); // 'nodes'
|
|
1699
|
+
const bravoToken = parser.getTokenAt(vscode_languageserver_1.Position.create(3, 35)); // 'bravo'
|
|
1700
|
+
let tokenChainResponse = parser.getTokenChain(labelToken);
|
|
1701
|
+
(0, chai_1.expect)(tokenChainResponse.includesUnknowableTokenType).to.be.false;
|
|
1702
|
+
(0, chai_1.expect)(tokenChainResponse.chain.map(tcm => tcm.token).map(token => token.text)).to.eql(['m', 'nodes', 'label']);
|
|
1703
|
+
(0, chai_1.expect)(tokenChainResponse.chain.map(tcm => tcm.usage)).to.eql([Parser_1.TokenUsage.Direct, Parser_1.TokenUsage.ArrayReference, Parser_1.TokenUsage.Direct]);
|
|
1704
|
+
tokenChainResponse = parser.getTokenChain(nodesToken);
|
|
1705
|
+
(0, chai_1.expect)(tokenChainResponse.includesUnknowableTokenType).to.be.false;
|
|
1706
|
+
(0, chai_1.expect)(tokenChainResponse.chain.map(tcm => tcm.token).map(token => token.text)).to.eql(['m', 'nodes']);
|
|
1707
|
+
(0, chai_1.expect)(tokenChainResponse.chain.map(tcm => tcm.usage)).to.eql([Parser_1.TokenUsage.Direct, Parser_1.TokenUsage.Direct]);
|
|
1708
|
+
tokenChainResponse = parser.getTokenChain(bravoToken);
|
|
1709
|
+
(0, chai_1.expect)(tokenChainResponse.includesUnknowableTokenType).to.be.false;
|
|
1710
|
+
(0, chai_1.expect)(tokenChainResponse.chain.map(tcm => tcm.token).map(token => token.text)).to.eql(['alpha', 'bravo']);
|
|
1711
|
+
(0, chai_1.expect)(tokenChainResponse.chain.map(tcm => tcm.usage)).to.eql([Parser_1.TokenUsage.Direct, Parser_1.TokenUsage.Direct]);
|
|
1712
|
+
});
|
|
1713
|
+
it('gets chain from ending dot', () => {
|
|
1714
|
+
const parser = parse(`
|
|
1715
|
+
sub testDotAtEndOfChain()
|
|
1716
|
+
m.someFunc().data[0].param.
|
|
1717
|
+
end sub
|
|
1718
|
+
`);
|
|
1719
|
+
const endDotToken = parser.getTokenAt(vscode_languageserver_1.Position.create(2, 46)); // dot of 'param.'
|
|
1720
|
+
let tokenChainResponse = parser.getTokenChain(endDotToken);
|
|
1721
|
+
(0, chai_1.expect)(tokenChainResponse.includesUnknowableTokenType).to.be.false;
|
|
1722
|
+
(0, chai_1.expect)(tokenChainResponse.chain.map(tcm => tcm.token).map(token => token.text)).to.eql(['m', 'someFunc', 'data', 'param']);
|
|
1723
|
+
(0, chai_1.expect)(tokenChainResponse.chain.map(tcm => tcm.usage)).to.eql([Parser_1.TokenUsage.Direct, Parser_1.TokenUsage.Call, Parser_1.TokenUsage.ArrayReference, Parser_1.TokenUsage.Direct]);
|
|
1724
|
+
});
|
|
1652
1725
|
});
|
|
1653
1726
|
});
|
|
1654
1727
|
function parse(text, mode) {
|