brighterscript 0.41.6 → 0.44.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 +46 -0
- package/dist/Cache.d.ts +3 -3
- package/dist/Cache.js +10 -6
- package/dist/Cache.js.map +1 -1
- package/dist/LanguageServer.d.ts +1 -6
- package/dist/LanguageServer.js +0 -9
- package/dist/LanguageServer.js.map +1 -1
- package/dist/PluginInterface.d.ts +3 -3
- package/dist/PluginInterface.js +3 -0
- package/dist/PluginInterface.js.map +1 -1
- package/dist/Program.d.ts +48 -19
- package/dist/Program.js +160 -60
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.js +3 -3
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +6 -5
- package/dist/Scope.js +18 -14
- package/dist/Scope.js.map +1 -1
- package/dist/astUtils/AstEditor.d.ts +27 -0
- package/dist/astUtils/AstEditor.js +97 -0
- package/dist/astUtils/AstEditor.js.map +1 -0
- package/dist/{bscPlugin/semanticTokens/SemanticTokensProcessor.spec.d.ts → astUtils/AstEditor.spec.d.ts} +0 -0
- package/dist/astUtils/AstEditor.spec.js +133 -0
- package/dist/astUtils/AstEditor.spec.js.map +1 -0
- package/dist/astUtils/reflection.d.ts +2 -1
- package/dist/astUtils/reflection.js +6 -2
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +6 -6
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +13 -16
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.js +5 -2
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +3 -3
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +2 -0
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +8 -0
- package/dist/bscPlugin/semanticTokens/{SemanticTokensProcessor.js → BrsFileSemanticTokensProcessor.js} +12 -14
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.d.ts +1 -0
- package/dist/bscPlugin/semanticTokens/{SemanticTokensProcessor.spec.js → BrsFileSemanticTokensProcessor.spec.js} +2 -2
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -0
- package/dist/files/BrsFile.Class.spec.js +182 -78
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +18 -7
- package/dist/files/BrsFile.js +118 -71
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +185 -107
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.d.ts +6 -0
- package/dist/files/XmlFile.js +15 -9
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/files/XmlFile.spec.js +44 -40
- package/dist/files/XmlFile.spec.js.map +1 -1
- package/dist/files/tests/imports.spec.js +6 -4
- package/dist/files/tests/imports.spec.js.map +1 -1
- package/dist/globalCallables.d.ts +3 -1
- package/dist/globalCallables.js +200 -100
- package/dist/globalCallables.js.map +1 -1
- package/dist/index.d.ts +12 -3
- package/dist/index.js +21 -4
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +73 -7
- package/dist/lexer/Lexer.js +1 -2
- package/dist/lexer/Lexer.js.map +1 -1
- package/dist/lexer/Lexer.spec.js +462 -462
- package/dist/lexer/Lexer.spec.js.map +1 -1
- package/dist/parser/Expression.d.ts +1 -1
- package/dist/parser/Expression.js +10 -10
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +32 -31
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.d.ts +13 -1
- package/dist/parser/Parser.js +355 -253
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.js +86 -24
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/Statement.d.ts +2 -2
- package/dist/parser/Statement.js +8 -8
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/Statement.spec.js +4 -4
- package/dist/parser/Statement.spec.js.map +1 -1
- package/dist/parser/tests/Parser.spec.d.ts +3 -3
- package/dist/parser/tests/Parser.spec.js +4 -4
- package/dist/parser/tests/Parser.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/For.spec.js +40 -40
- package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/ForEach.spec.js +22 -21
- package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/If.spec.js +100 -99
- package/dist/parser/tests/controlFlow/If.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/While.spec.js +25 -25
- package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
- package/dist/parser/tests/expression/Additive.spec.js +21 -21
- package/dist/parser/tests/expression/Additive.spec.js.map +1 -1
- package/dist/parser/tests/expression/ArrayLiterals.spec.js +91 -91
- package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +1 -1
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +102 -102
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
- package/dist/parser/tests/expression/Boolean.spec.js +15 -15
- package/dist/parser/tests/expression/Boolean.spec.js.map +1 -1
- package/dist/parser/tests/expression/Call.spec.js +22 -21
- package/dist/parser/tests/expression/Call.spec.js.map +1 -1
- package/dist/parser/tests/expression/Exponential.spec.js +11 -11
- package/dist/parser/tests/expression/Exponential.spec.js.map +1 -1
- package/dist/parser/tests/expression/Function.spec.js +171 -171
- package/dist/parser/tests/expression/Function.spec.js.map +1 -1
- package/dist/parser/tests/expression/Indexing.spec.js +50 -50
- package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
- package/dist/parser/tests/expression/Multiplicative.spec.js +25 -25
- package/dist/parser/tests/expression/Multiplicative.spec.js.map +1 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +16 -16
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/PrefixUnary.spec.js +26 -26
- package/dist/parser/tests/expression/PrefixUnary.spec.js.map +1 -1
- package/dist/parser/tests/expression/Primary.spec.js +27 -27
- package/dist/parser/tests/expression/Primary.spec.js.map +1 -1
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +3 -2
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/Relational.spec.js +25 -25
- package/dist/parser/tests/expression/Relational.spec.js.map +1 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js +7 -7
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.js +6 -6
- 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/Declaration.spec.js +20 -20
- package/dist/parser/tests/statement/Declaration.spec.js.map +1 -1
- package/dist/parser/tests/statement/Function.spec.js +121 -120
- package/dist/parser/tests/statement/Function.spec.js.map +1 -1
- package/dist/parser/tests/statement/Goto.spec.js +9 -8
- package/dist/parser/tests/statement/Goto.spec.js.map +1 -1
- package/dist/parser/tests/statement/Increment.spec.js +22 -22
- package/dist/parser/tests/statement/Increment.spec.js.map +1 -1
- package/dist/parser/tests/statement/InterfaceStatement.spec.js +12 -0
- package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/LibraryStatement.spec.js +7 -7
- package/dist/parser/tests/statement/LibraryStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Misc.spec.js +71 -70
- package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
- package/dist/parser/tests/statement/PrintStatement.spec.js +17 -17
- package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/ReturnStatement.spec.js +33 -33
- package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Set.spec.js +53 -53
- package/dist/parser/tests/statement/Set.spec.js.map +1 -1
- package/dist/parser/tests/statement/Stop.spec.js +7 -6
- package/dist/parser/tests/statement/Stop.spec.js.map +1 -1
- package/dist/preprocessor/Chunk.d.ts +1 -1
- package/dist/preprocessor/Preprocessor.d.ts +1 -1
- package/dist/preprocessor/Preprocessor.js +7 -7
- package/dist/preprocessor/Preprocessor.js.map +1 -1
- package/dist/types/FunctionType.d.ts +2 -2
- package/dist/types/FunctionType.js +3 -3
- package/dist/types/FunctionType.js.map +1 -1
- package/dist/types/FunctionType.spec.js +2 -2
- package/dist/types/FunctionType.spec.js.map +1 -1
- package/dist/util.d.ts +17 -1
- package/dist/util.js +59 -29
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.js +20 -27
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +2 -1
- package/dist/astUtils/index.d.ts +0 -7
- package/dist/astUtils/index.js +0 -26
- package/dist/astUtils/index.js.map +0 -1
- package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.d.ts +0 -7
- package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.js.map +0 -1
- package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.js.map +0 -1
- package/dist/lexer/index.d.ts +0 -3
- package/dist/lexer/index.js +0 -18
- package/dist/lexer/index.js.map +0 -1
- package/dist/parser/index.d.ts +0 -3
- package/dist/parser/index.js +0 -16
- package/dist/parser/index.js.map +0 -1
- package/dist/preprocessor/index.d.ts +0 -3
- package/dist/preprocessor/index.js +0 -16
- package/dist/preprocessor/index.js.map +0 -1
|
@@ -12,7 +12,8 @@ const IntegerType_1 = require("../types/IntegerType");
|
|
|
12
12
|
const StringType_1 = require("../types/StringType");
|
|
13
13
|
const BrsFile_1 = require("./BrsFile");
|
|
14
14
|
const source_map_1 = require("source-map");
|
|
15
|
-
const
|
|
15
|
+
const Lexer_1 = require("../lexer/Lexer");
|
|
16
|
+
const TokenKind_1 = require("../lexer/TokenKind");
|
|
16
17
|
const DiagnosticMessages_1 = require("../DiagnosticMessages");
|
|
17
18
|
const util_1 = require("../util");
|
|
18
19
|
const PluginInterface_1 = require("../PluginInterface");
|
|
@@ -36,24 +37,22 @@ describe('BrsFile', () => {
|
|
|
36
37
|
program.dispose();
|
|
37
38
|
});
|
|
38
39
|
it('supports the third parameter in CreateObject', () => {
|
|
39
|
-
var _a;
|
|
40
40
|
program.addOrReplaceFile('source/main.brs', `
|
|
41
41
|
sub main()
|
|
42
42
|
regexp = CreateObject("roRegex", "[a-z]+", "i")
|
|
43
43
|
end sub
|
|
44
44
|
`);
|
|
45
45
|
program.validate();
|
|
46
|
-
(0,
|
|
46
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
47
47
|
});
|
|
48
48
|
it('supports the 6 params in CreateObject for roRegion', () => {
|
|
49
|
-
var _a;
|
|
50
49
|
program.addOrReplaceFile('source/main.brs', `
|
|
51
50
|
sub createRegion(bitmap as object)
|
|
52
51
|
region = CreateObject("roRegion", bitmap, 20, 40, 100, 200)
|
|
53
52
|
end sub
|
|
54
53
|
`);
|
|
55
54
|
program.validate();
|
|
56
|
-
(0,
|
|
55
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
57
56
|
});
|
|
58
57
|
it('sets needsTranspiled to true for .bs files', () => {
|
|
59
58
|
//BrightScript
|
|
@@ -68,8 +67,7 @@ describe('BrsFile', () => {
|
|
|
68
67
|
range: undefined
|
|
69
68
|
}];
|
|
70
69
|
file.addDiagnostics(expected);
|
|
71
|
-
|
|
72
|
-
(0, chai_1.expect)(actual).deep.equal(expected);
|
|
70
|
+
(0, testHelpers_spec_1.expectDiagnostics)(file, expected);
|
|
73
71
|
});
|
|
74
72
|
describe('getPartialVariableName', () => {
|
|
75
73
|
let entry = {
|
|
@@ -181,7 +179,7 @@ describe('BrsFile', () => {
|
|
|
181
179
|
|
|
182
180
|
end sub
|
|
183
181
|
`);
|
|
184
|
-
let keywords = Object.keys(
|
|
182
|
+
let keywords = Object.keys(TokenKind_1.Keywords).filter(x => !x.includes(' '));
|
|
185
183
|
//inside the function
|
|
186
184
|
let result = program.getCompletions(`${rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 23));
|
|
187
185
|
let names = result.map(x => x.label);
|
|
@@ -258,7 +256,6 @@ describe('BrsFile', () => {
|
|
|
258
256
|
describe('comment flags', () => {
|
|
259
257
|
describe('bs:disable-next-line', () => {
|
|
260
258
|
it('disables critical diagnostic issues', () => {
|
|
261
|
-
var _a, _b;
|
|
262
259
|
program.addOrReplaceFile('source/main.brs', `
|
|
263
260
|
sub main()
|
|
264
261
|
Dim requestData
|
|
@@ -266,19 +263,18 @@ describe('BrsFile', () => {
|
|
|
266
263
|
`);
|
|
267
264
|
//should have an error
|
|
268
265
|
program.validate();
|
|
269
|
-
(0,
|
|
266
|
+
(0, testHelpers_spec_1.expectHasDiagnostics)(program);
|
|
270
267
|
program.addOrReplaceFile('source/main.brs', `
|
|
271
268
|
sub main()
|
|
272
269
|
'bs:disable-next-line
|
|
273
270
|
Dim requestData
|
|
274
271
|
end sub
|
|
275
272
|
`);
|
|
276
|
-
//should have an error
|
|
273
|
+
//should not have an error
|
|
277
274
|
program.validate();
|
|
278
|
-
(0,
|
|
275
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
279
276
|
});
|
|
280
277
|
it('works with leading whitespace', () => {
|
|
281
|
-
var _a;
|
|
282
278
|
program.addOrReplaceFile('source/main.brs', `
|
|
283
279
|
sub main()
|
|
284
280
|
' bs:disable-next-line
|
|
@@ -287,10 +283,9 @@ describe('BrsFile', () => {
|
|
|
287
283
|
`);
|
|
288
284
|
//should have an error
|
|
289
285
|
program.validate();
|
|
290
|
-
(0,
|
|
286
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
291
287
|
});
|
|
292
288
|
it('works for all', () => {
|
|
293
|
-
var _a;
|
|
294
289
|
let file = program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
295
290
|
sub Main()
|
|
296
291
|
'bs:disable-next-line
|
|
@@ -305,10 +300,9 @@ describe('BrsFile', () => {
|
|
|
305
300
|
});
|
|
306
301
|
program.validate();
|
|
307
302
|
//the "unterminated string" error should be filtered out
|
|
308
|
-
(0,
|
|
303
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
309
304
|
});
|
|
310
305
|
it('works for specific codes', () => {
|
|
311
|
-
var _a;
|
|
312
306
|
let file = program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
313
307
|
sub Main()
|
|
314
308
|
'bs:disable-next-line: 1083, 1001
|
|
@@ -322,10 +316,9 @@ describe('BrsFile', () => {
|
|
|
322
316
|
affectedRange: util_1.default.createRange(3, 0, 3, Number.MAX_SAFE_INTEGER)
|
|
323
317
|
});
|
|
324
318
|
//the "unterminated string" error should be filtered out
|
|
325
|
-
(0,
|
|
319
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
326
320
|
});
|
|
327
321
|
it('recognizes non-numeric codes', () => {
|
|
328
|
-
var _a;
|
|
329
322
|
let file = program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
330
323
|
sub Main()
|
|
331
324
|
'bs:disable-next-line: LINT9999
|
|
@@ -333,7 +326,7 @@ describe('BrsFile', () => {
|
|
|
333
326
|
end sub
|
|
334
327
|
`);
|
|
335
328
|
(0, chai_1.expect)(file.commentFlags[0]).to.exist;
|
|
336
|
-
(0,
|
|
329
|
+
(0, testHelpers_spec_1.expectHasDiagnostics)(program);
|
|
337
330
|
});
|
|
338
331
|
it('supports disabling non-numeric error codes', () => {
|
|
339
332
|
const program = new Program_1.Program({});
|
|
@@ -348,7 +341,8 @@ describe('BrsFile', () => {
|
|
|
348
341
|
message: 'Something is not right',
|
|
349
342
|
range: util_1.default.createRange(2, 16, 2, 26)
|
|
350
343
|
}]);
|
|
351
|
-
|
|
344
|
+
const scope = program.getScopesForFile(file)[0];
|
|
345
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(scope);
|
|
352
346
|
});
|
|
353
347
|
it('adds diagnostics for unknown numeric diagnostic codes', () => {
|
|
354
348
|
program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
@@ -357,13 +351,7 @@ describe('BrsFile', () => {
|
|
|
357
351
|
end sub
|
|
358
352
|
`);
|
|
359
353
|
program.validate();
|
|
360
|
-
(0,
|
|
361
|
-
(0, chai_1.expect)(program.getDiagnostics()[0]).to.deep.include({
|
|
362
|
-
range: vscode_languageserver_1.Range.create(2, 53, 2, 59)
|
|
363
|
-
});
|
|
364
|
-
(0, chai_1.expect)(program.getDiagnostics()[1]).to.deep.include({
|
|
365
|
-
range: vscode_languageserver_1.Range.create(2, 60, 2, 66)
|
|
366
|
-
});
|
|
354
|
+
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.unknownDiagnosticCode(123456)), { range: vscode_languageserver_1.Range.create(2, 53, 2, 59) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.unknownDiagnosticCode(999999)), { range: vscode_languageserver_1.Range.create(2, 60, 2, 66) })]);
|
|
367
355
|
});
|
|
368
356
|
});
|
|
369
357
|
describe('bs:disable-line', () => {
|
|
@@ -381,7 +369,7 @@ describe('BrsFile', () => {
|
|
|
381
369
|
});
|
|
382
370
|
program.validate();
|
|
383
371
|
//the "unterminated string" error should be filtered out
|
|
384
|
-
(0,
|
|
372
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
385
373
|
});
|
|
386
374
|
it('works for specific codes', () => {
|
|
387
375
|
program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
@@ -395,10 +383,9 @@ describe('BrsFile', () => {
|
|
|
395
383
|
end sub
|
|
396
384
|
`);
|
|
397
385
|
program.validate();
|
|
398
|
-
(0,
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
});
|
|
386
|
+
(0, testHelpers_spec_1.expectDiagnostics)(program, [{
|
|
387
|
+
range: vscode_languageserver_1.Range.create(5, 24, 5, 35)
|
|
388
|
+
}]);
|
|
402
389
|
});
|
|
403
390
|
it('handles the erraneous `stop` keyword', () => {
|
|
404
391
|
//the current version of BRS causes parse errors after the `parse` keyword, showing error in comments
|
|
@@ -411,7 +398,7 @@ describe('BrsFile', () => {
|
|
|
411
398
|
end sub
|
|
412
399
|
`);
|
|
413
400
|
program.validate();
|
|
414
|
-
(0,
|
|
401
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
415
402
|
});
|
|
416
403
|
});
|
|
417
404
|
});
|
|
@@ -447,7 +434,7 @@ describe('BrsFile', () => {
|
|
|
447
434
|
myLabel:
|
|
448
435
|
end sub
|
|
449
436
|
`);
|
|
450
|
-
(0,
|
|
437
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
451
438
|
});
|
|
452
439
|
it('supports empty print statements', () => {
|
|
453
440
|
let file = program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
@@ -455,7 +442,7 @@ describe('BrsFile', () => {
|
|
|
455
442
|
print
|
|
456
443
|
end sub
|
|
457
444
|
`);
|
|
458
|
-
(0,
|
|
445
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
459
446
|
});
|
|
460
447
|
describe('conditional compile', () => {
|
|
461
448
|
it('works for upper case keywords', () => {
|
|
@@ -471,7 +458,7 @@ describe('BrsFile', () => {
|
|
|
471
458
|
#ENDIF
|
|
472
459
|
end sub
|
|
473
460
|
`);
|
|
474
|
-
(0,
|
|
461
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
475
462
|
});
|
|
476
463
|
it('supports single-word #elseif and #endif', () => {
|
|
477
464
|
let file = program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
@@ -484,7 +471,7 @@ describe('BrsFile', () => {
|
|
|
484
471
|
#endif
|
|
485
472
|
end sub
|
|
486
473
|
`);
|
|
487
|
-
(0,
|
|
474
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
488
475
|
});
|
|
489
476
|
it('supports multi-word #else if and #end if', () => {
|
|
490
477
|
let file = program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
@@ -497,7 +484,7 @@ describe('BrsFile', () => {
|
|
|
497
484
|
#end if
|
|
498
485
|
end sub
|
|
499
486
|
`);
|
|
500
|
-
(0,
|
|
487
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
501
488
|
});
|
|
502
489
|
it('does not choke on invalid code inside a false conditional compile', () => {
|
|
503
490
|
let file = program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
@@ -507,7 +494,7 @@ describe('BrsFile', () => {
|
|
|
507
494
|
#end if
|
|
508
495
|
end sub
|
|
509
496
|
`);
|
|
510
|
-
(0,
|
|
497
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
511
498
|
});
|
|
512
499
|
it('detects syntax error in #if', () => {
|
|
513
500
|
let file = program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
@@ -517,7 +504,9 @@ describe('BrsFile', () => {
|
|
|
517
504
|
#end if
|
|
518
505
|
end sub
|
|
519
506
|
`);
|
|
520
|
-
(0,
|
|
507
|
+
(0, testHelpers_spec_1.expectDiagnostics)(file, [
|
|
508
|
+
DiagnosticMessages_1.DiagnosticMessages.referencedConstDoesNotExist()
|
|
509
|
+
]);
|
|
521
510
|
});
|
|
522
511
|
it('detects syntax error in #const', () => {
|
|
523
512
|
let file = program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
@@ -527,7 +516,10 @@ describe('BrsFile', () => {
|
|
|
527
516
|
#end if
|
|
528
517
|
end sub
|
|
529
518
|
`);
|
|
530
|
-
(0,
|
|
519
|
+
(0, testHelpers_spec_1.expectDiagnostics)(file, [
|
|
520
|
+
DiagnosticMessages_1.DiagnosticMessages.unexpectedCharacter('%'),
|
|
521
|
+
DiagnosticMessages_1.DiagnosticMessages.invalidHashIfValue()
|
|
522
|
+
]);
|
|
531
523
|
});
|
|
532
524
|
it('detects #const name using reserved word', () => {
|
|
533
525
|
let file = program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
@@ -535,7 +527,10 @@ describe('BrsFile', () => {
|
|
|
535
527
|
#const function = true
|
|
536
528
|
end sub
|
|
537
529
|
`);
|
|
538
|
-
(0,
|
|
530
|
+
(0, testHelpers_spec_1.expectDiagnostics)(file, [
|
|
531
|
+
DiagnosticMessages_1.DiagnosticMessages.constNameCannotBeReservedWord(),
|
|
532
|
+
DiagnosticMessages_1.DiagnosticMessages.unexpectedToken('#const')
|
|
533
|
+
]);
|
|
539
534
|
});
|
|
540
535
|
it('detects syntax error in #const', () => {
|
|
541
536
|
let file = program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
@@ -543,7 +538,9 @@ describe('BrsFile', () => {
|
|
|
543
538
|
#const someConst = 123
|
|
544
539
|
end sub
|
|
545
540
|
`);
|
|
546
|
-
(0,
|
|
541
|
+
(0, testHelpers_spec_1.expectDiagnostics)(file, [
|
|
542
|
+
DiagnosticMessages_1.DiagnosticMessages.invalidHashConstValue()
|
|
543
|
+
]);
|
|
547
544
|
});
|
|
548
545
|
});
|
|
549
546
|
it('supports stop statement', () => {
|
|
@@ -552,7 +549,7 @@ describe('BrsFile', () => {
|
|
|
552
549
|
stop
|
|
553
550
|
end sub
|
|
554
551
|
`);
|
|
555
|
-
(0,
|
|
552
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
556
553
|
});
|
|
557
554
|
it('supports single-line if statements', () => {
|
|
558
555
|
let file = program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
@@ -565,16 +562,15 @@ describe('BrsFile', () => {
|
|
|
565
562
|
if true then : test = sub() : print "yes" : end sub : end if
|
|
566
563
|
end sub
|
|
567
564
|
`);
|
|
568
|
-
(0,
|
|
565
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
569
566
|
});
|
|
570
567
|
it('supports line_num as global variable', () => {
|
|
571
|
-
var _a;
|
|
572
568
|
file.parse(`
|
|
573
569
|
sub Main()
|
|
574
570
|
print LINE_NUM
|
|
575
571
|
end sub
|
|
576
572
|
`);
|
|
577
|
-
(0,
|
|
573
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
578
574
|
});
|
|
579
575
|
it('supports many keywords as object property names', () => {
|
|
580
576
|
file.parse(`
|
|
@@ -640,7 +636,7 @@ describe('BrsFile', () => {
|
|
|
640
636
|
person.new = true
|
|
641
637
|
end sub
|
|
642
638
|
`);
|
|
643
|
-
(0,
|
|
639
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
644
640
|
});
|
|
645
641
|
it('does not error on numeric literal type designators', () => {
|
|
646
642
|
file.parse(`
|
|
@@ -654,7 +650,7 @@ describe('BrsFile', () => {
|
|
|
654
650
|
print 9876543210&
|
|
655
651
|
end sub
|
|
656
652
|
`);
|
|
657
|
-
(0,
|
|
653
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
658
654
|
});
|
|
659
655
|
it('does not error when encountering sub with return type', () => {
|
|
660
656
|
file.parse(`
|
|
@@ -662,7 +658,7 @@ describe('BrsFile', () => {
|
|
|
662
658
|
return
|
|
663
659
|
end sub
|
|
664
660
|
`);
|
|
665
|
-
(0,
|
|
661
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
666
662
|
});
|
|
667
663
|
it('does not lose function scopes when mismatched end sub', () => {
|
|
668
664
|
file.parse(`
|
|
@@ -697,7 +693,7 @@ describe('BrsFile', () => {
|
|
|
697
693
|
foo.bar = true and false or 3 > 4
|
|
698
694
|
end sub
|
|
699
695
|
`);
|
|
700
|
-
(0,
|
|
696
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
701
697
|
});
|
|
702
698
|
it('does not error with boolean in RHS of set statement', () => {
|
|
703
699
|
file.parse(`
|
|
@@ -710,7 +706,7 @@ describe('BrsFile', () => {
|
|
|
710
706
|
m.isTrue = m.isTrue = m.isTrue
|
|
711
707
|
end sub
|
|
712
708
|
`);
|
|
713
|
-
(0,
|
|
709
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
714
710
|
});
|
|
715
711
|
it('supports variable names ending with type designators', () => {
|
|
716
712
|
file.parse(`
|
|
@@ -722,7 +718,7 @@ describe('BrsFile', () => {
|
|
|
722
718
|
someHex& = 13
|
|
723
719
|
end sub
|
|
724
720
|
`);
|
|
725
|
-
(0,
|
|
721
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
726
722
|
});
|
|
727
723
|
it('supports multiple spaces between two-word keywords', () => {
|
|
728
724
|
file.parse(`
|
|
@@ -734,7 +730,7 @@ describe('BrsFile', () => {
|
|
|
734
730
|
end if
|
|
735
731
|
end sub
|
|
736
732
|
`);
|
|
737
|
-
(0,
|
|
733
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
738
734
|
});
|
|
739
735
|
it('does not error with `stop` as object key', () => {
|
|
740
736
|
file.parse(`
|
|
@@ -747,7 +743,7 @@ describe('BrsFile', () => {
|
|
|
747
743
|
return obj
|
|
748
744
|
end function
|
|
749
745
|
`);
|
|
750
|
-
(0,
|
|
746
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
751
747
|
});
|
|
752
748
|
it('does not error with `run` as object key', () => {
|
|
753
749
|
file.parse(`
|
|
@@ -760,7 +756,7 @@ describe('BrsFile', () => {
|
|
|
760
756
|
return obj
|
|
761
757
|
end function
|
|
762
758
|
`);
|
|
763
|
-
(0,
|
|
759
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
764
760
|
});
|
|
765
761
|
it('supports assignment operators', () => {
|
|
766
762
|
file.parse(`
|
|
@@ -777,7 +773,7 @@ describe('BrsFile', () => {
|
|
|
777
773
|
print x
|
|
778
774
|
end function
|
|
779
775
|
`);
|
|
780
|
-
(0,
|
|
776
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
781
777
|
});
|
|
782
778
|
it('supports `then` as object property', () => {
|
|
783
779
|
file.parse(`
|
|
@@ -789,7 +785,7 @@ describe('BrsFile', () => {
|
|
|
789
785
|
promise.then()
|
|
790
786
|
end function
|
|
791
787
|
`);
|
|
792
|
-
(0,
|
|
788
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
793
789
|
});
|
|
794
790
|
it('supports function as parameter type', () => {
|
|
795
791
|
file.parse(`
|
|
@@ -798,7 +794,7 @@ describe('BrsFile', () => {
|
|
|
798
794
|
end function
|
|
799
795
|
end sub
|
|
800
796
|
`);
|
|
801
|
-
(0,
|
|
797
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
802
798
|
});
|
|
803
799
|
it('supports increment operator', () => {
|
|
804
800
|
file.parse(`
|
|
@@ -807,8 +803,7 @@ describe('BrsFile', () => {
|
|
|
807
803
|
x++
|
|
808
804
|
end function
|
|
809
805
|
`);
|
|
810
|
-
|
|
811
|
-
(0, chai_1.expect)(file.getDiagnostics()).to.be.lengthOf(0);
|
|
806
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
812
807
|
});
|
|
813
808
|
it('supports decrement operator', () => {
|
|
814
809
|
file.parse(`
|
|
@@ -817,8 +812,7 @@ describe('BrsFile', () => {
|
|
|
817
812
|
x--
|
|
818
813
|
end function
|
|
819
814
|
`);
|
|
820
|
-
|
|
821
|
-
(0, chai_1.expect)(file.getDiagnostics()).to.be.lengthOf(0);
|
|
815
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
822
816
|
});
|
|
823
817
|
it('supports writing numbers with decimal but no trailing digit', () => {
|
|
824
818
|
file.parse(`
|
|
@@ -827,7 +821,7 @@ describe('BrsFile', () => {
|
|
|
827
821
|
print x
|
|
828
822
|
end function
|
|
829
823
|
`);
|
|
830
|
-
(0,
|
|
824
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
831
825
|
});
|
|
832
826
|
it('supports assignment operators against object properties', () => {
|
|
833
827
|
file.parse(`
|
|
@@ -849,7 +843,7 @@ describe('BrsFile', () => {
|
|
|
849
843
|
print m.age
|
|
850
844
|
end function
|
|
851
845
|
`);
|
|
852
|
-
(0,
|
|
846
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
853
847
|
});
|
|
854
848
|
//skipped until `brs` supports this
|
|
855
849
|
it('supports bitshift assignment operators', () => {
|
|
@@ -861,7 +855,7 @@ describe('BrsFile', () => {
|
|
|
861
855
|
print x
|
|
862
856
|
end function
|
|
863
857
|
`);
|
|
864
|
-
(0,
|
|
858
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
865
859
|
});
|
|
866
860
|
//skipped until `brs` supports this
|
|
867
861
|
it('supports bitshift assignment operators on objects', () => {
|
|
@@ -873,7 +867,7 @@ describe('BrsFile', () => {
|
|
|
873
867
|
print m.x
|
|
874
868
|
end function
|
|
875
869
|
`);
|
|
876
|
-
(0,
|
|
870
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
877
871
|
});
|
|
878
872
|
it('supports leading and trailing periods for numeric literals', () => {
|
|
879
873
|
file.parse(`
|
|
@@ -884,7 +878,7 @@ describe('BrsFile', () => {
|
|
|
884
878
|
print pointOne
|
|
885
879
|
end function
|
|
886
880
|
`);
|
|
887
|
-
(0,
|
|
881
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
888
882
|
});
|
|
889
883
|
it('supports bitshift assignment operators on object properties accessed by array syntax', () => {
|
|
890
884
|
file.parse(`
|
|
@@ -895,7 +889,7 @@ describe('BrsFile', () => {
|
|
|
895
889
|
print m.x
|
|
896
890
|
end function
|
|
897
891
|
`);
|
|
898
|
-
(0,
|
|
892
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
899
893
|
});
|
|
900
894
|
it('supports weird period AA accessor', () => {
|
|
901
895
|
file.parse(`
|
|
@@ -904,42 +898,46 @@ describe('BrsFile', () => {
|
|
|
904
898
|
print m.["_uuid"]
|
|
905
899
|
end function
|
|
906
900
|
`);
|
|
907
|
-
(0,
|
|
901
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
908
902
|
});
|
|
909
903
|
it('adds error for library statements NOT at top of file', () => {
|
|
910
|
-
|
|
904
|
+
program.addOrReplaceFile('source/file.brs', ``);
|
|
905
|
+
program.addOrReplaceFile('source/main.bs', `
|
|
911
906
|
sub main()
|
|
912
907
|
end sub
|
|
913
908
|
import "file.brs"
|
|
914
909
|
`);
|
|
915
|
-
|
|
916
|
-
|
|
910
|
+
program.validate();
|
|
911
|
+
(0, testHelpers_spec_1.expectDiagnostics)(program, [
|
|
912
|
+
DiagnosticMessages_1.DiagnosticMessages.importStatementMustBeDeclaredAtTopOfFile()
|
|
917
913
|
]);
|
|
918
914
|
});
|
|
919
915
|
it('supports library imports', () => {
|
|
920
|
-
|
|
916
|
+
program.addOrReplaceFile('source/main.brs', `
|
|
921
917
|
Library "v30/bslCore.brs"
|
|
922
918
|
`);
|
|
923
|
-
(0,
|
|
919
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
924
920
|
});
|
|
925
921
|
it('adds error for library statements NOT at top of file', () => {
|
|
926
|
-
|
|
922
|
+
program.addOrReplaceFile('source/main.brs', `
|
|
927
923
|
sub main()
|
|
928
924
|
end sub
|
|
929
925
|
Library "v30/bslCore.brs"
|
|
930
926
|
`);
|
|
931
|
-
|
|
932
|
-
|
|
927
|
+
program.validate();
|
|
928
|
+
(0, testHelpers_spec_1.expectDiagnostics)(program, [
|
|
929
|
+
DiagnosticMessages_1.DiagnosticMessages.libraryStatementMustBeDeclaredAtTopOfFile()
|
|
933
930
|
]);
|
|
934
931
|
});
|
|
935
932
|
it('adds error for library statements inside of function body', () => {
|
|
936
|
-
|
|
933
|
+
program.addOrReplaceFile('source/main.brs', `
|
|
937
934
|
sub main()
|
|
938
935
|
Library "v30/bslCore.brs"
|
|
939
936
|
end sub
|
|
940
937
|
`);
|
|
941
|
-
|
|
942
|
-
|
|
938
|
+
program.validate();
|
|
939
|
+
(0, testHelpers_spec_1.expectDiagnostics)(program, [
|
|
940
|
+
DiagnosticMessages_1.DiagnosticMessages.libraryStatementMustBeDeclaredAtTopOfFile()
|
|
943
941
|
]);
|
|
944
942
|
});
|
|
945
943
|
it('supports colons as separators in associative array properties', () => {
|
|
@@ -948,7 +946,7 @@ describe('BrsFile', () => {
|
|
|
948
946
|
obj = {x:0 : y: 1}
|
|
949
947
|
end sub
|
|
950
948
|
`);
|
|
951
|
-
(0,
|
|
949
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
952
950
|
});
|
|
953
951
|
it('succeeds when finding variables with "sub" in them', () => {
|
|
954
952
|
let file = program.addOrReplaceFile('source/main.brs', `
|
|
@@ -1034,10 +1032,8 @@ describe('BrsFile', () => {
|
|
|
1034
1032
|
function DoSomething
|
|
1035
1033
|
end function
|
|
1036
1034
|
`);
|
|
1037
|
-
(0,
|
|
1038
|
-
(0, chai_1.expect)(file.getDiagnostics()[0]).to.
|
|
1039
|
-
file: file
|
|
1040
|
-
});
|
|
1035
|
+
(0, testHelpers_spec_1.expectHasDiagnostics)(file);
|
|
1036
|
+
(0, chai_1.expect)(file.getDiagnostics()[0].file).to.equal(file);
|
|
1041
1037
|
(0, chai_1.expect)(file.getDiagnostics()[0].range.start.line).to.equal(1);
|
|
1042
1038
|
});
|
|
1043
1039
|
it('supports using the `next` keyword in a for loop', () => {
|
|
@@ -1049,7 +1045,7 @@ describe('BrsFile', () => {
|
|
|
1049
1045
|
next
|
|
1050
1046
|
end sub
|
|
1051
1047
|
`);
|
|
1052
|
-
(0,
|
|
1048
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
1053
1049
|
});
|
|
1054
1050
|
//test is not working yet, but will be enabled when brs supports this syntax
|
|
1055
1051
|
it('supports assigning functions to objects', () => {
|
|
@@ -1062,7 +1058,7 @@ describe('BrsFile', () => {
|
|
|
1062
1058
|
end sub
|
|
1063
1059
|
end function
|
|
1064
1060
|
`);
|
|
1065
|
-
(0,
|
|
1061
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
1066
1062
|
});
|
|
1067
1063
|
});
|
|
1068
1064
|
describe('findCallables', () => {
|
|
@@ -1183,7 +1179,6 @@ describe('BrsFile', () => {
|
|
|
1183
1179
|
}]);
|
|
1184
1180
|
});
|
|
1185
1181
|
it('finds function calls nested inside statements', () => {
|
|
1186
|
-
var _a;
|
|
1187
1182
|
program.addOrReplaceFile(`source/main.brs`, `
|
|
1188
1183
|
sub main()
|
|
1189
1184
|
if true then
|
|
@@ -1192,7 +1187,9 @@ describe('BrsFile', () => {
|
|
|
1192
1187
|
end sub
|
|
1193
1188
|
`);
|
|
1194
1189
|
program.validate();
|
|
1195
|
-
(0,
|
|
1190
|
+
(0, testHelpers_spec_1.expectDiagnostics)(program, [
|
|
1191
|
+
DiagnosticMessages_1.DiagnosticMessages.callToUnknownFunction('DoesNotExist', 'source')
|
|
1192
|
+
]);
|
|
1196
1193
|
});
|
|
1197
1194
|
it('finds arguments with variable values', () => {
|
|
1198
1195
|
let file = new BrsFile_1.BrsFile('absolute_path/file.brs', 'relative_path/file.brs', program);
|
|
@@ -1406,7 +1403,11 @@ describe('BrsFile', () => {
|
|
|
1406
1403
|
let hover = file.getHover(vscode_languageserver_1.Position.create(1, 28));
|
|
1407
1404
|
(0, chai_1.expect)(hover).to.exist;
|
|
1408
1405
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(1, 25, 1, 29));
|
|
1409
|
-
(0, chai_1.expect)(hover.contents).to.equal(
|
|
1406
|
+
(0, chai_1.expect)(hover.contents).to.equal([
|
|
1407
|
+
'```brightscript',
|
|
1408
|
+
'function Main(count? as dynamic) as dynamic',
|
|
1409
|
+
'```'
|
|
1410
|
+
].join('\n'));
|
|
1410
1411
|
});
|
|
1411
1412
|
it('finds variable function hover in same scope', () => {
|
|
1412
1413
|
let file = program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
@@ -1419,7 +1420,36 @@ describe('BrsFile', () => {
|
|
|
1419
1420
|
`);
|
|
1420
1421
|
let hover = file.getHover(vscode_languageserver_1.Position.create(5, 24));
|
|
1421
1422
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(5, 20, 5, 29));
|
|
1422
|
-
(0, chai_1.expect)(hover.contents).to.equal(
|
|
1423
|
+
(0, chai_1.expect)(hover.contents).to.equal([
|
|
1424
|
+
'```brightscript',
|
|
1425
|
+
'sub sayMyName(name as string) as void',
|
|
1426
|
+
'```'
|
|
1427
|
+
].join('\n'));
|
|
1428
|
+
});
|
|
1429
|
+
it('does not crash when hovering on built-in functions', async () => {
|
|
1430
|
+
let file = program.addOrReplaceFile('source/main.brs', `
|
|
1431
|
+
function doUcase(text)
|
|
1432
|
+
return ucase(text)
|
|
1433
|
+
end function
|
|
1434
|
+
`);
|
|
1435
|
+
(0, chai_1.expect)((await program.getHover(file.pathAbsolute, vscode_languageserver_1.Position.create(2, 30))).contents).to.equal([
|
|
1436
|
+
'```brightscript',
|
|
1437
|
+
'function UCase(s as string) as string',
|
|
1438
|
+
'```'
|
|
1439
|
+
].join('\n'));
|
|
1440
|
+
});
|
|
1441
|
+
it('does not crash when hovering on object method call', async () => {
|
|
1442
|
+
let file = program.addOrReplaceFile('source/main.brs', `
|
|
1443
|
+
function getInstr(url, text)
|
|
1444
|
+
return url.instr(text)
|
|
1445
|
+
end function
|
|
1446
|
+
`);
|
|
1447
|
+
(0, chai_1.expect)((await program.getHover(file.pathAbsolute, vscode_languageserver_1.Position.create(2, 35))).contents).to.equal([
|
|
1448
|
+
'```brightscript',
|
|
1449
|
+
//TODO this really shouldn't be returning the global function, but it does...so make sure it doesn't crash right now.
|
|
1450
|
+
'function Instr(start as integer, text as string, substring as string) as integer',
|
|
1451
|
+
'```'
|
|
1452
|
+
].join('\n'));
|
|
1423
1453
|
});
|
|
1424
1454
|
it('finds function hover in file scope', () => {
|
|
1425
1455
|
let file = program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
@@ -1433,7 +1463,11 @@ describe('BrsFile', () => {
|
|
|
1433
1463
|
`);
|
|
1434
1464
|
let hover = file.getHover(vscode_languageserver_1.Position.create(2, 25));
|
|
1435
1465
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(2, 20, 2, 29));
|
|
1436
|
-
(0, chai_1.expect)(hover.contents).to.equal(
|
|
1466
|
+
(0, chai_1.expect)(hover.contents).to.equal([
|
|
1467
|
+
'```brightscript',
|
|
1468
|
+
'sub sayMyName() as void',
|
|
1469
|
+
'```'
|
|
1470
|
+
].join('\n'));
|
|
1437
1471
|
});
|
|
1438
1472
|
it('finds function hover in scope', () => {
|
|
1439
1473
|
let rootDir = process.cwd();
|
|
@@ -1453,7 +1487,53 @@ describe('BrsFile', () => {
|
|
|
1453
1487
|
let hover = mainFile.getHover(vscode_languageserver_1.Position.create(2, 25));
|
|
1454
1488
|
(0, chai_1.expect)(hover).to.exist;
|
|
1455
1489
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(2, 20, 2, 29));
|
|
1456
|
-
(0, chai_1.expect)(hover.contents).to.equal(
|
|
1490
|
+
(0, chai_1.expect)(hover.contents).to.equal([
|
|
1491
|
+
'```brightscript',
|
|
1492
|
+
'sub sayMyName(name as string) as void',
|
|
1493
|
+
'```'
|
|
1494
|
+
].join('\n'));
|
|
1495
|
+
});
|
|
1496
|
+
it('includes markdown comments in hover.', async () => {
|
|
1497
|
+
let rootDir = process.cwd();
|
|
1498
|
+
program = new Program_1.Program({
|
|
1499
|
+
rootDir: rootDir
|
|
1500
|
+
});
|
|
1501
|
+
const file = program.addOrReplaceFile('source/lib.brs', `
|
|
1502
|
+
'
|
|
1503
|
+
' The main function
|
|
1504
|
+
'
|
|
1505
|
+
sub main()
|
|
1506
|
+
log("hello")
|
|
1507
|
+
end sub
|
|
1508
|
+
|
|
1509
|
+
'
|
|
1510
|
+
' Prints a message to the log.
|
|
1511
|
+
' Works with *markdown* **content**
|
|
1512
|
+
'
|
|
1513
|
+
sub log(message as string)
|
|
1514
|
+
print message
|
|
1515
|
+
end sub
|
|
1516
|
+
`);
|
|
1517
|
+
//hover over log("hello")
|
|
1518
|
+
(0, chai_1.expect)((await program.getHover(file.pathAbsolute, vscode_languageserver_1.Position.create(5, 22))).contents).to.equal([
|
|
1519
|
+
'```brightscript',
|
|
1520
|
+
'sub log(message as string) as void',
|
|
1521
|
+
'```',
|
|
1522
|
+
'***',
|
|
1523
|
+
'',
|
|
1524
|
+
' Prints a message to the log.',
|
|
1525
|
+
' Works with *markdown* **content**',
|
|
1526
|
+
''
|
|
1527
|
+
].join('\n'));
|
|
1528
|
+
//hover over sub ma|in()
|
|
1529
|
+
(0, chai_1.expect)((await program.getHover(file.pathAbsolute, vscode_languageserver_1.Position.create(4, 22))).contents).to.equal((0, testHelpers_spec_1.trim) `
|
|
1530
|
+
\`\`\`brightscript
|
|
1531
|
+
sub main() as void
|
|
1532
|
+
\`\`\`
|
|
1533
|
+
***
|
|
1534
|
+
|
|
1535
|
+
The main function
|
|
1536
|
+
`);
|
|
1457
1537
|
});
|
|
1458
1538
|
it('handles mixed case `then` partions of conditionals', () => {
|
|
1459
1539
|
let mainFile = program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
@@ -1463,7 +1543,7 @@ describe('BrsFile', () => {
|
|
|
1463
1543
|
end if
|
|
1464
1544
|
end sub
|
|
1465
1545
|
`);
|
|
1466
|
-
(0,
|
|
1546
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(mainFile);
|
|
1467
1547
|
mainFile = program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
1468
1548
|
sub Main()
|
|
1469
1549
|
if true Then
|
|
@@ -1471,7 +1551,7 @@ describe('BrsFile', () => {
|
|
|
1471
1551
|
end if
|
|
1472
1552
|
end sub
|
|
1473
1553
|
`);
|
|
1474
|
-
(0,
|
|
1554
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(mainFile);
|
|
1475
1555
|
mainFile = program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
1476
1556
|
sub Main()
|
|
1477
1557
|
if true THEN
|
|
@@ -1479,7 +1559,7 @@ describe('BrsFile', () => {
|
|
|
1479
1559
|
end if
|
|
1480
1560
|
end sub
|
|
1481
1561
|
`);
|
|
1482
|
-
(0,
|
|
1562
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(mainFile);
|
|
1483
1563
|
});
|
|
1484
1564
|
});
|
|
1485
1565
|
it('does not throw when encountering incomplete import statement', () => {
|
|
@@ -1788,9 +1868,9 @@ describe('BrsFile', () => {
|
|
|
1788
1868
|
});
|
|
1789
1869
|
it('computes correct locations for sourcemap', async () => {
|
|
1790
1870
|
let source = `function abc(name)\n firstName = name\nend function`;
|
|
1791
|
-
let tokens =
|
|
1871
|
+
let tokens = Lexer_1.Lexer.scan(source).tokens
|
|
1792
1872
|
//remove newlines and EOF
|
|
1793
|
-
.filter(x => x.kind !==
|
|
1873
|
+
.filter(x => x.kind !== TokenKind_1.TokenKind.Eof && x.kind !== TokenKind_1.TokenKind.Newline);
|
|
1794
1874
|
program.options.sourceMap = true;
|
|
1795
1875
|
let result = testTranspile(source, source, 'none');
|
|
1796
1876
|
//load the source map
|
|
@@ -2048,14 +2128,13 @@ describe('BrsFile', () => {
|
|
|
2048
2128
|
describe('callfunc operator', () => {
|
|
2049
2129
|
describe('transpile', () => {
|
|
2050
2130
|
it('does not produce diagnostics', () => {
|
|
2051
|
-
var _a;
|
|
2052
2131
|
program.addOrReplaceFile('source/main.bs', `
|
|
2053
2132
|
sub main()
|
|
2054
2133
|
someObject@.someFunction(paramObject.value)
|
|
2055
2134
|
end sub
|
|
2056
2135
|
`);
|
|
2057
2136
|
program.validate();
|
|
2058
|
-
(0,
|
|
2137
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
2059
2138
|
});
|
|
2060
2139
|
it('sets invalid on empty callfunc', () => {
|
|
2061
2140
|
testTranspile(`
|
|
@@ -2095,13 +2174,12 @@ describe('BrsFile', () => {
|
|
|
2095
2174
|
name: 'transform callback',
|
|
2096
2175
|
afterFileParse: onParsed
|
|
2097
2176
|
});
|
|
2098
|
-
|
|
2099
|
-
(0, chai_1.expect)(file.extension).to.equal(ext);
|
|
2100
|
-
file.parse(`
|
|
2177
|
+
file = program.addOrReplaceFile({ src: `absolute_path/file${ext}`, dest: `relative_path/file${ext}` }, `
|
|
2101
2178
|
sub Sum()
|
|
2102
2179
|
print "hello world"
|
|
2103
2180
|
end sub
|
|
2104
2181
|
`);
|
|
2182
|
+
(0, chai_1.expect)(file.extension).to.equal(ext);
|
|
2105
2183
|
return file;
|
|
2106
2184
|
}
|
|
2107
2185
|
it('called for BRS file', () => {
|
|
@@ -2469,11 +2547,11 @@ describe('BrsFile', () => {
|
|
|
2469
2547
|
(0, chai_1.expect)(file.parser).to.equal(newParser);
|
|
2470
2548
|
});
|
|
2471
2549
|
it('call parse when previously skipped', () => {
|
|
2472
|
-
program.addOrReplaceFile('source/main.d.bs', `
|
|
2550
|
+
program.addOrReplaceFile('source/main.d.bs', `'typedef
|
|
2473
2551
|
sub main()
|
|
2474
2552
|
end sub
|
|
2475
2553
|
`);
|
|
2476
|
-
const file = program.addOrReplaceFile('source/main.brs', `
|
|
2554
|
+
const file = program.addOrReplaceFile('source/main.brs', `'source
|
|
2477
2555
|
sub main()
|
|
2478
2556
|
end sub
|
|
2479
2557
|
`);
|