brighterscript 0.66.0-alpha.6 → 0.66.0-alpha.8
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 +88 -10
- package/README.md +16 -0
- package/bsconfig.schema.json +15 -0
- package/dist/ActionPipeline.d.ts +10 -0
- package/dist/ActionPipeline.js +40 -0
- package/dist/ActionPipeline.js.map +1 -0
- package/dist/AstValidationSegmenter.d.ts +25 -0
- package/dist/AstValidationSegmenter.js +150 -0
- package/dist/AstValidationSegmenter.js.map +1 -0
- package/dist/BsConfig.d.ts +15 -1
- package/dist/CommentFlagProcessor.d.ts +4 -3
- package/dist/CommentFlagProcessor.js.map +1 -1
- package/dist/DiagnosticMessages.d.ts +8 -1
- package/dist/DiagnosticMessages.js +30 -13
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/LanguageServer.js +7 -1
- package/dist/LanguageServer.js.map +1 -1
- package/dist/PluginInterface.d.ts +11 -2
- package/dist/PluginInterface.js +69 -10
- package/dist/PluginInterface.js.map +1 -1
- package/dist/Program.d.ts +107 -38
- package/dist/Program.js +502 -270
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +10 -4
- package/dist/ProgramBuilder.js +44 -54
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +26 -38
- package/dist/Scope.js +153 -174
- package/dist/Scope.js.map +1 -1
- package/dist/SymbolTable.d.ts +4 -1
- package/dist/SymbolTable.js +19 -7
- package/dist/SymbolTable.js.map +1 -1
- package/dist/XmlScope.d.ts +5 -4
- package/dist/XmlScope.js +16 -14
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/{AstEditor.d.ts → Editor.d.ts} +6 -1
- package/dist/astUtils/{AstEditor.js → Editor.js} +9 -3
- package/dist/astUtils/Editor.js.map +1 -0
- package/dist/astUtils/{AstEditor.spec.js → Editor.spec.js} +10 -6
- package/dist/astUtils/Editor.spec.js.map +1 -0
- package/dist/astUtils/reflection.d.ts +9 -4
- package/dist/astUtils/reflection.js +23 -7
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +2 -2
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +14 -3
- package/dist/astUtils/visitors.js +22 -2
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +58 -7
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +10 -2
- package/dist/bscPlugin/BscPlugin.js +24 -4
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/FileWriter.d.ts +6 -0
- package/dist/bscPlugin/FileWriter.js +24 -0
- package/dist/bscPlugin/FileWriter.js.map +1 -0
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +8 -8
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +7 -2
- package/dist/bscPlugin/completions/CompletionsProcessor.js +112 -44
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +212 -6
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/fileProviders/FileProvider.d.ts +9 -0
- package/dist/bscPlugin/fileProviders/FileProvider.js +51 -0
- package/dist/bscPlugin/fileProviders/FileProvider.js.map +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.d.ts +1 -7
- package/dist/bscPlugin/hover/HoverProcessor.js +10 -8
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +1 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +43 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +22 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/serialize/BslibInjector.spec.js +19 -0
- package/dist/bscPlugin/serialize/BslibInjector.spec.js.map +1 -0
- package/dist/bscPlugin/serialize/BslibManager.d.ts +9 -0
- package/dist/bscPlugin/serialize/BslibManager.js +40 -0
- package/dist/bscPlugin/serialize/BslibManager.js.map +1 -0
- package/dist/bscPlugin/serialize/FileSerializer.d.ts +9 -0
- package/dist/bscPlugin/serialize/FileSerializer.js +72 -0
- package/dist/bscPlugin/serialize/FileSerializer.js.map +1 -0
- package/dist/bscPlugin/transpile/{BrsFilePreTranspileProcessor.d.ts → BrsFileTranspileProcessor.d.ts} +4 -2
- package/dist/bscPlugin/transpile/{BrsFilePreTranspileProcessor.js → BrsFileTranspileProcessor.js} +29 -5
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.d.ts +1 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js +41 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +2 -2
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.js +8 -3
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +5 -9
- package/dist/bscPlugin/validation/ScopeValidator.js +214 -222
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.spec.js +669 -0
- package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -1
- package/dist/bscPlugin/validation/XmlFileValidator.js +2 -2
- package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -1
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -1
- package/dist/deferred.d.ts +2 -2
- package/dist/deferred.js.map +1 -1
- package/dist/diagnosticUtils.d.ts +1 -0
- package/dist/diagnosticUtils.js +4 -3
- package/dist/diagnosticUtils.js.map +1 -1
- package/dist/examples/plugins/removePrint.js +1 -1
- package/dist/examples/plugins/removePrint.js.map +1 -1
- package/dist/files/AssetFile.d.ts +26 -0
- package/dist/files/AssetFile.js +26 -0
- package/dist/files/AssetFile.js.map +1 -0
- package/dist/files/BrsFile.Class.spec.js +241 -40
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +66 -16
- package/dist/files/BrsFile.js +330 -80
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +1134 -167
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/Factory.d.ts +25 -0
- package/dist/files/Factory.js +22 -0
- package/dist/files/Factory.js.map +1 -0
- package/dist/files/File.d.ts +106 -0
- package/dist/files/File.js +16 -0
- package/dist/files/File.js.map +1 -0
- package/dist/files/LazyFileData.d.ts +20 -0
- package/dist/files/LazyFileData.js +54 -0
- package/dist/files/LazyFileData.js.map +1 -0
- package/dist/files/LazyFileData.spec.d.ts +1 -0
- package/dist/files/LazyFileData.spec.js +27 -0
- package/dist/files/LazyFileData.spec.js.map +1 -0
- package/dist/files/XmlFile.d.ts +55 -17
- package/dist/files/XmlFile.js +88 -47
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/files/XmlFile.spec.js +64 -57
- package/dist/files/XmlFile.spec.js.map +1 -1
- package/dist/files/tests/imports.spec.js +21 -8
- package/dist/files/tests/imports.spec.js.map +1 -1
- package/dist/files/tests/optionalChaning.spec.js +14 -14
- package/dist/files/tests/optionalChaning.spec.js.map +1 -1
- package/dist/globalCallables.js +1 -1
- package/dist/globalCallables.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +357 -89
- package/dist/interfaces.js +10 -2
- package/dist/interfaces.js.map +1 -1
- package/dist/lexer/Lexer.js +1 -1
- package/dist/lexer/TokenKind.d.ts +1 -0
- package/dist/lexer/TokenKind.js +4 -1
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/parser/AstNode.d.ts +2 -2
- package/dist/parser/AstNode.js +1 -1
- package/dist/parser/AstNode.js.map +1 -1
- package/dist/parser/BrsTranspileState.d.ts +3 -2
- package/dist/parser/BrsTranspileState.js +3 -2
- package/dist/parser/BrsTranspileState.js.map +1 -1
- package/dist/parser/Expression.d.ts +2 -2
- package/dist/parser/Expression.js +23 -19
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +103 -0
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.js +61 -13
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.js +227 -1
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/SGParser.d.ts +2 -2
- package/dist/parser/SGParser.js +3 -3
- package/dist/parser/SGParser.js.map +1 -1
- package/dist/parser/SGParser.spec.js +2 -2
- package/dist/parser/SGParser.spec.js.map +1 -1
- package/dist/parser/SGTypes.d.ts +1 -1
- package/dist/parser/Statement.d.ts +12 -5
- package/dist/parser/Statement.js +56 -26
- package/dist/parser/Statement.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/RegexLiteralExpression.spec.js +10 -10
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +24 -24
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js +64 -36
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.js +34 -34
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/UnaryExpression.spec.d.ts +1 -0
- package/dist/parser/tests/expression/UnaryExpression.spec.js +52 -0
- package/dist/parser/tests/expression/UnaryExpression.spec.js.map +1 -0
- package/dist/parser/tests/statement/ConstStatement.spec.js +90 -16
- package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Continue.spec.js +2 -2
- package/dist/parser/tests/statement/Continue.spec.js.map +1 -1
- package/dist/parser/tests/statement/Enum.spec.js +35 -26
- package/dist/parser/tests/statement/Enum.spec.js.map +1 -1
- package/dist/parser/tests/statement/For.spec.js +6 -6
- package/dist/parser/tests/statement/For.spec.js.map +1 -1
- package/dist/parser/tests/statement/ForEach.spec.js +4 -4
- package/dist/parser/tests/statement/ForEach.spec.js.map +1 -1
- package/dist/parser/tests/statement/InterfaceStatement.spec.js +20 -12
- package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/PrintStatement.spec.js +10 -10
- package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
- package/dist/preprocessor/Manifest.d.ts +1 -1
- package/dist/preprocessor/Manifest.js +2 -2
- package/dist/preprocessor/Manifest.js.map +1 -1
- package/dist/roku-types/data.json +98 -193
- package/dist/roku-types/index.d.ts +15 -11
- package/dist/types/ArrayType.d.ts +1 -1
- package/dist/types/ArrayType.js +4 -0
- package/dist/types/ArrayType.js.map +1 -1
- package/dist/types/ArrayType.spec.js +1 -1
- package/dist/types/ArrayType.spec.js.map +1 -1
- package/dist/types/AssociativeArrayType.d.ts +1 -1
- package/dist/types/AssociativeArrayType.js +1 -1
- package/dist/types/AssociativeArrayType.js.map +1 -1
- package/dist/types/BooleanType.d.ts +1 -1
- package/dist/types/BooleanType.js +2 -1
- package/dist/types/BooleanType.js.map +1 -1
- package/dist/types/BscType.d.ts +2 -2
- package/dist/types/BscType.js +30 -9
- package/dist/types/BscType.js.map +1 -1
- package/dist/types/BuiltInInterfaceAdder.d.ts +3 -0
- package/dist/types/BuiltInInterfaceAdder.js +37 -16
- package/dist/types/BuiltInInterfaceAdder.js.map +1 -1
- package/dist/types/BuiltInInterfaceAdder.spec.js +7 -0
- package/dist/types/BuiltInInterfaceAdder.spec.js.map +1 -1
- package/dist/types/ClassType.d.ts +4 -3
- package/dist/types/ClassType.js +6 -3
- package/dist/types/ClassType.js.map +1 -1
- package/dist/types/ClassType.spec.js +5 -3
- package/dist/types/ClassType.spec.js.map +1 -1
- package/dist/types/ComponentType.d.ts +1 -1
- package/dist/types/ComponentType.js +3 -0
- package/dist/types/ComponentType.js.map +1 -1
- package/dist/types/DoubleType.js +3 -1
- package/dist/types/DoubleType.js.map +1 -1
- package/dist/types/EnumType.d.ts +1 -1
- package/dist/types/EnumType.js +7 -2
- package/dist/types/EnumType.js.map +1 -1
- package/dist/types/FloatType.js +3 -1
- package/dist/types/FloatType.js.map +1 -1
- package/dist/types/InheritableType.d.ts +7 -4
- package/dist/types/InheritableType.js +67 -3
- package/dist/types/InheritableType.js.map +1 -1
- package/dist/types/IntegerType.js +3 -1
- package/dist/types/IntegerType.js.map +1 -1
- package/dist/types/InterfaceType.d.ts +5 -4
- package/dist/types/InterfaceType.js +5 -12
- package/dist/types/InterfaceType.js.map +1 -1
- package/dist/types/InterfaceType.spec.js +23 -0
- package/dist/types/InterfaceType.spec.js.map +1 -1
- package/dist/types/LongIntegerType.js +3 -1
- package/dist/types/LongIntegerType.js.map +1 -1
- package/dist/types/NamespaceType.d.ts +2 -1
- package/dist/types/NamespaceType.js +3 -0
- package/dist/types/NamespaceType.js.map +1 -1
- package/dist/types/ObjectType.d.ts +1 -1
- package/dist/types/ReferenceType.js +40 -6
- package/dist/types/ReferenceType.js.map +1 -1
- package/dist/types/StringType.js +2 -2
- package/dist/types/StringType.js.map +1 -1
- package/dist/types/TypedFunctionType.d.ts +6 -1
- package/dist/types/TypedFunctionType.js +46 -16
- package/dist/types/TypedFunctionType.js.map +1 -1
- package/dist/types/TypedFunctionType.spec.js +99 -0
- package/dist/types/TypedFunctionType.spec.js.map +1 -1
- package/dist/types/UnionType.js +8 -0
- package/dist/types/UnionType.js.map +1 -1
- package/dist/types/helper.spec.js +15 -0
- package/dist/types/helper.spec.js.map +1 -1
- package/dist/types/helpers.d.ts +3 -0
- package/dist/types/helpers.js +33 -1
- package/dist/types/helpers.js.map +1 -1
- package/dist/util.d.ts +25 -9
- package/dist/util.js +165 -72
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +2 -2
- package/dist/astUtils/AstEditor.js.map +0 -1
- package/dist/astUtils/AstEditor.spec.js.map +0 -1
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +0 -1
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js +0 -31
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js.map +0 -1
- /package/dist/astUtils/{AstEditor.spec.d.ts → Editor.spec.d.ts} +0 -0
- /package/dist/bscPlugin/{transpile/BrsFilePreTranspileProcessor.spec.d.ts → serialize/BslibInjector.spec.d.ts} +0 -0
package/dist/Scope.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.Scope = void 0;
|
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const chalk_1 = require("chalk");
|
|
6
6
|
const DiagnosticMessages_1 = require("./DiagnosticMessages");
|
|
7
|
+
const interfaces_1 = require("./interfaces");
|
|
7
8
|
const ClassValidator_1 = require("./validators/ClassValidator");
|
|
8
9
|
const Parser_1 = require("./parser/Parser");
|
|
9
10
|
const util_1 = require("./util");
|
|
@@ -40,6 +41,7 @@ class Scope {
|
|
|
40
41
|
* A list of functions that will be called whenever `unlinkSymbolTable` is called
|
|
41
42
|
*/
|
|
42
43
|
this.linkSymbolTableDisposables = [];
|
|
44
|
+
this.symbolsAddedDuringLinking = [];
|
|
43
45
|
this.isValidated = false;
|
|
44
46
|
//used for improved logging performance
|
|
45
47
|
this._debugLogComponentName = `Scope '${chalk_1.default.redBright(this.name)}'`;
|
|
@@ -53,6 +55,20 @@ class Scope {
|
|
|
53
55
|
* "namea", "namea.nameb", "namea.nameb.namec"
|
|
54
56
|
*/
|
|
55
57
|
get namespaceLookup() {
|
|
58
|
+
let allFilesValidated = true;
|
|
59
|
+
for (const file of this.getAllFiles()) {
|
|
60
|
+
if ((0, reflection_1.isBrsFile)(file) && !file.hasTypedef) {
|
|
61
|
+
allFilesValidated = allFilesValidated && file.isValidated;
|
|
62
|
+
if (!allFilesValidated) {
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (!allFilesValidated) {
|
|
68
|
+
// This is not fit to cache
|
|
69
|
+
// Since the files have not been validated, all namespace info might not have been available
|
|
70
|
+
return this.buildNamespaceLookup();
|
|
71
|
+
}
|
|
56
72
|
return this.cache.getOrAdd('namespaceLookup', () => this.buildNamespaceLookup());
|
|
57
73
|
}
|
|
58
74
|
/**
|
|
@@ -356,14 +372,14 @@ class Scope {
|
|
|
356
372
|
}
|
|
357
373
|
/**
|
|
358
374
|
* Get the file from this scope with the given path.
|
|
359
|
-
* @param filePath can be a srcPath or
|
|
375
|
+
* @param filePath can be a srcPath or destPath
|
|
360
376
|
* @param normalizePath should this function repair and standardize the path? Passing false should have a performance boost if you can guarantee your path is already sanitized
|
|
361
377
|
*/
|
|
362
378
|
getFile(filePath, normalizePath = true) {
|
|
363
379
|
if (typeof filePath !== 'string') {
|
|
364
380
|
return undefined;
|
|
365
381
|
}
|
|
366
|
-
const key = path.isAbsolute(filePath) ? 'srcPath' : '
|
|
382
|
+
const key = path.isAbsolute(filePath) ? 'srcPath' : 'destPath';
|
|
367
383
|
let map = this.cache.getOrAdd('fileMaps-srcPath', () => {
|
|
368
384
|
const result = new Map();
|
|
369
385
|
for (const file of this.getAllFiles()) {
|
|
@@ -404,26 +420,26 @@ class Scope {
|
|
|
404
420
|
}
|
|
405
421
|
}
|
|
406
422
|
}
|
|
407
|
-
this.logDebug('getAllFiles', () => result.map(x => x.
|
|
423
|
+
this.logDebug('getAllFiles', () => result.map(x => x.destPath));
|
|
408
424
|
return result;
|
|
409
425
|
});
|
|
410
426
|
}
|
|
411
427
|
/**
|
|
412
|
-
* Get the list of errors for this scope. It's calculated on the fly, so
|
|
413
|
-
* call this sparingly.
|
|
428
|
+
* Get the list of errors for this scope. It's calculated on the fly, so call this sparingly.
|
|
414
429
|
*/
|
|
415
430
|
getDiagnostics() {
|
|
416
|
-
let diagnosticLists = [this.diagnostics];
|
|
417
431
|
//add diagnostics from every referenced file
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
432
|
+
const diagnostics = [
|
|
433
|
+
//diagnostics raised on this scope
|
|
434
|
+
...this.diagnostics,
|
|
435
|
+
//get diagnostics from all files
|
|
436
|
+
...this.getOwnFiles().map(x => { var _a; return (_a = x.diagnostics) !== null && _a !== void 0 ? _a : []; }).flat()
|
|
437
|
+
]
|
|
438
|
+
//exclude diagnostics that match any of the comment flags
|
|
439
|
+
.filter((x) => {
|
|
423
440
|
return !util_1.util.diagnosticIsSuppressed(x);
|
|
424
441
|
});
|
|
425
|
-
|
|
426
|
-
return filteredDiagnostics;
|
|
442
|
+
return diagnostics;
|
|
427
443
|
}
|
|
428
444
|
addDiagnostics(diagnostics) {
|
|
429
445
|
this.diagnostics.push(...diagnostics);
|
|
@@ -481,7 +497,7 @@ class Scope {
|
|
|
481
497
|
const files = this.getOwnFiles();
|
|
482
498
|
for (const file of files) {
|
|
483
499
|
//either XML components or files without a typedef
|
|
484
|
-
if ((0, reflection_1.isXmlFile)(file) || !file.hasTypedef) {
|
|
500
|
+
if ((0, reflection_1.isXmlFile)(file) || ((0, reflection_1.isBrsFile)(file) && !file.hasTypedef)) {
|
|
485
501
|
callback(file);
|
|
486
502
|
}
|
|
487
503
|
}
|
|
@@ -492,14 +508,16 @@ class Scope {
|
|
|
492
508
|
*/
|
|
493
509
|
getOwnCallables() {
|
|
494
510
|
let result = [];
|
|
495
|
-
this.logDebug('getOwnCallables() files: ', () => this.getOwnFiles().map(x => x.
|
|
511
|
+
this.logDebug('getOwnCallables() files: ', () => this.getOwnFiles().map(x => x.destPath));
|
|
496
512
|
//get callables from own files
|
|
497
513
|
this.enumerateOwnFiles((file) => {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
514
|
+
if ((0, reflection_1.isBrsFile)(file)) {
|
|
515
|
+
for (let callable of file.callables) {
|
|
516
|
+
result.push({
|
|
517
|
+
callable: callable,
|
|
518
|
+
scope: this
|
|
519
|
+
});
|
|
520
|
+
}
|
|
503
521
|
}
|
|
504
522
|
});
|
|
505
523
|
return result;
|
|
@@ -507,74 +525,27 @@ class Scope {
|
|
|
507
525
|
/**
|
|
508
526
|
* Builds a tree of namespace objects
|
|
509
527
|
*/
|
|
510
|
-
buildNamespaceLookup() {
|
|
528
|
+
buildNamespaceLookup(options = { okToCache: true }) {
|
|
511
529
|
let namespaceLookup = new Map();
|
|
530
|
+
options.okToCache = true;
|
|
512
531
|
this.enumerateBrsFiles((file) => {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
for (let i = 0; i < nameParts.length; i++) {
|
|
521
|
-
let part = nameParts[i];
|
|
522
|
-
let lowerPartName = part.text.toLowerCase();
|
|
523
|
-
if (i === 0) {
|
|
524
|
-
loopName = part.text;
|
|
525
|
-
lowerLoopName = lowerPartName;
|
|
526
|
-
}
|
|
527
|
-
else {
|
|
528
|
-
parentNameLower = lowerLoopName;
|
|
529
|
-
loopName += '.' + part.text;
|
|
530
|
-
lowerLoopName += '.' + lowerPartName;
|
|
531
|
-
}
|
|
532
|
-
if (!namespaceLookup.has(lowerLoopName)) {
|
|
533
|
-
namespaceLookup.set(lowerLoopName, {
|
|
534
|
-
file: file,
|
|
535
|
-
fullName: loopName,
|
|
536
|
-
fullNameLower: lowerLoopName,
|
|
537
|
-
parentNameLower: parentNameLower,
|
|
538
|
-
nameParts: nameParts.slice(0, i),
|
|
539
|
-
nameRange: namespaceStatement.nameExpression.range,
|
|
540
|
-
lastPartName: part.text,
|
|
541
|
-
lastPartNameLower: lowerPartName,
|
|
542
|
-
namespaces: new Map(),
|
|
543
|
-
classStatements: new Map(),
|
|
544
|
-
functionStatements: new Map(),
|
|
545
|
-
enumStatements: new Map(),
|
|
546
|
-
constStatements: new Map(),
|
|
547
|
-
statements: [],
|
|
548
|
-
// the aggregate symbol table should have no parent. It should include just the symbols of the namespace.
|
|
549
|
-
symbolTable: new SymbolTable_1.SymbolTable(`Namespace Aggregate: '${loopName}'`)
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
let ns = namespaceLookup.get(lowerLoopName);
|
|
554
|
-
ns.statements.push(...namespaceStatement.body.statements);
|
|
555
|
-
for (let statement of namespaceStatement.body.statements) {
|
|
556
|
-
if ((0, reflection_1.isClassStatement)(statement) && statement.name) {
|
|
557
|
-
ns.classStatements.set(statement.name.text.toLowerCase(), statement);
|
|
558
|
-
}
|
|
559
|
-
else if ((0, reflection_1.isFunctionStatement)(statement) && statement.name) {
|
|
560
|
-
ns.functionStatements.set(statement.name.text.toLowerCase(), statement);
|
|
561
|
-
}
|
|
562
|
-
else if ((0, reflection_1.isEnumStatement)(statement) && statement.fullName) {
|
|
563
|
-
ns.enumStatements.set(statement.fullName.toLowerCase(), statement);
|
|
564
|
-
}
|
|
565
|
-
else if ((0, reflection_1.isConstStatement)(statement) && statement.fullName) {
|
|
566
|
-
ns.constStatements.set(statement.fullName.toLowerCase(), statement);
|
|
567
|
-
}
|
|
532
|
+
options.okToCache = options.okToCache && file.isValidated;
|
|
533
|
+
const fileNamespaceLookup = file.getNamespaceLookupObject();
|
|
534
|
+
for (const [lowerNamespaceName, nsContainer] of fileNamespaceLookup) {
|
|
535
|
+
if (!namespaceLookup.has(lowerNamespaceName)) {
|
|
536
|
+
const clonedNsContainer = Object.assign(Object.assign({}, nsContainer), { namespaceStatements: [...nsContainer.namespaceStatements], symbolTable: new SymbolTable_1.SymbolTable(`Namespace Aggregate: '${nsContainer.fullName}'`) });
|
|
537
|
+
clonedNsContainer.symbolTable.mergeSymbolTable(nsContainer.symbolTable);
|
|
538
|
+
namespaceLookup.set(lowerNamespaceName, clonedNsContainer);
|
|
568
539
|
}
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
540
|
+
else {
|
|
541
|
+
const existingContainer = namespaceLookup.get(lowerNamespaceName);
|
|
542
|
+
existingContainer.classStatements = new Map([...existingContainer.classStatements, ...nsContainer.classStatements]);
|
|
543
|
+
existingContainer.constStatements = new Map([...existingContainer.constStatements, ...nsContainer.constStatements]);
|
|
544
|
+
existingContainer.enumStatements = new Map([...existingContainer.enumStatements, ...nsContainer.enumStatements]);
|
|
545
|
+
existingContainer.functionStatements = new Map([...existingContainer.functionStatements, ...nsContainer.functionStatements]);
|
|
546
|
+
existingContainer.namespaces = new Map([...existingContainer.namespaces, ...nsContainer.namespaces]);
|
|
547
|
+
existingContainer.namespaceStatements.push(...nsContainer.namespaceStatements);
|
|
548
|
+
existingContainer.symbolTable.mergeSymbolTable(nsContainer.symbolTable);
|
|
578
549
|
}
|
|
579
550
|
}
|
|
580
551
|
});
|
|
@@ -590,9 +561,9 @@ class Scope {
|
|
|
590
561
|
logDebug(...args) {
|
|
591
562
|
this.program.logger.debug(this._debugLogComponentName, ...args);
|
|
592
563
|
}
|
|
593
|
-
validate(
|
|
564
|
+
validate(validationOptions = { force: false }) {
|
|
594
565
|
//if this scope is already validated, no need to revalidate
|
|
595
|
-
if (this.isValidated === true && !force) {
|
|
566
|
+
if (this.isValidated === true && !validationOptions.force) {
|
|
596
567
|
this.logDebug('validate(): already validated');
|
|
597
568
|
return;
|
|
598
569
|
}
|
|
@@ -601,10 +572,10 @@ class Scope {
|
|
|
601
572
|
//validate our parent before we validate ourself
|
|
602
573
|
if (parentScope && parentScope.isValidated === false) {
|
|
603
574
|
this.logDebug('validate(): validating parent first');
|
|
604
|
-
parentScope.validate(
|
|
575
|
+
parentScope.validate(validationOptions);
|
|
605
576
|
}
|
|
606
577
|
//clear the scope's errors list (we will populate them from this method)
|
|
607
|
-
this.
|
|
578
|
+
this.clearScopeLevelDiagnostics();
|
|
608
579
|
let callables = this.getAllCallables();
|
|
609
580
|
//sort the callables by filepath and then method name, so the errors will be consistent
|
|
610
581
|
// eslint-disable-next-line prefer-arrow-callback
|
|
@@ -635,7 +606,9 @@ class Scope {
|
|
|
635
606
|
this.linkSymbolTable();
|
|
636
607
|
const scopeValidateEvent = {
|
|
637
608
|
program: this.program,
|
|
638
|
-
scope: this
|
|
609
|
+
scope: this,
|
|
610
|
+
changedFiles: validationOptions === null || validationOptions === void 0 ? void 0 : validationOptions.changedFiles,
|
|
611
|
+
changedSymbols: validationOptions === null || validationOptions === void 0 ? void 0 : validationOptions.changedSymbols
|
|
639
612
|
};
|
|
640
613
|
this.program.plugins.emit('beforeScopeValidate', scopeValidateEvent);
|
|
641
614
|
this.program.plugins.emit('onScopeValidate', scopeValidateEvent);
|
|
@@ -660,6 +633,16 @@ class Scope {
|
|
|
660
633
|
this.detectVariableNamespaceCollisions(file);
|
|
661
634
|
});
|
|
662
635
|
}
|
|
636
|
+
clearAstSegmentDiagnostics(astSegment) {
|
|
637
|
+
this.diagnostics = this.diagnostics.filter(diag => !(diag.origin === interfaces_1.DiagnosticOrigin.ASTSegment && diag.astSegment === astSegment));
|
|
638
|
+
}
|
|
639
|
+
clearAstSegmentDiagnosticsByFile(file) {
|
|
640
|
+
const lowerSrcPath = file.srcPath.toLowerCase();
|
|
641
|
+
this.diagnostics = this.diagnostics.filter(diag => !(diag.origin === interfaces_1.DiagnosticOrigin.ASTSegment && diag.file.srcPath.toLowerCase() === lowerSrcPath));
|
|
642
|
+
}
|
|
643
|
+
clearScopeLevelDiagnostics() {
|
|
644
|
+
this.diagnostics = this.diagnostics.filter(diag => diag.origin !== interfaces_1.DiagnosticOrigin.Scope);
|
|
645
|
+
}
|
|
663
646
|
/**
|
|
664
647
|
* Mark this scope as invalid, which means its `validate()` function needs to be called again before use.
|
|
665
648
|
*/
|
|
@@ -701,69 +684,68 @@ class Scope {
|
|
|
701
684
|
* ```
|
|
702
685
|
*/
|
|
703
686
|
linkSymbolTable() {
|
|
687
|
+
var _a;
|
|
704
688
|
SymbolTable_1.SymbolTable.cacheVerifier.generateToken();
|
|
705
|
-
const allNamespaces = [];
|
|
706
689
|
for (const file of this.getAllFiles()) {
|
|
707
690
|
if ((0, reflection_1.isBrsFile)(file)) {
|
|
708
691
|
this.linkSymbolTableDisposables.push(file.parser.symbolTable.pushParentProvider(() => this.symbolTable));
|
|
709
|
-
allNamespaces.push(...file.parser.references.namespaceStatements);
|
|
710
692
|
}
|
|
711
693
|
}
|
|
712
|
-
const aggregatesAdded = new Set();
|
|
713
694
|
//Add namespace aggregates to namespace member tables
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
for (let i = 1; i < namespaceParts.length; i++) {
|
|
719
|
-
fullNamespaceName += '.' + namespaceParts[i].text;
|
|
720
|
-
}
|
|
721
|
-
// eslint-disable-next-line no-bitwise
|
|
722
|
-
let getTypeOptions = { flags: SymbolTable_1.SymbolTypeFlag.runtime | SymbolTable_1.SymbolTypeFlag.typetime };
|
|
695
|
+
const namespaceTypesKnown = new Map();
|
|
696
|
+
// eslint-disable-next-line no-bitwise
|
|
697
|
+
let getTypeOptions = { flags: SymbolTable_1.SymbolTypeFlag.runtime | SymbolTable_1.SymbolTypeFlag.typetime };
|
|
698
|
+
for (const [nsName, nsContainer] of this.namespaceLookup) {
|
|
723
699
|
let currentNSType = null;
|
|
724
|
-
let
|
|
725
|
-
const
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
symbolTable.addSymbol(nsNamePart, { definingNode: namespace }, currentNSType, getTypeOptions.flags);
|
|
747
|
-
}
|
|
700
|
+
let parentNSType = null;
|
|
701
|
+
const existingNsStmt = (_a = nsContainer.namespaceStatements) === null || _a === void 0 ? void 0 : _a[0];
|
|
702
|
+
if (!nsContainer.isTopLevel) {
|
|
703
|
+
parentNSType = namespaceTypesKnown.get(nsContainer.parentNameLower);
|
|
704
|
+
if (!parentNSType) {
|
|
705
|
+
// we don't know about the parent namespace... uh, oh!
|
|
706
|
+
break;
|
|
707
|
+
}
|
|
708
|
+
currentNSType = parentNSType.getMemberType(nsContainer.fullNameLower, getTypeOptions);
|
|
709
|
+
}
|
|
710
|
+
else {
|
|
711
|
+
currentNSType = this.symbolTable.getSymbolType(nsContainer.fullNameLower, getTypeOptions);
|
|
712
|
+
}
|
|
713
|
+
if (!(0, reflection_1.isNamespaceType)(currentNSType)) {
|
|
714
|
+
if (!currentNSType || (0, reflection_1.isReferenceType)(currentNSType)) {
|
|
715
|
+
currentNSType = existingNsStmt
|
|
716
|
+
? existingNsStmt.getType(getTypeOptions)
|
|
717
|
+
: new NamespaceType_1.NamespaceType(nsName);
|
|
718
|
+
if (parentNSType) {
|
|
719
|
+
// adding as a member of existing NS
|
|
720
|
+
parentNSType.addMember(nsContainer.lastPartName, { definingNode: existingNsStmt }, currentNSType, getTypeOptions.flags);
|
|
721
|
+
this.symbolsAddedDuringLinking.push({ symbolTable: parentNSType.getMemberTable(), name: nsContainer.lastPartName, flags: getTypeOptions.flags });
|
|
748
722
|
}
|
|
749
723
|
else {
|
|
750
|
-
|
|
724
|
+
this.symbolTable.addSymbol(nsContainer.lastPartName, { definingNode: existingNsStmt }, currentNSType, getTypeOptions.flags);
|
|
725
|
+
this.symbolsAddedDuringLinking.push({ symbolTable: this.symbolTable, name: nsContainer.lastPartName, flags: getTypeOptions.flags });
|
|
751
726
|
}
|
|
752
727
|
}
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
let aggregateNSSymbolTable = this.namespaceLookup.get(nameSoFar.toLowerCase()).symbolTable;
|
|
756
|
-
if (!aggregatesAdded.has(lowerNameSpace)) {
|
|
757
|
-
this.linkSymbolTableDisposables.push(currentNSType.memberTable.addSibling(aggregateNSSymbolTable));
|
|
758
|
-
aggregatesAdded.add(lowerNameSpace);
|
|
759
|
-
}
|
|
760
|
-
if (isFinalNamespace) {
|
|
761
|
-
this.linkSymbolTableDisposables.push(namespace.getSymbolTable().addSibling(aggregateNSSymbolTable));
|
|
728
|
+
else {
|
|
729
|
+
break;
|
|
762
730
|
}
|
|
763
731
|
}
|
|
732
|
+
else {
|
|
733
|
+
// Existing known namespace
|
|
734
|
+
}
|
|
735
|
+
if (!namespaceTypesKnown.has(nsName)) {
|
|
736
|
+
namespaceTypesKnown.set(nsName, currentNSType);
|
|
737
|
+
}
|
|
738
|
+
for (let nsStmt of nsContainer.namespaceStatements) {
|
|
739
|
+
this.linkSymbolTableDisposables.push(nsStmt === null || nsStmt === void 0 ? void 0 : nsStmt.getSymbolTable().addSibling(nsContainer.symbolTable));
|
|
740
|
+
}
|
|
741
|
+
this.linkSymbolTableDisposables.push(currentNSType.memberTable.addSibling(nsContainer.symbolTable));
|
|
764
742
|
}
|
|
765
743
|
}
|
|
766
744
|
unlinkSymbolTable() {
|
|
745
|
+
for (const symbolToRemove of this.symbolsAddedDuringLinking) {
|
|
746
|
+
this.symbolTable.removeSymbol(symbolToRemove.name);
|
|
747
|
+
}
|
|
748
|
+
this.symbolsAddedDuringLinking = [];
|
|
767
749
|
for (const dispose of this.linkSymbolTableDisposables) {
|
|
768
750
|
dispose();
|
|
769
751
|
}
|
|
@@ -778,7 +760,7 @@ class Scope {
|
|
|
778
760
|
let namespace = this.getNamespace(lowerParamName, (_a = param.findAncestor(reflection_1.isNamespaceStatement)) === null || _a === void 0 ? void 0 : _a.getName(Parser_1.ParseMode.BrighterScript).toLowerCase());
|
|
779
761
|
//see if the param matches any starting namespace part
|
|
780
762
|
if (namespace) {
|
|
781
|
-
this.diagnostics.push(Object.assign(Object.assign({ file: file }, DiagnosticMessages_1.DiagnosticMessages.parameterMayNotHaveSameNameAsNamespace(param.name.text)), { range: param.name.range, relatedInformation: [{
|
|
763
|
+
this.diagnostics.push(Object.assign(Object.assign({ origin: interfaces_1.DiagnosticOrigin.Scope, file: file }, DiagnosticMessages_1.DiagnosticMessages.parameterMayNotHaveSameNameAsNamespace(param.name.text)), { range: param.name.range, relatedInformation: [{
|
|
782
764
|
message: 'Namespace declared here',
|
|
783
765
|
location: util_1.util.createLocation(vscode_uri_1.URI.file(namespace.file.srcPath).toString(), namespace.nameRange)
|
|
784
766
|
}] }));
|
|
@@ -790,7 +772,7 @@ class Scope {
|
|
|
790
772
|
let namespace = this.getNamespace(lowerAssignmentName, (_b = assignment.findAncestor(reflection_1.isNamespaceStatement)) === null || _b === void 0 ? void 0 : _b.getName(Parser_1.ParseMode.BrighterScript).toLowerCase());
|
|
791
773
|
//see if the param matches any starting namespace part
|
|
792
774
|
if (namespace) {
|
|
793
|
-
this.diagnostics.push(Object.assign(Object.assign({ file: file }, DiagnosticMessages_1.DiagnosticMessages.variableMayNotHaveSameNameAsNamespace(assignment.name.text)), { range: assignment.name.range, relatedInformation: [{
|
|
775
|
+
this.diagnostics.push(Object.assign(Object.assign({ origin: interfaces_1.DiagnosticOrigin.Scope, file: file }, DiagnosticMessages_1.DiagnosticMessages.variableMayNotHaveSameNameAsNamespace(assignment.name.text)), { range: assignment.name.range, relatedInformation: [{
|
|
794
776
|
message: 'Namespace declared here',
|
|
795
777
|
location: util_1.util.createLocation(vscode_uri_1.URI.file(namespace.file.srcPath).toString(), namespace.nameRange)
|
|
796
778
|
}] }));
|
|
@@ -807,11 +789,11 @@ class Scope {
|
|
|
807
789
|
if (lowerFuncName) {
|
|
808
790
|
//find function declarations with the same name as a stdlib function
|
|
809
791
|
if (globalCallables_1.globalCallableMap.has(lowerFuncName)) {
|
|
810
|
-
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.scopeFunctionShadowedByBuiltInFunction()), { range: func.nameRange, file: file }));
|
|
792
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.scopeFunctionShadowedByBuiltInFunction()), { range: func.nameRange, file: file, origin: interfaces_1.DiagnosticOrigin.Scope }));
|
|
811
793
|
}
|
|
812
794
|
//find any functions that have the same name as a class
|
|
813
795
|
if (this.hasClass(lowerFuncName)) {
|
|
814
|
-
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.functionCannotHaveSameNameAsClass(funcName)), { range: func.nameRange, file: file }));
|
|
796
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.functionCannotHaveSameNameAsClass(funcName)), { range: func.nameRange, file: file, origin: interfaces_1.DiagnosticOrigin.Scope }));
|
|
815
797
|
}
|
|
816
798
|
}
|
|
817
799
|
}
|
|
@@ -830,7 +812,9 @@ class Scope {
|
|
|
830
812
|
validateClasses() {
|
|
831
813
|
let validator = new ClassValidator_1.BsClassValidator();
|
|
832
814
|
validator.validate(this);
|
|
833
|
-
this.diagnostics.push(...validator.diagnostics
|
|
815
|
+
this.diagnostics.push(...validator.diagnostics.map(diag => {
|
|
816
|
+
return Object.assign(Object.assign({}, diag), { origin: interfaces_1.DiagnosticOrigin.Scope });
|
|
817
|
+
}));
|
|
834
818
|
}
|
|
835
819
|
/**
|
|
836
820
|
* Detect local variables (function scope) that have the same name as scope calls
|
|
@@ -839,39 +823,34 @@ class Scope {
|
|
|
839
823
|
var _a;
|
|
840
824
|
const classMap = this.getClassMap();
|
|
841
825
|
//loop through every function scope
|
|
842
|
-
for (let
|
|
826
|
+
for (let funcScope of file.functionScopes) {
|
|
843
827
|
//every var declaration in this function scope
|
|
844
|
-
for (let varDeclaration of
|
|
828
|
+
for (let varDeclaration of funcScope.variableDeclarations) {
|
|
845
829
|
const varName = varDeclaration.name;
|
|
846
830
|
const lowerVarName = varName.toLowerCase();
|
|
847
|
-
|
|
848
|
-
|
|
831
|
+
const varIsFunction = () => {
|
|
832
|
+
return (0, reflection_1.isCallableType)(varDeclaration.getType());
|
|
833
|
+
};
|
|
834
|
+
if (
|
|
835
|
+
//has same name as stdlib
|
|
836
|
+
globalCallables_1.globalCallableMap.has(lowerVarName)) {
|
|
849
837
|
//local var function with same name as stdlib function
|
|
850
|
-
if (
|
|
851
|
-
|
|
852
|
-
globalCallables_1.globalCallableMap.has(lowerVarName)) {
|
|
853
|
-
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarFunctionShadowsParentFunction('stdlib')), { range: varDeclaration.nameRange, file: file }));
|
|
854
|
-
//this check needs to come after the stdlib one, because the stdlib functions are included
|
|
855
|
-
//in the scope function list
|
|
856
|
-
}
|
|
857
|
-
else if (
|
|
858
|
-
//has same name as scope function
|
|
859
|
-
callableContainerMap.has(lowerVarName)) {
|
|
860
|
-
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarFunctionShadowsParentFunction('scope')), { range: varDeclaration.nameRange, file: file }));
|
|
838
|
+
if (varIsFunction()) {
|
|
839
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarFunctionShadowsParentFunction('stdlib')), { range: varDeclaration.nameRange, file: file, origin: interfaces_1.DiagnosticOrigin.Scope }));
|
|
861
840
|
}
|
|
862
|
-
//var is not a function
|
|
863
841
|
}
|
|
864
|
-
else if (
|
|
865
|
-
//is NOT a callable from stdlib (because non-function local vars can have same name as stdlib names)
|
|
866
|
-
!globalCallables_1.globalCallableMap.has(lowerVarName)) {
|
|
842
|
+
else if (callableContainerMap.has(lowerVarName)) {
|
|
867
843
|
//is same name as a callable
|
|
868
|
-
if (
|
|
869
|
-
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.
|
|
870
|
-
//has the same name as an in-scope class
|
|
844
|
+
if (varIsFunction()) {
|
|
845
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarFunctionShadowsParentFunction('scope')), { range: varDeclaration.nameRange, file: file, origin: interfaces_1.DiagnosticOrigin.Scope }));
|
|
871
846
|
}
|
|
872
|
-
else
|
|
873
|
-
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.
|
|
847
|
+
else {
|
|
848
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarShadowedByScopedFunction()), { range: varDeclaration.nameRange, file: file, origin: interfaces_1.DiagnosticOrigin.Scope }));
|
|
874
849
|
}
|
|
850
|
+
//has the same name as an in-scope class
|
|
851
|
+
}
|
|
852
|
+
else if (classMap.has(lowerVarName)) {
|
|
853
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarSameNameAsClass((_a = classMap.get(lowerVarName)) === null || _a === void 0 ? void 0 : _a.item.getName(Parser_1.ParseMode.BrighterScript))), { range: varDeclaration.nameRange, file: file, origin: interfaces_1.DiagnosticOrigin.Scope }));
|
|
875
854
|
}
|
|
876
855
|
}
|
|
877
856
|
}
|
|
@@ -910,9 +889,9 @@ class Scope {
|
|
|
910
889
|
//same file: skip redundant imports
|
|
911
890
|
continue;
|
|
912
891
|
}
|
|
913
|
-
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.overridesAncestorFunction(container.callable.name, container.scope.name, shadowedCallable.callable.file.
|
|
892
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.overridesAncestorFunction(container.callable.name, container.scope.name, shadowedCallable.callable.file.destPath,
|
|
914
893
|
//grab the last item in the list, which should be the closest ancestor's version
|
|
915
|
-
shadowedCallable.scope.name)), { range: container.callable.nameRange, file: container.callable.file }));
|
|
894
|
+
shadowedCallable.scope.name)), { range: container.callable.nameRange, file: container.callable.file, origin: interfaces_1.DiagnosticOrigin.Scope }));
|
|
916
895
|
}
|
|
917
896
|
}
|
|
918
897
|
}
|
|
@@ -920,7 +899,7 @@ class Scope {
|
|
|
920
899
|
if (ownCallables.length > 1) {
|
|
921
900
|
for (let callableContainer of ownCallables) {
|
|
922
901
|
let callable = callableContainer.callable;
|
|
923
|
-
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.duplicateFunctionImplementation(callable.name, callableContainer.scope.name)), { range: util_1.util.createRange(callable.nameRange.start.line, callable.nameRange.start.character, callable.nameRange.start.line, callable.nameRange.end.character), file: callable.file }));
|
|
902
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.duplicateFunctionImplementation(callable.name, callableContainer.scope.name)), { range: util_1.util.createRange(callable.nameRange.start.line, callable.nameRange.start.character, callable.nameRange.start.line, callable.nameRange.end.character), file: callable.file, origin: interfaces_1.DiagnosticOrigin.Scope }));
|
|
924
903
|
}
|
|
925
904
|
}
|
|
926
905
|
}
|
|
@@ -947,11 +926,11 @@ class Scope {
|
|
|
947
926
|
let scriptImports = this.getOwnScriptImports();
|
|
948
927
|
//verify every script import
|
|
949
928
|
for (let scriptImport of scriptImports) {
|
|
950
|
-
let referencedFile = this.getFileByRelativePath(scriptImport.
|
|
929
|
+
let referencedFile = this.getFileByRelativePath(scriptImport.destPath);
|
|
951
930
|
//if we can't find the file
|
|
952
931
|
if (!referencedFile) {
|
|
953
932
|
//skip the default bslib file, it will exist at transpile time but should not show up in the program during validation cycle
|
|
954
|
-
if (scriptImport.
|
|
933
|
+
if (scriptImport.destPath === this.program.bslibPkgPath) {
|
|
955
934
|
continue;
|
|
956
935
|
}
|
|
957
936
|
let dInfo;
|
|
@@ -961,11 +940,11 @@ class Scope {
|
|
|
961
940
|
else {
|
|
962
941
|
dInfo = DiagnosticMessages_1.DiagnosticMessages.referencedFileDoesNotExist();
|
|
963
942
|
}
|
|
964
|
-
this.diagnostics.push(Object.assign(Object.assign({}, dInfo), { range: scriptImport.filePathRange, file: scriptImport.sourceFile }));
|
|
943
|
+
this.diagnostics.push(Object.assign(Object.assign({}, dInfo), { range: scriptImport.filePathRange, file: scriptImport.sourceFile, origin: interfaces_1.DiagnosticOrigin.Scope }));
|
|
965
944
|
//if the character casing of the script import path does not match that of the actual path
|
|
966
945
|
}
|
|
967
|
-
else if (scriptImport.
|
|
968
|
-
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.scriptImportCaseMismatch(referencedFile.
|
|
946
|
+
else if (scriptImport.destPath !== referencedFile.destPath) {
|
|
947
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.scriptImportCaseMismatch(referencedFile.destPath)), { range: scriptImport.filePathRange, file: scriptImport.sourceFile, origin: interfaces_1.DiagnosticOrigin.Scope }));
|
|
969
948
|
}
|
|
970
949
|
}
|
|
971
950
|
}
|
|
@@ -978,7 +957,7 @@ class Scope {
|
|
|
978
957
|
}
|
|
979
958
|
let files = this.getAllFiles();
|
|
980
959
|
for (let file of files) {
|
|
981
|
-
if (file.
|
|
960
|
+
if (file.destPath.toLowerCase() === relativePath.toLowerCase()) {
|
|
982
961
|
return file;
|
|
983
962
|
}
|
|
984
963
|
}
|