brighterscript 0.66.0-alpha.1 → 0.66.0-alpha.10
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 +215 -10
- package/README.md +13 -3
- package/bsconfig.schema.json +15 -0
- package/dist/ActionPipeline.d.ts +10 -0
- package/dist/ActionPipeline.js +40 -0
- package/dist/ActionPipeline.js.map +1 -0
- package/dist/AstValidationSegmenter.d.ts +25 -0
- package/dist/AstValidationSegmenter.js +150 -0
- package/dist/AstValidationSegmenter.js.map +1 -0
- package/dist/BsConfig.d.ts +13 -4
- package/dist/BusyStatusTracker.d.ts +31 -0
- package/dist/BusyStatusTracker.js +83 -0
- package/dist/BusyStatusTracker.js.map +1 -0
- package/dist/Cache.js +3 -3
- package/dist/Cache.js.map +1 -1
- package/dist/CacheVerifier.d.ts +0 -1
- package/dist/CodeActionUtil.d.ts +2 -2
- package/dist/CommentFlagProcessor.d.ts +4 -3
- package/dist/CommentFlagProcessor.js.map +1 -1
- package/dist/DiagnosticCollection.js +8 -5
- package/dist/DiagnosticCollection.js.map +1 -1
- package/dist/DiagnosticMessages.d.ts +34 -4
- package/dist/DiagnosticMessages.js +59 -4
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/FunctionScope.d.ts +1 -1
- package/dist/LanguageServer.d.ts +23 -1
- package/dist/LanguageServer.js +139 -57
- package/dist/LanguageServer.js.map +1 -1
- package/dist/Logger.d.ts +3 -2
- package/dist/Logger.js +10 -2
- package/dist/Logger.js.map +1 -1
- package/dist/PluginInterface.d.ts +11 -2
- package/dist/PluginInterface.js +69 -10
- package/dist/PluginInterface.js.map +1 -1
- package/dist/Program.d.ts +138 -49
- package/dist/Program.js +637 -349
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +10 -4
- package/dist/ProgramBuilder.js +76 -74
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +52 -49
- package/dist/Scope.js +298 -274
- package/dist/Scope.js.map +1 -1
- package/dist/SymbolTable.d.ts +35 -14
- package/dist/SymbolTable.js +90 -29
- package/dist/SymbolTable.js.map +1 -1
- package/dist/Throttler.d.ts +12 -0
- package/dist/Throttler.js +39 -0
- package/dist/Throttler.js.map +1 -1
- package/dist/XmlScope.d.ts +7 -4
- package/dist/XmlScope.js +52 -12
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/{AstEditor.d.ts → Editor.d.ts} +6 -1
- package/dist/astUtils/{AstEditor.js → Editor.js} +9 -3
- package/dist/astUtils/Editor.js.map +1 -0
- package/dist/astUtils/{AstEditor.spec.js → Editor.spec.js} +10 -6
- package/dist/astUtils/Editor.spec.js.map +1 -0
- package/dist/astUtils/creators.d.ts +3 -1
- package/dist/astUtils/creators.js +14 -4
- package/dist/astUtils/creators.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +37 -9
- package/dist/astUtils/reflection.js +83 -14
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +87 -5
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +14 -3
- package/dist/astUtils/visitors.js +22 -2
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +58 -7
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +10 -2
- package/dist/bscPlugin/BscPlugin.js +24 -4
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/CallExpressionInfo.d.ts +3 -3
- package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
- package/dist/bscPlugin/FileWriter.d.ts +6 -0
- package/dist/bscPlugin/FileWriter.js +24 -0
- package/dist/bscPlugin/FileWriter.js.map +1 -0
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +8 -8
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +4 -4
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +50 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.js +442 -23
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +1737 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.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 +7 -3
- package/dist/bscPlugin/hover/HoverProcessor.js +133 -103
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.spec.js +241 -29
- package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +1 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +43 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +22 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/serialize/BslibInjector.spec.js +19 -0
- package/dist/bscPlugin/serialize/BslibInjector.spec.js.map +1 -0
- package/dist/bscPlugin/serialize/BslibManager.d.ts +9 -0
- package/dist/bscPlugin/serialize/BslibManager.js +40 -0
- package/dist/bscPlugin/serialize/BslibManager.js.map +1 -0
- package/dist/bscPlugin/serialize/FileSerializer.d.ts +9 -0
- package/dist/bscPlugin/serialize/FileSerializer.js +72 -0
- package/dist/bscPlugin/serialize/FileSerializer.js.map +1 -0
- package/dist/bscPlugin/transpile/{BrsFilePreTranspileProcessor.d.ts → BrsFileTranspileProcessor.d.ts} +4 -2
- package/dist/bscPlugin/transpile/{BrsFilePreTranspileProcessor.js → BrsFileTranspileProcessor.js} +29 -5
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.d.ts +1 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js +41 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +2 -2
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.d.ts +0 -4
- package/dist/bscPlugin/validation/BrsFileValidator.js +34 -29
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +28 -7
- package/dist/bscPlugin/validation/ScopeValidator.js +393 -205
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.spec.d.ts +1 -0
- package/dist/bscPlugin/validation/ScopeValidator.spec.js +2038 -0
- package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -0
- package/dist/bscPlugin/validation/XmlFileValidator.js +2 -2
- package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -1
- package/dist/cli.js +104 -13
- 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 +8 -2
- package/dist/diagnosticUtils.js +45 -16
- package/dist/diagnosticUtils.js.map +1 -1
- package/dist/examples/plugins/removePrint.js +1 -1
- package/dist/examples/plugins/removePrint.js.map +1 -1
- package/dist/files/AssetFile.d.ts +26 -0
- package/dist/files/AssetFile.js +26 -0
- package/dist/files/AssetFile.js.map +1 -0
- package/dist/files/BrsFile.Class.spec.js +383 -56
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +73 -46
- package/dist/files/BrsFile.js +370 -534
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +1139 -682
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/Factory.d.ts +25 -0
- package/dist/files/Factory.js +22 -0
- package/dist/files/Factory.js.map +1 -0
- package/dist/files/File.d.ts +106 -0
- package/dist/files/File.js +16 -0
- package/dist/files/File.js.map +1 -0
- package/dist/files/LazyFileData.d.ts +20 -0
- package/dist/files/LazyFileData.js +54 -0
- package/dist/files/LazyFileData.js.map +1 -0
- package/dist/files/LazyFileData.spec.d.ts +1 -0
- package/dist/files/LazyFileData.spec.js +27 -0
- package/dist/files/LazyFileData.spec.js.map +1 -0
- package/dist/files/XmlFile.d.ts +56 -23
- package/dist/files/XmlFile.js +88 -60
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/files/XmlFile.spec.js +64 -93
- package/dist/files/XmlFile.spec.js.map +1 -1
- package/dist/files/tests/imports.spec.js +21 -8
- package/dist/files/tests/imports.spec.js.map +1 -1
- package/dist/files/tests/optionalChaning.spec.js +14 -14
- package/dist/files/tests/optionalChaning.spec.js.map +1 -1
- package/dist/globalCallables.js +88 -84
- package/dist/globalCallables.js.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +389 -94
- package/dist/interfaces.js +13 -2
- package/dist/interfaces.js.map +1 -1
- package/dist/lexer/Lexer.d.ts +12 -0
- package/dist/lexer/Lexer.js +28 -8
- package/dist/lexer/Lexer.js.map +1 -1
- package/dist/lexer/Lexer.spec.js +40 -0
- package/dist/lexer/Lexer.spec.js.map +1 -1
- package/dist/lexer/Token.d.ts +4 -0
- package/dist/lexer/Token.js.map +1 -1
- package/dist/lexer/TokenKind.d.ts +5 -0
- package/dist/lexer/TokenKind.js +14 -2
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/parser/AstNode.d.ts +9 -2
- package/dist/parser/AstNode.js +16 -0
- package/dist/parser/AstNode.js.map +1 -1
- package/dist/parser/BrsTranspileState.d.ts +3 -2
- package/dist/parser/BrsTranspileState.js +3 -2
- package/dist/parser/BrsTranspileState.js.map +1 -1
- package/dist/parser/Expression.d.ts +21 -5
- package/dist/parser/Expression.js +128 -35
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +103 -1
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.d.ts +7 -0
- package/dist/parser/Parser.js +117 -21
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.js +557 -5
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/SGParser.d.ts +4 -4
- package/dist/parser/SGParser.js +3 -3
- package/dist/parser/SGParser.js.map +1 -1
- package/dist/parser/SGParser.spec.js +2 -2
- package/dist/parser/SGParser.spec.js.map +1 -1
- package/dist/parser/SGTypes.d.ts +2 -2
- package/dist/parser/Statement.d.ts +37 -12
- package/dist/parser/Statement.js +153 -46
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/tests/Parser.spec.js +2 -1
- package/dist/parser/tests/Parser.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/For.spec.js +16 -8
- package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/ForEach.spec.js +12 -6
- package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/While.spec.js +8 -4
- 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/NullCoalescenceExpression.spec.js +29 -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 +75 -36
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.js +36 -36
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/UnaryExpression.spec.d.ts +1 -0
- package/dist/parser/tests/expression/UnaryExpression.spec.js +52 -0
- package/dist/parser/tests/expression/UnaryExpression.spec.js.map +1 -0
- package/dist/parser/tests/statement/ConstStatement.spec.js +71 -22
- package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Continue.spec.js +2 -2
- package/dist/parser/tests/statement/Continue.spec.js.map +1 -1
- package/dist/parser/tests/statement/Enum.spec.js +38 -285
- package/dist/parser/tests/statement/Enum.spec.js.map +1 -1
- package/dist/parser/tests/statement/For.spec.js +6 -6
- package/dist/parser/tests/statement/For.spec.js.map +1 -1
- package/dist/parser/tests/statement/ForEach.spec.js +4 -4
- package/dist/parser/tests/statement/ForEach.spec.js.map +1 -1
- package/dist/parser/tests/statement/InterfaceStatement.spec.js +26 -10
- package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/PrintStatement.spec.js +16 -13
- package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/ReturnStatement.spec.js +5 -3
- package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Set.spec.js +26 -13
- package/dist/parser/tests/statement/Set.spec.js.map +1 -1
- package/dist/preprocessor/Manifest.d.ts +1 -1
- package/dist/preprocessor/Manifest.js +2 -2
- package/dist/preprocessor/Manifest.js.map +1 -1
- package/dist/roku-types/data.json +243 -293
- package/dist/roku-types/index.d.ts +17 -38
- package/dist/types/ArrayType.d.ts +4 -1
- package/dist/types/ArrayType.js +46 -6
- package/dist/types/ArrayType.js.map +1 -1
- package/dist/types/ArrayType.spec.js +32 -3
- package/dist/types/ArrayType.spec.js.map +1 -1
- package/dist/types/AssociativeArrayType.d.ts +11 -0
- package/dist/types/AssociativeArrayType.js +52 -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 +2 -1
- package/dist/types/BooleanType.js +8 -2
- package/dist/types/BooleanType.js.map +1 -1
- package/dist/types/BscType.d.ts +10 -6
- package/dist/types/BscType.js +69 -16
- package/dist/types/BscType.js.map +1 -1
- package/dist/types/BscTypeKind.d.ts +3 -0
- package/dist/types/BscTypeKind.js +3 -0
- package/dist/types/BscTypeKind.js.map +1 -1
- package/dist/types/BuiltInInterfaceAdder.d.ts +23 -0
- package/dist/types/BuiltInInterfaceAdder.js +157 -0
- package/dist/types/BuiltInInterfaceAdder.js.map +1 -0
- package/dist/types/BuiltInInterfaceAdder.spec.d.ts +1 -0
- package/dist/types/BuiltInInterfaceAdder.spec.js +116 -0
- package/dist/types/BuiltInInterfaceAdder.spec.js.map +1 -0
- package/dist/types/ClassType.d.ts +10 -4
- package/dist/types/ClassType.js +32 -5
- package/dist/types/ClassType.js.map +1 -1
- package/dist/types/ClassType.spec.js +5 -3
- package/dist/types/ClassType.spec.js.map +1 -1
- package/dist/types/ComponentType.d.ts +26 -0
- package/dist/types/ComponentType.js +83 -0
- package/dist/types/ComponentType.js.map +1 -0
- package/dist/types/DoubleType.d.ts +2 -1
- package/dist/types/DoubleType.js +9 -2
- package/dist/types/DoubleType.js.map +1 -1
- package/dist/types/DynamicType.d.ts +2 -2
- package/dist/types/DynamicType.js +3 -1
- package/dist/types/DynamicType.js.map +1 -1
- package/dist/types/EnumType.d.ts +24 -6
- package/dist/types/EnumType.js +29 -7
- package/dist/types/EnumType.js.map +1 -1
- package/dist/types/FloatType.d.ts +2 -1
- package/dist/types/FloatType.js +9 -2
- package/dist/types/FloatType.js.map +1 -1
- package/dist/types/FunctionType.d.ts +8 -20
- package/dist/types/FunctionType.js +17 -45
- package/dist/types/FunctionType.js.map +1 -1
- package/dist/types/InheritableType.d.ts +7 -4
- package/dist/types/InheritableType.js +67 -3
- package/dist/types/InheritableType.js.map +1 -1
- package/dist/types/IntegerType.d.ts +2 -1
- package/dist/types/IntegerType.js +9 -2
- package/dist/types/IntegerType.js.map +1 -1
- package/dist/types/InterfaceType.d.ts +6 -4
- package/dist/types/InterfaceType.js +8 -11
- package/dist/types/InterfaceType.js.map +1 -1
- package/dist/types/InterfaceType.spec.js +30 -2
- package/dist/types/InterfaceType.spec.js.map +1 -1
- package/dist/types/InvalidType.d.ts +2 -1
- package/dist/types/InvalidType.js +7 -1
- package/dist/types/InvalidType.js.map +1 -1
- package/dist/types/LongIntegerType.d.ts +2 -1
- package/dist/types/LongIntegerType.js +9 -2
- package/dist/types/LongIntegerType.js.map +1 -1
- package/dist/types/NamespaceType.d.ts +2 -1
- package/dist/types/NamespaceType.js +3 -0
- package/dist/types/NamespaceType.js.map +1 -1
- package/dist/types/ObjectType.d.ts +2 -2
- package/dist/types/ObjectType.js +5 -10
- package/dist/types/ObjectType.js.map +1 -1
- package/dist/types/ReferenceType.d.ts +15 -3
- package/dist/types/ReferenceType.js +173 -24
- package/dist/types/ReferenceType.js.map +1 -1
- package/dist/types/ReferenceType.spec.js +21 -6
- package/dist/types/ReferenceType.spec.js.map +1 -1
- package/dist/types/StringType.d.ts +2 -1
- package/dist/types/StringType.js +9 -2
- package/dist/types/StringType.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 +2 -1
- package/dist/types/UninitializedType.js +1 -1
- package/dist/types/UninitializedType.js.map +1 -1
- package/dist/types/UnionType.d.ts +4 -2
- package/dist/types/UnionType.js +36 -4
- package/dist/types/UnionType.js.map +1 -1
- package/dist/types/UnionType.spec.js +46 -19
- package/dist/types/UnionType.spec.js.map +1 -1
- package/dist/types/VoidType.d.ts +2 -1
- package/dist/types/VoidType.js +7 -2
- package/dist/types/VoidType.js.map +1 -1
- package/dist/types/helper.spec.js +15 -0
- package/dist/types/helper.spec.js.map +1 -1
- package/dist/types/helpers.d.ts +5 -0
- package/dist/types/helpers.js +50 -3
- package/dist/types/helpers.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/util.d.ts +71 -15
- package/dist/util.js +578 -150
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.d.ts +0 -1
- package/dist/validators/ClassValidator.js +0 -22
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +3 -2
- package/dist/astUtils/AstEditor.js.map +0 -1
- package/dist/astUtils/AstEditor.spec.js.map +0 -1
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +0 -1
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js +0 -31
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js.map +0 -1
- package/dist/types/FunctionType.spec.js +0 -23
- package/dist/types/FunctionType.spec.js.map +0 -1
- /package/dist/astUtils/{AstEditor.spec.d.ts → Editor.spec.d.ts} +0 -0
- /package/dist/bscPlugin/{transpile/BrsFilePreTranspileProcessor.spec.d.ts → completions/CompletionsProcessor.spec.d.ts} +0 -0
- /package/dist/{types/FunctionType.spec.d.ts → bscPlugin/serialize/BslibInjector.spec.d.ts} +0 -0
|
@@ -6,7 +6,7 @@ const vscode_languageserver_1 = require("vscode-languageserver");
|
|
|
6
6
|
const Program_1 = require("../Program");
|
|
7
7
|
const BooleanType_1 = require("../types/BooleanType");
|
|
8
8
|
const DynamicType_1 = require("../types/DynamicType");
|
|
9
|
-
const
|
|
9
|
+
const TypedFunctionType_1 = require("../types/TypedFunctionType");
|
|
10
10
|
const IntegerType_1 = require("../types/IntegerType");
|
|
11
11
|
const StringType_1 = require("../types/StringType");
|
|
12
12
|
const BrsFile_1 = require("./BrsFile");
|
|
@@ -15,16 +15,16 @@ const Lexer_1 = require("../lexer/Lexer");
|
|
|
15
15
|
const TokenKind_1 = require("../lexer/TokenKind");
|
|
16
16
|
const DiagnosticMessages_1 = require("../DiagnosticMessages");
|
|
17
17
|
const util_1 = require("../util");
|
|
18
|
-
const PluginInterface_1 = require("../PluginInterface");
|
|
19
18
|
const testHelpers_spec_1 = require("../testHelpers.spec");
|
|
20
19
|
const Parser_1 = require("../parser/Parser");
|
|
21
|
-
const Logger_1 = require("../Logger");
|
|
22
20
|
const Statement_1 = require("../parser/Statement");
|
|
23
21
|
const creators_1 = require("../astUtils/creators");
|
|
24
22
|
const fsExtra = require("fs-extra");
|
|
25
23
|
const vscode_uri_1 = require("vscode-uri");
|
|
26
24
|
const undent_1 = require("undent");
|
|
27
25
|
const testHelpers_spec_2 = require("../testHelpers.spec");
|
|
26
|
+
const SymbolTable_1 = require("../SymbolTable");
|
|
27
|
+
const types_1 = require("../types");
|
|
28
28
|
let sinon = sinonImport.createSandbox();
|
|
29
29
|
describe('BrsFile', () => {
|
|
30
30
|
let program;
|
|
@@ -36,12 +36,41 @@ describe('BrsFile', () => {
|
|
|
36
36
|
beforeEach(() => {
|
|
37
37
|
fsExtra.emptyDirSync(testHelpers_spec_2.tempDir);
|
|
38
38
|
program = new Program_1.Program({ rootDir: testHelpers_spec_2.rootDir, sourceMap: true });
|
|
39
|
-
file = new BrsFile_1.BrsFile(
|
|
39
|
+
file = new BrsFile_1.BrsFile({
|
|
40
|
+
srcPath: srcPath,
|
|
41
|
+
destPath: destPath,
|
|
42
|
+
program: program
|
|
43
|
+
});
|
|
40
44
|
});
|
|
41
45
|
afterEach(() => {
|
|
42
46
|
sinon.restore();
|
|
43
47
|
program.dispose();
|
|
44
48
|
});
|
|
49
|
+
describe('constructor', () => {
|
|
50
|
+
it('calculates correct paths when no pkgPath specified', () => {
|
|
51
|
+
(0, chai_config_spec_1.expect)(new BrsFile_1.BrsFile({
|
|
52
|
+
srcPath: (0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/source/main.bs`,
|
|
53
|
+
destPath: (0, util_1.standardizePath) `source/main.bs`,
|
|
54
|
+
program: program
|
|
55
|
+
})).to.include({
|
|
56
|
+
srcPath: (0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/source/main.bs`,
|
|
57
|
+
destPath: (0, util_1.standardizePath) `source/main.bs`,
|
|
58
|
+
pkgPath: (0, util_1.standardizePath) `source/main.brs`
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
it('uses supplied pkgPath', () => {
|
|
62
|
+
(0, chai_config_spec_1.expect)(new BrsFile_1.BrsFile({
|
|
63
|
+
srcPath: (0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/source/main.bs`,
|
|
64
|
+
destPath: (0, util_1.standardizePath) `source/main.bs`,
|
|
65
|
+
pkgPath: (0, util_1.standardizePath) `source/main.transpiled.brs`,
|
|
66
|
+
program: program
|
|
67
|
+
})).to.include({
|
|
68
|
+
srcPath: (0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/source/main.bs`,
|
|
69
|
+
destPath: (0, util_1.standardizePath) `source/main.bs`,
|
|
70
|
+
pkgPath: (0, util_1.standardizePath) `source/main.transpiled.brs`
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
});
|
|
45
74
|
describe('allowBrighterScriptInBrightScript', () => {
|
|
46
75
|
it('is false by default', () => {
|
|
47
76
|
program.setFile('source/main.brs', `
|
|
@@ -82,6 +111,22 @@ describe('BrsFile', () => {
|
|
|
82
111
|
program.validate();
|
|
83
112
|
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.itemCannotBeUsedAsVariable('namespace')), { range: util_1.default.createRange(3, 22, 3, 27) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.itemCannotBeUsedAsVariable('namespace')), { range: util_1.default.createRange(4, 22, 4, 32) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.itemCannotBeUsedAsVariable('namespace')), { range: util_1.default.createRange(5, 22, 5, 40) })]);
|
|
84
113
|
});
|
|
114
|
+
it('allows namespaces with the name `optional`', () => {
|
|
115
|
+
program.setFile('source/main.bs', `
|
|
116
|
+
namespace optional
|
|
117
|
+
namespace optional
|
|
118
|
+
end namespace
|
|
119
|
+
end namespace
|
|
120
|
+
namespace alpha
|
|
121
|
+
namespace optional
|
|
122
|
+
end namespace
|
|
123
|
+
end namespace
|
|
124
|
+
namespace alpha.beta.optional
|
|
125
|
+
end namespace
|
|
126
|
+
`);
|
|
127
|
+
program.validate();
|
|
128
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
129
|
+
});
|
|
85
130
|
it('flags enums used as variables', () => {
|
|
86
131
|
program.setFile('source/main.bs', `
|
|
87
132
|
enum Foo
|
|
@@ -125,9 +170,17 @@ describe('BrsFile', () => {
|
|
|
125
170
|
});
|
|
126
171
|
it('sets needsTranspiled to true for .bs files', () => {
|
|
127
172
|
//BrightScript
|
|
128
|
-
(0, chai_config_spec_1.expect)(new BrsFile_1.BrsFile(
|
|
173
|
+
(0, chai_config_spec_1.expect)(new BrsFile_1.BrsFile({
|
|
174
|
+
srcPath: `${testHelpers_spec_2.rootDir}/source/main.brs`,
|
|
175
|
+
destPath: 'source/main.brs',
|
|
176
|
+
program: program
|
|
177
|
+
})['needsTranspiled']).to.be.false;
|
|
129
178
|
//BrighterScript
|
|
130
|
-
(0, chai_config_spec_1.expect)(new BrsFile_1.BrsFile(
|
|
179
|
+
(0, chai_config_spec_1.expect)(new BrsFile_1.BrsFile({
|
|
180
|
+
srcPath: `${testHelpers_spec_2.rootDir}/source/main.bs`,
|
|
181
|
+
destPath: 'source/main.bs',
|
|
182
|
+
program: program
|
|
183
|
+
})['needsTranspiled']).to.be.true;
|
|
131
184
|
});
|
|
132
185
|
it('computes new import statements after clearing parser references', () => {
|
|
133
186
|
const file = program.setFile('source/main.bs', ``);
|
|
@@ -146,21 +199,6 @@ describe('BrsFile', () => {
|
|
|
146
199
|
file.addDiagnostics(expected);
|
|
147
200
|
(0, testHelpers_spec_1.expectDiagnostics)(file, expected);
|
|
148
201
|
});
|
|
149
|
-
describe('getPartialVariableName', () => {
|
|
150
|
-
let entry = {
|
|
151
|
-
src: `${testHelpers_spec_2.rootDir}/source/lib.brs`,
|
|
152
|
-
dest: `source/lib.brs`
|
|
153
|
-
};
|
|
154
|
-
it('creates proper tokens', () => {
|
|
155
|
-
file = program.setFile(entry, `call(ModuleA.ModuleB.ModuleC.`);
|
|
156
|
-
(0, chai_config_spec_1.expect)(file['getPartialVariableName'](file.parser.tokens[7])).to.equal('ModuleA.ModuleB.ModuleC.');
|
|
157
|
-
(0, chai_config_spec_1.expect)(file['getPartialVariableName'](file.parser.tokens[6])).to.equal('ModuleA.ModuleB.ModuleC');
|
|
158
|
-
(0, chai_config_spec_1.expect)(file['getPartialVariableName'](file.parser.tokens[5])).to.equal('ModuleA.ModuleB.');
|
|
159
|
-
(0, chai_config_spec_1.expect)(file['getPartialVariableName'](file.parser.tokens[4])).to.equal('ModuleA.ModuleB');
|
|
160
|
-
(0, chai_config_spec_1.expect)(file['getPartialVariableName'](file.parser.tokens[3])).to.equal('ModuleA.');
|
|
161
|
-
(0, chai_config_spec_1.expect)(file['getPartialVariableName'](file.parser.tokens[2])).to.equal('ModuleA');
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
202
|
describe('getScopesForFile', () => {
|
|
165
203
|
it('finds the scope for the file', () => {
|
|
166
204
|
var _a;
|
|
@@ -168,238 +206,6 @@ describe('BrsFile', () => {
|
|
|
168
206
|
(0, chai_config_spec_1.expect)((_a = program.getScopesForFile(file)[0]) === null || _a === void 0 ? void 0 : _a.name).to.equal('source');
|
|
169
207
|
});
|
|
170
208
|
});
|
|
171
|
-
describe('getCompletions', () => {
|
|
172
|
-
it('does not crash for callfunc on a function call', () => {
|
|
173
|
-
const file = program.setFile('source/main.brs', `
|
|
174
|
-
sub main()
|
|
175
|
-
getManager()@.
|
|
176
|
-
end sub
|
|
177
|
-
`);
|
|
178
|
-
(0, chai_config_spec_1.expect)(() => {
|
|
179
|
-
program.getCompletions(file.srcPath, util_1.default.createPosition(2, 34));
|
|
180
|
-
}).not.to.throw;
|
|
181
|
-
});
|
|
182
|
-
it('suggests pkg paths in strings that match that criteria', () => {
|
|
183
|
-
program.setFile('source/main.brs', `
|
|
184
|
-
sub main()
|
|
185
|
-
print "pkg:"
|
|
186
|
-
end sub
|
|
187
|
-
`);
|
|
188
|
-
const result = program.getCompletions(`${testHelpers_spec_2.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 31));
|
|
189
|
-
const names = result.map(x => x.label);
|
|
190
|
-
(0, chai_config_spec_1.expect)(names.sort()).to.eql([
|
|
191
|
-
'pkg:/source/main.brs'
|
|
192
|
-
]);
|
|
193
|
-
});
|
|
194
|
-
it('suggests libpkg paths in strings that match that criteria', () => {
|
|
195
|
-
program.setFile('source/main.brs', `
|
|
196
|
-
sub main()
|
|
197
|
-
print "libpkg:"
|
|
198
|
-
end sub
|
|
199
|
-
`);
|
|
200
|
-
const result = program.getCompletions(`${testHelpers_spec_2.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 31));
|
|
201
|
-
const names = result.map(x => x.label);
|
|
202
|
-
(0, chai_config_spec_1.expect)(names.sort()).to.eql([
|
|
203
|
-
'libpkg:/source/main.brs'
|
|
204
|
-
]);
|
|
205
|
-
});
|
|
206
|
-
it('suggests pkg paths in template strings', () => {
|
|
207
|
-
program.setFile('source/main.brs', `
|
|
208
|
-
sub main()
|
|
209
|
-
print \`pkg:\`
|
|
210
|
-
end sub
|
|
211
|
-
`);
|
|
212
|
-
const result = program.getCompletions(`${testHelpers_spec_2.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 31));
|
|
213
|
-
const names = result.map(x => x.label);
|
|
214
|
-
(0, chai_config_spec_1.expect)(names.sort()).to.eql([
|
|
215
|
-
'pkg:/source/main.brs'
|
|
216
|
-
]);
|
|
217
|
-
});
|
|
218
|
-
it('waits for the file to be processed before collecting completions', () => {
|
|
219
|
-
//eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
220
|
-
program.setFile('source/main.brs', `
|
|
221
|
-
sub Main()
|
|
222
|
-
print "hello"
|
|
223
|
-
Say
|
|
224
|
-
end sub
|
|
225
|
-
|
|
226
|
-
sub SayHello()
|
|
227
|
-
end sub
|
|
228
|
-
`);
|
|
229
|
-
let result = program.getCompletions(`${testHelpers_spec_2.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(3, 23));
|
|
230
|
-
let names = result.map(x => x.label);
|
|
231
|
-
(0, chai_config_spec_1.expect)(names).to.includes('Main');
|
|
232
|
-
(0, chai_config_spec_1.expect)(names).to.includes('SayHello');
|
|
233
|
-
});
|
|
234
|
-
it('includes every type of item at base level', () => {
|
|
235
|
-
program.setFile('source/main.bs', `
|
|
236
|
-
sub main()
|
|
237
|
-
print
|
|
238
|
-
end sub
|
|
239
|
-
sub speak()
|
|
240
|
-
end sub
|
|
241
|
-
namespace stuff
|
|
242
|
-
end namespace
|
|
243
|
-
class Person
|
|
244
|
-
end class
|
|
245
|
-
enum Direction
|
|
246
|
-
end enum
|
|
247
|
-
`);
|
|
248
|
-
(0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(2, 26)), [{
|
|
249
|
-
label: 'main',
|
|
250
|
-
kind: vscode_languageserver_1.CompletionItemKind.Function
|
|
251
|
-
}, {
|
|
252
|
-
label: 'speak',
|
|
253
|
-
kind: vscode_languageserver_1.CompletionItemKind.Function
|
|
254
|
-
}, {
|
|
255
|
-
label: 'stuff',
|
|
256
|
-
kind: vscode_languageserver_1.CompletionItemKind.Module
|
|
257
|
-
}, {
|
|
258
|
-
label: 'Person',
|
|
259
|
-
kind: vscode_languageserver_1.CompletionItemKind.Class
|
|
260
|
-
}, {
|
|
261
|
-
label: 'Direction',
|
|
262
|
-
kind: vscode_languageserver_1.CompletionItemKind.Enum
|
|
263
|
-
}]);
|
|
264
|
-
});
|
|
265
|
-
describe('namespaces', () => {
|
|
266
|
-
it('gets full namespace completions at any point through the leading identifier', () => {
|
|
267
|
-
program.setFile('source/main.bs', `
|
|
268
|
-
sub main()
|
|
269
|
-
foo.bar
|
|
270
|
-
end sub
|
|
271
|
-
|
|
272
|
-
namespace foo.bar
|
|
273
|
-
end namespace
|
|
274
|
-
|
|
275
|
-
class Person
|
|
276
|
-
end class
|
|
277
|
-
`);
|
|
278
|
-
const result = program.getCompletions(`${testHelpers_spec_2.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(2, 24)).map(x => x.label);
|
|
279
|
-
(0, chai_config_spec_1.expect)(result).includes('main');
|
|
280
|
-
(0, chai_config_spec_1.expect)(result).includes('foo');
|
|
281
|
-
(0, chai_config_spec_1.expect)(result).includes('Person');
|
|
282
|
-
});
|
|
283
|
-
it('gets namespace completions', () => {
|
|
284
|
-
program.setFile('source/main.bs', `
|
|
285
|
-
namespace foo.bar
|
|
286
|
-
function sayHello()
|
|
287
|
-
end function
|
|
288
|
-
end namespace
|
|
289
|
-
|
|
290
|
-
sub Main()
|
|
291
|
-
print "hello"
|
|
292
|
-
foo.ba
|
|
293
|
-
foo.bar.
|
|
294
|
-
end sub
|
|
295
|
-
`);
|
|
296
|
-
let result = program.getCompletions(`${testHelpers_spec_2.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(8, 30));
|
|
297
|
-
let names = result.map(x => x.label);
|
|
298
|
-
(0, chai_config_spec_1.expect)(names).to.includes('bar');
|
|
299
|
-
result = program.getCompletions(`${testHelpers_spec_2.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(9, 32));
|
|
300
|
-
names = result.map(x => x.label);
|
|
301
|
-
(0, chai_config_spec_1.expect)(names).to.includes('sayHello');
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
it('always includes `m`', () => {
|
|
305
|
-
//eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
306
|
-
program.setFile('source/main.brs', `
|
|
307
|
-
sub Main()
|
|
308
|
-
|
|
309
|
-
end sub
|
|
310
|
-
`);
|
|
311
|
-
let result = program.getCompletions(`${testHelpers_spec_2.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 23));
|
|
312
|
-
let names = result.map(x => x.label);
|
|
313
|
-
(0, chai_config_spec_1.expect)(names).to.contain('m');
|
|
314
|
-
});
|
|
315
|
-
it('does not fail for missing previousToken', () => {
|
|
316
|
-
//add a single character to the file, and get completions after it
|
|
317
|
-
program.setFile('source/main.brs', `i`);
|
|
318
|
-
(0, chai_config_spec_1.expect)(() => {
|
|
319
|
-
program.getCompletions(`${testHelpers_spec_2.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(0, 1)).map(x => x.label);
|
|
320
|
-
}).not.to.throw;
|
|
321
|
-
});
|
|
322
|
-
it('includes all keywords`', () => {
|
|
323
|
-
//eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
324
|
-
program.setFile('source/main.brs', `
|
|
325
|
-
sub Main()
|
|
326
|
-
|
|
327
|
-
end sub
|
|
328
|
-
`);
|
|
329
|
-
let keywords = Object.keys(TokenKind_1.Keywords).filter(x => !x.includes(' '));
|
|
330
|
-
//inside the function
|
|
331
|
-
let result = program.getCompletions(`${testHelpers_spec_2.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 23));
|
|
332
|
-
let names = result.map(x => x.label);
|
|
333
|
-
for (let keyword of keywords) {
|
|
334
|
-
(0, chai_config_spec_1.expect)(names).to.include(keyword);
|
|
335
|
-
}
|
|
336
|
-
//outside the function
|
|
337
|
-
result = program.getCompletions(`${testHelpers_spec_2.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(4, 8));
|
|
338
|
-
names = result.map(x => x.label);
|
|
339
|
-
for (let keyword of keywords) {
|
|
340
|
-
(0, chai_config_spec_1.expect)(names).to.include(keyword);
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
it('does not provide completions within a comment', () => {
|
|
344
|
-
//eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
345
|
-
program.setFile('source/main.brs', `
|
|
346
|
-
sub Main()
|
|
347
|
-
'some comment
|
|
348
|
-
end sub
|
|
349
|
-
`);
|
|
350
|
-
//inside the function
|
|
351
|
-
let result = program.getCompletions(`${testHelpers_spec_2.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 33));
|
|
352
|
-
(0, chai_config_spec_1.expect)(result).to.be.lengthOf(0);
|
|
353
|
-
});
|
|
354
|
-
it('does not provide duplicate entries for variables', () => {
|
|
355
|
-
//eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
356
|
-
program.setFile('source/main.brs', `
|
|
357
|
-
sub Main()
|
|
358
|
-
name = "bob"
|
|
359
|
-
age = 12
|
|
360
|
-
name = "john"
|
|
361
|
-
end sub
|
|
362
|
-
`);
|
|
363
|
-
let result = program.getCompletions(`${testHelpers_spec_2.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(3, 23));
|
|
364
|
-
let count = result.reduce((total, x) => {
|
|
365
|
-
return x.label === 'name' ? total + 1 : total;
|
|
366
|
-
}, 0);
|
|
367
|
-
(0, chai_config_spec_1.expect)(count).to.equal(1);
|
|
368
|
-
});
|
|
369
|
-
it('does not include `as` and `string` text options when used in function params', () => {
|
|
370
|
-
//eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
371
|
-
program.setFile('source/main.brs', `
|
|
372
|
-
sub Main(name as string)
|
|
373
|
-
|
|
374
|
-
end sub
|
|
375
|
-
`);
|
|
376
|
-
let result = program.getCompletions(`${testHelpers_spec_2.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 23));
|
|
377
|
-
(0, chai_config_spec_1.expect)(result.filter(x => x.kind === vscode_languageserver_1.CompletionItemKind.Text)).not.to.contain('as');
|
|
378
|
-
(0, chai_config_spec_1.expect)(result.filter(x => x.kind === vscode_languageserver_1.CompletionItemKind.Text)).not.to.contain('string');
|
|
379
|
-
});
|
|
380
|
-
it('does not provide intellisense results when inside a comment', () => {
|
|
381
|
-
//eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
382
|
-
program.setFile('source/main.brs', `
|
|
383
|
-
sub Main(name as string)
|
|
384
|
-
'this is a comment
|
|
385
|
-
end sub
|
|
386
|
-
`);
|
|
387
|
-
let results = program.getCompletions(`${testHelpers_spec_2.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 30));
|
|
388
|
-
(0, chai_config_spec_1.expect)(results).to.be.empty;
|
|
389
|
-
});
|
|
390
|
-
it('does provide intellisence for labels only after a goto keyword', () => {
|
|
391
|
-
var _a;
|
|
392
|
-
//eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
393
|
-
program.setFile('source/main.brs', `
|
|
394
|
-
sub Main(name as string)
|
|
395
|
-
something:
|
|
396
|
-
goto \nend sub
|
|
397
|
-
`);
|
|
398
|
-
let results = program.getCompletions(`${testHelpers_spec_2.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(3, 25));
|
|
399
|
-
(0, chai_config_spec_1.expect)(results.length).to.equal(1);
|
|
400
|
-
(0, chai_config_spec_1.expect)((_a = results[0]) === null || _a === void 0 ? void 0 : _a.label).to.equal('something');
|
|
401
|
-
});
|
|
402
|
-
});
|
|
403
209
|
describe('comment flags', () => {
|
|
404
210
|
describe('bs:disable-next-line', () => {
|
|
405
211
|
it('disables critical diagnostic issues', () => {
|
|
@@ -482,12 +288,12 @@ describe('BrsFile', () => {
|
|
|
482
288
|
something = true 'bs:disable-line: LINT1005
|
|
483
289
|
end sub
|
|
484
290
|
`);
|
|
485
|
-
file.
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
291
|
+
file.diagnostics.push({
|
|
292
|
+
code: 'LINT1005',
|
|
293
|
+
file: file,
|
|
294
|
+
message: 'Something is not right',
|
|
295
|
+
range: util_1.default.createRange(2, 16, 2, 26)
|
|
296
|
+
});
|
|
491
297
|
const scope = program.getScopesForFile(file)[0];
|
|
492
298
|
(0, testHelpers_spec_1.expectZeroDiagnostics)(scope);
|
|
493
299
|
});
|
|
@@ -995,6 +801,7 @@ describe('BrsFile', () => {
|
|
|
995
801
|
file.parse(`
|
|
996
802
|
sub Main()
|
|
997
803
|
doWork = function(callback as function)
|
|
804
|
+
callback()
|
|
998
805
|
end function
|
|
999
806
|
end sub
|
|
1000
807
|
`);
|
|
@@ -1171,7 +978,11 @@ describe('BrsFile', () => {
|
|
|
1171
978
|
`);
|
|
1172
979
|
});
|
|
1173
980
|
it('finds line and column numbers for functions', () => {
|
|
1174
|
-
let file = new BrsFile_1.BrsFile(
|
|
981
|
+
let file = new BrsFile_1.BrsFile({
|
|
982
|
+
srcPath: 'absolute_path/file.brs',
|
|
983
|
+
destPath: 'relative_path/file.brs',
|
|
984
|
+
program: program
|
|
985
|
+
});
|
|
1175
986
|
file.parse(`
|
|
1176
987
|
function DoA()
|
|
1177
988
|
print "A"
|
|
@@ -1187,7 +998,11 @@ describe('BrsFile', () => {
|
|
|
1187
998
|
(0, chai_config_spec_1.expect)(file.callables[1].nameRange).to.eql(vscode_languageserver_1.Range.create(5, 26, 5, 29));
|
|
1188
999
|
});
|
|
1189
1000
|
it('throws an error if the file has already been parsed', () => {
|
|
1190
|
-
let file = new BrsFile_1.BrsFile(
|
|
1001
|
+
let file = new BrsFile_1.BrsFile({
|
|
1002
|
+
srcPath: 'abspath',
|
|
1003
|
+
destPath: 'relpath',
|
|
1004
|
+
program: program
|
|
1005
|
+
});
|
|
1191
1006
|
file.parse(`'a comment`);
|
|
1192
1007
|
try {
|
|
1193
1008
|
file.parse(`'a new comment`);
|
|
@@ -1198,7 +1013,11 @@ describe('BrsFile', () => {
|
|
|
1198
1013
|
}
|
|
1199
1014
|
});
|
|
1200
1015
|
it('finds and registers duplicate callables', () => {
|
|
1201
|
-
let file = new BrsFile_1.BrsFile(
|
|
1016
|
+
let file = new BrsFile_1.BrsFile({
|
|
1017
|
+
srcPath: 'absolute_path/file.brs',
|
|
1018
|
+
destPath: 'relative_path/file.brs',
|
|
1019
|
+
program: program
|
|
1020
|
+
});
|
|
1202
1021
|
file.parse(`
|
|
1203
1022
|
function DoA()
|
|
1204
1023
|
print "A"
|
|
@@ -1215,7 +1034,11 @@ describe('BrsFile', () => {
|
|
|
1215
1034
|
(0, chai_config_spec_1.expect)(file.callables[1].nameRange.start.line).to.equal(5);
|
|
1216
1035
|
});
|
|
1217
1036
|
it('finds function call line and column numbers', () => {
|
|
1218
|
-
let file = new BrsFile_1.BrsFile(
|
|
1037
|
+
let file = new BrsFile_1.BrsFile({
|
|
1038
|
+
srcPath: 'absolute_path/file.brs',
|
|
1039
|
+
destPath: 'relative_path/file.brs',
|
|
1040
|
+
program: program
|
|
1041
|
+
});
|
|
1219
1042
|
file.parse(`
|
|
1220
1043
|
function DoA()
|
|
1221
1044
|
DoB("a")
|
|
@@ -1231,7 +1054,11 @@ describe('BrsFile', () => {
|
|
|
1231
1054
|
(0, chai_config_spec_1.expect)(file.functionCalls[1].nameRange).to.eql(vscode_languageserver_1.Range.create(5, 20, 5, 23));
|
|
1232
1055
|
});
|
|
1233
1056
|
it('finds function calls that are unfinished', () => {
|
|
1234
|
-
let file = new BrsFile_1.BrsFile(
|
|
1057
|
+
let file = new BrsFile_1.BrsFile({
|
|
1058
|
+
srcPath: 'absolute_path/file.brs',
|
|
1059
|
+
destPath: 'relative_path/file.brs',
|
|
1060
|
+
program: program
|
|
1061
|
+
});
|
|
1235
1062
|
file.parse(`
|
|
1236
1063
|
function DoA()
|
|
1237
1064
|
DoB("a"
|
|
@@ -1254,7 +1081,11 @@ describe('BrsFile', () => {
|
|
|
1254
1081
|
(0, chai_config_spec_1.expect)(file.functionCalls[1].nameRange).to.eql(vscode_languageserver_1.Range.create(5, 20, 5, 23));
|
|
1255
1082
|
});
|
|
1256
1083
|
it('sanitizes brs errors', () => {
|
|
1257
|
-
let file = new BrsFile_1.BrsFile(
|
|
1084
|
+
let file = new BrsFile_1.BrsFile({
|
|
1085
|
+
srcPath: 'absolute_path/file.brs',
|
|
1086
|
+
destPath: 'relative_path/file.brs',
|
|
1087
|
+
program: program
|
|
1088
|
+
});
|
|
1258
1089
|
file.parse(`
|
|
1259
1090
|
function DoSomething
|
|
1260
1091
|
end function
|
|
@@ -1264,7 +1095,11 @@ describe('BrsFile', () => {
|
|
|
1264
1095
|
(0, chai_config_spec_1.expect)(file.getDiagnostics()[0].range.start.line).to.equal(1);
|
|
1265
1096
|
});
|
|
1266
1097
|
it('supports using the `next` keyword in a for loop', () => {
|
|
1267
|
-
let file = new BrsFile_1.BrsFile(
|
|
1098
|
+
let file = new BrsFile_1.BrsFile({
|
|
1099
|
+
srcPath: 'absolute_path/file.brs',
|
|
1100
|
+
destPath: 'relative_path/file.brs',
|
|
1101
|
+
program: program
|
|
1102
|
+
});
|
|
1268
1103
|
file.parse(`
|
|
1269
1104
|
sub countit()
|
|
1270
1105
|
for each num in [1,2,3]
|
|
@@ -1276,7 +1111,11 @@ describe('BrsFile', () => {
|
|
|
1276
1111
|
});
|
|
1277
1112
|
//test is not working yet, but will be enabled when brs supports this syntax
|
|
1278
1113
|
it('supports assigning functions to objects', () => {
|
|
1279
|
-
let file = new BrsFile_1.BrsFile(
|
|
1114
|
+
let file = new BrsFile_1.BrsFile({
|
|
1115
|
+
srcPath: 'absolute_path/file.brs',
|
|
1116
|
+
destPath: 'relative_path/file.brs',
|
|
1117
|
+
program: program
|
|
1118
|
+
});
|
|
1280
1119
|
file.parse(`
|
|
1281
1120
|
function main()
|
|
1282
1121
|
o = CreateObject("roAssociativeArray")
|
|
@@ -1304,7 +1143,11 @@ describe('BrsFile', () => {
|
|
|
1304
1143
|
});
|
|
1305
1144
|
describe('findCallables', () => {
|
|
1306
1145
|
it('finds range', () => {
|
|
1307
|
-
let file = new BrsFile_1.BrsFile(
|
|
1146
|
+
let file = new BrsFile_1.BrsFile({
|
|
1147
|
+
srcPath: 'absolute_path/file.brs',
|
|
1148
|
+
destPath: 'relative_path/file.brs',
|
|
1149
|
+
program: program
|
|
1150
|
+
});
|
|
1308
1151
|
file.parse(`
|
|
1309
1152
|
sub Sum()
|
|
1310
1153
|
print "hello world"
|
|
@@ -1314,7 +1157,11 @@ describe('BrsFile', () => {
|
|
|
1314
1157
|
(0, chai_config_spec_1.expect)(callable.range).to.eql(vscode_languageserver_1.Range.create(1, 16, 3, 23));
|
|
1315
1158
|
});
|
|
1316
1159
|
it('finds correct body range even with inner function', () => {
|
|
1317
|
-
let file = new BrsFile_1.BrsFile(
|
|
1160
|
+
let file = new BrsFile_1.BrsFile({
|
|
1161
|
+
srcPath: 'absolute_path/file.brs',
|
|
1162
|
+
destPath: 'relative_path/file.brs',
|
|
1163
|
+
program: program
|
|
1164
|
+
});
|
|
1318
1165
|
file.parse(`
|
|
1319
1166
|
sub Sum()
|
|
1320
1167
|
sayHi = sub()
|
|
@@ -1327,7 +1174,11 @@ describe('BrsFile', () => {
|
|
|
1327
1174
|
(0, chai_config_spec_1.expect)(callable.range).to.eql(vscode_languageserver_1.Range.create(1, 16, 6, 23));
|
|
1328
1175
|
});
|
|
1329
1176
|
it('finds callable parameters', () => {
|
|
1330
|
-
let file = new BrsFile_1.BrsFile(
|
|
1177
|
+
let file = new BrsFile_1.BrsFile({
|
|
1178
|
+
srcPath: 'absolute_path/file.brs',
|
|
1179
|
+
destPath: 'relative_path/file.brs',
|
|
1180
|
+
program: program
|
|
1181
|
+
});
|
|
1331
1182
|
file.parse(`
|
|
1332
1183
|
function Sum(a, b, c)
|
|
1333
1184
|
|
|
@@ -1354,7 +1205,11 @@ describe('BrsFile', () => {
|
|
|
1354
1205
|
(0, chai_config_spec_1.expect)(callable.params[2].type).instanceof(DynamicType_1.DynamicType);
|
|
1355
1206
|
});
|
|
1356
1207
|
it('finds optional parameters', () => {
|
|
1357
|
-
let file = new BrsFile_1.BrsFile(
|
|
1208
|
+
let file = new BrsFile_1.BrsFile({
|
|
1209
|
+
srcPath: 'absolute_path/file.brs',
|
|
1210
|
+
destPath: 'relative_path/file.brs',
|
|
1211
|
+
program: program
|
|
1212
|
+
});
|
|
1358
1213
|
file.parse(`
|
|
1359
1214
|
function Sum(a=2)
|
|
1360
1215
|
|
|
@@ -1369,7 +1224,11 @@ describe('BrsFile', () => {
|
|
|
1369
1224
|
(0, chai_config_spec_1.expect)(callable.params[0].type).instanceof(IntegerType_1.IntegerType);
|
|
1370
1225
|
});
|
|
1371
1226
|
it('finds parameter types', () => {
|
|
1372
|
-
let file = new BrsFile_1.BrsFile(
|
|
1227
|
+
let file = new BrsFile_1.BrsFile({
|
|
1228
|
+
srcPath: 'absolute_path/file.brs',
|
|
1229
|
+
destPath: 'relative_path/file.brs',
|
|
1230
|
+
program: program
|
|
1231
|
+
});
|
|
1373
1232
|
file.parse(`
|
|
1374
1233
|
function Sum(a, b as integer, c as string)
|
|
1375
1234
|
|
|
@@ -1398,7 +1257,11 @@ describe('BrsFile', () => {
|
|
|
1398
1257
|
});
|
|
1399
1258
|
describe('findCallableInvocations', () => {
|
|
1400
1259
|
it('finds arguments with literal values', () => {
|
|
1401
|
-
let file = new BrsFile_1.BrsFile(
|
|
1260
|
+
let file = new BrsFile_1.BrsFile({
|
|
1261
|
+
srcPath: 'absolute_path/file.brs',
|
|
1262
|
+
destPath: 'relative_path/file.brs',
|
|
1263
|
+
program: program
|
|
1264
|
+
});
|
|
1402
1265
|
file.parse(`
|
|
1403
1266
|
function Sum()
|
|
1404
1267
|
DoSomething("name", 12, true)
|
|
@@ -1437,7 +1300,11 @@ describe('BrsFile', () => {
|
|
|
1437
1300
|
]);
|
|
1438
1301
|
});
|
|
1439
1302
|
it('finds arguments with variable values', () => {
|
|
1440
|
-
let file = new BrsFile_1.BrsFile(
|
|
1303
|
+
let file = new BrsFile_1.BrsFile({
|
|
1304
|
+
srcPath: 'absolute_path/file.brs',
|
|
1305
|
+
destPath: 'relative_path/file.brs',
|
|
1306
|
+
program: program
|
|
1307
|
+
});
|
|
1441
1308
|
file.parse(`
|
|
1442
1309
|
function Sum()
|
|
1443
1310
|
count = 1
|
|
@@ -1464,7 +1331,11 @@ describe('BrsFile', () => {
|
|
|
1464
1331
|
describe('findCallables', () => {
|
|
1465
1332
|
//this test is to help with code coverage
|
|
1466
1333
|
it('skips top-level statements', () => {
|
|
1467
|
-
let file = new BrsFile_1.BrsFile(
|
|
1334
|
+
let file = new BrsFile_1.BrsFile({
|
|
1335
|
+
srcPath: 'absolute',
|
|
1336
|
+
destPath: 'relative',
|
|
1337
|
+
program: program
|
|
1338
|
+
});
|
|
1468
1339
|
file.parse('name = "Bob"');
|
|
1469
1340
|
(0, chai_config_spec_1.expect)(file.callables.length).to.equal(0);
|
|
1470
1341
|
});
|
|
@@ -1536,7 +1407,7 @@ describe('BrsFile', () => {
|
|
|
1536
1407
|
lineIndex: 2,
|
|
1537
1408
|
name: 'sayHi'
|
|
1538
1409
|
});
|
|
1539
|
-
(0, chai_config_spec_1.expect)(file.functionScopes[0].variableDeclarations[0].getType()).instanceof(
|
|
1410
|
+
(0, chai_config_spec_1.expect)(file.functionScopes[0].variableDeclarations[0].getType()).instanceof(TypedFunctionType_1.TypedFunctionType);
|
|
1540
1411
|
(0, chai_config_spec_1.expect)(file.functionScopes[1].variableDeclarations).to.be.length(1);
|
|
1541
1412
|
(0, chai_config_spec_1.expect)(file.functionScopes[1].variableDeclarations[0]).to.deep.include({
|
|
1542
1413
|
lineIndex: 3,
|
|
@@ -1619,7 +1490,7 @@ describe('BrsFile', () => {
|
|
|
1619
1490
|
end if
|
|
1620
1491
|
end sub
|
|
1621
1492
|
`);
|
|
1622
|
-
(0,
|
|
1493
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(mainFile);
|
|
1623
1494
|
mainFile = program.setFile('source/main.brs', `
|
|
1624
1495
|
sub Main()
|
|
1625
1496
|
if true Then
|
|
@@ -1627,7 +1498,7 @@ describe('BrsFile', () => {
|
|
|
1627
1498
|
end if
|
|
1628
1499
|
end sub
|
|
1629
1500
|
`);
|
|
1630
|
-
(0,
|
|
1501
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(mainFile);
|
|
1631
1502
|
mainFile = program.setFile('source/main.brs', `
|
|
1632
1503
|
sub Main()
|
|
1633
1504
|
if true THEN
|
|
@@ -1635,272 +1506,7 @@ describe('BrsFile', () => {
|
|
|
1635
1506
|
end if
|
|
1636
1507
|
end sub
|
|
1637
1508
|
`);
|
|
1638
|
-
(0,
|
|
1639
|
-
});
|
|
1640
|
-
describe('getHover', () => {
|
|
1641
|
-
it('works for param types', () => {
|
|
1642
|
-
let file = program.setFile('source/main.brs', `
|
|
1643
|
-
sub DoSomething(name as string)
|
|
1644
|
-
name = 1
|
|
1645
|
-
sayMyName = function(name as string)
|
|
1646
|
-
end function
|
|
1647
|
-
end sub
|
|
1648
|
-
`);
|
|
1649
|
-
//hover over the `name = 1` line
|
|
1650
|
-
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(2, 24))[0];
|
|
1651
|
-
(0, chai_config_spec_1.expect)(hover).to.exist;
|
|
1652
|
-
(0, chai_config_spec_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(2, 20, 2, 24));
|
|
1653
|
-
//hover over the `name` parameter declaration
|
|
1654
|
-
hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(1, 34))[0];
|
|
1655
|
-
(0, chai_config_spec_1.expect)(hover).to.exist;
|
|
1656
|
-
(0, chai_config_spec_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(1, 32, 1, 36));
|
|
1657
|
-
});
|
|
1658
|
-
//ignore this for now...it's not a huge deal
|
|
1659
|
-
it('does not match on keywords or data types', () => {
|
|
1660
|
-
let file = program.setFile('source/main.brs', `
|
|
1661
|
-
sub Main(name as string)
|
|
1662
|
-
end sub
|
|
1663
|
-
sub as()
|
|
1664
|
-
end sub
|
|
1665
|
-
`);
|
|
1666
|
-
//hover over the `as`
|
|
1667
|
-
(0, chai_config_spec_1.expect)(program.getHover(file.srcPath, vscode_languageserver_1.Position.create(1, 31))).to.be.empty;
|
|
1668
|
-
//hover over the `string`
|
|
1669
|
-
(0, chai_config_spec_1.expect)(program.getHover(file.srcPath, vscode_languageserver_1.Position.create(1, 36))).to.be.empty;
|
|
1670
|
-
});
|
|
1671
|
-
it('finds declared function', () => {
|
|
1672
|
-
let file = program.setFile('source/main.brs', `
|
|
1673
|
-
function Main(count = 1)
|
|
1674
|
-
firstName = "bob"
|
|
1675
|
-
age = 21
|
|
1676
|
-
shoeSize = 10
|
|
1677
|
-
end function
|
|
1678
|
-
`);
|
|
1679
|
-
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(1, 28))[0];
|
|
1680
|
-
(0, chai_config_spec_1.expect)(hover).to.exist;
|
|
1681
|
-
(0, chai_config_spec_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(1, 25, 1, 29));
|
|
1682
|
-
(0, chai_config_spec_1.expect)(hover.contents).to.equal([
|
|
1683
|
-
'```brightscript',
|
|
1684
|
-
'function Main(count? as integer) as dynamic',
|
|
1685
|
-
'```'
|
|
1686
|
-
].join('\n'));
|
|
1687
|
-
});
|
|
1688
|
-
it('finds declared namespace function', () => {
|
|
1689
|
-
let file = program.setFile('source/main.brs', `
|
|
1690
|
-
namespace mySpace
|
|
1691
|
-
function Main(count = 1)
|
|
1692
|
-
firstName = "bob"
|
|
1693
|
-
age = 21
|
|
1694
|
-
shoeSize = 10
|
|
1695
|
-
end function
|
|
1696
|
-
end namespace
|
|
1697
|
-
`);
|
|
1698
|
-
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(2, 28))[0];
|
|
1699
|
-
(0, chai_config_spec_1.expect)(hover).to.exist;
|
|
1700
|
-
(0, chai_config_spec_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(2, 25, 2, 29));
|
|
1701
|
-
(0, chai_config_spec_1.expect)(hover.contents).to.equal([
|
|
1702
|
-
'```brightscript',
|
|
1703
|
-
'function Main(count? as integer) as dynamic',
|
|
1704
|
-
'```'
|
|
1705
|
-
].join('\n'));
|
|
1706
|
-
});
|
|
1707
|
-
it('finds variable function hover in same scope', () => {
|
|
1708
|
-
let file = program.setFile('source/main.brs', `
|
|
1709
|
-
sub Main()
|
|
1710
|
-
sayMyName = sub(name as string)
|
|
1711
|
-
end sub
|
|
1712
|
-
|
|
1713
|
-
sayMyName()
|
|
1714
|
-
end sub
|
|
1715
|
-
`);
|
|
1716
|
-
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(5, 24))[0];
|
|
1717
|
-
(0, chai_config_spec_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(5, 20, 5, 29));
|
|
1718
|
-
(0, chai_config_spec_1.expect)(hover.contents).to.equal([
|
|
1719
|
-
'```brightscript',
|
|
1720
|
-
'sub sayMyName(name as string) as void',
|
|
1721
|
-
'```'
|
|
1722
|
-
].join('\n'));
|
|
1723
|
-
});
|
|
1724
|
-
it('does not crash when hovering on built-in functions', () => {
|
|
1725
|
-
let file = program.setFile('source/main.brs', `
|
|
1726
|
-
function doUcase(text)
|
|
1727
|
-
return ucase(text)
|
|
1728
|
-
end function
|
|
1729
|
-
`);
|
|
1730
|
-
(0, chai_config_spec_1.expect)(program.getHover(file.srcPath, vscode_languageserver_1.Position.create(2, 30))[0].contents).to.equal([
|
|
1731
|
-
'```brightscript',
|
|
1732
|
-
'function UCase(s as string) as string',
|
|
1733
|
-
'```'
|
|
1734
|
-
].join('\n'));
|
|
1735
|
-
});
|
|
1736
|
-
it('does not crash when hovering on object method call', () => {
|
|
1737
|
-
let file = program.setFile('source/main.brs', `
|
|
1738
|
-
function getInstr(url, text)
|
|
1739
|
-
return url.instr(text)
|
|
1740
|
-
end function
|
|
1741
|
-
`);
|
|
1742
|
-
(0, chai_config_spec_1.expect)(program.getHover(file.srcPath, vscode_languageserver_1.Position.create(2, 35))[0].contents).to.equal([
|
|
1743
|
-
'```brightscript',
|
|
1744
|
-
//TODO this really shouldn't be returning the global function, but it does...so make sure it doesn't crash right now.
|
|
1745
|
-
'function Instr(start as integer, text as string, substring as string) as integer',
|
|
1746
|
-
'```'
|
|
1747
|
-
].join('\n'));
|
|
1748
|
-
});
|
|
1749
|
-
it('finds function hover in file scope', () => {
|
|
1750
|
-
let file = program.setFile('source/main.brs', `
|
|
1751
|
-
sub Main()
|
|
1752
|
-
sayMyName()
|
|
1753
|
-
end sub
|
|
1754
|
-
|
|
1755
|
-
sub sayMyName()
|
|
1756
|
-
|
|
1757
|
-
end sub
|
|
1758
|
-
`);
|
|
1759
|
-
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(2, 25))[0];
|
|
1760
|
-
(0, chai_config_spec_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(2, 20, 2, 29));
|
|
1761
|
-
(0, chai_config_spec_1.expect)(hover.contents).to.equal([
|
|
1762
|
-
'```brightscript',
|
|
1763
|
-
'sub sayMyName() as void',
|
|
1764
|
-
'```'
|
|
1765
|
-
].join('\n'));
|
|
1766
|
-
});
|
|
1767
|
-
it('finds namespace function hover in file scope', () => {
|
|
1768
|
-
let file = program.setFile('source/main.brs', `
|
|
1769
|
-
namespace mySpace
|
|
1770
|
-
sub Main()
|
|
1771
|
-
sayMyName()
|
|
1772
|
-
end sub
|
|
1773
|
-
|
|
1774
|
-
sub sayMyName()
|
|
1775
|
-
|
|
1776
|
-
end sub
|
|
1777
|
-
end namespace
|
|
1778
|
-
`);
|
|
1779
|
-
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(3, 25))[0];
|
|
1780
|
-
(0, chai_config_spec_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(3, 20, 3, 29));
|
|
1781
|
-
(0, chai_config_spec_1.expect)(hover.contents).to.equal([
|
|
1782
|
-
'```brightscript',
|
|
1783
|
-
'sub sayMyName() as void',
|
|
1784
|
-
'```'
|
|
1785
|
-
].join('\n'));
|
|
1786
|
-
});
|
|
1787
|
-
it('finds function hover in scope', () => {
|
|
1788
|
-
let rootDir = process.cwd();
|
|
1789
|
-
program = new Program_1.Program({
|
|
1790
|
-
rootDir: rootDir
|
|
1791
|
-
});
|
|
1792
|
-
let mainFile = program.setFile('source/main.brs', `
|
|
1793
|
-
sub Main()
|
|
1794
|
-
sayMyName()
|
|
1795
|
-
end sub
|
|
1796
|
-
`);
|
|
1797
|
-
program.setFile('source/lib.brs', `
|
|
1798
|
-
sub sayMyName(name as string)
|
|
1799
|
-
|
|
1800
|
-
end sub
|
|
1801
|
-
`);
|
|
1802
|
-
let hover = program.getHover(mainFile.srcPath, vscode_languageserver_1.Position.create(2, 25))[0];
|
|
1803
|
-
(0, chai_config_spec_1.expect)(hover).to.exist;
|
|
1804
|
-
(0, chai_config_spec_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(2, 20, 2, 29));
|
|
1805
|
-
(0, chai_config_spec_1.expect)(hover.contents).to.equal([
|
|
1806
|
-
'```brightscript',
|
|
1807
|
-
'sub sayMyName(name as string) as void',
|
|
1808
|
-
'```'
|
|
1809
|
-
].join('\n'));
|
|
1810
|
-
});
|
|
1811
|
-
it('finds namespace function hover in scope', () => {
|
|
1812
|
-
let rootDir = process.cwd();
|
|
1813
|
-
program = new Program_1.Program({
|
|
1814
|
-
rootDir: rootDir
|
|
1815
|
-
});
|
|
1816
|
-
let mainFile = program.setFile('source/main.brs', `
|
|
1817
|
-
sub Main()
|
|
1818
|
-
mySpace.sayMyName()
|
|
1819
|
-
end sub
|
|
1820
|
-
`);
|
|
1821
|
-
program.setFile('source/lib.brs', `
|
|
1822
|
-
namespace mySpace
|
|
1823
|
-
sub sayMyName(name as string)
|
|
1824
|
-
end sub
|
|
1825
|
-
end namespace
|
|
1826
|
-
`);
|
|
1827
|
-
let hover = program.getHover(mainFile.srcPath, vscode_languageserver_1.Position.create(2, 34))[0];
|
|
1828
|
-
(0, chai_config_spec_1.expect)(hover).to.exist;
|
|
1829
|
-
(0, chai_config_spec_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(2, 28, 2, 37));
|
|
1830
|
-
(0, chai_config_spec_1.expect)(hover.contents).to.equal([
|
|
1831
|
-
'```brightscript',
|
|
1832
|
-
'sub sayMyName(name as string) as void',
|
|
1833
|
-
'```'
|
|
1834
|
-
].join('\n'));
|
|
1835
|
-
});
|
|
1836
|
-
it('includes markdown comments in hover.', () => {
|
|
1837
|
-
let rootDir = process.cwd();
|
|
1838
|
-
program = new Program_1.Program({
|
|
1839
|
-
rootDir: rootDir
|
|
1840
|
-
});
|
|
1841
|
-
const file = program.setFile('source/lib.brs', `
|
|
1842
|
-
'
|
|
1843
|
-
' The main function
|
|
1844
|
-
'
|
|
1845
|
-
sub main()
|
|
1846
|
-
writeToLog("hello")
|
|
1847
|
-
end sub
|
|
1848
|
-
|
|
1849
|
-
'
|
|
1850
|
-
' Prints a message to the log.
|
|
1851
|
-
' Works with *markdown* **content**
|
|
1852
|
-
'
|
|
1853
|
-
sub writeToLog(message as string)
|
|
1854
|
-
print message
|
|
1855
|
-
end sub
|
|
1856
|
-
`);
|
|
1857
|
-
//hover over log("hello")
|
|
1858
|
-
(0, chai_config_spec_1.expect)(program.getHover(file.srcPath, vscode_languageserver_1.Position.create(5, 22))[0].contents).to.equal([
|
|
1859
|
-
'```brightscript',
|
|
1860
|
-
'sub writeToLog(message as string) as void',
|
|
1861
|
-
'```',
|
|
1862
|
-
'***',
|
|
1863
|
-
'',
|
|
1864
|
-
' Prints a message to the log.',
|
|
1865
|
-
' Works with *markdown* **content**',
|
|
1866
|
-
''
|
|
1867
|
-
].join('\n'));
|
|
1868
|
-
//hover over sub ma|in()
|
|
1869
|
-
(0, chai_config_spec_1.expect)((0, testHelpers_spec_1.trim)(program.getHover(file.srcPath, vscode_languageserver_1.Position.create(4, 22))[0].contents.toString())).to.equal((0, testHelpers_spec_1.trim) `
|
|
1870
|
-
\`\`\`brightscript
|
|
1871
|
-
sub main() as void
|
|
1872
|
-
\`\`\`
|
|
1873
|
-
***
|
|
1874
|
-
|
|
1875
|
-
The main function
|
|
1876
|
-
`);
|
|
1877
|
-
});
|
|
1878
|
-
it('handles mixed case `then` partions of conditionals', () => {
|
|
1879
|
-
let mainFile = program.setFile('source/main.brs', `
|
|
1880
|
-
sub Main()
|
|
1881
|
-
if true then
|
|
1882
|
-
print "works"
|
|
1883
|
-
end if
|
|
1884
|
-
end sub
|
|
1885
|
-
`);
|
|
1886
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(mainFile);
|
|
1887
|
-
mainFile = program.setFile('source/main.brs', `
|
|
1888
|
-
sub Main()
|
|
1889
|
-
if true Then
|
|
1890
|
-
print "works"
|
|
1891
|
-
end if
|
|
1892
|
-
end sub
|
|
1893
|
-
`);
|
|
1894
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(mainFile);
|
|
1895
|
-
mainFile = program.setFile('source/main.brs', `
|
|
1896
|
-
sub Main()
|
|
1897
|
-
if true THEN
|
|
1898
|
-
print "works"
|
|
1899
|
-
end if
|
|
1900
|
-
end sub
|
|
1901
|
-
`);
|
|
1902
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(mainFile);
|
|
1903
|
-
});
|
|
1509
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(mainFile);
|
|
1904
1510
|
});
|
|
1905
1511
|
it('does not throw when encountering incomplete import statement', () => {
|
|
1906
1512
|
program.setFile('source/main.brs', `
|
|
@@ -1912,8 +1518,8 @@ describe('BrsFile', () => {
|
|
|
1912
1518
|
//this test will throw an exception if something went wrong
|
|
1913
1519
|
});
|
|
1914
1520
|
describe('transpile', () => {
|
|
1915
|
-
it('excludes trailing commas in array literals', () => {
|
|
1916
|
-
testTranspile(`
|
|
1521
|
+
it('excludes trailing commas in array literals', async () => {
|
|
1522
|
+
await testTranspile(`
|
|
1917
1523
|
sub main()
|
|
1918
1524
|
arr = [
|
|
1919
1525
|
1,
|
|
@@ -1941,7 +1547,7 @@ describe('BrsFile', () => {
|
|
|
1941
1547
|
end sub
|
|
1942
1548
|
`);
|
|
1943
1549
|
});
|
|
1944
|
-
it('transpiles if statement keywords as provided', () => {
|
|
1550
|
+
it('transpiles if statement keywords as provided', async () => {
|
|
1945
1551
|
const code = `
|
|
1946
1552
|
sub main()
|
|
1947
1553
|
If True Then
|
|
@@ -1955,12 +1561,12 @@ describe('BrsFile', () => {
|
|
|
1955
1561
|
End If
|
|
1956
1562
|
end sub
|
|
1957
1563
|
`;
|
|
1958
|
-
testTranspile(code);
|
|
1959
|
-
testTranspile(code.toLowerCase());
|
|
1960
|
-
testTranspile(code.toUpperCase());
|
|
1564
|
+
await testTranspile(code);
|
|
1565
|
+
await testTranspile(code.toLowerCase());
|
|
1566
|
+
await testTranspile(code.toUpperCase());
|
|
1961
1567
|
});
|
|
1962
|
-
it('does not transpile `then` tokens', () => {
|
|
1963
|
-
testTranspile(`
|
|
1568
|
+
it('does not transpile `then` tokens', async () => {
|
|
1569
|
+
await testTranspile(`
|
|
1964
1570
|
sub main()
|
|
1965
1571
|
if true
|
|
1966
1572
|
print true
|
|
@@ -1970,8 +1576,8 @@ describe('BrsFile', () => {
|
|
|
1970
1576
|
end sub
|
|
1971
1577
|
`);
|
|
1972
1578
|
});
|
|
1973
|
-
it('honors spacing between multi-word tokens', () => {
|
|
1974
|
-
testTranspile(`
|
|
1579
|
+
it('honors spacing between multi-word tokens', async () => {
|
|
1580
|
+
await testTranspile(`
|
|
1975
1581
|
sub main()
|
|
1976
1582
|
if true
|
|
1977
1583
|
print true
|
|
@@ -1981,39 +1587,39 @@ describe('BrsFile', () => {
|
|
|
1981
1587
|
end sub
|
|
1982
1588
|
`);
|
|
1983
1589
|
});
|
|
1984
|
-
it('handles when only some of the statements have `then`', () => {
|
|
1985
|
-
testTranspile(`
|
|
1590
|
+
it('handles when only some of the statements have `then`', async () => {
|
|
1591
|
+
await testTranspile(`
|
|
1986
1592
|
sub main()
|
|
1987
1593
|
if true
|
|
1988
1594
|
else if true then
|
|
1989
1595
|
else if true
|
|
1990
1596
|
else if true then
|
|
1991
1597
|
if true then
|
|
1992
|
-
return
|
|
1598
|
+
return
|
|
1993
1599
|
end if
|
|
1994
1600
|
end if
|
|
1995
1601
|
end sub
|
|
1996
1602
|
`);
|
|
1997
1603
|
});
|
|
1998
|
-
it('retains casing of parameter types', () => {
|
|
1999
|
-
function test(type) {
|
|
2000
|
-
testTranspile(`
|
|
1604
|
+
it('retains casing of parameter types', async () => {
|
|
1605
|
+
async function test(type) {
|
|
1606
|
+
await testTranspile(`
|
|
2001
1607
|
sub one(a as ${type}, b as ${type.toUpperCase()}, c as ${type.toLowerCase()})
|
|
2002
1608
|
end sub
|
|
2003
1609
|
`);
|
|
2004
1610
|
}
|
|
2005
|
-
test('Boolean');
|
|
2006
|
-
test('Double');
|
|
2007
|
-
test('Dynamic');
|
|
2008
|
-
test('Float');
|
|
2009
|
-
test('Integer');
|
|
2010
|
-
test('LongInteger');
|
|
2011
|
-
test('Object');
|
|
2012
|
-
test('String');
|
|
2013
|
-
});
|
|
2014
|
-
it('retains casing of return types', () => {
|
|
2015
|
-
function test(type) {
|
|
2016
|
-
testTranspile(`
|
|
1611
|
+
await test('Boolean');
|
|
1612
|
+
await test('Double');
|
|
1613
|
+
await test('Dynamic');
|
|
1614
|
+
await test('Float');
|
|
1615
|
+
await test('Integer');
|
|
1616
|
+
await test('LongInteger');
|
|
1617
|
+
await test('Object');
|
|
1618
|
+
await test('String');
|
|
1619
|
+
});
|
|
1620
|
+
it('retains casing of return types', async () => {
|
|
1621
|
+
async function test(type) {
|
|
1622
|
+
await testTranspile(`
|
|
2017
1623
|
sub one() as ${type}
|
|
2018
1624
|
end sub
|
|
2019
1625
|
|
|
@@ -2024,19 +1630,19 @@ describe('BrsFile', () => {
|
|
|
2024
1630
|
end sub
|
|
2025
1631
|
`);
|
|
2026
1632
|
}
|
|
2027
|
-
test('Boolean');
|
|
2028
|
-
test('Double');
|
|
2029
|
-
test('Dynamic');
|
|
2030
|
-
test('Float');
|
|
2031
|
-
test('Integer');
|
|
2032
|
-
test('LongInteger');
|
|
2033
|
-
test('Object');
|
|
2034
|
-
test('String');
|
|
2035
|
-
test('Void');
|
|
2036
|
-
});
|
|
2037
|
-
it('retains casing of literal types', () => {
|
|
2038
|
-
function test(type) {
|
|
2039
|
-
testTranspile(`
|
|
1633
|
+
await test('Boolean');
|
|
1634
|
+
await test('Double');
|
|
1635
|
+
await test('Dynamic');
|
|
1636
|
+
await test('Float');
|
|
1637
|
+
await test('Integer');
|
|
1638
|
+
await test('LongInteger');
|
|
1639
|
+
await test('Object');
|
|
1640
|
+
await test('String');
|
|
1641
|
+
await test('Void');
|
|
1642
|
+
});
|
|
1643
|
+
it('retains casing of literal types', async () => {
|
|
1644
|
+
async function test(type) {
|
|
1645
|
+
await testTranspile(`
|
|
2040
1646
|
sub main()
|
|
2041
1647
|
thing = ${type}
|
|
2042
1648
|
thing = ${type.toLowerCase()}
|
|
@@ -2044,13 +1650,13 @@ describe('BrsFile', () => {
|
|
|
2044
1650
|
end sub
|
|
2045
1651
|
`);
|
|
2046
1652
|
}
|
|
2047
|
-
test('Invalid');
|
|
2048
|
-
test('True');
|
|
2049
|
-
test('False');
|
|
1653
|
+
await test('Invalid');
|
|
1654
|
+
await test('True');
|
|
1655
|
+
await test('False');
|
|
2050
1656
|
});
|
|
2051
1657
|
describe('throwStatement', () => {
|
|
2052
|
-
it('transpiles properly', () => {
|
|
2053
|
-
testTranspile(`
|
|
1658
|
+
it('transpiles properly', async () => {
|
|
1659
|
+
await testTranspile(`
|
|
2054
1660
|
sub main()
|
|
2055
1661
|
try
|
|
2056
1662
|
throw "some message"
|
|
@@ -2061,8 +1667,8 @@ describe('BrsFile', () => {
|
|
|
2061
1667
|
});
|
|
2062
1668
|
});
|
|
2063
1669
|
describe('try/catch', () => {
|
|
2064
|
-
it('transpiles properly', () => {
|
|
2065
|
-
testTranspile(`
|
|
1670
|
+
it('transpiles properly', async () => {
|
|
1671
|
+
await testTranspile(`
|
|
2066
1672
|
sub main()
|
|
2067
1673
|
try
|
|
2068
1674
|
print m.b.c
|
|
@@ -2074,8 +1680,8 @@ describe('BrsFile', () => {
|
|
|
2074
1680
|
});
|
|
2075
1681
|
});
|
|
2076
1682
|
describe('namespaces', () => {
|
|
2077
|
-
it('properly transpiles namespace functions for assignments', () => {
|
|
2078
|
-
testTranspile(`
|
|
1683
|
+
it('properly transpiles namespace functions for assignments', async () => {
|
|
1684
|
+
await testTranspile(`
|
|
2079
1685
|
namespace NameA.NameB
|
|
2080
1686
|
sub Speak()
|
|
2081
1687
|
end sub
|
|
@@ -2096,8 +1702,8 @@ describe('BrsFile', () => {
|
|
|
2096
1702
|
end sub
|
|
2097
1703
|
`);
|
|
2098
1704
|
});
|
|
2099
|
-
it('properly transpiles inferred namespace function for assignment', () => {
|
|
2100
|
-
testTranspile(`
|
|
1705
|
+
it('properly transpiles inferred namespace function for assignment', async () => {
|
|
1706
|
+
await testTranspile(`
|
|
2101
1707
|
namespace NameA.NameB
|
|
2102
1708
|
sub Speak()
|
|
2103
1709
|
end sub
|
|
@@ -2117,25 +1723,26 @@ describe('BrsFile', () => {
|
|
|
2117
1723
|
`);
|
|
2118
1724
|
});
|
|
2119
1725
|
});
|
|
2120
|
-
it('includes all text to end of line for a non-terminated string', () => {
|
|
2121
|
-
testTranspile('sub main()\n name = "john \nend sub', 'sub main()\n name = "john "\nend sub', null, 'source/main.bs', false);
|
|
1726
|
+
it('includes all text to end of line for a non-terminated string', async () => {
|
|
1727
|
+
await testTranspile('sub main()\n name = "john \nend sub', 'sub main()\n name = "john "\nend sub', null, 'source/main.bs', false);
|
|
2122
1728
|
});
|
|
2123
|
-
it('escapes quotes in string literals', () => {
|
|
2124
|
-
testTranspile(`
|
|
1729
|
+
it('escapes quotes in string literals', async () => {
|
|
1730
|
+
await testTranspile(`
|
|
2125
1731
|
sub main()
|
|
1732
|
+
expected = "Hello"
|
|
2126
1733
|
expected += chr(10) + " version=""2.0"""
|
|
2127
1734
|
end sub
|
|
2128
1735
|
`);
|
|
2129
1736
|
});
|
|
2130
|
-
it('keeps function parameter types in proper order', () => {
|
|
2131
|
-
testTranspile(`
|
|
1737
|
+
it('keeps function parameter types in proper order', async () => {
|
|
1738
|
+
await testTranspile(`
|
|
2132
1739
|
function CreateTestStatistic(name as string, result = "Success" as string, time = 0 as integer, errorCode = 0 as integer, errorMessage = "" as string) as object
|
|
2133
1740
|
end function
|
|
2134
1741
|
`);
|
|
2135
1742
|
});
|
|
2136
|
-
it('discard parameter types when removeParameterTypes is true', () => {
|
|
1743
|
+
it('discard parameter types when removeParameterTypes is true', async () => {
|
|
2137
1744
|
program.options.removeParameterTypes = true;
|
|
2138
|
-
testTranspile(`
|
|
1745
|
+
await testTranspile(`
|
|
2139
1746
|
sub one(a as integer, b = "" as string, c = invalid as dynamic)
|
|
2140
1747
|
end sub
|
|
2141
1748
|
`, `
|
|
@@ -2143,9 +1750,9 @@ describe('BrsFile', () => {
|
|
|
2143
1750
|
end sub
|
|
2144
1751
|
`);
|
|
2145
1752
|
});
|
|
2146
|
-
it('discard return type when removeParameterTypes is true', () => {
|
|
1753
|
+
it('discard return type when removeParameterTypes is true', async () => {
|
|
2147
1754
|
program.options.removeParameterTypes = true;
|
|
2148
|
-
testTranspile(`
|
|
1755
|
+
await testTranspile(`
|
|
2149
1756
|
function one() as string
|
|
2150
1757
|
return ""
|
|
2151
1758
|
end function
|
|
@@ -2155,8 +1762,8 @@ describe('BrsFile', () => {
|
|
|
2155
1762
|
end function
|
|
2156
1763
|
`);
|
|
2157
1764
|
});
|
|
2158
|
-
it('transpiles local var assignment operators', () => {
|
|
2159
|
-
testTranspile(`
|
|
1765
|
+
it('transpiles local var assignment operators', async () => {
|
|
1766
|
+
await testTranspile(`
|
|
2160
1767
|
sub main()
|
|
2161
1768
|
count = 0
|
|
2162
1769
|
count += 1
|
|
@@ -2169,8 +1776,8 @@ describe('BrsFile', () => {
|
|
|
2169
1776
|
end sub
|
|
2170
1777
|
`);
|
|
2171
1778
|
});
|
|
2172
|
-
it('transpiles AA property assignment operators', () => {
|
|
2173
|
-
testTranspile(`
|
|
1779
|
+
it('transpiles AA property assignment operators', async () => {
|
|
1780
|
+
await testTranspile(`
|
|
2174
1781
|
sub main()
|
|
2175
1782
|
person = {
|
|
2176
1783
|
count: 0
|
|
@@ -2179,8 +1786,8 @@ describe('BrsFile', () => {
|
|
|
2179
1786
|
end sub
|
|
2180
1787
|
`);
|
|
2181
1788
|
});
|
|
2182
|
-
it('transpiles AA indexed assignment operators', () => {
|
|
2183
|
-
testTranspile(`
|
|
1789
|
+
it('transpiles AA indexed assignment operators', async () => {
|
|
1790
|
+
await testTranspile(`
|
|
2184
1791
|
sub main()
|
|
2185
1792
|
person = {
|
|
2186
1793
|
count: 0
|
|
@@ -2189,8 +1796,8 @@ describe('BrsFile', () => {
|
|
|
2189
1796
|
end sub
|
|
2190
1797
|
`);
|
|
2191
1798
|
});
|
|
2192
|
-
it('relative-referenced namespaced functions get prefixed', () => {
|
|
2193
|
-
testTranspile(`
|
|
1799
|
+
it('relative-referenced namespaced functions get prefixed', async () => {
|
|
1800
|
+
await testTranspile(`
|
|
2194
1801
|
namespace Vertibrates.Birds
|
|
2195
1802
|
function GetAllBirds()
|
|
2196
1803
|
return [
|
|
@@ -2220,8 +1827,8 @@ describe('BrsFile', () => {
|
|
|
2220
1827
|
end function
|
|
2221
1828
|
`, 'trim', 'source/main.bs');
|
|
2222
1829
|
});
|
|
2223
|
-
it('transpiles namespaced functions', () => {
|
|
2224
|
-
testTranspile(`
|
|
1830
|
+
it('transpiles namespaced functions', async () => {
|
|
1831
|
+
await testTranspile(`
|
|
2225
1832
|
namespace NameA
|
|
2226
1833
|
sub alert()
|
|
2227
1834
|
end sub
|
|
@@ -2237,9 +1844,9 @@ describe('BrsFile', () => {
|
|
|
2237
1844
|
end sub
|
|
2238
1845
|
`, 'trim', 'source/main.bs');
|
|
2239
1846
|
});
|
|
2240
|
-
it('transpiles dim', () => {
|
|
2241
|
-
function doTest(code) {
|
|
2242
|
-
testTranspile(`
|
|
1847
|
+
it('transpiles dim', async () => {
|
|
1848
|
+
async function doTest(code) {
|
|
1849
|
+
await testTranspile(`
|
|
2243
1850
|
sub main()
|
|
2244
1851
|
requestList = []
|
|
2245
1852
|
${code}
|
|
@@ -2251,20 +1858,20 @@ describe('BrsFile', () => {
|
|
|
2251
1858
|
end sub
|
|
2252
1859
|
`);
|
|
2253
1860
|
}
|
|
2254
|
-
doTest(`Dim c[5]`);
|
|
2255
|
-
doTest(`Dim c[5, 4]`);
|
|
2256
|
-
doTest(`Dim c[5, 4, 6]`);
|
|
2257
|
-
doTest(`Dim requestData[requestList.count()]`);
|
|
2258
|
-
doTest(`Dim requestData[1, requestList.count()]`);
|
|
2259
|
-
doTest(`Dim requestData[1, requestList.count(), 2]`);
|
|
2260
|
-
doTest(`Dim requestData[requestList[2]]`);
|
|
2261
|
-
doTest(`Dim requestData[1, requestList[2]]`);
|
|
2262
|
-
doTest(`Dim requestData[1, requestList[2], 2]`);
|
|
2263
|
-
doTest(`Dim requestData[requestList["2"]]`);
|
|
2264
|
-
doTest(`Dim requestData[1, requestList["2"]]`);
|
|
2265
|
-
doTest(`Dim requestData[1, requestList["2"], 2]`);
|
|
2266
|
-
doTest(`Dim requestData[1, StrToI("1"), 2]`);
|
|
2267
|
-
testTranspile(`
|
|
1861
|
+
await doTest(`Dim c[5]`);
|
|
1862
|
+
await doTest(`Dim c[5, 4]`);
|
|
1863
|
+
await doTest(`Dim c[5, 4, 6]`);
|
|
1864
|
+
await doTest(`Dim requestData[requestList.count()]`);
|
|
1865
|
+
await doTest(`Dim requestData[1, requestList.count()]`);
|
|
1866
|
+
await doTest(`Dim requestData[1, requestList.count(), 2]`);
|
|
1867
|
+
await doTest(`Dim requestData[requestList[2]]`);
|
|
1868
|
+
await doTest(`Dim requestData[1, requestList[2]]`);
|
|
1869
|
+
await doTest(`Dim requestData[1, requestList[2], 2]`);
|
|
1870
|
+
await doTest(`Dim requestData[requestList["2"]]`);
|
|
1871
|
+
await doTest(`Dim requestData[1, requestList["2"]]`);
|
|
1872
|
+
await doTest(`Dim requestData[1, requestList["2"], 2]`);
|
|
1873
|
+
await doTest(`Dim requestData[1, StrToI("1"), 2]`);
|
|
1874
|
+
await testTranspile(`
|
|
2268
1875
|
function getValue(param1)
|
|
2269
1876
|
end function
|
|
2270
1877
|
|
|
@@ -2276,8 +1883,8 @@ describe('BrsFile', () => {
|
|
|
2276
1883
|
end sub
|
|
2277
1884
|
`);
|
|
2278
1885
|
});
|
|
2279
|
-
it('transpiles calls to fully-qualified namespaced functions', () => {
|
|
2280
|
-
testTranspile(`
|
|
1886
|
+
it('transpiles calls to fully-qualified namespaced functions', async () => {
|
|
1887
|
+
await testTranspile(`
|
|
2281
1888
|
namespace NameA
|
|
2282
1889
|
sub alert()
|
|
2283
1890
|
end sub
|
|
@@ -2302,15 +1909,15 @@ describe('BrsFile', () => {
|
|
|
2302
1909
|
end sub
|
|
2303
1910
|
`, 'trim', 'source/main.bs');
|
|
2304
1911
|
});
|
|
2305
|
-
it('keeps end-of-line comments with their line', () => {
|
|
2306
|
-
testTranspile(`
|
|
1912
|
+
it('keeps end-of-line comments with their line', async () => {
|
|
1913
|
+
await testTranspile(`
|
|
2307
1914
|
function DoSomething() 'comment 1
|
|
2308
1915
|
name = "bob" 'comment 2
|
|
2309
1916
|
end function 'comment 3
|
|
2310
1917
|
`);
|
|
2311
1918
|
});
|
|
2312
|
-
it('works for functions', () => {
|
|
2313
|
-
testTranspile(`
|
|
1919
|
+
it('works for functions', async () => {
|
|
1920
|
+
await testTranspile(`
|
|
2314
1921
|
function DoSomething()
|
|
2315
1922
|
'lots of empty white space
|
|
2316
1923
|
'that will be removed during transpile
|
|
@@ -2325,16 +1932,16 @@ describe('BrsFile', () => {
|
|
|
2325
1932
|
end function
|
|
2326
1933
|
`);
|
|
2327
1934
|
});
|
|
2328
|
-
it('keeps empty AAs and arrays on same line', () => {
|
|
2329
|
-
testTranspile(`
|
|
1935
|
+
it('keeps empty AAs and arrays on same line', async () => {
|
|
1936
|
+
await testTranspile(`
|
|
2330
1937
|
sub a()
|
|
2331
1938
|
person = {}
|
|
2332
1939
|
stuff = []
|
|
2333
1940
|
end sub
|
|
2334
1941
|
`, null, 'trim');
|
|
2335
1942
|
});
|
|
2336
|
-
it('does not add leading or trailing newlines', () => {
|
|
2337
|
-
testTranspile(`function abc()\nend function`, undefined, 'none');
|
|
1943
|
+
it('does not add leading or trailing newlines', async () => {
|
|
1944
|
+
await testTranspile(`function abc()\nend function`, undefined, 'none');
|
|
2338
1945
|
});
|
|
2339
1946
|
it('handles sourcemap edge case', async () => {
|
|
2340
1947
|
let source = 'sub main()\n' +
|
|
@@ -2343,9 +1950,9 @@ describe('BrsFile', () => {
|
|
|
2343
1950
|
'\n' +
|
|
2344
1951
|
'end sub';
|
|
2345
1952
|
program.options.sourceMap = true;
|
|
2346
|
-
let result = testTranspile(source, `sub main()\n print 1\nend sub`, 'none', 'source/main.bs');
|
|
1953
|
+
let result = await testTranspile(source, `sub main()\n print 1\nend sub`, 'none', 'source/main.bs');
|
|
2347
1954
|
//load the source map
|
|
2348
|
-
let location = await source_map_1.SourceMapConsumer.with(result.map
|
|
1955
|
+
let location = await source_map_1.SourceMapConsumer.with(result.map, null, (consumer) => {
|
|
2349
1956
|
return consumer.generatedPositionFor({
|
|
2350
1957
|
line: 3,
|
|
2351
1958
|
column: 0,
|
|
@@ -2362,7 +1969,7 @@ describe('BrsFile', () => {
|
|
|
2362
1969
|
//remove newlines and EOF
|
|
2363
1970
|
.filter(x => x.kind !== TokenKind_1.TokenKind.Eof && x.kind !== TokenKind_1.TokenKind.Newline);
|
|
2364
1971
|
program.options.sourceMap = true;
|
|
2365
|
-
let result = testTranspile(source, source, 'none');
|
|
1972
|
+
let result = await testTranspile(source, source, 'none');
|
|
2366
1973
|
//load the source map
|
|
2367
1974
|
await source_map_1.SourceMapConsumer.with(result.map.toString(), null, (consumer) => {
|
|
2368
1975
|
let tokenResult = tokens.map(token => ({
|
|
@@ -2385,8 +1992,8 @@ describe('BrsFile', () => {
|
|
|
2385
1992
|
(0, chai_config_spec_1.expect)(sourcemapResult).to.eql(tokenResult);
|
|
2386
1993
|
});
|
|
2387
1994
|
});
|
|
2388
|
-
it('handles empty if block', () => {
|
|
2389
|
-
testTranspile(`
|
|
1995
|
+
it('handles empty if block', async () => {
|
|
1996
|
+
await testTranspile(`
|
|
2390
1997
|
sub main()
|
|
2391
1998
|
if true then
|
|
2392
1999
|
end if
|
|
@@ -2407,8 +2014,8 @@ describe('BrsFile', () => {
|
|
|
2407
2014
|
end sub
|
|
2408
2015
|
`);
|
|
2409
2016
|
});
|
|
2410
|
-
it('handles empty elseif block', () => {
|
|
2411
|
-
testTranspile(`
|
|
2017
|
+
it('handles empty elseif block', async () => {
|
|
2018
|
+
await testTranspile(`
|
|
2412
2019
|
sub main()
|
|
2413
2020
|
if true then
|
|
2414
2021
|
print "if"
|
|
@@ -2422,8 +2029,8 @@ describe('BrsFile', () => {
|
|
|
2422
2029
|
end sub
|
|
2423
2030
|
`);
|
|
2424
2031
|
});
|
|
2425
|
-
it('handles empty else block', () => {
|
|
2426
|
-
testTranspile(`
|
|
2032
|
+
it('handles empty else block', async () => {
|
|
2033
|
+
await testTranspile(`
|
|
2427
2034
|
sub main()
|
|
2428
2035
|
if true then
|
|
2429
2036
|
print "if"
|
|
@@ -2438,8 +2045,8 @@ describe('BrsFile', () => {
|
|
|
2438
2045
|
end sub
|
|
2439
2046
|
`);
|
|
2440
2047
|
});
|
|
2441
|
-
it('handles else block with a leading comment', () => {
|
|
2442
|
-
testTranspile(`
|
|
2048
|
+
it('handles else block with a leading comment', async () => {
|
|
2049
|
+
await testTranspile(`
|
|
2443
2050
|
sub main()
|
|
2444
2051
|
if true then
|
|
2445
2052
|
print "if"
|
|
@@ -2450,8 +2057,8 @@ describe('BrsFile', () => {
|
|
|
2450
2057
|
end sub
|
|
2451
2058
|
`);
|
|
2452
2059
|
});
|
|
2453
|
-
it('works for function parameters', () => {
|
|
2454
|
-
testTranspile(`
|
|
2060
|
+
it('works for function parameters', async () => {
|
|
2061
|
+
await testTranspile(`
|
|
2455
2062
|
function DoSomething(name, age as integer, text as string)
|
|
2456
2063
|
end function
|
|
2457
2064
|
`, `
|
|
@@ -2459,8 +2066,8 @@ describe('BrsFile', () => {
|
|
|
2459
2066
|
end function
|
|
2460
2067
|
`);
|
|
2461
2068
|
});
|
|
2462
|
-
it('adds newlines between top-level statements', () => {
|
|
2463
|
-
testTranspile(`
|
|
2069
|
+
it('adds newlines between top-level statements', async () => {
|
|
2070
|
+
await testTranspile(`
|
|
2464
2071
|
function a()
|
|
2465
2072
|
end function
|
|
2466
2073
|
|
|
@@ -2468,8 +2075,8 @@ describe('BrsFile', () => {
|
|
|
2468
2075
|
end function
|
|
2469
2076
|
`);
|
|
2470
2077
|
});
|
|
2471
|
-
it('properly indents nested AA literals', () => {
|
|
2472
|
-
testTranspile(`
|
|
2078
|
+
it('properly indents nested AA literals', async () => {
|
|
2079
|
+
await testTranspile(`
|
|
2473
2080
|
sub doSomething()
|
|
2474
2081
|
grandparent = {
|
|
2475
2082
|
parent: {
|
|
@@ -2483,8 +2090,8 @@ describe('BrsFile', () => {
|
|
|
2483
2090
|
end sub
|
|
2484
2091
|
`);
|
|
2485
2092
|
});
|
|
2486
|
-
it('does not add comma after final object property even when comments are present', () => {
|
|
2487
|
-
testTranspile(`
|
|
2093
|
+
it('does not add comma after final object property even when comments are present', async () => {
|
|
2094
|
+
await testTranspile(`
|
|
2488
2095
|
sub doSomething()
|
|
2489
2096
|
person = {
|
|
2490
2097
|
age: 12 'comment
|
|
@@ -2507,8 +2114,8 @@ describe('BrsFile', () => {
|
|
|
2507
2114
|
end sub
|
|
2508
2115
|
`);
|
|
2509
2116
|
});
|
|
2510
|
-
it('works for a complex function with comments all over the place', () => {
|
|
2511
|
-
testTranspile(`
|
|
2117
|
+
it('works for a complex function with comments all over the place', async () => {
|
|
2118
|
+
await testTranspile(`
|
|
2512
2119
|
'import some library
|
|
2513
2120
|
library "v30/bslCore.brs" 'comment
|
|
2514
2121
|
|
|
@@ -2598,7 +2205,7 @@ describe('BrsFile', () => {
|
|
|
2598
2205
|
sub logInfo()
|
|
2599
2206
|
end sub
|
|
2600
2207
|
`);
|
|
2601
|
-
file
|
|
2208
|
+
file['needsTranspiled'] = false;
|
|
2602
2209
|
const { code } = file.transpile();
|
|
2603
2210
|
(0, chai_config_spec_1.expect)(code.endsWith(`'//# sourceMappingURL=./logger.brs.map`)).to.be.true;
|
|
2604
2211
|
});
|
|
@@ -2607,16 +2214,16 @@ describe('BrsFile', () => {
|
|
|
2607
2214
|
sub logInfo()
|
|
2608
2215
|
end sub
|
|
2609
2216
|
`);
|
|
2610
|
-
file
|
|
2217
|
+
file['needsTranspiled'] = true;
|
|
2611
2218
|
const { code } = file.transpile();
|
|
2612
2219
|
(0, chai_config_spec_1.expect)(code.endsWith(`'//# sourceMappingURL=./logger.brs.map`)).to.be.true;
|
|
2613
2220
|
});
|
|
2614
|
-
it('replaces custom types in parameter types and return types', () => {
|
|
2221
|
+
it('replaces custom types in parameter types and return types', async () => {
|
|
2615
2222
|
program.setFile('source/SomeKlass.bs', `
|
|
2616
2223
|
class SomeKlass
|
|
2617
2224
|
end class
|
|
2618
2225
|
`);
|
|
2619
|
-
testTranspile(`
|
|
2226
|
+
await testTranspile(`
|
|
2620
2227
|
function foo() as SomeKlass
|
|
2621
2228
|
return new SomeKlass()
|
|
2622
2229
|
end function
|
|
@@ -2645,8 +2252,8 @@ describe('BrsFile', () => {
|
|
|
2645
2252
|
program.validate();
|
|
2646
2253
|
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
2647
2254
|
});
|
|
2648
|
-
it('sets invalid on empty callfunc', () => {
|
|
2649
|
-
testTranspile(`
|
|
2255
|
+
it('sets invalid on empty callfunc', async () => {
|
|
2256
|
+
await testTranspile(`
|
|
2650
2257
|
sub main()
|
|
2651
2258
|
node = invalid
|
|
2652
2259
|
node@.doSomething()
|
|
@@ -2662,8 +2269,8 @@ describe('BrsFile', () => {
|
|
|
2662
2269
|
end sub
|
|
2663
2270
|
`);
|
|
2664
2271
|
});
|
|
2665
|
-
it('includes original arguments', () => {
|
|
2666
|
-
testTranspile(`
|
|
2272
|
+
it('includes original arguments', async () => {
|
|
2273
|
+
await testTranspile(`
|
|
2667
2274
|
sub main()
|
|
2668
2275
|
node = invalid
|
|
2669
2276
|
node@.doSomething(1, true, m.top.someVal)
|
|
@@ -2765,8 +2372,8 @@ describe('BrsFile', () => {
|
|
|
2765
2372
|
});
|
|
2766
2373
|
});
|
|
2767
2374
|
describe('typedef', () => {
|
|
2768
|
-
it('includes enum and interface types', () => {
|
|
2769
|
-
testGetTypedef(`
|
|
2375
|
+
it('includes enum and interface types', async () => {
|
|
2376
|
+
await testGetTypedef(`
|
|
2770
2377
|
interface Foo
|
|
2771
2378
|
field as string
|
|
2772
2379
|
end interface
|
|
@@ -3142,8 +2749,8 @@ describe('BrsFile', () => {
|
|
|
3142
2749
|
function plugin() {
|
|
3143
2750
|
return {
|
|
3144
2751
|
name: 'lower-file-name',
|
|
3145
|
-
|
|
3146
|
-
evt.
|
|
2752
|
+
afterProvideFile: (evt) => {
|
|
2753
|
+
evt.files[0]._customProp = true;
|
|
3147
2754
|
}
|
|
3148
2755
|
};
|
|
3149
2756
|
}
|
|
@@ -3151,16 +2758,16 @@ describe('BrsFile', () => {
|
|
|
3151
2758
|
`);
|
|
3152
2759
|
});
|
|
3153
2760
|
it('can load an absolute plugin which receives callbacks', () => {
|
|
3154
|
-
|
|
3155
|
-
(
|
|
3156
|
-
|
|
2761
|
+
for (const plugin of util_1.default.loadPlugins(testHelpers_spec_2.tempDir, [(0, util_1.standardizePath) `${testHelpers_spec_2.tempDir}/plugins/${pluginFileName}`])) {
|
|
2762
|
+
program.plugins.add(plugin);
|
|
2763
|
+
}
|
|
3157
2764
|
const file = program.setFile('source/MAIN.brs', '');
|
|
3158
2765
|
(0, chai_config_spec_1.expect)(file._customProp).to.exist;
|
|
3159
2766
|
});
|
|
3160
2767
|
it('can load a relative plugin which receives callbacks', () => {
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
2768
|
+
for (const plugin of util_1.default.loadPlugins(testHelpers_spec_2.tempDir, [`./plugins/${pluginFileName}`])) {
|
|
2769
|
+
program.plugins.add(plugin);
|
|
2770
|
+
}
|
|
3164
2771
|
const file = program.setFile('source/MAIN.brs', '');
|
|
3165
2772
|
(0, chai_config_spec_1.expect)(file._customProp).to.exist;
|
|
3166
2773
|
});
|
|
@@ -3200,6 +2807,74 @@ describe('BrsFile', () => {
|
|
|
3200
2807
|
range: util_1.default.createRange(5, 25, 5, 31)
|
|
3201
2808
|
}]);
|
|
3202
2809
|
});
|
|
2810
|
+
it('returns interface location', () => {
|
|
2811
|
+
const file = program.setFile('source/main.bs', `
|
|
2812
|
+
sub test(selectedMovie as Movie)
|
|
2813
|
+
print selectedMovie
|
|
2814
|
+
end sub
|
|
2815
|
+
interface Movie
|
|
2816
|
+
url as string
|
|
2817
|
+
end interface
|
|
2818
|
+
`);
|
|
2819
|
+
program.validate();
|
|
2820
|
+
// sub test(selectedMovie as Mo|vie)
|
|
2821
|
+
(0, chai_config_spec_1.expect)(program.getDefinition(file.srcPath, vscode_languageserver_1.Position.create(1, 44))).to.eql([{
|
|
2822
|
+
uri: vscode_uri_1.URI.file(file.srcPath).toString(),
|
|
2823
|
+
range: util_1.default.createRange(4, 26, 4, 31)
|
|
2824
|
+
}]);
|
|
2825
|
+
});
|
|
2826
|
+
it('returns namespaced interface location', () => {
|
|
2827
|
+
const file = program.setFile('source/main.bs', `
|
|
2828
|
+
sub test(selectedMovie as interfaces.Movie)
|
|
2829
|
+
print selectedMovie
|
|
2830
|
+
end sub
|
|
2831
|
+
namespace interfaces
|
|
2832
|
+
interface Movie
|
|
2833
|
+
url as string
|
|
2834
|
+
end interface
|
|
2835
|
+
end namespace
|
|
2836
|
+
`);
|
|
2837
|
+
program.validate();
|
|
2838
|
+
//sub test(selectedMovie as interfaces.Mo|vie)
|
|
2839
|
+
(0, chai_config_spec_1.expect)(program.getDefinition(file.srcPath, vscode_languageserver_1.Position.create(1, 55))).to.eql([{
|
|
2840
|
+
uri: vscode_uri_1.URI.file(file.srcPath).toString(),
|
|
2841
|
+
range: util_1.default.createRange(5, 30, 5, 35)
|
|
2842
|
+
}]);
|
|
2843
|
+
});
|
|
2844
|
+
it('returns class location', () => {
|
|
2845
|
+
const file = program.setFile('source/main.bs', `
|
|
2846
|
+
sub test(selectedMovie as Movie)
|
|
2847
|
+
print selectedMovie
|
|
2848
|
+
end sub
|
|
2849
|
+
class Movie
|
|
2850
|
+
url as string
|
|
2851
|
+
end class
|
|
2852
|
+
`);
|
|
2853
|
+
program.validate();
|
|
2854
|
+
//sub test(selectedMovie as Mo|vie)
|
|
2855
|
+
(0, chai_config_spec_1.expect)(program.getDefinition(file.srcPath, vscode_languageserver_1.Position.create(1, 44))).to.eql([{
|
|
2856
|
+
uri: vscode_uri_1.URI.file(file.srcPath).toString(),
|
|
2857
|
+
range: util_1.default.createRange(4, 22, 4, 27)
|
|
2858
|
+
}]);
|
|
2859
|
+
});
|
|
2860
|
+
it('returns namespaced class location', () => {
|
|
2861
|
+
const file = program.setFile('source/main.bs', `
|
|
2862
|
+
sub test(selectedMovie as classes.Movie)
|
|
2863
|
+
print selectedMovie
|
|
2864
|
+
end sub
|
|
2865
|
+
namespace classes
|
|
2866
|
+
class Movie
|
|
2867
|
+
url as string
|
|
2868
|
+
end class
|
|
2869
|
+
end namespace
|
|
2870
|
+
`);
|
|
2871
|
+
program.validate();
|
|
2872
|
+
//sub test(selectedMovie as classes.Mo|vie)
|
|
2873
|
+
(0, chai_config_spec_1.expect)(program.getDefinition(file.srcPath, vscode_languageserver_1.Position.create(1, 52))).to.eql([{
|
|
2874
|
+
uri: vscode_uri_1.URI.file(file.srcPath).toString(),
|
|
2875
|
+
range: util_1.default.createRange(5, 26, 5, 31)
|
|
2876
|
+
}]);
|
|
2877
|
+
});
|
|
3203
2878
|
it('does not crash on nulls', () => {
|
|
3204
2879
|
const file = program.setFile('source/main.bs', `
|
|
3205
2880
|
sub main()
|
|
@@ -3240,5 +2915,787 @@ describe('BrsFile', () => {
|
|
|
3240
2915
|
program.validate();
|
|
3241
2916
|
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.mismatchedEndCallableKeyword('function', 'sub')), { range: util_1.default.createRange(2, 12, 2, 19) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.mismatchedEndCallableKeyword('sub', 'function')), { range: util_1.default.createRange(4, 12, 4, 24) })]);
|
|
3242
2917
|
});
|
|
2918
|
+
describe('requiredSymbols', () => {
|
|
2919
|
+
it('should be empty for a simple file', () => {
|
|
2920
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
2921
|
+
function someFunc() as integer
|
|
2922
|
+
return 1
|
|
2923
|
+
end function
|
|
2924
|
+
`);
|
|
2925
|
+
const validateFileEvent = {
|
|
2926
|
+
program: program,
|
|
2927
|
+
file: mainFile
|
|
2928
|
+
};
|
|
2929
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
2930
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(0);
|
|
2931
|
+
});
|
|
2932
|
+
it('should be empty if the file needs no external symbols', () => {
|
|
2933
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
2934
|
+
function someFunc() as integer
|
|
2935
|
+
return 1
|
|
2936
|
+
end function
|
|
2937
|
+
|
|
2938
|
+
sub useKlass()
|
|
2939
|
+
k = new Klass()
|
|
2940
|
+
k.addTwo()
|
|
2941
|
+
end sub
|
|
2942
|
+
|
|
2943
|
+
class Klass
|
|
2944
|
+
sub addTwo()
|
|
2945
|
+
print someFunc() + someFunc()
|
|
2946
|
+
end sub
|
|
2947
|
+
end class
|
|
2948
|
+
`);
|
|
2949
|
+
const validateFileEvent = {
|
|
2950
|
+
program: program,
|
|
2951
|
+
file: mainFile
|
|
2952
|
+
};
|
|
2953
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
2954
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(0);
|
|
2955
|
+
});
|
|
2956
|
+
it('should not include global callables or types', () => {
|
|
2957
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
2958
|
+
function printLower(s as string) as integer
|
|
2959
|
+
print lcase(s.trim())
|
|
2960
|
+
end function
|
|
2961
|
+
|
|
2962
|
+
sub setLabelText( label as roSGNodeLabel, text as string)
|
|
2963
|
+
label.text = text
|
|
2964
|
+
end sub
|
|
2965
|
+
`);
|
|
2966
|
+
const validateFileEvent = {
|
|
2967
|
+
program: program,
|
|
2968
|
+
file: mainFile
|
|
2969
|
+
};
|
|
2970
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
2971
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(0);
|
|
2972
|
+
});
|
|
2973
|
+
it('should include unknown param and return types', () => {
|
|
2974
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
2975
|
+
function someFunc(arg as OneType) as TwoType
|
|
2976
|
+
return arg.getTwo()
|
|
2977
|
+
end function
|
|
2978
|
+
`);
|
|
2979
|
+
const validateFileEvent = {
|
|
2980
|
+
program: program,
|
|
2981
|
+
file: mainFile
|
|
2982
|
+
};
|
|
2983
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
2984
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(2);
|
|
2985
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.map(x => x.typeChain[0].name)).to.have.same.members([
|
|
2986
|
+
'TwoType', 'OneType'
|
|
2987
|
+
]);
|
|
2988
|
+
});
|
|
2989
|
+
it('should include unknown param and return types on class methods', () => {
|
|
2990
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
2991
|
+
class Klass
|
|
2992
|
+
function someFunc(arg as OneType) as TwoType
|
|
2993
|
+
return arg.getTwo()
|
|
2994
|
+
end function
|
|
2995
|
+
end class
|
|
2996
|
+
`);
|
|
2997
|
+
const validateFileEvent = {
|
|
2998
|
+
program: program,
|
|
2999
|
+
file: mainFile
|
|
3000
|
+
};
|
|
3001
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3002
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(2);
|
|
3003
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.map(x => x.typeChain[0].name)).to.have.same.members([
|
|
3004
|
+
'TwoType', 'OneType'
|
|
3005
|
+
]);
|
|
3006
|
+
});
|
|
3007
|
+
it('should not include assigned symbols', () => {
|
|
3008
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3009
|
+
sub someFunc(arg as SomeOtherType)
|
|
3010
|
+
x = arg.member
|
|
3011
|
+
print x+1
|
|
3012
|
+
end sub
|
|
3013
|
+
`);
|
|
3014
|
+
const validateFileEvent = {
|
|
3015
|
+
program: program,
|
|
3016
|
+
file: mainFile
|
|
3017
|
+
};
|
|
3018
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3019
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(1);
|
|
3020
|
+
// x and arg are assigned.. they are not included in the required symbols
|
|
3021
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols[0].typeChain[0].name).to.equal('SomeOtherType');
|
|
3022
|
+
});
|
|
3023
|
+
it('should include functions called that are not in the file', () => {
|
|
3024
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3025
|
+
sub someFunc()
|
|
3026
|
+
x = otherFileFunc1()
|
|
3027
|
+
print x+1
|
|
3028
|
+
end sub
|
|
3029
|
+
|
|
3030
|
+
function deepFunctionCall(i as integer)
|
|
3031
|
+
x = 2*i and otherFileFunc2()
|
|
3032
|
+
y = sin(x+fix(78.2)*log(otherFileFunc3()))
|
|
3033
|
+
' this is a comment otherFileFunc5()
|
|
3034
|
+
return y-otherFileFunc4()
|
|
3035
|
+
end function
|
|
3036
|
+
`);
|
|
3037
|
+
const validateFileEvent = {
|
|
3038
|
+
program: program,
|
|
3039
|
+
file: mainFile
|
|
3040
|
+
};
|
|
3041
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3042
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(4);
|
|
3043
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.map(x => x.typeChain[0].name)).to.have.same.members([
|
|
3044
|
+
'otherFileFunc1', 'otherFileFunc2', 'otherFileFunc3', 'otherFileFunc4'
|
|
3045
|
+
]);
|
|
3046
|
+
});
|
|
3047
|
+
it('should include classes called that are not in the file', () => {
|
|
3048
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3049
|
+
function someFunc(other as OtherKlass) as NS1.Thing
|
|
3050
|
+
x = new AnotherClass()
|
|
3051
|
+
return other.getThing(x)
|
|
3052
|
+
end function
|
|
3053
|
+
`);
|
|
3054
|
+
const validateFileEvent = {
|
|
3055
|
+
program: program,
|
|
3056
|
+
file: mainFile
|
|
3057
|
+
};
|
|
3058
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3059
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(3);
|
|
3060
|
+
const requiredTypeChains = mainFile.requiredSymbols.map(x => x.typeChain.map(tc => tc.name).join('.'));
|
|
3061
|
+
(0, chai_config_spec_1.expect)(requiredTypeChains).to.have.same.members([
|
|
3062
|
+
'OtherKlass', 'NS1.Thing', 'AnotherClass'
|
|
3063
|
+
]);
|
|
3064
|
+
const requiredSymbolsFlags = mainFile.requiredSymbols.map(x => x.flags);
|
|
3065
|
+
(0, chai_config_spec_1.expect)(requiredSymbolsFlags).to.have.same.members([
|
|
3066
|
+
SymbolTable_1.SymbolTypeFlag.typetime, SymbolTable_1.SymbolTypeFlag.typetime, SymbolTable_1.SymbolTypeFlag.runtime
|
|
3067
|
+
]);
|
|
3068
|
+
});
|
|
3069
|
+
it('should include enums and consts that are not in the file', () => {
|
|
3070
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3071
|
+
sub someFunc(myEnum as SomeEnum)
|
|
3072
|
+
if myEnum = SomeEnum.value1
|
|
3073
|
+
print 1
|
|
3074
|
+
else if myEnum = SomeEnum.value2
|
|
3075
|
+
print 2
|
|
3076
|
+
else if myEnum = SomeConstValue
|
|
3077
|
+
print 3
|
|
3078
|
+
end if
|
|
3079
|
+
end sub
|
|
3080
|
+
`);
|
|
3081
|
+
const validateFileEvent = {
|
|
3082
|
+
program: program,
|
|
3083
|
+
file: mainFile
|
|
3084
|
+
};
|
|
3085
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3086
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(4);
|
|
3087
|
+
const requiredTypeChains = mainFile.requiredSymbols.map(x => x.typeChain.map(tc => tc.name).join('.'));
|
|
3088
|
+
(0, chai_config_spec_1.expect)(requiredTypeChains).to.have.same.members([
|
|
3089
|
+
'SomeEnum', 'SomeEnum.value1', 'SomeEnum.value2', 'SomeConstValue'
|
|
3090
|
+
]);
|
|
3091
|
+
const requiredSymbolsFlags = mainFile.requiredSymbols.map(x => x.flags);
|
|
3092
|
+
(0, chai_config_spec_1.expect)(requiredSymbolsFlags).to.have.same.members([
|
|
3093
|
+
SymbolTable_1.SymbolTypeFlag.typetime, SymbolTable_1.SymbolTypeFlag.runtime, SymbolTable_1.SymbolTypeFlag.runtime, SymbolTable_1.SymbolTypeFlag.runtime
|
|
3094
|
+
]);
|
|
3095
|
+
});
|
|
3096
|
+
it('should include types not defined in the file', () => {
|
|
3097
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3098
|
+
interface Data
|
|
3099
|
+
kind as DataKind
|
|
3100
|
+
getObj as DataObject
|
|
3101
|
+
subData as SubData
|
|
3102
|
+
end interface
|
|
3103
|
+
|
|
3104
|
+
class DataObject extends BaseData
|
|
3105
|
+
kind as DataKind
|
|
3106
|
+
function process(dataProcess as DataProcessor) as ProcessedData
|
|
3107
|
+
return dataProcess.work(m)
|
|
3108
|
+
end function
|
|
3109
|
+
end class
|
|
3110
|
+
`);
|
|
3111
|
+
const validateFileEvent = {
|
|
3112
|
+
program: program,
|
|
3113
|
+
file: mainFile
|
|
3114
|
+
};
|
|
3115
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3116
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(5);
|
|
3117
|
+
const requiredTypeChains = mainFile.requiredSymbols.map(x => x.typeChain.map(tc => tc.name).join('.'));
|
|
3118
|
+
(0, chai_config_spec_1.expect)(requiredTypeChains).to.have.same.members([
|
|
3119
|
+
'DataKind', 'SubData', 'BaseData', 'DataProcessor', 'ProcessedData'
|
|
3120
|
+
]);
|
|
3121
|
+
const requiredSymbolsFlags = mainFile.requiredSymbols.map(x => x.flags);
|
|
3122
|
+
(0, chai_config_spec_1.expect)(requiredSymbolsFlags).to.have.same.members([
|
|
3123
|
+
SymbolTable_1.SymbolTypeFlag.typetime, SymbolTable_1.SymbolTypeFlag.typetime, SymbolTable_1.SymbolTypeFlag.typetime, SymbolTable_1.SymbolTypeFlag.typetime, SymbolTable_1.SymbolTypeFlag.typetime
|
|
3124
|
+
]);
|
|
3125
|
+
});
|
|
3126
|
+
it('includes namespace details', () => {
|
|
3127
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3128
|
+
namespace Alpha.Beta
|
|
3129
|
+
sub printConstVal()
|
|
3130
|
+
print CONST_VALUE
|
|
3131
|
+
end sub
|
|
3132
|
+
end namespace
|
|
3133
|
+
|
|
3134
|
+
namespace Delta
|
|
3135
|
+
namespace Gamma
|
|
3136
|
+
namespace Eta
|
|
3137
|
+
sub doStuff(x as OtherType)
|
|
3138
|
+
x.something()
|
|
3139
|
+
end sub
|
|
3140
|
+
end namespace
|
|
3141
|
+
end namespace
|
|
3142
|
+
end namespace
|
|
3143
|
+
`);
|
|
3144
|
+
const validateFileEvent = {
|
|
3145
|
+
program: program,
|
|
3146
|
+
file: mainFile
|
|
3147
|
+
};
|
|
3148
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3149
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(2);
|
|
3150
|
+
const requiredTypeChains = mainFile.requiredSymbols.map(x => x.typeChain.map(tc => tc.name).join('.'));
|
|
3151
|
+
(0, chai_config_spec_1.expect)(requiredTypeChains).to.have.same.members([
|
|
3152
|
+
'CONST_VALUE', 'OtherType'
|
|
3153
|
+
]);
|
|
3154
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols[0].containingNamespaces).to.have.same.members(['Alpha', 'Beta']);
|
|
3155
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols[1].containingNamespaces).to.have.same.members(['Delta', 'Gamma', 'Eta']);
|
|
3156
|
+
});
|
|
3157
|
+
it('does not include namespaces that are defined in the file', () => {
|
|
3158
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3159
|
+
namespace name1
|
|
3160
|
+
const PI = 3.14
|
|
3161
|
+
|
|
3162
|
+
namespace name2
|
|
3163
|
+
function getPi() as float
|
|
3164
|
+
return name1.PI
|
|
3165
|
+
end function
|
|
3166
|
+
end namespace
|
|
3167
|
+
end namespace
|
|
3168
|
+
`);
|
|
3169
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3170
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(0);
|
|
3171
|
+
});
|
|
3172
|
+
it('should put types from typecasts as typetime required', () => {
|
|
3173
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3174
|
+
function takesIface(z) as string
|
|
3175
|
+
return (z as MyInterface).name
|
|
3176
|
+
end function
|
|
3177
|
+
`);
|
|
3178
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3179
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(1);
|
|
3180
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols[0].flags).to.eq(SymbolTable_1.SymbolTypeFlag.typetime);
|
|
3181
|
+
});
|
|
3182
|
+
});
|
|
3183
|
+
describe('providedSymbols', () => {
|
|
3184
|
+
it('includes functions defined in the file', () => {
|
|
3185
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3186
|
+
function someFunc() as integer
|
|
3187
|
+
return 1
|
|
3188
|
+
end function
|
|
3189
|
+
|
|
3190
|
+
function someFunc2() as float
|
|
3191
|
+
return 2.3
|
|
3192
|
+
end function
|
|
3193
|
+
`);
|
|
3194
|
+
const validateFileEvent = {
|
|
3195
|
+
program: program,
|
|
3196
|
+
file: mainFile
|
|
3197
|
+
};
|
|
3198
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3199
|
+
const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3200
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3201
|
+
const someFuncType = runtimeSymbols.get('somefunc').type;
|
|
3202
|
+
(0, testHelpers_spec_1.expectTypeToBe)(someFuncType, TypedFunctionType_1.TypedFunctionType);
|
|
3203
|
+
const someFunc2Type = runtimeSymbols.get('somefunc2').type;
|
|
3204
|
+
(0, testHelpers_spec_1.expectTypeToBe)(someFunc2Type, TypedFunctionType_1.TypedFunctionType);
|
|
3205
|
+
});
|
|
3206
|
+
it('includes functions with unresolved params/return types', () => {
|
|
3207
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3208
|
+
function someFunc() as OtherFileType
|
|
3209
|
+
return new OtherFileType()
|
|
3210
|
+
end function
|
|
3211
|
+
`);
|
|
3212
|
+
const validateFileEvent = {
|
|
3213
|
+
program: program,
|
|
3214
|
+
file: mainFile
|
|
3215
|
+
};
|
|
3216
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3217
|
+
const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3218
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3219
|
+
const someFuncType = runtimeSymbols.get('somefunc').type;
|
|
3220
|
+
(0, testHelpers_spec_1.expectTypeToBe)(someFuncType, TypedFunctionType_1.TypedFunctionType);
|
|
3221
|
+
const requiredSymbols = mainFile.requiredSymbols.map(x => x.typeChain[0].name);
|
|
3222
|
+
(0, chai_config_spec_1.expect)(requiredSymbols).to.have.same.members(['OtherFileType', 'OtherFileType']);
|
|
3223
|
+
const requiredSymbolTypes = mainFile.requiredSymbols.map(x => x.flags);
|
|
3224
|
+
(0, chai_config_spec_1.expect)(requiredSymbolTypes).to.have.same.members([SymbolTable_1.SymbolTypeFlag.runtime, SymbolTable_1.SymbolTypeFlag.typetime]);
|
|
3225
|
+
});
|
|
3226
|
+
it('includes classes defined in the file', () => {
|
|
3227
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3228
|
+
class Klass
|
|
3229
|
+
name as string
|
|
3230
|
+
end class
|
|
3231
|
+
|
|
3232
|
+
class Klass2 extends Klass
|
|
3233
|
+
age as integer
|
|
3234
|
+
|
|
3235
|
+
function getId() as string
|
|
3236
|
+
return m.name + " " + m.age.toStr()
|
|
3237
|
+
end function
|
|
3238
|
+
end class
|
|
3239
|
+
|
|
3240
|
+
class Klass3
|
|
3241
|
+
propClass = new Klass2()
|
|
3242
|
+
end class
|
|
3243
|
+
`);
|
|
3244
|
+
const validateFileEvent = {
|
|
3245
|
+
program: program,
|
|
3246
|
+
file: mainFile
|
|
3247
|
+
};
|
|
3248
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3249
|
+
const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3250
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(3);
|
|
3251
|
+
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('klass').type, types_1.ClassType);
|
|
3252
|
+
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('klass2').type, types_1.ClassType);
|
|
3253
|
+
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('klass3').type, types_1.ClassType);
|
|
3254
|
+
const typetimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.typetime);
|
|
3255
|
+
(0, chai_config_spec_1.expect)(typetimeSymbols.size).to.eq(3);
|
|
3256
|
+
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('klass').type, types_1.ClassType);
|
|
3257
|
+
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('klass2').type, types_1.ClassType);
|
|
3258
|
+
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('klass3').type, types_1.ClassType);
|
|
3259
|
+
});
|
|
3260
|
+
it('includes other types defined in the file', () => {
|
|
3261
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3262
|
+
interface MyInterface
|
|
3263
|
+
name as string
|
|
3264
|
+
end interface
|
|
3265
|
+
|
|
3266
|
+
enum MyEnum
|
|
3267
|
+
val1
|
|
3268
|
+
val2
|
|
3269
|
+
end enum
|
|
3270
|
+
|
|
3271
|
+
namespace MyNamespace
|
|
3272
|
+
const MyConst = 3.14
|
|
3273
|
+
end namespace
|
|
3274
|
+
`);
|
|
3275
|
+
const validateFileEvent = {
|
|
3276
|
+
program: program,
|
|
3277
|
+
file: mainFile
|
|
3278
|
+
};
|
|
3279
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3280
|
+
const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3281
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3282
|
+
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('myenum').type, types_1.EnumType);
|
|
3283
|
+
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('mynamespace.myconst').type, types_1.FloatType);
|
|
3284
|
+
const typetimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.typetime);
|
|
3285
|
+
(0, chai_config_spec_1.expect)(typetimeSymbols.size).to.eq(2);
|
|
3286
|
+
(0, testHelpers_spec_1.expectTypeToBe)(typetimeSymbols.get('myinterface').type, types_1.InterfaceType);
|
|
3287
|
+
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('myenum').type, types_1.EnumType);
|
|
3288
|
+
});
|
|
3289
|
+
describe('changes', () => {
|
|
3290
|
+
it('new symbols are added to the changes set', () => {
|
|
3291
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3292
|
+
sub someFunc()
|
|
3293
|
+
print 1
|
|
3294
|
+
end sub
|
|
3295
|
+
`);
|
|
3296
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3297
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3298
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3299
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3300
|
+
sub someFunc()
|
|
3301
|
+
print 1
|
|
3302
|
+
end sub
|
|
3303
|
+
|
|
3304
|
+
sub someFunc2()
|
|
3305
|
+
print 2
|
|
3306
|
+
end sub
|
|
3307
|
+
`);
|
|
3308
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3309
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3310
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3311
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3312
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3313
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.has('somefunc2')).to.be.true;
|
|
3314
|
+
});
|
|
3315
|
+
it('removed symbols are added to the changes set', () => {
|
|
3316
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3317
|
+
sub someFunc()
|
|
3318
|
+
print 1
|
|
3319
|
+
end sub
|
|
3320
|
+
|
|
3321
|
+
sub someFunc2()
|
|
3322
|
+
print 2
|
|
3323
|
+
end sub
|
|
3324
|
+
`);
|
|
3325
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3326
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3327
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3328
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3329
|
+
sub someFunc()
|
|
3330
|
+
print 1
|
|
3331
|
+
end sub
|
|
3332
|
+
`);
|
|
3333
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3334
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3335
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3336
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3337
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3338
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.has('somefunc2')).to.be.true;
|
|
3339
|
+
});
|
|
3340
|
+
it('new symbols in a namespace are added to the changes set', () => {
|
|
3341
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3342
|
+
namespace Alpha
|
|
3343
|
+
end namespace
|
|
3344
|
+
`);
|
|
3345
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3346
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3347
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(0);
|
|
3348
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3349
|
+
namespace Alpha
|
|
3350
|
+
const ABC = "abc"
|
|
3351
|
+
end namespace
|
|
3352
|
+
`);
|
|
3353
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3354
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3355
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3356
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3357
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3358
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.has('alpha.abc')).to.be.true;
|
|
3359
|
+
});
|
|
3360
|
+
it('should be empty if no changes in actual provided symbols', () => {
|
|
3361
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3362
|
+
sub printSomething()
|
|
3363
|
+
print "Something"
|
|
3364
|
+
end sub
|
|
3365
|
+
|
|
3366
|
+
namespace alpha.beta
|
|
3367
|
+
const PI = 3.14
|
|
3368
|
+
end namespace
|
|
3369
|
+
`);
|
|
3370
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3371
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3372
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3373
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3374
|
+
sub printSomething()
|
|
3375
|
+
print "Something Else"
|
|
3376
|
+
end sub
|
|
3377
|
+
|
|
3378
|
+
namespace alpha.beta
|
|
3379
|
+
const PI = 3.14159
|
|
3380
|
+
end namespace
|
|
3381
|
+
`);
|
|
3382
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3383
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3384
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3385
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3386
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3387
|
+
});
|
|
3388
|
+
it('should include changes in function signatures', () => {
|
|
3389
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3390
|
+
function someFunc(x)
|
|
3391
|
+
return x
|
|
3392
|
+
end function
|
|
3393
|
+
`);
|
|
3394
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3395
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3396
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3397
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3398
|
+
function someFunc(x, y)
|
|
3399
|
+
return x+y
|
|
3400
|
+
end function
|
|
3401
|
+
`);
|
|
3402
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3403
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3404
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3405
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3406
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3407
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.has('somefunc'));
|
|
3408
|
+
});
|
|
3409
|
+
it('should include changes in classes', () => {
|
|
3410
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3411
|
+
class MyKlass
|
|
3412
|
+
name as string
|
|
3413
|
+
function getValue() as float
|
|
3414
|
+
return 3.14
|
|
3415
|
+
end function
|
|
3416
|
+
end class
|
|
3417
|
+
`);
|
|
3418
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3419
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3420
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3421
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3422
|
+
class MyKlass
|
|
3423
|
+
name as string
|
|
3424
|
+
function getValue() as string
|
|
3425
|
+
return "hello"
|
|
3426
|
+
end function
|
|
3427
|
+
end class
|
|
3428
|
+
`);
|
|
3429
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3430
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3431
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3432
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3433
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3434
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.has('myklass'));
|
|
3435
|
+
let typeTimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.typetime);
|
|
3436
|
+
(0, chai_config_spec_1.expect)(typeTimeChanges.size).to.eq(1);
|
|
3437
|
+
(0, chai_config_spec_1.expect)(typeTimeChanges.has('myklass'));
|
|
3438
|
+
});
|
|
3439
|
+
it('should include changes in interfaces', () => {
|
|
3440
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3441
|
+
interface Iface1
|
|
3442
|
+
name as string
|
|
3443
|
+
function doStuff() as float
|
|
3444
|
+
end interface
|
|
3445
|
+
`);
|
|
3446
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3447
|
+
let typetimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.typetime);
|
|
3448
|
+
(0, chai_config_spec_1.expect)(typetimeSymbols.size).to.eq(1);
|
|
3449
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3450
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(0);
|
|
3451
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3452
|
+
interface Iface1
|
|
3453
|
+
name as string
|
|
3454
|
+
age as integer
|
|
3455
|
+
function doStuff() as float
|
|
3456
|
+
end interface
|
|
3457
|
+
`);
|
|
3458
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3459
|
+
typetimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.typetime);
|
|
3460
|
+
(0, chai_config_spec_1.expect)(typetimeSymbols.size).to.eq(1);
|
|
3461
|
+
let typeTimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.typetime);
|
|
3462
|
+
(0, chai_config_spec_1.expect)(typeTimeChanges.size).to.eq(1);
|
|
3463
|
+
(0, chai_config_spec_1.expect)(typeTimeChanges.has('iface1'));
|
|
3464
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3465
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3466
|
+
});
|
|
3467
|
+
it('should not include changes in enum values, if inner type is the same', () => {
|
|
3468
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3469
|
+
enum MyEnum
|
|
3470
|
+
north = 4
|
|
3471
|
+
east = 3
|
|
3472
|
+
south = 2
|
|
3473
|
+
west = 1
|
|
3474
|
+
end enum
|
|
3475
|
+
`);
|
|
3476
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3477
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3478
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3479
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3480
|
+
enum MyEnum
|
|
3481
|
+
north = 1
|
|
3482
|
+
east = 2
|
|
3483
|
+
south = 3
|
|
3484
|
+
west = 4
|
|
3485
|
+
end enum
|
|
3486
|
+
`);
|
|
3487
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3488
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3489
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3490
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3491
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3492
|
+
let typetimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.typetime);
|
|
3493
|
+
(0, chai_config_spec_1.expect)(typetimeSymbols.size).to.eq(1);
|
|
3494
|
+
let typetimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.typetime);
|
|
3495
|
+
(0, chai_config_spec_1.expect)(typetimeChanges.size).to.eq(0);
|
|
3496
|
+
});
|
|
3497
|
+
it('should include changes in enum, if different number of members', () => {
|
|
3498
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3499
|
+
enum Direction
|
|
3500
|
+
north = 1
|
|
3501
|
+
east = 2
|
|
3502
|
+
south = 3
|
|
3503
|
+
west = 4
|
|
3504
|
+
end enum
|
|
3505
|
+
|
|
3506
|
+
enum Weather
|
|
3507
|
+
rainy
|
|
3508
|
+
sunny
|
|
3509
|
+
end enum
|
|
3510
|
+
|
|
3511
|
+
enum Colors
|
|
3512
|
+
blue
|
|
3513
|
+
red
|
|
3514
|
+
green
|
|
3515
|
+
purple
|
|
3516
|
+
end enum
|
|
3517
|
+
`);
|
|
3518
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3519
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3520
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(3);
|
|
3521
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3522
|
+
enum Direction ' same
|
|
3523
|
+
north = 1
|
|
3524
|
+
east = 2
|
|
3525
|
+
south = 3
|
|
3526
|
+
west = 4
|
|
3527
|
+
end enum
|
|
3528
|
+
|
|
3529
|
+
enum Weather 'added member
|
|
3530
|
+
rainy
|
|
3531
|
+
sunny
|
|
3532
|
+
snowy
|
|
3533
|
+
end enum
|
|
3534
|
+
|
|
3535
|
+
enum Colors 'removed member
|
|
3536
|
+
blue
|
|
3537
|
+
red
|
|
3538
|
+
green
|
|
3539
|
+
end enum
|
|
3540
|
+
`);
|
|
3541
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3542
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3543
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(3);
|
|
3544
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3545
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(2);
|
|
3546
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.has('weather'));
|
|
3547
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.has('colors'));
|
|
3548
|
+
});
|
|
3549
|
+
it('should include changes in enum, if different underlying type', () => {
|
|
3550
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3551
|
+
enum Direction
|
|
3552
|
+
north = 1
|
|
3553
|
+
east = 2
|
|
3554
|
+
south = 3
|
|
3555
|
+
west = 4
|
|
3556
|
+
end enum
|
|
3557
|
+
`);
|
|
3558
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3559
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3560
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3561
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3562
|
+
enum Direction ' now is a string
|
|
3563
|
+
north = "N"
|
|
3564
|
+
east = "E"
|
|
3565
|
+
south = "S"
|
|
3566
|
+
west = "W"
|
|
3567
|
+
end enum
|
|
3568
|
+
`);
|
|
3569
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3570
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3571
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3572
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3573
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3574
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.has('direction'));
|
|
3575
|
+
});
|
|
3576
|
+
it('should include changes in const, if different underlying type', () => {
|
|
3577
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3578
|
+
namespace alpha.beta
|
|
3579
|
+
const PI = 3.14
|
|
3580
|
+
end namespace
|
|
3581
|
+
`);
|
|
3582
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3583
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3584
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3585
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3586
|
+
namespace alpha.beta
|
|
3587
|
+
const PI = "lemon chiffon"
|
|
3588
|
+
end namespace
|
|
3589
|
+
`);
|
|
3590
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3591
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3592
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3593
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3594
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3595
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.has('alpha.beta.pi'));
|
|
3596
|
+
});
|
|
3597
|
+
it('should not include changes inside a function if the param types are known', () => {
|
|
3598
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3599
|
+
function func1(p as string) as integer
|
|
3600
|
+
return len(p)
|
|
3601
|
+
end function
|
|
3602
|
+
|
|
3603
|
+
sub displayModelTypeInLabel(myLabel as roSgNodeLabel)
|
|
3604
|
+
print myLabel.text
|
|
3605
|
+
di = createObject("roDeviceInfo")' as roDeviceInfo
|
|
3606
|
+
myLabel.text = di.GetFriendlyName()
|
|
3607
|
+
print myLabel.getChildren(0, -1)
|
|
3608
|
+
end sub
|
|
3609
|
+
`);
|
|
3610
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3611
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3612
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3613
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3614
|
+
function func1(p as string) as integer
|
|
3615
|
+
return len(p)+1
|
|
3616
|
+
end function
|
|
3617
|
+
|
|
3618
|
+
sub displayModelTypeInLabel(myLabel as roSgNodeLabel)
|
|
3619
|
+
print myLabel.text
|
|
3620
|
+
di = createObject("roDeviceInfo") as roDeviceInfo
|
|
3621
|
+
myLabel.text = di.GetFriendlyName()
|
|
3622
|
+
print myLabel.getChildren(0, -1)
|
|
3623
|
+
end sub
|
|
3624
|
+
`);
|
|
3625
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3626
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3627
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3628
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3629
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3630
|
+
});
|
|
3631
|
+
it('classes that override AA built-in methods show change properly', () => {
|
|
3632
|
+
const classFileContent = `
|
|
3633
|
+
class AAOverRide
|
|
3634
|
+
sub count(num as integer) as void
|
|
3635
|
+
print num
|
|
3636
|
+
end sub
|
|
3637
|
+
end class
|
|
3638
|
+
`;
|
|
3639
|
+
let mainFile = program.setFile('source/class.bs', classFileContent);
|
|
3640
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3641
|
+
// No changes!
|
|
3642
|
+
mainFile = program.setFile('source/class.bs', classFileContent);
|
|
3643
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3644
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3645
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3646
|
+
});
|
|
3647
|
+
it('functions in a namespace that return classes show change properly', () => {
|
|
3648
|
+
const fileContent = `
|
|
3649
|
+
namespace Alpha.Beta
|
|
3650
|
+
|
|
3651
|
+
class SomeKlass
|
|
3652
|
+
name as string
|
|
3653
|
+
function combineName(klass as SomeKlass)
|
|
3654
|
+
m.name = m.name+klass.name
|
|
3655
|
+
end function
|
|
3656
|
+
end class
|
|
3657
|
+
|
|
3658
|
+
function getSomeKlass(name as string) as SomeKlass
|
|
3659
|
+
k = new SomeKlass()
|
|
3660
|
+
k.name = name
|
|
3661
|
+
return k
|
|
3662
|
+
end function
|
|
3663
|
+
end namespace
|
|
3664
|
+
`;
|
|
3665
|
+
let mainFile = program.setFile('source/class.bs', fileContent);
|
|
3666
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3667
|
+
// No changes!
|
|
3668
|
+
mainFile = program.setFile('source/class.bs', fileContent);
|
|
3669
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3670
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3671
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3672
|
+
});
|
|
3673
|
+
it('functions in a namespace that have class params show change properly', () => {
|
|
3674
|
+
const fileContent = `
|
|
3675
|
+
namespace Alpha.Beta
|
|
3676
|
+
|
|
3677
|
+
class SomeKlass
|
|
3678
|
+
name as string
|
|
3679
|
+
function combineName(klass as SomeKlass)
|
|
3680
|
+
m.name = m.name+klass.name
|
|
3681
|
+
end function
|
|
3682
|
+
end class
|
|
3683
|
+
|
|
3684
|
+
function combineKlass(klass1 as SomeKlass, klass2 as SomeKlass) as SomeKlass
|
|
3685
|
+
klass1.combineName(klass2)
|
|
3686
|
+
return klass1
|
|
3687
|
+
end function
|
|
3688
|
+
end namespace
|
|
3689
|
+
`;
|
|
3690
|
+
let mainFile = program.setFile('source/class.bs', fileContent);
|
|
3691
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3692
|
+
// No changes!
|
|
3693
|
+
mainFile = program.setFile('source/class.bs', fileContent);
|
|
3694
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3695
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3696
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3697
|
+
});
|
|
3698
|
+
});
|
|
3699
|
+
});
|
|
3243
3700
|
});
|
|
3244
3701
|
//# sourceMappingURL=BrsFile.spec.js.map
|