brighterscript 1.0.0-alpha.4 → 1.0.0-alpha.40
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 +1387 -291
- package/README.md +72 -131
- package/bsconfig.schema.json +85 -1
- package/dist/ActionPipeline.d.ts +10 -0
- package/dist/ActionPipeline.js +40 -0
- package/dist/ActionPipeline.js.map +1 -0
- package/dist/AstValidationSegmenter.d.ts +42 -0
- package/dist/AstValidationSegmenter.js +237 -0
- package/dist/AstValidationSegmenter.js.map +1 -0
- package/dist/BsConfig.d.ts +56 -6
- package/dist/BusyStatusTracker.d.ts +31 -0
- package/dist/BusyStatusTracker.js +83 -0
- package/dist/BusyStatusTracker.js.map +1 -0
- package/dist/Cache.d.ts +5 -6
- package/dist/Cache.js +12 -11
- package/dist/Cache.js.map +1 -1
- package/dist/CacheVerifier.d.ts +7 -0
- package/dist/CacheVerifier.js +20 -0
- package/dist/CacheVerifier.js.map +1 -0
- package/dist/CodeActionUtil.d.ts +6 -3
- package/dist/CodeActionUtil.js +19 -5
- package/dist/CodeActionUtil.js.map +1 -1
- package/dist/CommentFlagProcessor.d.ts +7 -6
- package/dist/CommentFlagProcessor.js +11 -8
- package/dist/CommentFlagProcessor.js.map +1 -1
- package/dist/CrossScopeValidator.d.ts +67 -0
- package/dist/CrossScopeValidator.js +617 -0
- package/dist/CrossScopeValidator.js.map +1 -0
- package/dist/DependencyGraph.d.ts +8 -3
- package/dist/DependencyGraph.js +49 -16
- package/dist/DependencyGraph.js.map +1 -1
- package/dist/DiagnosticCollection.d.ts +5 -3
- package/dist/DiagnosticCollection.js +21 -16
- package/dist/DiagnosticCollection.js.map +1 -1
- package/dist/DiagnosticFilterer.d.ts +8 -4
- package/dist/DiagnosticFilterer.js +90 -54
- package/dist/DiagnosticFilterer.js.map +1 -1
- package/dist/DiagnosticManager.d.ts +61 -0
- package/dist/DiagnosticManager.js +238 -0
- package/dist/DiagnosticManager.js.map +1 -0
- package/dist/DiagnosticMessages.d.ts +204 -24
- package/dist/DiagnosticMessages.js +266 -33
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/DiagnosticSeverityAdjuster.d.ts +7 -0
- package/dist/DiagnosticSeverityAdjuster.js +41 -0
- package/dist/DiagnosticSeverityAdjuster.js.map +1 -0
- package/dist/FunctionScope.d.ts +28 -0
- package/dist/FunctionScope.js +52 -0
- package/dist/FunctionScope.js.map +1 -0
- package/dist/KeyedThrottler.d.ts +3 -3
- package/dist/KeyedThrottler.js +3 -3
- package/dist/KeyedThrottler.js.map +1 -1
- package/dist/LanguageServer.d.ts +72 -47
- package/dist/LanguageServer.js +545 -314
- package/dist/LanguageServer.js.map +1 -1
- package/dist/Logger.d.ts +9 -10
- package/dist/Logger.js +36 -30
- package/dist/Logger.js.map +1 -1
- package/dist/PluginInterface.d.ts +29 -7
- package/dist/PluginInterface.js +90 -7
- package/dist/PluginInterface.js.map +1 -1
- package/dist/Program.d.ts +201 -100
- package/dist/Program.js +1079 -700
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +29 -18
- package/dist/ProgramBuilder.js +178 -141
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +144 -109
- package/dist/Scope.js +533 -552
- package/dist/Scope.js.map +1 -1
- package/dist/SemanticTokenUtils.d.ts +14 -0
- package/dist/SemanticTokenUtils.js +85 -0
- package/dist/SemanticTokenUtils.js.map +1 -0
- package/dist/Stopwatch.d.ts +4 -0
- package/dist/Stopwatch.js +8 -1
- package/dist/Stopwatch.js.map +1 -1
- package/dist/SymbolTable.d.ts +91 -24
- package/dist/SymbolTable.js +291 -64
- package/dist/SymbolTable.js.map +1 -1
- package/dist/SymbolTypeFlag.d.ts +9 -0
- package/dist/SymbolTypeFlag.js +14 -0
- package/dist/SymbolTypeFlag.js.map +1 -0
- package/dist/Throttler.d.ts +12 -0
- package/dist/Throttler.js +39 -0
- package/dist/Throttler.js.map +1 -1
- package/dist/Watcher.d.ts +0 -3
- package/dist/Watcher.js +0 -3
- package/dist/Watcher.js.map +1 -1
- package/dist/XmlScope.d.ts +5 -15
- package/dist/XmlScope.js +35 -87
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/CachedLookups.d.ts +50 -0
- package/dist/astUtils/CachedLookups.js +335 -0
- package/dist/astUtils/CachedLookups.js.map +1 -0
- package/dist/astUtils/CachedLookups.spec.js +39 -0
- package/dist/astUtils/CachedLookups.spec.js.map +1 -0
- package/dist/astUtils/Editor.d.ts +69 -0
- package/dist/astUtils/Editor.js +245 -0
- package/dist/astUtils/Editor.js.map +1 -0
- package/dist/astUtils/Editor.spec.js +258 -0
- package/dist/astUtils/Editor.spec.js.map +1 -0
- package/dist/astUtils/creators.d.ts +36 -19
- package/dist/astUtils/creators.js +222 -43
- package/dist/astUtils/creators.js.map +1 -1
- package/dist/astUtils/creators.spec.js +5 -5
- package/dist/astUtils/creators.spec.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +148 -82
- package/dist/astUtils/reflection.js +324 -137
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +267 -167
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/astUtils/stackedVisitor.js.map +1 -1
- package/dist/astUtils/stackedVisitor.spec.js +14 -14
- package/dist/astUtils/stackedVisitor.spec.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +114 -53
- package/dist/astUtils/visitors.js +70 -13
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +463 -51
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/astUtils/xml.d.ts +9 -8
- package/dist/astUtils/xml.js +10 -5
- package/dist/astUtils/xml.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +22 -1
- package/dist/bscPlugin/BscPlugin.js +88 -0
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/CallExpressionInfo.d.ts +36 -0
- package/dist/bscPlugin/CallExpressionInfo.js +135 -0
- package/dist/bscPlugin/CallExpressionInfo.js.map +1 -0
- package/dist/bscPlugin/FileWriter.d.ts +6 -0
- package/dist/bscPlugin/FileWriter.js +24 -0
- package/dist/bscPlugin/FileWriter.js.map +1 -0
- package/dist/bscPlugin/SignatureHelpUtil.d.ts +10 -0
- package/dist/bscPlugin/SignatureHelpUtil.js +137 -0
- package/dist/bscPlugin/SignatureHelpUtil.js.map +1 -0
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.d.ts +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +30 -18
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +94 -21
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +64 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.js +626 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +2188 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/definition/DefinitionProvider.d.ts +13 -0
- package/dist/bscPlugin/definition/DefinitionProvider.js +212 -0
- package/dist/bscPlugin/definition/DefinitionProvider.js.map +1 -0
- package/dist/bscPlugin/definition/DefinitionProvider.spec.d.ts +1 -0
- package/dist/bscPlugin/definition/DefinitionProvider.spec.js +87 -0
- package/dist/bscPlugin/definition/DefinitionProvider.spec.js.map +1 -0
- package/dist/bscPlugin/fileProviders/FileProvider.d.ts +9 -0
- package/dist/bscPlugin/fileProviders/FileProvider.js +51 -0
- package/dist/bscPlugin/fileProviders/FileProvider.js.map +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.d.ts +18 -0
- package/dist/bscPlugin/hover/HoverProcessor.js +218 -0
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.spec.d.ts +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.spec.js +786 -0
- package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/references/ReferencesProvider.d.ts +12 -0
- package/dist/bscPlugin/references/ReferencesProvider.js +57 -0
- package/dist/bscPlugin/references/ReferencesProvider.js.map +1 -0
- package/dist/bscPlugin/references/ReferencesProvider.spec.d.ts +1 -0
- package/dist/bscPlugin/references/ReferencesProvider.spec.js +51 -0
- package/dist/bscPlugin/references/ReferencesProvider.spec.js.map +1 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +14 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +154 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.d.ts +1 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +530 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/serialize/BslibInjector.spec.d.ts +1 -0
- package/dist/bscPlugin/serialize/BslibInjector.spec.js +33 -0
- package/dist/bscPlugin/serialize/BslibInjector.spec.js.map +1 -0
- package/dist/bscPlugin/serialize/BslibManager.d.ts +12 -0
- package/dist/bscPlugin/serialize/BslibManager.js +46 -0
- package/dist/bscPlugin/serialize/BslibManager.js.map +1 -0
- package/dist/bscPlugin/serialize/FileSerializer.d.ts +9 -0
- package/dist/bscPlugin/serialize/FileSerializer.js +75 -0
- package/dist/bscPlugin/serialize/FileSerializer.js.map +1 -0
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.d.ts +7 -0
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.js +22 -0
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.js.map +1 -0
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.d.ts +1 -0
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js +291 -0
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.d.ts +7 -0
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.js +26 -0
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.js.map +1 -0
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.d.ts +1 -0
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js +245 -0
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/symbols/symbolUtils.d.ts +5 -0
- package/dist/bscPlugin/symbols/symbolUtils.js +141 -0
- package/dist/bscPlugin/symbols/symbolUtils.js.map +1 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.d.ts +21 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js +201 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.d.ts +1 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js +75 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +12 -0
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js +99 -0
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +1 -0
- package/dist/bscPlugin/validation/BrsFileAfterValidator.d.ts +7 -0
- package/dist/bscPlugin/validation/BrsFileAfterValidator.js +18 -0
- package/dist/bscPlugin/validation/BrsFileAfterValidator.js.map +1 -0
- package/dist/bscPlugin/validation/BrsFileValidator.d.ts +36 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js +534 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -0
- package/dist/bscPlugin/validation/BrsFileValidator.spec.d.ts +1 -0
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js +1118 -0
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -0
- package/dist/bscPlugin/validation/ProgramValidator.d.ts +11 -0
- package/dist/bscPlugin/validation/ProgramValidator.js +33 -0
- package/dist/bscPlugin/validation/ProgramValidator.js.map +1 -0
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +126 -0
- package/dist/bscPlugin/validation/ScopeValidator.js +1039 -0
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -0
- package/dist/bscPlugin/validation/ScopeValidator.spec.d.ts +1 -0
- package/dist/bscPlugin/validation/ScopeValidator.spec.js +3346 -0
- package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -0
- package/dist/bscPlugin/validation/XmlFileValidator.d.ts +8 -0
- package/dist/bscPlugin/validation/XmlFileValidator.js +44 -0
- package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -0
- package/dist/cli.js +117 -11
- package/dist/cli.js.map +1 -1
- package/dist/deferred.d.ts +3 -3
- package/dist/deferred.js.map +1 -1
- package/dist/diagnosticUtils.d.ts +10 -3
- package/dist/diagnosticUtils.js +62 -24
- package/dist/diagnosticUtils.js.map +1 -1
- package/dist/examples/plugins/removePrint.js +8 -12
- package/dist/examples/plugins/removePrint.js.map +1 -1
- package/dist/files/AssetFile.d.ts +24 -0
- package/dist/files/AssetFile.js +25 -0
- package/dist/files/AssetFile.js.map +1 -0
- package/dist/files/BrsFile.Class.spec.js +912 -153
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +142 -85
- package/dist/files/BrsFile.js +845 -935
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +3778 -862
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/BscFile.d.ts +101 -0
- package/dist/files/BscFile.js +15 -0
- package/dist/files/BscFile.js.map +1 -0
- package/dist/files/Factory.d.ts +25 -0
- package/dist/files/Factory.js +22 -0
- package/dist/files/Factory.js.map +1 -0
- package/dist/files/LazyFileData.d.ts +20 -0
- package/dist/files/LazyFileData.js +54 -0
- package/dist/files/LazyFileData.js.map +1 -0
- package/dist/files/LazyFileData.spec.d.ts +1 -0
- package/dist/files/LazyFileData.spec.js +27 -0
- package/dist/files/LazyFileData.spec.js.map +1 -0
- package/dist/files/XmlFile.d.ts +73 -41
- package/dist/files/XmlFile.js +128 -138
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/files/XmlFile.spec.js +451 -324
- package/dist/files/XmlFile.spec.js.map +1 -1
- package/dist/files/tests/imports.spec.js +62 -52
- package/dist/files/tests/imports.spec.js.map +1 -1
- package/dist/files/tests/optionalChaning.spec.d.ts +1 -0
- package/dist/files/tests/optionalChaning.spec.js +152 -0
- package/dist/files/tests/optionalChaning.spec.js.map +1 -0
- package/dist/globalCallables.d.ts +3 -1
- package/dist/globalCallables.js +417 -163
- package/dist/globalCallables.js.map +1 -1
- package/dist/index.d.ts +26 -3
- package/dist/index.js +44 -5
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +783 -122
- package/dist/interfaces.js +21 -0
- package/dist/interfaces.js.map +1 -1
- package/dist/lexer/Character.spec.js +5 -5
- package/dist/lexer/Character.spec.js.map +1 -1
- package/dist/lexer/Lexer.d.ts +51 -12
- package/dist/lexer/Lexer.js +201 -57
- package/dist/lexer/Lexer.js.map +1 -1
- package/dist/lexer/Lexer.spec.js +781 -565
- package/dist/lexer/Lexer.spec.js.map +1 -1
- package/dist/lexer/Token.d.ts +27 -11
- package/dist/lexer/Token.js +10 -2
- package/dist/lexer/Token.js.map +1 -1
- package/dist/lexer/TokenKind.d.ts +31 -2
- package/dist/lexer/TokenKind.js +134 -10
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/logging.d.ts +9 -0
- package/dist/logging.js +16 -0
- package/dist/logging.js.map +1 -0
- package/dist/parser/AstNode.d.ts +191 -0
- package/dist/parser/AstNode.js +269 -0
- package/dist/parser/AstNode.js.map +1 -0
- package/dist/parser/AstNode.spec.d.ts +1 -0
- package/dist/parser/AstNode.spec.js +1455 -0
- package/dist/parser/AstNode.spec.js.map +1 -0
- package/dist/parser/BrightScriptDocParser.d.ts +56 -0
- package/dist/parser/BrightScriptDocParser.js +294 -0
- package/dist/parser/BrightScriptDocParser.js.map +1 -0
- package/dist/parser/BrightScriptDocParser.spec.d.ts +1 -0
- package/dist/parser/BrightScriptDocParser.spec.js +310 -0
- package/dist/parser/BrightScriptDocParser.spec.js.map +1 -0
- package/dist/parser/BrsTranspileState.d.ts +22 -3
- package/dist/parser/BrsTranspileState.js +19 -0
- package/dist/parser/BrsTranspileState.js.map +1 -1
- package/dist/parser/Expression.d.ts +489 -221
- package/dist/parser/Expression.js +1206 -506
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Expression.spec.d.ts +1 -0
- package/dist/parser/Expression.spec.js +40 -0
- package/dist/parser/Expression.spec.js.map +1 -0
- package/dist/parser/Parser.Class.spec.js +230 -125
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.d.ts +113 -124
- package/dist/parser/Parser.js +1510 -983
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.d.ts +3 -1
- package/dist/parser/Parser.spec.js +1533 -517
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/SGParser.d.ts +60 -7
- package/dist/parser/SGParser.js +225 -185
- package/dist/parser/SGParser.js.map +1 -1
- package/dist/parser/SGParser.spec.js +29 -32
- package/dist/parser/SGParser.spec.js.map +1 -1
- package/dist/parser/SGTypes.d.ts +295 -52
- package/dist/parser/SGTypes.js +540 -187
- package/dist/parser/SGTypes.js.map +1 -1
- package/dist/parser/Statement.d.ts +808 -261
- package/dist/parser/Statement.js +2232 -588
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/Statement.spec.js +133 -36
- package/dist/parser/Statement.spec.js.map +1 -1
- package/dist/parser/TranspileState.d.ts +26 -12
- package/dist/parser/TranspileState.js +114 -15
- package/dist/parser/TranspileState.js.map +1 -1
- package/dist/parser/tests/Parser.spec.d.ts +3 -9
- package/dist/parser/tests/Parser.spec.js +7 -13
- package/dist/parser/tests/Parser.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/For.spec.js +83 -75
- package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/ForEach.spec.js +58 -51
- package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/If.spec.js +382 -239
- package/dist/parser/tests/controlFlow/If.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/While.spec.js +52 -45
- package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
- package/dist/parser/tests/expression/Additive.spec.js +51 -43
- package/dist/parser/tests/expression/Additive.spec.js.map +1 -1
- package/dist/parser/tests/expression/ArrayLiterals.spec.js +192 -142
- package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +1 -1
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +236 -160
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
- package/dist/parser/tests/expression/Boolean.spec.js +41 -34
- package/dist/parser/tests/expression/Boolean.spec.js.map +1 -1
- package/dist/parser/tests/expression/Call.spec.js +173 -55
- package/dist/parser/tests/expression/Call.spec.js.map +1 -1
- package/dist/parser/tests/expression/Exponential.spec.js +20 -20
- package/dist/parser/tests/expression/Exponential.spec.js.map +1 -1
- package/dist/parser/tests/expression/Function.spec.js +291 -282
- package/dist/parser/tests/expression/Function.spec.js.map +1 -1
- package/dist/parser/tests/expression/Indexing.spec.js +193 -110
- package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
- package/dist/parser/tests/expression/Multiplicative.spec.js +42 -42
- package/dist/parser/tests/expression/Multiplicative.spec.js.map +1 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +213 -115
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/PrefixUnary.spec.js +58 -52
- package/dist/parser/tests/expression/PrefixUnary.spec.js.map +1 -1
- package/dist/parser/tests/expression/Primary.spec.js +76 -60
- package/dist/parser/tests/expression/Primary.spec.js.map +1 -1
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.d.ts +1 -0
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +171 -0
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -0
- package/dist/parser/tests/expression/Relational.spec.js +50 -50
- package/dist/parser/tests/expression/Relational.spec.js.map +1 -1
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +31 -31
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js +235 -94
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.js +403 -174
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TypeExpression.spec.d.ts +1 -0
- package/dist/parser/tests/expression/TypeExpression.spec.js +126 -0
- package/dist/parser/tests/expression/TypeExpression.spec.js.map +1 -0
- package/dist/parser/tests/expression/UnaryExpression.spec.d.ts +1 -0
- package/dist/parser/tests/expression/UnaryExpression.spec.js +52 -0
- package/dist/parser/tests/expression/UnaryExpression.spec.js.map +1 -0
- package/dist/parser/tests/statement/AssignmentOperators.spec.js +44 -44
- package/dist/parser/tests/statement/AssignmentOperators.spec.js.map +1 -1
- package/dist/parser/tests/statement/ConstStatement.spec.d.ts +1 -0
- package/dist/parser/tests/statement/ConstStatement.spec.js +262 -0
- package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -0
- package/dist/parser/tests/statement/Continue.spec.d.ts +1 -0
- package/dist/parser/tests/statement/Continue.spec.js +119 -0
- package/dist/parser/tests/statement/Continue.spec.js.map +1 -0
- package/dist/parser/tests/statement/Declaration.spec.js +61 -55
- package/dist/parser/tests/statement/Declaration.spec.js.map +1 -1
- package/dist/parser/tests/statement/Dim.spec.js +22 -22
- package/dist/parser/tests/statement/Dim.spec.js.map +1 -1
- package/dist/parser/tests/statement/Enum.spec.d.ts +1 -0
- package/dist/parser/tests/statement/Enum.spec.js +744 -0
- package/dist/parser/tests/statement/Enum.spec.js.map +1 -0
- package/dist/parser/tests/statement/For.spec.d.ts +1 -0
- package/dist/parser/tests/statement/For.spec.js +45 -0
- package/dist/parser/tests/statement/For.spec.js.map +1 -0
- package/dist/parser/tests/statement/ForEach.spec.d.ts +1 -0
- package/dist/parser/tests/statement/ForEach.spec.js +36 -0
- package/dist/parser/tests/statement/ForEach.spec.js.map +1 -0
- package/dist/parser/tests/statement/Function.spec.js +226 -215
- package/dist/parser/tests/statement/Function.spec.js.map +1 -1
- package/dist/parser/tests/statement/Goto.spec.js +16 -15
- package/dist/parser/tests/statement/Goto.spec.js.map +1 -1
- package/dist/parser/tests/statement/Increment.spec.js +64 -59
- package/dist/parser/tests/statement/Increment.spec.js.map +1 -1
- package/dist/parser/tests/statement/InterfaceStatement.spec.d.ts +1 -0
- package/dist/parser/tests/statement/InterfaceStatement.spec.js +110 -0
- package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -0
- package/dist/parser/tests/statement/LibraryStatement.spec.js +22 -22
- package/dist/parser/tests/statement/LibraryStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Misc.spec.js +127 -168
- package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
- package/dist/parser/tests/statement/PrintStatement.spec.js +133 -114
- package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/ReturnStatement.spec.js +57 -54
- package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Set.spec.js +131 -117
- package/dist/parser/tests/statement/Set.spec.js.map +1 -1
- package/dist/parser/tests/statement/Stop.spec.js +14 -13
- package/dist/parser/tests/statement/Stop.spec.js.map +1 -1
- package/dist/parser/tests/statement/Throw.spec.js +11 -8
- package/dist/parser/tests/statement/Throw.spec.js.map +1 -1
- package/dist/parser/tests/statement/TryCatch.spec.js +26 -15
- package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
- package/dist/preprocessor/Manifest.d.ts +6 -6
- package/dist/preprocessor/Manifest.js +17 -38
- package/dist/preprocessor/Manifest.js.map +1 -1
- package/dist/preprocessor/Manifest.spec.d.ts +1 -0
- package/dist/preprocessor/Manifest.spec.js +78 -103
- package/dist/preprocessor/Manifest.spec.js.map +1 -1
- package/dist/roku-types/data.json +19452 -0
- package/dist/roku-types/index.d.ts +5533 -0
- package/dist/roku-types/index.js +11 -0
- package/dist/roku-types/index.js.map +1 -0
- package/dist/types/ArrayType.d.ts +9 -5
- package/dist/types/ArrayType.js +73 -24
- package/dist/types/ArrayType.js.map +1 -1
- package/dist/types/ArrayType.spec.js +39 -11
- package/dist/types/ArrayType.spec.js.map +1 -1
- package/dist/types/AssociativeArrayType.d.ts +14 -0
- package/dist/types/AssociativeArrayType.js +60 -0
- package/dist/types/AssociativeArrayType.js.map +1 -0
- package/dist/types/BaseFunctionType.d.ts +9 -0
- package/dist/types/BaseFunctionType.js +25 -0
- package/dist/types/BaseFunctionType.js.map +1 -0
- package/dist/types/BooleanType.d.ts +10 -5
- package/dist/types/BooleanType.js +21 -9
- package/dist/types/BooleanType.js.map +1 -1
- package/dist/types/BooleanType.spec.js +10 -4
- package/dist/types/BooleanType.spec.js.map +1 -1
- package/dist/types/BscType.d.ts +29 -3
- package/dist/types/BscType.js +121 -0
- package/dist/types/BscType.js.map +1 -1
- package/dist/types/BscTypeKind.d.ts +25 -0
- package/dist/types/BscTypeKind.js +30 -0
- package/dist/types/BscTypeKind.js.map +1 -0
- package/dist/types/BuiltInInterfaceAdder.d.ts +25 -0
- package/dist/types/BuiltInInterfaceAdder.js +201 -0
- package/dist/types/BuiltInInterfaceAdder.js.map +1 -0
- package/dist/types/BuiltInInterfaceAdder.spec.d.ts +1 -0
- package/dist/types/BuiltInInterfaceAdder.spec.js +115 -0
- package/dist/types/BuiltInInterfaceAdder.spec.js.map +1 -0
- package/dist/types/ClassType.d.ts +16 -0
- package/dist/types/ClassType.js +57 -0
- package/dist/types/ClassType.js.map +1 -0
- package/dist/types/ClassType.spec.d.ts +1 -0
- package/dist/types/ClassType.spec.js +76 -0
- package/dist/types/ClassType.spec.js.map +1 -0
- package/dist/types/ComponentType.d.ts +27 -0
- package/dist/types/ComponentType.js +83 -0
- package/dist/types/ComponentType.js.map +1 -0
- package/dist/types/DoubleType.d.ts +10 -5
- package/dist/types/DoubleType.js +25 -18
- package/dist/types/DoubleType.js.map +1 -1
- package/dist/types/DoubleType.spec.js +12 -4
- package/dist/types/DoubleType.spec.js.map +1 -1
- package/dist/types/DynamicType.d.ts +12 -5
- package/dist/types/DynamicType.js +22 -6
- package/dist/types/DynamicType.js.map +1 -1
- package/dist/types/DynamicType.spec.js +16 -5
- package/dist/types/DynamicType.spec.js.map +1 -1
- package/dist/types/EnumType.d.ts +40 -0
- package/dist/types/EnumType.js +80 -0
- package/dist/types/EnumType.js.map +1 -0
- package/dist/types/EnumType.spec.d.ts +1 -0
- package/dist/types/EnumType.spec.js +33 -0
- package/dist/types/EnumType.spec.js.map +1 -0
- package/dist/types/FloatType.d.ts +10 -5
- package/dist/types/FloatType.js +25 -18
- package/dist/types/FloatType.js.map +1 -1
- package/dist/types/FloatType.spec.js +4 -4
- package/dist/types/FloatType.spec.js.map +1 -1
- package/dist/types/FunctionType.d.ts +10 -22
- package/dist/types/FunctionType.js +26 -63
- package/dist/types/FunctionType.js.map +1 -1
- package/dist/types/InheritableType.d.ts +28 -0
- package/dist/types/InheritableType.js +157 -0
- package/dist/types/InheritableType.js.map +1 -0
- package/dist/types/IntegerType.d.ts +10 -5
- package/dist/types/IntegerType.js +25 -18
- package/dist/types/IntegerType.js.map +1 -1
- package/dist/types/IntegerType.spec.js +8 -4
- package/dist/types/IntegerType.spec.js.map +1 -1
- package/dist/types/InterfaceType.d.ts +14 -6
- package/dist/types/InterfaceType.js +26 -15
- package/dist/types/InterfaceType.js.map +1 -1
- package/dist/types/InterfaceType.spec.d.ts +1 -0
- package/dist/types/InterfaceType.spec.js +227 -0
- package/dist/types/InterfaceType.spec.js.map +1 -0
- package/dist/types/InvalidType.d.ts +9 -5
- package/dist/types/InvalidType.js +20 -9
- package/dist/types/InvalidType.js.map +1 -1
- package/dist/types/InvalidType.spec.js +8 -4
- package/dist/types/InvalidType.spec.js.map +1 -1
- package/dist/types/LongIntegerType.d.ts +10 -5
- package/dist/types/LongIntegerType.js +25 -18
- package/dist/types/LongIntegerType.js.map +1 -1
- package/dist/types/LongIntegerType.spec.js +10 -4
- package/dist/types/LongIntegerType.spec.js.map +1 -1
- package/dist/types/NamespaceType.d.ts +12 -0
- package/dist/types/NamespaceType.js +28 -0
- package/dist/types/NamespaceType.js.map +1 -0
- package/dist/types/ObjectType.d.ts +10 -5
- package/dist/types/ObjectType.js +23 -9
- package/dist/types/ObjectType.js.map +1 -1
- package/dist/types/ObjectType.spec.js +3 -3
- package/dist/types/ObjectType.spec.js.map +1 -1
- package/dist/types/ReferenceType.d.ts +79 -0
- package/dist/types/ReferenceType.js +522 -0
- package/dist/types/ReferenceType.js.map +1 -0
- package/dist/types/ReferenceType.spec.d.ts +1 -0
- package/dist/types/ReferenceType.spec.js +151 -0
- package/dist/types/ReferenceType.spec.js.map +1 -0
- package/dist/types/StringType.d.ts +13 -5
- package/dist/types/StringType.js +25 -9
- package/dist/types/StringType.js.map +1 -1
- package/dist/types/StringType.spec.js +3 -3
- package/dist/types/StringType.spec.js.map +1 -1
- package/dist/types/TypedFunctionType.d.ts +33 -0
- package/dist/types/TypedFunctionType.js +106 -0
- package/dist/types/TypedFunctionType.js.map +1 -0
- package/dist/types/TypedFunctionType.spec.d.ts +1 -0
- package/dist/types/TypedFunctionType.spec.js +122 -0
- package/dist/types/TypedFunctionType.spec.js.map +1 -0
- package/dist/types/UninitializedType.d.ts +8 -6
- package/dist/types/UninitializedType.js +15 -9
- package/dist/types/UninitializedType.js.map +1 -1
- package/dist/types/UnionType.d.ts +20 -0
- package/dist/types/UnionType.js +127 -0
- package/dist/types/UnionType.js.map +1 -0
- package/dist/types/UnionType.spec.d.ts +1 -0
- package/dist/types/UnionType.spec.js +129 -0
- package/dist/types/UnionType.spec.js.map +1 -0
- package/dist/types/VoidType.d.ts +10 -5
- package/dist/types/VoidType.js +20 -9
- package/dist/types/VoidType.js.map +1 -1
- package/dist/types/VoidType.spec.js +3 -3
- package/dist/types/VoidType.spec.js.map +1 -1
- package/dist/types/helper.spec.d.ts +1 -0
- package/dist/types/helper.spec.js +144 -0
- package/dist/types/helper.spec.js.map +1 -0
- package/dist/types/helpers.d.ts +26 -0
- package/dist/types/helpers.js +191 -0
- package/dist/types/helpers.js.map +1 -0
- package/dist/types/index.d.ts +22 -0
- package/dist/types/index.js +39 -0
- package/dist/types/index.js.map +1 -0
- package/dist/util.d.ts +272 -117
- package/dist/util.js +1583 -343
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.d.ts +9 -15
- package/dist/validators/ClassValidator.js +85 -138
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +174 -138
- package/dist/astUtils/index.d.ts +0 -7
- package/dist/astUtils/index.js +0 -26
- package/dist/astUtils/index.js.map +0 -1
- package/dist/lexer/index.d.ts +0 -3
- package/dist/lexer/index.js +0 -17
- package/dist/lexer/index.js.map +0 -1
- package/dist/parser/index.d.ts +0 -3
- package/dist/parser/index.js +0 -16
- package/dist/parser/index.js.map +0 -1
- package/dist/preprocessor/Chunk.d.ts +0 -82
- package/dist/preprocessor/Chunk.js +0 -77
- package/dist/preprocessor/Chunk.js.map +0 -1
- package/dist/preprocessor/Preprocessor.d.ts +0 -60
- package/dist/preprocessor/Preprocessor.js +0 -156
- package/dist/preprocessor/Preprocessor.js.map +0 -1
- package/dist/preprocessor/Preprocessor.spec.js +0 -152
- package/dist/preprocessor/Preprocessor.spec.js.map +0 -1
- package/dist/preprocessor/PreprocessorParser.d.ts +0 -61
- package/dist/preprocessor/PreprocessorParser.js +0 -194
- package/dist/preprocessor/PreprocessorParser.js.map +0 -1
- package/dist/preprocessor/PreprocessorParser.spec.js +0 -116
- package/dist/preprocessor/PreprocessorParser.spec.js.map +0 -1
- package/dist/preprocessor/index.d.ts +0 -3
- package/dist/preprocessor/index.js +0 -16
- package/dist/preprocessor/index.js.map +0 -1
- package/dist/types/CustomType.d.ts +0 -10
- package/dist/types/CustomType.js +0 -35
- package/dist/types/CustomType.js.map +0 -1
- package/dist/types/FunctionType.spec.js +0 -29
- package/dist/types/FunctionType.spec.js.map +0 -1
- package/dist/types/LazyType.d.ts +0 -15
- package/dist/types/LazyType.js +0 -32
- package/dist/types/LazyType.js.map +0 -1
- /package/dist/{preprocessor/Preprocessor.spec.d.ts → astUtils/CachedLookups.spec.d.ts} +0 -0
- /package/dist/{preprocessor/PreprocessorParser.spec.d.ts → astUtils/Editor.spec.d.ts} +0 -0
- /package/dist/{types/FunctionType.spec.d.ts → bscPlugin/completions/CompletionsProcessor.spec.d.ts} +0 -0
|
@@ -0,0 +1,786 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chai_config_spec_1 = require("../../chai-config.spec");
|
|
4
|
+
const Program_1 = require("../../Program");
|
|
5
|
+
const util_1 = require("../../util");
|
|
6
|
+
const sinon_1 = require("sinon");
|
|
7
|
+
const testHelpers_spec_1 = require("../../testHelpers.spec");
|
|
8
|
+
const HoverProcessor_1 = require("./HoverProcessor");
|
|
9
|
+
const creators_1 = require("../../astUtils/creators");
|
|
10
|
+
let sinon = (0, sinon_1.createSandbox)();
|
|
11
|
+
const fence = (code) => util_1.util.mdFence(code, 'brightscript');
|
|
12
|
+
const commentSep = `\n***\n`;
|
|
13
|
+
describe('HoverProcessor', () => {
|
|
14
|
+
let program;
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
program = new Program_1.Program({ rootDir: testHelpers_spec_1.rootDir, sourceMap: true });
|
|
17
|
+
});
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
sinon.restore();
|
|
20
|
+
program.dispose();
|
|
21
|
+
});
|
|
22
|
+
it('does not short-circuit the event since our plugin is the base plugin', () => {
|
|
23
|
+
const mock = sinon.mock();
|
|
24
|
+
program.plugins.add({
|
|
25
|
+
name: 'test-plugin',
|
|
26
|
+
provideHover: mock
|
|
27
|
+
});
|
|
28
|
+
const file = program.setFile('source/main.brs', `
|
|
29
|
+
sub main()
|
|
30
|
+
end sub
|
|
31
|
+
`);
|
|
32
|
+
//get the hover
|
|
33
|
+
program.getHover(file.srcPath, util_1.util.createPosition(1, 20));
|
|
34
|
+
//the onGetHover function from `test-plugin` should always get called because
|
|
35
|
+
//BscPlugin should never short-circuit the event
|
|
36
|
+
(0, chai_config_spec_1.expect)(mock.called).to.be.true;
|
|
37
|
+
});
|
|
38
|
+
describe('BrsFile', () => {
|
|
39
|
+
it('getConstHover does not crash on expression with missing range', () => {
|
|
40
|
+
const file = program.setFile('source/main.bs', ``);
|
|
41
|
+
const processor = new HoverProcessor_1.HoverProcessor({});
|
|
42
|
+
const expression = (0, creators_1.createIntegerLiteral)('1');
|
|
43
|
+
(0, chai_config_spec_1.expect)(processor['getConstHover']((0, creators_1.createIdentifier)('hello'), file, program.getScopeByName('source'), expression)).to.eql(undefined);
|
|
44
|
+
});
|
|
45
|
+
it('works for param types', () => {
|
|
46
|
+
const file = program.setFile('source/main.brs', `
|
|
47
|
+
sub DoSomething(name as string)
|
|
48
|
+
name = 1
|
|
49
|
+
sayMyName = function(name as string)
|
|
50
|
+
end function
|
|
51
|
+
end sub
|
|
52
|
+
`);
|
|
53
|
+
program.validate();
|
|
54
|
+
//hover over the `name = 1` line
|
|
55
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(2, 24))[0];
|
|
56
|
+
(0, chai_config_spec_1.expect)(hover).to.exist;
|
|
57
|
+
(0, chai_config_spec_1.expect)(hover.range).to.eql(util_1.util.createRange(2, 20, 2, 24));
|
|
58
|
+
//hover over the `name` parameter declaration
|
|
59
|
+
hover = program.getHover(file.srcPath, util_1.util.createPosition(1, 34))[0];
|
|
60
|
+
(0, chai_config_spec_1.expect)(hover).to.exist;
|
|
61
|
+
(0, chai_config_spec_1.expect)(hover.range).to.eql(util_1.util.createRange(1, 32, 1, 36));
|
|
62
|
+
});
|
|
63
|
+
//ignore this for now...it's not a huge deal
|
|
64
|
+
it('does not match on keywords or data types', () => {
|
|
65
|
+
let file = program.setFile('source/main.brs', `
|
|
66
|
+
sub Main(name as string)
|
|
67
|
+
end sub
|
|
68
|
+
sub as()
|
|
69
|
+
end sub
|
|
70
|
+
`);
|
|
71
|
+
//hover over the `as`
|
|
72
|
+
(0, chai_config_spec_1.expect)(program.getHover(file.srcPath, util_1.util.createPosition(1, 31))).to.be.empty;
|
|
73
|
+
//hover over the `string`
|
|
74
|
+
(0, chai_config_spec_1.expect)(program.getHover(file.srcPath, util_1.util.createPosition(1, 36))).to.be.empty;
|
|
75
|
+
});
|
|
76
|
+
it('finds declared function', () => {
|
|
77
|
+
let file = program.setFile('source/main.brs', `
|
|
78
|
+
function Main(count = 1)
|
|
79
|
+
firstName = "bob"
|
|
80
|
+
age = 21
|
|
81
|
+
shoeSize = 10
|
|
82
|
+
end function
|
|
83
|
+
`);
|
|
84
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(1, 28))[0];
|
|
85
|
+
(0, chai_config_spec_1.expect)(hover).to.exist;
|
|
86
|
+
(0, chai_config_spec_1.expect)(hover.range).to.eql(util_1.util.createRange(1, 25, 1, 29));
|
|
87
|
+
(0, chai_config_spec_1.expect)(hover.contents).to.eql([fence('function Main(count? as integer) as dynamic')]);
|
|
88
|
+
});
|
|
89
|
+
it('finds variable function hover in same scope', () => {
|
|
90
|
+
let file = program.setFile('source/main.brs', `
|
|
91
|
+
sub Main()
|
|
92
|
+
sayMyName = sub(name as string)
|
|
93
|
+
end sub
|
|
94
|
+
|
|
95
|
+
sayMyName()
|
|
96
|
+
end sub
|
|
97
|
+
`);
|
|
98
|
+
program.validate();
|
|
99
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(5, 24))[0];
|
|
100
|
+
(0, chai_config_spec_1.expect)(hover.range).to.eql(util_1.util.createRange(5, 20, 5, 29));
|
|
101
|
+
(0, chai_config_spec_1.expect)(hover.contents).to.eql([fence('sub sayMyName(name as string) as void')]);
|
|
102
|
+
});
|
|
103
|
+
it('finds function hover in file scope', () => {
|
|
104
|
+
let file = program.setFile('source/main.brs', `
|
|
105
|
+
sub Main()
|
|
106
|
+
sayMyName()
|
|
107
|
+
end sub
|
|
108
|
+
|
|
109
|
+
sub sayMyName()
|
|
110
|
+
end sub
|
|
111
|
+
`);
|
|
112
|
+
program.validate();
|
|
113
|
+
//sayM|yName()
|
|
114
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(2, 25))[0];
|
|
115
|
+
(0, chai_config_spec_1.expect)(hover.range).to.eql(util_1.util.createRange(2, 20, 2, 29));
|
|
116
|
+
(0, chai_config_spec_1.expect)(hover.contents).to.eql([fence('sub sayMyName() as void')]);
|
|
117
|
+
});
|
|
118
|
+
it('finds function hover in scope', () => {
|
|
119
|
+
let mainFile = program.setFile('source/main.brs', `
|
|
120
|
+
sub Main()
|
|
121
|
+
sayMyName()
|
|
122
|
+
end sub
|
|
123
|
+
`);
|
|
124
|
+
program.setFile('source/lib.brs', `
|
|
125
|
+
sub sayMyName(name as string)
|
|
126
|
+
|
|
127
|
+
end sub
|
|
128
|
+
`);
|
|
129
|
+
program.validate();
|
|
130
|
+
let hover = program.getHover(mainFile.srcPath, util_1.util.createPosition(2, 25))[0];
|
|
131
|
+
(0, chai_config_spec_1.expect)(hover.range).to.eql(util_1.util.createRange(2, 20, 2, 29));
|
|
132
|
+
(0, chai_config_spec_1.expect)(hover.contents).to.eql([fence('sub sayMyName(name as string) as void')]);
|
|
133
|
+
});
|
|
134
|
+
it('finds top-level constant value', () => {
|
|
135
|
+
program.setFile('source/main.bs', `
|
|
136
|
+
sub main()
|
|
137
|
+
print SOME_VALUE
|
|
138
|
+
end sub
|
|
139
|
+
const SOME_VALUE = true
|
|
140
|
+
`);
|
|
141
|
+
program.validate();
|
|
142
|
+
// print SOM|E_VALUE
|
|
143
|
+
let hover = program.getHover('source/main.bs', util_1.util.createPosition(2, 29))[0];
|
|
144
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.range).to.eql(util_1.util.createRange(2, 26, 2, 36));
|
|
145
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('const SOME_VALUE = true as boolean')]);
|
|
146
|
+
});
|
|
147
|
+
it('finds top-level constant in assignment expression', () => {
|
|
148
|
+
program.setFile('source/main.bs', `
|
|
149
|
+
sub main()
|
|
150
|
+
value = ""
|
|
151
|
+
value += SOME_VALUE
|
|
152
|
+
end sub
|
|
153
|
+
const SOME_VALUE = "value"
|
|
154
|
+
`);
|
|
155
|
+
program.validate();
|
|
156
|
+
// value += SOME|_VALUE
|
|
157
|
+
let hover = program.getHover('source/main.bs', util_1.util.createPosition(3, 33))[0];
|
|
158
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.range).to.eql(util_1.util.createRange(3, 29, 3, 39));
|
|
159
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('const SOME_VALUE = "value" as string')]);
|
|
160
|
+
});
|
|
161
|
+
it('finds namespaced constant in assignment expression', () => {
|
|
162
|
+
program.setFile('source/main.bs', `
|
|
163
|
+
sub main()
|
|
164
|
+
value = ""
|
|
165
|
+
value += someNamespace.SOME_VALUE
|
|
166
|
+
end sub
|
|
167
|
+
namespace someNamespace
|
|
168
|
+
const SOME_VALUE = "value"
|
|
169
|
+
end namespace
|
|
170
|
+
`);
|
|
171
|
+
program.validate();
|
|
172
|
+
// value += SOME|_VALUE
|
|
173
|
+
let hover = program.getHover('source/main.bs', util_1.util.createPosition(3, 47))[0];
|
|
174
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.range).to.eql(util_1.util.createRange(3, 43, 3, 53));
|
|
175
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('const someNamespace.SOME_VALUE = "value" as string')]);
|
|
176
|
+
});
|
|
177
|
+
it('finds namespaced constant value', () => {
|
|
178
|
+
program.setFile('source/main.bs', `
|
|
179
|
+
sub main()
|
|
180
|
+
print name.SOME_VALUE
|
|
181
|
+
end sub
|
|
182
|
+
namespace name
|
|
183
|
+
const SOME_VALUE = true
|
|
184
|
+
end namespace
|
|
185
|
+
`);
|
|
186
|
+
program.validate();
|
|
187
|
+
// print name.SOM|E_VALUE
|
|
188
|
+
let hover = program.getHover('source/main.bs', util_1.util.createPosition(2, 34))[0];
|
|
189
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.range).to.eql(util_1.util.createRange(2, 31, 2, 41));
|
|
190
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('const name.SOME_VALUE = true as boolean')]);
|
|
191
|
+
});
|
|
192
|
+
it('finds constant value that is an array', () => {
|
|
193
|
+
program.setFile('source/main.bs', `
|
|
194
|
+
sub main()
|
|
195
|
+
print SOME_VALUE
|
|
196
|
+
end sub
|
|
197
|
+
const SOME_VALUE = [] as function[]
|
|
198
|
+
`);
|
|
199
|
+
program.validate();
|
|
200
|
+
// print SOM|E_VALUE
|
|
201
|
+
let hover = program.getHover('source/main.bs', util_1.util.createPosition(2, 30))[0];
|
|
202
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.range).to.eql(util_1.util.createRange(2, 26, 2, 36));
|
|
203
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('const SOME_VALUE = [] as Array<function>')]);
|
|
204
|
+
});
|
|
205
|
+
it('finds deep namespaced constant value', () => {
|
|
206
|
+
program.setFile('source/main.bs', `
|
|
207
|
+
sub main()
|
|
208
|
+
print name.sp.a.c.e.SOME_VALUE
|
|
209
|
+
end sub
|
|
210
|
+
namespace name.sp.a.c.e
|
|
211
|
+
const SOME_VALUE = true
|
|
212
|
+
end namespace
|
|
213
|
+
`);
|
|
214
|
+
program.validate();
|
|
215
|
+
// print name.sp.a.c.e.SOM|E_VALUE
|
|
216
|
+
let hover = program.getHover('source/main.bs', util_1.util.createPosition(2, 43))[0];
|
|
217
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.range).to.eql(util_1.util.createRange(2, 40, 2, 50));
|
|
218
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('const name.sp.a.c.e.SOME_VALUE = true as boolean')]);
|
|
219
|
+
});
|
|
220
|
+
it('finds namespaced class types', () => {
|
|
221
|
+
program.setFile('source/main.bs', `
|
|
222
|
+
sub main()
|
|
223
|
+
myKlass = new name.Klass()
|
|
224
|
+
runNoop(myKlass)
|
|
225
|
+
end sub
|
|
226
|
+
|
|
227
|
+
sub runNoop(myKlass as name.Klass)
|
|
228
|
+
myKlass.noop()
|
|
229
|
+
end sub
|
|
230
|
+
|
|
231
|
+
namespace name
|
|
232
|
+
class Klass
|
|
233
|
+
sub noop()
|
|
234
|
+
end sub
|
|
235
|
+
end class
|
|
236
|
+
end namespace
|
|
237
|
+
`);
|
|
238
|
+
program.validate();
|
|
239
|
+
// run|Noop(myKlass)
|
|
240
|
+
let hover = program.getHover('source/main.bs', util_1.util.createPosition(3, 24))[0];
|
|
241
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.range).to.eql(util_1.util.createRange(3, 20, 3, 27));
|
|
242
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('sub runNoop(myKlass as name.Klass) as void')]);
|
|
243
|
+
// myKl|ass.noop()
|
|
244
|
+
hover = program.getHover('source/main.bs', util_1.util.createPosition(7, 25))[0];
|
|
245
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.range).to.eql(util_1.util.createRange(7, 20, 7, 27));
|
|
246
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('myKlass as name.Klass')]);
|
|
247
|
+
// sub no|op()
|
|
248
|
+
hover = program.getHover('source/main.bs', util_1.util.createPosition(12, 31))[0];
|
|
249
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('sub name.Klass.noop() as void')]);
|
|
250
|
+
});
|
|
251
|
+
it('finds local variables that shadow namespaces', () => {
|
|
252
|
+
program.setFile('source/main.bs', `
|
|
253
|
+
sub foo1(alpha as string)
|
|
254
|
+
print alpha.toStr() ' in foo1()
|
|
255
|
+
end sub
|
|
256
|
+
|
|
257
|
+
sub foo2()
|
|
258
|
+
alpha = 123
|
|
259
|
+
print alpha.toStr() ' in foo2()
|
|
260
|
+
end sub
|
|
261
|
+
|
|
262
|
+
namespace alpha
|
|
263
|
+
function toStr()
|
|
264
|
+
return "alpha"
|
|
265
|
+
end function
|
|
266
|
+
end namespace
|
|
267
|
+
`);
|
|
268
|
+
program.validate();
|
|
269
|
+
// sub foo1(alp|ha as string)
|
|
270
|
+
let hover = program.getHover('source/main.bs', util_1.util.createPosition(1, 29))[0];
|
|
271
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('alpha as string')]);
|
|
272
|
+
// print alp|ha.toStr() ' in foo1()
|
|
273
|
+
hover = program.getHover('source/main.bs', util_1.util.createPosition(2, 30))[0];
|
|
274
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('alpha as string')]);
|
|
275
|
+
// alp|ha = 123
|
|
276
|
+
hover = program.getHover('source/main.bs', util_1.util.createPosition(6, 23))[0];
|
|
277
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('alpha as integer')]);
|
|
278
|
+
// print alp|ha.toStr() ' in foo2()
|
|
279
|
+
hover = program.getHover('source/main.bs', util_1.util.createPosition(7, 30))[0];
|
|
280
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('alpha as integer')]);
|
|
281
|
+
});
|
|
282
|
+
it('finds types properly', () => {
|
|
283
|
+
program.setFile('source/main.bs', `
|
|
284
|
+
class Person
|
|
285
|
+
end class
|
|
286
|
+
|
|
287
|
+
sub doWork(age as integer, name as string, guy as Person)
|
|
288
|
+
end sub
|
|
289
|
+
`);
|
|
290
|
+
program.validate();
|
|
291
|
+
// a|ge as integer
|
|
292
|
+
let hover = program.getHover('source/main.bs', util_1.util.createPosition(4, 29))[0];
|
|
293
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.range).to.eql(util_1.util.createRange(4, 27, 4, 30));
|
|
294
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('age as integer')]);
|
|
295
|
+
// age as int|eger
|
|
296
|
+
hover = program.getHover('source/main.bs', util_1.util.createPosition(4, 39))[0];
|
|
297
|
+
// no hover on base types
|
|
298
|
+
(0, chai_config_spec_1.expect)(hover).to.be.undefined;
|
|
299
|
+
// n|ame as string
|
|
300
|
+
hover = program.getHover('source/main.bs', util_1.util.createPosition(4, 46))[0];
|
|
301
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.range).to.eql(util_1.util.createRange(4, 43, 4, 47));
|
|
302
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('name as string')]);
|
|
303
|
+
// name as st|ring
|
|
304
|
+
hover = program.getHover('source/main.bs', util_1.util.createPosition(4, 54))[0];
|
|
305
|
+
// no hover on base types
|
|
306
|
+
(0, chai_config_spec_1.expect)(hover).to.be.undefined;
|
|
307
|
+
// gu|y as Person
|
|
308
|
+
hover = program.getHover('source/main.bs', util_1.util.createPosition(4, 60))[0];
|
|
309
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.range).to.eql(util_1.util.createRange(4, 59, 4, 62));
|
|
310
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('guy as Person')]);
|
|
311
|
+
// guy as Pe|rson
|
|
312
|
+
hover = program.getHover('source/main.bs', util_1.util.createPosition(4, 69))[0];
|
|
313
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('class Person')]);
|
|
314
|
+
});
|
|
315
|
+
it('finds namespaces properly', () => {
|
|
316
|
+
program.setFile('source/main.bs', `
|
|
317
|
+
namespace Name1
|
|
318
|
+
namespace Name2
|
|
319
|
+
const hi = "hello"
|
|
320
|
+
end namespace
|
|
321
|
+
end namespace
|
|
322
|
+
|
|
323
|
+
sub doWork()
|
|
324
|
+
print Name1.Name2.hi
|
|
325
|
+
end sub
|
|
326
|
+
`);
|
|
327
|
+
program.validate();
|
|
328
|
+
// print Name1.Nam|e2.hi
|
|
329
|
+
let hover = program.getHover('source/main.bs', util_1.util.createPosition(8, 36))[0];
|
|
330
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('namespace Name1.Name2')]);
|
|
331
|
+
});
|
|
332
|
+
it('finds enum properly', () => {
|
|
333
|
+
program.setFile('source/main.bs', `
|
|
334
|
+
enum Direction
|
|
335
|
+
up
|
|
336
|
+
down
|
|
337
|
+
end enum
|
|
338
|
+
|
|
339
|
+
sub doWork()
|
|
340
|
+
print Direction.up
|
|
341
|
+
end sub
|
|
342
|
+
`);
|
|
343
|
+
program.validate();
|
|
344
|
+
// print Dire|ction.up
|
|
345
|
+
let hover = program.getHover('source/main.bs', util_1.util.createPosition(7, 30))[0];
|
|
346
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('enum Direction')]);
|
|
347
|
+
// print Direction.u|p
|
|
348
|
+
hover = program.getHover('source/main.bs', util_1.util.createPosition(7, 37))[0];
|
|
349
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('Direction.up as Direction')]);
|
|
350
|
+
});
|
|
351
|
+
it('finds types hover with comment', () => {
|
|
352
|
+
program.setFile('source/main.bs', `
|
|
353
|
+
' this is a class comment
|
|
354
|
+
' it is more than one line
|
|
355
|
+
class Person
|
|
356
|
+
end class
|
|
357
|
+
|
|
358
|
+
' does some work
|
|
359
|
+
sub doWork(age as integer, name as string, guy as Person)
|
|
360
|
+
end sub
|
|
361
|
+
`);
|
|
362
|
+
program.validate();
|
|
363
|
+
// gu|y as Person
|
|
364
|
+
let hover = program.getHover('source/main.bs', util_1.util.createPosition(7, 60))[0];
|
|
365
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.range).to.eql(util_1.util.createRange(7, 59, 7, 62));
|
|
366
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([`${fence('guy as Person')}${commentSep}this is a class comment\nit is more than one line`]);
|
|
367
|
+
// guy as Pe|rson
|
|
368
|
+
hover = program.getHover('source/main.bs', util_1.util.createPosition(7, 69))[0];
|
|
369
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([`${fence('class Person')}${commentSep}this is a class comment\nit is more than one line`]);
|
|
370
|
+
});
|
|
371
|
+
it('finds types from assignments defined in different file', () => {
|
|
372
|
+
program.setFile(`source/main.bs`, `
|
|
373
|
+
sub main()
|
|
374
|
+
thing = new MyKlass()
|
|
375
|
+
useKlass(thing)
|
|
376
|
+
someVal = getValue()
|
|
377
|
+
print someVal
|
|
378
|
+
end sub
|
|
379
|
+
|
|
380
|
+
sub useKlass(thing as MyKlass)
|
|
381
|
+
print thing
|
|
382
|
+
end sub
|
|
383
|
+
`);
|
|
384
|
+
program.setFile(`source/MyKlass.bs`, `
|
|
385
|
+
class MyKlass
|
|
386
|
+
end class
|
|
387
|
+
`);
|
|
388
|
+
program.setFile(`source/util.bs`, `
|
|
389
|
+
function getValue() as string
|
|
390
|
+
return "hello"
|
|
391
|
+
end function
|
|
392
|
+
`);
|
|
393
|
+
program.validate();
|
|
394
|
+
//th|ing = new MyKlass()
|
|
395
|
+
let hover = program.getHover('source/main.bs', util_1.util.createPosition(2, 24))[0];
|
|
396
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.range).to.eql(util_1.util.createRange(2, 20, 2, 25));
|
|
397
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('thing as MyKlass')]);
|
|
398
|
+
//print some|Val
|
|
399
|
+
hover = program.getHover('source/main.bs', util_1.util.createPosition(5, 31))[0];
|
|
400
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.range).to.eql(util_1.util.createRange(5, 26, 5, 33));
|
|
401
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('someVal as string')]);
|
|
402
|
+
});
|
|
403
|
+
it('hovers of functions include comments', () => {
|
|
404
|
+
program.setFile(`source/main.bs`, `
|
|
405
|
+
sub main()
|
|
406
|
+
thing = new MyKlass()
|
|
407
|
+
useKlass(thing)
|
|
408
|
+
end sub
|
|
409
|
+
|
|
410
|
+
' Prints a MyKlass.name
|
|
411
|
+
sub useKlass(thing as MyKlass)
|
|
412
|
+
print thing.getName()
|
|
413
|
+
end sub
|
|
414
|
+
|
|
415
|
+
' A sample class
|
|
416
|
+
class MyKlass
|
|
417
|
+
name as string
|
|
418
|
+
|
|
419
|
+
' Gets the name of this thing
|
|
420
|
+
function getName() as string
|
|
421
|
+
return m.name
|
|
422
|
+
end function
|
|
423
|
+
|
|
424
|
+
' Wraps another function
|
|
425
|
+
function getNameWrap() as string
|
|
426
|
+
return m.getName()
|
|
427
|
+
end function
|
|
428
|
+
end class
|
|
429
|
+
`);
|
|
430
|
+
program.validate();
|
|
431
|
+
let commentSep = `\n***\n`;
|
|
432
|
+
//th|ing = new MyKlass()
|
|
433
|
+
let hover = program.getHover('source/main.bs', util_1.util.createPosition(2, 24))[0];
|
|
434
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([`${fence('thing as MyKlass')}`]);
|
|
435
|
+
//thing = new MyK|lass()
|
|
436
|
+
hover = program.getHover('source/main.bs', util_1.util.createPosition(2, 37))[0];
|
|
437
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([`${fence('class MyKlass')}${commentSep}A sample class`]);
|
|
438
|
+
//use|Klass(thing)
|
|
439
|
+
hover = program.getHover('source/main.bs', util_1.util.createPosition(3, 24))[0];
|
|
440
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([`${fence('sub useKlass(thing as MyKlass) as void')}${commentSep}Prints a MyKlass.name`]);
|
|
441
|
+
//print thing.getN|ame()
|
|
442
|
+
hover = program.getHover('source/main.bs', util_1.util.createPosition(8, 37))[0];
|
|
443
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([`${fence('function MyKlass.getName() as string')}${commentSep}Gets the name of this thing`]);
|
|
444
|
+
});
|
|
445
|
+
it('finds globalCallables with documentation', () => {
|
|
446
|
+
let mainFile = program.setFile('source/main.brs', `
|
|
447
|
+
sub Main()
|
|
448
|
+
print lcase("HELLO")
|
|
449
|
+
end sub
|
|
450
|
+
`);
|
|
451
|
+
program.validate();
|
|
452
|
+
// print lc|ase("HELLO")
|
|
453
|
+
let hover = program.getHover(mainFile.srcPath, util_1.util.createPosition(2, 29))[0];
|
|
454
|
+
(0, chai_config_spec_1.expect)(hover.contents).to.eql([`${fence('function lcase(s as string) as string')}${commentSep}Converts the string to all lower case.`]);
|
|
455
|
+
});
|
|
456
|
+
it('finds functions as params', () => {
|
|
457
|
+
program.setFile('source/main.brs', `
|
|
458
|
+
function getStrLength(name as string) as integer
|
|
459
|
+
return len(name)
|
|
460
|
+
end function
|
|
461
|
+
|
|
462
|
+
sub tryManyParams(someFunc as function)
|
|
463
|
+
print someFunc(1, 2, "hello", "world")
|
|
464
|
+
end sub
|
|
465
|
+
|
|
466
|
+
sub test()
|
|
467
|
+
tryManyParams(getStrLength)
|
|
468
|
+
end sub
|
|
469
|
+
`);
|
|
470
|
+
program.validate();
|
|
471
|
+
// print some|Func(1, 2, "hello", "world")
|
|
472
|
+
let hover = program.getHover('source/main.brs', util_1.util.createPosition(6, 31))[0];
|
|
473
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.range).to.eql(util_1.util.createRange(6, 26, 6, 34));
|
|
474
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('someFunc as function')]);
|
|
475
|
+
});
|
|
476
|
+
it('keeps unresolved types as type names', () => {
|
|
477
|
+
const file = program.setFile('source/main.bs', `
|
|
478
|
+
sub doSomething(thing as UnknownType)
|
|
479
|
+
print thing
|
|
480
|
+
end sub
|
|
481
|
+
`);
|
|
482
|
+
program.validate();
|
|
483
|
+
// print thi|ng
|
|
484
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(2, 30))[0];
|
|
485
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.range).to.eql(util_1.util.createRange(2, 26, 2, 31));
|
|
486
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence('thing as UnknownType')]);
|
|
487
|
+
});
|
|
488
|
+
it('says members on dynamic are dynamic', () => {
|
|
489
|
+
const file = program.setFile('source/main.bs', `
|
|
490
|
+
sub doSomething(thing)
|
|
491
|
+
print thing.member
|
|
492
|
+
end sub
|
|
493
|
+
`);
|
|
494
|
+
program.validate();
|
|
495
|
+
// print thing.mem|ber
|
|
496
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(2, 36))[0];
|
|
497
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.range).to.eql(util_1.util.createRange(2, 32, 2, 38));
|
|
498
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence('member as dynamic')]);
|
|
499
|
+
});
|
|
500
|
+
it('should recognize consistent type after function call in binary op', () => {
|
|
501
|
+
let file = program.setFile('source/main.bs', `
|
|
502
|
+
function arrayToString(items as object) as string
|
|
503
|
+
description = "["
|
|
504
|
+
for each item in items
|
|
505
|
+
description += utils.toString(item) + ", "
|
|
506
|
+
end for
|
|
507
|
+
description += "]"
|
|
508
|
+
return description
|
|
509
|
+
end function
|
|
510
|
+
`);
|
|
511
|
+
program.setFile('source/utils.bs', `
|
|
512
|
+
namespace utils
|
|
513
|
+
function toString(thing as dynamic) as string
|
|
514
|
+
return "hello"
|
|
515
|
+
end function
|
|
516
|
+
end namespace
|
|
517
|
+
`);
|
|
518
|
+
program.validate();
|
|
519
|
+
// return myS|tring
|
|
520
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(7, 31))[0];
|
|
521
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence('description as string')]);
|
|
522
|
+
});
|
|
523
|
+
it('should provide correct hover for LHS of assignment', () => {
|
|
524
|
+
let file = program.setFile('source/main.bs', `
|
|
525
|
+
function getFloat() as float
|
|
526
|
+
return 123
|
|
527
|
+
end function
|
|
528
|
+
|
|
529
|
+
sub doStuff()
|
|
530
|
+
myFloat = getFloat()
|
|
531
|
+
end sub
|
|
532
|
+
`);
|
|
533
|
+
program.validate();
|
|
534
|
+
// myF|loat = getFloat()
|
|
535
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(6, 24))[0];
|
|
536
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence('myFloat as float')]);
|
|
537
|
+
});
|
|
538
|
+
it('should provide correct hover for members of classes', () => {
|
|
539
|
+
let file = program.setFile('source/main.bs', `
|
|
540
|
+
class SomeKlass
|
|
541
|
+
name as string
|
|
542
|
+
other as OtherKlass
|
|
543
|
+
myLabel as roSGNodeLabel
|
|
544
|
+
end class
|
|
545
|
+
|
|
546
|
+
class OtherKlass
|
|
547
|
+
size as integer
|
|
548
|
+
end class
|
|
549
|
+
`);
|
|
550
|
+
program.validate();
|
|
551
|
+
// na|me as string
|
|
552
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(2, 24))[0];
|
|
553
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence('SomeKlass.name as string')]);
|
|
554
|
+
// ot|her as OtherKlass
|
|
555
|
+
hover = program.getHover(file.srcPath, util_1.util.createPosition(3, 24))[0];
|
|
556
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence('SomeKlass.other as OtherKlass')]);
|
|
557
|
+
// my|Label as RoSGNodeLabel
|
|
558
|
+
hover = program.getHover(file.srcPath, util_1.util.createPosition(4, 24))[0];
|
|
559
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence('SomeKlass.myLabel as roSGNodeLabel')]);
|
|
560
|
+
});
|
|
561
|
+
it('should provide correct hover for members of interfaces', () => {
|
|
562
|
+
let file = program.setFile('source/main.bs', `
|
|
563
|
+
interface SomeIFace
|
|
564
|
+
name as string
|
|
565
|
+
other as OtherIFace
|
|
566
|
+
myLabel as roSGNodeLabel
|
|
567
|
+
end interface
|
|
568
|
+
|
|
569
|
+
interface OtherIFace
|
|
570
|
+
size as integer
|
|
571
|
+
end interface
|
|
572
|
+
`);
|
|
573
|
+
program.validate();
|
|
574
|
+
// na|me as string
|
|
575
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(2, 24))[0];
|
|
576
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence('SomeIFace.name as string')]);
|
|
577
|
+
// ot|her as OtherIFace
|
|
578
|
+
hover = program.getHover(file.srcPath, util_1.util.createPosition(3, 24))[0];
|
|
579
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence('SomeIFace.other as OtherIFace')]);
|
|
580
|
+
// my|Label as RoSGNodeLabel
|
|
581
|
+
hover = program.getHover(file.srcPath, util_1.util.createPosition(4, 24))[0];
|
|
582
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence('SomeIFace.myLabel as roSGNodeLabel')]);
|
|
583
|
+
});
|
|
584
|
+
it('should include leading trivia of member field hover', () => {
|
|
585
|
+
let file = program.setFile('source/main.bs', `
|
|
586
|
+
interface SomeIFace
|
|
587
|
+
' Some description
|
|
588
|
+
name as string
|
|
589
|
+
other as OtherIFace
|
|
590
|
+
myLabel as roSGNodeLabel
|
|
591
|
+
end interface
|
|
592
|
+
`);
|
|
593
|
+
program.validate();
|
|
594
|
+
// na|me as string
|
|
595
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(3, 24))[0];
|
|
596
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([`${fence('SomeIFace.name as string')}${commentSep}Some description`]);
|
|
597
|
+
});
|
|
598
|
+
it('should include leading trivia of enum member field hover', () => {
|
|
599
|
+
let file = program.setFile('source/main.bs', `
|
|
600
|
+
enum Direction
|
|
601
|
+
' Go Up
|
|
602
|
+
up = "up"
|
|
603
|
+
down = "down"
|
|
604
|
+
end enum
|
|
605
|
+
`);
|
|
606
|
+
program.validate();
|
|
607
|
+
// u|p = "up"
|
|
608
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(3, 22))[0];
|
|
609
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([`${fence('Direction.up as Direction')}${commentSep}Go Up`]);
|
|
610
|
+
});
|
|
611
|
+
it('should have correct hovers for loop-items of for-loops', () => {
|
|
612
|
+
let file = program.setFile('source/main.bs', `
|
|
613
|
+
sub test()
|
|
614
|
+
for index = 0 to 10
|
|
615
|
+
print index
|
|
616
|
+
end for
|
|
617
|
+
end sub
|
|
618
|
+
`);
|
|
619
|
+
program.validate();
|
|
620
|
+
// for in|dex = 0 to 10
|
|
621
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(2, 27))[0];
|
|
622
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('index as integer')]);
|
|
623
|
+
});
|
|
624
|
+
it('should have correct hovers for loop-items of for-each-loops', () => {
|
|
625
|
+
let file = program.setFile('source/main.bs', `
|
|
626
|
+
sub test()
|
|
627
|
+
numbers = [1,2,3]
|
|
628
|
+
for each number in numbers
|
|
629
|
+
print number
|
|
630
|
+
end for
|
|
631
|
+
end sub
|
|
632
|
+
`);
|
|
633
|
+
program.validate();
|
|
634
|
+
// for each number in num|bers
|
|
635
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(3, 43))[0];
|
|
636
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('numbers as Array<integer>')]);
|
|
637
|
+
// for each num|ber in numbers
|
|
638
|
+
hover = program.getHover(file.srcPath, util_1.util.createPosition(3, 33))[0];
|
|
639
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.eql([fence('number as integer')]);
|
|
640
|
+
// for each number i|n numbers
|
|
641
|
+
hover = program.getHover(file.srcPath, util_1.util.createPosition(3, 38))[0];
|
|
642
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.be.undefined;
|
|
643
|
+
});
|
|
644
|
+
it('should show unresolved members as invalid', () => {
|
|
645
|
+
const file = program.setFile('source/main.bs', `
|
|
646
|
+
interface MyIFace
|
|
647
|
+
name as string
|
|
648
|
+
end interface
|
|
649
|
+
|
|
650
|
+
sub doSomething(thing as MyIFace)
|
|
651
|
+
print thing.member
|
|
652
|
+
end sub
|
|
653
|
+
`);
|
|
654
|
+
program.validate();
|
|
655
|
+
// print thing.mem|ber
|
|
656
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(6, 40))[0];
|
|
657
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence('MyIFace.member as invalid')]);
|
|
658
|
+
});
|
|
659
|
+
it('has m as an AA in inline function', () => {
|
|
660
|
+
const file = program.setFile('source/main.bs', `
|
|
661
|
+
class Test
|
|
662
|
+
sub method()
|
|
663
|
+
stub = function()
|
|
664
|
+
m.whatever = false
|
|
665
|
+
end function
|
|
666
|
+
end sub
|
|
667
|
+
end class
|
|
668
|
+
`);
|
|
669
|
+
program.validate();
|
|
670
|
+
// |m.whatever = false
|
|
671
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(4, 29))[0];
|
|
672
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence('m as roAssociativeArray')]);
|
|
673
|
+
// m.what|ever = false
|
|
674
|
+
hover = program.getHover(file.srcPath, util_1.util.createPosition(4, 35))[0];
|
|
675
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence('whatever as dynamic')]);
|
|
676
|
+
});
|
|
677
|
+
});
|
|
678
|
+
describe('callFunc', () => {
|
|
679
|
+
it('should get hovers on @callfunc invocations', () => {
|
|
680
|
+
program.setFile('components/Widget.xml', (0, testHelpers_spec_1.trim) `
|
|
681
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
|
682
|
+
<component name="Widget" extends="Group">
|
|
683
|
+
<script uri="Widget.bs"/>
|
|
684
|
+
<interface>
|
|
685
|
+
<function name="someFunc" />
|
|
686
|
+
</interface>
|
|
687
|
+
</component>
|
|
688
|
+
`);
|
|
689
|
+
const file = program.setFile('components/Widget.bs', `
|
|
690
|
+
sub foo()
|
|
691
|
+
top = m.top as roSgNodeWidget
|
|
692
|
+
print top@.someFunc("3.14")
|
|
693
|
+
end sub
|
|
694
|
+
|
|
695
|
+
function someFunc(input as string) as float
|
|
696
|
+
return input.toFloat()
|
|
697
|
+
end function
|
|
698
|
+
`);
|
|
699
|
+
program.validate();
|
|
700
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
701
|
+
// print top@.some|Func("3.14")
|
|
702
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(3, 35))[0];
|
|
703
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence('function roSGNodeWidget@.someFunc(input as string) as float')]);
|
|
704
|
+
});
|
|
705
|
+
});
|
|
706
|
+
describe('multiple definition locations', () => {
|
|
707
|
+
it('shows correct type in all locations', () => {
|
|
708
|
+
const file = program.setFile('source/util.bs', `
|
|
709
|
+
sub test()
|
|
710
|
+
myVar = "hello" ' setting type to string
|
|
711
|
+
print 1; myVar
|
|
712
|
+
myVar = "hello".len() ' setting type to integer
|
|
713
|
+
myVar = sqr(33) ' setting type to float
|
|
714
|
+
print 2; myVar
|
|
715
|
+
end sub
|
|
716
|
+
`);
|
|
717
|
+
const expectedHoverStr = `myVar as string or integer or float`;
|
|
718
|
+
program.validate();
|
|
719
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
720
|
+
// print 1; my|Var
|
|
721
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(3, 31))[0];
|
|
722
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence(expectedHoverStr)]);
|
|
723
|
+
// my|Var = "hello".len()
|
|
724
|
+
hover = program.getHover(file.srcPath, util_1.util.createPosition(4, 23))[0];
|
|
725
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence(expectedHoverStr)]);
|
|
726
|
+
// print 2; my|Var
|
|
727
|
+
hover = program.getHover(file.srcPath, util_1.util.createPosition(6, 31))[0];
|
|
728
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence(expectedHoverStr)]);
|
|
729
|
+
});
|
|
730
|
+
it('reusing same variable for multiple types', () => {
|
|
731
|
+
const file = program.setFile('source/util.bs', `
|
|
732
|
+
namespace stringUtil
|
|
733
|
+
function pad(x as string or integer) as string
|
|
734
|
+
return "0"+x.toStr()
|
|
735
|
+
end function
|
|
736
|
+
end namespace
|
|
737
|
+
|
|
738
|
+
' Formats a timestamp into a user friendly string.
|
|
739
|
+
' @param {Integer} time - The unix time stamp to format.
|
|
740
|
+
' @param {String} meridiemStyle - A style key to be wrapped around the meridiem for MultiStyleLabels.
|
|
741
|
+
' @return {String} - The formatted time
|
|
742
|
+
function formatTime(time as integer, meridiemStyle = "" as string) as string
|
|
743
|
+
dateObj = createObject("roDateTime")
|
|
744
|
+
deviceInfo = createObject("roDeviceInfo")
|
|
745
|
+
dateObj.fromSeconds(time)
|
|
746
|
+
hour = dateObj.getHours()
|
|
747
|
+
minutes = dateObj.getMinutes()
|
|
748
|
+
|
|
749
|
+
' Get the Meridiem value
|
|
750
|
+
if hour > 11 then
|
|
751
|
+
meridiem = "pm"
|
|
752
|
+
else
|
|
753
|
+
meridiem = "am"
|
|
754
|
+
end if
|
|
755
|
+
|
|
756
|
+
if meridiemStyle <> "" then
|
|
757
|
+
meridiem = "<" + meridiemStyle + ">" + meridiem + "</" + meridiemStyle + ">"
|
|
758
|
+
end if
|
|
759
|
+
|
|
760
|
+
minutes = stringUtil.pad(minutes)
|
|
761
|
+
|
|
762
|
+
if deviceInfo.getClockFormat() = "24h" then
|
|
763
|
+
hour = stringUtil.pad(hour)
|
|
764
|
+
' "22:01" | "01:01"
|
|
765
|
+
return substitute("{0}:{1}", hour, minutes as string)
|
|
766
|
+
else
|
|
767
|
+
hour = hour mod 12
|
|
768
|
+
if hour = 0 then hour = 12
|
|
769
|
+
' "10:01 AM" | "1:01 AM"
|
|
770
|
+
return substitute("{0}:{1} {2}", hour, minutes as string, meridiem)
|
|
771
|
+
end if
|
|
772
|
+
end function
|
|
773
|
+
`);
|
|
774
|
+
const expectedHourHoverStr = `hour as dynamic`;
|
|
775
|
+
program.validate();
|
|
776
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
777
|
+
// ho|ur = stringUtil.pad(hour)
|
|
778
|
+
let hover = program.getHover(file.srcPath, util_1.util.createPosition(32, 27))[0];
|
|
779
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence(expectedHourHoverStr)]);
|
|
780
|
+
// ho|ur = hour mod 12
|
|
781
|
+
hover = program.getHover(file.srcPath, util_1.util.createPosition(36, 27))[0];
|
|
782
|
+
(0, chai_config_spec_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).eql([fence(expectedHourHoverStr)]);
|
|
783
|
+
});
|
|
784
|
+
});
|
|
785
|
+
});
|
|
786
|
+
//# sourceMappingURL=HoverProcessor.spec.js.map
|