brighterscript 1.0.0-alpha.25 → 1.0.0-alpha.26
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 +28 -0
- package/bsconfig.schema.json +5 -0
- package/dist/AstValidationSegmenter.js +4 -4
- package/dist/AstValidationSegmenter.js.map +1 -1
- package/dist/BsConfig.d.ts +1 -0
- package/dist/Program.d.ts +1 -1
- package/dist/Program.js +18 -19
- package/dist/Program.js.map +1 -1
- package/dist/Scope.d.ts +0 -5
- package/dist/Scope.js +8 -14
- package/dist/Scope.js.map +1 -1
- package/dist/XmlScope.d.ts +0 -5
- package/dist/XmlScope.js +3 -21
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/CachedLookups.js +3 -3
- package/dist/astUtils/CachedLookups.js.map +1 -1
- package/dist/astUtils/Editor.spec.js +1 -1
- package/dist/astUtils/Editor.spec.js.map +1 -1
- package/dist/astUtils/creators.js +32 -12
- package/dist/astUtils/creators.js.map +1 -1
- package/dist/astUtils/creators.spec.js +4 -4
- package/dist/astUtils/creators.spec.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +1 -1
- package/dist/astUtils/reflection.js +1 -1
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +59 -42
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +30 -19
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +2 -1
- package/dist/bscPlugin/BscPlugin.js +7 -3
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/CallExpressionInfo.js +7 -7
- package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
- package/dist/bscPlugin/SignatureHelpUtil.js +5 -4
- package/dist/bscPlugin/SignatureHelpUtil.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +2 -2
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.js +3 -3
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
- package/dist/bscPlugin/definition/DefinitionProvider.d.ts +13 -0
- package/dist/bscPlugin/definition/DefinitionProvider.js +210 -0
- package/dist/bscPlugin/definition/DefinitionProvider.js.map +1 -0
- package/dist/bscPlugin/definition/DefinitionProvider.spec.d.ts +1 -0
- package/dist/bscPlugin/definition/DefinitionProvider.spec.js +88 -0
- package/dist/bscPlugin/definition/DefinitionProvider.spec.js.map +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.js +2 -2
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +0 -2
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js +8 -6
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.js +28 -28
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +4 -0
- package/dist/bscPlugin/validation/ScopeValidator.js +51 -20
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.spec.js +73 -0
- package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -1
- package/dist/files/BrsFile.Class.spec.js +3 -3
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +4 -11
- package/dist/files/BrsFile.js +39 -206
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +56 -2
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/interfaces.d.ts +32 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/parser/AstNode.spec.js +6 -6
- package/dist/parser/AstNode.spec.js.map +1 -1
- package/dist/parser/Expression.d.ts +288 -145
- package/dist/parser/Expression.js +310 -271
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +11 -11
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.d.ts +5 -0
- package/dist/parser/Parser.js +315 -120
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.js +42 -185
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/Statement.d.ts +332 -188
- package/dist/parser/Statement.js +475 -364
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/Statement.spec.js +2 -2
- package/dist/parser/Statement.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/For.spec.js +1 -1
- package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/ForEach.spec.js +2 -2
- package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +1 -1
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
- package/dist/parser/tests/expression/Call.spec.js +11 -11
- package/dist/parser/tests/expression/Call.spec.js.map +1 -1
- package/dist/parser/tests/expression/Indexing.spec.js +30 -5
- package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +2 -2
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.js +2 -2
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
- package/dist/parser/tests/statement/ConstStatement.spec.js +1 -1
- package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Dim.spec.js +8 -8
- package/dist/parser/tests/statement/Dim.spec.js.map +1 -1
- package/dist/parser/tests/statement/Enum.spec.js +2 -2
- package/dist/parser/tests/statement/Enum.spec.js.map +1 -1
- package/dist/parser/tests/statement/LibraryStatement.spec.js +2 -2
- package/dist/parser/tests/statement/LibraryStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Misc.spec.js +2 -2
- package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
- package/dist/parser/tests/statement/PrintStatement.spec.js +1 -1
- package/dist/parser/tests/statement/TryCatch.spec.js +1 -1
- package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
- package/dist/types/BuiltInInterfaceAdder.js +11 -4
- package/dist/types/BuiltInInterfaceAdder.js.map +1 -1
- package/dist/util.d.ts +17 -8
- package/dist/util.js +96 -51
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.js +6 -6
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +1 -1
|
@@ -24,167 +24,6 @@ describe('parser', () => {
|
|
|
24
24
|
diagnostics: []
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
|
-
/*
|
|
28
|
-
describe.skip('findReferences', () => {
|
|
29
|
-
it('gets called if references are missing', () => {
|
|
30
|
-
const parser = Parser.parse(`
|
|
31
|
-
sub main()
|
|
32
|
-
end sub
|
|
33
|
-
|
|
34
|
-
sub UnusedFunction()
|
|
35
|
-
end sub
|
|
36
|
-
`);
|
|
37
|
-
expect(parser.references.functionStatements.map(x => x.name.text)).to.eql([
|
|
38
|
-
'main',
|
|
39
|
-
'UnusedFunction'
|
|
40
|
-
]);
|
|
41
|
-
//simulate a tree-shaking plugin by removing the `UnusedFunction`
|
|
42
|
-
parser.ast.statements.splice(1);
|
|
43
|
-
//tell the parser we modified the AST and need to regenerate references
|
|
44
|
-
parser.invalidateReferences();
|
|
45
|
-
expect(parser['_references']).not.to.exist;
|
|
46
|
-
//calling `references` automatically regenerates the references
|
|
47
|
-
expect(parser.references.functionStatements.map(x => x.name.text)).to.eql([
|
|
48
|
-
'main'
|
|
49
|
-
]);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
function expressionsToStrings(expressions: Set<Expression>) {
|
|
53
|
-
return [...expressions.values()].map(x => {
|
|
54
|
-
const file = new BrsFile({
|
|
55
|
-
srcPath: '',
|
|
56
|
-
destPath: '',
|
|
57
|
-
program: new Program({} as any)
|
|
58
|
-
});
|
|
59
|
-
const state = new BrsTranspileState(file);
|
|
60
|
-
return new SourceNode(null, null, null, x.transpile(state)).toString();
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// eslint-disable-next-line func-names, prefer-arrow-callback
|
|
65
|
-
it('works for references.expressions', function () {
|
|
66
|
-
this.timeout(5000); // this test takes a long time on github
|
|
67
|
-
const parser = Parser.parse(`
|
|
68
|
-
b += "plus-equal"
|
|
69
|
-
a += 1 + 2
|
|
70
|
-
b += getValue1() + getValue2()
|
|
71
|
-
increment++
|
|
72
|
-
decrement--
|
|
73
|
-
some.node@.doCallfunc()
|
|
74
|
-
bravo(3 + 4).jump(callMe())
|
|
75
|
-
obj = {
|
|
76
|
-
val1: someValue
|
|
77
|
-
}
|
|
78
|
-
arr = [
|
|
79
|
-
one
|
|
80
|
-
]
|
|
81
|
-
thing = alpha.bravo
|
|
82
|
-
alpha.charlie()
|
|
83
|
-
delta(alpha.delta)
|
|
84
|
-
call1().a.b.call2()
|
|
85
|
-
class Person
|
|
86
|
-
name as string = "bob"
|
|
87
|
-
end class
|
|
88
|
-
function thing(p1 = name.space.getSomething())
|
|
89
|
-
|
|
90
|
-
end function
|
|
91
|
-
`);
|
|
92
|
-
const expected = [
|
|
93
|
-
'"plus-equal"',
|
|
94
|
-
'b',
|
|
95
|
-
'b += "plus-equal"',
|
|
96
|
-
'1',
|
|
97
|
-
'2',
|
|
98
|
-
'a',
|
|
99
|
-
'a += 1 + 2',
|
|
100
|
-
'getValue1()',
|
|
101
|
-
'getValue2()',
|
|
102
|
-
'b',
|
|
103
|
-
'b += getValue1() + getValue2()',
|
|
104
|
-
'increment++',
|
|
105
|
-
'decrement--',
|
|
106
|
-
//currently the "toString" does a transpile, so that's why this is different.
|
|
107
|
-
'some.node.callfunc("doCallfunc", invalid)',
|
|
108
|
-
'3',
|
|
109
|
-
'4',
|
|
110
|
-
'3 + 4',
|
|
111
|
-
'callMe()',
|
|
112
|
-
'bravo(3 + 4).jump(callMe())',
|
|
113
|
-
'someValue',
|
|
114
|
-
'{\n val1: someValue\n}',
|
|
115
|
-
'one',
|
|
116
|
-
'[\n one\n]',
|
|
117
|
-
'alpha.bravo',
|
|
118
|
-
'alpha.charlie()',
|
|
119
|
-
'alpha.delta',
|
|
120
|
-
'delta(alpha.delta)',
|
|
121
|
-
'call1().a.b.call2()',
|
|
122
|
-
'"bob"',
|
|
123
|
-
'name.space.getSomething()'
|
|
124
|
-
];
|
|
125
|
-
|
|
126
|
-
expect(
|
|
127
|
-
expressionsToStrings(parser.references.expressions)
|
|
128
|
-
).to.eql(expected);
|
|
129
|
-
|
|
130
|
-
//tell the parser we modified the AST and need to regenerate references
|
|
131
|
-
parser.invalidateReferences();
|
|
132
|
-
|
|
133
|
-
expect(
|
|
134
|
-
expressionsToStrings(parser.references.expressions).sort()
|
|
135
|
-
).to.eql(expected.sort());
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('works for references.expressions', () => {
|
|
139
|
-
const parser = Parser.parse(`
|
|
140
|
-
value = true or type(true) = "something" or Enums.A.Value = "value" and Enum1.Value = Name.Space.Enum2.Value
|
|
141
|
-
`);
|
|
142
|
-
const expected = [
|
|
143
|
-
'true',
|
|
144
|
-
'type(true)',
|
|
145
|
-
'"something"',
|
|
146
|
-
'true',
|
|
147
|
-
'Enums.A.Value',
|
|
148
|
-
'"value"',
|
|
149
|
-
'Enum1.Value',
|
|
150
|
-
'Name.Space.Enum2.Value',
|
|
151
|
-
'true or type(true) = "something" or Enums.A.Value = "value" and Enum1.Value = Name.Space.Enum2.Value'
|
|
152
|
-
];
|
|
153
|
-
|
|
154
|
-
expect(
|
|
155
|
-
expressionsToStrings(parser.references.expressions)
|
|
156
|
-
).to.eql(expected);
|
|
157
|
-
|
|
158
|
-
//tell the parser we modified the AST and need to regenerate references
|
|
159
|
-
parser.invalidateReferences();
|
|
160
|
-
|
|
161
|
-
expect(
|
|
162
|
-
expressionsToStrings(parser.references.expressions).sort()
|
|
163
|
-
).to.eql(expected.sort());
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it('works for logical expression', () => {
|
|
167
|
-
const parser = Parser.parse(`
|
|
168
|
-
value = Enums.A.Value = "value"
|
|
169
|
-
`);
|
|
170
|
-
const expected = [
|
|
171
|
-
'Enums.A.Value',
|
|
172
|
-
'"value"',
|
|
173
|
-
'Enums.A.Value = "value"'
|
|
174
|
-
];
|
|
175
|
-
|
|
176
|
-
expect(
|
|
177
|
-
expressionsToStrings(parser.references.expressions)
|
|
178
|
-
).to.eql(expected);
|
|
179
|
-
|
|
180
|
-
//tell the parser we modified the AST and need to regenerate references
|
|
181
|
-
parser.invalidateReferences();
|
|
182
|
-
|
|
183
|
-
expect(
|
|
184
|
-
expressionsToStrings(parser.references.expressions).sort()
|
|
185
|
-
).to.eql(expected.sort());
|
|
186
|
-
});
|
|
187
|
-
}); */
|
|
188
27
|
describe('callfunc operator', () => {
|
|
189
28
|
it('is not allowed in brightscript mode', () => {
|
|
190
29
|
var _a;
|
|
@@ -221,30 +60,30 @@ describe('parser', () => {
|
|
|
221
60
|
it('works for ?.', () => {
|
|
222
61
|
const expression = getExpression(`value = person?.name`);
|
|
223
62
|
(0, chai_config_spec_1.expect)(expression).to.be.instanceOf(Expression_1.DottedGetExpression);
|
|
224
|
-
(0, chai_config_spec_1.expect)(expression.dot.kind).to.eql(TokenKind_1.TokenKind.QuestionDot);
|
|
63
|
+
(0, chai_config_spec_1.expect)(expression.tokens.dot.kind).to.eql(TokenKind_1.TokenKind.QuestionDot);
|
|
225
64
|
});
|
|
226
65
|
it('works for ?[', () => {
|
|
227
66
|
const expression = getExpression(`value = person?["name"]`, { matcher: reflection_1.isIndexedGetExpression });
|
|
228
67
|
(0, chai_config_spec_1.expect)(expression).to.be.instanceOf(Expression_1.IndexedGetExpression);
|
|
229
|
-
(0, chai_config_spec_1.expect)(expression.openingSquare.kind).to.eql(TokenKind_1.TokenKind.QuestionLeftSquare);
|
|
230
|
-
(0, chai_config_spec_1.expect)(expression.
|
|
68
|
+
(0, chai_config_spec_1.expect)(expression.tokens.openingSquare.kind).to.eql(TokenKind_1.TokenKind.QuestionLeftSquare);
|
|
69
|
+
(0, chai_config_spec_1.expect)(expression.tokens.questionDot).not.to.exist;
|
|
231
70
|
});
|
|
232
71
|
it('works for ?.[', () => {
|
|
233
72
|
var _a;
|
|
234
73
|
const expression = getExpression(`value = person?.["name"]`, { matcher: reflection_1.isIndexedGetExpression });
|
|
235
74
|
(0, chai_config_spec_1.expect)(expression).to.be.instanceOf(Expression_1.IndexedGetExpression);
|
|
236
|
-
(0, chai_config_spec_1.expect)(expression.openingSquare.kind).to.eql(TokenKind_1.TokenKind.LeftSquareBracket);
|
|
237
|
-
(0, chai_config_spec_1.expect)((_a = expression.
|
|
75
|
+
(0, chai_config_spec_1.expect)(expression.tokens.openingSquare.kind).to.eql(TokenKind_1.TokenKind.LeftSquareBracket);
|
|
76
|
+
(0, chai_config_spec_1.expect)((_a = expression.tokens.questionDot) === null || _a === void 0 ? void 0 : _a.kind).to.eql(TokenKind_1.TokenKind.QuestionDot);
|
|
238
77
|
});
|
|
239
78
|
it('works for ?@', () => {
|
|
240
79
|
const expression = getExpression(`value = someXml?@someAttr`);
|
|
241
80
|
(0, chai_config_spec_1.expect)(expression).to.be.instanceOf(Expression_1.XmlAttributeGetExpression);
|
|
242
|
-
(0, chai_config_spec_1.expect)(expression.at.kind).to.eql(TokenKind_1.TokenKind.QuestionAt);
|
|
81
|
+
(0, chai_config_spec_1.expect)(expression.tokens.at.kind).to.eql(TokenKind_1.TokenKind.QuestionAt);
|
|
243
82
|
});
|
|
244
83
|
it('works for ?(', () => {
|
|
245
84
|
const expression = getExpression(`value = person.getName?()`);
|
|
246
85
|
(0, chai_config_spec_1.expect)(expression).to.be.instanceOf(Expression_1.CallExpression);
|
|
247
|
-
(0, chai_config_spec_1.expect)(expression.openingParen.kind).to.eql(TokenKind_1.TokenKind.QuestionLeftParen);
|
|
86
|
+
(0, chai_config_spec_1.expect)(expression.tokens.openingParen.kind).to.eql(TokenKind_1.TokenKind.QuestionLeftParen);
|
|
248
87
|
});
|
|
249
88
|
it('works for print statements using question mark', () => {
|
|
250
89
|
const { statements } = parse(`
|
|
@@ -258,12 +97,12 @@ describe('parser', () => {
|
|
|
258
97
|
it.skip('works for ?( in anonymous function', () => {
|
|
259
98
|
const expression = getExpression(`thing = (function() : end function)?()`);
|
|
260
99
|
(0, chai_config_spec_1.expect)(expression).to.be.instanceOf(Expression_1.CallExpression);
|
|
261
|
-
(0, chai_config_spec_1.expect)(expression.openingParen.kind).to.eql(TokenKind_1.TokenKind.QuestionLeftParen);
|
|
100
|
+
(0, chai_config_spec_1.expect)(expression.tokens.openingParen.kind).to.eql(TokenKind_1.TokenKind.QuestionLeftParen);
|
|
262
101
|
});
|
|
263
102
|
it('works for ?( in new call', () => {
|
|
264
103
|
const expression = getExpression(`thing = new Person?()`, { parseMode: Parser_1.ParseMode.BrighterScript });
|
|
265
104
|
(0, chai_config_spec_1.expect)(expression).to.be.instanceOf(Expression_1.NewExpression);
|
|
266
|
-
(0, chai_config_spec_1.expect)(expression.call.openingParen.kind).to.eql(TokenKind_1.TokenKind.QuestionLeftParen);
|
|
105
|
+
(0, chai_config_spec_1.expect)(expression.call.tokens.openingParen.kind).to.eql(TokenKind_1.TokenKind.QuestionLeftParen);
|
|
267
106
|
});
|
|
268
107
|
it('distinguishes between optional chaining and ternary expression', () => {
|
|
269
108
|
const parser = parse(`
|
|
@@ -480,14 +319,14 @@ describe('parser', () => {
|
|
|
480
319
|
let statements = parser.statements[0].func.body.statements;
|
|
481
320
|
let first = statements[0].value;
|
|
482
321
|
(0, chai_config_spec_1.expect)(first).to.be.instanceof(Expression_1.XmlAttributeGetExpression);
|
|
483
|
-
(0, chai_config_spec_1.expect)(first.name.text).to.equal('firstName');
|
|
484
|
-
(0, chai_config_spec_1.expect)(first.at.text).to.equal('@');
|
|
485
|
-
(0, chai_config_spec_1.expect)(first.obj.name.text).to.equal('personXml');
|
|
322
|
+
(0, chai_config_spec_1.expect)(first.tokens.name.text).to.equal('firstName');
|
|
323
|
+
(0, chai_config_spec_1.expect)(first.tokens.at.text).to.equal('@');
|
|
324
|
+
(0, chai_config_spec_1.expect)(first.obj.tokens.name.text).to.equal('personXml');
|
|
486
325
|
let second = statements[1].value;
|
|
487
326
|
(0, chai_config_spec_1.expect)(second).to.be.instanceof(Expression_1.XmlAttributeGetExpression);
|
|
488
|
-
(0, chai_config_spec_1.expect)(second.name.text).to.equal('age');
|
|
489
|
-
(0, chai_config_spec_1.expect)(second.at.text).to.equal('@');
|
|
490
|
-
(0, chai_config_spec_1.expect)(second.obj.name.text).to.equal('firstChild');
|
|
327
|
+
(0, chai_config_spec_1.expect)(second.tokens.name.text).to.equal('age');
|
|
328
|
+
(0, chai_config_spec_1.expect)(second.tokens.at.text).to.equal('@');
|
|
329
|
+
(0, chai_config_spec_1.expect)(second.obj.tokens.name.text).to.equal('firstChild');
|
|
491
330
|
});
|
|
492
331
|
it('does not allow chaining of @ symbols', () => {
|
|
493
332
|
let parser = parse(`
|
|
@@ -617,7 +456,7 @@ describe('parser', () => {
|
|
|
617
456
|
let stmt = statements[0].func.body.statements[0];
|
|
618
457
|
(0, chai_config_spec_1.expect)((0, reflection_1.isExpressionStatement)(stmt)).to.be.true;
|
|
619
458
|
(0, chai_config_spec_1.expect)((0, reflection_1.isVariableExpression)((stmt).expression)).to.be.true;
|
|
620
|
-
(0, chai_config_spec_1.expect)(stmt.expression.name.text).to.equal('NameA');
|
|
459
|
+
(0, chai_config_spec_1.expect)(stmt.expression.tokens.name.text).to.equal('NameA');
|
|
621
460
|
});
|
|
622
461
|
it('adds unended call statements', () => {
|
|
623
462
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -629,7 +468,7 @@ describe('parser', () => {
|
|
|
629
468
|
let stmt = statements[0].func.body.statements[0];
|
|
630
469
|
(0, chai_config_spec_1.expect)((0, reflection_1.isExpressionStatement)(stmt)).to.be.true;
|
|
631
470
|
(0, chai_config_spec_1.expect)((0, reflection_1.isCallExpression)((stmt).expression)).to.be.true;
|
|
632
|
-
(0, chai_config_spec_1.expect)(stmt.expression.callee.name.text).to.equal('lcase');
|
|
471
|
+
(0, chai_config_spec_1.expect)(stmt.expression.callee.tokens.name.text).to.equal('lcase');
|
|
633
472
|
});
|
|
634
473
|
it('adds unended indexed get statements', () => {
|
|
635
474
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -643,7 +482,7 @@ describe('parser', () => {
|
|
|
643
482
|
let stmt = statements[0].func.body.statements[0];
|
|
644
483
|
(0, chai_config_spec_1.expect)((0, reflection_1.isExpressionStatement)(stmt)).to.be.true;
|
|
645
484
|
(0, chai_config_spec_1.expect)((0, reflection_1.isIndexedGetExpression)((stmt).expression)).to.be.true;
|
|
646
|
-
(0, chai_config_spec_1.expect)(stmt.expression.obj.name.text).to.equal('nums');
|
|
485
|
+
(0, chai_config_spec_1.expect)(stmt.expression.obj.tokens.name.text).to.equal('nums');
|
|
647
486
|
});
|
|
648
487
|
it('adds dotted gets', () => {
|
|
649
488
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -664,8 +503,8 @@ describe('parser', () => {
|
|
|
664
503
|
let stmt = statements[0].func.body.statements[0];
|
|
665
504
|
(0, chai_config_spec_1.expect)((0, reflection_1.isExpressionStatement)(stmt)).to.be.true;
|
|
666
505
|
(0, chai_config_spec_1.expect)((0, reflection_1.isDottedGetExpression)((stmt).expression)).to.be.true;
|
|
667
|
-
(0, chai_config_spec_1.expect)(stmt.expression.obj.name.text).to.equal('a');
|
|
668
|
-
(0, chai_config_spec_1.expect)(stmt.expression.name.text).to.equal('b');
|
|
506
|
+
(0, chai_config_spec_1.expect)(stmt.expression.obj.tokens.name.text).to.equal('a');
|
|
507
|
+
(0, chai_config_spec_1.expect)(stmt.expression.tokens.name.text).to.equal('b');
|
|
669
508
|
});
|
|
670
509
|
it('adds function statement with missing type after as', () => {
|
|
671
510
|
var _a;
|
|
@@ -926,7 +765,7 @@ describe('parser', () => {
|
|
|
926
765
|
}), {
|
|
927
766
|
walkMode: visitors_1.WalkMode.visitAllRecursive
|
|
928
767
|
});
|
|
929
|
-
(0, chai_config_spec_1.expect)(elements.map(x => x.
|
|
768
|
+
(0, chai_config_spec_1.expect)(elements.map(x => x.tokens.key.kind)).to.eql([TokenKind_1.TokenKind.Identifier, TokenKind_1.TokenKind.Identifier]);
|
|
930
769
|
});
|
|
931
770
|
});
|
|
932
771
|
it('"end" is not allowed as a local identifier', () => {
|
|
@@ -1033,13 +872,13 @@ describe('parser', () => {
|
|
|
1033
872
|
let fn = statements[0];
|
|
1034
873
|
(0, chai_config_spec_1.expect)(fn.annotations).to.exist;
|
|
1035
874
|
(0, chai_config_spec_1.expect)(fn.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
1036
|
-
(0, chai_config_spec_1.expect)(fn.annotations[0].
|
|
875
|
+
(0, chai_config_spec_1.expect)(fn.annotations[0].tokens.name.text).to.equal('meta1');
|
|
1037
876
|
(0, chai_config_spec_1.expect)(fn.annotations[0].name).to.equal('meta1');
|
|
1038
877
|
(0, chai_config_spec_1.expect)(statements[1]).to.be.instanceof(Statement_1.FunctionStatement);
|
|
1039
878
|
fn = statements[1];
|
|
1040
879
|
(0, chai_config_spec_1.expect)(fn.annotations).to.exist;
|
|
1041
880
|
(0, chai_config_spec_1.expect)(fn.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
1042
|
-
(0, chai_config_spec_1.expect)(fn.annotations[0].
|
|
881
|
+
(0, chai_config_spec_1.expect)(fn.annotations[0].tokens.name.text).to.equal('meta2');
|
|
1043
882
|
});
|
|
1044
883
|
it('attaches annotations inside a function body', () => {
|
|
1045
884
|
var _a, _b;
|
|
@@ -1085,7 +924,7 @@ describe('parser', () => {
|
|
|
1085
924
|
let fn = statements[0];
|
|
1086
925
|
(0, chai_config_spec_1.expect)(fn.annotations).to.exist;
|
|
1087
926
|
(0, chai_config_spec_1.expect)(fn.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
1088
|
-
(0, chai_config_spec_1.expect)(fn.annotations[0].
|
|
927
|
+
(0, chai_config_spec_1.expect)(fn.annotations[0].tokens.name.text).to.equal('meta1');
|
|
1089
928
|
(0, chai_config_spec_1.expect)(fn.annotations[0].call).to.be.instanceof(Expression_1.CallExpression);
|
|
1090
929
|
});
|
|
1091
930
|
it('attaches annotations to a class', () => {
|
|
@@ -1427,6 +1266,24 @@ describe('parser', () => {
|
|
|
1427
1266
|
`, Parser_1.ParseMode.BrighterScript);
|
|
1428
1267
|
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).to.exist;
|
|
1429
1268
|
});
|
|
1269
|
+
it('allows declaring types on assignment in Brighterscript mode', () => {
|
|
1270
|
+
let { diagnostics } = parse(`
|
|
1271
|
+
sub foo()
|
|
1272
|
+
x as string = formatJson("some string")
|
|
1273
|
+
end sub
|
|
1274
|
+
`, Parser_1.ParseMode.BrighterScript);
|
|
1275
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(diagnostics);
|
|
1276
|
+
});
|
|
1277
|
+
it('does not allow declaring types on assignment in brightscript mode', () => {
|
|
1278
|
+
var _a, _b;
|
|
1279
|
+
let { diagnostics } = parse(`
|
|
1280
|
+
sub foo()
|
|
1281
|
+
x as string = formatJson("some string")
|
|
1282
|
+
end sub
|
|
1283
|
+
`, Parser_1.ParseMode.BrightScript);
|
|
1284
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).to.exist;
|
|
1285
|
+
(0, chai_config_spec_1.expect)((_b = diagnostics[0]) === null || _b === void 0 ? void 0 : _b.message).to.include('typed assignment');
|
|
1286
|
+
});
|
|
1430
1287
|
});
|
|
1431
1288
|
describe('union types', () => {
|
|
1432
1289
|
it('is not allowed in brightscript mode', () => {
|