brighterscript 1.0.0-alpha.4 → 1.0.0-alpha.41
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 +1393 -291
- package/README.md +72 -131
- package/bsconfig.schema.json +85 -1
- 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 +42 -0
- package/dist/AstValidationSegmenter.js +237 -0
- package/dist/AstValidationSegmenter.js.map +1 -0
- package/dist/BsConfig.d.ts +56 -6
- package/dist/BusyStatusTracker.d.ts +31 -0
- package/dist/BusyStatusTracker.js +83 -0
- package/dist/BusyStatusTracker.js.map +1 -0
- package/dist/Cache.d.ts +5 -6
- package/dist/Cache.js +12 -11
- package/dist/Cache.js.map +1 -1
- package/dist/CacheVerifier.d.ts +7 -0
- package/dist/CacheVerifier.js +20 -0
- package/dist/CacheVerifier.js.map +1 -0
- package/dist/CodeActionUtil.d.ts +6 -3
- package/dist/CodeActionUtil.js +19 -5
- package/dist/CodeActionUtil.js.map +1 -1
- package/dist/CommentFlagProcessor.d.ts +7 -6
- package/dist/CommentFlagProcessor.js +11 -8
- package/dist/CommentFlagProcessor.js.map +1 -1
- package/dist/CrossScopeValidator.d.ts +67 -0
- package/dist/CrossScopeValidator.js +617 -0
- package/dist/CrossScopeValidator.js.map +1 -0
- package/dist/DependencyGraph.d.ts +8 -3
- package/dist/DependencyGraph.js +49 -16
- package/dist/DependencyGraph.js.map +1 -1
- package/dist/DiagnosticCollection.d.ts +5 -3
- package/dist/DiagnosticCollection.js +21 -16
- package/dist/DiagnosticCollection.js.map +1 -1
- package/dist/DiagnosticFilterer.d.ts +8 -4
- package/dist/DiagnosticFilterer.js +90 -54
- package/dist/DiagnosticFilterer.js.map +1 -1
- package/dist/DiagnosticManager.d.ts +61 -0
- package/dist/DiagnosticManager.js +238 -0
- package/dist/DiagnosticManager.js.map +1 -0
- package/dist/DiagnosticMessages.d.ts +204 -24
- package/dist/DiagnosticMessages.js +266 -33
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/DiagnosticSeverityAdjuster.d.ts +7 -0
- package/dist/DiagnosticSeverityAdjuster.js +41 -0
- package/dist/DiagnosticSeverityAdjuster.js.map +1 -0
- package/dist/FunctionScope.d.ts +28 -0
- package/dist/FunctionScope.js +52 -0
- package/dist/FunctionScope.js.map +1 -0
- 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 +72 -47
- package/dist/LanguageServer.js +545 -314
- package/dist/LanguageServer.js.map +1 -1
- package/dist/Logger.d.ts +9 -10
- package/dist/Logger.js +36 -30
- package/dist/Logger.js.map +1 -1
- package/dist/PluginInterface.d.ts +29 -7
- package/dist/PluginInterface.js +90 -7
- package/dist/PluginInterface.js.map +1 -1
- package/dist/Program.d.ts +201 -100
- package/dist/Program.js +1079 -700
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +29 -18
- package/dist/ProgramBuilder.js +178 -141
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +144 -109
- package/dist/Scope.js +533 -552
- package/dist/Scope.js.map +1 -1
- package/dist/SemanticTokenUtils.d.ts +14 -0
- package/dist/SemanticTokenUtils.js +85 -0
- package/dist/SemanticTokenUtils.js.map +1 -0
- package/dist/Stopwatch.d.ts +4 -0
- package/dist/Stopwatch.js +8 -1
- package/dist/Stopwatch.js.map +1 -1
- package/dist/SymbolTable.d.ts +91 -24
- package/dist/SymbolTable.js +291 -64
- package/dist/SymbolTable.js.map +1 -1
- package/dist/SymbolTypeFlag.d.ts +9 -0
- package/dist/SymbolTypeFlag.js +14 -0
- package/dist/SymbolTypeFlag.js.map +1 -0
- package/dist/Throttler.d.ts +12 -0
- package/dist/Throttler.js +39 -0
- package/dist/Throttler.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/XmlScope.d.ts +5 -15
- package/dist/XmlScope.js +35 -87
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/CachedLookups.d.ts +50 -0
- package/dist/astUtils/CachedLookups.js +335 -0
- package/dist/astUtils/CachedLookups.js.map +1 -0
- package/dist/astUtils/CachedLookups.spec.js +39 -0
- package/dist/astUtils/CachedLookups.spec.js.map +1 -0
- package/dist/astUtils/Editor.d.ts +69 -0
- package/dist/astUtils/Editor.js +245 -0
- package/dist/astUtils/Editor.js.map +1 -0
- package/dist/astUtils/Editor.spec.js +258 -0
- package/dist/astUtils/Editor.spec.js.map +1 -0
- package/dist/astUtils/creators.d.ts +36 -19
- package/dist/astUtils/creators.js +222 -43
- package/dist/astUtils/creators.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.d.ts +148 -82
- package/dist/astUtils/reflection.js +324 -137
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +267 -167
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/astUtils/stackedVisitor.js.map +1 -1
- package/dist/astUtils/stackedVisitor.spec.js +14 -14
- package/dist/astUtils/stackedVisitor.spec.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +114 -53
- package/dist/astUtils/visitors.js +70 -13
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +463 -51
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/astUtils/xml.d.ts +9 -8
- package/dist/astUtils/xml.js +10 -5
- package/dist/astUtils/xml.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +22 -1
- package/dist/bscPlugin/BscPlugin.js +88 -0
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/CallExpressionInfo.d.ts +36 -0
- package/dist/bscPlugin/CallExpressionInfo.js +135 -0
- package/dist/bscPlugin/CallExpressionInfo.js.map +1 -0
- 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/SignatureHelpUtil.d.ts +10 -0
- package/dist/bscPlugin/SignatureHelpUtil.js +137 -0
- package/dist/bscPlugin/SignatureHelpUtil.js.map +1 -0
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.d.ts +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +30 -18
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +94 -21
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +64 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.js +626 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +2188 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/definition/DefinitionProvider.d.ts +13 -0
- package/dist/bscPlugin/definition/DefinitionProvider.js +212 -0
- package/dist/bscPlugin/definition/DefinitionProvider.js.map +1 -0
- package/dist/bscPlugin/definition/DefinitionProvider.spec.d.ts +1 -0
- package/dist/bscPlugin/definition/DefinitionProvider.spec.js +87 -0
- package/dist/bscPlugin/definition/DefinitionProvider.spec.js.map +1 -0
- 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 +18 -0
- package/dist/bscPlugin/hover/HoverProcessor.js +218 -0
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.spec.d.ts +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.spec.js +786 -0
- package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/references/ReferencesProvider.d.ts +12 -0
- package/dist/bscPlugin/references/ReferencesProvider.js +57 -0
- package/dist/bscPlugin/references/ReferencesProvider.js.map +1 -0
- package/dist/bscPlugin/references/ReferencesProvider.spec.d.ts +1 -0
- package/dist/bscPlugin/references/ReferencesProvider.spec.js +51 -0
- package/dist/bscPlugin/references/ReferencesProvider.spec.js.map +1 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +14 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +154 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.d.ts +1 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +530 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/serialize/BslibInjector.spec.d.ts +1 -0
- package/dist/bscPlugin/serialize/BslibInjector.spec.js +33 -0
- package/dist/bscPlugin/serialize/BslibInjector.spec.js.map +1 -0
- package/dist/bscPlugin/serialize/BslibManager.d.ts +12 -0
- package/dist/bscPlugin/serialize/BslibManager.js +46 -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 +75 -0
- package/dist/bscPlugin/serialize/FileSerializer.js.map +1 -0
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.d.ts +7 -0
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.js +22 -0
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.js.map +1 -0
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.d.ts +1 -0
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js +291 -0
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.d.ts +7 -0
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.js +26 -0
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.js.map +1 -0
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.d.ts +1 -0
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js +245 -0
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/symbols/symbolUtils.d.ts +5 -0
- package/dist/bscPlugin/symbols/symbolUtils.js +141 -0
- package/dist/bscPlugin/symbols/symbolUtils.js.map +1 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.d.ts +21 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js +201 -0
- 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 +75 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +12 -0
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js +99 -0
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +1 -0
- package/dist/bscPlugin/validation/BrsFileAfterValidator.d.ts +7 -0
- package/dist/bscPlugin/validation/BrsFileAfterValidator.js +18 -0
- package/dist/bscPlugin/validation/BrsFileAfterValidator.js.map +1 -0
- package/dist/bscPlugin/validation/BrsFileValidator.d.ts +36 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js +534 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -0
- package/dist/bscPlugin/validation/BrsFileValidator.spec.d.ts +1 -0
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js +1118 -0
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -0
- package/dist/bscPlugin/validation/ProgramValidator.d.ts +11 -0
- package/dist/bscPlugin/validation/ProgramValidator.js +33 -0
- package/dist/bscPlugin/validation/ProgramValidator.js.map +1 -0
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +128 -0
- package/dist/bscPlugin/validation/ScopeValidator.js +1045 -0
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -0
- package/dist/bscPlugin/validation/ScopeValidator.spec.d.ts +1 -0
- package/dist/bscPlugin/validation/ScopeValidator.spec.js +3380 -0
- package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -0
- package/dist/bscPlugin/validation/XmlFileValidator.d.ts +8 -0
- package/dist/bscPlugin/validation/XmlFileValidator.js +44 -0
- package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -0
- package/dist/cli.js +117 -11
- package/dist/cli.js.map +1 -1
- package/dist/deferred.d.ts +3 -3
- package/dist/deferred.js.map +1 -1
- package/dist/diagnosticUtils.d.ts +10 -3
- package/dist/diagnosticUtils.js +62 -24
- package/dist/diagnosticUtils.js.map +1 -1
- package/dist/examples/plugins/removePrint.js +8 -12
- package/dist/examples/plugins/removePrint.js.map +1 -1
- package/dist/files/AssetFile.d.ts +24 -0
- package/dist/files/AssetFile.js +25 -0
- package/dist/files/AssetFile.js.map +1 -0
- package/dist/files/BrsFile.Class.spec.js +912 -153
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +142 -85
- package/dist/files/BrsFile.js +845 -935
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +3778 -862
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/BscFile.d.ts +101 -0
- package/dist/files/BscFile.js +15 -0
- package/dist/files/BscFile.js.map +1 -0
- 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/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 +73 -41
- package/dist/files/XmlFile.js +128 -138
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/files/XmlFile.spec.js +451 -324
- package/dist/files/XmlFile.spec.js.map +1 -1
- package/dist/files/tests/imports.spec.js +62 -52
- package/dist/files/tests/imports.spec.js.map +1 -1
- package/dist/files/tests/optionalChaning.spec.d.ts +1 -0
- package/dist/files/tests/optionalChaning.spec.js +152 -0
- package/dist/files/tests/optionalChaning.spec.js.map +1 -0
- package/dist/globalCallables.d.ts +3 -1
- package/dist/globalCallables.js +417 -163
- package/dist/globalCallables.js.map +1 -1
- package/dist/index.d.ts +26 -3
- package/dist/index.js +44 -5
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +783 -122
- package/dist/interfaces.js +21 -0
- package/dist/interfaces.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 +51 -12
- package/dist/lexer/Lexer.js +201 -57
- package/dist/lexer/Lexer.js.map +1 -1
- package/dist/lexer/Lexer.spec.js +781 -565
- package/dist/lexer/Lexer.spec.js.map +1 -1
- package/dist/lexer/Token.d.ts +27 -11
- package/dist/lexer/Token.js +10 -2
- package/dist/lexer/Token.js.map +1 -1
- package/dist/lexer/TokenKind.d.ts +31 -2
- package/dist/lexer/TokenKind.js +134 -10
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/logging.d.ts +9 -0
- package/dist/logging.js +16 -0
- package/dist/logging.js.map +1 -0
- package/dist/parser/AstNode.d.ts +191 -0
- package/dist/parser/AstNode.js +269 -0
- package/dist/parser/AstNode.js.map +1 -0
- package/dist/parser/AstNode.spec.d.ts +1 -0
- package/dist/parser/AstNode.spec.js +1455 -0
- package/dist/parser/AstNode.spec.js.map +1 -0
- package/dist/parser/BrightScriptDocParser.d.ts +56 -0
- package/dist/parser/BrightScriptDocParser.js +294 -0
- package/dist/parser/BrightScriptDocParser.js.map +1 -0
- package/dist/parser/BrightScriptDocParser.spec.d.ts +1 -0
- package/dist/parser/BrightScriptDocParser.spec.js +310 -0
- package/dist/parser/BrightScriptDocParser.spec.js.map +1 -0
- package/dist/parser/BrsTranspileState.d.ts +22 -3
- package/dist/parser/BrsTranspileState.js +19 -0
- package/dist/parser/BrsTranspileState.js.map +1 -1
- package/dist/parser/Expression.d.ts +489 -221
- package/dist/parser/Expression.js +1206 -506
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Expression.spec.d.ts +1 -0
- package/dist/parser/Expression.spec.js +40 -0
- package/dist/parser/Expression.spec.js.map +1 -0
- package/dist/parser/Parser.Class.spec.js +230 -125
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.d.ts +113 -124
- package/dist/parser/Parser.js +1510 -983
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.d.ts +3 -1
- package/dist/parser/Parser.spec.js +1533 -517
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/SGParser.d.ts +60 -7
- package/dist/parser/SGParser.js +225 -185
- package/dist/parser/SGParser.js.map +1 -1
- package/dist/parser/SGParser.spec.js +29 -32
- package/dist/parser/SGParser.spec.js.map +1 -1
- package/dist/parser/SGTypes.d.ts +295 -52
- package/dist/parser/SGTypes.js +540 -187
- package/dist/parser/SGTypes.js.map +1 -1
- package/dist/parser/Statement.d.ts +808 -261
- package/dist/parser/Statement.js +2232 -588
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/Statement.spec.js +133 -36
- package/dist/parser/Statement.spec.js.map +1 -1
- package/dist/parser/TranspileState.d.ts +26 -12
- package/dist/parser/TranspileState.js +114 -15
- package/dist/parser/TranspileState.js.map +1 -1
- package/dist/parser/tests/Parser.spec.d.ts +3 -9
- package/dist/parser/tests/Parser.spec.js +7 -13
- package/dist/parser/tests/Parser.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/For.spec.js +83 -75
- package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/ForEach.spec.js +58 -51
- package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/If.spec.js +382 -239
- package/dist/parser/tests/controlFlow/If.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/While.spec.js +52 -45
- package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
- package/dist/parser/tests/expression/Additive.spec.js +51 -43
- package/dist/parser/tests/expression/Additive.spec.js.map +1 -1
- package/dist/parser/tests/expression/ArrayLiterals.spec.js +192 -142
- package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +1 -1
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +236 -160
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
- package/dist/parser/tests/expression/Boolean.spec.js +41 -34
- package/dist/parser/tests/expression/Boolean.spec.js.map +1 -1
- package/dist/parser/tests/expression/Call.spec.js +173 -55
- package/dist/parser/tests/expression/Call.spec.js.map +1 -1
- package/dist/parser/tests/expression/Exponential.spec.js +20 -20
- package/dist/parser/tests/expression/Exponential.spec.js.map +1 -1
- package/dist/parser/tests/expression/Function.spec.js +291 -282
- package/dist/parser/tests/expression/Function.spec.js.map +1 -1
- package/dist/parser/tests/expression/Indexing.spec.js +193 -110
- package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
- package/dist/parser/tests/expression/Multiplicative.spec.js +42 -42
- package/dist/parser/tests/expression/Multiplicative.spec.js.map +1 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +213 -115
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/PrefixUnary.spec.js +58 -52
- package/dist/parser/tests/expression/PrefixUnary.spec.js.map +1 -1
- package/dist/parser/tests/expression/Primary.spec.js +76 -60
- package/dist/parser/tests/expression/Primary.spec.js.map +1 -1
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.d.ts +1 -0
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +171 -0
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -0
- package/dist/parser/tests/expression/Relational.spec.js +50 -50
- package/dist/parser/tests/expression/Relational.spec.js.map +1 -1
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +31 -31
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js +235 -94
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.js +403 -174
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TypeExpression.spec.d.ts +1 -0
- package/dist/parser/tests/expression/TypeExpression.spec.js +126 -0
- package/dist/parser/tests/expression/TypeExpression.spec.js.map +1 -0
- 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/AssignmentOperators.spec.js +44 -44
- package/dist/parser/tests/statement/AssignmentOperators.spec.js.map +1 -1
- package/dist/parser/tests/statement/ConstStatement.spec.d.ts +1 -0
- package/dist/parser/tests/statement/ConstStatement.spec.js +262 -0
- package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -0
- package/dist/parser/tests/statement/Continue.spec.d.ts +1 -0
- package/dist/parser/tests/statement/Continue.spec.js +119 -0
- package/dist/parser/tests/statement/Continue.spec.js.map +1 -0
- package/dist/parser/tests/statement/Declaration.spec.js +61 -55
- 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.d.ts +1 -0
- package/dist/parser/tests/statement/Enum.spec.js +744 -0
- package/dist/parser/tests/statement/Enum.spec.js.map +1 -0
- package/dist/parser/tests/statement/For.spec.d.ts +1 -0
- package/dist/parser/tests/statement/For.spec.js +45 -0
- package/dist/parser/tests/statement/For.spec.js.map +1 -0
- package/dist/parser/tests/statement/ForEach.spec.d.ts +1 -0
- package/dist/parser/tests/statement/ForEach.spec.js +36 -0
- package/dist/parser/tests/statement/ForEach.spec.js.map +1 -0
- package/dist/parser/tests/statement/Function.spec.js +226 -215
- package/dist/parser/tests/statement/Function.spec.js.map +1 -1
- package/dist/parser/tests/statement/Goto.spec.js +16 -15
- package/dist/parser/tests/statement/Goto.spec.js.map +1 -1
- package/dist/parser/tests/statement/Increment.spec.js +64 -59
- package/dist/parser/tests/statement/Increment.spec.js.map +1 -1
- package/dist/parser/tests/statement/InterfaceStatement.spec.d.ts +1 -0
- package/dist/parser/tests/statement/InterfaceStatement.spec.js +110 -0
- package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -0
- package/dist/parser/tests/statement/LibraryStatement.spec.js +22 -22
- package/dist/parser/tests/statement/LibraryStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Misc.spec.js +127 -168
- package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
- package/dist/parser/tests/statement/PrintStatement.spec.js +133 -114
- package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/ReturnStatement.spec.js +57 -54
- package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Set.spec.js +131 -117
- package/dist/parser/tests/statement/Set.spec.js.map +1 -1
- package/dist/parser/tests/statement/Stop.spec.js +14 -13
- package/dist/parser/tests/statement/Stop.spec.js.map +1 -1
- package/dist/parser/tests/statement/Throw.spec.js +11 -8
- package/dist/parser/tests/statement/Throw.spec.js.map +1 -1
- package/dist/parser/tests/statement/TryCatch.spec.js +26 -15
- package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
- package/dist/preprocessor/Manifest.d.ts +6 -6
- package/dist/preprocessor/Manifest.js +17 -38
- package/dist/preprocessor/Manifest.js.map +1 -1
- package/dist/preprocessor/Manifest.spec.d.ts +1 -0
- package/dist/preprocessor/Manifest.spec.js +78 -103
- package/dist/preprocessor/Manifest.spec.js.map +1 -1
- package/dist/roku-types/data.json +19452 -0
- package/dist/roku-types/index.d.ts +5533 -0
- package/dist/roku-types/index.js +11 -0
- package/dist/roku-types/index.js.map +1 -0
- package/dist/types/ArrayType.d.ts +9 -5
- package/dist/types/ArrayType.js +73 -24
- package/dist/types/ArrayType.js.map +1 -1
- package/dist/types/ArrayType.spec.js +39 -11
- package/dist/types/ArrayType.spec.js.map +1 -1
- package/dist/types/AssociativeArrayType.d.ts +14 -0
- package/dist/types/AssociativeArrayType.js +60 -0
- package/dist/types/AssociativeArrayType.js.map +1 -0
- package/dist/types/BaseFunctionType.d.ts +9 -0
- package/dist/types/BaseFunctionType.js +25 -0
- package/dist/types/BaseFunctionType.js.map +1 -0
- package/dist/types/BooleanType.d.ts +10 -5
- package/dist/types/BooleanType.js +21 -9
- package/dist/types/BooleanType.js.map +1 -1
- package/dist/types/BooleanType.spec.js +10 -4
- package/dist/types/BooleanType.spec.js.map +1 -1
- package/dist/types/BscType.d.ts +29 -3
- package/dist/types/BscType.js +121 -0
- package/dist/types/BscType.js.map +1 -1
- package/dist/types/BscTypeKind.d.ts +25 -0
- package/dist/types/BscTypeKind.js +30 -0
- package/dist/types/BscTypeKind.js.map +1 -0
- package/dist/types/BuiltInInterfaceAdder.d.ts +25 -0
- package/dist/types/BuiltInInterfaceAdder.js +201 -0
- package/dist/types/BuiltInInterfaceAdder.js.map +1 -0
- package/dist/types/BuiltInInterfaceAdder.spec.d.ts +1 -0
- package/dist/types/BuiltInInterfaceAdder.spec.js +115 -0
- package/dist/types/BuiltInInterfaceAdder.spec.js.map +1 -0
- package/dist/types/ClassType.d.ts +16 -0
- package/dist/types/ClassType.js +57 -0
- package/dist/types/ClassType.js.map +1 -0
- package/dist/types/ClassType.spec.d.ts +1 -0
- package/dist/types/ClassType.spec.js +76 -0
- package/dist/types/ClassType.spec.js.map +1 -0
- package/dist/types/ComponentType.d.ts +27 -0
- package/dist/types/ComponentType.js +83 -0
- package/dist/types/ComponentType.js.map +1 -0
- package/dist/types/DoubleType.d.ts +10 -5
- package/dist/types/DoubleType.js +25 -18
- package/dist/types/DoubleType.js.map +1 -1
- package/dist/types/DoubleType.spec.js +12 -4
- package/dist/types/DoubleType.spec.js.map +1 -1
- package/dist/types/DynamicType.d.ts +12 -5
- package/dist/types/DynamicType.js +22 -6
- package/dist/types/DynamicType.js.map +1 -1
- package/dist/types/DynamicType.spec.js +16 -5
- package/dist/types/DynamicType.spec.js.map +1 -1
- package/dist/types/EnumType.d.ts +40 -0
- package/dist/types/EnumType.js +80 -0
- package/dist/types/EnumType.js.map +1 -0
- package/dist/types/EnumType.spec.d.ts +1 -0
- package/dist/types/EnumType.spec.js +33 -0
- package/dist/types/EnumType.spec.js.map +1 -0
- package/dist/types/FloatType.d.ts +10 -5
- package/dist/types/FloatType.js +25 -18
- package/dist/types/FloatType.js.map +1 -1
- package/dist/types/FloatType.spec.js +4 -4
- package/dist/types/FloatType.spec.js.map +1 -1
- package/dist/types/FunctionType.d.ts +10 -22
- package/dist/types/FunctionType.js +26 -63
- package/dist/types/FunctionType.js.map +1 -1
- package/dist/types/InheritableType.d.ts +29 -0
- package/dist/types/InheritableType.js +162 -0
- package/dist/types/InheritableType.js.map +1 -0
- package/dist/types/IntegerType.d.ts +10 -5
- package/dist/types/IntegerType.js +25 -18
- package/dist/types/IntegerType.js.map +1 -1
- package/dist/types/IntegerType.spec.js +8 -4
- package/dist/types/IntegerType.spec.js.map +1 -1
- package/dist/types/InterfaceType.d.ts +14 -6
- package/dist/types/InterfaceType.js +26 -15
- package/dist/types/InterfaceType.js.map +1 -1
- package/dist/types/InterfaceType.spec.d.ts +1 -0
- package/dist/types/InterfaceType.spec.js +227 -0
- package/dist/types/InterfaceType.spec.js.map +1 -0
- package/dist/types/InvalidType.d.ts +9 -5
- package/dist/types/InvalidType.js +20 -9
- package/dist/types/InvalidType.js.map +1 -1
- package/dist/types/InvalidType.spec.js +8 -4
- package/dist/types/InvalidType.spec.js.map +1 -1
- package/dist/types/LongIntegerType.d.ts +10 -5
- package/dist/types/LongIntegerType.js +25 -18
- package/dist/types/LongIntegerType.js.map +1 -1
- package/dist/types/LongIntegerType.spec.js +10 -4
- package/dist/types/LongIntegerType.spec.js.map +1 -1
- package/dist/types/NamespaceType.d.ts +12 -0
- package/dist/types/NamespaceType.js +28 -0
- package/dist/types/NamespaceType.js.map +1 -0
- package/dist/types/ObjectType.d.ts +10 -5
- package/dist/types/ObjectType.js +23 -9
- package/dist/types/ObjectType.js.map +1 -1
- package/dist/types/ObjectType.spec.js +3 -3
- package/dist/types/ObjectType.spec.js.map +1 -1
- package/dist/types/ReferenceType.d.ts +79 -0
- package/dist/types/ReferenceType.js +522 -0
- package/dist/types/ReferenceType.js.map +1 -0
- package/dist/types/ReferenceType.spec.d.ts +1 -0
- package/dist/types/ReferenceType.spec.js +151 -0
- package/dist/types/ReferenceType.spec.js.map +1 -0
- package/dist/types/StringType.d.ts +13 -5
- package/dist/types/StringType.js +25 -9
- package/dist/types/StringType.js.map +1 -1
- package/dist/types/StringType.spec.js +3 -3
- package/dist/types/StringType.spec.js.map +1 -1
- package/dist/types/TypedFunctionType.d.ts +33 -0
- package/dist/types/TypedFunctionType.js +106 -0
- package/dist/types/TypedFunctionType.js.map +1 -0
- package/dist/types/TypedFunctionType.spec.d.ts +1 -0
- package/dist/types/TypedFunctionType.spec.js +122 -0
- package/dist/types/TypedFunctionType.spec.js.map +1 -0
- package/dist/types/UninitializedType.d.ts +8 -6
- package/dist/types/UninitializedType.js +15 -9
- package/dist/types/UninitializedType.js.map +1 -1
- package/dist/types/UnionType.d.ts +20 -0
- package/dist/types/UnionType.js +127 -0
- package/dist/types/UnionType.js.map +1 -0
- package/dist/types/UnionType.spec.d.ts +1 -0
- package/dist/types/UnionType.spec.js +129 -0
- package/dist/types/UnionType.spec.js.map +1 -0
- package/dist/types/VoidType.d.ts +10 -5
- package/dist/types/VoidType.js +20 -9
- package/dist/types/VoidType.js.map +1 -1
- package/dist/types/VoidType.spec.js +3 -3
- package/dist/types/VoidType.spec.js.map +1 -1
- package/dist/types/helper.spec.d.ts +1 -0
- package/dist/types/helper.spec.js +144 -0
- package/dist/types/helper.spec.js.map +1 -0
- package/dist/types/helpers.d.ts +26 -0
- package/dist/types/helpers.js +191 -0
- package/dist/types/helpers.js.map +1 -0
- package/dist/types/index.d.ts +22 -0
- package/dist/types/index.js +39 -0
- package/dist/types/index.js.map +1 -0
- package/dist/util.d.ts +272 -117
- package/dist/util.js +1583 -343
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.d.ts +9 -15
- package/dist/validators/ClassValidator.js +85 -138
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +174 -138
- 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/lexer/index.d.ts +0 -3
- package/dist/lexer/index.js +0 -17
- 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/Chunk.d.ts +0 -82
- package/dist/preprocessor/Chunk.js +0 -77
- package/dist/preprocessor/Chunk.js.map +0 -1
- package/dist/preprocessor/Preprocessor.d.ts +0 -60
- package/dist/preprocessor/Preprocessor.js +0 -156
- package/dist/preprocessor/Preprocessor.js.map +0 -1
- package/dist/preprocessor/Preprocessor.spec.js +0 -152
- package/dist/preprocessor/Preprocessor.spec.js.map +0 -1
- package/dist/preprocessor/PreprocessorParser.d.ts +0 -61
- package/dist/preprocessor/PreprocessorParser.js +0 -194
- package/dist/preprocessor/PreprocessorParser.js.map +0 -1
- package/dist/preprocessor/PreprocessorParser.spec.js +0 -116
- package/dist/preprocessor/PreprocessorParser.spec.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
- package/dist/types/CustomType.d.ts +0 -10
- package/dist/types/CustomType.js +0 -35
- package/dist/types/CustomType.js.map +0 -1
- package/dist/types/FunctionType.spec.js +0 -29
- package/dist/types/FunctionType.spec.js.map +0 -1
- package/dist/types/LazyType.d.ts +0 -15
- package/dist/types/LazyType.js +0 -32
- package/dist/types/LazyType.js.map +0 -1
- /package/dist/{preprocessor/Preprocessor.spec.d.ts → astUtils/CachedLookups.spec.d.ts} +0 -0
- /package/dist/{preprocessor/PreprocessorParser.spec.d.ts → astUtils/Editor.spec.d.ts} +0 -0
- /package/dist/{types/FunctionType.spec.d.ts → bscPlugin/completions/CompletionsProcessor.spec.d.ts} +0 -0
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrossScopeValidator = exports.ProvidedNode = void 0;
|
|
4
|
+
const DiagnosticMessages_1 = require("./DiagnosticMessages");
|
|
5
|
+
const util_1 = require("./util");
|
|
6
|
+
const reflection_1 = require("./astUtils/reflection");
|
|
7
|
+
const ReferenceType_1 = require("./types/ReferenceType");
|
|
8
|
+
const BscTypeKind_1 = require("./types/BscTypeKind");
|
|
9
|
+
const helpers_1 = require("./types/helpers");
|
|
10
|
+
const Parser_1 = require("./parser/Parser");
|
|
11
|
+
const globalCallables_1 = require("./globalCallables");
|
|
12
|
+
const CrossScopeValidatorDiagnosticTag = 'CrossScopeValidator';
|
|
13
|
+
class ProvidedNode {
|
|
14
|
+
constructor(key = '', componentsMap) {
|
|
15
|
+
this.key = key;
|
|
16
|
+
this.componentsMap = componentsMap;
|
|
17
|
+
this.namespaces = new Map();
|
|
18
|
+
this.symbols = new Map();
|
|
19
|
+
}
|
|
20
|
+
getSymbolByKey(symbolKeys) {
|
|
21
|
+
var _a, _b, _c;
|
|
22
|
+
return (_c = (_b = (_a = this.getSymbol(symbolKeys.namespacedKey)) !== null && _a !== void 0 ? _a : this.getSymbol(symbolKeys.key)) !== null && _b !== void 0 ? _b : this.getSymbol(symbolKeys.namespacedPotentialTypeKey)) !== null && _c !== void 0 ? _c : this.getSymbol(symbolKeys.potentialTypeKey);
|
|
23
|
+
}
|
|
24
|
+
getSymbol(symbolName) {
|
|
25
|
+
var _a;
|
|
26
|
+
if (!symbolName) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const lowerSymbolName = symbolName.toLowerCase();
|
|
30
|
+
if ((_a = this.componentsMap) === null || _a === void 0 ? void 0 : _a.has(lowerSymbolName)) {
|
|
31
|
+
return this.componentsMap.get(lowerSymbolName);
|
|
32
|
+
}
|
|
33
|
+
let lowerSymbolNameParts = lowerSymbolName.split('.');
|
|
34
|
+
return this.getSymbolByNameParts(lowerSymbolNameParts, this);
|
|
35
|
+
}
|
|
36
|
+
getNamespace(namespaceName) {
|
|
37
|
+
let lowerSymbolNameParts = namespaceName.toLowerCase().split('.');
|
|
38
|
+
return this.getNamespaceByNameParts(lowerSymbolNameParts);
|
|
39
|
+
}
|
|
40
|
+
getSymbolByNameParts(lowerSymbolNameParts, root) {
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
42
|
+
const first = lowerSymbolNameParts === null || lowerSymbolNameParts === void 0 ? void 0 : lowerSymbolNameParts[0];
|
|
43
|
+
const rest = lowerSymbolNameParts.slice(1);
|
|
44
|
+
if (!first) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (this.symbols.has(first)) {
|
|
48
|
+
let result = this.symbols.get(first);
|
|
49
|
+
let currentType = result.symbol.type;
|
|
50
|
+
for (const namePart of rest) {
|
|
51
|
+
if ((0, reflection_1.isTypedFunctionType)(currentType)) {
|
|
52
|
+
const returnType = currentType.returnType;
|
|
53
|
+
if (returnType.isResolvable()) {
|
|
54
|
+
currentType = returnType;
|
|
55
|
+
}
|
|
56
|
+
else if ((0, reflection_1.isReferenceType)(returnType)) {
|
|
57
|
+
const fullName = returnType.fullName;
|
|
58
|
+
if (fullName.includes('.')) {
|
|
59
|
+
currentType = (_b = (_a = root.getSymbol(fullName)) === null || _a === void 0 ? void 0 : _a.symbol) === null || _b === void 0 ? void 0 : _b.type;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
currentType = (_e = (_d = (_c = this.getSymbol(fullName)) === null || _c === void 0 ? void 0 : _c.symbol) === null || _d === void 0 ? void 0 : _d.type) !== null && _e !== void 0 ? _e : (_g = (_f = root.getSymbol(fullName)) === null || _f === void 0 ? void 0 : _f.symbol) === null || _g === void 0 ? void 0 : _g.type;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
let typesToTry = [currentType];
|
|
67
|
+
if ((0, reflection_1.isEnumType)(currentType)) {
|
|
68
|
+
typesToTry.push(currentType.defaultMemberType);
|
|
69
|
+
}
|
|
70
|
+
if ((0, reflection_1.isInheritableType)(currentType)) {
|
|
71
|
+
let inheritableType = currentType;
|
|
72
|
+
while (inheritableType === null || inheritableType === void 0 ? void 0 : inheritableType.parentType) {
|
|
73
|
+
let parentType = inheritableType.parentType;
|
|
74
|
+
if ((0, reflection_1.isReferenceType)(inheritableType.parentType)) {
|
|
75
|
+
const fullName = inheritableType.parentType.fullName;
|
|
76
|
+
if (fullName.includes('.')) {
|
|
77
|
+
parentType = (_j = (_h = root.getSymbol(fullName)) === null || _h === void 0 ? void 0 : _h.symbol) === null || _j === void 0 ? void 0 : _j.type;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
parentType = (_m = (_l = (_k = this.getSymbol(fullName)) === null || _k === void 0 ? void 0 : _k.symbol) === null || _l === void 0 ? void 0 : _l.type) !== null && _m !== void 0 ? _m : (_p = (_o = root.getSymbol(fullName)) === null || _o === void 0 ? void 0 : _o.symbol) === null || _p === void 0 ? void 0 : _p.type;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
typesToTry.push(parentType);
|
|
84
|
+
inheritableType = parentType;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const extraData = {};
|
|
88
|
+
for (const curType of typesToTry) {
|
|
89
|
+
currentType = curType === null || curType === void 0 ? void 0 : curType.getMemberType(namePart, { flags: 1 /* SymbolTypeFlag.runtime */, data: extraData });
|
|
90
|
+
if ((0, reflection_1.isReferenceType)(currentType)) {
|
|
91
|
+
const memberLookup = currentType.fullName;
|
|
92
|
+
currentType = (_s = (_r = (_q = this.getSymbol(memberLookup.toLowerCase())) === null || _q === void 0 ? void 0 : _q.symbol) === null || _r === void 0 ? void 0 : _r.type) !== null && _s !== void 0 ? _s : (_u = (_t = root.getSymbol(memberLookup.toLowerCase())) === null || _t === void 0 ? void 0 : _t.symbol) === null || _u === void 0 ? void 0 : _u.type;
|
|
93
|
+
}
|
|
94
|
+
if (currentType) {
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (!currentType) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
// get specific member
|
|
102
|
+
result = Object.assign(Object.assign({}, result), { symbol: { name: namePart, type: currentType, data: extraData, flags: 1 /* SymbolTypeFlag.runtime */ } });
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
else if (rest && this.namespaces.has(first)) {
|
|
107
|
+
const node = this.namespaces.get(first);
|
|
108
|
+
const parts = node.getSymbolByNameParts(rest, root);
|
|
109
|
+
return parts;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
getNamespaceByNameParts(lowerSymbolNameParts) {
|
|
113
|
+
var _a;
|
|
114
|
+
const first = (_a = lowerSymbolNameParts === null || lowerSymbolNameParts === void 0 ? void 0 : lowerSymbolNameParts[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
115
|
+
const rest = lowerSymbolNameParts.slice(1);
|
|
116
|
+
if (!first) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (this.namespaces.has(first)) {
|
|
120
|
+
const node = this.namespaces.get(first);
|
|
121
|
+
const result = (rest === null || rest === void 0 ? void 0 : rest.length) > 0 ? node.getNamespaceByNameParts(rest) : node;
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
addSymbol(symbolName, symbolPair) {
|
|
126
|
+
let lowerSymbolNameParts = symbolName.toLowerCase().split('.');
|
|
127
|
+
return this.addSymbolByNameParts(lowerSymbolNameParts, symbolPair);
|
|
128
|
+
}
|
|
129
|
+
addSymbolByNameParts(lowerSymbolNameParts, symbolPair) {
|
|
130
|
+
var _a, _b;
|
|
131
|
+
const first = lowerSymbolNameParts === null || lowerSymbolNameParts === void 0 ? void 0 : lowerSymbolNameParts[0];
|
|
132
|
+
const rest = lowerSymbolNameParts === null || lowerSymbolNameParts === void 0 ? void 0 : lowerSymbolNameParts.slice(1);
|
|
133
|
+
let isDuplicate = false;
|
|
134
|
+
if (!first) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if ((rest === null || rest === void 0 ? void 0 : rest.length) > 0) {
|
|
138
|
+
// first must be a namespace
|
|
139
|
+
let namespaceNode = this.namespaces.get(first);
|
|
140
|
+
if (!namespaceNode) {
|
|
141
|
+
namespaceNode = new ProvidedNode(first);
|
|
142
|
+
this.namespaces.set(first, namespaceNode);
|
|
143
|
+
}
|
|
144
|
+
return namespaceNode.addSymbolByNameParts(rest, symbolPair);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
if (this.namespaces.get(first)) {
|
|
148
|
+
// trying to add a symbol that already exists as a namespace - this is a duplicate
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
// just add it to the symbols
|
|
152
|
+
const existingSymbolPair = this.symbols.get(first);
|
|
153
|
+
if (!existingSymbolPair) {
|
|
154
|
+
this.symbols.set(first, symbolPair);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
isDuplicate = ((_a = existingSymbolPair.symbol.data) === null || _a === void 0 ? void 0 : _a.definingNode) !== ((_b = symbolPair.symbol.data) === null || _b === void 0 ? void 0 : _b.definingNode);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return isDuplicate;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
exports.ProvidedNode = ProvidedNode;
|
|
164
|
+
class CrossScopeValidator {
|
|
165
|
+
constructor(program) {
|
|
166
|
+
this.program = program;
|
|
167
|
+
this.resolutionsMap = new Map();
|
|
168
|
+
this.providedTreeMap = new Map();
|
|
169
|
+
this.componentsMap = new Map();
|
|
170
|
+
}
|
|
171
|
+
symbolMapKeys(symbol) {
|
|
172
|
+
var _a, _b, _c, _d, _e, _f;
|
|
173
|
+
let keysArray = new Array();
|
|
174
|
+
let unnamespacedNameLowers = [];
|
|
175
|
+
function joinTypeChainForKey(typeChain, firstType) {
|
|
176
|
+
firstType || (firstType = typeChain[0].type);
|
|
177
|
+
const unnamespacedNameLower = typeChain.map((tce, i) => {
|
|
178
|
+
if (i === 0) {
|
|
179
|
+
if ((0, reflection_1.isReferenceType)(firstType)) {
|
|
180
|
+
return firstType.fullName;
|
|
181
|
+
}
|
|
182
|
+
else if ((0, reflection_1.isInheritableType)(firstType)) {
|
|
183
|
+
return tce.type.toString();
|
|
184
|
+
}
|
|
185
|
+
return tce.name;
|
|
186
|
+
}
|
|
187
|
+
return tce.name;
|
|
188
|
+
}).join('.').toLowerCase();
|
|
189
|
+
return unnamespacedNameLower;
|
|
190
|
+
}
|
|
191
|
+
if ((0, reflection_1.isUnionType)(symbol.typeChain[0].type) && symbol.typeChain[0].data.isInstance) {
|
|
192
|
+
const allUnifiedTypes = (0, helpers_1.getAllTypesFromUnionType)(symbol.typeChain[0].type);
|
|
193
|
+
for (const unifiedType of allUnifiedTypes) {
|
|
194
|
+
unnamespacedNameLowers.push(joinTypeChainForKey(symbol.typeChain, unifiedType));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
unnamespacedNameLowers.push(joinTypeChainForKey(symbol.typeChain));
|
|
199
|
+
}
|
|
200
|
+
for (const unnamespacedNameLower of unnamespacedNameLowers) {
|
|
201
|
+
const lowerFirst = (_c = (_b = (_a = symbol.typeChain[0]) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== null && _c !== void 0 ? _c : '';
|
|
202
|
+
let namespacedName = '';
|
|
203
|
+
let lowerNamespacePrefix = '';
|
|
204
|
+
let namespacedPotentialTypeKey = '';
|
|
205
|
+
if (((_d = symbol.containingNamespaces) === null || _d === void 0 ? void 0 : _d.length) > 0 && ((_e = symbol.typeChain[0]) === null || _e === void 0 ? void 0 : _e.name.toLowerCase()) !== symbol.containingNamespaces[0].toLowerCase()) {
|
|
206
|
+
lowerNamespacePrefix = `${((_f = symbol.containingNamespaces) !== null && _f !== void 0 ? _f : []).join('.')}`.toLowerCase();
|
|
207
|
+
}
|
|
208
|
+
if (lowerNamespacePrefix) {
|
|
209
|
+
namespacedName = `${lowerNamespacePrefix}.${unnamespacedNameLower}`;
|
|
210
|
+
namespacedPotentialTypeKey = `${lowerNamespacePrefix}.${lowerFirst}`;
|
|
211
|
+
}
|
|
212
|
+
keysArray.push({
|
|
213
|
+
potentialTypeKey: lowerFirst,
|
|
214
|
+
key: unnamespacedNameLower,
|
|
215
|
+
namespacedKey: namespacedName,
|
|
216
|
+
namespacedPotentialTypeKey: namespacedPotentialTypeKey //first entry in chain, prefixed with current namespace
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
return keysArray;
|
|
220
|
+
}
|
|
221
|
+
getRequiredMap(scope) {
|
|
222
|
+
const map = new Map();
|
|
223
|
+
scope.enumerateBrsFiles((file) => {
|
|
224
|
+
for (const symbol of file.requiredSymbols) {
|
|
225
|
+
const symbolKeysArray = this.symbolMapKeys(symbol);
|
|
226
|
+
for (const symbolKeys of symbolKeysArray) {
|
|
227
|
+
map.set(symbolKeys, symbol);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
return map;
|
|
232
|
+
}
|
|
233
|
+
getProvidedTree(scope) {
|
|
234
|
+
var _a;
|
|
235
|
+
if (this.providedTreeMap.has(scope)) {
|
|
236
|
+
return this.providedTreeMap.get(scope);
|
|
237
|
+
}
|
|
238
|
+
const providedTree = new ProvidedNode('', this.componentsMap);
|
|
239
|
+
const duplicatesMap = new Map();
|
|
240
|
+
const referenceTypesMap = new Map();
|
|
241
|
+
const addSymbolWithDuplicates = (symbolName, file, symbolObj) => {
|
|
242
|
+
var _a;
|
|
243
|
+
// eslint-disable-next-line no-bitwise
|
|
244
|
+
const globalSymbol = this.program.globalScope.symbolTable.getSymbol(symbolName, 2 /* SymbolTypeFlag.typetime */ | 1 /* SymbolTypeFlag.runtime */);
|
|
245
|
+
const symbolIsNamespace = providedTree.getNamespace(symbolName);
|
|
246
|
+
const isDupe = providedTree.addSymbol(symbolName, { file: file, symbol: symbolObj.symbol });
|
|
247
|
+
if (symbolIsNamespace || globalSymbol || isDupe || symbolObj.duplicates.length > 0) {
|
|
248
|
+
let dupesSet = duplicatesMap.get(symbolName);
|
|
249
|
+
if (!dupesSet) {
|
|
250
|
+
dupesSet = new Set();
|
|
251
|
+
duplicatesMap.set(symbolName, dupesSet);
|
|
252
|
+
const existing = providedTree.getSymbol(symbolName);
|
|
253
|
+
if (existing) {
|
|
254
|
+
dupesSet.add(existing);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (!dupesSet.has({ file: file, symbol: symbolObj.symbol })) {
|
|
258
|
+
dupesSet.add({ file: file, symbol: symbolObj.symbol });
|
|
259
|
+
}
|
|
260
|
+
if (symbolIsNamespace) {
|
|
261
|
+
const namespaceContainer = scope.getNamespace(symbolName);
|
|
262
|
+
const nsNode = (_a = namespaceContainer === null || namespaceContainer === void 0 ? void 0 : namespaceContainer.namespaceStatements) === null || _a === void 0 ? void 0 : _a[0];
|
|
263
|
+
if (nsNode) {
|
|
264
|
+
const nsFile = namespaceContainer.file;
|
|
265
|
+
const nsType = nsNode.getType({ flags: 2 /* SymbolTypeFlag.typetime */ });
|
|
266
|
+
let nsSymbol = {
|
|
267
|
+
name: nsNode.getName(Parser_1.ParseMode.BrighterScript),
|
|
268
|
+
type: nsType,
|
|
269
|
+
data: { definingNode: nsNode },
|
|
270
|
+
flags: 2 /* SymbolTypeFlag.typetime */
|
|
271
|
+
};
|
|
272
|
+
if (nsSymbol && !dupesSet.has({ file: nsFile, symbol: nsSymbol })) {
|
|
273
|
+
dupesSet.add({ file: nsFile, symbol: nsSymbol });
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
for (const providedDupeSymbol of symbolObj.duplicates) {
|
|
278
|
+
if (!dupesSet.has({ file: file, symbol: providedDupeSymbol })) {
|
|
279
|
+
dupesSet.add({ file: file, symbol: providedDupeSymbol });
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (globalSymbol) {
|
|
283
|
+
dupesSet.add({ file: globalCallables_1.globalFile, symbol: globalSymbol[0] });
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
scope.enumerateBrsFiles((file) => {
|
|
288
|
+
var _a, _b, _c;
|
|
289
|
+
for (const [_, nameMap] of file.providedSymbols.symbolMap.entries()) {
|
|
290
|
+
for (const [symbolName, symbolObj] of nameMap.entries()) {
|
|
291
|
+
if ((0, reflection_1.isNamespaceType)(symbolObj.symbol.type)) {
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
addSymbolWithDuplicates(symbolName, file, symbolObj);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
// find all "provided symbols" that are reference types
|
|
298
|
+
for (const [_, nameMap] of file.providedSymbols.referenceSymbolMap.entries()) {
|
|
299
|
+
for (const [symbolName, symbolObj] of nameMap.entries()) {
|
|
300
|
+
const symbolType = symbolObj.symbol.type;
|
|
301
|
+
const namespaceLower = (_c = (_b = (_a = symbolObj.symbol.data) === null || _a === void 0 ? void 0 : _a.definingNode) === null || _b === void 0 ? void 0 : _b.findAncestor(reflection_1.isNamespaceStatement)) === null || _c === void 0 ? void 0 : _c.getName(Parser_1.ParseMode.BrighterScript).toLowerCase();
|
|
302
|
+
const allNames = (0, ReferenceType_1.getAllRequiredSymbolNames)(symbolType, namespaceLower);
|
|
303
|
+
referenceTypesMap.set({ symbolName: symbolName, file: file, symbolObj: symbolObj }, allNames);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
// check provided reference types to see if they exist yet!
|
|
308
|
+
while (referenceTypesMap.size > 0) {
|
|
309
|
+
let addedSymbol = false;
|
|
310
|
+
for (const [refTypeDetails, neededNames] of referenceTypesMap.entries()) {
|
|
311
|
+
let foundNames = 0;
|
|
312
|
+
for (const neededName of neededNames) {
|
|
313
|
+
// check if name exists or namespaced version exists
|
|
314
|
+
if ((_a = providedTree.getSymbol(neededName.name)) !== null && _a !== void 0 ? _a : providedTree.getSymbol(neededName.namespacedName)) {
|
|
315
|
+
foundNames++;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (neededNames.length === foundNames) {
|
|
319
|
+
//found all that were needed
|
|
320
|
+
addSymbolWithDuplicates(refTypeDetails.symbolName, refTypeDetails.file, refTypeDetails.symbolObj);
|
|
321
|
+
referenceTypesMap.delete(refTypeDetails);
|
|
322
|
+
addedSymbol = true;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if (!addedSymbol) {
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
const result = { duplicatesMap: duplicatesMap, providedTree: providedTree };
|
|
330
|
+
this.providedTreeMap.set(scope, result);
|
|
331
|
+
return result;
|
|
332
|
+
}
|
|
333
|
+
getIssuesForScope(scope) {
|
|
334
|
+
var _a, _b, _c, _d, _e;
|
|
335
|
+
const requiredMap = this.getRequiredMap(scope);
|
|
336
|
+
const { providedTree, duplicatesMap } = this.getProvidedTree(scope);
|
|
337
|
+
const missingSymbols = new Set();
|
|
338
|
+
for (const [symbolKeys, unresolvedSymbol] of requiredMap.entries()) {
|
|
339
|
+
// check global scope for components
|
|
340
|
+
if (unresolvedSymbol.typeChain.length === 1 && this.program.globalScope.symbolTable.getSymbol(unresolvedSymbol.typeChain[0].name, unresolvedSymbol.flags)) {
|
|
341
|
+
//symbol is available in global scope. ignore it
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
let foundSymbol = providedTree.getSymbolByKey(symbolKeys);
|
|
345
|
+
if (foundSymbol) {
|
|
346
|
+
if (!((_a = unresolvedSymbol.typeChain[0].data) === null || _a === void 0 ? void 0 : _a.isInstance)) {
|
|
347
|
+
let resolvedListForSymbol = this.resolutionsMap.get(unresolvedSymbol);
|
|
348
|
+
if (!resolvedListForSymbol) {
|
|
349
|
+
resolvedListForSymbol = new Set();
|
|
350
|
+
this.resolutionsMap.set(unresolvedSymbol, resolvedListForSymbol);
|
|
351
|
+
}
|
|
352
|
+
resolvedListForSymbol.add({
|
|
353
|
+
scope: scope,
|
|
354
|
+
sourceFile: foundSymbol.file,
|
|
355
|
+
providedSymbol: foundSymbol.symbol
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
let foundNamespace = providedTree.getNamespace(symbolKeys.key);
|
|
361
|
+
if (foundNamespace) {
|
|
362
|
+
// this symbol turned out to be a namespace. This is allowed for alias statements
|
|
363
|
+
// TODO: add check to make sure this usage is from an alias statement
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
// did not find symbol!
|
|
367
|
+
const missing = Object.assign({}, unresolvedSymbol);
|
|
368
|
+
let namespaceNode = providedTree;
|
|
369
|
+
let currentKnownType;
|
|
370
|
+
for (const chainEntry of missing.typeChain) {
|
|
371
|
+
if (!chainEntry.isResolved) {
|
|
372
|
+
// for each unresolved part of a chain, see if we can resolve it with stuff from the provided tree
|
|
373
|
+
// and if so, mark it as resolved
|
|
374
|
+
const lookupName = (_c = (_b = chainEntry.type) === null || _b === void 0 ? void 0 : _b.fullName) !== null && _c !== void 0 ? _c : chainEntry.name;
|
|
375
|
+
if (!currentKnownType) {
|
|
376
|
+
namespaceNode = namespaceNode === null || namespaceNode === void 0 ? void 0 : namespaceNode.getNamespaceByNameParts([chainEntry.name]);
|
|
377
|
+
}
|
|
378
|
+
if (namespaceNode) {
|
|
379
|
+
chainEntry.isResolved = true;
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
if (currentKnownType) {
|
|
383
|
+
currentKnownType = currentKnownType.getMemberType(chainEntry.name, { flags: 1 /* SymbolTypeFlag.runtime */ });
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
currentKnownType = (_e = (_d = providedTree.getSymbol(lookupName.toLowerCase())) === null || _d === void 0 ? void 0 : _d.symbol) === null || _e === void 0 ? void 0 : _e.type;
|
|
387
|
+
}
|
|
388
|
+
if (currentKnownType === null || currentKnownType === void 0 ? void 0 : currentKnownType.isResolvable()) {
|
|
389
|
+
chainEntry.isResolved = true;
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
missingSymbols.add(unresolvedSymbol);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return { missingSymbols: missingSymbols, duplicatesMap: duplicatesMap };
|
|
402
|
+
}
|
|
403
|
+
clearResolutionsForFile(file) {
|
|
404
|
+
for (const symbol of this.resolutionsMap.keys()) {
|
|
405
|
+
if (symbol.file === file) {
|
|
406
|
+
this.resolutionsMap.delete(symbol);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
clearResolutionsForScopes(scopes) {
|
|
411
|
+
for (const [symbol, resolutionInfos] of this.resolutionsMap.entries()) {
|
|
412
|
+
for (const info of resolutionInfos.values()) {
|
|
413
|
+
if (scopes.includes(info.scope)) {
|
|
414
|
+
resolutionInfos.delete(info);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (resolutionInfos.size === 0) {
|
|
418
|
+
this.resolutionsMap.delete(symbol);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
getFilesRequiringChangedSymbol(scopes, changedSymbols) {
|
|
423
|
+
const filesThatNeedRevalidation = new Set();
|
|
424
|
+
const filesThatDoNotNeedRevalidation = new Set();
|
|
425
|
+
for (const scope of scopes) {
|
|
426
|
+
scope.enumerateBrsFiles((file) => {
|
|
427
|
+
if (filesThatNeedRevalidation.has(file) || filesThatDoNotNeedRevalidation.has(file)) {
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
if (util_1.util.hasAnyRequiredSymbolChanged(file.requiredSymbols, changedSymbols)) {
|
|
431
|
+
filesThatNeedRevalidation.add(file);
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
filesThatDoNotNeedRevalidation.add(file);
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
return filesThatNeedRevalidation;
|
|
438
|
+
}
|
|
439
|
+
buildComponentsMap() {
|
|
440
|
+
var _a;
|
|
441
|
+
this.componentsMap.clear();
|
|
442
|
+
// Add custom components
|
|
443
|
+
for (let componentName of this.program.getSortedComponentNames()) {
|
|
444
|
+
const typeName = 'rosgnode' + componentName;
|
|
445
|
+
const component = this.program.getComponent(componentName);
|
|
446
|
+
const componentSymbol = (_a = this.program.globalScope.symbolTable.getSymbol(typeName, 2 /* SymbolTypeFlag.typetime */)) === null || _a === void 0 ? void 0 : _a[0];
|
|
447
|
+
if (componentSymbol && component) {
|
|
448
|
+
this.componentsMap.set(typeName, { file: component.file, symbol: componentSymbol });
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
addDiagnosticsForScopes(scopes) {
|
|
453
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
454
|
+
const addDuplicateSymbolDiagnostics = true;
|
|
455
|
+
const missingSymbolInScope = new Map();
|
|
456
|
+
this.providedTreeMap.clear();
|
|
457
|
+
this.clearResolutionsForScopes(scopes);
|
|
458
|
+
// Check scope for duplicates and missing symbols
|
|
459
|
+
for (const scope of scopes) {
|
|
460
|
+
this.program.diagnostics.clearByFilter({
|
|
461
|
+
scope: scope,
|
|
462
|
+
tag: CrossScopeValidatorDiagnosticTag
|
|
463
|
+
});
|
|
464
|
+
const { missingSymbols, duplicatesMap } = this.getIssuesForScope(scope);
|
|
465
|
+
if (addDuplicateSymbolDiagnostics) {
|
|
466
|
+
for (const [_flag, dupeSet] of duplicatesMap.entries()) {
|
|
467
|
+
if (dupeSet.size > 1) {
|
|
468
|
+
const dupesArray = [...dupeSet.values()];
|
|
469
|
+
for (let i = 0; i < dupesArray.length; i++) {
|
|
470
|
+
const dupe = dupesArray[i];
|
|
471
|
+
const dupeNode = (_b = (_a = dupe === null || dupe === void 0 ? void 0 : dupe.symbol) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.definingNode;
|
|
472
|
+
if (!dupeNode) {
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
let thisName = (_c = dupe.symbol) === null || _c === void 0 ? void 0 : _c.name;
|
|
476
|
+
const wrappingNameSpace = dupeNode === null || dupeNode === void 0 ? void 0 : dupeNode.findAncestor(reflection_1.isNamespaceStatement);
|
|
477
|
+
if (wrappingNameSpace) {
|
|
478
|
+
thisName = `${wrappingNameSpace.getName(Parser_1.ParseMode.BrighterScript)}.` + thisName;
|
|
479
|
+
}
|
|
480
|
+
const thisNodeKindName = (_d = util_1.util.getAstNodeFriendlyName(dupeNode)) !== null && _d !== void 0 ? _d : 'Item';
|
|
481
|
+
for (let j = 0; j < dupesArray.length; j++) {
|
|
482
|
+
if (i === j) {
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
const otherDupe = dupesArray[j];
|
|
486
|
+
if (!otherDupe || dupe.symbol === otherDupe.symbol) {
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
const otherDupeNode = (_e = otherDupe.symbol.data) === null || _e === void 0 ? void 0 : _e.definingNode;
|
|
490
|
+
const otherIsGlobal = otherDupe.file.srcPath === 'global';
|
|
491
|
+
if ((0, reflection_1.isFunctionStatement)(dupeNode) && (0, reflection_1.isFunctionStatement)(otherDupeNode)) {
|
|
492
|
+
// duplicate functions are handled in ScopeValidator
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
if (otherIsGlobal &&
|
|
496
|
+
((0, reflection_1.isInterfaceStatement)(dupeNode) ||
|
|
497
|
+
(0, reflection_1.isEnumStatement)(dupeNode) ||
|
|
498
|
+
(0, reflection_1.isConstStatement)(dupeNode))) {
|
|
499
|
+
// these are allowed to shadow global functions
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
let thatName = (_f = otherDupe.symbol) === null || _f === void 0 ? void 0 : _f.name;
|
|
503
|
+
if (otherDupeNode) {
|
|
504
|
+
const otherWrappingNameSpace = otherDupeNode === null || otherDupeNode === void 0 ? void 0 : otherDupeNode.findAncestor(reflection_1.isNamespaceStatement);
|
|
505
|
+
if (otherWrappingNameSpace) {
|
|
506
|
+
thatName = `${otherWrappingNameSpace.getName(Parser_1.ParseMode.BrighterScript)}.` + thatName;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
const thatNodeKindName = otherIsGlobal ? 'Global Function' : (_g = util_1.util.getAstNodeFriendlyName(otherDupeNode)) !== null && _g !== void 0 ? _g : 'Item';
|
|
510
|
+
let thisNameRange = (_l = (_k = (_j = (_h = dupeNode === null || dupeNode === void 0 ? void 0 : dupeNode.tokens) === null || _h === void 0 ? void 0 : _h.name) === null || _j === void 0 ? void 0 : _j.location) === null || _k === void 0 ? void 0 : _k.range) !== null && _l !== void 0 ? _l : (_m = dupeNode.location) === null || _m === void 0 ? void 0 : _m.range;
|
|
511
|
+
let thatNameRange = (_r = (_q = (_p = (_o = otherDupeNode === null || otherDupeNode === void 0 ? void 0 : otherDupeNode.tokens) === null || _o === void 0 ? void 0 : _o.name) === null || _p === void 0 ? void 0 : _p.location) === null || _q === void 0 ? void 0 : _q.range) !== null && _r !== void 0 ? _r : (_s = otherDupeNode === null || otherDupeNode === void 0 ? void 0 : otherDupeNode.location) === null || _s === void 0 ? void 0 : _s.range;
|
|
512
|
+
const relatedInformation = thatNameRange ? [{
|
|
513
|
+
message: `${thatNodeKindName} declared here`,
|
|
514
|
+
location: util_1.util.createLocationFromFileRange(otherDupe.file, thatNameRange)
|
|
515
|
+
}] : undefined;
|
|
516
|
+
this.program.diagnostics.register(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.nameCollision(thisNodeKindName, thatNodeKindName, thatName)), { location: util_1.util.createLocationFromFileRange(dupe.file, thisNameRange), relatedInformation: relatedInformation }), {
|
|
517
|
+
scope: scope,
|
|
518
|
+
tags: [CrossScopeValidatorDiagnosticTag]
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
// build map of the symbols and scopes where the symbols are missing per file
|
|
526
|
+
for (const missingSymbol of missingSymbols) {
|
|
527
|
+
let scopesWithMissingSymbol = missingSymbolInScope.get(missingSymbol);
|
|
528
|
+
if (!scopesWithMissingSymbol) {
|
|
529
|
+
scopesWithMissingSymbol = new Set();
|
|
530
|
+
missingSymbolInScope.set(missingSymbol, scopesWithMissingSymbol);
|
|
531
|
+
}
|
|
532
|
+
scopesWithMissingSymbol.add(scope);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
// If symbols are missing in SOME scopes, add diagnostic
|
|
536
|
+
for (const [symbol, scopeList] of missingSymbolInScope.entries()) {
|
|
537
|
+
const typeChainResult = util_1.util.processTypeChain(symbol.typeChain);
|
|
538
|
+
for (const scope of scopeList) {
|
|
539
|
+
this.program.diagnostics.register(Object.assign(Object.assign({}, this.getCannotFindDiagnostic(scope, typeChainResult)), { location: typeChainResult.location }), {
|
|
540
|
+
scope: scope,
|
|
541
|
+
tags: [CrossScopeValidatorDiagnosticTag]
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
for (const resolution of this.getIncompatibleSymbolResolutions()) {
|
|
546
|
+
const symbol = resolution.symbol;
|
|
547
|
+
const incompatibleScopes = resolution.incompatibleScopes;
|
|
548
|
+
if (incompatibleScopes.size > 1) {
|
|
549
|
+
const typeChainResult = util_1.util.processTypeChain(symbol.typeChain);
|
|
550
|
+
const scopeListName = [...incompatibleScopes.values()].map(s => s.name).join(', ');
|
|
551
|
+
this.program.diagnostics.register(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.incompatibleSymbolDefinition(typeChainResult.fullChainName, scopeListName)), { location: typeChainResult.location }), {
|
|
552
|
+
tags: [CrossScopeValidatorDiagnosticTag]
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
getIncompatibleSymbolResolutions() {
|
|
558
|
+
const incompatibleResolutions = new Array();
|
|
559
|
+
// check all resolutions and check if there are resolutions that are not compatible across scopes
|
|
560
|
+
for (const [symbol, resolutionDetails] of this.resolutionsMap.entries()) {
|
|
561
|
+
if (resolutionDetails.size < 2) {
|
|
562
|
+
// there is only one resolution... no worries
|
|
563
|
+
continue;
|
|
564
|
+
}
|
|
565
|
+
const resolutionsList = [...resolutionDetails];
|
|
566
|
+
const prime = resolutionsList[0];
|
|
567
|
+
let incompatibleScopes = new Set();
|
|
568
|
+
let addedPrime = false;
|
|
569
|
+
for (let i = 1; i < resolutionsList.length; i++) {
|
|
570
|
+
let providedSymbolType = prime.providedSymbol.type;
|
|
571
|
+
const symbolInThisScope = resolutionsList[i].providedSymbol;
|
|
572
|
+
//get more general type
|
|
573
|
+
if (providedSymbolType.isEqual(symbolInThisScope.type)) {
|
|
574
|
+
//type in this scope is the same as one we're already checking
|
|
575
|
+
}
|
|
576
|
+
else if (providedSymbolType.isTypeCompatible(symbolInThisScope.type)) {
|
|
577
|
+
//type in this scope is compatible with one we're storing. use most generic
|
|
578
|
+
providedSymbolType = symbolInThisScope.type;
|
|
579
|
+
}
|
|
580
|
+
else if (symbolInThisScope.type.isTypeCompatible(providedSymbolType)) {
|
|
581
|
+
// type we're storing is more generic that the type in this scope
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
// type in this scope is not compatible with other types for this symbol
|
|
585
|
+
if (!addedPrime) {
|
|
586
|
+
incompatibleScopes.add(prime.scope);
|
|
587
|
+
addedPrime = true;
|
|
588
|
+
}
|
|
589
|
+
incompatibleScopes.add(resolutionsList[i].scope);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
if (incompatibleScopes.size > 1) {
|
|
593
|
+
incompatibleResolutions.push({
|
|
594
|
+
symbol: symbol,
|
|
595
|
+
incompatibleScopes: incompatibleScopes
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
return incompatibleResolutions;
|
|
600
|
+
}
|
|
601
|
+
getCannotFindDiagnostic(scope, typeChainResult) {
|
|
602
|
+
var _a, _b, _c;
|
|
603
|
+
const parentDescriptor = this.getParentTypeDescriptor((_a = this.getProvidedTree(scope)) === null || _a === void 0 ? void 0 : _a.providedTree, typeChainResult);
|
|
604
|
+
if ((0, reflection_1.isCallExpression)((_b = typeChainResult.astNode) === null || _b === void 0 ? void 0 : _b.parent) && ((_c = typeChainResult.astNode) === null || _c === void 0 ? void 0 : _c.parent.callee) === typeChainResult.astNode) {
|
|
605
|
+
return DiagnosticMessages_1.DiagnosticMessages.cannotFindFunction(typeChainResult.itemName, typeChainResult.fullNameOfItem, typeChainResult.itemParentTypeName, parentDescriptor);
|
|
606
|
+
}
|
|
607
|
+
return DiagnosticMessages_1.DiagnosticMessages.cannotFindName(typeChainResult.itemName, typeChainResult.fullNameOfItem, typeChainResult.itemParentTypeName, parentDescriptor);
|
|
608
|
+
}
|
|
609
|
+
getParentTypeDescriptor(provided, typeChainResult) {
|
|
610
|
+
if (typeChainResult.itemParentTypeKind === BscTypeKind_1.BscTypeKind.NamespaceType || (provided === null || provided === void 0 ? void 0 : provided.getNamespace(typeChainResult.itemParentTypeName))) {
|
|
611
|
+
return 'namespace';
|
|
612
|
+
}
|
|
613
|
+
return 'type';
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
exports.CrossScopeValidator = CrossScopeValidator;
|
|
617
|
+
//# sourceMappingURL=CrossScopeValidator.js.map
|