brighterscript 0.59.0 → 0.60.0
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 +13 -0
- package/README.md +5 -4
- package/dist/CommentFlagProcessor.d.ts +1 -1
- package/dist/CommentFlagProcessor.js +1 -1
- package/dist/DependencyGraph.d.ts +3 -2
- package/dist/DependencyGraph.js +3 -2
- package/dist/DependencyGraph.js.map +1 -1
- package/dist/DiagnosticFilterer.js +1 -2
- package/dist/DiagnosticFilterer.js.map +1 -1
- package/dist/DiagnosticMessages.d.ts +6 -1
- package/dist/DiagnosticMessages.js +5 -0
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/FunctionScope.d.ts +1 -1
- package/dist/FunctionScope.js +1 -1
- package/dist/KeyedThrottler.d.ts +3 -3
- package/dist/KeyedThrottler.js +3 -3
- package/dist/KeyedThrottler.js.map +1 -1
- package/dist/LanguageServer.d.ts +0 -7
- package/dist/LanguageServer.js +0 -7
- package/dist/LanguageServer.js.map +1 -1
- package/dist/Program.d.ts +5 -7
- package/dist/Program.js +11 -213
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +0 -1
- package/dist/ProgramBuilder.js +0 -1
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +31 -33
- package/dist/Scope.js +47 -33
- package/dist/Scope.js.map +1 -1
- package/dist/SymbolTable.d.ts +0 -3
- package/dist/SymbolTable.js +0 -3
- package/dist/SymbolTable.js.map +1 -1
- package/dist/Watcher.d.ts +0 -3
- package/dist/Watcher.js +0 -3
- package/dist/Watcher.js.map +1 -1
- package/dist/astUtils/AstEditor.d.ts +1 -1
- package/dist/astUtils/AstEditor.js +1 -1
- package/dist/astUtils/AstEditor.spec.js +58 -58
- package/dist/astUtils/AstEditor.spec.js.map +1 -1
- package/dist/astUtils/creators.spec.js +5 -5
- package/dist/astUtils/creators.spec.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +112 -112
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/astUtils/stackedVisitor.spec.js +12 -12
- package/dist/astUtils/stackedVisitor.spec.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +4 -0
- package/dist/astUtils/visitors.js +4 -0
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +21 -21
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/bscPlugin/CallExpressionInfo.d.ts +35 -0
- package/dist/bscPlugin/CallExpressionInfo.js +131 -0
- package/dist/bscPlugin/CallExpressionInfo.js.map +1 -0
- package/dist/bscPlugin/SignatureHelpUtil.d.ts +10 -0
- package/dist/bscPlugin/SignatureHelpUtil.js +135 -0
- package/dist/bscPlugin/SignatureHelpUtil.js.map +1 -0
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +7 -7
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.spec.js +27 -27
- package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +2 -2
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js +1 -2
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.d.ts +1 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js +11 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js +39 -9
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -1
- package/dist/files/BrsFile.Class.spec.js +11 -11
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +8 -20
- package/dist/files/BrsFile.js +16 -97
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +235 -187
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.d.ts +1 -4
- package/dist/files/XmlFile.js +1 -4
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/files/XmlFile.spec.js +82 -82
- package/dist/files/XmlFile.spec.js.map +1 -1
- package/dist/files/tests/imports.spec.js +7 -7
- package/dist/files/tests/imports.spec.js.map +1 -1
- package/dist/lexer/Character.spec.js +5 -5
- package/dist/lexer/Character.spec.js.map +1 -1
- package/dist/lexer/Lexer.d.ts +0 -5
- package/dist/lexer/Lexer.js +0 -5
- package/dist/lexer/Lexer.js.map +1 -1
- package/dist/lexer/Lexer.spec.js +136 -136
- package/dist/lexer/Lexer.spec.js.map +1 -1
- package/dist/parser/AstNode.d.ts +1 -1
- package/dist/parser/AstNode.spec.js +3 -3
- package/dist/parser/AstNode.spec.js.map +1 -1
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +60 -60
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.d.ts +4 -4
- package/dist/parser/Parser.js +4 -7
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.js +229 -221
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/SGParser.spec.js +14 -14
- package/dist/parser/SGParser.spec.js.map +1 -1
- package/dist/parser/Statement.d.ts +3 -2
- package/dist/parser/Statement.js +12 -5
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/Statement.spec.js +29 -11
- package/dist/parser/Statement.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/For.spec.js +15 -15
- package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/ForEach.spec.js +13 -13
- package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/If.spec.js +93 -93
- package/dist/parser/tests/controlFlow/If.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/While.spec.js +12 -12
- package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
- package/dist/parser/tests/expression/Additive.spec.js +8 -8
- package/dist/parser/tests/expression/Additive.spec.js.map +1 -1
- package/dist/parser/tests/expression/ArrayLiterals.spec.js +26 -26
- package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +1 -1
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +27 -27
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
- package/dist/parser/tests/expression/Boolean.spec.js +8 -8
- package/dist/parser/tests/expression/Boolean.spec.js.map +1 -1
- package/dist/parser/tests/expression/Call.spec.js +45 -45
- package/dist/parser/tests/expression/Call.spec.js.map +1 -1
- package/dist/parser/tests/expression/Exponential.spec.js +5 -5
- package/dist/parser/tests/expression/Exponential.spec.js.map +1 -1
- package/dist/parser/tests/expression/Function.spec.js +36 -36
- package/dist/parser/tests/expression/Function.spec.js.map +1 -1
- package/dist/parser/tests/expression/Indexing.spec.js +29 -29
- package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
- package/dist/parser/tests/expression/Multiplicative.spec.js +9 -9
- package/dist/parser/tests/expression/Multiplicative.spec.js.map +1 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +34 -34
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/PrefixUnary.spec.js +12 -12
- package/dist/parser/tests/expression/PrefixUnary.spec.js.map +1 -1
- package/dist/parser/tests/expression/Primary.spec.js +12 -12
- package/dist/parser/tests/expression/Primary.spec.js.map +1 -1
- package/dist/parser/tests/expression/Relational.spec.js +13 -13
- package/dist/parser/tests/expression/Relational.spec.js.map +1 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js +10 -10
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.js +53 -53
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
- package/dist/parser/tests/statement/AssignmentOperators.spec.js +15 -15
- package/dist/parser/tests/statement/AssignmentOperators.spec.js.map +1 -1
- package/dist/parser/tests/statement/ConstStatement.spec.js +6 -6
- package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Continue.spec.js +4 -4
- package/dist/parser/tests/statement/Continue.spec.js.map +1 -1
- package/dist/parser/tests/statement/Declaration.spec.js +19 -19
- package/dist/parser/tests/statement/Declaration.spec.js.map +1 -1
- package/dist/parser/tests/statement/Dim.spec.js +22 -22
- package/dist/parser/tests/statement/Dim.spec.js.map +1 -1
- package/dist/parser/tests/statement/Enum.spec.js +14 -14
- package/dist/parser/tests/statement/Enum.spec.js.map +1 -1
- package/dist/parser/tests/statement/Function.spec.js +35 -35
- package/dist/parser/tests/statement/Function.spec.js.map +1 -1
- package/dist/parser/tests/statement/Goto.spec.js +5 -5
- package/dist/parser/tests/statement/Goto.spec.js.map +1 -1
- package/dist/parser/tests/statement/Increment.spec.js +20 -20
- package/dist/parser/tests/statement/Increment.spec.js.map +1 -1
- package/dist/parser/tests/statement/LibraryStatement.spec.js +11 -11
- package/dist/parser/tests/statement/LibraryStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Misc.spec.js +20 -20
- package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
- package/dist/parser/tests/statement/PrintStatement.spec.js +16 -16
- package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/ReturnStatement.spec.js +9 -9
- package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Set.spec.js +22 -22
- package/dist/parser/tests/statement/Set.spec.js.map +1 -1
- package/dist/parser/tests/statement/Stop.spec.js +6 -6
- package/dist/parser/tests/statement/Stop.spec.js.map +1 -1
- package/dist/parser/tests/statement/Throw.spec.js +6 -6
- package/dist/parser/tests/statement/Throw.spec.js.map +1 -1
- package/dist/parser/tests/statement/TryCatch.spec.js +15 -15
- package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
- package/dist/preprocessor/Manifest.spec.js +8 -8
- package/dist/preprocessor/Manifest.spec.js.map +1 -1
- package/dist/preprocessor/Preprocessor.d.ts +2 -2
- package/dist/preprocessor/Preprocessor.js +2 -2
- package/dist/preprocessor/Preprocessor.spec.js +25 -25
- package/dist/preprocessor/Preprocessor.spec.js.map +1 -1
- package/dist/preprocessor/PreprocessorParser.d.ts +1 -1
- package/dist/preprocessor/PreprocessorParser.js +1 -1
- package/dist/preprocessor/PreprocessorParser.spec.js +13 -13
- package/dist/preprocessor/PreprocessorParser.spec.js.map +1 -1
- package/dist/types/ArrayType.spec.js +9 -9
- package/dist/types/ArrayType.spec.js.map +1 -1
- package/dist/types/BooleanType.spec.js +3 -3
- package/dist/types/BooleanType.spec.js.map +1 -1
- package/dist/types/DoubleType.spec.js +3 -3
- package/dist/types/DoubleType.spec.js.map +1 -1
- package/dist/types/DynamicType.d.ts +0 -1
- package/dist/types/DynamicType.js +0 -1
- package/dist/types/DynamicType.js.map +1 -1
- package/dist/types/DynamicType.spec.js +3 -3
- package/dist/types/DynamicType.spec.js.map +1 -1
- package/dist/types/FloatType.spec.js +3 -3
- package/dist/types/FloatType.spec.js.map +1 -1
- package/dist/types/FunctionType.spec.js +6 -6
- package/dist/types/FunctionType.spec.js.map +1 -1
- package/dist/types/IntegerType.spec.js +3 -3
- package/dist/types/IntegerType.spec.js.map +1 -1
- package/dist/types/InterfaceType.spec.js +8 -8
- package/dist/types/InterfaceType.spec.js.map +1 -1
- package/dist/types/InvalidType.spec.js +3 -3
- package/dist/types/InvalidType.spec.js.map +1 -1
- package/dist/types/LongIntegerType.spec.js +3 -3
- package/dist/types/LongIntegerType.spec.js.map +1 -1
- package/dist/types/ObjectType.spec.js +3 -3
- package/dist/types/ObjectType.spec.js.map +1 -1
- package/dist/types/StringType.spec.js +3 -3
- package/dist/types/StringType.spec.js.map +1 -1
- package/dist/types/VoidType.spec.js +3 -3
- package/dist/types/VoidType.spec.js.map +1 -1
- package/dist/util.d.ts +21 -43
- package/dist/util.js +26 -54
- package/dist/util.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.failStatementType = exports.rangeToArray = void 0;
|
|
4
|
-
const
|
|
4
|
+
const chai_config_spec_1 = require("../chai-config.spec");
|
|
5
5
|
const Lexer_1 = require("../lexer/Lexer");
|
|
6
6
|
const TokenKind_1 = require("../lexer/TokenKind");
|
|
7
7
|
const Expression_1 = require("./Expression");
|
|
@@ -18,7 +18,7 @@ const Program_1 = require("../Program");
|
|
|
18
18
|
const visitors_1 = require("../astUtils/visitors");
|
|
19
19
|
describe('parser', () => {
|
|
20
20
|
it('emits empty object when empty token list is provided', () => {
|
|
21
|
-
(0,
|
|
21
|
+
(0, chai_config_spec_1.expect)(Parser_1.Parser.parse([])).to.deep.include({
|
|
22
22
|
statements: [],
|
|
23
23
|
diagnostics: []
|
|
24
24
|
});
|
|
@@ -32,7 +32,7 @@ describe('parser', () => {
|
|
|
32
32
|
sub UnusedFunction()
|
|
33
33
|
end sub
|
|
34
34
|
`);
|
|
35
|
-
(0,
|
|
35
|
+
(0, chai_config_spec_1.expect)(parser.references.functionStatements.map(x => x.name.text)).to.eql([
|
|
36
36
|
'main',
|
|
37
37
|
'UnusedFunction'
|
|
38
38
|
]);
|
|
@@ -40,9 +40,9 @@ describe('parser', () => {
|
|
|
40
40
|
parser.ast.statements.splice(1);
|
|
41
41
|
//tell the parser we modified the AST and need to regenerate references
|
|
42
42
|
parser.invalidateReferences();
|
|
43
|
-
(0,
|
|
43
|
+
(0, chai_config_spec_1.expect)(parser['_references']).not.to.exist;
|
|
44
44
|
//calling `references` automatically regenerates the references
|
|
45
|
-
(0,
|
|
45
|
+
(0, chai_config_spec_1.expect)(parser.references.functionStatements.map(x => x.name.text)).to.eql([
|
|
46
46
|
'main'
|
|
47
47
|
]);
|
|
48
48
|
});
|
|
@@ -112,10 +112,10 @@ describe('parser', () => {
|
|
|
112
112
|
'"bob"',
|
|
113
113
|
'name.space.getSomething()'
|
|
114
114
|
];
|
|
115
|
-
(0,
|
|
115
|
+
(0, chai_config_spec_1.expect)(expressionsToStrings(parser.references.expressions)).to.eql(expected);
|
|
116
116
|
//tell the parser we modified the AST and need to regenerate references
|
|
117
117
|
parser.invalidateReferences();
|
|
118
|
-
(0,
|
|
118
|
+
(0, chai_config_spec_1.expect)(expressionsToStrings(parser.references.expressions).sort()).to.eql(expected.sort());
|
|
119
119
|
});
|
|
120
120
|
it('works for references.expressions', () => {
|
|
121
121
|
const parser = Parser_1.Parser.parse(`
|
|
@@ -132,10 +132,10 @@ describe('parser', () => {
|
|
|
132
132
|
'Name.Space.Enum2.Value',
|
|
133
133
|
'true or type(true) = "something" or Enums.A.Value = "value" and Enum1.Value = Name.Space.Enum2.Value'
|
|
134
134
|
];
|
|
135
|
-
(0,
|
|
135
|
+
(0, chai_config_spec_1.expect)(expressionsToStrings(parser.references.expressions)).to.eql(expected);
|
|
136
136
|
//tell the parser we modified the AST and need to regenerate references
|
|
137
137
|
parser.invalidateReferences();
|
|
138
|
-
(0,
|
|
138
|
+
(0, chai_config_spec_1.expect)(expressionsToStrings(parser.references.expressions).sort()).to.eql(expected.sort());
|
|
139
139
|
});
|
|
140
140
|
it('works for logical expression', () => {
|
|
141
141
|
const parser = Parser_1.Parser.parse(`
|
|
@@ -146,10 +146,10 @@ describe('parser', () => {
|
|
|
146
146
|
'"value"',
|
|
147
147
|
'Enums.A.Value = "value"'
|
|
148
148
|
];
|
|
149
|
-
(0,
|
|
149
|
+
(0, chai_config_spec_1.expect)(expressionsToStrings(parser.references.expressions)).to.eql(expected);
|
|
150
150
|
//tell the parser we modified the AST and need to regenerate references
|
|
151
151
|
parser.invalidateReferences();
|
|
152
|
-
(0,
|
|
152
|
+
(0, chai_config_spec_1.expect)(expressionsToStrings(parser.references.expressions).sort()).to.eql(expected.sort());
|
|
153
153
|
});
|
|
154
154
|
});
|
|
155
155
|
describe('callfunc operator', () => {
|
|
@@ -160,7 +160,7 @@ describe('parser', () => {
|
|
|
160
160
|
node@.doSomething(1, 2)
|
|
161
161
|
end sub
|
|
162
162
|
`, Parser_1.ParseMode.BrightScript);
|
|
163
|
-
(0,
|
|
163
|
+
(0, chai_config_spec_1.expect)((_a = parser.diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.bsFeatureNotSupportedInBrsFiles('callfunc operator').message);
|
|
164
164
|
});
|
|
165
165
|
it('does not cause parse errors', () => {
|
|
166
166
|
var _a, _b, _c, _d, _e;
|
|
@@ -169,8 +169,8 @@ describe('parser', () => {
|
|
|
169
169
|
node@.doSomething(1, 2)
|
|
170
170
|
end sub
|
|
171
171
|
`, Parser_1.ParseMode.BrighterScript);
|
|
172
|
-
(0,
|
|
173
|
-
(0,
|
|
172
|
+
(0, chai_config_spec_1.expect)((_a = parser.diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
173
|
+
(0, chai_config_spec_1.expect)((_e = (_d = (_c = (_b = parser.statements[0]) === null || _b === void 0 ? void 0 : _b.func) === null || _c === void 0 ? void 0 : _c.body) === null || _d === void 0 ? void 0 : _d.statements[0]) === null || _e === void 0 ? void 0 : _e.expression).to.be.instanceof(Expression_1.CallfuncExpression);
|
|
174
174
|
});
|
|
175
175
|
});
|
|
176
176
|
describe('optional chaining operator', () => {
|
|
@@ -187,50 +187,50 @@ describe('parser', () => {
|
|
|
187
187
|
}
|
|
188
188
|
it('works for ?.', () => {
|
|
189
189
|
const expression = getExpression(`value = person?.name`);
|
|
190
|
-
(0,
|
|
191
|
-
(0,
|
|
190
|
+
(0, chai_config_spec_1.expect)(expression).to.be.instanceOf(Expression_1.DottedGetExpression);
|
|
191
|
+
(0, chai_config_spec_1.expect)(expression.dot.kind).to.eql(TokenKind_1.TokenKind.QuestionDot);
|
|
192
192
|
});
|
|
193
193
|
it('works for ?[', () => {
|
|
194
194
|
const expression = getExpression(`value = person?["name"]`, { matcher: reflection_1.isIndexedGetExpression });
|
|
195
|
-
(0,
|
|
196
|
-
(0,
|
|
197
|
-
(0,
|
|
195
|
+
(0, chai_config_spec_1.expect)(expression).to.be.instanceOf(Expression_1.IndexedGetExpression);
|
|
196
|
+
(0, chai_config_spec_1.expect)(expression.openingSquare.kind).to.eql(TokenKind_1.TokenKind.QuestionLeftSquare);
|
|
197
|
+
(0, chai_config_spec_1.expect)(expression.questionDotToken).not.to.exist;
|
|
198
198
|
});
|
|
199
199
|
it('works for ?.[', () => {
|
|
200
200
|
var _a;
|
|
201
201
|
const expression = getExpression(`value = person?.["name"]`, { matcher: reflection_1.isIndexedGetExpression });
|
|
202
|
-
(0,
|
|
203
|
-
(0,
|
|
204
|
-
(0,
|
|
202
|
+
(0, chai_config_spec_1.expect)(expression).to.be.instanceOf(Expression_1.IndexedGetExpression);
|
|
203
|
+
(0, chai_config_spec_1.expect)(expression.openingSquare.kind).to.eql(TokenKind_1.TokenKind.LeftSquareBracket);
|
|
204
|
+
(0, chai_config_spec_1.expect)((_a = expression.questionDotToken) === null || _a === void 0 ? void 0 : _a.kind).to.eql(TokenKind_1.TokenKind.QuestionDot);
|
|
205
205
|
});
|
|
206
206
|
it('works for ?@', () => {
|
|
207
207
|
const expression = getExpression(`value = someXml?@someAttr`);
|
|
208
|
-
(0,
|
|
209
|
-
(0,
|
|
208
|
+
(0, chai_config_spec_1.expect)(expression).to.be.instanceOf(Expression_1.XmlAttributeGetExpression);
|
|
209
|
+
(0, chai_config_spec_1.expect)(expression.at.kind).to.eql(TokenKind_1.TokenKind.QuestionAt);
|
|
210
210
|
});
|
|
211
211
|
it('works for ?(', () => {
|
|
212
212
|
const expression = getExpression(`value = person.getName?()`);
|
|
213
|
-
(0,
|
|
214
|
-
(0,
|
|
213
|
+
(0, chai_config_spec_1.expect)(expression).to.be.instanceOf(Expression_1.CallExpression);
|
|
214
|
+
(0, chai_config_spec_1.expect)(expression.openingParen.kind).to.eql(TokenKind_1.TokenKind.QuestionLeftParen);
|
|
215
215
|
});
|
|
216
216
|
it('works for print statements using question mark', () => {
|
|
217
217
|
const { statements } = parse(`
|
|
218
218
|
?[1]
|
|
219
219
|
?(1+1)
|
|
220
220
|
`);
|
|
221
|
-
(0,
|
|
222
|
-
(0,
|
|
221
|
+
(0, chai_config_spec_1.expect)(statements[0]).to.be.instanceOf(Statement_1.PrintStatement);
|
|
222
|
+
(0, chai_config_spec_1.expect)(statements[1]).to.be.instanceOf(Statement_1.PrintStatement);
|
|
223
223
|
});
|
|
224
224
|
//TODO enable this once we properly parse IIFEs
|
|
225
225
|
it.skip('works for ?( in anonymous function', () => {
|
|
226
226
|
const expression = getExpression(`thing = (function() : end function)?()`);
|
|
227
|
-
(0,
|
|
228
|
-
(0,
|
|
227
|
+
(0, chai_config_spec_1.expect)(expression).to.be.instanceOf(Expression_1.CallExpression);
|
|
228
|
+
(0, chai_config_spec_1.expect)(expression.openingParen.kind).to.eql(TokenKind_1.TokenKind.QuestionLeftParen);
|
|
229
229
|
});
|
|
230
230
|
it('works for ?( in new call', () => {
|
|
231
231
|
const expression = getExpression(`thing = new Person?()`, { parseMode: Parser_1.ParseMode.BrighterScript });
|
|
232
|
-
(0,
|
|
233
|
-
(0,
|
|
232
|
+
(0, chai_config_spec_1.expect)(expression).to.be.instanceOf(Expression_1.NewExpression);
|
|
233
|
+
(0, chai_config_spec_1.expect)(expression.call.openingParen.kind).to.eql(TokenKind_1.TokenKind.QuestionLeftParen);
|
|
234
234
|
});
|
|
235
235
|
it('distinguishes between optional chaining and ternary expression', () => {
|
|
236
236
|
const parser = parse(`
|
|
@@ -240,8 +240,8 @@ describe('parser', () => {
|
|
|
240
240
|
key = isTrue ? ["name"] : ["age"]
|
|
241
241
|
end sub
|
|
242
242
|
`, Parser_1.ParseMode.BrighterScript);
|
|
243
|
-
(0,
|
|
244
|
-
(0,
|
|
243
|
+
(0, chai_config_spec_1.expect)(parser.references.assignmentStatements[0].value).is.instanceof(Expression_1.IndexedGetExpression);
|
|
244
|
+
(0, chai_config_spec_1.expect)(parser.references.assignmentStatements[2].value).is.instanceof(Expression_1.TernaryExpression);
|
|
245
245
|
});
|
|
246
246
|
it('distinguishes between optional chaining and ternary expression', () => {
|
|
247
247
|
const parser = parse(`
|
|
@@ -252,13 +252,13 @@ describe('parser', () => {
|
|
|
252
252
|
key = isTrue ? ["name"] : getDefault()
|
|
253
253
|
end sub
|
|
254
254
|
`, Parser_1.ParseMode.BrighterScript);
|
|
255
|
-
(0,
|
|
256
|
-
(0,
|
|
255
|
+
(0, chai_config_spec_1.expect)(parser.references.assignmentStatements[0].value).is.instanceof(Expression_1.IndexedGetExpression);
|
|
256
|
+
(0, chai_config_spec_1.expect)(parser.references.assignmentStatements[1].value).is.instanceof(Expression_1.TernaryExpression);
|
|
257
257
|
});
|
|
258
258
|
});
|
|
259
259
|
describe('diagnostic locations', () => {
|
|
260
260
|
it('tracks basic diagnostic locations', () => {
|
|
261
|
-
(0,
|
|
261
|
+
(0, chai_config_spec_1.expect)(parse(`
|
|
262
262
|
sub main()
|
|
263
263
|
call()a
|
|
264
264
|
end sub
|
|
@@ -274,8 +274,8 @@ describe('parser', () => {
|
|
|
274
274
|
return "6c5cdf1"
|
|
275
275
|
end functionasdf
|
|
276
276
|
`).diagnostics;
|
|
277
|
-
(0,
|
|
278
|
-
(0,
|
|
277
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).to.exist.and.to.eql(DiagnosticMessages_1.DiagnosticMessages.expectedStatementOrFunctionCallButReceivedExpression().message);
|
|
278
|
+
(0, chai_config_spec_1.expect)((_b = diagnostics[0]) === null || _b === void 0 ? void 0 : _b.range).to.eql(vscode_languageserver_1.Range.create(3, 20, 3, 32));
|
|
279
279
|
});
|
|
280
280
|
});
|
|
281
281
|
describe('parse', () => {
|
|
@@ -312,20 +312,28 @@ describe('parser', () => {
|
|
|
312
312
|
});
|
|
313
313
|
it('supports using "interface" as parameter name', () => {
|
|
314
314
|
var _a;
|
|
315
|
-
(0,
|
|
315
|
+
(0, chai_config_spec_1.expect)((_a = parse(`
|
|
316
316
|
sub main(interface as object)
|
|
317
317
|
end sub
|
|
318
318
|
`, Parser_1.ParseMode.BrighterScript).diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
319
319
|
});
|
|
320
320
|
describe('namespace', () => {
|
|
321
|
-
it('
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
321
|
+
it('allows namespaces declared inside other namespaces', () => {
|
|
322
|
+
const parser = parse(`
|
|
323
|
+
namespace Level1
|
|
324
|
+
namespace Level2.Level3
|
|
325
|
+
sub main()
|
|
326
|
+
end sub
|
|
326
327
|
end namespace
|
|
327
|
-
end
|
|
328
|
-
`, Parser_1.ParseMode.BrighterScript)
|
|
328
|
+
end namespace
|
|
329
|
+
`, Parser_1.ParseMode.BrighterScript);
|
|
330
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(parser);
|
|
331
|
+
// We expect these names to be "as given" in this context, because we aren't
|
|
332
|
+
// evaluating a full program.
|
|
333
|
+
(0, chai_config_spec_1.expect)(parser.references.namespaceStatements.map(statement => statement.getName(Parser_1.ParseMode.BrighterScript))).to.deep.equal([
|
|
334
|
+
'Level2.Level3',
|
|
335
|
+
'Level1'
|
|
336
|
+
]);
|
|
329
337
|
});
|
|
330
338
|
it('parses empty namespace', () => {
|
|
331
339
|
var _a;
|
|
@@ -333,8 +341,8 @@ describe('parser', () => {
|
|
|
333
341
|
namespace Name.Space
|
|
334
342
|
end namespace
|
|
335
343
|
`, Parser_1.ParseMode.BrighterScript);
|
|
336
|
-
(0,
|
|
337
|
-
(0,
|
|
344
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
345
|
+
(0, chai_config_spec_1.expect)(statements[0]).to.be.instanceof(Statement_1.NamespaceStatement);
|
|
338
346
|
});
|
|
339
347
|
it('includes body', () => {
|
|
340
348
|
var _a;
|
|
@@ -344,9 +352,9 @@ describe('parser', () => {
|
|
|
344
352
|
end sub
|
|
345
353
|
end namespace
|
|
346
354
|
`, Parser_1.ParseMode.BrighterScript);
|
|
347
|
-
(0,
|
|
348
|
-
(0,
|
|
349
|
-
(0,
|
|
355
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
356
|
+
(0, chai_config_spec_1.expect)(statements[0]).to.be.instanceof(Statement_1.NamespaceStatement);
|
|
357
|
+
(0, chai_config_spec_1.expect)(statements[0].body.statements[0]).to.be.instanceof(Statement_1.FunctionStatement);
|
|
350
358
|
});
|
|
351
359
|
it('supports comments and newlines', () => {
|
|
352
360
|
var _a;
|
|
@@ -362,7 +370,7 @@ describe('parser', () => {
|
|
|
362
370
|
'comment
|
|
363
371
|
end namespace 'comment
|
|
364
372
|
`, Parser_1.ParseMode.BrighterScript);
|
|
365
|
-
(0,
|
|
373
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
366
374
|
});
|
|
367
375
|
it('catches missing name', () => {
|
|
368
376
|
var _a;
|
|
@@ -370,7 +378,7 @@ describe('parser', () => {
|
|
|
370
378
|
namespace
|
|
371
379
|
end namespace
|
|
372
380
|
`, Parser_1.ParseMode.BrighterScript);
|
|
373
|
-
(0,
|
|
381
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.expectedIdentifierAfterKeyword('namespace').message);
|
|
374
382
|
});
|
|
375
383
|
it('recovers after missing `end namespace`', () => {
|
|
376
384
|
var _a, _b, _c;
|
|
@@ -379,9 +387,9 @@ describe('parser', () => {
|
|
|
379
387
|
sub main()
|
|
380
388
|
end sub
|
|
381
389
|
`, Parser_1.ParseMode.BrighterScript);
|
|
382
|
-
(0,
|
|
383
|
-
(0,
|
|
384
|
-
(0,
|
|
390
|
+
(0, chai_config_spec_1.expect)(parser.ast.statements[0]).to.be.instanceof(Statement_1.NamespaceStatement);
|
|
391
|
+
(0, chai_config_spec_1.expect)((_a = parser.diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.couldNotFindMatchingEndKeyword('namespace').message);
|
|
392
|
+
(0, chai_config_spec_1.expect)((_c = (_b = parser.ast.statements[0]) === null || _b === void 0 ? void 0 : _b.body) === null || _c === void 0 ? void 0 : _c.statements[0]).to.be.instanceof(Statement_1.FunctionStatement);
|
|
385
393
|
});
|
|
386
394
|
it('adds diagnostic when encountering namespace in brightscript mode', () => {
|
|
387
395
|
var _a;
|
|
@@ -389,12 +397,12 @@ describe('parser', () => {
|
|
|
389
397
|
namespace Name.Space
|
|
390
398
|
end namespace
|
|
391
399
|
`);
|
|
392
|
-
(0,
|
|
400
|
+
(0, chai_config_spec_1.expect)((_a = parser.diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.bsFeatureNotSupportedInBrsFiles('namespace').message);
|
|
393
401
|
});
|
|
394
402
|
});
|
|
395
403
|
it('supports << operator', () => {
|
|
396
404
|
var _a;
|
|
397
|
-
(0,
|
|
405
|
+
(0, chai_config_spec_1.expect)((_a = parse(`
|
|
398
406
|
sub main()
|
|
399
407
|
print ((r << 24) + (g << 16) + (b << 8) + a)
|
|
400
408
|
end sub
|
|
@@ -402,7 +410,7 @@ describe('parser', () => {
|
|
|
402
410
|
});
|
|
403
411
|
it('supports >> operator', () => {
|
|
404
412
|
var _a;
|
|
405
|
-
(0,
|
|
413
|
+
(0, chai_config_spec_1.expect)((_a = parse(`
|
|
406
414
|
sub main()
|
|
407
415
|
print ((r >> 24) + (g >> 16) + (b >> 8) + a)
|
|
408
416
|
end sub
|
|
@@ -410,7 +418,7 @@ describe('parser', () => {
|
|
|
410
418
|
});
|
|
411
419
|
it('allows global function names with same as token to be called', () => {
|
|
412
420
|
var _a;
|
|
413
|
-
(0,
|
|
421
|
+
(0, chai_config_spec_1.expect)((_a = parse(`
|
|
414
422
|
sub main()
|
|
415
423
|
print string(123)
|
|
416
424
|
end sub
|
|
@@ -424,18 +432,18 @@ describe('parser', () => {
|
|
|
424
432
|
age = personXml.firstChild@age
|
|
425
433
|
end sub
|
|
426
434
|
`);
|
|
427
|
-
(0,
|
|
435
|
+
(0, chai_config_spec_1.expect)((_a = parser.diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).to.not.exist;
|
|
428
436
|
let statements = parser.statements[0].func.body.statements;
|
|
429
437
|
let first = statements[0].value;
|
|
430
|
-
(0,
|
|
431
|
-
(0,
|
|
432
|
-
(0,
|
|
433
|
-
(0,
|
|
438
|
+
(0, chai_config_spec_1.expect)(first).to.be.instanceof(Expression_1.XmlAttributeGetExpression);
|
|
439
|
+
(0, chai_config_spec_1.expect)(first.name.text).to.equal('firstName');
|
|
440
|
+
(0, chai_config_spec_1.expect)(first.at.text).to.equal('@');
|
|
441
|
+
(0, chai_config_spec_1.expect)(first.obj.name.text).to.equal('personXml');
|
|
434
442
|
let second = statements[1].value;
|
|
435
|
-
(0,
|
|
436
|
-
(0,
|
|
437
|
-
(0,
|
|
438
|
-
(0,
|
|
443
|
+
(0, chai_config_spec_1.expect)(second).to.be.instanceof(Expression_1.XmlAttributeGetExpression);
|
|
444
|
+
(0, chai_config_spec_1.expect)(second.name.text).to.equal('age');
|
|
445
|
+
(0, chai_config_spec_1.expect)(second.at.text).to.equal('@');
|
|
446
|
+
(0, chai_config_spec_1.expect)(second.obj.name.text).to.equal('firstChild');
|
|
439
447
|
});
|
|
440
448
|
it('does not allow chaining of @ symbols', () => {
|
|
441
449
|
let parser = parse(`
|
|
@@ -444,58 +452,58 @@ describe('parser', () => {
|
|
|
444
452
|
name = personXml@name@age@shoeSize
|
|
445
453
|
end sub
|
|
446
454
|
`);
|
|
447
|
-
(0,
|
|
455
|
+
(0, chai_config_spec_1.expect)(parser.diagnostics).not.to.be.empty;
|
|
448
456
|
});
|
|
449
457
|
it('unknown function type does not invalidate rest of function', () => {
|
|
450
458
|
let { statements, diagnostics } = parse(`
|
|
451
459
|
function log() as UNKNOWN_TYPE
|
|
452
460
|
end function
|
|
453
461
|
`, Parser_1.ParseMode.BrightScript);
|
|
454
|
-
(0,
|
|
455
|
-
(0,
|
|
462
|
+
(0, chai_config_spec_1.expect)(diagnostics.length).to.be.greaterThan(0);
|
|
463
|
+
(0, chai_config_spec_1.expect)(statements[0]).to.exist;
|
|
456
464
|
});
|
|
457
465
|
it('unknown function type is not a problem in Brighterscript mode', () => {
|
|
458
466
|
let { statements, diagnostics } = parse(`
|
|
459
467
|
function log() as UNKNOWN_TYPE
|
|
460
468
|
end function
|
|
461
469
|
`, Parser_1.ParseMode.BrighterScript);
|
|
462
|
-
(0,
|
|
463
|
-
(0,
|
|
470
|
+
(0, chai_config_spec_1.expect)(diagnostics.length).to.equal(0);
|
|
471
|
+
(0, chai_config_spec_1.expect)(statements[0]).to.exist;
|
|
464
472
|
});
|
|
465
473
|
it('allows namespaced function type in Brighterscript mode', () => {
|
|
466
474
|
let { statements, diagnostics } = parse(`
|
|
467
475
|
function log() as SOME_NAMESPACE.UNKNOWN_TYPE
|
|
468
476
|
end function
|
|
469
477
|
`, Parser_1.ParseMode.BrighterScript);
|
|
470
|
-
(0,
|
|
471
|
-
(0,
|
|
478
|
+
(0, chai_config_spec_1.expect)(diagnostics.length).to.equal(0);
|
|
479
|
+
(0, chai_config_spec_1.expect)(statements[0]).to.exist;
|
|
472
480
|
});
|
|
473
481
|
it('allows custom parameter types in BrighterscriptMode', () => {
|
|
474
482
|
let { statements, diagnostics } = parse(`
|
|
475
483
|
sub foo(value as UNKNOWN_TYPE)
|
|
476
484
|
end sub
|
|
477
485
|
`, Parser_1.ParseMode.BrighterScript);
|
|
478
|
-
(0,
|
|
479
|
-
(0,
|
|
486
|
+
(0, chai_config_spec_1.expect)(diagnostics.length).to.equal(0);
|
|
487
|
+
(0, chai_config_spec_1.expect)(statements[0]).to.exist;
|
|
480
488
|
});
|
|
481
489
|
it('does not allow custom parameter types in Brightscript Mode', () => {
|
|
482
490
|
let { diagnostics } = parse(`
|
|
483
491
|
sub foo(value as UNKNOWN_TYPE)
|
|
484
492
|
end sub
|
|
485
493
|
`, Parser_1.ParseMode.BrightScript);
|
|
486
|
-
(0,
|
|
494
|
+
(0, chai_config_spec_1.expect)(diagnostics.length).not.to.equal(0);
|
|
487
495
|
});
|
|
488
496
|
it('allows custom namespaced parameter types in BrighterscriptMode', () => {
|
|
489
497
|
let { statements, diagnostics } = parse(`
|
|
490
498
|
sub foo(value as SOME_NAMESPACE.UNKNOWN_TYPE)
|
|
491
499
|
end sub
|
|
492
500
|
`, Parser_1.ParseMode.BrighterScript);
|
|
493
|
-
(0,
|
|
494
|
-
(0,
|
|
501
|
+
(0, chai_config_spec_1.expect)(diagnostics.length).to.equal(0);
|
|
502
|
+
(0, chai_config_spec_1.expect)(statements[0]).to.exist;
|
|
495
503
|
});
|
|
496
504
|
it('works with conditionals', () => {
|
|
497
505
|
var _a;
|
|
498
|
-
(0,
|
|
506
|
+
(0, chai_config_spec_1.expect)((_a = parse(`
|
|
499
507
|
function printNumber()
|
|
500
508
|
if true then
|
|
501
509
|
print 1
|
|
@@ -507,7 +515,7 @@ describe('parser', () => {
|
|
|
507
515
|
});
|
|
508
516
|
it('supports single-line if statements', () => {
|
|
509
517
|
var _a;
|
|
510
|
-
(0,
|
|
518
|
+
(0, chai_config_spec_1.expect)((_a = parse(`If true Then print "error" : Stop`).diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).to.not.exist;
|
|
511
519
|
});
|
|
512
520
|
it('works with excess newlines', () => {
|
|
513
521
|
var _a;
|
|
@@ -520,7 +528,7 @@ describe('parser', () => {
|
|
|
520
528
|
' print 1\n\n' +
|
|
521
529
|
' end if\n\n' +
|
|
522
530
|
'end function\n\n');
|
|
523
|
-
(0,
|
|
531
|
+
(0, chai_config_spec_1.expect)((_a = Parser_1.Parser.parse(tokens).diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).to.not.exist;
|
|
524
532
|
});
|
|
525
533
|
it('does not invalidate entire file when line ends with a period', () => {
|
|
526
534
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -530,15 +538,15 @@ describe('parser', () => {
|
|
|
530
538
|
|
|
531
539
|
`);
|
|
532
540
|
let { diagnostics } = Parser_1.Parser.parse(tokens);
|
|
533
|
-
(0,
|
|
541
|
+
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(1, 'Error count should be 0');
|
|
534
542
|
});
|
|
535
543
|
it.skip('allows printing object with trailing period', () => {
|
|
536
544
|
let { tokens } = Lexer_1.Lexer.scan(`print a.`);
|
|
537
545
|
let { statements, diagnostics } = Parser_1.Parser.parse(tokens);
|
|
538
546
|
let printStatement = statements[0];
|
|
539
|
-
(0,
|
|
540
|
-
(0,
|
|
541
|
-
(0,
|
|
547
|
+
(0, chai_config_spec_1.expect)(diagnostics).to.be.empty;
|
|
548
|
+
(0, chai_config_spec_1.expect)(printStatement).to.be.instanceof(Statement_1.PrintStatement);
|
|
549
|
+
(0, chai_config_spec_1.expect)(printStatement.expressions[0]).to.be.instanceof(Expression_1.DottedGetExpression);
|
|
542
550
|
});
|
|
543
551
|
describe('comments', () => {
|
|
544
552
|
it('combines multi-line comments', () => {
|
|
@@ -548,8 +556,8 @@ describe('parser', () => {
|
|
|
548
556
|
'line 3
|
|
549
557
|
`);
|
|
550
558
|
let { diagnostics, statements } = Parser_1.Parser.parse(tokens);
|
|
551
|
-
(0,
|
|
552
|
-
(0,
|
|
559
|
+
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(0, 'Error count should be 0');
|
|
560
|
+
(0, chai_config_spec_1.expect)(statements[0].text).to.equal(`'line 1\n'line 2\n'line 3`);
|
|
553
561
|
});
|
|
554
562
|
it('does not combile comments separated by newlines', () => {
|
|
555
563
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -560,11 +568,11 @@ describe('parser', () => {
|
|
|
560
568
|
'line 3
|
|
561
569
|
`);
|
|
562
570
|
let { diagnostics, statements } = Parser_1.Parser.parse(tokens);
|
|
563
|
-
(0,
|
|
564
|
-
(0,
|
|
565
|
-
(0,
|
|
566
|
-
(0,
|
|
567
|
-
(0,
|
|
571
|
+
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(0, 'Error count should be 0');
|
|
572
|
+
(0, chai_config_spec_1.expect)(statements).to.be.lengthOf(3);
|
|
573
|
+
(0, chai_config_spec_1.expect)(statements[0].text).to.equal(`'line 1`);
|
|
574
|
+
(0, chai_config_spec_1.expect)(statements[1].text).to.equal(`'line 2`);
|
|
575
|
+
(0, chai_config_spec_1.expect)(statements[2].text).to.equal(`'line 3`);
|
|
568
576
|
});
|
|
569
577
|
it('works after print statement', () => {
|
|
570
578
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -573,8 +581,8 @@ describe('parser', () => {
|
|
|
573
581
|
end sub
|
|
574
582
|
`);
|
|
575
583
|
let { diagnostics, statements } = Parser_1.Parser.parse(tokens);
|
|
576
|
-
(0,
|
|
577
|
-
(0,
|
|
584
|
+
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(0, 'Error count should be 0');
|
|
585
|
+
(0, chai_config_spec_1.expect)(statements[0].func.body.statements[1].text).to.equal(`'comment 1`);
|
|
578
586
|
});
|
|
579
587
|
it('declaration-level', () => {
|
|
580
588
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -584,9 +592,9 @@ describe('parser', () => {
|
|
|
584
592
|
'comment 2
|
|
585
593
|
`);
|
|
586
594
|
let { diagnostics, statements } = Parser_1.Parser.parse(tokens);
|
|
587
|
-
(0,
|
|
588
|
-
(0,
|
|
589
|
-
(0,
|
|
595
|
+
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(0, 'Error count should be 0');
|
|
596
|
+
(0, chai_config_spec_1.expect)(statements[0].text).to.equal(`'comment 1`);
|
|
597
|
+
(0, chai_config_spec_1.expect)(statements[2].text).to.equal(`'comment 2`);
|
|
590
598
|
});
|
|
591
599
|
it('works in aa literal as its own statement', () => {
|
|
592
600
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -596,7 +604,7 @@ describe('parser', () => {
|
|
|
596
604
|
}
|
|
597
605
|
`);
|
|
598
606
|
let { diagnostics } = Parser_1.Parser.parse(tokens);
|
|
599
|
-
(0,
|
|
607
|
+
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(0, 'Error count should be 0');
|
|
600
608
|
});
|
|
601
609
|
it('parses after function call', () => {
|
|
602
610
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -606,8 +614,8 @@ describe('parser', () => {
|
|
|
606
614
|
end sub
|
|
607
615
|
`);
|
|
608
616
|
let { diagnostics, statements } = Parser_1.Parser.parse(tokens);
|
|
609
|
-
(0,
|
|
610
|
-
(0,
|
|
617
|
+
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(0, 'Should have zero diagnostics');
|
|
618
|
+
(0, chai_config_spec_1.expect)(statements[0].func.body.statements[2].text).to.equal(`'comment 1`);
|
|
611
619
|
});
|
|
612
620
|
it('function', () => {
|
|
613
621
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -618,11 +626,11 @@ describe('parser', () => {
|
|
|
618
626
|
end function 'comment 4
|
|
619
627
|
`);
|
|
620
628
|
let { diagnostics, statements } = Parser_1.Parser.parse(tokens);
|
|
621
|
-
(0,
|
|
622
|
-
(0,
|
|
623
|
-
(0,
|
|
624
|
-
(0,
|
|
625
|
-
(0,
|
|
629
|
+
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(0, 'Should have zero diagnostics');
|
|
630
|
+
(0, chai_config_spec_1.expect)(statements[0].func.body.statements[0].text).to.equal(`'comment 1`);
|
|
631
|
+
(0, chai_config_spec_1.expect)(statements[0].func.body.statements[1].text).to.equal(`'comment 2`);
|
|
632
|
+
(0, chai_config_spec_1.expect)(statements[0].func.body.statements[3].text).to.equal(`'comment 3`);
|
|
633
|
+
(0, chai_config_spec_1.expect)(statements[1].text).to.equal(`'comment 4`);
|
|
626
634
|
});
|
|
627
635
|
it('if statement`', () => {
|
|
628
636
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -643,7 +651,7 @@ describe('parser', () => {
|
|
|
643
651
|
end function
|
|
644
652
|
`);
|
|
645
653
|
let { diagnostics, statements } = Parser_1.Parser.parse(tokens);
|
|
646
|
-
(0,
|
|
654
|
+
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(0, 'Should have zero diagnostics');
|
|
647
655
|
let fnSmt = statements[0];
|
|
648
656
|
if ((0, reflection_1.isFunctionStatement)(fnSmt)) {
|
|
649
657
|
let ifStmt = fnSmt.func.body.statements[0];
|
|
@@ -690,12 +698,12 @@ describe('parser', () => {
|
|
|
690
698
|
end function
|
|
691
699
|
`);
|
|
692
700
|
let { diagnostics, statements } = Parser_1.Parser.parse(tokens);
|
|
693
|
-
(0,
|
|
701
|
+
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(0, 'Error count should be zero');
|
|
694
702
|
let stmt = statements[0].func.body.statements[0];
|
|
695
|
-
(0,
|
|
696
|
-
(0,
|
|
697
|
-
(0,
|
|
698
|
-
(0,
|
|
703
|
+
(0, chai_config_spec_1.expect)(stmt.body.statements[0].text).to.equal(`'comment 1`);
|
|
704
|
+
(0, chai_config_spec_1.expect)(stmt.body.statements[1].text).to.equal(`'comment 2`);
|
|
705
|
+
(0, chai_config_spec_1.expect)(stmt.body.statements[3].text).to.equal(`'comment 3`);
|
|
706
|
+
(0, chai_config_spec_1.expect)(statements[0].func.body.statements[1].text).to.equal(`'comment 4`);
|
|
699
707
|
});
|
|
700
708
|
it('for', () => {
|
|
701
709
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -708,12 +716,12 @@ describe('parser', () => {
|
|
|
708
716
|
end function
|
|
709
717
|
`);
|
|
710
718
|
let { diagnostics, statements } = Parser_1.Parser.parse(tokens);
|
|
711
|
-
(0,
|
|
719
|
+
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(0, 'Error count should be zero');
|
|
712
720
|
let stmt = statements[0].func.body.statements[0];
|
|
713
|
-
(0,
|
|
714
|
-
(0,
|
|
715
|
-
(0,
|
|
716
|
-
(0,
|
|
721
|
+
(0, chai_config_spec_1.expect)(stmt.body.statements[0].text).to.equal(`'comment 1`);
|
|
722
|
+
(0, chai_config_spec_1.expect)(stmt.body.statements[1].text).to.equal(`'comment 2`);
|
|
723
|
+
(0, chai_config_spec_1.expect)(stmt.body.statements[3].text).to.equal(`'comment 3`);
|
|
724
|
+
(0, chai_config_spec_1.expect)(statements[0].func.body.statements[1].text).to.equal(`'comment 4`);
|
|
717
725
|
});
|
|
718
726
|
it('for each', () => {
|
|
719
727
|
let { tokens } = Lexer_1.Lexer.scan(`
|
|
@@ -726,12 +734,12 @@ describe('parser', () => {
|
|
|
726
734
|
end function
|
|
727
735
|
`);
|
|
728
736
|
let { diagnostics, statements } = Parser_1.Parser.parse(tokens);
|
|
729
|
-
(0,
|
|
737
|
+
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(0, 'Error count should be zero');
|
|
730
738
|
let stmt = statements[0].func.body.statements[0];
|
|
731
|
-
(0,
|
|
732
|
-
(0,
|
|
733
|
-
(0,
|
|
734
|
-
(0,
|
|
739
|
+
(0, chai_config_spec_1.expect)(stmt.body.statements[0].text).to.equal(`'comment 1`);
|
|
740
|
+
(0, chai_config_spec_1.expect)(stmt.body.statements[1].text).to.equal(`'comment 2`);
|
|
741
|
+
(0, chai_config_spec_1.expect)(stmt.body.statements[3].text).to.equal(`'comment 3`);
|
|
742
|
+
(0, chai_config_spec_1.expect)(statements[0].func.body.statements[1].text).to.equal(`'comment 4`);
|
|
735
743
|
});
|
|
736
744
|
});
|
|
737
745
|
});
|
|
@@ -743,7 +751,7 @@ describe('parser', () => {
|
|
|
743
751
|
then = true
|
|
744
752
|
end sub
|
|
745
753
|
`);
|
|
746
|
-
(0,
|
|
754
|
+
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(1);
|
|
747
755
|
});
|
|
748
756
|
it('is allowed as an AA property name', () => {
|
|
749
757
|
var _a;
|
|
@@ -756,7 +764,7 @@ describe('parser', () => {
|
|
|
756
764
|
print person.then
|
|
757
765
|
end sub
|
|
758
766
|
`);
|
|
759
|
-
(0,
|
|
767
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
760
768
|
});
|
|
761
769
|
it('allows `mod` as an AA literal property', () => {
|
|
762
770
|
const parser = parse(`
|
|
@@ -788,7 +796,7 @@ describe('parser', () => {
|
|
|
788
796
|
}), {
|
|
789
797
|
walkMode: visitors_1.WalkMode.visitAllRecursive
|
|
790
798
|
});
|
|
791
|
-
(0,
|
|
799
|
+
(0, chai_config_spec_1.expect)(elements.map(x => x.keyToken.kind)).to.eql([TokenKind_1.TokenKind.Identifier, TokenKind_1.TokenKind.Identifier]);
|
|
792
800
|
});
|
|
793
801
|
});
|
|
794
802
|
it('"end" is not allowed as a local identifier', () => {
|
|
@@ -797,7 +805,7 @@ describe('parser', () => {
|
|
|
797
805
|
end = true
|
|
798
806
|
end sub
|
|
799
807
|
`);
|
|
800
|
-
(0,
|
|
808
|
+
(0, chai_config_spec_1.expect)(diagnostics).to.be.length.greaterThan(0);
|
|
801
809
|
});
|
|
802
810
|
it('none of them can be used as local variables', () => {
|
|
803
811
|
let reservedWords = new Set(TokenKind_1.ReservedWords);
|
|
@@ -810,7 +818,7 @@ describe('parser', () => {
|
|
|
810
818
|
end sub
|
|
811
819
|
`);
|
|
812
820
|
let { diagnostics } = Parser_1.Parser.parse(tokens);
|
|
813
|
-
(0,
|
|
821
|
+
(0, chai_config_spec_1.expect)(diagnostics, `assigning to reserved word "${reservedWord}" should have been an error`).to.be.length.greaterThan(0);
|
|
814
822
|
}
|
|
815
823
|
});
|
|
816
824
|
});
|
|
@@ -820,24 +828,24 @@ describe('parser', () => {
|
|
|
820
828
|
let { statements, diagnostics } = parse(`
|
|
821
829
|
import "somePath"
|
|
822
830
|
`, Parser_1.ParseMode.BrighterScript);
|
|
823
|
-
(0,
|
|
824
|
-
(0,
|
|
831
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
832
|
+
(0, chai_config_spec_1.expect)(statements[0]).to.be.instanceof(Statement_1.ImportStatement);
|
|
825
833
|
});
|
|
826
834
|
it('catches import statements used in brightscript files', () => {
|
|
827
835
|
var _a;
|
|
828
836
|
let { statements, diagnostics } = parse(`
|
|
829
837
|
import "somePath"
|
|
830
838
|
`, Parser_1.ParseMode.BrightScript);
|
|
831
|
-
(0,
|
|
832
|
-
(0,
|
|
839
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).to.eql(DiagnosticMessages_1.DiagnosticMessages.bsFeatureNotSupportedInBrsFiles('import statements').message);
|
|
840
|
+
(0, chai_config_spec_1.expect)(statements[0]).to.be.instanceof(Statement_1.ImportStatement);
|
|
833
841
|
});
|
|
834
842
|
it('catchs missing file path', () => {
|
|
835
843
|
var _a;
|
|
836
844
|
let { statements, diagnostics } = parse(`
|
|
837
845
|
import
|
|
838
846
|
`, Parser_1.ParseMode.BrighterScript);
|
|
839
|
-
(0,
|
|
840
|
-
(0,
|
|
847
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.expectedStringLiteralAfterKeyword('import').message);
|
|
848
|
+
(0, chai_config_spec_1.expect)(statements[0]).to.be.instanceof(Statement_1.ImportStatement);
|
|
841
849
|
});
|
|
842
850
|
});
|
|
843
851
|
describe('Annotations', () => {
|
|
@@ -848,7 +856,7 @@ describe('parser', () => {
|
|
|
848
856
|
sub main()
|
|
849
857
|
end sub
|
|
850
858
|
`, Parser_1.ParseMode.BrighterScript);
|
|
851
|
-
(0,
|
|
859
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.unexpectedToken('@').message);
|
|
852
860
|
});
|
|
853
861
|
it('properly handles empty annotation above class method', () => {
|
|
854
862
|
var _a;
|
|
@@ -860,7 +868,7 @@ describe('parser', () => {
|
|
|
860
868
|
end sub
|
|
861
869
|
end class
|
|
862
870
|
`, Parser_1.ParseMode.BrighterScript);
|
|
863
|
-
(0,
|
|
871
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.expectedIdentifier().message);
|
|
864
872
|
});
|
|
865
873
|
it('parses with error if annotation is not followed by a statement', () => {
|
|
866
874
|
var _a, _b, _c, _d;
|
|
@@ -874,11 +882,11 @@ describe('parser', () => {
|
|
|
874
882
|
end class
|
|
875
883
|
@meta1
|
|
876
884
|
`, Parser_1.ParseMode.BrighterScript);
|
|
877
|
-
(0,
|
|
878
|
-
(0,
|
|
879
|
-
(0,
|
|
880
|
-
(0,
|
|
881
|
-
(0,
|
|
885
|
+
(0, chai_config_spec_1.expect)(diagnostics.length).to.equal(4);
|
|
886
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.unusedAnnotation().message);
|
|
887
|
+
(0, chai_config_spec_1.expect)((_b = diagnostics[1]) === null || _b === void 0 ? void 0 : _b.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.unusedAnnotation().message);
|
|
888
|
+
(0, chai_config_spec_1.expect)((_c = diagnostics[2]) === null || _c === void 0 ? void 0 : _c.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.unusedAnnotation().message);
|
|
889
|
+
(0, chai_config_spec_1.expect)((_d = diagnostics[3]) === null || _d === void 0 ? void 0 : _d.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.unusedAnnotation().message);
|
|
882
890
|
});
|
|
883
891
|
it('attaches an annotation to next statement', () => {
|
|
884
892
|
var _a;
|
|
@@ -890,18 +898,18 @@ describe('parser', () => {
|
|
|
890
898
|
@meta2 sub init()
|
|
891
899
|
end sub
|
|
892
900
|
`, Parser_1.ParseMode.BrighterScript);
|
|
893
|
-
(0,
|
|
894
|
-
(0,
|
|
901
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
902
|
+
(0, chai_config_spec_1.expect)(statements[0]).to.be.instanceof(Statement_1.FunctionStatement);
|
|
895
903
|
let fn = statements[0];
|
|
896
|
-
(0,
|
|
897
|
-
(0,
|
|
898
|
-
(0,
|
|
899
|
-
(0,
|
|
900
|
-
(0,
|
|
904
|
+
(0, chai_config_spec_1.expect)(fn.annotations).to.exist;
|
|
905
|
+
(0, chai_config_spec_1.expect)(fn.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
906
|
+
(0, chai_config_spec_1.expect)(fn.annotations[0].nameToken.text).to.equal('meta1');
|
|
907
|
+
(0, chai_config_spec_1.expect)(fn.annotations[0].name).to.equal('meta1');
|
|
908
|
+
(0, chai_config_spec_1.expect)(statements[1]).to.be.instanceof(Statement_1.FunctionStatement);
|
|
901
909
|
fn = statements[1];
|
|
902
|
-
(0,
|
|
903
|
-
(0,
|
|
904
|
-
(0,
|
|
910
|
+
(0, chai_config_spec_1.expect)(fn.annotations).to.exist;
|
|
911
|
+
(0, chai_config_spec_1.expect)(fn.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
912
|
+
(0, chai_config_spec_1.expect)(fn.annotations[0].nameToken.text).to.equal('meta2');
|
|
905
913
|
});
|
|
906
914
|
it('attaches annotations inside a function body', () => {
|
|
907
915
|
var _a, _b;
|
|
@@ -911,13 +919,13 @@ describe('parser', () => {
|
|
|
911
919
|
print "hello"
|
|
912
920
|
end function
|
|
913
921
|
`, Parser_1.ParseMode.BrighterScript);
|
|
914
|
-
(0,
|
|
922
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
915
923
|
let fn = statements[0];
|
|
916
924
|
let fnStatements = fn.func.body.statements;
|
|
917
925
|
let stat = fnStatements[0];
|
|
918
|
-
(0,
|
|
919
|
-
(0,
|
|
920
|
-
(0,
|
|
926
|
+
(0, chai_config_spec_1.expect)(stat).to.exist;
|
|
927
|
+
(0, chai_config_spec_1.expect)((_b = stat.annotations) === null || _b === void 0 ? void 0 : _b.length).to.equal(1);
|
|
928
|
+
(0, chai_config_spec_1.expect)(stat.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
921
929
|
});
|
|
922
930
|
it('attaches multiple annotations to next statement', () => {
|
|
923
931
|
var _a;
|
|
@@ -927,14 +935,14 @@ describe('parser', () => {
|
|
|
927
935
|
function main()
|
|
928
936
|
end function
|
|
929
937
|
`, Parser_1.ParseMode.BrighterScript);
|
|
930
|
-
(0,
|
|
931
|
-
(0,
|
|
938
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
939
|
+
(0, chai_config_spec_1.expect)(statements[0]).to.be.instanceof(Statement_1.FunctionStatement);
|
|
932
940
|
let fn = statements[0];
|
|
933
|
-
(0,
|
|
934
|
-
(0,
|
|
935
|
-
(0,
|
|
936
|
-
(0,
|
|
937
|
-
(0,
|
|
941
|
+
(0, chai_config_spec_1.expect)(fn.annotations).to.exist;
|
|
942
|
+
(0, chai_config_spec_1.expect)(fn.annotations.length).to.equal(3);
|
|
943
|
+
(0, chai_config_spec_1.expect)(fn.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
944
|
+
(0, chai_config_spec_1.expect)(fn.annotations[1]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
945
|
+
(0, chai_config_spec_1.expect)(fn.annotations[2]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
938
946
|
});
|
|
939
947
|
it('allows annotations with parameters', () => {
|
|
940
948
|
var _a;
|
|
@@ -943,12 +951,12 @@ describe('parser', () => {
|
|
|
943
951
|
function main()
|
|
944
952
|
end function
|
|
945
953
|
`, Parser_1.ParseMode.BrighterScript);
|
|
946
|
-
(0,
|
|
954
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
947
955
|
let fn = statements[0];
|
|
948
|
-
(0,
|
|
949
|
-
(0,
|
|
950
|
-
(0,
|
|
951
|
-
(0,
|
|
956
|
+
(0, chai_config_spec_1.expect)(fn.annotations).to.exist;
|
|
957
|
+
(0, chai_config_spec_1.expect)(fn.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
958
|
+
(0, chai_config_spec_1.expect)(fn.annotations[0].nameToken.text).to.equal('meta1');
|
|
959
|
+
(0, chai_config_spec_1.expect)(fn.annotations[0].call).to.be.instanceof(Expression_1.CallExpression);
|
|
952
960
|
});
|
|
953
961
|
it('attaches annotations to a class', () => {
|
|
954
962
|
var _a, _b;
|
|
@@ -960,10 +968,10 @@ describe('parser', () => {
|
|
|
960
968
|
end function
|
|
961
969
|
end class
|
|
962
970
|
`, Parser_1.ParseMode.BrighterScript);
|
|
963
|
-
(0,
|
|
971
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
964
972
|
let cs = statements[0];
|
|
965
|
-
(0,
|
|
966
|
-
(0,
|
|
973
|
+
(0, chai_config_spec_1.expect)((_b = cs.annotations) === null || _b === void 0 ? void 0 : _b.length).to.equal(1);
|
|
974
|
+
(0, chai_config_spec_1.expect)(cs.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
967
975
|
});
|
|
968
976
|
it('attaches annotations to multiple clases', () => {
|
|
969
977
|
var _a, _b, _c;
|
|
@@ -981,15 +989,15 @@ describe('parser', () => {
|
|
|
981
989
|
end function
|
|
982
990
|
end class
|
|
983
991
|
`, Parser_1.ParseMode.BrighterScript);
|
|
984
|
-
(0,
|
|
992
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
985
993
|
let cs = statements[0];
|
|
986
|
-
(0,
|
|
987
|
-
(0,
|
|
988
|
-
(0,
|
|
994
|
+
(0, chai_config_spec_1.expect)((_b = cs.annotations) === null || _b === void 0 ? void 0 : _b.length).to.equal(1);
|
|
995
|
+
(0, chai_config_spec_1.expect)(cs.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
996
|
+
(0, chai_config_spec_1.expect)(cs.annotations[0].name).to.equal('meta1');
|
|
989
997
|
let cs2 = statements[1];
|
|
990
|
-
(0,
|
|
991
|
-
(0,
|
|
992
|
-
(0,
|
|
998
|
+
(0, chai_config_spec_1.expect)((_c = cs2.annotations) === null || _c === void 0 ? void 0 : _c.length).to.equal(1);
|
|
999
|
+
(0, chai_config_spec_1.expect)(cs2.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
1000
|
+
(0, chai_config_spec_1.expect)(cs2.annotations[0].name).to.equal('meta2');
|
|
993
1001
|
});
|
|
994
1002
|
it('attaches annotations to a namespaced class', () => {
|
|
995
1003
|
var _a, _b;
|
|
@@ -1003,11 +1011,11 @@ describe('parser', () => {
|
|
|
1003
1011
|
end class
|
|
1004
1012
|
end namespace
|
|
1005
1013
|
`, Parser_1.ParseMode.BrighterScript);
|
|
1006
|
-
(0,
|
|
1014
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
1007
1015
|
let ns = statements[0];
|
|
1008
1016
|
let cs = ns.body.statements[0];
|
|
1009
|
-
(0,
|
|
1010
|
-
(0,
|
|
1017
|
+
(0, chai_config_spec_1.expect)((_b = cs.annotations) === null || _b === void 0 ? void 0 : _b.length).to.equal(1);
|
|
1018
|
+
(0, chai_config_spec_1.expect)(cs.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
1011
1019
|
});
|
|
1012
1020
|
it('attaches annotations to a namespaced class - multiple', () => {
|
|
1013
1021
|
var _a, _b, _c;
|
|
@@ -1027,16 +1035,16 @@ describe('parser', () => {
|
|
|
1027
1035
|
end class
|
|
1028
1036
|
end namespace
|
|
1029
1037
|
`, Parser_1.ParseMode.BrighterScript);
|
|
1030
|
-
(0,
|
|
1038
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
1031
1039
|
let ns = statements[0];
|
|
1032
1040
|
let cs = ns.body.statements[0];
|
|
1033
|
-
(0,
|
|
1034
|
-
(0,
|
|
1035
|
-
(0,
|
|
1041
|
+
(0, chai_config_spec_1.expect)((_b = cs.annotations) === null || _b === void 0 ? void 0 : _b.length).to.equal(1);
|
|
1042
|
+
(0, chai_config_spec_1.expect)(cs.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
1043
|
+
(0, chai_config_spec_1.expect)(cs.annotations[0].name).to.equal('meta1');
|
|
1036
1044
|
let cs2 = ns.body.statements[1];
|
|
1037
|
-
(0,
|
|
1038
|
-
(0,
|
|
1039
|
-
(0,
|
|
1045
|
+
(0, chai_config_spec_1.expect)((_c = cs2.annotations) === null || _c === void 0 ? void 0 : _c.length).to.equal(1);
|
|
1046
|
+
(0, chai_config_spec_1.expect)(cs2.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
1047
|
+
(0, chai_config_spec_1.expect)(cs2.annotations[0].name).to.equal('meta2');
|
|
1040
1048
|
});
|
|
1041
1049
|
it('attaches annotations to a class constructor', () => {
|
|
1042
1050
|
var _a, _b;
|
|
@@ -1051,11 +1059,11 @@ describe('parser', () => {
|
|
|
1051
1059
|
end function
|
|
1052
1060
|
end class
|
|
1053
1061
|
`, Parser_1.ParseMode.BrighterScript);
|
|
1054
|
-
(0,
|
|
1062
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
1055
1063
|
let cs = statements[0];
|
|
1056
1064
|
let stat = cs.body[0];
|
|
1057
|
-
(0,
|
|
1058
|
-
(0,
|
|
1065
|
+
(0, chai_config_spec_1.expect)((_b = stat.annotations) === null || _b === void 0 ? void 0 : _b.length).to.equal(1);
|
|
1066
|
+
(0, chai_config_spec_1.expect)(stat.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
1059
1067
|
});
|
|
1060
1068
|
it('attaches annotations to a class methods', () => {
|
|
1061
1069
|
var _a, _b;
|
|
@@ -1070,11 +1078,11 @@ describe('parser', () => {
|
|
|
1070
1078
|
end function
|
|
1071
1079
|
end class
|
|
1072
1080
|
`, Parser_1.ParseMode.BrighterScript);
|
|
1073
|
-
(0,
|
|
1081
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
1074
1082
|
let cs = statements[0];
|
|
1075
1083
|
let stat = cs.body[1];
|
|
1076
|
-
(0,
|
|
1077
|
-
(0,
|
|
1084
|
+
(0, chai_config_spec_1.expect)((_b = stat.annotations) === null || _b === void 0 ? void 0 : _b.length).to.equal(1);
|
|
1085
|
+
(0, chai_config_spec_1.expect)(stat.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
1078
1086
|
});
|
|
1079
1087
|
it('attaches annotations to a class methods, fields and constructor', () => {
|
|
1080
1088
|
var _a, _b, _c, _d, _e;
|
|
@@ -1098,19 +1106,19 @@ describe('parser', () => {
|
|
|
1098
1106
|
public foo="bar"
|
|
1099
1107
|
end class
|
|
1100
1108
|
`, Parser_1.ParseMode.BrighterScript);
|
|
1101
|
-
(0,
|
|
1109
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
1102
1110
|
let cs = statements[0];
|
|
1103
|
-
(0,
|
|
1104
|
-
(0,
|
|
1111
|
+
(0, chai_config_spec_1.expect)((_b = cs.annotations) === null || _b === void 0 ? void 0 : _b.length).to.equal(2);
|
|
1112
|
+
(0, chai_config_spec_1.expect)(cs.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
1105
1113
|
let stat1 = cs.body[0];
|
|
1106
1114
|
let stat2 = cs.body[1];
|
|
1107
1115
|
let f1 = cs.body[2];
|
|
1108
|
-
(0,
|
|
1109
|
-
(0,
|
|
1110
|
-
(0,
|
|
1111
|
-
(0,
|
|
1112
|
-
(0,
|
|
1113
|
-
(0,
|
|
1116
|
+
(0, chai_config_spec_1.expect)((_c = stat1.annotations) === null || _c === void 0 ? void 0 : _c.length).to.equal(2);
|
|
1117
|
+
(0, chai_config_spec_1.expect)(stat1.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
1118
|
+
(0, chai_config_spec_1.expect)((_d = stat2.annotations) === null || _d === void 0 ? void 0 : _d.length).to.equal(2);
|
|
1119
|
+
(0, chai_config_spec_1.expect)(stat2.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
1120
|
+
(0, chai_config_spec_1.expect)((_e = f1.annotations) === null || _e === void 0 ? void 0 : _e.length).to.equal(2);
|
|
1121
|
+
(0, chai_config_spec_1.expect)(f1.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
1114
1122
|
});
|
|
1115
1123
|
it('ignores annotations on commented out lines', () => {
|
|
1116
1124
|
var _a;
|
|
@@ -1121,9 +1129,9 @@ describe('parser', () => {
|
|
|
1121
1129
|
print "hello"
|
|
1122
1130
|
end function
|
|
1123
1131
|
`, Parser_1.ParseMode.BrighterScript);
|
|
1124
|
-
(0,
|
|
1132
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
1125
1133
|
let cs = statements[0];
|
|
1126
|
-
(0,
|
|
1134
|
+
(0, chai_config_spec_1.expect)(cs.annotations).to.be.undefined;
|
|
1127
1135
|
});
|
|
1128
1136
|
it('can convert argument of an annotation to JS types', () => {
|
|
1129
1137
|
var _a;
|
|
@@ -1141,22 +1149,22 @@ describe('parser', () => {
|
|
|
1141
1149
|
sub init()
|
|
1142
1150
|
end sub
|
|
1143
1151
|
`, Parser_1.ParseMode.BrighterScript);
|
|
1144
|
-
(0,
|
|
1145
|
-
(0,
|
|
1152
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
1153
|
+
(0, chai_config_spec_1.expect)(statements[0]).to.be.instanceof(Statement_1.FunctionStatement);
|
|
1146
1154
|
let fn = statements[0];
|
|
1147
|
-
(0,
|
|
1148
|
-
(0,
|
|
1149
|
-
(0,
|
|
1155
|
+
(0, chai_config_spec_1.expect)(fn.annotations).to.exist;
|
|
1156
|
+
(0, chai_config_spec_1.expect)(fn.annotations[0].getArguments()).to.deep.equal([]);
|
|
1157
|
+
(0, chai_config_spec_1.expect)(statements[1]).to.be.instanceof(Statement_1.FunctionStatement);
|
|
1150
1158
|
fn = statements[1];
|
|
1151
|
-
(0,
|
|
1152
|
-
(0,
|
|
1153
|
-
(0,
|
|
1159
|
+
(0, chai_config_spec_1.expect)(fn.annotations).to.exist;
|
|
1160
|
+
(0, chai_config_spec_1.expect)(fn.annotations[0]).to.be.instanceof(Expression_1.AnnotationExpression);
|
|
1161
|
+
(0, chai_config_spec_1.expect)(fn.annotations[0].getArguments()).to.deep.equal([
|
|
1154
1162
|
'arg', 2, true,
|
|
1155
1163
|
{ prop: 'value' }, [1, 2],
|
|
1156
1164
|
null
|
|
1157
1165
|
]);
|
|
1158
1166
|
let allArgs = fn.annotations[0].getArguments(false);
|
|
1159
|
-
(0,
|
|
1167
|
+
(0, chai_config_spec_1.expect)(allArgs.pop()).to.be.instanceOf(Expression_1.FunctionExpression);
|
|
1160
1168
|
});
|
|
1161
1169
|
it('can handle negative numbers', () => {
|
|
1162
1170
|
var _a;
|
|
@@ -1168,11 +1176,11 @@ describe('parser', () => {
|
|
|
1168
1176
|
sub init()
|
|
1169
1177
|
end sub
|
|
1170
1178
|
`, Parser_1.ParseMode.BrighterScript);
|
|
1171
|
-
(0,
|
|
1172
|
-
(0,
|
|
1179
|
+
(0, chai_config_spec_1.expect)((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
|
|
1180
|
+
(0, chai_config_spec_1.expect)(statements[0]).to.be.instanceof(Statement_1.FunctionStatement);
|
|
1173
1181
|
let fn = statements[0];
|
|
1174
|
-
(0,
|
|
1175
|
-
(0,
|
|
1182
|
+
(0, chai_config_spec_1.expect)(fn.annotations).to.exist;
|
|
1183
|
+
(0, chai_config_spec_1.expect)(fn.annotations[0].getArguments()).to.deep.equal([-100]);
|
|
1176
1184
|
});
|
|
1177
1185
|
});
|
|
1178
1186
|
});
|
|
@@ -1193,14 +1201,14 @@ function rangeToArray(range) {
|
|
|
1193
1201
|
exports.rangeToArray = rangeToArray;
|
|
1194
1202
|
function expectCommentWithText(stat, text) {
|
|
1195
1203
|
if ((0, reflection_1.isCommentStatement)(stat)) {
|
|
1196
|
-
(0,
|
|
1204
|
+
(0, chai_config_spec_1.expect)(stat.text).to.equal(text);
|
|
1197
1205
|
}
|
|
1198
1206
|
else {
|
|
1199
1207
|
failStatementType(stat, 'Comment');
|
|
1200
1208
|
}
|
|
1201
1209
|
}
|
|
1202
1210
|
function failStatementType(stat, type) {
|
|
1203
|
-
|
|
1211
|
+
chai_config_spec_1.assert.fail(`Statement ${stat.constructor.name} line ${stat.range.start.line} is not a ${type}`);
|
|
1204
1212
|
}
|
|
1205
1213
|
exports.failStatementType = failStatementType;
|
|
1206
1214
|
//# sourceMappingURL=Parser.spec.js.map
|