brighterscript 1.0.0-alpha.50 → 1.0.0-alpha.51
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/README.md +3 -0
- package/bsconfig.schema.json +75 -0
- package/dist/BsConfig.d.ts +90 -5
- package/dist/CodeActionUtil.d.ts +17 -0
- package/dist/CodeActionUtil.js.map +1 -1
- package/dist/CommentFlagProcessor.d.ts +16 -12
- package/dist/CommentFlagProcessor.js +141 -59
- package/dist/CommentFlagProcessor.js.map +1 -1
- package/dist/CrossScopeValidator.js +13 -5
- package/dist/CrossScopeValidator.js.map +1 -1
- package/dist/DiagnosticManager.d.ts +1 -0
- package/dist/DiagnosticManager.js +25 -9
- package/dist/DiagnosticManager.js.map +1 -1
- package/dist/DiagnosticMessages.d.ts +61 -17
- package/dist/DiagnosticMessages.js +78 -24
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/LanguageServer.d.ts +39 -2
- package/dist/LanguageServer.js +142 -5
- package/dist/LanguageServer.js.map +1 -1
- package/dist/Program.d.ts +62 -1
- package/dist/Program.js +185 -13
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +1 -8
- package/dist/ProgramBuilder.js +31 -11
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +87 -6
- package/dist/Scope.js +76 -31
- package/dist/Scope.js.map +1 -1
- package/dist/ScopeNamespaceLookup.d.ts +73 -0
- package/dist/ScopeNamespaceLookup.js +242 -0
- package/dist/ScopeNamespaceLookup.js.map +1 -0
- package/dist/SymbolTable.d.ts +9 -2
- package/dist/SymbolTable.js +24 -14
- package/dist/SymbolTable.js.map +1 -1
- package/dist/astUtils/CachedLookups.js +3 -0
- package/dist/astUtils/CachedLookups.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +4 -1
- package/dist/astUtils/reflection.js +24 -4
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +2 -1
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +4 -2
- package/dist/bscPlugin/BscPlugin.js +10 -2
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/CallExpressionInfo.d.ts +1 -1
- package/dist/bscPlugin/CallExpressionInfo.js +1 -2
- package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
- package/dist/bscPlugin/FileWriter.d.ts +13 -0
- package/dist/bscPlugin/FileWriter.js +56 -1
- package/dist/bscPlugin/FileWriter.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.d.ts +106 -5
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +630 -126
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
- package/dist/bscPlugin/codeActions/FixAllCodeActionsProcessor.d.ts +17 -0
- package/dist/bscPlugin/codeActions/FixAllCodeActionsProcessor.js +66 -0
- package/dist/bscPlugin/codeActions/FixAllCodeActionsProcessor.js.map +1 -0
- package/dist/bscPlugin/codeActions/codeActionHelpers.d.ts +18 -0
- package/dist/bscPlugin/codeActions/codeActionHelpers.js +31 -0
- package/dist/bscPlugin/codeActions/codeActionHelpers.js.map +1 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.js +5 -5
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
- package/dist/bscPlugin/definition/DefinitionProvider.js +8 -0
- package/dist/bscPlugin/definition/DefinitionProvider.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.js +11 -3
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
- package/dist/bscPlugin/selectionRanges/SelectionRangesProcessor.d.ts +7 -0
- package/dist/bscPlugin/selectionRanges/SelectionRangesProcessor.js +77 -0
- package/dist/bscPlugin/selectionRanges/SelectionRangesProcessor.js.map +1 -0
- package/dist/bscPlugin/serialize/FileSerializer.d.ts +1 -1
- package/dist/bscPlugin/serialize/FileSerializer.js +12 -7
- package/dist/bscPlugin/serialize/FileSerializer.js.map +1 -1
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.d.ts +7 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js +87 -1
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.d.ts +14 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js +97 -21
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +17 -0
- package/dist/bscPlugin/validation/ScopeValidator.js +162 -4
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/bscPlugin/validation/XmlFileValidator.js +14 -0
- package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -1
- package/dist/cli.js +13 -0
- package/dist/cli.js.map +1 -1
- package/dist/diagnosticUtils.d.ts +51 -1
- package/dist/diagnosticUtils.js +222 -1
- package/dist/diagnosticUtils.js.map +1 -1
- package/dist/files/BrsFile.d.ts +18 -2
- package/dist/files/BrsFile.js +87 -6
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/XmlFile.js +2 -1
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/interfaces.d.ts +68 -23
- package/dist/interfaces.js.map +1 -1
- package/dist/lexer/Lexer.js +4 -5
- package/dist/lexer/Lexer.js.map +1 -1
- package/dist/lexer/Token.d.ts +1 -1
- package/dist/lexer/TokenKind.d.ts +8 -0
- package/dist/lexer/TokenKind.js +21 -1
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/lsp/LspProject.d.ts +49 -1
- package/dist/lsp/Project.d.ts +33 -1
- package/dist/lsp/Project.js +129 -4
- package/dist/lsp/Project.js.map +1 -1
- package/dist/lsp/ProjectManager.d.ts +48 -2
- package/dist/lsp/ProjectManager.js +152 -9
- package/dist/lsp/ProjectManager.js.map +1 -1
- package/dist/lsp/worker/WorkerThreadProject.d.ts +27 -2
- package/dist/lsp/worker/WorkerThreadProject.js +16 -0
- package/dist/lsp/worker/WorkerThreadProject.js.map +1 -1
- package/dist/parser/AstNode.d.ts +3 -1
- package/dist/parser/AstNode.js +2 -0
- package/dist/parser/AstNode.js.map +1 -1
- package/dist/parser/Expression.d.ts +54 -5
- package/dist/parser/Expression.js +112 -7
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.d.ts +24 -1
- package/dist/parser/Parser.js +180 -41
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/SGParser.d.ts +1 -0
- package/dist/parser/SGParser.js +9 -0
- package/dist/parser/SGParser.js.map +1 -1
- package/dist/parser/Statement.d.ts +6 -1
- package/dist/parser/Statement.js +22 -14
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/TranspileState.d.ts +4 -2
- package/dist/parser/TranspileState.js +10 -4
- package/dist/parser/TranspileState.js.map +1 -1
- package/dist/roku-types/data.json +210 -3
- package/dist/types/ArrayType.js +6 -1
- package/dist/types/ArrayType.js.map +1 -1
- package/dist/types/BooleanType.js +1 -1
- package/dist/types/BooleanType.js.map +1 -1
- package/dist/types/CallFuncableType.d.ts +1 -1
- package/dist/types/ClassType.js +3 -0
- package/dist/types/ClassType.js.map +1 -1
- package/dist/types/ComponentType.js +3 -0
- package/dist/types/ComponentType.js.map +1 -1
- package/dist/types/EnumType.js +3 -0
- package/dist/types/EnumType.js.map +1 -1
- package/dist/types/IntersectionType.js +3 -0
- package/dist/types/IntersectionType.js.map +1 -1
- package/dist/types/ReferenceType.js +6 -0
- package/dist/types/ReferenceType.js.map +1 -1
- package/dist/types/TypeStatementType.d.ts +1 -0
- package/dist/types/TypeStatementType.js +12 -1
- package/dist/types/TypeStatementType.js.map +1 -1
- package/dist/types/TypedFunctionType.js +20 -10
- package/dist/types/TypedFunctionType.js.map +1 -1
- package/dist/types/UnionType.js +3 -0
- package/dist/types/UnionType.js.map +1 -1
- package/dist/types/helpers.js +6 -0
- package/dist/types/helpers.js.map +1 -1
- package/dist/util.d.ts +42 -3
- package/dist/util.js +131 -7
- package/dist/util.js.map +1 -1
- package/package.json +24 -26
- package/dist/astUtils/CachedLookups.spec.d.ts +0 -1
- package/dist/astUtils/CachedLookups.spec.js +0 -39
- package/dist/astUtils/CachedLookups.spec.js.map +0 -1
- package/dist/astUtils/Editor.spec.d.ts +0 -1
- package/dist/astUtils/Editor.spec.js +0 -258
- package/dist/astUtils/Editor.spec.js.map +0 -1
- package/dist/astUtils/creators.spec.d.ts +0 -1
- package/dist/astUtils/creators.spec.js +0 -21
- package/dist/astUtils/creators.spec.js.map +0 -1
- package/dist/astUtils/reflection.spec.d.ts +0 -1
- package/dist/astUtils/reflection.spec.js +0 -392
- package/dist/astUtils/reflection.spec.js.map +0 -1
- package/dist/astUtils/stackedVisitor.spec.d.ts +0 -1
- package/dist/astUtils/stackedVisitor.spec.js +0 -79
- package/dist/astUtils/stackedVisitor.spec.js.map +0 -1
- package/dist/astUtils/visitors.spec.d.ts +0 -1
- package/dist/astUtils/visitors.spec.js +0 -1432
- package/dist/astUtils/visitors.spec.js.map +0 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +0 -311
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +0 -2512
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/definition/DefinitionProvider.spec.d.ts +0 -1
- package/dist/bscPlugin/definition/DefinitionProvider.spec.js +0 -87
- package/dist/bscPlugin/definition/DefinitionProvider.spec.js.map +0 -1
- package/dist/bscPlugin/hover/HoverProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/hover/HoverProcessor.spec.js +0 -991
- package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/references/ReferencesProvider.spec.d.ts +0 -1
- package/dist/bscPlugin/references/ReferencesProvider.spec.js +0 -51
- package/dist/bscPlugin/references/ReferencesProvider.spec.js.map +0 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +0 -564
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/serialize/BslibInjector.spec.d.ts +0 -1
- package/dist/bscPlugin/serialize/BslibInjector.spec.js +0 -33
- package/dist/bscPlugin/serialize/BslibInjector.spec.js.map +0 -1
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js +0 -291
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js +0 -245
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js +0 -75
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.d.ts +0 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js +0 -1517
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +0 -1
- package/dist/bscPlugin/validation/ScopeValidator.spec.d.ts +0 -1
- package/dist/bscPlugin/validation/ScopeValidator.spec.js +0 -6135
- package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +0 -1
- package/dist/common/Sequencer.spec.d.ts +0 -1
- package/dist/common/Sequencer.spec.js +0 -75
- package/dist/common/Sequencer.spec.js.map +0 -1
- package/dist/files/BrsFile.Class.spec.d.ts +0 -1
- package/dist/files/BrsFile.Class.spec.js +0 -2035
- package/dist/files/BrsFile.Class.spec.js.map +0 -1
- package/dist/files/BrsFile.spec.d.ts +0 -1
- package/dist/files/BrsFile.spec.js +0 -5848
- package/dist/files/BrsFile.spec.js.map +0 -1
- package/dist/files/LazyFileData.spec.d.ts +0 -1
- package/dist/files/LazyFileData.spec.js +0 -27
- package/dist/files/LazyFileData.spec.js.map +0 -1
- package/dist/files/XmlFile.spec.d.ts +0 -1
- package/dist/files/XmlFile.spec.js +0 -1173
- package/dist/files/XmlFile.spec.js.map +0 -1
- package/dist/files/tests/imports.spec.d.ts +0 -1
- package/dist/files/tests/imports.spec.js +0 -251
- package/dist/files/tests/imports.spec.js.map +0 -1
- package/dist/files/tests/optionalChaning.spec.d.ts +0 -1
- package/dist/files/tests/optionalChaning.spec.js +0 -152
- package/dist/files/tests/optionalChaning.spec.js.map +0 -1
- package/dist/lexer/Character.spec.d.ts +0 -1
- package/dist/lexer/Character.spec.js +0 -27
- package/dist/lexer/Character.spec.js.map +0 -1
- package/dist/lexer/Lexer.spec.d.ts +0 -1
- package/dist/lexer/Lexer.spec.js +0 -1345
- package/dist/lexer/Lexer.spec.js.map +0 -1
- package/dist/lsp/ActionQueue.spec.d.ts +0 -1
- package/dist/lsp/ActionQueue.spec.js +0 -80
- package/dist/lsp/ActionQueue.spec.js.map +0 -1
- package/dist/lsp/DocumentManager.spec.d.ts +0 -1
- package/dist/lsp/DocumentManager.spec.js +0 -103
- package/dist/lsp/DocumentManager.spec.js.map +0 -1
- package/dist/lsp/PathFilterer.spec.d.ts +0 -1
- package/dist/lsp/PathFilterer.spec.js +0 -182
- package/dist/lsp/PathFilterer.spec.js.map +0 -1
- package/dist/lsp/Project.spec.d.ts +0 -1
- package/dist/lsp/Project.spec.js +0 -267
- package/dist/lsp/Project.spec.js.map +0 -1
- package/dist/lsp/ProjectManager.spec.d.ts +0 -1
- package/dist/lsp/ProjectManager.spec.js +0 -913
- package/dist/lsp/ProjectManager.spec.js.map +0 -1
- package/dist/lsp/worker/MessageHandler.spec.d.ts +0 -1
- package/dist/lsp/worker/MessageHandler.spec.js +0 -64
- package/dist/lsp/worker/MessageHandler.spec.js.map +0 -1
- package/dist/lsp/worker/WorkerPool.spec.d.ts +0 -1
- package/dist/lsp/worker/WorkerPool.spec.js +0 -59
- package/dist/lsp/worker/WorkerPool.spec.js.map +0 -1
- package/dist/lsp/worker/WorkerThreadProject.spec.d.ts +0 -2
- package/dist/lsp/worker/WorkerThreadProject.spec.js +0 -71
- package/dist/lsp/worker/WorkerThreadProject.spec.js.map +0 -1
- package/dist/parser/AstNode.spec.d.ts +0 -1
- package/dist/parser/AstNode.spec.js +0 -1455
- package/dist/parser/AstNode.spec.js.map +0 -1
- package/dist/parser/BrightScriptDocParser.spec.d.ts +0 -1
- package/dist/parser/BrightScriptDocParser.spec.js +0 -310
- package/dist/parser/BrightScriptDocParser.spec.js.map +0 -1
- package/dist/parser/Expression.spec.d.ts +0 -1
- package/dist/parser/Expression.spec.js +0 -40
- package/dist/parser/Expression.spec.js.map +0 -1
- package/dist/parser/Parser.Class.spec.d.ts +0 -1
- package/dist/parser/Parser.Class.spec.js +0 -520
- package/dist/parser/Parser.Class.spec.js.map +0 -1
- package/dist/parser/Parser.spec.d.ts +0 -6
- package/dist/parser/Parser.spec.js +0 -2802
- package/dist/parser/Parser.spec.js.map +0 -1
- package/dist/parser/SGParser.spec.d.ts +0 -1
- package/dist/parser/SGParser.spec.js +0 -130
- package/dist/parser/SGParser.spec.js.map +0 -1
- package/dist/parser/Statement.spec.d.ts +0 -1
- package/dist/parser/Statement.spec.js +0 -191
- package/dist/parser/Statement.spec.js.map +0 -1
- package/dist/parser/tests/Parser.spec.d.ts +0 -12
- package/dist/parser/tests/Parser.spec.js +0 -29
- package/dist/parser/tests/Parser.spec.js.map +0 -1
- package/dist/parser/tests/controlFlow/For.spec.d.ts +0 -1
- package/dist/parser/tests/controlFlow/For.spec.js +0 -169
- package/dist/parser/tests/controlFlow/For.spec.js.map +0 -1
- package/dist/parser/tests/controlFlow/ForEach.spec.d.ts +0 -1
- package/dist/parser/tests/controlFlow/ForEach.spec.js +0 -140
- package/dist/parser/tests/controlFlow/ForEach.spec.js.map +0 -1
- package/dist/parser/tests/controlFlow/If.spec.d.ts +0 -1
- package/dist/parser/tests/controlFlow/If.spec.js +0 -694
- package/dist/parser/tests/controlFlow/If.spec.js.map +0 -1
- package/dist/parser/tests/controlFlow/While.spec.d.ts +0 -1
- package/dist/parser/tests/controlFlow/While.spec.js +0 -114
- package/dist/parser/tests/controlFlow/While.spec.js.map +0 -1
- package/dist/parser/tests/expression/Additive.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Additive.spec.js +0 -107
- package/dist/parser/tests/expression/Additive.spec.js.map +0 -1
- package/dist/parser/tests/expression/ArrayLiterals.spec.d.ts +0 -1
- package/dist/parser/tests/expression/ArrayLiterals.spec.js +0 -304
- package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +0 -1
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.d.ts +0 -1
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +0 -342
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +0 -1
- package/dist/parser/tests/expression/Boolean.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Boolean.spec.js +0 -90
- package/dist/parser/tests/expression/Boolean.spec.js.map +0 -1
- package/dist/parser/tests/expression/Call.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Call.spec.js +0 -252
- package/dist/parser/tests/expression/Call.spec.js.map +0 -1
- package/dist/parser/tests/expression/Exponential.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Exponential.spec.js +0 -37
- package/dist/parser/tests/expression/Exponential.spec.js.map +0 -1
- package/dist/parser/tests/expression/Function.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Function.spec.js +0 -412
- package/dist/parser/tests/expression/Function.spec.js.map +0 -1
- package/dist/parser/tests/expression/Indexing.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Indexing.spec.js +0 -302
- package/dist/parser/tests/expression/Indexing.spec.js.map +0 -1
- package/dist/parser/tests/expression/Multiplicative.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Multiplicative.spec.js +0 -67
- package/dist/parser/tests/expression/Multiplicative.spec.js.map +0 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +0 -346
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +0 -1
- package/dist/parser/tests/expression/PrefixUnary.spec.d.ts +0 -1
- package/dist/parser/tests/expression/PrefixUnary.spec.js +0 -111
- package/dist/parser/tests/expression/PrefixUnary.spec.js.map +0 -1
- package/dist/parser/tests/expression/Primary.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Primary.spec.js +0 -165
- package/dist/parser/tests/expression/Primary.spec.js.map +0 -1
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +0 -171
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +0 -1
- package/dist/parser/tests/expression/Relational.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Relational.spec.js +0 -83
- package/dist/parser/tests/expression/Relational.spec.js.map +0 -1
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +0 -201
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +0 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js +0 -389
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +0 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.js +0 -878
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +0 -1
- package/dist/parser/tests/expression/TypeExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/TypeExpression.spec.js +0 -126
- package/dist/parser/tests/expression/TypeExpression.spec.js.map +0 -1
- package/dist/parser/tests/expression/UnaryExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/UnaryExpression.spec.js +0 -52
- package/dist/parser/tests/expression/UnaryExpression.spec.js.map +0 -1
- package/dist/parser/tests/statement/AssignmentOperators.spec.d.ts +0 -1
- package/dist/parser/tests/statement/AssignmentOperators.spec.js +0 -79
- package/dist/parser/tests/statement/AssignmentOperators.spec.js.map +0 -1
- package/dist/parser/tests/statement/ConstStatement.spec.d.ts +0 -1
- package/dist/parser/tests/statement/ConstStatement.spec.js +0 -500
- package/dist/parser/tests/statement/ConstStatement.spec.js.map +0 -1
- package/dist/parser/tests/statement/Continue.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Continue.spec.js +0 -119
- package/dist/parser/tests/statement/Continue.spec.js.map +0 -1
- package/dist/parser/tests/statement/Declaration.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Declaration.spec.js +0 -114
- package/dist/parser/tests/statement/Declaration.spec.js.map +0 -1
- package/dist/parser/tests/statement/Dim.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Dim.spec.js +0 -80
- package/dist/parser/tests/statement/Dim.spec.js.map +0 -1
- package/dist/parser/tests/statement/Enum.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Enum.spec.js +0 -744
- package/dist/parser/tests/statement/Enum.spec.js.map +0 -1
- package/dist/parser/tests/statement/For.spec.d.ts +0 -1
- package/dist/parser/tests/statement/For.spec.js +0 -45
- package/dist/parser/tests/statement/For.spec.js.map +0 -1
- package/dist/parser/tests/statement/ForEach.spec.d.ts +0 -1
- package/dist/parser/tests/statement/ForEach.spec.js +0 -36
- package/dist/parser/tests/statement/ForEach.spec.js.map +0 -1
- package/dist/parser/tests/statement/Function.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Function.spec.js +0 -343
- package/dist/parser/tests/statement/Function.spec.js.map +0 -1
- package/dist/parser/tests/statement/Goto.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Goto.spec.js +0 -51
- package/dist/parser/tests/statement/Goto.spec.js.map +0 -1
- package/dist/parser/tests/statement/Increment.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Increment.spec.js +0 -120
- package/dist/parser/tests/statement/Increment.spec.js.map +0 -1
- package/dist/parser/tests/statement/InterfaceStatement.spec.d.ts +0 -1
- package/dist/parser/tests/statement/InterfaceStatement.spec.js +0 -110
- package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +0 -1
- package/dist/parser/tests/statement/LibraryStatement.spec.d.ts +0 -1
- package/dist/parser/tests/statement/LibraryStatement.spec.js +0 -74
- package/dist/parser/tests/statement/LibraryStatement.spec.js.map +0 -1
- package/dist/parser/tests/statement/Misc.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Misc.spec.js +0 -292
- package/dist/parser/tests/statement/Misc.spec.js.map +0 -1
- package/dist/parser/tests/statement/PrintStatement.spec.d.ts +0 -1
- package/dist/parser/tests/statement/PrintStatement.spec.js +0 -200
- package/dist/parser/tests/statement/PrintStatement.spec.js.map +0 -1
- package/dist/parser/tests/statement/ReturnStatement.spec.d.ts +0 -1
- package/dist/parser/tests/statement/ReturnStatement.spec.js +0 -97
- package/dist/parser/tests/statement/ReturnStatement.spec.js.map +0 -1
- package/dist/parser/tests/statement/Set.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Set.spec.js +0 -232
- package/dist/parser/tests/statement/Set.spec.js.map +0 -1
- package/dist/parser/tests/statement/Stop.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Stop.spec.js +0 -38
- package/dist/parser/tests/statement/Stop.spec.js.map +0 -1
- package/dist/parser/tests/statement/Throw.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Throw.spec.js +0 -38
- package/dist/parser/tests/statement/Throw.spec.js.map +0 -1
- package/dist/parser/tests/statement/TryCatch.spec.d.ts +0 -1
- package/dist/parser/tests/statement/TryCatch.spec.js +0 -151
- package/dist/parser/tests/statement/TryCatch.spec.js.map +0 -1
- package/dist/preprocessor/Manifest.spec.d.ts +0 -1
- package/dist/preprocessor/Manifest.spec.js +0 -80
- package/dist/preprocessor/Manifest.spec.js.map +0 -1
- package/dist/types/ArrayType.spec.d.ts +0 -1
- package/dist/types/ArrayType.spec.js +0 -58
- package/dist/types/ArrayType.spec.js.map +0 -1
- package/dist/types/BooleanType.spec.d.ts +0 -1
- package/dist/types/BooleanType.spec.js +0 -18
- package/dist/types/BooleanType.spec.js.map +0 -1
- package/dist/types/BuiltInInterfaceAdder.spec.d.ts +0 -1
- package/dist/types/BuiltInInterfaceAdder.spec.js +0 -115
- package/dist/types/BuiltInInterfaceAdder.spec.js.map +0 -1
- package/dist/types/ClassType.spec.d.ts +0 -1
- package/dist/types/ClassType.spec.js +0 -76
- package/dist/types/ClassType.spec.js.map +0 -1
- package/dist/types/DoubleType.spec.d.ts +0 -1
- package/dist/types/DoubleType.spec.js +0 -20
- package/dist/types/DoubleType.spec.js.map +0 -1
- package/dist/types/DynamicType.spec.d.ts +0 -1
- package/dist/types/DynamicType.spec.js +0 -23
- package/dist/types/DynamicType.spec.js.map +0 -1
- package/dist/types/EnumType.spec.d.ts +0 -1
- package/dist/types/EnumType.spec.js +0 -33
- package/dist/types/EnumType.spec.js.map +0 -1
- package/dist/types/FloatType.spec.d.ts +0 -1
- package/dist/types/FloatType.spec.js +0 -12
- package/dist/types/FloatType.spec.js.map +0 -1
- package/dist/types/IntegerType.spec.d.ts +0 -1
- package/dist/types/IntegerType.spec.js +0 -16
- package/dist/types/IntegerType.spec.js.map +0 -1
- package/dist/types/InterfaceType.spec.d.ts +0 -1
- package/dist/types/InterfaceType.spec.js +0 -227
- package/dist/types/InterfaceType.spec.js.map +0 -1
- package/dist/types/IntersectionType.spec.d.ts +0 -1
- package/dist/types/IntersectionType.spec.js +0 -150
- package/dist/types/IntersectionType.spec.js.map +0 -1
- package/dist/types/InvalidType.spec.d.ts +0 -1
- package/dist/types/InvalidType.spec.js +0 -16
- package/dist/types/InvalidType.spec.js.map +0 -1
- package/dist/types/LongIntegerType.spec.d.ts +0 -1
- package/dist/types/LongIntegerType.spec.js +0 -18
- package/dist/types/LongIntegerType.spec.js.map +0 -1
- package/dist/types/ObjectType.spec.d.ts +0 -1
- package/dist/types/ObjectType.spec.js +0 -12
- package/dist/types/ObjectType.spec.js.map +0 -1
- package/dist/types/ReferenceType.spec.d.ts +0 -1
- package/dist/types/ReferenceType.spec.js +0 -151
- package/dist/types/ReferenceType.spec.js.map +0 -1
- package/dist/types/StringType.spec.d.ts +0 -1
- package/dist/types/StringType.spec.js +0 -12
- package/dist/types/StringType.spec.js.map +0 -1
- package/dist/types/TypedFunctionType.spec.d.ts +0 -1
- package/dist/types/TypedFunctionType.spec.js +0 -122
- package/dist/types/TypedFunctionType.spec.js.map +0 -1
- package/dist/types/UnionType.spec.d.ts +0 -1
- package/dist/types/UnionType.spec.js +0 -205
- package/dist/types/UnionType.spec.js.map +0 -1
- package/dist/types/VoidType.spec.d.ts +0 -1
- package/dist/types/VoidType.spec.js +0 -12
- package/dist/types/VoidType.spec.js.map +0 -1
- package/dist/types/helper.spec.d.ts +0 -1
- package/dist/types/helper.spec.js +0 -174
- package/dist/types/helper.spec.js.map +0 -1
- package/dist/types/roFunctionType.spec.d.ts +0 -1
- package/dist/types/roFunctionType.spec.js +0 -20
- package/dist/types/roFunctionType.spec.js.map +0 -1
|
@@ -1,1173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const chai_config_spec_1 = require("../chai-config.spec");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const sinonImport = require("sinon");
|
|
6
|
-
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
7
|
-
const fsExtra = require("fs-extra");
|
|
8
|
-
const DiagnosticMessages_1 = require("../DiagnosticMessages");
|
|
9
|
-
const Program_1 = require("../Program");
|
|
10
|
-
const XmlFile_1 = require("./XmlFile");
|
|
11
|
-
const util_1 = require("../util");
|
|
12
|
-
const testHelpers_spec_1 = require("../testHelpers.spec");
|
|
13
|
-
const ProgramBuilder_1 = require("../ProgramBuilder");
|
|
14
|
-
const logging_1 = require("../logging");
|
|
15
|
-
const reflection_1 = require("../astUtils/reflection");
|
|
16
|
-
const testHelpers_spec_2 = require("../testHelpers.spec");
|
|
17
|
-
describe('XmlFile', () => {
|
|
18
|
-
let program;
|
|
19
|
-
let sinon = sinonImport.createSandbox();
|
|
20
|
-
let file;
|
|
21
|
-
let testTranspile = (0, testHelpers_spec_1.getTestTranspile)(() => [program, testHelpers_spec_2.rootDir]);
|
|
22
|
-
beforeEach(() => {
|
|
23
|
-
fsExtra.emptyDirSync(testHelpers_spec_2.tempDir);
|
|
24
|
-
fsExtra.ensureDirSync(testHelpers_spec_2.rootDir);
|
|
25
|
-
fsExtra.ensureDirSync(testHelpers_spec_2.outDir);
|
|
26
|
-
program = new Program_1.Program({ rootDir: testHelpers_spec_2.rootDir, outDir: testHelpers_spec_2.outDir });
|
|
27
|
-
file = new XmlFile_1.XmlFile({
|
|
28
|
-
srcPath: `${testHelpers_spec_2.rootDir}/components/MainComponent.xml`,
|
|
29
|
-
destPath: 'components/MainComponent.xml',
|
|
30
|
-
program: program
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
afterEach(() => {
|
|
34
|
-
sinon.restore();
|
|
35
|
-
program.dispose();
|
|
36
|
-
});
|
|
37
|
-
describe('parse', () => {
|
|
38
|
-
it('allows modifying the parsed XML model', () => {
|
|
39
|
-
const expected = 'OtherName';
|
|
40
|
-
program.plugins.add({
|
|
41
|
-
name: 'allows modifying the parsed XML model',
|
|
42
|
-
afterProvideFile: (event) => {
|
|
43
|
-
var _a, _b, _c;
|
|
44
|
-
const file = event.files[0];
|
|
45
|
-
if ((0, reflection_1.isXmlFile)(file) && ((_c = (_b = (_a = file.parser.ast.rootElement) === null || _a === void 0 ? void 0 : _a.attributes) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.value)) {
|
|
46
|
-
file.parser.ast.rootElement.attributes[0].value = expected;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
file = program.setFile('components/ChildScene.xml', (0, testHelpers_spec_1.trim) `
|
|
51
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
52
|
-
<component name="ChildScene" extends="Scene">
|
|
53
|
-
</component>
|
|
54
|
-
`);
|
|
55
|
-
(0, chai_config_spec_1.expect)(file.componentName.text).to.equal(expected);
|
|
56
|
-
});
|
|
57
|
-
it('only removes specified attribute when calling setAttribute', () => {
|
|
58
|
-
const file = new XmlFile_1.XmlFile({ srcPath: 'abs', destPath: 'rel', program: program });
|
|
59
|
-
program.plugins.add({
|
|
60
|
-
name: 'allows modifying the parsed XML model',
|
|
61
|
-
afterProvideFile: () => {
|
|
62
|
-
let child = file.parser.ast.componentElement.childrenElement.elements[0];
|
|
63
|
-
(0, chai_config_spec_1.expect)(child.attributes).to.have.lengthOf(4);
|
|
64
|
-
child.setAttributeValue('text', undefined);
|
|
65
|
-
(0, chai_config_spec_1.expect)(child.getAttribute('id').value).to.equal('one');
|
|
66
|
-
(0, chai_config_spec_1.expect)(child.attributes).to.have.lengthOf(3);
|
|
67
|
-
child.setAttributeValue('text3', undefined);
|
|
68
|
-
(0, chai_config_spec_1.expect)(child.getAttribute('id').value).to.equal('one');
|
|
69
|
-
(0, chai_config_spec_1.expect)(child.attributes).to.have.lengthOf(2);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
file.parse((0, testHelpers_spec_1.trim) `
|
|
73
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
74
|
-
<component name="ChildScene" extends="Scene">
|
|
75
|
-
<script type="text/brightscript" uri="ChildScene1.brs" /> <script type="text/brightscript" uri="ChildScene2.brs" /> <script type="text/brightscript" uri="ChildScene3.brs" />
|
|
76
|
-
<children>
|
|
77
|
-
<Label id="one"
|
|
78
|
-
text="two"
|
|
79
|
-
text2="three"
|
|
80
|
-
text3="four"
|
|
81
|
-
/>
|
|
82
|
-
</children>
|
|
83
|
-
</component>
|
|
84
|
-
`);
|
|
85
|
-
});
|
|
86
|
-
it('supports importing BrighterScript files', () => {
|
|
87
|
-
file = program.setFile('components/custom.xml', (0, testHelpers_spec_1.trim) `
|
|
88
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
89
|
-
<component name="ChildScene" extends="Scene">
|
|
90
|
-
<script type="text/brightscript" uri="ChildScene.bs" />
|
|
91
|
-
</component>
|
|
92
|
-
`);
|
|
93
|
-
(0, chai_config_spec_1.expect)(file.scriptTagImports.map(x => x.destPath)[0]).to.equal((0, util_1.standardizePath) `components/ChildScene.bs`);
|
|
94
|
-
});
|
|
95
|
-
it('does not include commented-out script imports', () => {
|
|
96
|
-
var _a, _b;
|
|
97
|
-
file = program.setFile('components/custom.xml', (0, testHelpers_spec_1.trim) `
|
|
98
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
99
|
-
<component name="ChildScene" extends="Scene">
|
|
100
|
-
<script type="text/brightscript" uri="ChildScene.brs" />
|
|
101
|
-
<!--
|
|
102
|
-
<script type="text/brightscript" uri="ChildScene.brs" />
|
|
103
|
-
-->
|
|
104
|
-
</component>
|
|
105
|
-
`);
|
|
106
|
-
(0, chai_config_spec_1.expect)((_b = (_a = file.scriptTagImports) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.destPath).to.eql((0, util_1.standardizePath) `components/ChildScene.brs`);
|
|
107
|
-
});
|
|
108
|
-
it('finds scripts when more than one per line', () => {
|
|
109
|
-
file = new XmlFile_1.XmlFile({ srcPath: 'abs', destPath: 'rel', program: program });
|
|
110
|
-
file.parse((0, testHelpers_spec_1.trim) `
|
|
111
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
112
|
-
<component name="ChildScene" extends="Scene">
|
|
113
|
-
<script type="text/brightscript" uri="ChildScene1.brs" /> <script type="text/brightscript" uri="ChildScene2.brs" /> <script type="text/brightscript" uri="ChildScene3.brs" />
|
|
114
|
-
</component>
|
|
115
|
-
`);
|
|
116
|
-
(0, chai_config_spec_1.expect)(file.scriptTagImports).to.be.lengthOf(3);
|
|
117
|
-
(0, chai_config_spec_1.expect)(file.scriptTagImports[0]).to.deep.include({
|
|
118
|
-
text: 'ChildScene1.brs',
|
|
119
|
-
filePathRange: vscode_languageserver_1.Range.create(2, 42, 2, 57)
|
|
120
|
-
});
|
|
121
|
-
(0, chai_config_spec_1.expect)(file.scriptTagImports[1]).to.deep.include({
|
|
122
|
-
text: 'ChildScene2.brs',
|
|
123
|
-
filePathRange: vscode_languageserver_1.Range.create(2, 100, 2, 115)
|
|
124
|
-
});
|
|
125
|
-
(0, chai_config_spec_1.expect)(file.scriptTagImports[2]).to.deep.include({
|
|
126
|
-
text: 'ChildScene3.brs',
|
|
127
|
-
filePathRange: vscode_languageserver_1.Range.create(2, 158, 2, 173)
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
it('finds component names', () => {
|
|
131
|
-
file = new XmlFile_1.XmlFile({ srcPath: 'abs', destPath: 'rel', program: program });
|
|
132
|
-
file.parse((0, testHelpers_spec_1.trim) `
|
|
133
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
134
|
-
<component name="ChildScene" extends="ParentScene">
|
|
135
|
-
<script type="text/brightscript" uri="ChildScene.brs" />
|
|
136
|
-
</component>
|
|
137
|
-
`);
|
|
138
|
-
(0, chai_config_spec_1.expect)(file.parentComponentName.text).to.equal('ParentScene');
|
|
139
|
-
(0, chai_config_spec_1.expect)(file.componentName.text).to.equal('ChildScene');
|
|
140
|
-
});
|
|
141
|
-
it('Adds error when whitespace appears before the prolog', () => {
|
|
142
|
-
file = new XmlFile_1.XmlFile({ srcPath: 'abs', destPath: 'rel', program: program });
|
|
143
|
-
file.parse(/* not trimmed */ `
|
|
144
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
145
|
-
<component name="ChildScene" extends="ParentScene">
|
|
146
|
-
<script type="text/brightscript" uri="ChildScene.brs" />
|
|
147
|
-
</component>`);
|
|
148
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [{
|
|
149
|
-
code: DiagnosticMessages_1.DiagnosticMessages.syntaxError('').code,
|
|
150
|
-
location: { range: vscode_languageserver_1.Range.create(1, 16, 1, 22) }
|
|
151
|
-
}, Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.syntaxError('Syntax error: whitespace found before the XML prolog')), { location: { range: vscode_languageserver_1.Range.create(0, 0, 1, 16) } })]);
|
|
152
|
-
});
|
|
153
|
-
it('Adds error when an unknown tag is found in xml', () => {
|
|
154
|
-
file = new XmlFile_1.XmlFile({ srcPath: 'abs', destPath: 'rel', program: program });
|
|
155
|
-
file.parse((0, testHelpers_spec_1.trim) `
|
|
156
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
157
|
-
<component name="ChildScene" extends="ParentScene">
|
|
158
|
-
<interface>
|
|
159
|
-
<unexpected />
|
|
160
|
-
</interface>
|
|
161
|
-
<unexpectedToo />
|
|
162
|
-
</component>
|
|
163
|
-
`);
|
|
164
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.xmlUnexpectedTag('unexpected')), { location: { range: vscode_languageserver_1.Range.create(3, 9, 3, 19) } }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.xmlUnexpectedTag('unexpectedToo')), { location: { range: vscode_languageserver_1.Range.create(5, 5, 5, 18) } })]);
|
|
165
|
-
});
|
|
166
|
-
it('Adds error when no component is declared in xml', () => {
|
|
167
|
-
program.setFile('components/comp.xml', '<script type="text/brightscript" uri="ChildScene.brs" />');
|
|
168
|
-
program.validate();
|
|
169
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [
|
|
170
|
-
Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.xmlUnexpectedTag('script')), { location: { range: vscode_languageserver_1.Range.create(0, 1, 0, 7) } }),
|
|
171
|
-
DiagnosticMessages_1.DiagnosticMessages.xmlComponentMissingComponentDeclaration()
|
|
172
|
-
]);
|
|
173
|
-
});
|
|
174
|
-
it('adds error when component does not declare a name', () => {
|
|
175
|
-
file = program.setFile('components/comp.xml', (0, testHelpers_spec_1.trim) `
|
|
176
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
177
|
-
<component extends="ParentScene">
|
|
178
|
-
<script type="text/brightscript" uri="ChildScene.brs" />
|
|
179
|
-
</component>
|
|
180
|
-
`);
|
|
181
|
-
program.validate();
|
|
182
|
-
(0, testHelpers_spec_1.expectDiagnosticsIncludes)(program, [{
|
|
183
|
-
message: DiagnosticMessages_1.DiagnosticMessages.xmlComponentMissingNameAttribute().message,
|
|
184
|
-
location: { range: vscode_languageserver_1.Range.create(1, 1, 1, 10) }
|
|
185
|
-
}]);
|
|
186
|
-
});
|
|
187
|
-
it('catches xml parse errors', () => {
|
|
188
|
-
file = program.setFile('components/comp.xml', (0, testHelpers_spec_1.trim) `
|
|
189
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
190
|
-
<component 1extends="ParentScene">
|
|
191
|
-
</component>
|
|
192
|
-
`);
|
|
193
|
-
program.validate();
|
|
194
|
-
const diagnostics = program.getDiagnostics();
|
|
195
|
-
(0, chai_config_spec_1.expect)(diagnostics).to.be.lengthOf(2);
|
|
196
|
-
(0, chai_config_spec_1.expect)(diagnostics[0].code).to.equal(DiagnosticMessages_1.DiagnosticMessages.syntaxError('').code); //unexpected character '1'
|
|
197
|
-
(0, chai_config_spec_1.expect)(diagnostics[1]).to.deep.include({
|
|
198
|
-
code: DiagnosticMessages_1.DiagnosticMessages.xmlComponentMissingNameAttribute().code,
|
|
199
|
-
location: util_1.default.createLocationFromFileRange(file, vscode_languageserver_1.Range.create(1, 1, 1, 10))
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
it('finds script imports', () => {
|
|
203
|
-
file = new XmlFile_1.XmlFile({ srcPath: 'abspath/components/cmp1.xml', destPath: 'components/cmp1.xml', program: program });
|
|
204
|
-
file.parse((0, testHelpers_spec_1.trim) `
|
|
205
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
206
|
-
<component name="Cmp1" extends="Scene">
|
|
207
|
-
<script type="text/brightscript" uri="pkg:/components/cmp1.brs" />
|
|
208
|
-
</component>
|
|
209
|
-
`);
|
|
210
|
-
(0, chai_config_spec_1.expect)(file.scriptTagImports.length).to.equal(1);
|
|
211
|
-
(0, chai_config_spec_1.expect)(file.scriptTagImports[0]).to.deep.include({
|
|
212
|
-
sourceFile: file,
|
|
213
|
-
text: 'pkg:/components/cmp1.brs',
|
|
214
|
-
destPath: `components${path.sep}cmp1.brs`,
|
|
215
|
-
filePathRange: vscode_languageserver_1.Range.create(2, 42, 2, 66)
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
it('throws an error if the file has already been parsed', () => {
|
|
219
|
-
file = new XmlFile_1.XmlFile({ srcPath: 'abspath', destPath: 'relpath', program: program });
|
|
220
|
-
file.parse('a comment');
|
|
221
|
-
try {
|
|
222
|
-
file.parse(`'a new comment`);
|
|
223
|
-
chai_config_spec_1.assert.fail(null, null, 'Should have thrown an exception, but did not');
|
|
224
|
-
}
|
|
225
|
-
catch (e) {
|
|
226
|
-
//test passes
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
it('resolves relative paths', () => {
|
|
230
|
-
file = program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
|
|
231
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
232
|
-
<component name="Cmp1" extends="Scene">
|
|
233
|
-
<script type="text/brightscript" uri="cmp1.brs" />
|
|
234
|
-
</component>
|
|
235
|
-
`);
|
|
236
|
-
(0, chai_config_spec_1.expect)(file.scriptTagImports.length).to.equal(1);
|
|
237
|
-
(0, chai_config_spec_1.expect)(file.scriptTagImports[0]).to.deep.include({
|
|
238
|
-
text: 'cmp1.brs',
|
|
239
|
-
destPath: `components${path.sep}cmp1.brs`
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
it('finds correct position for empty uri in script tag', () => {
|
|
243
|
-
var _a;
|
|
244
|
-
file = program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
|
|
245
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
246
|
-
<component name="Cmp1" extends="Scene">
|
|
247
|
-
<script type="text/brightscript" uri="" />
|
|
248
|
-
</component>
|
|
249
|
-
`);
|
|
250
|
-
(0, chai_config_spec_1.expect)(file.scriptTagImports.length).to.equal(1);
|
|
251
|
-
(0, chai_config_spec_1.expect)((_a = file.scriptTagImports[0]) === null || _a === void 0 ? void 0 : _a.filePathRange).to.eql(vscode_languageserver_1.Range.create(2, 42, 2, 42));
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
describe('doesReferenceFile', () => {
|
|
255
|
-
it('compares case insensitive', () => {
|
|
256
|
-
let xmlFile = program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
|
|
257
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
258
|
-
<component name="Cmp1" extends="Scene">
|
|
259
|
-
<script type="text/brightscript" uri="HeroGrid.brs" />
|
|
260
|
-
</component>
|
|
261
|
-
`);
|
|
262
|
-
let brsFile = program.setFile(`components/HEROGRID.brs`, ``);
|
|
263
|
-
(0, chai_config_spec_1.expect)(xmlFile.doesReferenceFile(brsFile)).to.be.true;
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
describe('autoImportComponentScript', () => {
|
|
267
|
-
it('is not enabled by default', () => {
|
|
268
|
-
program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
|
|
269
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
270
|
-
<component name="ParentScene" extends="GrandparentScene">
|
|
271
|
-
<script type="text/brightscript" uri="./lib.brs" />
|
|
272
|
-
</component>
|
|
273
|
-
`);
|
|
274
|
-
program.setFile('components/lib.brs', `
|
|
275
|
-
function libFunc()
|
|
276
|
-
end function
|
|
277
|
-
`);
|
|
278
|
-
program.setFile('components/comp1.bs', `
|
|
279
|
-
function init()
|
|
280
|
-
libFunc()
|
|
281
|
-
end function
|
|
282
|
-
`);
|
|
283
|
-
program.validate();
|
|
284
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [
|
|
285
|
-
DiagnosticMessages_1.DiagnosticMessages.fileNotReferencedByAnyOtherFile()
|
|
286
|
-
]);
|
|
287
|
-
});
|
|
288
|
-
it('is not enabled by default', () => {
|
|
289
|
-
program = new Program_1.Program({
|
|
290
|
-
rootDir: testHelpers_spec_2.rootDir,
|
|
291
|
-
autoImportComponentScript: true
|
|
292
|
-
});
|
|
293
|
-
program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
|
|
294
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
295
|
-
<component name="ParentScene" extends="GrandparentScene">
|
|
296
|
-
<script type="text/brightscript" uri="./lib.brs" />
|
|
297
|
-
</component>
|
|
298
|
-
`);
|
|
299
|
-
program.setFile('components/lib.brs', `
|
|
300
|
-
function libFunc()
|
|
301
|
-
end function
|
|
302
|
-
`);
|
|
303
|
-
program.setFile('components/comp1.bs', `
|
|
304
|
-
function init()
|
|
305
|
-
libFunc()
|
|
306
|
-
end function
|
|
307
|
-
`);
|
|
308
|
-
program.validate();
|
|
309
|
-
//there should be no errors
|
|
310
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
describe('getAllDependencies', () => {
|
|
314
|
-
it('returns own imports', () => {
|
|
315
|
-
file = program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
|
|
316
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
317
|
-
<component name="ChildScene" extends="BaseScene">
|
|
318
|
-
<script type="text/brightscript" uri="pkg:/source/lib.brs" />
|
|
319
|
-
</component>
|
|
320
|
-
`);
|
|
321
|
-
(0, chai_config_spec_1.expect)(file.getOwnDependencies().sort()).to.eql([
|
|
322
|
-
(0, util_1.standardizePath) `source/lib.brs`,
|
|
323
|
-
(0, util_1.standardizePath) `source/lib.d.bs`
|
|
324
|
-
]);
|
|
325
|
-
});
|
|
326
|
-
});
|
|
327
|
-
it('invalidates dependent scopes on change', () => {
|
|
328
|
-
let xmlFile = program.setFile({
|
|
329
|
-
src: `${testHelpers_spec_2.rootDir}/components/comp1.xml`,
|
|
330
|
-
dest: `components/comp1.xml`
|
|
331
|
-
}, (0, testHelpers_spec_1.trim) `
|
|
332
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
333
|
-
<component name="ChildScene" extends="BaseScene">
|
|
334
|
-
<script type="text/brightscript" uri="pkg:/source/lib.bs" />
|
|
335
|
-
</component>
|
|
336
|
-
`);
|
|
337
|
-
program.validate();
|
|
338
|
-
let scope = program.getScopesForFile(xmlFile)[0];
|
|
339
|
-
//scope should be validated
|
|
340
|
-
(0, chai_config_spec_1.expect)(scope.isValidated);
|
|
341
|
-
//add lib1
|
|
342
|
-
program.setFile(`source/lib.bs`, ``);
|
|
343
|
-
//adding a dependent file should have invalidated the scope
|
|
344
|
-
(0, chai_config_spec_1.expect)(scope.isValidated).to.be.false;
|
|
345
|
-
program.validate();
|
|
346
|
-
(0, chai_config_spec_1.expect)(scope.isValidated).to.be.true;
|
|
347
|
-
//update lib1 to include an import
|
|
348
|
-
program.setFile(`source/lib.bs`, `
|
|
349
|
-
import "lib2.bs"
|
|
350
|
-
`);
|
|
351
|
-
//scope should have been invalidated again
|
|
352
|
-
(0, chai_config_spec_1.expect)(scope.isValidated).to.be.false;
|
|
353
|
-
program.validate();
|
|
354
|
-
(0, chai_config_spec_1.expect)(scope.isValidated).to.be.true;
|
|
355
|
-
//add the lib2 imported from lib
|
|
356
|
-
program.setFile(`source/lib2.bs`, ``);
|
|
357
|
-
//scope should have been invalidated again because of chained dependency
|
|
358
|
-
(0, chai_config_spec_1.expect)(scope.isValidated).to.be.false;
|
|
359
|
-
program.validate();
|
|
360
|
-
(0, chai_config_spec_1.expect)(scope.isValidated).to.be.true;
|
|
361
|
-
program.removeFile(`${testHelpers_spec_2.rootDir}/source/lib.bs`);
|
|
362
|
-
(0, chai_config_spec_1.expect)(scope.isValidated).to.be.false;
|
|
363
|
-
});
|
|
364
|
-
it('does not invalidate unrelated scopes on change', () => {
|
|
365
|
-
let xmlFile1 = program.setFile({
|
|
366
|
-
src: `${testHelpers_spec_2.rootDir}/components/comp1.xml`,
|
|
367
|
-
dest: `components/comp1.xml`
|
|
368
|
-
}, (0, testHelpers_spec_1.trim) `
|
|
369
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
370
|
-
<component name="ChildScene1" extends="BaseScene">
|
|
371
|
-
<script type="text/brightscript" uri="pkg:/source/lib.brs" />
|
|
372
|
-
</component>
|
|
373
|
-
`);
|
|
374
|
-
let xmlFile2 = program.setFile({
|
|
375
|
-
src: `${testHelpers_spec_2.rootDir}/components/comp2.xml`,
|
|
376
|
-
dest: `components/comp2.xml`
|
|
377
|
-
}, (0, testHelpers_spec_1.trim) `
|
|
378
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
379
|
-
<component name="ChildScene2" extends="BaseScene">
|
|
380
|
-
</component>
|
|
381
|
-
`);
|
|
382
|
-
program.validate();
|
|
383
|
-
//scope should be validated
|
|
384
|
-
(0, chai_config_spec_1.expect)(program.getScopesForFile(xmlFile1)[0].isValidated).to.be.true;
|
|
385
|
-
(0, chai_config_spec_1.expect)(program.getScopesForFile(xmlFile2)[0].isValidated).to.be.true;
|
|
386
|
-
//add the lib file
|
|
387
|
-
program.setFile(`source/lib.brs`, ``);
|
|
388
|
-
(0, chai_config_spec_1.expect)(program.getScopesForFile(xmlFile1)[0].isValidated).to.be.false;
|
|
389
|
-
(0, chai_config_spec_1.expect)(program.getScopesForFile(xmlFile2)[0].isValidated).to.be.true;
|
|
390
|
-
});
|
|
391
|
-
describe('component extends', () => {
|
|
392
|
-
it('works for single-line', () => {
|
|
393
|
-
var _a;
|
|
394
|
-
file = program.setFile({
|
|
395
|
-
src: `${testHelpers_spec_2.rootDir}/components/comp1.xml`,
|
|
396
|
-
dest: `components/comp1.xml`
|
|
397
|
-
}, (0, testHelpers_spec_1.trim) `
|
|
398
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
399
|
-
<component name="ChildScene" extends="BaseScene">
|
|
400
|
-
</component>
|
|
401
|
-
`);
|
|
402
|
-
(0, chai_config_spec_1.expect)((_a = file.parentComponentName.location) === null || _a === void 0 ? void 0 : _a.range).to.eql(vscode_languageserver_1.Range.create(1, 38, 1, 47));
|
|
403
|
-
});
|
|
404
|
-
it('works for multi-line', () => {
|
|
405
|
-
var _a;
|
|
406
|
-
file = program.setFile({
|
|
407
|
-
src: `${testHelpers_spec_2.rootDir}/components/comp1.xml`,
|
|
408
|
-
dest: `components/comp1.xml`
|
|
409
|
-
}, (0, testHelpers_spec_1.trim) `
|
|
410
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
411
|
-
<component name="ChildScene"
|
|
412
|
-
extends="BaseScene">
|
|
413
|
-
</component>
|
|
414
|
-
`);
|
|
415
|
-
(0, chai_config_spec_1.expect)((_a = file.parentComponentName.location) === null || _a === void 0 ? void 0 : _a.range).to.eql(vscode_languageserver_1.Range.create(2, 13, 2, 22));
|
|
416
|
-
});
|
|
417
|
-
it('does not throw when unable to find extends', () => {
|
|
418
|
-
file = program.setFile({
|
|
419
|
-
src: `${testHelpers_spec_2.rootDir}/components/comp1.xml`,
|
|
420
|
-
dest: `components/comp1.xml`
|
|
421
|
-
}, (0, testHelpers_spec_1.trim) `
|
|
422
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
423
|
-
<component name="ChildScene">
|
|
424
|
-
</component>
|
|
425
|
-
`);
|
|
426
|
-
(0, chai_config_spec_1.expect)(file.parentComponentName).to.not.exist;
|
|
427
|
-
});
|
|
428
|
-
it('adds warning when no "extends" attribute is found', () => {
|
|
429
|
-
program.setFile({
|
|
430
|
-
src: `${testHelpers_spec_2.rootDir}/components/comp1.xml`,
|
|
431
|
-
dest: `components/comp1.xml`
|
|
432
|
-
}, (0, testHelpers_spec_1.trim) `
|
|
433
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
434
|
-
<component name="ChildScene">
|
|
435
|
-
</component>
|
|
436
|
-
`);
|
|
437
|
-
program.validate();
|
|
438
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [
|
|
439
|
-
DiagnosticMessages_1.DiagnosticMessages.xmlComponentMissingExtendsAttribute()
|
|
440
|
-
]);
|
|
441
|
-
});
|
|
442
|
-
});
|
|
443
|
-
describe('transpile', () => {
|
|
444
|
-
it('handles single quotes properly', async () => {
|
|
445
|
-
await testTranspile((0, testHelpers_spec_1.trim) `
|
|
446
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
447
|
-
<component name="AnimationExample" extends="Scene">
|
|
448
|
-
<children>
|
|
449
|
-
<Animated frames='["pkg:/images/animation-1.png"]' />
|
|
450
|
-
</children>
|
|
451
|
-
</component>
|
|
452
|
-
`, (0, testHelpers_spec_1.trim) `
|
|
453
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
454
|
-
<component name="AnimationExample" extends="Scene">
|
|
455
|
-
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
|
456
|
-
<children>
|
|
457
|
-
<Animated frames='["pkg:/images/animation-1.png"]' />
|
|
458
|
-
</children>
|
|
459
|
-
</component>
|
|
460
|
-
`, 'none', 'components/Comp.xml');
|
|
461
|
-
});
|
|
462
|
-
it('supports instantresume <customization> elements', async () => {
|
|
463
|
-
fsExtra.outputFileSync(`${testHelpers_spec_2.rootDir}/manifest`, '');
|
|
464
|
-
fsExtra.outputFileSync(`${testHelpers_spec_2.rootDir}/source/main.brs`, `sub main()\nend sub`);
|
|
465
|
-
fsExtra.outputFileSync(`${testHelpers_spec_2.rootDir}/components/MainScene.xml`, (0, testHelpers_spec_1.trim) `
|
|
466
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
467
|
-
<component name="MainScene" extends="Scene">
|
|
468
|
-
<customization resumehandler="customResume" />
|
|
469
|
-
<customization suspendhandler="customSuspend" />
|
|
470
|
-
<children>
|
|
471
|
-
<Rectangle width="1920" height="1080" />
|
|
472
|
-
</children>
|
|
473
|
-
</component>
|
|
474
|
-
`);
|
|
475
|
-
const builder = new ProgramBuilder_1.ProgramBuilder();
|
|
476
|
-
await builder.run({
|
|
477
|
-
cwd: testHelpers_spec_2.rootDir,
|
|
478
|
-
outDir: testHelpers_spec_2.outDir,
|
|
479
|
-
logLevel: logging_1.LogLevel.off
|
|
480
|
-
});
|
|
481
|
-
(0, chai_config_spec_1.expect)((0, testHelpers_spec_1.trim)(fsExtra.readFileSync(`${testHelpers_spec_2.outDir}/components/MainScene.xml`).toString())).to.eql((0, testHelpers_spec_1.trim) `
|
|
482
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
483
|
-
<component name="MainScene" extends="Scene">
|
|
484
|
-
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
|
485
|
-
<customization resumehandler="customResume" />
|
|
486
|
-
<customization suspendhandler="customSuspend" />
|
|
487
|
-
<children>
|
|
488
|
-
<Rectangle width="1920" height="1080" />
|
|
489
|
-
</children>
|
|
490
|
-
</component>
|
|
491
|
-
`);
|
|
492
|
-
});
|
|
493
|
-
it(`honors the 'needsTranspiled' flag when set in 'afterProvideFile'`, () => {
|
|
494
|
-
program.plugins.add({
|
|
495
|
-
name: 'test',
|
|
496
|
-
afterProvideFile: (event) => {
|
|
497
|
-
//enable transpile for every file
|
|
498
|
-
event.files[0].needsTranspiled = true;
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
const file = program.setFile('components/file.xml', (0, testHelpers_spec_1.trim) `
|
|
502
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
503
|
-
<component name="Comp" extends="Group">
|
|
504
|
-
</component>
|
|
505
|
-
`);
|
|
506
|
-
(0, chai_config_spec_1.expect)(file['needsTranspiled']).to.be.true;
|
|
507
|
-
});
|
|
508
|
-
it('includes bslib script', async () => {
|
|
509
|
-
await testTranspile((0, testHelpers_spec_1.trim) `
|
|
510
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
511
|
-
<component name="Comp" extends="Group">
|
|
512
|
-
</component>
|
|
513
|
-
`, (0, testHelpers_spec_1.trim) `
|
|
514
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
515
|
-
<component name="Comp" extends="Group">
|
|
516
|
-
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
|
517
|
-
</component>
|
|
518
|
-
`, 'none', 'components/Comp.xml');
|
|
519
|
-
});
|
|
520
|
-
it('does not include additional bslib script if already there ', async () => {
|
|
521
|
-
await testTranspile((0, testHelpers_spec_1.trim) `
|
|
522
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
523
|
-
<component name="Comp" extends="Group">
|
|
524
|
-
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
|
525
|
-
</component>
|
|
526
|
-
`, (0, testHelpers_spec_1.trim) `
|
|
527
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
528
|
-
<component name="Comp" extends="Group">
|
|
529
|
-
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
|
530
|
-
</component>
|
|
531
|
-
`, 'none', 'components/child.xml');
|
|
532
|
-
});
|
|
533
|
-
it('does not include bslib script if already there from ropm', async () => {
|
|
534
|
-
program.setFile('source/roku_modules/bslib/bslib.brs', ``);
|
|
535
|
-
program.setFile('source/lib.bs', ``);
|
|
536
|
-
//include a bs file to force transpile for the xml file
|
|
537
|
-
await testTranspile((0, testHelpers_spec_1.trim) `
|
|
538
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
539
|
-
<component name="Comp" extends="Group">
|
|
540
|
-
<script type="text/brightscript" uri="pkg:/source/lib.bs" />
|
|
541
|
-
<script type="text/brightscript" uri="pkg:/source/roku_modules/bslib/bslib.brs" />
|
|
542
|
-
</component>
|
|
543
|
-
`, (0, testHelpers_spec_1.trim) `
|
|
544
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
545
|
-
<component name="Comp" extends="Group">
|
|
546
|
-
<script type="text/brightscript" uri="pkg:/source/lib.brs" />
|
|
547
|
-
<script type="text/brightscript" uri="pkg:/source/roku_modules/bslib/bslib.brs" />
|
|
548
|
-
</component>
|
|
549
|
-
`, 'none', 'components/child.xml');
|
|
550
|
-
});
|
|
551
|
-
it('does not transpile xml file when bslib script is already present', () => {
|
|
552
|
-
const file = program.setFile('components/comp.xml', (0, testHelpers_spec_1.trim) `
|
|
553
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
554
|
-
<component name="Comp" extends="Group">
|
|
555
|
-
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
|
556
|
-
</component>
|
|
557
|
-
`);
|
|
558
|
-
program.validate();
|
|
559
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
560
|
-
(0, chai_config_spec_1.expect)(file['needsTranspiled']).to.be.false;
|
|
561
|
-
});
|
|
562
|
-
/**
|
|
563
|
-
* There was a bug that would incorrectly replace one of the script paths on the second or third transpile, so this test verifies it doesn't do that anymore
|
|
564
|
-
*/
|
|
565
|
-
it('does not mangle scripts on multiple transpile', async () => {
|
|
566
|
-
program.setFile('components/SimpleScene.bs', ``);
|
|
567
|
-
program.setFile(`components/SimpleScene.xml`, (0, testHelpers_spec_1.trim) `
|
|
568
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
569
|
-
<component name="SimpleScene" extends="Scene">
|
|
570
|
-
<script type="text/brightscript" uri="SimpleScene.bs" />
|
|
571
|
-
</component>
|
|
572
|
-
`);
|
|
573
|
-
const expected = (0, testHelpers_spec_1.trim) `
|
|
574
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
575
|
-
<component name="SimpleScene" extends="Scene">
|
|
576
|
-
<script type="text/brightscript" uri="SimpleScene.brs" />
|
|
577
|
-
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
|
578
|
-
</component>
|
|
579
|
-
`;
|
|
580
|
-
await program.build();
|
|
581
|
-
(0, chai_config_spec_1.expect)((0, testHelpers_spec_1.trim)(fsExtra.readFileSync(`${testHelpers_spec_2.outDir}/components/SimpleScene.xml`).toString())).to.eql(expected);
|
|
582
|
-
//clear the output folder
|
|
583
|
-
fsExtra.emptyDirSync(testHelpers_spec_2.outDir);
|
|
584
|
-
await program.build();
|
|
585
|
-
(0, chai_config_spec_1.expect)((0, testHelpers_spec_1.trim)(fsExtra.readFileSync(`${testHelpers_spec_2.outDir}/components/SimpleScene.xml`).toString())).to.eql(expected);
|
|
586
|
-
});
|
|
587
|
-
it('injects new scripts near existing scripts', async () => {
|
|
588
|
-
program.setFile(`components/SimpleScene.bs`, `
|
|
589
|
-
sub b()
|
|
590
|
-
end sub
|
|
591
|
-
`);
|
|
592
|
-
await testTranspile((0, testHelpers_spec_1.trim) `
|
|
593
|
-
<component name="SimpleScene" extends="group">
|
|
594
|
-
<script type="text/brightscript" uri="SimpleScene.bs"/>
|
|
595
|
-
<children>
|
|
596
|
-
<aa id="aa">
|
|
597
|
-
<bb id="bb" />
|
|
598
|
-
</aa>
|
|
599
|
-
</children>
|
|
600
|
-
</component>
|
|
601
|
-
`, (0, testHelpers_spec_1.trim) `
|
|
602
|
-
<component name="SimpleScene" extends="group">
|
|
603
|
-
<script type="text/brightscript" uri="SimpleScene.brs" />
|
|
604
|
-
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
|
605
|
-
<children>
|
|
606
|
-
<aa id="aa">
|
|
607
|
-
<bb id="bb" />
|
|
608
|
-
</aa>
|
|
609
|
-
</children>
|
|
610
|
-
</component>
|
|
611
|
-
`, 'none', 'components/SimpleScene.xml');
|
|
612
|
-
});
|
|
613
|
-
it('injects new scripts at top of component when no scripts were present', async () => {
|
|
614
|
-
program.setFile(`components/SimpleScene.bs`, `
|
|
615
|
-
sub b()
|
|
616
|
-
end sub
|
|
617
|
-
`);
|
|
618
|
-
program.options.autoImportComponentScript = true;
|
|
619
|
-
await testTranspile((0, testHelpers_spec_1.trim) `
|
|
620
|
-
<component name="SimpleScene" extends="group">
|
|
621
|
-
<children>
|
|
622
|
-
<aa id="aa">
|
|
623
|
-
<bb id="bb" />
|
|
624
|
-
</aa>
|
|
625
|
-
</children>
|
|
626
|
-
</component>
|
|
627
|
-
`, (0, testHelpers_spec_1.trim) `
|
|
628
|
-
<component name="SimpleScene" extends="group">
|
|
629
|
-
<script type="text/brightscript" uri="pkg:/components/SimpleScene.brs" />
|
|
630
|
-
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
|
631
|
-
<children>
|
|
632
|
-
<aa id="aa">
|
|
633
|
-
<bb id="bb" />
|
|
634
|
-
</aa>
|
|
635
|
-
</children>
|
|
636
|
-
</component>
|
|
637
|
-
`, 'none', 'components/SimpleScene.xml');
|
|
638
|
-
});
|
|
639
|
-
it('keeps all content of the XML', async () => {
|
|
640
|
-
program.setFile(`components/SimpleScene.bs`, `
|
|
641
|
-
sub b()
|
|
642
|
-
end sub
|
|
643
|
-
`);
|
|
644
|
-
await testTranspile((0, testHelpers_spec_1.trim) `
|
|
645
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
646
|
-
<component
|
|
647
|
-
name="SimpleScene" extends="Scene"
|
|
648
|
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
649
|
-
xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd"
|
|
650
|
-
>
|
|
651
|
-
<interface>
|
|
652
|
-
<field id="a" type="string" />
|
|
653
|
-
<function name="b" />
|
|
654
|
-
</interface>
|
|
655
|
-
<script type="text/brightscript" uri="SimpleScene.bs"/>
|
|
656
|
-
<children>
|
|
657
|
-
<aa id="aa">
|
|
658
|
-
<bb id="bb" />
|
|
659
|
-
</aa>
|
|
660
|
-
</children>
|
|
661
|
-
</component>
|
|
662
|
-
`, (0, testHelpers_spec_1.trim) `
|
|
663
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
664
|
-
<component name="SimpleScene" extends="Scene" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd">
|
|
665
|
-
<interface>
|
|
666
|
-
<field id="a" type="string" />
|
|
667
|
-
<function name="b" />
|
|
668
|
-
</interface>
|
|
669
|
-
<script type="text/brightscript" uri="SimpleScene.brs" />
|
|
670
|
-
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
|
671
|
-
<children>
|
|
672
|
-
<aa id="aa">
|
|
673
|
-
<bb id="bb" />
|
|
674
|
-
</aa>
|
|
675
|
-
</children>
|
|
676
|
-
</component>
|
|
677
|
-
`, 'none', 'components/SimpleScene.xml');
|
|
678
|
-
});
|
|
679
|
-
it('changes file extensions from bs to brs', async () => {
|
|
680
|
-
program.setFile(`components/SimpleScene.bs`, `
|
|
681
|
-
import "pkg:/source/lib.bs"
|
|
682
|
-
`);
|
|
683
|
-
program.setFile('source/lib.bs', ``);
|
|
684
|
-
await testTranspile((0, testHelpers_spec_1.trim) `
|
|
685
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
686
|
-
<component name="SimpleScene" extends="Scene">
|
|
687
|
-
<script type="text/brighterscript" uri="SimpleScene.bs"/>
|
|
688
|
-
</component>
|
|
689
|
-
`, (0, testHelpers_spec_1.trim) `
|
|
690
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
691
|
-
<component name="SimpleScene" extends="Scene">
|
|
692
|
-
<script type="text/brightscript" uri="SimpleScene.brs" />
|
|
693
|
-
<script type="text/brightscript" uri="pkg:/source/lib.brs" />
|
|
694
|
-
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
|
695
|
-
</component>
|
|
696
|
-
`, 'none', 'components/SimpleScene.xml');
|
|
697
|
-
});
|
|
698
|
-
it('does not fail on missing script type', async () => {
|
|
699
|
-
program.setFile('components/SimpleScene.brs', '');
|
|
700
|
-
await testTranspile((0, testHelpers_spec_1.trim) `
|
|
701
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
702
|
-
<component name="SimpleScene" extends="Scene">
|
|
703
|
-
<script uri="SimpleScene.brs"/>
|
|
704
|
-
</component>
|
|
705
|
-
`, (0, testHelpers_spec_1.trim) `
|
|
706
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
707
|
-
<component name="SimpleScene" extends="Scene">
|
|
708
|
-
<script uri="SimpleScene.brs" type="text/brightscript" />
|
|
709
|
-
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
|
710
|
-
</component>
|
|
711
|
-
`, null, 'components/comp.xml');
|
|
712
|
-
});
|
|
713
|
-
it('returns the XML unmodified if needsTranspiled is false', () => {
|
|
714
|
-
let file = program.setFile('components/SimpleScene.xml', (0, testHelpers_spec_1.trim) `
|
|
715
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
716
|
-
<!-- should stay as-is -->
|
|
717
|
-
<component name="SimpleScene" extends="Scene" >
|
|
718
|
-
<script type="text/brightscript" uri="SimpleScene.brs"/>
|
|
719
|
-
</component>
|
|
720
|
-
`);
|
|
721
|
-
//prevent the default auto-imports to ensure no transpilation from AST
|
|
722
|
-
file.getMissingImportsForTranspile = () => [];
|
|
723
|
-
(0, chai_config_spec_1.expect)((0, testHelpers_spec_1.trimMap)(file.transpile().code)).to.equal((0, testHelpers_spec_1.trim) `
|
|
724
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
725
|
-
<!-- should stay as-is -->
|
|
726
|
-
<component name="SimpleScene" extends="Scene" >
|
|
727
|
-
<script type="text/brightscript" uri="SimpleScene.brs"/>
|
|
728
|
-
</component>
|
|
729
|
-
`);
|
|
730
|
-
});
|
|
731
|
-
it('needsTranspiled is false by default', () => {
|
|
732
|
-
let file = program.setFile('components/SimpleScene.xml', (0, testHelpers_spec_1.trim) `
|
|
733
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
734
|
-
<component name="SimpleScene" extends="Scene" >
|
|
735
|
-
</component>
|
|
736
|
-
`);
|
|
737
|
-
(0, chai_config_spec_1.expect)(file['needsTranspiled']).to.be.false;
|
|
738
|
-
});
|
|
739
|
-
it('needsTranspiled is true if an import is brighterscript', () => {
|
|
740
|
-
let file = program.setFile('components/SimpleScene.xml', (0, testHelpers_spec_1.trim) `
|
|
741
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
742
|
-
<component name="SimpleScene" extends="Scene" >
|
|
743
|
-
<script type="text/brightscript" uri="SimpleScene.bs"/>
|
|
744
|
-
</component>
|
|
745
|
-
`);
|
|
746
|
-
(0, chai_config_spec_1.expect)(file['needsTranspiled']).to.be.true;
|
|
747
|
-
});
|
|
748
|
-
it('simple source mapping includes sourcemap reference', () => {
|
|
749
|
-
program.options.sourceMap = true;
|
|
750
|
-
let file = program.setFile('components/SimpleScene.xml', (0, testHelpers_spec_1.trim) `
|
|
751
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
752
|
-
<component name="SimpleScene" extends="Scene">
|
|
753
|
-
</component>
|
|
754
|
-
`);
|
|
755
|
-
//prevent the default auto-imports to ensure no transpilation from AST
|
|
756
|
-
file.getMissingImportsForTranspile = () => [];
|
|
757
|
-
const code = file.transpile().code;
|
|
758
|
-
(0, chai_config_spec_1.expect)(code.endsWith(`<!--//# sourceMappingURL=./SimpleScene.xml.map -->`)).to.be.true;
|
|
759
|
-
});
|
|
760
|
-
it('AST-based source mapping includes sourcemap reference', () => {
|
|
761
|
-
program.options.sourceMap = true;
|
|
762
|
-
let file = program.setFile('components/SimpleScene.xml', (0, testHelpers_spec_1.trim) `
|
|
763
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
764
|
-
<component name="SimpleScene" extends="Scene">
|
|
765
|
-
</component>
|
|
766
|
-
`);
|
|
767
|
-
file['needsTranspiled'] = true;
|
|
768
|
-
const code = file.transpile().code;
|
|
769
|
-
(0, chai_config_spec_1.expect)(code.endsWith(`<!--//# sourceMappingURL=./SimpleScene.xml.map -->`)).to.be.true;
|
|
770
|
-
});
|
|
771
|
-
it('removes script imports if given file is not publishable', async () => {
|
|
772
|
-
program.options.pruneEmptyCodeFiles = true;
|
|
773
|
-
program.setFile(`components/SimpleScene.bs`, `
|
|
774
|
-
enum simplescenetypes
|
|
775
|
-
hero
|
|
776
|
-
intro
|
|
777
|
-
end enum
|
|
778
|
-
`);
|
|
779
|
-
await testTranspile((0, testHelpers_spec_1.trim) `
|
|
780
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
781
|
-
<component
|
|
782
|
-
name="SimpleScene" extends="Scene"
|
|
783
|
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
784
|
-
xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd"
|
|
785
|
-
>
|
|
786
|
-
<script type="text/brightscript" uri="SimpleScene.bs"/>
|
|
787
|
-
</component>
|
|
788
|
-
`, (0, testHelpers_spec_1.trim) `
|
|
789
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
790
|
-
<component name="SimpleScene" extends="Scene" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd">
|
|
791
|
-
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
|
792
|
-
</component>
|
|
793
|
-
`, 'none', 'components/SimpleScene.xml');
|
|
794
|
-
});
|
|
795
|
-
it('removes extra imports found via dependencies if given file is not publishable', async () => {
|
|
796
|
-
program.options.pruneEmptyCodeFiles = true;
|
|
797
|
-
program.setFile(`source/simplescenetypes.bs`, `
|
|
798
|
-
enum SimpleSceneTypes
|
|
799
|
-
world = "world"
|
|
800
|
-
end enum
|
|
801
|
-
`);
|
|
802
|
-
program.setFile(`components/SimpleScene.bs`, `
|
|
803
|
-
import "pkg:/source/simplescenetypes.bs"
|
|
804
|
-
|
|
805
|
-
sub init()
|
|
806
|
-
? "Hello " + SimpleSceneTypes.world
|
|
807
|
-
end sub
|
|
808
|
-
`);
|
|
809
|
-
await testTranspile((0, testHelpers_spec_1.trim) `
|
|
810
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
811
|
-
<component
|
|
812
|
-
name="SimpleScene" extends="Scene"
|
|
813
|
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
814
|
-
xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd"
|
|
815
|
-
>
|
|
816
|
-
<script type="text/brightscript" uri="SimpleScene.bs"/>
|
|
817
|
-
</component>
|
|
818
|
-
`, (0, testHelpers_spec_1.trim) `
|
|
819
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
820
|
-
<component name="SimpleScene" extends="Scene" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd">
|
|
821
|
-
<script type="text/brightscript" uri="SimpleScene.brs" />
|
|
822
|
-
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
|
823
|
-
</component>
|
|
824
|
-
`, 'none', 'components/SimpleScene.xml');
|
|
825
|
-
});
|
|
826
|
-
it('removes imports of empty brightscript files', async () => {
|
|
827
|
-
program.options.pruneEmptyCodeFiles = true;
|
|
828
|
-
program.setFile(`components/EmptyFile.brs`, '');
|
|
829
|
-
program.setFile(`components/SimpleScene.brs`, `
|
|
830
|
-
sub init()
|
|
831
|
-
? "Hello World"
|
|
832
|
-
end sub
|
|
833
|
-
`);
|
|
834
|
-
await testTranspile((0, testHelpers_spec_1.trim) `
|
|
835
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
836
|
-
<component
|
|
837
|
-
name="SimpleScene" extends="Scene"
|
|
838
|
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
839
|
-
xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd"
|
|
840
|
-
>
|
|
841
|
-
<script type="text/brightscript" uri="SimpleScene.brs"/>
|
|
842
|
-
<script type="text/brightscript" uri="EmptyFile.brs"/>
|
|
843
|
-
</component>
|
|
844
|
-
`, (0, testHelpers_spec_1.trim) `
|
|
845
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
846
|
-
<component name="SimpleScene" extends="Scene" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd">
|
|
847
|
-
<script type="text/brightscript" uri="SimpleScene.brs" />
|
|
848
|
-
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
|
849
|
-
</component>
|
|
850
|
-
`, 'none', 'components/SimpleScene.xml');
|
|
851
|
-
});
|
|
852
|
-
it('includes script tags in self closing component', async () => {
|
|
853
|
-
await testTranspile((0, testHelpers_spec_1.trim) `
|
|
854
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
855
|
-
<component name="Comp" extends="Group" />
|
|
856
|
-
`, (0, testHelpers_spec_1.trim) `
|
|
857
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
858
|
-
<component name="Comp" extends="Group">
|
|
859
|
-
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
|
860
|
-
</component>
|
|
861
|
-
`, 'none', 'components/Comp.xml');
|
|
862
|
-
});
|
|
863
|
-
});
|
|
864
|
-
describe('Transform plugins', () => {
|
|
865
|
-
function parseFileWithPlugins(validateXml) {
|
|
866
|
-
const rootDir = process.cwd();
|
|
867
|
-
const program = new Program_1.Program({
|
|
868
|
-
rootDir: rootDir
|
|
869
|
-
});
|
|
870
|
-
program.plugins.add({
|
|
871
|
-
name: 'Transform plugins',
|
|
872
|
-
validateFile: event => validateXml(event.file)
|
|
873
|
-
});
|
|
874
|
-
file = program.setFile('components/component.xml', (0, testHelpers_spec_1.trim) `
|
|
875
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
876
|
-
<component name="Cmp1" extends="Scene">
|
|
877
|
-
</component>
|
|
878
|
-
`);
|
|
879
|
-
program.validate();
|
|
880
|
-
return file;
|
|
881
|
-
}
|
|
882
|
-
it('Calls XML file validation plugins', () => {
|
|
883
|
-
const validateXml = sinon.spy();
|
|
884
|
-
const file = parseFileWithPlugins(validateXml);
|
|
885
|
-
(0, chai_config_spec_1.expect)(validateXml.callCount).to.be.greaterThan(0);
|
|
886
|
-
(0, chai_config_spec_1.expect)(validateXml.getCalls().flatMap(x => x.args)).to.include(file);
|
|
887
|
-
});
|
|
888
|
-
});
|
|
889
|
-
it('plugin diagnostics work for xml files', () => {
|
|
890
|
-
program.plugins.add({
|
|
891
|
-
name: 'Xml diagnostic test',
|
|
892
|
-
afterProvideFile: (event) => {
|
|
893
|
-
for (const file of event.files) {
|
|
894
|
-
if ((0, reflection_1.isXmlFile)(file)) {
|
|
895
|
-
program.diagnostics.register({
|
|
896
|
-
message: 'Test diagnostic',
|
|
897
|
-
location: util_1.default.createLocationFromFileRange(file, vscode_languageserver_1.Range.create(0, 0, 0, 0)),
|
|
898
|
-
code: 9999
|
|
899
|
-
});
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
});
|
|
904
|
-
program.setFile('components/comp.xml', (0, testHelpers_spec_1.trim) `
|
|
905
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
906
|
-
<component name="Cmp1" extends="Scene">
|
|
907
|
-
</component>
|
|
908
|
-
`);
|
|
909
|
-
program.validate();
|
|
910
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [{
|
|
911
|
-
message: 'Test diagnostic',
|
|
912
|
-
code: 9999
|
|
913
|
-
}]);
|
|
914
|
-
});
|
|
915
|
-
describe('typedef', () => {
|
|
916
|
-
it('loads d.bs files from parent scope', () => {
|
|
917
|
-
program.setFile('components/ParentComponent.xml', (0, testHelpers_spec_1.trim) `
|
|
918
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
919
|
-
<component name="ParentComponent" extends="Scene">
|
|
920
|
-
<script uri="ParentComponent.brs" />
|
|
921
|
-
</component>
|
|
922
|
-
`);
|
|
923
|
-
program.setFile('components/ParentComponent.d.bs', `
|
|
924
|
-
import "Lib.brs"
|
|
925
|
-
namespace Parent
|
|
926
|
-
sub log()
|
|
927
|
-
end sub
|
|
928
|
-
end namespace
|
|
929
|
-
`);
|
|
930
|
-
program.setFile('components/ParentComponent.brs', `
|
|
931
|
-
sub Parent_log()
|
|
932
|
-
end sub
|
|
933
|
-
`);
|
|
934
|
-
program.setFile('components/Lib.d.bs', `
|
|
935
|
-
namespace Lib
|
|
936
|
-
sub log()
|
|
937
|
-
end sub
|
|
938
|
-
end namespace
|
|
939
|
-
`);
|
|
940
|
-
program.setFile('components/Lib.brs', `
|
|
941
|
-
sub Lib_log()
|
|
942
|
-
end sub
|
|
943
|
-
`);
|
|
944
|
-
program.setFile('components/ChildComponent.xml', (0, testHelpers_spec_1.trim) `
|
|
945
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
946
|
-
<component name="ChildComponent" extends="ParentComponent">
|
|
947
|
-
<script uri="ChildComponent.bs" />
|
|
948
|
-
</component>
|
|
949
|
-
`);
|
|
950
|
-
program.setFile('components/ChildComponent.bs', `
|
|
951
|
-
sub init()
|
|
952
|
-
Parent.log()
|
|
953
|
-
Lib.log()
|
|
954
|
-
end sub
|
|
955
|
-
`);
|
|
956
|
-
program.validate();
|
|
957
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
958
|
-
const scope = program.getComponentScope('ChildComponent');
|
|
959
|
-
(0, chai_config_spec_1.expect)([...scope.namespaceNameSet.keys()].sort()).to.eql([
|
|
960
|
-
'lib',
|
|
961
|
-
'parent'
|
|
962
|
-
]);
|
|
963
|
-
});
|
|
964
|
-
it('loads `d.bs` files into scope', () => {
|
|
965
|
-
const xmlFile = program.setFile('components/Component1.xml', (0, testHelpers_spec_1.trim) `
|
|
966
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
967
|
-
<component name="Component1" extends="Scene">
|
|
968
|
-
<script uri="Component1.brs" />
|
|
969
|
-
</component>
|
|
970
|
-
`);
|
|
971
|
-
program.setFile('components/Component1.d.bs', `
|
|
972
|
-
sub logInfo()
|
|
973
|
-
end sub
|
|
974
|
-
`);
|
|
975
|
-
(0, chai_config_spec_1.expect)(program.getScopesForFile(xmlFile)[0].getAllCallables().map(x => x.callable.name)).to.include('logInfo');
|
|
976
|
-
});
|
|
977
|
-
it('does not include `d.bs` script during transpile', async () => {
|
|
978
|
-
program.setFile('source/logger.d.bs', `
|
|
979
|
-
sub logInfo()
|
|
980
|
-
end sub
|
|
981
|
-
`);
|
|
982
|
-
program.setFile('source/logger.brs', `
|
|
983
|
-
sub logInfo()
|
|
984
|
-
end sub
|
|
985
|
-
`);
|
|
986
|
-
program.setFile('components/Component1.bs', `
|
|
987
|
-
import "pkg:/source/logger.brs"
|
|
988
|
-
sub init()
|
|
989
|
-
end sub
|
|
990
|
-
`);
|
|
991
|
-
await testTranspile((0, testHelpers_spec_1.trim) `
|
|
992
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
993
|
-
<component name="Component1" extends="Scene">
|
|
994
|
-
<script type="text/brighterscript" uri="Component1.bs" />
|
|
995
|
-
</component>
|
|
996
|
-
`, (0, testHelpers_spec_1.trim) `
|
|
997
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
998
|
-
<component name="Component1" extends="Scene">
|
|
999
|
-
<script type="text/brightscript" uri="Component1.brs" />
|
|
1000
|
-
<script type="text/brightscript" uri="pkg:/source/logger.brs" />
|
|
1001
|
-
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
|
1002
|
-
</component>
|
|
1003
|
-
`, 'none', 'components/Component1.xml');
|
|
1004
|
-
});
|
|
1005
|
-
it('does not load .brs information into scope if related d.bs is in scope', () => {
|
|
1006
|
-
const xmlFile = program.setFile('components/Component1.xml', (0, testHelpers_spec_1.trim) `
|
|
1007
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
1008
|
-
<component name="Component1" extends="Scene">
|
|
1009
|
-
<script uri="Component1.brs" />
|
|
1010
|
-
</component>
|
|
1011
|
-
`);
|
|
1012
|
-
const scope = program.getScopesForFile(xmlFile)[0];
|
|
1013
|
-
//load brs file
|
|
1014
|
-
program.setFile('components/Component1.brs', `
|
|
1015
|
-
sub logInfo()
|
|
1016
|
-
end sub
|
|
1017
|
-
sub logWarning()
|
|
1018
|
-
end sub
|
|
1019
|
-
`);
|
|
1020
|
-
let functionNames = scope.getAllCallables().map(x => x.callable.name);
|
|
1021
|
-
(0, chai_config_spec_1.expect)(functionNames).to.include('logInfo');
|
|
1022
|
-
(0, chai_config_spec_1.expect)(functionNames).to.include('logWarning');
|
|
1023
|
-
//load d.bs file, which should shadow out the .brs file
|
|
1024
|
-
program.setFile('components/Component1.d.bs', `
|
|
1025
|
-
sub logError()
|
|
1026
|
-
end sub
|
|
1027
|
-
`);
|
|
1028
|
-
functionNames = scope.getAllCallables().map(x => x.callable.name);
|
|
1029
|
-
(0, chai_config_spec_1.expect)(functionNames).to.include('logError');
|
|
1030
|
-
(0, chai_config_spec_1.expect)(functionNames).not.to.include('logInfo');
|
|
1031
|
-
(0, chai_config_spec_1.expect)(functionNames).not.to.include('logWarning');
|
|
1032
|
-
});
|
|
1033
|
-
it('updates xml scope when typedef disappears', () => {
|
|
1034
|
-
const xmlFile = program.setFile('components/Component1.xml', (0, testHelpers_spec_1.trim) `
|
|
1035
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
1036
|
-
<component name="Component1" extends="Scene">
|
|
1037
|
-
<script uri="Component1.brs" />
|
|
1038
|
-
</component>
|
|
1039
|
-
`);
|
|
1040
|
-
const scope = program.getScopesForFile(xmlFile)[0];
|
|
1041
|
-
//load brs file
|
|
1042
|
-
program.setFile('components/Component1.brs', `
|
|
1043
|
-
sub logBrs()
|
|
1044
|
-
end sub
|
|
1045
|
-
`);
|
|
1046
|
-
//load d.bs file, which should shadow out the .brs file
|
|
1047
|
-
const typedef = program.setFile('components/Component1.d.bs', `
|
|
1048
|
-
sub logTypedef()
|
|
1049
|
-
end sub
|
|
1050
|
-
`);
|
|
1051
|
-
program.validate();
|
|
1052
|
-
let functionNames = scope.getOwnCallables().map(x => x.callable.name);
|
|
1053
|
-
(0, chai_config_spec_1.expect)(functionNames).to.include('logTypedef');
|
|
1054
|
-
(0, chai_config_spec_1.expect)(functionNames).not.to.include('logBrs');
|
|
1055
|
-
//remove the typdef file
|
|
1056
|
-
program.removeFile(typedef.srcPath);
|
|
1057
|
-
program.validate();
|
|
1058
|
-
functionNames = scope.getOwnCallables().map(x => x.callable.name);
|
|
1059
|
-
(0, chai_config_spec_1.expect)(functionNames).not.to.include('logTypedef');
|
|
1060
|
-
(0, chai_config_spec_1.expect)(functionNames).to.include('logBrs');
|
|
1061
|
-
});
|
|
1062
|
-
});
|
|
1063
|
-
it('finds script imports for single-quoted script tags', () => {
|
|
1064
|
-
var _a;
|
|
1065
|
-
const file = program.setFile('components/file.xml', (0, testHelpers_spec_1.trim) `
|
|
1066
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
1067
|
-
<component name="Cmp1" extends="Scene">
|
|
1068
|
-
<script uri='SingleQuotedFile.brs' />
|
|
1069
|
-
</component>
|
|
1070
|
-
`);
|
|
1071
|
-
(0, chai_config_spec_1.expect)((_a = file.scriptTagImports[0]) === null || _a === void 0 ? void 0 : _a.text).to.eql('SingleQuotedFile.brs');
|
|
1072
|
-
});
|
|
1073
|
-
describe('commentFlags', () => {
|
|
1074
|
-
it('ignores warning from previous line comment', () => {
|
|
1075
|
-
//component without a name attribute
|
|
1076
|
-
program.setFile('components/file.xml', (0, testHelpers_spec_1.trim) `
|
|
1077
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
1078
|
-
<!--bs:disable-next-line-->
|
|
1079
|
-
<component>
|
|
1080
|
-
</component>
|
|
1081
|
-
`);
|
|
1082
|
-
program.validate();
|
|
1083
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
1084
|
-
});
|
|
1085
|
-
it('ignores a specific diagnostic on next line', () => {
|
|
1086
|
-
//component without a name attribute
|
|
1087
|
-
program.setFile('components/file.xml', (0, testHelpers_spec_1.trim) `
|
|
1088
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
1089
|
-
<!--bs:disable-next-line 1006-->
|
|
1090
|
-
<component>
|
|
1091
|
-
</component>
|
|
1092
|
-
`);
|
|
1093
|
-
program.validate();
|
|
1094
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [
|
|
1095
|
-
DiagnosticMessages_1.DiagnosticMessages.xmlComponentMissingExtendsAttribute()
|
|
1096
|
-
]);
|
|
1097
|
-
});
|
|
1098
|
-
it('ignores all warnings from previous line comment', () => {
|
|
1099
|
-
//component without a name attribute
|
|
1100
|
-
program.setFile('components/file.xml', (0, testHelpers_spec_1.trim) `
|
|
1101
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
1102
|
-
<component> <!--bs:disable-line-->
|
|
1103
|
-
</component>
|
|
1104
|
-
`);
|
|
1105
|
-
program.validate();
|
|
1106
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
1107
|
-
});
|
|
1108
|
-
it('ignores warning from previous line just for the specified code', () => {
|
|
1109
|
-
//component without a name attribute
|
|
1110
|
-
program.setFile('components/file.xml', (0, testHelpers_spec_1.trim) `
|
|
1111
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
1112
|
-
<component name="ButtonCustom"> <!--bs:disable-line 1006-->
|
|
1113
|
-
</component>
|
|
1114
|
-
`);
|
|
1115
|
-
program.validate();
|
|
1116
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [
|
|
1117
|
-
DiagnosticMessages_1.DiagnosticMessages.xmlComponentMissingExtendsAttribute()
|
|
1118
|
-
]);
|
|
1119
|
-
});
|
|
1120
|
-
});
|
|
1121
|
-
describe('duplicate components', () => {
|
|
1122
|
-
it('more gracefully handles multiple components with the same name', () => {
|
|
1123
|
-
program.setFile('components/comp1.brs', ``);
|
|
1124
|
-
program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
|
|
1125
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
1126
|
-
<component name="comp1" extends="Group">
|
|
1127
|
-
<script uri="comp1.brs" />
|
|
1128
|
-
</component>
|
|
1129
|
-
`);
|
|
1130
|
-
//add another component with the same name
|
|
1131
|
-
program.setFile('components/comp2.brs', ``);
|
|
1132
|
-
program.setFile('components/comp2.xml', (0, testHelpers_spec_1.trim) `
|
|
1133
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
1134
|
-
<component name="comp1" extends="Group">
|
|
1135
|
-
<script uri="comp2.brs" />
|
|
1136
|
-
</component>
|
|
1137
|
-
`);
|
|
1138
|
-
program.validate();
|
|
1139
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [
|
|
1140
|
-
DiagnosticMessages_1.DiagnosticMessages.duplicateComponentName('comp1'),
|
|
1141
|
-
DiagnosticMessages_1.DiagnosticMessages.duplicateComponentName('comp1')
|
|
1142
|
-
]);
|
|
1143
|
-
});
|
|
1144
|
-
it('maintains consistent component selection', () => {
|
|
1145
|
-
//add comp2 first
|
|
1146
|
-
const comp2 = program.setFile('components/comp2.xml', (0, testHelpers_spec_1.trim) `
|
|
1147
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
1148
|
-
<component name="comp1">
|
|
1149
|
-
</component>
|
|
1150
|
-
`);
|
|
1151
|
-
(0, chai_config_spec_1.expect)(program.getComponent('comp1').file.destPath).to.equal(comp2.destPath);
|
|
1152
|
-
//add comp1. it should become the main component with this name
|
|
1153
|
-
const comp1 = program.setFile('components/comp1.xml', (0, testHelpers_spec_1.trim) `
|
|
1154
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
1155
|
-
<component name="comp1" extends="Group">
|
|
1156
|
-
</component>
|
|
1157
|
-
`);
|
|
1158
|
-
(0, chai_config_spec_1.expect)(program.getComponent('comp1').file.destPath).to.equal(comp1.destPath);
|
|
1159
|
-
//remove comp1, comp2 should be the primary again
|
|
1160
|
-
program.removeFile((0, util_1.standardizePath) `${testHelpers_spec_2.rootDir}/components/comp1.xml`);
|
|
1161
|
-
(0, chai_config_spec_1.expect)(program.getComponent('comp1').file.destPath).to.equal(comp2.destPath);
|
|
1162
|
-
//add comp3
|
|
1163
|
-
program.setFile('components/comp3.xml', (0, testHelpers_spec_1.trim) `
|
|
1164
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
|
1165
|
-
<component name="comp1">
|
|
1166
|
-
</component>
|
|
1167
|
-
`);
|
|
1168
|
-
//...the 2nd file should still be main
|
|
1169
|
-
(0, chai_config_spec_1.expect)(program.getComponent('comp1').file.destPath).to.equal(comp2.destPath);
|
|
1170
|
-
});
|
|
1171
|
-
});
|
|
1172
|
-
});
|
|
1173
|
-
//# sourceMappingURL=XmlFile.spec.js.map
|