brighterscript 0.66.0-alpha.9 → 0.67.1
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 +123 -73
- package/README.md +14 -418
- package/dist/BsConfig.d.ts +25 -2
- package/dist/Cache.js +3 -3
- package/dist/Cache.js.map +1 -1
- package/dist/CodeActionUtil.d.ts +3 -3
- package/dist/CodeActionUtil.js.map +1 -1
- package/dist/CommentFlagProcessor.d.ts +3 -4
- package/dist/CommentFlagProcessor.js +4 -3
- package/dist/CommentFlagProcessor.js.map +1 -1
- package/dist/DependencyGraph.js +8 -8
- package/dist/DependencyGraph.js.map +1 -1
- package/dist/DiagnosticFilterer.d.ts +8 -4
- package/dist/DiagnosticFilterer.js +71 -38
- package/dist/DiagnosticFilterer.js.map +1 -1
- package/dist/DiagnosticMessages.d.ts +15 -36
- package/dist/DiagnosticMessages.js +15 -61
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/DiagnosticSeverityAdjuster.js +3 -0
- package/dist/DiagnosticSeverityAdjuster.js.map +1 -1
- package/dist/FunctionScope.d.ts +2 -3
- package/dist/FunctionScope.js +0 -3
- package/dist/FunctionScope.js.map +1 -1
- package/dist/LanguageServer.d.ts +1 -2
- package/dist/LanguageServer.js +31 -35
- package/dist/LanguageServer.js.map +1 -1
- package/dist/Logger.d.ts +5 -9
- package/dist/Logger.js +18 -22
- package/dist/Logger.js.map +1 -1
- package/dist/PluginInterface.d.ts +13 -15
- package/dist/PluginInterface.js +16 -70
- package/dist/PluginInterface.js.map +1 -1
- package/dist/Program.d.ts +105 -138
- package/dist/Program.js +479 -702
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +8 -19
- package/dist/ProgramBuilder.js +85 -89
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +56 -46
- package/dist/Scope.js +281 -217
- package/dist/Scope.js.map +1 -1
- package/dist/Stopwatch.js +1 -1
- package/dist/Stopwatch.js.map +1 -1
- package/dist/SymbolTable.d.ts +12 -68
- package/dist/SymbolTable.js +28 -213
- package/dist/SymbolTable.js.map +1 -1
- package/dist/XmlScope.d.ts +5 -7
- package/dist/XmlScope.js +36 -76
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/{Editor.d.ts → AstEditor.d.ts} +1 -6
- package/dist/astUtils/{Editor.js → AstEditor.js} +3 -9
- package/dist/astUtils/AstEditor.js.map +1 -0
- package/dist/astUtils/{Editor.spec.js → AstEditor.spec.js} +6 -10
- package/dist/astUtils/AstEditor.spec.js.map +1 -0
- package/dist/astUtils/creators.d.ts +8 -19
- package/dist/astUtils/creators.js +22 -54
- package/dist/astUtils/creators.js.map +1 -1
- package/dist/astUtils/creators.spec.js +0 -10
- package/dist/astUtils/creators.spec.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +45 -81
- package/dist/astUtils/reflection.js +157 -220
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +19 -96
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/astUtils/stackedVisitor.spec.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +14 -18
- package/dist/astUtils/visitors.js +9 -22
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +9 -62
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/astUtils/xml.d.ts +9 -9
- package/dist/astUtils/xml.js +6 -6
- package/dist/astUtils/xml.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +8 -11
- package/dist/bscPlugin/BscPlugin.js +21 -29
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/CallExpressionInfo.d.ts +6 -5
- package/dist/bscPlugin/CallExpressionInfo.js +2 -2
- package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +11 -11
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +4 -4
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +1 -49
- package/dist/bscPlugin/completions/CompletionsProcessor.js +23 -424
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
- package/dist/bscPlugin/definition/DefinitionProvider.d.ts +13 -0
- package/dist/bscPlugin/definition/DefinitionProvider.js +200 -0
- package/dist/bscPlugin/definition/DefinitionProvider.js.map +1 -0
- package/dist/bscPlugin/definition/DefinitionProvider.spec.js +87 -0
- package/dist/bscPlugin/definition/DefinitionProvider.spec.js.map +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.d.ts +3 -7
- package/dist/bscPlugin/hover/HoverProcessor.js +88 -128
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.spec.js +24 -336
- package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/references/ReferencesProvider.d.ts +12 -0
- package/dist/bscPlugin/references/ReferencesProvider.js +56 -0
- package/dist/bscPlugin/references/ReferencesProvider.js.map +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 +0 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +5 -49
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +0 -22
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -1
- 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.js +290 -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.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 +140 -0
- package/dist/bscPlugin/symbols/symbolUtils.js.map +1 -0
- package/dist/bscPlugin/transpile/{BrsFileTranspileProcessor.d.ts → BrsFilePreTranspileProcessor.d.ts} +2 -4
- package/dist/bscPlugin/transpile/{BrsFileTranspileProcessor.js → BrsFilePreTranspileProcessor.js} +15 -36
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +1 -0
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js +46 -0
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/validation/BrsFileValidator.d.ts +1 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js +30 -41
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js +2 -2
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -1
- package/dist/bscPlugin/validation/ProgramValidator.d.ts +3 -3
- package/dist/bscPlugin/validation/ProgramValidator.js +6 -6
- package/dist/bscPlugin/validation/ProgramValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +6 -28
- package/dist/bscPlugin/validation/ScopeValidator.js +166 -387
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/bscPlugin/validation/XmlFileValidator.js +9 -9
- package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -1
- package/dist/diagnosticUtils.d.ts +2 -3
- package/dist/diagnosticUtils.js +5 -5
- 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/BrsFile.Class.spec.js +143 -114
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +61 -83
- package/dist/files/BrsFile.js +559 -612
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +1365 -1201
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.d.ts +28 -56
- package/dist/files/XmlFile.js +103 -89
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/files/XmlFile.spec.js +179 -122
- package/dist/files/XmlFile.spec.js.map +1 -1
- package/dist/files/tests/imports.spec.js +19 -29
- 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 +83 -88
- package/dist/globalCallables.js.map +1 -1
- package/dist/index.d.ts +1 -9
- package/dist/index.js +1 -9
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +173 -423
- package/dist/interfaces.js +0 -24
- package/dist/interfaces.js.map +1 -1
- package/dist/lexer/Lexer.d.ts +9 -15
- package/dist/lexer/Lexer.js +35 -46
- package/dist/lexer/Lexer.js.map +1 -1
- package/dist/lexer/Lexer.spec.js +48 -40
- package/dist/lexer/Lexer.spec.js.map +1 -1
- package/dist/lexer/Token.d.ts +1 -5
- package/dist/lexer/Token.js +1 -1
- package/dist/lexer/Token.js.map +1 -1
- package/dist/lexer/TokenKind.d.ts +0 -6
- package/dist/lexer/TokenKind.js +2 -14
- 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 +6 -90
- package/dist/parser/AstNode.js +5 -96
- package/dist/parser/AstNode.js.map +1 -1
- package/dist/parser/AstNode.spec.js.map +1 -1
- package/dist/parser/BrsTranspileState.d.ts +3 -4
- package/dist/parser/BrsTranspileState.js +2 -3
- package/dist/parser/BrsTranspileState.js.map +1 -1
- package/dist/parser/Expression.d.ts +114 -137
- package/dist/parser/Expression.js +244 -373
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +19 -46
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.d.ts +18 -14
- package/dist/parser/Parser.js +196 -175
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.d.ts +0 -2
- package/dist/parser/Parser.spec.js +10 -674
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/SGParser.d.ts +6 -44
- package/dist/parser/SGParser.js +198 -194
- package/dist/parser/SGParser.js.map +1 -1
- package/dist/parser/SGParser.spec.js +11 -14
- package/dist/parser/SGParser.spec.js.map +1 -1
- package/dist/parser/SGTypes.d.ts +52 -280
- package/dist/parser/SGTypes.js +185 -562
- package/dist/parser/SGTypes.js.map +1 -1
- package/dist/parser/Statement.d.ts +140 -172
- package/dist/parser/Statement.js +201 -337
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/Statement.spec.js.map +1 -1
- package/dist/parser/TranspileState.d.ts +3 -2
- package/dist/parser/TranspileState.js +8 -10
- package/dist/parser/TranspileState.js.map +1 -1
- package/dist/parser/tests/Parser.spec.js +3 -5
- package/dist/parser/tests/Parser.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/For.spec.js +8 -16
- package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/ForEach.spec.js +6 -12
- package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/While.spec.js +4 -8
- package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
- package/dist/parser/tests/expression/Call.spec.js +4 -4
- package/dist/parser/tests/expression/Call.spec.js.map +1 -1
- package/dist/parser/tests/expression/Indexing.spec.js +25 -0
- package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +73 -29
- 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 +47 -35
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.js +83 -36
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/UnaryExpression.spec.js +2 -2
- package/dist/parser/tests/expression/UnaryExpression.spec.js.map +1 -1
- package/dist/parser/tests/statement/ConstStatement.spec.js +26 -27
- 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/Dim.spec.js.map +1 -1
- package/dist/parser/tests/statement/Enum.spec.js +393 -90
- 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/Function.spec.js +1 -1
- package/dist/parser/tests/statement/Function.spec.js.map +1 -1
- package/dist/parser/tests/statement/InterfaceStatement.spec.js +18 -18
- package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
- package/dist/parser/tests/statement/PrintStatement.spec.js +13 -16
- package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/ReturnStatement.spec.js +3 -5
- package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Set.spec.js +13 -26
- package/dist/parser/tests/statement/Set.spec.js.map +1 -1
- package/dist/parser/tests/statement/Throw.spec.js.map +1 -1
- package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
- package/dist/preprocessor/Chunk.js +1 -2
- package/dist/preprocessor/Chunk.js.map +1 -1
- package/dist/preprocessor/Preprocessor.d.ts +3 -4
- package/dist/preprocessor/Preprocessor.js +3 -3
- package/dist/preprocessor/Preprocessor.js.map +1 -1
- package/dist/preprocessor/PreprocessorParser.js +8 -1
- package/dist/preprocessor/PreprocessorParser.js.map +1 -1
- package/dist/roku-types/data.json +293 -243
- package/dist/roku-types/index.d.ts +38 -17
- package/dist/types/ArrayType.d.ts +4 -9
- package/dist/types/ArrayType.js +24 -72
- package/dist/types/ArrayType.js.map +1 -1
- package/dist/types/ArrayType.spec.js +10 -39
- package/dist/types/ArrayType.spec.js.map +1 -1
- package/dist/types/BooleanType.d.ts +4 -8
- package/dist/types/BooleanType.js +8 -19
- package/dist/types/BooleanType.js.map +1 -1
- package/dist/types/BooleanType.spec.js +3 -9
- package/dist/types/BooleanType.spec.js.map +1 -1
- package/dist/types/BscType.d.ts +2 -29
- package/dist/types/BscType.js +0 -113
- package/dist/types/BscType.js.map +1 -1
- package/dist/types/CustomType.d.ts +9 -0
- package/dist/types/CustomType.js +32 -0
- package/dist/types/CustomType.js.map +1 -0
- package/dist/types/DoubleType.d.ts +4 -8
- package/dist/types/DoubleType.js +20 -23
- package/dist/types/DoubleType.js.map +1 -1
- package/dist/types/DoubleType.spec.js +3 -11
- package/dist/types/DoubleType.spec.js.map +1 -1
- package/dist/types/DynamicType.d.ts +3 -9
- package/dist/types/DynamicType.js +2 -18
- package/dist/types/DynamicType.js.map +1 -1
- package/dist/types/DynamicType.spec.js +4 -15
- package/dist/types/DynamicType.spec.js.map +1 -1
- package/dist/types/FloatType.d.ts +4 -8
- package/dist/types/FloatType.js +20 -23
- package/dist/types/FloatType.js.map +1 -1
- package/dist/types/FloatType.spec.js +3 -3
- package/dist/types/FloatType.spec.js.map +1 -1
- package/dist/types/FunctionType.d.ts +20 -10
- package/dist/types/FunctionType.js +52 -27
- package/dist/types/FunctionType.js.map +1 -1
- package/dist/types/FunctionType.spec.js +23 -0
- package/dist/types/FunctionType.spec.js.map +1 -0
- package/dist/types/IntegerType.d.ts +4 -8
- package/dist/types/IntegerType.js +20 -23
- package/dist/types/IntegerType.js.map +1 -1
- package/dist/types/IntegerType.spec.js +3 -7
- package/dist/types/IntegerType.spec.js.map +1 -1
- package/dist/types/InterfaceType.d.ts +10 -12
- package/dist/types/InterfaceType.js +48 -23
- package/dist/types/InterfaceType.js.map +1 -1
- package/dist/types/InterfaceType.spec.js +45 -82
- package/dist/types/InterfaceType.spec.js.map +1 -1
- package/dist/types/InvalidType.d.ts +4 -7
- package/dist/types/InvalidType.js +8 -18
- package/dist/types/InvalidType.js.map +1 -1
- package/dist/types/InvalidType.spec.js +3 -7
- package/dist/types/InvalidType.spec.js.map +1 -1
- package/dist/types/LongIntegerType.d.ts +4 -8
- package/dist/types/LongIntegerType.js +20 -23
- package/dist/types/LongIntegerType.js.map +1 -1
- package/dist/types/LongIntegerType.spec.js +3 -9
- package/dist/types/LongIntegerType.spec.js.map +1 -1
- package/dist/types/ObjectType.d.ts +4 -8
- package/dist/types/ObjectType.js +7 -21
- package/dist/types/ObjectType.js.map +1 -1
- package/dist/types/ObjectType.spec.js +2 -2
- package/dist/types/ObjectType.spec.js.map +1 -1
- package/dist/types/StringType.d.ts +4 -11
- package/dist/types/StringType.js +8 -23
- package/dist/types/StringType.js.map +1 -1
- package/dist/types/StringType.spec.js +2 -2
- package/dist/types/StringType.spec.js.map +1 -1
- package/dist/types/UninitializedType.d.ts +3 -7
- package/dist/types/UninitializedType.js +3 -14
- package/dist/types/UninitializedType.js.map +1 -1
- package/dist/types/VoidType.d.ts +4 -8
- package/dist/types/VoidType.js +8 -18
- package/dist/types/VoidType.js.map +1 -1
- package/dist/types/VoidType.spec.js +2 -2
- package/dist/types/VoidType.spec.js.map +1 -1
- package/dist/util.d.ts +43 -104
- package/dist/util.js +243 -640
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.d.ts +6 -1
- package/dist/validators/ClassValidator.js +61 -20
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +13 -11
- package/dist/ActionPipeline.d.ts +0 -10
- package/dist/ActionPipeline.js +0 -40
- package/dist/ActionPipeline.js.map +0 -1
- package/dist/AstValidationSegmenter.d.ts +0 -25
- package/dist/AstValidationSegmenter.js +0 -150
- package/dist/AstValidationSegmenter.js.map +0 -1
- package/dist/CacheVerifier.d.ts +0 -7
- package/dist/CacheVerifier.js +0 -20
- package/dist/CacheVerifier.js.map +0 -1
- package/dist/astUtils/Editor.js.map +0 -1
- package/dist/astUtils/Editor.spec.js.map +0 -1
- package/dist/bscPlugin/FileWriter.d.ts +0 -6
- package/dist/bscPlugin/FileWriter.js +0 -24
- package/dist/bscPlugin/FileWriter.js.map +0 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +0 -1658
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/fileProviders/FileProvider.d.ts +0 -9
- package/dist/bscPlugin/fileProviders/FileProvider.js +0 -51
- package/dist/bscPlugin/fileProviders/FileProvider.js.map +0 -1
- package/dist/bscPlugin/serialize/BslibInjector.spec.js +0 -19
- package/dist/bscPlugin/serialize/BslibInjector.spec.js.map +0 -1
- package/dist/bscPlugin/serialize/BslibManager.d.ts +0 -9
- package/dist/bscPlugin/serialize/BslibManager.js +0 -40
- package/dist/bscPlugin/serialize/BslibManager.js.map +0 -1
- package/dist/bscPlugin/serialize/FileSerializer.d.ts +0 -9
- package/dist/bscPlugin/serialize/FileSerializer.js +0 -72
- package/dist/bscPlugin/serialize/FileSerializer.js.map +0 -1
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +0 -1
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js +0 -41
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +0 -11
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js +0 -53
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +0 -1
- package/dist/bscPlugin/validation/ScopeValidator.spec.js +0 -2004
- package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +0 -1
- package/dist/files/AssetFile.d.ts +0 -26
- package/dist/files/AssetFile.js +0 -26
- package/dist/files/AssetFile.js.map +0 -1
- package/dist/files/Factory.d.ts +0 -25
- package/dist/files/Factory.js +0 -22
- package/dist/files/Factory.js.map +0 -1
- package/dist/files/File.d.ts +0 -106
- package/dist/files/File.js +0 -16
- package/dist/files/File.js.map +0 -1
- package/dist/files/LazyFileData.d.ts +0 -20
- package/dist/files/LazyFileData.js +0 -54
- package/dist/files/LazyFileData.js.map +0 -1
- package/dist/files/LazyFileData.spec.js +0 -27
- package/dist/files/LazyFileData.spec.js.map +0 -1
- package/dist/parser/tests/expression/TypeExpression.spec.js +0 -127
- package/dist/parser/tests/expression/TypeExpression.spec.js.map +0 -1
- package/dist/types/AssociativeArrayType.d.ts +0 -11
- package/dist/types/AssociativeArrayType.js +0 -52
- package/dist/types/AssociativeArrayType.js.map +0 -1
- package/dist/types/BaseFunctionType.d.ts +0 -9
- package/dist/types/BaseFunctionType.js +0 -25
- package/dist/types/BaseFunctionType.js.map +0 -1
- package/dist/types/BscTypeKind.d.ts +0 -25
- package/dist/types/BscTypeKind.js +0 -30
- package/dist/types/BscTypeKind.js.map +0 -1
- package/dist/types/BuiltInInterfaceAdder.d.ts +0 -23
- package/dist/types/BuiltInInterfaceAdder.js +0 -160
- package/dist/types/BuiltInInterfaceAdder.js.map +0 -1
- package/dist/types/BuiltInInterfaceAdder.spec.d.ts +0 -1
- package/dist/types/BuiltInInterfaceAdder.spec.js +0 -116
- package/dist/types/BuiltInInterfaceAdder.spec.js.map +0 -1
- package/dist/types/ClassType.d.ts +0 -17
- package/dist/types/ClassType.js +0 -58
- package/dist/types/ClassType.js.map +0 -1
- package/dist/types/ClassType.spec.d.ts +0 -1
- package/dist/types/ClassType.spec.js +0 -77
- package/dist/types/ClassType.spec.js.map +0 -1
- package/dist/types/ComponentType.d.ts +0 -26
- package/dist/types/ComponentType.js +0 -83
- package/dist/types/ComponentType.js.map +0 -1
- package/dist/types/EnumType.d.ts +0 -40
- package/dist/types/EnumType.js +0 -81
- package/dist/types/EnumType.js.map +0 -1
- package/dist/types/EnumType.spec.d.ts +0 -1
- package/dist/types/EnumType.spec.js +0 -33
- package/dist/types/EnumType.spec.js.map +0 -1
- package/dist/types/InheritableType.d.ts +0 -28
- package/dist/types/InheritableType.js +0 -152
- package/dist/types/InheritableType.js.map +0 -1
- package/dist/types/NamespaceType.d.ts +0 -12
- package/dist/types/NamespaceType.js +0 -28
- package/dist/types/NamespaceType.js.map +0 -1
- package/dist/types/ReferenceType.d.ts +0 -63
- package/dist/types/ReferenceType.js +0 -423
- package/dist/types/ReferenceType.js.map +0 -1
- package/dist/types/ReferenceType.spec.d.ts +0 -1
- package/dist/types/ReferenceType.spec.js +0 -137
- package/dist/types/ReferenceType.spec.js.map +0 -1
- package/dist/types/TypedFunctionType.d.ts +0 -33
- package/dist/types/TypedFunctionType.js +0 -106
- package/dist/types/TypedFunctionType.js.map +0 -1
- package/dist/types/TypedFunctionType.spec.d.ts +0 -1
- package/dist/types/TypedFunctionType.spec.js +0 -122
- package/dist/types/TypedFunctionType.spec.js.map +0 -1
- package/dist/types/UnionType.d.ts +0 -20
- package/dist/types/UnionType.js +0 -123
- package/dist/types/UnionType.js.map +0 -1
- package/dist/types/UnionType.spec.d.ts +0 -1
- package/dist/types/UnionType.spec.js +0 -130
- package/dist/types/UnionType.spec.js.map +0 -1
- package/dist/types/helper.spec.d.ts +0 -1
- package/dist/types/helper.spec.js +0 -145
- package/dist/types/helper.spec.js.map +0 -1
- package/dist/types/helpers.d.ts +0 -24
- package/dist/types/helpers.js +0 -178
- package/dist/types/helpers.js.map +0 -1
- package/dist/types/index.d.ts +0 -22
- package/dist/types/index.js +0 -39
- package/dist/types/index.js.map +0 -1
- /package/dist/astUtils/{Editor.spec.d.ts → AstEditor.spec.d.ts} +0 -0
- /package/dist/bscPlugin/{completions/CompletionsProcessor.spec.d.ts → definition/DefinitionProvider.spec.d.ts} +0 -0
- /package/dist/bscPlugin/{serialize/BslibInjector.spec.d.ts → references/ReferencesProvider.spec.d.ts} +0 -0
- /package/dist/bscPlugin/{transpile/BrsFileTranspileProcessor.spec.d.ts → symbols/DocumentSymbolProcessor.spec.d.ts} +0 -0
- /package/dist/bscPlugin/{validation/ScopeValidator.spec.d.ts → symbols/WorkspaceSymbolProcessor.spec.d.ts} +0 -0
- /package/dist/{files/LazyFileData.spec.d.ts → bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.d.ts} +0 -0
- /package/dist/{parser/tests/expression/TypeExpression.spec.d.ts → types/FunctionType.spec.d.ts} +0 -0
package/dist/Scope.js
CHANGED
|
@@ -2,28 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Scope = void 0;
|
|
4
4
|
const path = require("path");
|
|
5
|
+
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
5
6
|
const chalk_1 = require("chalk");
|
|
6
7
|
const DiagnosticMessages_1 = require("./DiagnosticMessages");
|
|
7
|
-
const interfaces_1 = require("./interfaces");
|
|
8
8
|
const ClassValidator_1 = require("./validators/ClassValidator");
|
|
9
9
|
const Parser_1 = require("./parser/Parser");
|
|
10
10
|
const util_1 = require("./util");
|
|
11
11
|
const globalCallables_1 = require("./globalCallables");
|
|
12
12
|
const Cache_1 = require("./Cache");
|
|
13
13
|
const vscode_uri_1 = require("vscode-uri");
|
|
14
|
-
const Logger_1 = require("./Logger");
|
|
15
14
|
const reflection_1 = require("./astUtils/reflection");
|
|
16
15
|
const SymbolTable_1 = require("./SymbolTable");
|
|
17
|
-
const
|
|
18
|
-
const ReferenceType_1 = require("./types/ReferenceType");
|
|
19
|
-
const UnionType_1 = require("./types/UnionType");
|
|
20
|
-
const AssociativeArrayType_1 = require("./types/AssociativeArrayType");
|
|
21
|
-
/**
|
|
22
|
-
* Assign some few factories to the SymbolTable to prevent cyclical imports. This file seems like the most intuitive place to do the linking
|
|
23
|
-
* since Scope will be used by pretty much everything
|
|
24
|
-
*/
|
|
25
|
-
SymbolTable_1.SymbolTable.referenceTypeFactory = ReferenceType_1.referenceTypeFactory;
|
|
26
|
-
SymbolTable_1.SymbolTable.unionTypeFactory = UnionType_1.unionTypeFactory;
|
|
16
|
+
const logging_1 = require("./logging");
|
|
27
17
|
/**
|
|
28
18
|
* A class to keep track of all declarations within a given scope (like source scope, component scope)
|
|
29
19
|
*/
|
|
@@ -37,11 +27,6 @@ class Scope {
|
|
|
37
27
|
* The list of diagnostics found specifically for this scope. Individual file diagnostics are stored on the files themselves.
|
|
38
28
|
*/
|
|
39
29
|
this.diagnostics = [];
|
|
40
|
-
/**
|
|
41
|
-
* A list of functions that will be called whenever `unlinkSymbolTable` is called
|
|
42
|
-
*/
|
|
43
|
-
this.linkSymbolTableDisposables = [];
|
|
44
|
-
this.symbolsAddedDuringLinking = [];
|
|
45
30
|
this.isValidated = false;
|
|
46
31
|
//used for improved logging performance
|
|
47
32
|
this._debugLogComponentName = `Scope '${chalk_1.default.redBright(this.name)}'`;
|
|
@@ -55,20 +40,6 @@ class Scope {
|
|
|
55
40
|
* "namea", "namea.nameb", "namea.nameb.namec"
|
|
56
41
|
*/
|
|
57
42
|
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
|
-
}
|
|
72
43
|
return this.cache.getOrAdd('namespaceLookup', () => this.buildNamespaceLookup());
|
|
73
44
|
}
|
|
74
45
|
/**
|
|
@@ -168,7 +139,7 @@ class Scope {
|
|
|
168
139
|
var _a, _b;
|
|
169
140
|
let lowerNameParts = (_a = enumMemberName === null || enumMemberName === void 0 ? void 0 : enumMemberName.toLowerCase()) === null || _a === void 0 ? void 0 : _a.split('.');
|
|
170
141
|
let memberName = (_b = lowerNameParts === null || lowerNameParts === void 0 ? void 0 : lowerNameParts.splice(lowerNameParts.length - 1, 1)) === null || _b === void 0 ? void 0 : _b[0];
|
|
171
|
-
let lowerName = lowerNameParts === null || lowerNameParts === void 0 ? void 0 : lowerNameParts.join('.');
|
|
142
|
+
let lowerName = lowerNameParts === null || lowerNameParts === void 0 ? void 0 : lowerNameParts.join('.').toLowerCase();
|
|
172
143
|
const enumMap = this.getEnumMap();
|
|
173
144
|
let enumeration = enumMap.get(util_1.util.getFullyQualifiedClassName(lowerName, containingNamespace === null || containingNamespace === void 0 ? void 0 : containingNamespace.toLowerCase()));
|
|
174
145
|
//if we couldn't find the enum by its full namespaced name, look for a global enum with that name
|
|
@@ -179,7 +150,6 @@ class Scope {
|
|
|
179
150
|
let member = enumeration.item.findChild((child) => { var _a; return (0, reflection_1.isEnumMemberStatement)(child) && ((_a = child.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === memberName; });
|
|
180
151
|
return member ? { item: member, file: enumeration.file } : undefined;
|
|
181
152
|
}
|
|
182
|
-
return enumeration;
|
|
183
153
|
}
|
|
184
154
|
/**
|
|
185
155
|
* Get a constant and its containing file by the constant name
|
|
@@ -244,12 +214,13 @@ class Scope {
|
|
|
244
214
|
return this.cache.getOrAdd('classMap', () => {
|
|
245
215
|
const map = new Map();
|
|
246
216
|
this.enumerateBrsFiles((file) => {
|
|
217
|
+
var _a;
|
|
247
218
|
if ((0, reflection_1.isBrsFile)(file)) {
|
|
248
219
|
for (let cls of file.parser.references.classStatements) {
|
|
249
|
-
const
|
|
220
|
+
const lowerClassName = (_a = cls.getName(Parser_1.ParseMode.BrighterScript)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
250
221
|
//only track classes with a defined name (i.e. exclude nameless malformed classes)
|
|
251
|
-
if (
|
|
252
|
-
map.set(
|
|
222
|
+
if (lowerClassName) {
|
|
223
|
+
map.set(lowerClassName, { item: cls, file: file });
|
|
253
224
|
}
|
|
254
225
|
}
|
|
255
226
|
}
|
|
@@ -265,12 +236,13 @@ class Scope {
|
|
|
265
236
|
return this.cache.getOrAdd('interfaceMap', () => {
|
|
266
237
|
const map = new Map();
|
|
267
238
|
this.enumerateBrsFiles((file) => {
|
|
239
|
+
var _a;
|
|
268
240
|
if ((0, reflection_1.isBrsFile)(file)) {
|
|
269
241
|
for (let iface of file.parser.references.interfaceStatements) {
|
|
270
|
-
const
|
|
242
|
+
const lowerIfaceName = (_a = iface.getName(Parser_1.ParseMode.BrighterScript)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
271
243
|
//only track classes with a defined name (i.e. exclude nameless malformed classes)
|
|
272
|
-
if (
|
|
273
|
-
map.set(
|
|
244
|
+
if (lowerIfaceName) {
|
|
245
|
+
map.set(lowerIfaceName, { item: iface, file: file });
|
|
274
246
|
}
|
|
275
247
|
}
|
|
276
248
|
}
|
|
@@ -287,9 +259,10 @@ class Scope {
|
|
|
287
259
|
const map = new Map();
|
|
288
260
|
this.enumerateBrsFiles((file) => {
|
|
289
261
|
for (let enumStmt of file.parser.references.enumStatements) {
|
|
262
|
+
const lowerEnumName = enumStmt.fullName.toLowerCase();
|
|
290
263
|
//only track enums with a defined name (i.e. exclude nameless malformed enums)
|
|
291
|
-
if (
|
|
292
|
-
map.set(
|
|
264
|
+
if (lowerEnumName) {
|
|
265
|
+
map.set(lowerEnumName, { item: enumStmt, file: file });
|
|
293
266
|
}
|
|
294
267
|
}
|
|
295
268
|
});
|
|
@@ -305,9 +278,10 @@ class Scope {
|
|
|
305
278
|
const map = new Map();
|
|
306
279
|
this.enumerateBrsFiles((file) => {
|
|
307
280
|
for (let stmt of file.parser.references.constStatements) {
|
|
281
|
+
const lowerEnumName = stmt.fullName.toLowerCase();
|
|
308
282
|
//only track enums with a defined name (i.e. exclude nameless malformed enums)
|
|
309
|
-
if (
|
|
310
|
-
map.set(
|
|
283
|
+
if (lowerEnumName) {
|
|
284
|
+
map.set(lowerEnumName, { item: stmt, file: file });
|
|
311
285
|
}
|
|
312
286
|
}
|
|
313
287
|
});
|
|
@@ -372,14 +346,14 @@ class Scope {
|
|
|
372
346
|
}
|
|
373
347
|
/**
|
|
374
348
|
* Get the file from this scope with the given path.
|
|
375
|
-
* @param filePath can be a srcPath or
|
|
349
|
+
* @param filePath can be a srcPath or pkgPath
|
|
376
350
|
* @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
|
|
377
351
|
*/
|
|
378
352
|
getFile(filePath, normalizePath = true) {
|
|
379
353
|
if (typeof filePath !== 'string') {
|
|
380
354
|
return undefined;
|
|
381
355
|
}
|
|
382
|
-
const key = path.isAbsolute(filePath) ? 'srcPath' : '
|
|
356
|
+
const key = path.isAbsolute(filePath) ? 'srcPath' : 'pkgPath';
|
|
383
357
|
let map = this.cache.getOrAdd('fileMaps-srcPath', () => {
|
|
384
358
|
const result = new Map();
|
|
385
359
|
for (const file of this.getAllFiles()) {
|
|
@@ -420,26 +394,26 @@ class Scope {
|
|
|
420
394
|
}
|
|
421
395
|
}
|
|
422
396
|
}
|
|
423
|
-
this.logDebug('getAllFiles', () => result.map(x => x.
|
|
397
|
+
this.logDebug('getAllFiles', () => result.map(x => x.pkgPath));
|
|
424
398
|
return result;
|
|
425
399
|
});
|
|
426
400
|
}
|
|
427
401
|
/**
|
|
428
|
-
* Get the list of errors for this scope. It's calculated on the fly, so
|
|
402
|
+
* Get the list of errors for this scope. It's calculated on the fly, so
|
|
403
|
+
* call this sparingly.
|
|
429
404
|
*/
|
|
430
405
|
getDiagnostics() {
|
|
406
|
+
let diagnosticLists = [this.diagnostics];
|
|
431
407
|
//add diagnostics from every referenced file
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
]
|
|
438
|
-
//exclude diagnostics that match any of the comment flags
|
|
439
|
-
.filter((x) => {
|
|
408
|
+
this.enumerateOwnFiles((file) => {
|
|
409
|
+
diagnosticLists.push(file.getDiagnostics());
|
|
410
|
+
});
|
|
411
|
+
let allDiagnostics = Array.prototype.concat.apply([], diagnosticLists);
|
|
412
|
+
let filteredDiagnostics = allDiagnostics.filter((x) => {
|
|
440
413
|
return !util_1.util.diagnosticIsSuppressed(x);
|
|
441
414
|
});
|
|
442
|
-
|
|
415
|
+
//filter out diangostics that match any of the comment flags
|
|
416
|
+
return filteredDiagnostics;
|
|
443
417
|
}
|
|
444
418
|
addDiagnostics(diagnostics) {
|
|
445
419
|
this.diagnostics.push(...diagnostics);
|
|
@@ -497,7 +471,7 @@ class Scope {
|
|
|
497
471
|
const files = this.getOwnFiles();
|
|
498
472
|
for (const file of files) {
|
|
499
473
|
//either XML components or files without a typedef
|
|
500
|
-
if ((0, reflection_1.isXmlFile)(file) ||
|
|
474
|
+
if ((0, reflection_1.isXmlFile)(file) || !file.hasTypedef) {
|
|
501
475
|
callback(file);
|
|
502
476
|
}
|
|
503
477
|
}
|
|
@@ -508,16 +482,14 @@ class Scope {
|
|
|
508
482
|
*/
|
|
509
483
|
getOwnCallables() {
|
|
510
484
|
let result = [];
|
|
511
|
-
this.logDebug('getOwnCallables() files: ', () => this.getOwnFiles().map(x => x.
|
|
485
|
+
this.logDebug('getOwnCallables() files: ', () => this.getOwnFiles().map(x => x.pkgPath));
|
|
512
486
|
//get callables from own files
|
|
513
487
|
this.enumerateOwnFiles((file) => {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
});
|
|
520
|
-
}
|
|
488
|
+
for (let callable of file.callables) {
|
|
489
|
+
result.push({
|
|
490
|
+
callable: callable,
|
|
491
|
+
scope: this
|
|
492
|
+
});
|
|
521
493
|
}
|
|
522
494
|
});
|
|
523
495
|
return result;
|
|
@@ -525,27 +497,64 @@ class Scope {
|
|
|
525
497
|
/**
|
|
526
498
|
* Builds a tree of namespace objects
|
|
527
499
|
*/
|
|
528
|
-
buildNamespaceLookup(
|
|
500
|
+
buildNamespaceLookup() {
|
|
529
501
|
let namespaceLookup = new Map();
|
|
530
|
-
options.okToCache = true;
|
|
531
502
|
this.enumerateBrsFiles((file) => {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
503
|
+
for (let namespaceStatement of file.parser.references.namespaceStatements) {
|
|
504
|
+
//TODO should we handle non-brighterscript?
|
|
505
|
+
let name = namespaceStatement.getName(Parser_1.ParseMode.BrighterScript);
|
|
506
|
+
let nameParts = name.split('.');
|
|
507
|
+
let loopName = null;
|
|
508
|
+
//ensure each namespace section is represented in the results
|
|
509
|
+
//(so if the namespace name is A.B.C, this will make an entry for "A", an entry for "A.B", and an entry for "A.B.C"
|
|
510
|
+
for (let part of nameParts) {
|
|
511
|
+
loopName = loopName === null ? part : `${loopName}.${part}`;
|
|
512
|
+
let lowerLoopName = loopName.toLowerCase();
|
|
513
|
+
if (!namespaceLookup.has(lowerLoopName)) {
|
|
514
|
+
namespaceLookup.set(lowerLoopName, {
|
|
515
|
+
file: file,
|
|
516
|
+
fullName: loopName,
|
|
517
|
+
nameRange: namespaceStatement.nameExpression.range,
|
|
518
|
+
lastPartName: part,
|
|
519
|
+
namespaces: new Map(),
|
|
520
|
+
classStatements: {},
|
|
521
|
+
functionStatements: {},
|
|
522
|
+
enumStatements: new Map(),
|
|
523
|
+
constStatements: new Map(),
|
|
524
|
+
statements: [],
|
|
525
|
+
symbolTable: new SymbolTable_1.SymbolTable(`Namespace Aggregate: '${loopName}'`, () => this.symbolTable)
|
|
526
|
+
});
|
|
527
|
+
}
|
|
539
528
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
529
|
+
let ns = namespaceLookup.get(name.toLowerCase());
|
|
530
|
+
ns.statements.push(...namespaceStatement.body.statements);
|
|
531
|
+
for (let statement of namespaceStatement.body.statements) {
|
|
532
|
+
if ((0, reflection_1.isClassStatement)(statement) && statement.name) {
|
|
533
|
+
ns.classStatements[statement.name.text.toLowerCase()] = statement;
|
|
534
|
+
}
|
|
535
|
+
else if ((0, reflection_1.isFunctionStatement)(statement) && statement.name) {
|
|
536
|
+
ns.functionStatements[statement.name.text.toLowerCase()] = statement;
|
|
537
|
+
}
|
|
538
|
+
else if ((0, reflection_1.isEnumStatement)(statement) && statement.fullName) {
|
|
539
|
+
ns.enumStatements.set(statement.fullName.toLowerCase(), statement);
|
|
540
|
+
}
|
|
541
|
+
else if ((0, reflection_1.isConstStatement)(statement) && statement.fullName) {
|
|
542
|
+
ns.constStatements.set(statement.fullName.toLowerCase(), statement);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
// Merges all the symbol tables of the namespace statements into the new symbol table created above.
|
|
546
|
+
// Set those symbol tables to have this new merged table as a parent
|
|
547
|
+
ns.symbolTable.mergeSymbolTable(namespaceStatement.body.getSymbolTable());
|
|
548
|
+
}
|
|
549
|
+
//associate child namespaces with their parents
|
|
550
|
+
for (let [, ns] of namespaceLookup) {
|
|
551
|
+
let parts = ns.fullName.split('.');
|
|
552
|
+
if (parts.length > 1) {
|
|
553
|
+
//remove the last part
|
|
554
|
+
parts.pop();
|
|
555
|
+
let parentName = parts.join('.');
|
|
556
|
+
const parent = namespaceLookup.get(parentName.toLowerCase());
|
|
557
|
+
parent.namespaces.set(ns.lastPartName.toLowerCase(), ns);
|
|
549
558
|
}
|
|
550
559
|
}
|
|
551
560
|
});
|
|
@@ -561,21 +570,21 @@ class Scope {
|
|
|
561
570
|
logDebug(...args) {
|
|
562
571
|
this.program.logger.debug(this._debugLogComponentName, ...args);
|
|
563
572
|
}
|
|
564
|
-
validate(
|
|
573
|
+
validate(force = false) {
|
|
565
574
|
//if this scope is already validated, no need to revalidate
|
|
566
|
-
if (this.isValidated === true && !
|
|
575
|
+
if (this.isValidated === true && !force) {
|
|
567
576
|
this.logDebug('validate(): already validated');
|
|
568
577
|
return;
|
|
569
578
|
}
|
|
570
|
-
this.program.logger.time(
|
|
579
|
+
this.program.logger.time(logging_1.LogLevel.debug, [this._debugLogComponentName, 'validate()'], () => {
|
|
571
580
|
let parentScope = this.getParentScope();
|
|
572
581
|
//validate our parent before we validate ourself
|
|
573
582
|
if (parentScope && parentScope.isValidated === false) {
|
|
574
583
|
this.logDebug('validate(): validating parent first');
|
|
575
|
-
parentScope.validate(
|
|
584
|
+
parentScope.validate(force);
|
|
576
585
|
}
|
|
577
586
|
//clear the scope's errors list (we will populate them from this method)
|
|
578
|
-
this.
|
|
587
|
+
this.diagnostics = [];
|
|
579
588
|
let callables = this.getAllCallables();
|
|
580
589
|
//sort the callables by filepath and then method name, so the errors will be consistent
|
|
581
590
|
// eslint-disable-next-line prefer-arrow-callback
|
|
@@ -602,18 +611,16 @@ class Scope {
|
|
|
602
611
|
});
|
|
603
612
|
//get a list of all callables, indexed by their lower case names
|
|
604
613
|
let callableContainerMap = util_1.util.getCallableContainersByLowerName(callables);
|
|
614
|
+
let files = this.getOwnFiles();
|
|
605
615
|
//Since statements from files are shared across multiple scopes, we need to link those statements to the current scope
|
|
606
616
|
this.linkSymbolTable();
|
|
607
|
-
|
|
617
|
+
this.program.plugins.emit('beforeScopeValidate', this, files, callableContainerMap);
|
|
618
|
+
this.program.plugins.emit('onScopeValidate', {
|
|
608
619
|
program: this.program,
|
|
609
|
-
scope: this
|
|
610
|
-
|
|
611
|
-
changedSymbols: validationOptions === null || validationOptions === void 0 ? void 0 : validationOptions.changedSymbols
|
|
612
|
-
};
|
|
613
|
-
this.program.plugins.emit('beforeScopeValidate', scopeValidateEvent);
|
|
614
|
-
this.program.plugins.emit('onScopeValidate', scopeValidateEvent);
|
|
620
|
+
scope: this
|
|
621
|
+
});
|
|
615
622
|
this._validate(callableContainerMap);
|
|
616
|
-
this.program.plugins.emit('afterScopeValidate',
|
|
623
|
+
this.program.plugins.emit('afterScopeValidate', this, files, callableContainerMap);
|
|
617
624
|
//unlink all symbol tables from this scope (so they don't accidentally stick around)
|
|
618
625
|
this.unlinkSymbolTable();
|
|
619
626
|
this.isValidated = true;
|
|
@@ -628,21 +635,13 @@ class Scope {
|
|
|
628
635
|
this.validateClasses();
|
|
629
636
|
//do many per-file checks
|
|
630
637
|
this.enumerateBrsFiles((file) => {
|
|
638
|
+
this.diagnosticDetectFunctionCallsWithWrongParamCount(file, callableContainerMap);
|
|
631
639
|
this.diagnosticDetectShadowedLocalVars(file, callableContainerMap);
|
|
632
640
|
this.diagnosticDetectFunctionCollisions(file);
|
|
633
641
|
this.detectVariableNamespaceCollisions(file);
|
|
642
|
+
this.diagnosticDetectInvalidFunctionExpressionTypes(file);
|
|
634
643
|
});
|
|
635
644
|
}
|
|
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
|
-
}
|
|
646
645
|
/**
|
|
647
646
|
* Mark this scope as invalid, which means its `validate()` function needs to be called again before use.
|
|
648
647
|
*/
|
|
@@ -655,7 +654,6 @@ class Scope {
|
|
|
655
654
|
return this.cache.getOrAdd('symbolTable', () => {
|
|
656
655
|
var _a;
|
|
657
656
|
const result = new SymbolTable_1.SymbolTable(`Scope: '${this.name}'`, () => { var _a; return (_a = this.getParentScope()) === null || _a === void 0 ? void 0 : _a.symbolTable; });
|
|
658
|
-
result.addSymbol('m', undefined, new AssociativeArrayType_1.AssociativeArrayType(), SymbolTable_1.SymbolTypeFlag.runtime);
|
|
659
657
|
for (let file of this.getOwnFiles()) {
|
|
660
658
|
if ((0, reflection_1.isBrsFile)(file)) {
|
|
661
659
|
result.mergeSymbolTable((_a = file.parser) === null || _a === void 0 ? void 0 : _a.symbolTable);
|
|
@@ -668,88 +666,30 @@ class Scope {
|
|
|
668
666
|
* Builds the current symbol table for the scope, by merging the tables for all the files in this scope.
|
|
669
667
|
* Also links all file symbols tables to this new table
|
|
670
668
|
* This will only rebuilt if the symbol table has not been built before
|
|
671
|
-
*
|
|
672
|
-
* Tree of symbol tables:
|
|
673
|
-
* ```
|
|
674
|
-
* Global Scope Symbol Table
|
|
675
|
-
* - Source Scope Symbol Table :: Aggregate Namespaces Symbol Table (Siblings)
|
|
676
|
-
* - File 1 Symbol Table
|
|
677
|
-
* - File 2 Symbol Table
|
|
678
|
-
* - Component A Scope Symbol Table :: Aggregate Namespaces Symbol Table (Siblings)
|
|
679
|
-
* - File 1 Symbol Table
|
|
680
|
-
* - File 2 Symbol Table
|
|
681
|
-
* - Component B Scope Symbol Table :: Aggregate Namespaces Symbol Table (Siblings)
|
|
682
|
-
* - File 1 Symbol Table
|
|
683
|
-
* - File 2 Symbol Table
|
|
684
|
-
* ```
|
|
685
669
|
*/
|
|
686
670
|
linkSymbolTable() {
|
|
687
|
-
var _a;
|
|
688
|
-
SymbolTable_1.SymbolTable.cacheVerifier.generateToken();
|
|
689
671
|
for (const file of this.getAllFiles()) {
|
|
690
672
|
if ((0, reflection_1.isBrsFile)(file)) {
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
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) {
|
|
699
|
-
let currentNSType = null;
|
|
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 });
|
|
722
|
-
}
|
|
723
|
-
else {
|
|
724
|
-
this.symbolTable.addSymbol(nsContainer.lastPartName, { definingNode: existingNsStmt }, currentNSType, getTypeOptions.flags);
|
|
725
|
-
this.symbolsAddedDuringLinking.push({ symbolTable: this.symbolTable, name: nsContainer.lastPartName, flags: getTypeOptions.flags });
|
|
726
|
-
}
|
|
673
|
+
file.parser.symbolTable.pushParentProvider(() => this.symbolTable);
|
|
674
|
+
//link each NamespaceStatement's SymbolTable with the aggregate NamespaceLookup SymbolTable
|
|
675
|
+
for (const namespace of file.parser.references.namespaceStatements) {
|
|
676
|
+
const namespaceNameLower = namespace.getName(Parser_1.ParseMode.BrighterScript).toLowerCase();
|
|
677
|
+
namespace.getSymbolTable().addSibling(this.namespaceLookup.get(namespaceNameLower).symbolTable);
|
|
727
678
|
}
|
|
728
|
-
else {
|
|
729
|
-
break;
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
else {
|
|
733
|
-
// Existing known namespace
|
|
734
|
-
}
|
|
735
|
-
if (!namespaceTypesKnown.has(nsName)) {
|
|
736
|
-
namespaceTypesKnown.set(nsName, currentNSType);
|
|
737
679
|
}
|
|
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));
|
|
742
680
|
}
|
|
743
681
|
}
|
|
744
682
|
unlinkSymbolTable() {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
683
|
+
var _a;
|
|
684
|
+
for (let file of this.getOwnFiles()) {
|
|
685
|
+
if ((0, reflection_1.isBrsFile)(file)) {
|
|
686
|
+
(_a = file.parser) === null || _a === void 0 ? void 0 : _a.symbolTable.popParentProvider();
|
|
687
|
+
for (const namespace of file.parser.references.namespaceStatements) {
|
|
688
|
+
const namespaceNameLower = namespace.getName(Parser_1.ParseMode.BrighterScript).toLowerCase();
|
|
689
|
+
namespace.getSymbolTable().removeSibling(this.namespaceLookup.get(namespaceNameLower).symbolTable);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
751
692
|
}
|
|
752
|
-
this.linkSymbolTableDisposables = [];
|
|
753
693
|
}
|
|
754
694
|
detectVariableNamespaceCollisions(file) {
|
|
755
695
|
var _a, _b;
|
|
@@ -760,7 +700,7 @@ class Scope {
|
|
|
760
700
|
let namespace = this.getNamespace(lowerParamName, (_a = param.findAncestor(reflection_1.isNamespaceStatement)) === null || _a === void 0 ? void 0 : _a.getName(Parser_1.ParseMode.BrighterScript).toLowerCase());
|
|
761
701
|
//see if the param matches any starting namespace part
|
|
762
702
|
if (namespace) {
|
|
763
|
-
this.diagnostics.push(Object.assign(Object.assign({
|
|
703
|
+
this.diagnostics.push(Object.assign(Object.assign({ file: file }, DiagnosticMessages_1.DiagnosticMessages.parameterMayNotHaveSameNameAsNamespace(param.name.text)), { range: param.name.range, relatedInformation: [{
|
|
764
704
|
message: 'Namespace declared here',
|
|
765
705
|
location: util_1.util.createLocation(vscode_uri_1.URI.file(namespace.file.srcPath).toString(), namespace.nameRange)
|
|
766
706
|
}] }));
|
|
@@ -772,7 +712,7 @@ class Scope {
|
|
|
772
712
|
let namespace = this.getNamespace(lowerAssignmentName, (_b = assignment.findAncestor(reflection_1.isNamespaceStatement)) === null || _b === void 0 ? void 0 : _b.getName(Parser_1.ParseMode.BrighterScript).toLowerCase());
|
|
773
713
|
//see if the param matches any starting namespace part
|
|
774
714
|
if (namespace) {
|
|
775
|
-
this.diagnostics.push(Object.assign(Object.assign({
|
|
715
|
+
this.diagnostics.push(Object.assign(Object.assign({ file: file }, DiagnosticMessages_1.DiagnosticMessages.variableMayNotHaveSameNameAsNamespace(assignment.name.text)), { range: assignment.name.range, relatedInformation: [{
|
|
776
716
|
message: 'Namespace declared here',
|
|
777
717
|
location: util_1.util.createLocation(vscode_uri_1.URI.file(namespace.file.srcPath).toString(), namespace.nameRange)
|
|
778
718
|
}] }));
|
|
@@ -789,11 +729,40 @@ class Scope {
|
|
|
789
729
|
if (lowerFuncName) {
|
|
790
730
|
//find function declarations with the same name as a stdlib function
|
|
791
731
|
if (globalCallables_1.globalCallableMap.has(lowerFuncName)) {
|
|
792
|
-
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.scopeFunctionShadowedByBuiltInFunction()), { range: func.nameRange, file: file
|
|
732
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.scopeFunctionShadowedByBuiltInFunction()), { range: func.nameRange, file: file }));
|
|
793
733
|
}
|
|
794
734
|
//find any functions that have the same name as a class
|
|
795
735
|
if (this.hasClass(lowerFuncName)) {
|
|
796
|
-
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.functionCannotHaveSameNameAsClass(funcName)), { range: func.nameRange, file: file
|
|
736
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.functionCannotHaveSameNameAsClass(funcName)), { range: func.nameRange, file: file }));
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Find function parameters and function return types that are neither built-in types or known Class references
|
|
743
|
+
*/
|
|
744
|
+
diagnosticDetectInvalidFunctionExpressionTypes(file) {
|
|
745
|
+
var _a, _b;
|
|
746
|
+
for (let func of file.parser.references.functionExpressions) {
|
|
747
|
+
if ((0, reflection_1.isCustomType)(func.returnType) && func.returnTypeToken) {
|
|
748
|
+
// check if this custom type is in our class map
|
|
749
|
+
const returnTypeName = func.returnType.name;
|
|
750
|
+
const currentNamespaceName = (_a = func.findAncestor(reflection_1.isNamespaceStatement)) === null || _a === void 0 ? void 0 : _a.getName(Parser_1.ParseMode.BrighterScript);
|
|
751
|
+
// check for built in types
|
|
752
|
+
const isBuiltInType = util_1.util.isBuiltInType(returnTypeName);
|
|
753
|
+
if (!isBuiltInType && !this.hasClass(returnTypeName, currentNamespaceName) && !this.hasInterface(returnTypeName) && !this.hasEnum(returnTypeName)) {
|
|
754
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.invalidFunctionReturnType(returnTypeName)), { range: func.returnTypeToken.range, file: file }));
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
for (let param of func.parameters) {
|
|
758
|
+
if ((0, reflection_1.isCustomType)(param.type) && param.typeToken) {
|
|
759
|
+
const paramTypeName = param.type.name;
|
|
760
|
+
const currentNamespaceName = (_b = func.findAncestor(reflection_1.isNamespaceStatement)) === null || _b === void 0 ? void 0 : _b.getName(Parser_1.ParseMode.BrighterScript);
|
|
761
|
+
// check for built in types
|
|
762
|
+
const isBuiltInType = util_1.util.isBuiltInType(paramTypeName);
|
|
763
|
+
if (!isBuiltInType && !this.hasClass(paramTypeName, currentNamespaceName) && !this.hasInterface(paramTypeName) && !this.hasEnum(paramTypeName)) {
|
|
764
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.functionParameterTypeIsInvalid(param.name.text, paramTypeName)), { range: param.typeToken.range, file: file }));
|
|
765
|
+
}
|
|
797
766
|
}
|
|
798
767
|
}
|
|
799
768
|
}
|
|
@@ -810,11 +779,40 @@ class Scope {
|
|
|
810
779
|
return result;
|
|
811
780
|
}
|
|
812
781
|
validateClasses() {
|
|
813
|
-
let validator = new ClassValidator_1.BsClassValidator();
|
|
814
|
-
validator.validate(
|
|
815
|
-
this.diagnostics.push(...validator.diagnostics
|
|
816
|
-
|
|
817
|
-
|
|
782
|
+
let validator = new ClassValidator_1.BsClassValidator(this);
|
|
783
|
+
validator.validate();
|
|
784
|
+
this.diagnostics.push(...validator.diagnostics);
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Detect calls to functions with the incorrect number of parameters
|
|
788
|
+
*/
|
|
789
|
+
diagnosticDetectFunctionCallsWithWrongParamCount(file, callableContainersByLowerName) {
|
|
790
|
+
//validate all function calls
|
|
791
|
+
for (let expCall of file.functionCalls) {
|
|
792
|
+
let callableContainersWithThisName = callableContainersByLowerName.get(expCall.name.toLowerCase());
|
|
793
|
+
//use the first item from callablesByLowerName, because if there are more, that's a separate error
|
|
794
|
+
let knownCallableContainer = callableContainersWithThisName ? callableContainersWithThisName[0] : undefined;
|
|
795
|
+
if (knownCallableContainer) {
|
|
796
|
+
//get min/max parameter count for callable
|
|
797
|
+
let minParams = 0;
|
|
798
|
+
let maxParams = 0;
|
|
799
|
+
for (let param of knownCallableContainer.callable.params) {
|
|
800
|
+
maxParams++;
|
|
801
|
+
//optional parameters must come last, so we can assume that minParams won't increase once we hit
|
|
802
|
+
//the first isOptional
|
|
803
|
+
if (param.isOptional !== true) {
|
|
804
|
+
minParams++;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
let expCallArgCount = expCall.args.length;
|
|
808
|
+
if (expCall.args.length > maxParams || expCall.args.length < minParams) {
|
|
809
|
+
let minMaxParamsText = minParams === maxParams ? maxParams : `${minParams}-${maxParams}`;
|
|
810
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.mismatchArgumentCount(minMaxParamsText, expCallArgCount)), { range: expCall.nameRange,
|
|
811
|
+
//TODO detect end of expression call
|
|
812
|
+
file: file }));
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
}
|
|
818
816
|
}
|
|
819
817
|
/**
|
|
820
818
|
* Detect local variables (function scope) that have the same name as scope calls
|
|
@@ -823,34 +821,39 @@ class Scope {
|
|
|
823
821
|
var _a;
|
|
824
822
|
const classMap = this.getClassMap();
|
|
825
823
|
//loop through every function scope
|
|
826
|
-
for (let
|
|
824
|
+
for (let scope of file.functionScopes) {
|
|
827
825
|
//every var declaration in this function scope
|
|
828
|
-
for (let varDeclaration of
|
|
826
|
+
for (let varDeclaration of scope.variableDeclarations) {
|
|
829
827
|
const varName = varDeclaration.name;
|
|
830
828
|
const lowerVarName = varName.toLowerCase();
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
};
|
|
834
|
-
if (
|
|
835
|
-
//has same name as stdlib
|
|
836
|
-
globalCallables_1.globalCallableMap.has(lowerVarName)) {
|
|
829
|
+
//if the var is a function
|
|
830
|
+
if ((0, reflection_1.isFunctionType)(varDeclaration.type)) {
|
|
837
831
|
//local var function with same name as stdlib function
|
|
838
|
-
if (
|
|
839
|
-
|
|
832
|
+
if (
|
|
833
|
+
//has same name as stdlib
|
|
834
|
+
globalCallables_1.globalCallableMap.has(lowerVarName)) {
|
|
835
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarFunctionShadowsParentFunction('stdlib')), { range: varDeclaration.nameRange, file: file }));
|
|
836
|
+
//this check needs to come after the stdlib one, because the stdlib functions are included
|
|
837
|
+
//in the scope function list
|
|
840
838
|
}
|
|
839
|
+
else if (
|
|
840
|
+
//has same name as scope function
|
|
841
|
+
callableContainerMap.has(lowerVarName)) {
|
|
842
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarFunctionShadowsParentFunction('scope')), { range: varDeclaration.nameRange, file: file }));
|
|
843
|
+
}
|
|
844
|
+
//var is not a function
|
|
841
845
|
}
|
|
842
|
-
else if (
|
|
846
|
+
else if (
|
|
847
|
+
//is NOT a callable from stdlib (because non-function local vars can have same name as stdlib names)
|
|
848
|
+
!globalCallables_1.globalCallableMap.has(lowerVarName)) {
|
|
843
849
|
//is same name as a callable
|
|
844
|
-
if (
|
|
845
|
-
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.
|
|
850
|
+
if (callableContainerMap.has(lowerVarName)) {
|
|
851
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.localVarShadowedByScopedFunction()), { range: varDeclaration.nameRange, file: file }));
|
|
852
|
+
//has the same name as an in-scope class
|
|
846
853
|
}
|
|
847
|
-
else {
|
|
848
|
-
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.
|
|
854
|
+
else if (classMap.has(lowerVarName)) {
|
|
855
|
+
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 }));
|
|
849
856
|
}
|
|
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 }));
|
|
854
857
|
}
|
|
855
858
|
}
|
|
856
859
|
}
|
|
@@ -889,9 +892,9 @@ class Scope {
|
|
|
889
892
|
//same file: skip redundant imports
|
|
890
893
|
continue;
|
|
891
894
|
}
|
|
892
|
-
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.overridesAncestorFunction(container.callable.name, container.scope.name, shadowedCallable.callable.file.
|
|
895
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.overridesAncestorFunction(container.callable.name, container.scope.name, shadowedCallable.callable.file.pkgPath,
|
|
893
896
|
//grab the last item in the list, which should be the closest ancestor's version
|
|
894
|
-
shadowedCallable.scope.name)), { range: container.callable.nameRange, file: container.callable.file
|
|
897
|
+
shadowedCallable.scope.name)), { range: container.callable.nameRange, file: container.callable.file }));
|
|
895
898
|
}
|
|
896
899
|
}
|
|
897
900
|
}
|
|
@@ -899,7 +902,7 @@ class Scope {
|
|
|
899
902
|
if (ownCallables.length > 1) {
|
|
900
903
|
for (let callableContainer of ownCallables) {
|
|
901
904
|
let callable = callableContainer.callable;
|
|
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
|
|
905
|
+
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 }));
|
|
903
906
|
}
|
|
904
907
|
}
|
|
905
908
|
}
|
|
@@ -926,11 +929,11 @@ class Scope {
|
|
|
926
929
|
let scriptImports = this.getOwnScriptImports();
|
|
927
930
|
//verify every script import
|
|
928
931
|
for (let scriptImport of scriptImports) {
|
|
929
|
-
let referencedFile = this.getFileByRelativePath(scriptImport.
|
|
932
|
+
let referencedFile = this.getFileByRelativePath(scriptImport.pkgPath);
|
|
930
933
|
//if we can't find the file
|
|
931
934
|
if (!referencedFile) {
|
|
932
935
|
//skip the default bslib file, it will exist at transpile time but should not show up in the program during validation cycle
|
|
933
|
-
if (scriptImport.
|
|
936
|
+
if (scriptImport.pkgPath === `source${path.sep}bslib.brs`) {
|
|
934
937
|
continue;
|
|
935
938
|
}
|
|
936
939
|
let dInfo;
|
|
@@ -940,11 +943,11 @@ class Scope {
|
|
|
940
943
|
else {
|
|
941
944
|
dInfo = DiagnosticMessages_1.DiagnosticMessages.referencedFileDoesNotExist();
|
|
942
945
|
}
|
|
943
|
-
this.diagnostics.push(Object.assign(Object.assign({}, dInfo), { range: scriptImport.filePathRange, file: scriptImport.sourceFile
|
|
946
|
+
this.diagnostics.push(Object.assign(Object.assign({}, dInfo), { range: scriptImport.filePathRange, file: scriptImport.sourceFile }));
|
|
944
947
|
//if the character casing of the script import path does not match that of the actual path
|
|
945
948
|
}
|
|
946
|
-
else if (scriptImport.
|
|
947
|
-
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.scriptImportCaseMismatch(referencedFile.
|
|
949
|
+
else if (scriptImport.pkgPath !== referencedFile.pkgPath) {
|
|
950
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.scriptImportCaseMismatch(referencedFile.pkgPath)), { range: scriptImport.filePathRange, file: scriptImport.sourceFile }));
|
|
948
951
|
}
|
|
949
952
|
}
|
|
950
953
|
}
|
|
@@ -957,7 +960,7 @@ class Scope {
|
|
|
957
960
|
}
|
|
958
961
|
let files = this.getAllFiles();
|
|
959
962
|
for (let file of files) {
|
|
960
|
-
if (file.
|
|
963
|
+
if (file.pkgPath.toLowerCase() === relativePath.toLowerCase()) {
|
|
961
964
|
return file;
|
|
962
965
|
}
|
|
963
966
|
}
|
|
@@ -970,13 +973,74 @@ class Scope {
|
|
|
970
973
|
let hasFile = files.includes(file);
|
|
971
974
|
return hasFile;
|
|
972
975
|
}
|
|
976
|
+
/**
|
|
977
|
+
* Get all callables as completionItems
|
|
978
|
+
*/
|
|
979
|
+
getCallablesAsCompletions(parseMode) {
|
|
980
|
+
let completions = [];
|
|
981
|
+
let callables = this.getAllCallables();
|
|
982
|
+
if (parseMode === Parser_1.ParseMode.BrighterScript) {
|
|
983
|
+
//throw out the namespaced callables (they will be handled by another method)
|
|
984
|
+
callables = callables.filter(x => x.callable.hasNamespace === false);
|
|
985
|
+
}
|
|
986
|
+
for (let callableContainer of callables) {
|
|
987
|
+
completions.push(this.createCompletionFromCallable(callableContainer));
|
|
988
|
+
}
|
|
989
|
+
return completions;
|
|
990
|
+
}
|
|
991
|
+
createCompletionFromCallable(callableContainer) {
|
|
992
|
+
return {
|
|
993
|
+
label: callableContainer.callable.getName(Parser_1.ParseMode.BrighterScript),
|
|
994
|
+
kind: vscode_languageserver_1.CompletionItemKind.Function,
|
|
995
|
+
detail: callableContainer.callable.shortDescription,
|
|
996
|
+
documentation: callableContainer.callable.documentation ? { kind: 'markdown', value: callableContainer.callable.documentation } : undefined
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
createCompletionFromFunctionStatement(statement) {
|
|
1000
|
+
return {
|
|
1001
|
+
label: statement.getName(Parser_1.ParseMode.BrighterScript),
|
|
1002
|
+
kind: vscode_languageserver_1.CompletionItemKind.Function
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
973
1005
|
/**
|
|
974
1006
|
* Get the definition (where was this thing first defined) of the symbol under the position
|
|
1007
|
+
* @deprecated use `DefinitionProvider.process()`
|
|
975
1008
|
*/
|
|
976
1009
|
getDefinition(file, position) {
|
|
977
1010
|
// Overridden in XMLScope. Brs files use implementation in BrsFile
|
|
978
1011
|
return [];
|
|
979
1012
|
}
|
|
1013
|
+
/**
|
|
1014
|
+
* Scan all files for property names, and return them as completions
|
|
1015
|
+
*/
|
|
1016
|
+
getPropertyNameCompletions() {
|
|
1017
|
+
let results = [];
|
|
1018
|
+
this.enumerateBrsFiles((file) => {
|
|
1019
|
+
results.push(...file.propertyNameCompletions);
|
|
1020
|
+
});
|
|
1021
|
+
return results;
|
|
1022
|
+
}
|
|
1023
|
+
getAllClassMemberCompletions() {
|
|
1024
|
+
let results = new Map();
|
|
1025
|
+
let filesSearched = new Set();
|
|
1026
|
+
for (const file of this.getAllFiles()) {
|
|
1027
|
+
if ((0, reflection_1.isXmlFile)(file) || filesSearched.has(file)) {
|
|
1028
|
+
continue;
|
|
1029
|
+
}
|
|
1030
|
+
filesSearched.add(file);
|
|
1031
|
+
for (let cs of file.parser.references.classStatements) {
|
|
1032
|
+
for (let s of [...cs.methods, ...cs.fields]) {
|
|
1033
|
+
if (!results.has(s.name.text) && s.name.text.toLowerCase() !== 'new') {
|
|
1034
|
+
results.set(s.name.text, {
|
|
1035
|
+
label: s.name.text,
|
|
1036
|
+
kind: (0, reflection_1.isMethodStatement)(s) ? vscode_languageserver_1.CompletionItemKind.Method : vscode_languageserver_1.CompletionItemKind.Field
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
return results;
|
|
1043
|
+
}
|
|
980
1044
|
/**
|
|
981
1045
|
* @param className - The name of the class (including namespace if possible)
|
|
982
1046
|
* @param callsiteNamespace - the name of the namespace where the call site resides (this is NOT the known namespace of the class).
|
|
@@ -988,7 +1052,7 @@ class Scope {
|
|
|
988
1052
|
let link = this.getClassFileLink(className, callsiteNamespace);
|
|
989
1053
|
while (link) {
|
|
990
1054
|
items.push(link);
|
|
991
|
-
link = this.getClassFileLink((_b = (_a = link.item.parentClassName) === null || _a === void 0 ? void 0 : _a.getName()) === null || _b === void 0 ? void 0 : _b.toLowerCase(), callsiteNamespace);
|
|
1055
|
+
link = this.getClassFileLink((_b = (_a = link.item.parentClassName) === null || _a === void 0 ? void 0 : _a.getName(Parser_1.ParseMode.BrighterScript)) === null || _b === void 0 ? void 0 : _b.toLowerCase(), callsiteNamespace);
|
|
992
1056
|
}
|
|
993
1057
|
return items;
|
|
994
1058
|
}
|