brighterscript 1.0.0-alpha.2 → 1.0.0-alpha.22
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 +643 -253
- package/README.md +33 -9
- package/bsconfig.schema.json +22 -2
- package/dist/BsConfig.d.ts +9 -0
- package/dist/Cache.d.ts +5 -6
- package/dist/Cache.js +12 -11
- package/dist/Cache.js.map +1 -1
- package/dist/CodeActionUtil.d.ts +11 -2
- package/dist/CodeActionUtil.js +17 -3
- package/dist/CodeActionUtil.js.map +1 -1
- package/dist/CommentFlagProcessor.d.ts +4 -4
- package/dist/CommentFlagProcessor.js +5 -3
- package/dist/CommentFlagProcessor.js.map +1 -1
- package/dist/DependencyGraph.d.ts +2 -2
- package/dist/DependencyGraph.js +20 -7
- package/dist/DependencyGraph.js.map +1 -1
- package/dist/DiagnosticCollection.d.ts +3 -3
- package/dist/DiagnosticCollection.js +11 -11
- package/dist/DiagnosticCollection.js.map +1 -1
- package/dist/DiagnosticFilterer.js +5 -4
- package/dist/DiagnosticFilterer.js.map +1 -1
- package/dist/DiagnosticMessages.d.ts +59 -4
- package/dist/DiagnosticMessages.js +65 -7
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/LanguageServer.d.ts +51 -39
- package/dist/LanguageServer.js +316 -232
- package/dist/LanguageServer.js.map +1 -1
- package/dist/Logger.d.ts +2 -0
- package/dist/Logger.js +10 -8
- package/dist/Logger.js.map +1 -1
- package/dist/PluginInterface.d.ts +7 -3
- package/dist/PluginInterface.js +9 -0
- package/dist/PluginInterface.js.map +1 -1
- package/dist/Program.d.ts +43 -25
- package/dist/Program.js +212 -95
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +4 -0
- package/dist/ProgramBuilder.js +36 -20
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +126 -29
- package/dist/Scope.js +433 -156
- package/dist/Scope.js.map +1 -1
- package/dist/SemanticTokenUtils.d.ts +14 -0
- package/dist/SemanticTokenUtils.js +81 -0
- package/dist/SemanticTokenUtils.js.map +1 -0
- package/dist/SymbolTable.d.ts +10 -4
- package/dist/SymbolTable.js +55 -13
- package/dist/SymbolTable.js.map +1 -1
- package/dist/XmlScope.d.ts +7 -2
- package/dist/XmlScope.js +65 -27
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/AstEditor.d.ts +65 -0
- package/dist/astUtils/AstEditor.js +239 -0
- package/dist/astUtils/AstEditor.js.map +1 -0
- package/dist/{types/FunctionType.spec.d.ts → astUtils/AstEditor.spec.d.ts} +0 -0
- package/dist/astUtils/AstEditor.spec.js +254 -0
- package/dist/astUtils/AstEditor.spec.js.map +1 -0
- package/dist/astUtils/creators.d.ts +28 -6
- package/dist/astUtils/creators.js +137 -19
- package/dist/astUtils/creators.js.map +1 -1
- package/dist/astUtils/creators.spec.js +14 -4
- package/dist/astUtils/creators.spec.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +32 -10
- package/dist/astUtils/reflection.js +82 -7
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +130 -119
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/astUtils/stackedVisitor.js.map +1 -1
- package/dist/astUtils/stackedVisitor.spec.js +13 -13
- package/dist/astUtils/stackedVisitor.spec.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +76 -51
- package/dist/astUtils/visitors.js +31 -11
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +126 -32
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/astUtils/xml.d.ts +4 -3
- package/dist/astUtils/xml.js +8 -3
- package/dist/astUtils/xml.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +7 -1
- package/dist/bscPlugin/BscPlugin.js +28 -0
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +4 -4
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +26 -26
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +9 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +108 -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 +130 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.d.ts +8 -0
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js +52 -0
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +1 -0
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.d.ts +1 -0
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js +32 -0
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/validation/BrsFileValidator.d.ts +9 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js +66 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -0
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +29 -0
- package/dist/bscPlugin/validation/ScopeValidator.js +183 -0
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -0
- package/dist/cli.js +10 -3
- package/dist/cli.js.map +1 -1
- package/dist/diagnosticUtils.d.ts +1 -0
- package/dist/diagnosticUtils.js +15 -8
- package/dist/diagnosticUtils.js.map +1 -1
- package/dist/examples/plugins/removePrint.js +12 -14
- package/dist/examples/plugins/removePrint.js.map +1 -1
- package/dist/files/BrsFile.Class.spec.js +717 -147
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +70 -30
- package/dist/files/BrsFile.js +719 -353
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +1238 -449
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.d.ts +6 -5
- package/dist/files/XmlFile.js +38 -30
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/files/XmlFile.spec.js +302 -237
- package/dist/files/XmlFile.spec.js.map +1 -1
- package/dist/files/tests/imports.spec.js +44 -42
- 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 +88 -0
- package/dist/files/tests/optionalChaning.spec.js.map +1 -0
- package/dist/globalCallables.d.ts +3 -1
- package/dist/globalCallables.js +424 -152
- package/dist/globalCallables.js.map +1 -1
- package/dist/index.d.ts +13 -3
- package/dist/index.js +28 -5
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +133 -16
- package/dist/lexer/Lexer.d.ts +19 -1
- package/dist/lexer/Lexer.js +127 -21
- package/dist/lexer/Lexer.js.map +1 -1
- package/dist/lexer/Lexer.spec.js +657 -536
- package/dist/lexer/Lexer.spec.js.map +1 -1
- package/dist/lexer/Token.d.ts +2 -2
- package/dist/lexer/TokenKind.d.ts +13 -1
- package/dist/lexer/TokenKind.js +60 -3
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/parser/BrsTranspileState.d.ts +9 -0
- package/dist/parser/BrsTranspileState.js +14 -0
- package/dist/parser/BrsTranspileState.js.map +1 -1
- package/dist/parser/Expression.d.ts +150 -34
- package/dist/parser/Expression.js +335 -165
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +189 -89
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.d.ts +153 -30
- package/dist/parser/Parser.js +1100 -503
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.js +687 -266
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/SGParser.d.ts +41 -4
- package/dist/parser/SGParser.js +186 -175
- package/dist/parser/SGParser.js.map +1 -1
- package/dist/parser/SGParser.spec.js +35 -22
- package/dist/parser/SGParser.spec.js.map +1 -1
- package/dist/parser/SGTypes.d.ts +206 -38
- package/dist/parser/SGTypes.js +470 -161
- package/dist/parser/SGTypes.js.map +1 -1
- package/dist/parser/SGTypes.spec.d.ts +1 -0
- package/dist/parser/SGTypes.spec.js +351 -0
- package/dist/parser/SGTypes.spec.js.map +1 -0
- package/dist/parser/Statement.d.ts +202 -48
- package/dist/parser/Statement.js +648 -193
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/Statement.spec.js +11 -11
- package/dist/parser/Statement.spec.js.map +1 -1
- package/dist/parser/TranspileState.d.ts +1 -1
- package/dist/parser/TranspileState.js +15 -7
- package/dist/parser/TranspileState.js.map +1 -1
- package/dist/parser/tests/Parser.spec.d.ts +10 -9
- package/dist/parser/tests/Parser.spec.js +15 -11
- package/dist/parser/tests/Parser.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/For.spec.js +60 -60
- package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/ForEach.spec.js +40 -39
- package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/If.spec.js +213 -194
- package/dist/parser/tests/controlFlow/If.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/While.spec.js +37 -37
- package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
- package/dist/parser/tests/expression/Additive.spec.js +30 -30
- package/dist/parser/tests/expression/Additive.spec.js.map +1 -1
- package/dist/parser/tests/expression/ArrayLiterals.spec.js +119 -119
- package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +1 -1
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +162 -138
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
- package/dist/parser/tests/expression/Boolean.spec.js +24 -24
- package/dist/parser/tests/expression/Boolean.spec.js.map +1 -1
- package/dist/parser/tests/expression/Call.spec.js +41 -40
- package/dist/parser/tests/expression/Call.spec.js.map +1 -1
- package/dist/parser/tests/expression/Exponential.spec.js +17 -17
- package/dist/parser/tests/expression/Exponential.spec.js.map +1 -1
- package/dist/parser/tests/expression/Function.spec.js +256 -256
- package/dist/parser/tests/expression/Function.spec.js.map +1 -1
- package/dist/parser/tests/expression/Indexing.spec.js +87 -87
- package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
- package/dist/parser/tests/expression/Multiplicative.spec.js +37 -37
- package/dist/parser/tests/expression/Multiplicative.spec.js.map +1 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +75 -63
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/PrefixUnary.spec.js +41 -41
- package/dist/parser/tests/expression/PrefixUnary.spec.js.map +1 -1
- package/dist/parser/tests/expression/Primary.spec.js +41 -41
- 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 +43 -43
- package/dist/parser/tests/expression/Relational.spec.js.map +1 -1
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +9 -9
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js +28 -28
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.js +102 -102
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
- package/dist/parser/tests/statement/AssignmentOperators.spec.js +36 -36
- package/dist/parser/tests/statement/AssignmentOperators.spec.js.map +1 -1
- package/dist/parser/tests/statement/Declaration.spec.js +44 -44
- package/dist/parser/tests/statement/Declaration.spec.js.map +1 -1
- package/dist/parser/tests/statement/Dim.spec.js +21 -21
- 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 +840 -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 +46 -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 +37 -0
- package/dist/parser/tests/statement/ForEach.spec.js.map +1 -0
- package/dist/parser/tests/statement/Function.spec.js +198 -197
- package/dist/parser/tests/statement/Function.spec.js.map +1 -1
- package/dist/parser/tests/statement/Goto.spec.js +15 -14
- package/dist/parser/tests/statement/Goto.spec.js.map +1 -1
- package/dist/parser/tests/statement/Increment.spec.js +50 -50
- 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 +254 -0
- package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -0
- package/dist/parser/tests/statement/LibraryStatement.spec.js +17 -17
- package/dist/parser/tests/statement/LibraryStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Misc.spec.js +108 -106
- package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
- package/dist/parser/tests/statement/PrintStatement.spec.js +40 -40
- package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/ReturnStatement.spec.js +46 -46
- package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Set.spec.js +83 -83
- package/dist/parser/tests/statement/Set.spec.js.map +1 -1
- package/dist/parser/tests/statement/Stop.spec.js +12 -11
- package/dist/parser/tests/statement/Stop.spec.js.map +1 -1
- package/dist/parser/tests/statement/Throw.spec.js +5 -5
- package/dist/parser/tests/statement/Throw.spec.js.map +1 -1
- package/dist/parser/tests/statement/TryCatch.spec.js +15 -13
- package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
- package/dist/preprocessor/Chunk.d.ts +1 -1
- package/dist/preprocessor/Chunk.js.map +1 -1
- package/dist/preprocessor/Manifest.d.ts +5 -5
- package/dist/preprocessor/Manifest.js +14 -35
- 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/preprocessor/Preprocessor.d.ts +1 -1
- package/dist/preprocessor/Preprocessor.js +8 -8
- package/dist/preprocessor/Preprocessor.js.map +1 -1
- package/dist/preprocessor/Preprocessor.spec.js +49 -49
- package/dist/preprocessor/Preprocessor.spec.js.map +1 -1
- package/dist/preprocessor/PreprocessorParser.spec.js +72 -72
- package/dist/preprocessor/PreprocessorParser.spec.js.map +1 -1
- package/dist/roku-types/data.json +21891 -0
- package/dist/roku-types/index.d.ts +6776 -0
- package/dist/roku-types/index.js +11 -0
- package/dist/roku-types/index.js.map +1 -0
- package/dist/types/ArrayType.d.ts +8 -5
- package/dist/types/ArrayType.js +52 -12
- package/dist/types/ArrayType.js.map +1 -1
- package/dist/types/ArrayType.spec.js +72 -11
- package/dist/types/ArrayType.spec.js.map +1 -1
- package/dist/types/BooleanType.d.ts +4 -2
- package/dist/types/BooleanType.js +9 -4
- package/dist/types/BooleanType.js.map +1 -1
- package/dist/types/BooleanType.spec.js +5 -3
- package/dist/types/BooleanType.spec.js.map +1 -1
- package/dist/types/BscType.d.ts +20 -5
- package/dist/types/BscType.js +24 -0
- package/dist/types/BscType.js.map +1 -1
- package/dist/types/CustomType.d.ts +8 -6
- package/dist/types/CustomType.js +20 -11
- package/dist/types/CustomType.js.map +1 -1
- package/dist/types/DoubleType.d.ts +2 -0
- package/dist/types/DoubleType.js +14 -9
- package/dist/types/DoubleType.js.map +1 -1
- package/dist/types/DoubleType.spec.js +5 -3
- package/dist/types/DoubleType.spec.js.map +1 -1
- package/dist/types/DynamicType.d.ts +2 -0
- package/dist/types/DynamicType.js +6 -2
- package/dist/types/DynamicType.js.map +1 -1
- package/dist/types/DynamicType.spec.js +2 -2
- package/dist/types/DynamicType.spec.js.map +1 -1
- package/dist/types/EnumType.d.ts +22 -0
- package/dist/types/EnumType.js +55 -0
- package/dist/types/EnumType.js.map +1 -0
- package/dist/types/FloatType.d.ts +2 -0
- package/dist/types/FloatType.js +14 -9
- package/dist/types/FloatType.js.map +1 -1
- package/dist/types/FloatType.spec.js +4 -2
- package/dist/types/FloatType.spec.js.map +1 -1
- package/dist/types/FunctionType.d.ts +7 -31
- package/dist/types/FunctionType.js +11 -57
- package/dist/types/FunctionType.js.map +1 -1
- package/dist/types/IntegerType.d.ts +2 -0
- package/dist/types/IntegerType.js +14 -9
- package/dist/types/IntegerType.js.map +1 -1
- package/dist/types/IntegerType.spec.js +5 -3
- package/dist/types/IntegerType.spec.js.map +1 -1
- package/dist/types/InterfaceType.d.ts +13 -4
- package/dist/types/InterfaceType.js +48 -8
- package/dist/types/InterfaceType.js.map +1 -1
- package/dist/types/InterfaceType.spec.d.ts +1 -0
- package/dist/types/InterfaceType.spec.js +194 -0
- package/dist/types/InterfaceType.spec.js.map +1 -0
- package/dist/types/InvalidType.d.ts +4 -2
- package/dist/types/InvalidType.js +10 -5
- package/dist/types/InvalidType.js.map +1 -1
- package/dist/types/InvalidType.spec.js +4 -2
- package/dist/types/InvalidType.spec.js.map +1 -1
- package/dist/types/LazyType.d.ts +8 -7
- package/dist/types/LazyType.js +22 -10
- package/dist/types/LazyType.js.map +1 -1
- package/dist/types/LongIntegerType.d.ts +2 -0
- package/dist/types/LongIntegerType.js +14 -9
- package/dist/types/LongIntegerType.js.map +1 -1
- package/dist/types/LongIntegerType.spec.js +4 -2
- package/dist/types/LongIntegerType.spec.js.map +1 -1
- package/dist/types/ObjectType.d.ts +8 -4
- package/dist/types/ObjectType.js +9 -4
- package/dist/types/ObjectType.js.map +1 -1
- package/dist/types/ObjectType.spec.js +2 -2
- package/dist/types/ObjectType.spec.js.map +1 -1
- package/dist/types/StringType.d.ts +4 -2
- package/dist/types/StringType.js +9 -4
- package/dist/types/StringType.js.map +1 -1
- package/dist/types/StringType.spec.js +4 -2
- package/dist/types/StringType.spec.js.map +1 -1
- package/dist/types/TypedFunctionType.d.ts +28 -0
- package/dist/types/TypedFunctionType.js +88 -0
- package/dist/types/TypedFunctionType.js.map +1 -0
- package/dist/types/TypedFunctionType.spec.d.ts +1 -0
- package/dist/types/TypedFunctionType.spec.js +37 -0
- package/dist/types/TypedFunctionType.spec.js.map +1 -0
- package/dist/types/UninitializedType.js +3 -3
- package/dist/types/UninitializedType.js.map +1 -1
- package/dist/types/VoidType.d.ts +4 -2
- package/dist/types/VoidType.js +8 -4
- package/dist/types/VoidType.js.map +1 -1
- package/dist/types/VoidType.spec.js +2 -2
- package/dist/types/VoidType.spec.js.map +1 -1
- package/dist/types/helpers.d.ts +42 -0
- package/dist/types/helpers.js +118 -0
- package/dist/types/helpers.js.map +1 -0
- package/dist/util.d.ts +91 -21
- package/dist/util.js +364 -114
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.d.ts +19 -2
- package/dist/validators/ClassValidator.js +164 -103
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +30 -19
- 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/index.d.ts +0 -3
- package/dist/preprocessor/index.js +0 -16
- package/dist/preprocessor/index.js.map +0 -1
- package/dist/types/FunctionType.spec.js +0 -23
- package/dist/types/FunctionType.spec.js.map +0 -1
package/dist/util.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.util = exports.standardizePath = exports.Util = void 0;
|
|
3
|
+
exports.MAX_PARAM_COUNT = exports.util = exports.standardizePath = exports.Util = void 0;
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const fsExtra = require("fs-extra");
|
|
6
6
|
const jsonc_parser_1 = require("jsonc-parser");
|
|
7
7
|
const path = require("path");
|
|
8
|
-
const
|
|
8
|
+
const roku_deploy_1 = require("roku-deploy");
|
|
9
9
|
const vscode_uri_1 = require("vscode-uri");
|
|
10
10
|
const xml2js = require("xml2js");
|
|
11
11
|
const DiagnosticMessages_1 = require("./DiagnosticMessages");
|
|
@@ -13,7 +13,7 @@ const BooleanType_1 = require("./types/BooleanType");
|
|
|
13
13
|
const DoubleType_1 = require("./types/DoubleType");
|
|
14
14
|
const DynamicType_1 = require("./types/DynamicType");
|
|
15
15
|
const FloatType_1 = require("./types/FloatType");
|
|
16
|
-
const
|
|
16
|
+
const TypedFunctionType_1 = require("./types/TypedFunctionType");
|
|
17
17
|
const IntegerType_1 = require("./types/IntegerType");
|
|
18
18
|
const InvalidType_1 = require("./types/InvalidType");
|
|
19
19
|
const LongIntegerType_1 = require("./types/LongIntegerType");
|
|
@@ -22,10 +22,13 @@ const StringType_1 = require("./types/StringType");
|
|
|
22
22
|
const VoidType_1 = require("./types/VoidType");
|
|
23
23
|
const Parser_1 = require("./parser/Parser");
|
|
24
24
|
const Logger_1 = require("./Logger");
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
25
|
+
const TokenKind_1 = require("./lexer/TokenKind");
|
|
26
|
+
const reflection_1 = require("./astUtils/reflection");
|
|
27
|
+
const visitors_1 = require("./astUtils/visitors");
|
|
28
28
|
const source_map_1 = require("source-map");
|
|
29
|
+
const SGTypes_1 = require("./parser/SGTypes");
|
|
30
|
+
const LazyType_1 = require("./types/LazyType");
|
|
31
|
+
const FunctionType_1 = require("./types/FunctionType");
|
|
29
32
|
class Util {
|
|
30
33
|
clearConsole() {
|
|
31
34
|
// process.stdout.write('\x1Bc');
|
|
@@ -125,7 +128,7 @@ class Util {
|
|
|
125
128
|
colIndex++;
|
|
126
129
|
}
|
|
127
130
|
}
|
|
128
|
-
return
|
|
131
|
+
return this.createRange(lineIndex, colIndex, lineIndex, colIndex + length);
|
|
129
132
|
}
|
|
130
133
|
/**
|
|
131
134
|
* Load the contents of a config file.
|
|
@@ -154,16 +157,23 @@ class Util {
|
|
|
154
157
|
//load the project file
|
|
155
158
|
let projectFileContents = fsExtra.readFileSync(configFilePath).toString();
|
|
156
159
|
let parseErrors = [];
|
|
157
|
-
let projectConfig = jsonc_parser_1.parse(projectFileContents, parseErrors
|
|
160
|
+
let projectConfig = (0, jsonc_parser_1.parse)(projectFileContents, parseErrors, {
|
|
161
|
+
allowEmptyContent: true,
|
|
162
|
+
allowTrailingComma: true,
|
|
163
|
+
disallowComments: false
|
|
164
|
+
});
|
|
158
165
|
if (parseErrors.length > 0) {
|
|
159
166
|
let err = parseErrors[0];
|
|
160
|
-
let diagnostic = Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.bsConfigJsonHasSyntaxErrors(jsonc_parser_1.printParseErrorCode(parseErrors[0].error))), { file: {
|
|
167
|
+
let diagnostic = Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.bsConfigJsonHasSyntaxErrors((0, jsonc_parser_1.printParseErrorCode)(parseErrors[0].error))), { file: {
|
|
161
168
|
srcPath: configFilePath
|
|
162
169
|
}, range: this.getRangeFromOffsetLength(projectFileContents, err.offset, err.length) });
|
|
163
170
|
throw diagnostic; //eslint-disable-line @typescript-eslint/no-throw-literal
|
|
164
171
|
}
|
|
165
|
-
this.resolvePluginPaths(projectConfig, configFilePath);
|
|
166
172
|
let projectFileCwd = path.dirname(configFilePath);
|
|
173
|
+
//`plugins` paths should be relative to the current bsconfig
|
|
174
|
+
this.resolvePathsRelativeTo(projectConfig, 'plugins', projectFileCwd);
|
|
175
|
+
//`require` paths should be relative to cwd
|
|
176
|
+
exports.util.resolvePathsRelativeTo(projectConfig, 'require', projectFileCwd);
|
|
167
177
|
let result;
|
|
168
178
|
//if the project has a base file, load it
|
|
169
179
|
if (projectConfig && typeof projectConfig.extends === 'string') {
|
|
@@ -191,26 +201,22 @@ class Util {
|
|
|
191
201
|
}
|
|
192
202
|
}
|
|
193
203
|
/**
|
|
194
|
-
*
|
|
195
|
-
* and
|
|
196
|
-
* @param
|
|
197
|
-
* @param configFilePath Path of the configuration file
|
|
204
|
+
* Convert relative paths to absolute paths, relative to the given directory. Also de-dupes the paths. Modifies the array in-place
|
|
205
|
+
* @param paths the list of paths to be resolved and deduped
|
|
206
|
+
* @param relativeDir the path to the folder where the paths should be resolved relative to. This should be an absolute path
|
|
198
207
|
*/
|
|
199
|
-
|
|
208
|
+
resolvePathsRelativeTo(collection, key, relativeDir) {
|
|
200
209
|
var _a;
|
|
201
|
-
if (
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
exists[p] = true;
|
|
211
|
-
return true;
|
|
212
|
-
});
|
|
210
|
+
if (!collection[key]) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const result = new Set();
|
|
214
|
+
for (const p of (_a = collection[key]) !== null && _a !== void 0 ? _a : []) {
|
|
215
|
+
if (p) {
|
|
216
|
+
result.add((p === null || p === void 0 ? void 0 : p.startsWith('.')) ? path.resolve(relativeDir, p) : p);
|
|
217
|
+
}
|
|
213
218
|
}
|
|
219
|
+
collection[key] = [...result];
|
|
214
220
|
}
|
|
215
221
|
/**
|
|
216
222
|
* Do work within the scope of a changed current working directory
|
|
@@ -270,25 +276,26 @@ class Util {
|
|
|
270
276
|
normalizeConfig(config) {
|
|
271
277
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
272
278
|
config = config || {};
|
|
279
|
+
config.cwd = (_a = config.cwd) !== null && _a !== void 0 ? _a : process.cwd();
|
|
273
280
|
config.deploy = config.deploy === true ? true : false;
|
|
274
|
-
//use default
|
|
275
|
-
config.files = (
|
|
281
|
+
//use default files array from rokuDeploy
|
|
282
|
+
config.files = (_b = config.files) !== null && _b !== void 0 ? _b : [...roku_deploy_1.DefaultFiles];
|
|
276
283
|
config.createPackage = config.createPackage === false ? false : true;
|
|
277
|
-
let rootFolderName = path.basename(
|
|
278
|
-
config.outFile = (
|
|
284
|
+
let rootFolderName = path.basename(config.cwd);
|
|
285
|
+
config.outFile = (_c = config.outFile) !== null && _c !== void 0 ? _c : `./out/${rootFolderName}.zip`;
|
|
279
286
|
config.sourceMap = config.sourceMap === true;
|
|
280
|
-
config.username = (
|
|
287
|
+
config.username = (_d = config.username) !== null && _d !== void 0 ? _d : 'rokudev';
|
|
281
288
|
config.watch = config.watch === true ? true : false;
|
|
282
289
|
config.emitFullPaths = config.emitFullPaths === true ? true : false;
|
|
283
290
|
config.retainStagingFolder = config.retainStagingFolder === true ? true : false;
|
|
284
291
|
config.copyToStaging = config.copyToStaging === false ? false : true;
|
|
285
|
-
config.ignoreErrorCodes = (
|
|
286
|
-
config.diagnosticFilters = (
|
|
287
|
-
config.plugins = (
|
|
292
|
+
config.ignoreErrorCodes = (_e = config.ignoreErrorCodes) !== null && _e !== void 0 ? _e : [];
|
|
293
|
+
config.diagnosticFilters = (_f = config.diagnosticFilters) !== null && _f !== void 0 ? _f : [];
|
|
294
|
+
config.plugins = (_g = config.plugins) !== null && _g !== void 0 ? _g : [];
|
|
288
295
|
config.autoImportComponentScript = config.autoImportComponentScript === true ? true : false;
|
|
289
296
|
config.showDiagnosticsInConsole = config.showDiagnosticsInConsole === false ? false : true;
|
|
290
297
|
config.sourceRoot = config.sourceRoot ? standardizePath(config.sourceRoot) : undefined;
|
|
291
|
-
config.
|
|
298
|
+
config.allowBrighterScriptInBrightScript = config.allowBrighterScriptInBrightScript === true ? true : false;
|
|
292
299
|
config.emitDefinitions = config.emitDefinitions === true ? true : false;
|
|
293
300
|
if (typeof config.logLevel === 'string') {
|
|
294
301
|
config.logLevel = Logger_1.LogLevel[config.logLevel.toLowerCase()];
|
|
@@ -387,15 +394,15 @@ class Util {
|
|
|
387
394
|
}
|
|
388
395
|
/**
|
|
389
396
|
* Compute the relative path from the source file to the target file
|
|
390
|
-
* @param
|
|
391
|
-
* @param
|
|
397
|
+
* @param pkgSrcPath - the absolute path to the source, where cwd is the package location
|
|
398
|
+
* @param pkgTargetPath - the absolute path to the target, where cwd is the package location
|
|
392
399
|
*/
|
|
393
|
-
getRelativePath(
|
|
394
|
-
|
|
395
|
-
|
|
400
|
+
getRelativePath(pkgSrcPath, pkgTargetPath) {
|
|
401
|
+
pkgSrcPath = path.normalize(pkgSrcPath);
|
|
402
|
+
pkgTargetPath = path.normalize(pkgTargetPath);
|
|
396
403
|
//break by path separator
|
|
397
|
-
let sourceParts =
|
|
398
|
-
let targetParts =
|
|
404
|
+
let sourceParts = pkgSrcPath.split(path.sep);
|
|
405
|
+
let targetParts = pkgTargetPath.split(path.sep);
|
|
399
406
|
let commonParts = [];
|
|
400
407
|
//find their common root
|
|
401
408
|
for (let i = 0; i < targetParts.length; i++) {
|
|
@@ -424,10 +431,10 @@ class Util {
|
|
|
424
431
|
findBeginningVariableExpression(dottedGet) {
|
|
425
432
|
let left = dottedGet;
|
|
426
433
|
while (left) {
|
|
427
|
-
if (
|
|
434
|
+
if ((0, reflection_1.isVariableExpression)(left)) {
|
|
428
435
|
return left;
|
|
429
436
|
}
|
|
430
|
-
else if (
|
|
437
|
+
else if ((0, reflection_1.isDottedGetExpression)(left)) {
|
|
431
438
|
left = left.obj;
|
|
432
439
|
}
|
|
433
440
|
else {
|
|
@@ -573,7 +580,7 @@ class Util {
|
|
|
573
580
|
*/
|
|
574
581
|
async getFilePaths(options) {
|
|
575
582
|
let rootDir = this.getRootDir(options);
|
|
576
|
-
let files = await rokuDeploy.getFilePaths(options.files, rootDir);
|
|
583
|
+
let files = await roku_deploy_1.rokuDeploy.getFilePaths(options.files, rootDir);
|
|
577
584
|
return files;
|
|
578
585
|
}
|
|
579
586
|
/**
|
|
@@ -598,11 +605,12 @@ class Util {
|
|
|
598
605
|
*/
|
|
599
606
|
diagnosticIsSuppressed(diagnostic) {
|
|
600
607
|
var _a, _b;
|
|
608
|
+
const diagnosticCode = typeof diagnostic.code === 'string' ? diagnostic.code.toLowerCase() : diagnostic.code;
|
|
601
609
|
for (let flag of (_b = (_a = diagnostic.file) === null || _a === void 0 ? void 0 : _a.commentFlags) !== null && _b !== void 0 ? _b : []) {
|
|
602
610
|
//this diagnostic is affected by this flag
|
|
603
611
|
if (this.rangeContains(flag.affectedRange, diagnostic.range.start)) {
|
|
604
612
|
//if the flag acts upon this diagnostic's code
|
|
605
|
-
if (flag.codes === null || flag.codes.includes(
|
|
613
|
+
if (flag.codes === null || flag.codes.includes(diagnosticCode)) {
|
|
606
614
|
return true;
|
|
607
615
|
}
|
|
608
616
|
}
|
|
@@ -807,6 +815,40 @@ class Util {
|
|
|
807
815
|
}
|
|
808
816
|
};
|
|
809
817
|
}
|
|
818
|
+
/**
|
|
819
|
+
* Given a list of ranges, create a range that starts with the first non-null lefthand range, and ends with the first non-null
|
|
820
|
+
* righthand range. Returns undefined if none of the items have a range.
|
|
821
|
+
*/
|
|
822
|
+
createBoundingRange(...locatables) {
|
|
823
|
+
let leftmostRange;
|
|
824
|
+
let rightmostRange;
|
|
825
|
+
for (let i = 0; i < locatables.length; i++) {
|
|
826
|
+
//set the leftmost non-null-range item
|
|
827
|
+
const left = locatables[i];
|
|
828
|
+
//the range might be a getter, so access it exactly once
|
|
829
|
+
const leftRange = left === null || left === void 0 ? void 0 : left.range;
|
|
830
|
+
if (!leftmostRange && leftRange) {
|
|
831
|
+
leftmostRange = leftRange;
|
|
832
|
+
}
|
|
833
|
+
//set the rightmost non-null-range item
|
|
834
|
+
const right = locatables[locatables.length - 1 - i];
|
|
835
|
+
//the range might be a getter, so access it exactly once
|
|
836
|
+
const rightRange = right === null || right === void 0 ? void 0 : right.range;
|
|
837
|
+
if (!rightmostRange && rightRange) {
|
|
838
|
+
rightmostRange = rightRange;
|
|
839
|
+
}
|
|
840
|
+
//if we have both sides, quit
|
|
841
|
+
if (leftmostRange && rightmostRange) {
|
|
842
|
+
break;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
if (leftmostRange) {
|
|
846
|
+
return this.createRangeFromPositions(leftmostRange.start, rightmostRange.end);
|
|
847
|
+
}
|
|
848
|
+
else {
|
|
849
|
+
return undefined;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
810
852
|
/**
|
|
811
853
|
* Create a `Position` object. Prefer this over `Position.create` for performance reasons
|
|
812
854
|
*/
|
|
@@ -831,71 +873,95 @@ class Util {
|
|
|
831
873
|
/**
|
|
832
874
|
* Convert a token into a BscType
|
|
833
875
|
*/
|
|
834
|
-
tokenToBscType(token,
|
|
876
|
+
tokenToBscType(token, allowBrighterscriptTypes = true, currentNamespaceName) {
|
|
835
877
|
if (!token) {
|
|
836
878
|
return new DynamicType_1.DynamicType();
|
|
837
879
|
}
|
|
838
880
|
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
839
881
|
switch (token.kind) {
|
|
840
|
-
case
|
|
841
|
-
|
|
842
|
-
case
|
|
882
|
+
case TokenKind_1.TokenKind.Boolean:
|
|
883
|
+
return new BooleanType_1.BooleanType(token.text);
|
|
884
|
+
case TokenKind_1.TokenKind.True:
|
|
885
|
+
case TokenKind_1.TokenKind.False:
|
|
843
886
|
return new BooleanType_1.BooleanType();
|
|
844
|
-
case
|
|
845
|
-
|
|
887
|
+
case TokenKind_1.TokenKind.Double:
|
|
888
|
+
return new DoubleType_1.DoubleType(token.text);
|
|
889
|
+
case TokenKind_1.TokenKind.DoubleLiteral:
|
|
846
890
|
return new DoubleType_1.DoubleType();
|
|
847
|
-
case
|
|
848
|
-
return new DynamicType_1.DynamicType();
|
|
849
|
-
case
|
|
850
|
-
|
|
891
|
+
case TokenKind_1.TokenKind.Dynamic:
|
|
892
|
+
return new DynamicType_1.DynamicType(token.text);
|
|
893
|
+
case TokenKind_1.TokenKind.Float:
|
|
894
|
+
return new FloatType_1.FloatType(token.text);
|
|
895
|
+
case TokenKind_1.TokenKind.FloatLiteral:
|
|
851
896
|
return new FloatType_1.FloatType();
|
|
852
|
-
case
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
case
|
|
897
|
+
case TokenKind_1.TokenKind.Function:
|
|
898
|
+
return new FunctionType_1.FunctionType();
|
|
899
|
+
case TokenKind_1.TokenKind.Integer:
|
|
900
|
+
return new IntegerType_1.IntegerType(token.text);
|
|
901
|
+
case TokenKind_1.TokenKind.IntegerLiteral:
|
|
857
902
|
return new IntegerType_1.IntegerType();
|
|
858
|
-
case
|
|
859
|
-
return new InvalidType_1.InvalidType();
|
|
860
|
-
case
|
|
861
|
-
|
|
903
|
+
case TokenKind_1.TokenKind.Invalid:
|
|
904
|
+
return new InvalidType_1.InvalidType(token.text);
|
|
905
|
+
case TokenKind_1.TokenKind.LongInteger:
|
|
906
|
+
return new LongIntegerType_1.LongIntegerType(token.text);
|
|
907
|
+
case TokenKind_1.TokenKind.LongIntegerLiteral:
|
|
862
908
|
return new LongIntegerType_1.LongIntegerType();
|
|
863
|
-
case
|
|
864
|
-
return new ObjectType_1.ObjectType();
|
|
865
|
-
case
|
|
866
|
-
|
|
867
|
-
case
|
|
868
|
-
case
|
|
869
|
-
case
|
|
909
|
+
case TokenKind_1.TokenKind.Object:
|
|
910
|
+
return new ObjectType_1.ObjectType(token.text);
|
|
911
|
+
case TokenKind_1.TokenKind.String:
|
|
912
|
+
return new StringType_1.StringType(token.text);
|
|
913
|
+
case TokenKind_1.TokenKind.StringLiteral:
|
|
914
|
+
case TokenKind_1.TokenKind.TemplateStringExpressionBegin:
|
|
915
|
+
case TokenKind_1.TokenKind.TemplateStringExpressionEnd:
|
|
916
|
+
case TokenKind_1.TokenKind.TemplateStringQuasi:
|
|
870
917
|
return new StringType_1.StringType();
|
|
871
|
-
case
|
|
872
|
-
return new VoidType_1.VoidType();
|
|
873
|
-
case
|
|
874
|
-
|
|
918
|
+
case TokenKind_1.TokenKind.Void:
|
|
919
|
+
return new VoidType_1.VoidType(token.text);
|
|
920
|
+
case TokenKind_1.TokenKind.Identifier:
|
|
921
|
+
let typeText = token.text.trim().toLowerCase();
|
|
922
|
+
let typeClass;
|
|
923
|
+
switch (typeText) {
|
|
875
924
|
case 'boolean':
|
|
876
|
-
|
|
925
|
+
typeClass = new BooleanType_1.BooleanType(token.text);
|
|
926
|
+
break;
|
|
877
927
|
case 'double':
|
|
878
|
-
|
|
928
|
+
typeClass = new DoubleType_1.DoubleType(token.text);
|
|
929
|
+
break;
|
|
879
930
|
case 'float':
|
|
880
|
-
|
|
931
|
+
typeClass = new FloatType_1.FloatType(token.text);
|
|
932
|
+
break;
|
|
881
933
|
case 'function':
|
|
882
|
-
|
|
934
|
+
typeClass = new TypedFunctionType_1.TypedFunctionType(new DynamicType_1.DynamicType(token.text));
|
|
935
|
+
break;
|
|
883
936
|
case 'integer':
|
|
884
|
-
|
|
937
|
+
typeClass = new IntegerType_1.IntegerType(token.text);
|
|
938
|
+
break;
|
|
885
939
|
case 'invalid':
|
|
886
|
-
|
|
940
|
+
typeClass = new InvalidType_1.InvalidType(token.text);
|
|
941
|
+
break;
|
|
887
942
|
case 'longinteger':
|
|
888
|
-
|
|
943
|
+
typeClass = new LongIntegerType_1.LongIntegerType(token.text);
|
|
944
|
+
break;
|
|
889
945
|
case 'object':
|
|
890
|
-
|
|
946
|
+
typeClass = new ObjectType_1.ObjectType(token.text);
|
|
947
|
+
break;
|
|
891
948
|
case 'string':
|
|
892
|
-
|
|
949
|
+
typeClass = new StringType_1.StringType(token.text);
|
|
950
|
+
break;
|
|
893
951
|
case 'void':
|
|
894
|
-
|
|
952
|
+
typeClass = new VoidType_1.VoidType(token.text);
|
|
953
|
+
break;
|
|
954
|
+
case 'dynamic':
|
|
955
|
+
typeClass = new DynamicType_1.DynamicType(token.text);
|
|
956
|
+
break;
|
|
895
957
|
}
|
|
896
|
-
if (
|
|
897
|
-
|
|
958
|
+
if (!typeClass && allowBrighterscriptTypes) {
|
|
959
|
+
typeClass = new LazyType_1.LazyType((context) => {
|
|
960
|
+
var _a, _b;
|
|
961
|
+
return (_b = (_a = context === null || context === void 0 ? void 0 : context.scope) === null || _a === void 0 ? void 0 : _a.getNamedTypeStatement(typeText, currentNamespaceName === null || currentNamespaceName === void 0 ? void 0 : currentNamespaceName.getName())) === null || _b === void 0 ? void 0 : _b.getThisBscType();
|
|
962
|
+
});
|
|
898
963
|
}
|
|
964
|
+
return typeClass;
|
|
899
965
|
}
|
|
900
966
|
}
|
|
901
967
|
/**
|
|
@@ -976,19 +1042,22 @@ class Util {
|
|
|
976
1042
|
const expressions = [expression];
|
|
977
1043
|
const variableExpressions = [];
|
|
978
1044
|
const uniqueVarNames = new Set();
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
expression === null || expression === void 0 ? void 0 : expression.walk((expression) => {
|
|
982
|
-
if (astUtils_1.isExpression(expression)) {
|
|
1045
|
+
function expressionWalker(expression) {
|
|
1046
|
+
if ((0, reflection_1.isExpression)(expression)) {
|
|
983
1047
|
expressions.push(expression);
|
|
984
1048
|
}
|
|
985
|
-
if (
|
|
1049
|
+
if ((0, reflection_1.isVariableExpression)(expression)) {
|
|
986
1050
|
variableExpressions.push(expression);
|
|
987
1051
|
uniqueVarNames.add(expression.name.text);
|
|
988
1052
|
}
|
|
989
|
-
}
|
|
990
|
-
|
|
1053
|
+
}
|
|
1054
|
+
// Collect all expressions. Most of these expressions are fairly small so this should be quick!
|
|
1055
|
+
// This should only be called during transpile time and only when we actually need it.
|
|
1056
|
+
expression === null || expression === void 0 ? void 0 : expression.walk(expressionWalker, {
|
|
1057
|
+
walkMode: visitors_1.WalkMode.visitExpressions
|
|
991
1058
|
});
|
|
1059
|
+
//handle the expression itself (for situations when expression is a VariableExpression)
|
|
1060
|
+
expressionWalker(expression);
|
|
992
1061
|
return { expressions: expressions, varExpressions: variableExpressions, uniqueVarNames: [...uniqueVarNames] };
|
|
993
1062
|
}
|
|
994
1063
|
/**
|
|
@@ -1006,20 +1075,25 @@ class Util {
|
|
|
1006
1075
|
return new source_map_1.SourceNode(null, null, source, chunks);
|
|
1007
1076
|
}
|
|
1008
1077
|
/**
|
|
1009
|
-
* Creates a new SGAttribute object, but keeps the existing Range references (since those
|
|
1078
|
+
* Creates a new SGAttribute object, but keeps the existing Range references (since those should be immutable)
|
|
1010
1079
|
*/
|
|
1011
1080
|
cloneSGAttribute(attr, value) {
|
|
1012
|
-
return {
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1081
|
+
return new SGTypes_1.SGAttribute({ text: attr.tokens.key.text, range: attr.range }, { text: '=' }, { text: '"' }, { text: value, range: attr.tokens.value.range }, { text: '"' });
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* Shorthand for creating a new source node
|
|
1085
|
+
*/
|
|
1086
|
+
sourceNode(source, locatable, code) {
|
|
1087
|
+
if (code !== undefined) {
|
|
1088
|
+
const node = new source_map_1.SourceNode(null, null, source, code);
|
|
1089
|
+
if (locatable.range) {
|
|
1090
|
+
//convert 0-based Range line to 1-based SourceNode line
|
|
1091
|
+
node.line = locatable.range.start.line + 1;
|
|
1092
|
+
//SourceNode columns are 0-based so no conversion necessary
|
|
1093
|
+
node.column = locatable.range.start.character;
|
|
1094
|
+
}
|
|
1095
|
+
return node;
|
|
1096
|
+
}
|
|
1023
1097
|
}
|
|
1024
1098
|
/**
|
|
1025
1099
|
* Remove leading simple protocols from a path (if present)
|
|
@@ -1033,10 +1107,13 @@ class Util {
|
|
|
1033
1107
|
return pkgPath;
|
|
1034
1108
|
}
|
|
1035
1109
|
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Converts a path into a standardized format (drive letter to lower, remove extra slashes, use single slash type, resolve relative parts, etc...)
|
|
1112
|
+
*/
|
|
1036
1113
|
standardizePath(thePath) {
|
|
1037
|
-
return exports.util.driveLetterToLower(
|
|
1114
|
+
return exports.util.driveLetterToLower((0, roku_deploy_1.standardizePath)(thePath));
|
|
1038
1115
|
}
|
|
1039
|
-
|
|
1116
|
+
/**
|
|
1040
1117
|
* Copy the version of bslib from local node_modules to the staging folder
|
|
1041
1118
|
*/
|
|
1042
1119
|
async copyBslibToStaging(stagingDir) {
|
|
@@ -1077,13 +1154,60 @@ class Util {
|
|
|
1077
1154
|
};
|
|
1078
1155
|
}
|
|
1079
1156
|
/**
|
|
1080
|
-
*
|
|
1157
|
+
* Gets the minimum and maximum number of allowed params
|
|
1158
|
+
* @param params The list of callable parameters to check
|
|
1159
|
+
* @returns the minimum and maximum number of allowed params
|
|
1160
|
+
*/
|
|
1161
|
+
getMinMaxParamCount(params) {
|
|
1162
|
+
//get min/max parameter count for callable
|
|
1163
|
+
let minParams = 0;
|
|
1164
|
+
let maxParams = 0;
|
|
1165
|
+
let continueCheckingForRequired = true;
|
|
1166
|
+
for (let param of params) {
|
|
1167
|
+
maxParams++;
|
|
1168
|
+
//optional parameters must come last, so we can assume that minParams won't increase once we hit
|
|
1169
|
+
//the first isOptional
|
|
1170
|
+
if (continueCheckingForRequired && !param.isOptional) {
|
|
1171
|
+
minParams++;
|
|
1172
|
+
}
|
|
1173
|
+
else {
|
|
1174
|
+
continueCheckingForRequired = false;
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
return { min: minParams, max: maxParams };
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Gets the minimum and maximum number of allowed params for ALL functions with the name of the function call
|
|
1181
|
+
* @param callablesByLowerName The map of callable containers
|
|
1182
|
+
* @param expCall function call expression to use for the name
|
|
1183
|
+
* @returns the minimum and maximum number of allowed params
|
|
1184
|
+
*/
|
|
1185
|
+
getMinMaxParamCountByFunctionCall(callablesByLowerName, expCall) {
|
|
1186
|
+
const callablesWithThisName = this.getCallableContainersByName(callablesByLowerName, expCall);
|
|
1187
|
+
if ((callablesWithThisName === null || callablesWithThisName === void 0 ? void 0 : callablesWithThisName.length) > 0) {
|
|
1188
|
+
const paramCount = { min: exports.MAX_PARAM_COUNT, max: 0 };
|
|
1189
|
+
for (const callableContainer of callablesWithThisName) {
|
|
1190
|
+
let specificParamCount = exports.util.getMinMaxParamCount(callableContainer.callable.params);
|
|
1191
|
+
if (specificParamCount.max > paramCount.max) {
|
|
1192
|
+
paramCount.max = specificParamCount.max;
|
|
1193
|
+
}
|
|
1194
|
+
if (specificParamCount.min < paramCount.min) {
|
|
1195
|
+
paramCount.min = specificParamCount.min;
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
return paramCount;
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
/**
|
|
1202
|
+
* Finds the array of callables from a container map, based on the name of the function call
|
|
1081
1203
|
* If the callable was called in a function in a namespace, functions in that namespace are preferred
|
|
1204
|
+
* @param callablesByLowerName The map of callable containers
|
|
1205
|
+
* @param expCall function call expression to use for the name
|
|
1082
1206
|
* @return an array with callable containers - could be empty if nothing was found
|
|
1083
1207
|
*/
|
|
1084
|
-
|
|
1208
|
+
getCallableContainersByName(callablesByLowerName, expCall) {
|
|
1085
1209
|
let callablesWithThisName = [];
|
|
1086
|
-
const lowerName = expCall.name.toLowerCase();
|
|
1210
|
+
const lowerName = expCall.name.text.toLowerCase();
|
|
1087
1211
|
if (expCall.functionExpression.namespaceName) {
|
|
1088
1212
|
// prefer namespaced function
|
|
1089
1213
|
const potentialNamespacedCallable = expCall.functionExpression.namespaceName.getName(Parser_1.ParseMode.BrightScript).toLowerCase() + '_' + lowerName;
|
|
@@ -1095,6 +1219,131 @@ class Util {
|
|
|
1095
1219
|
}
|
|
1096
1220
|
return callablesWithThisName;
|
|
1097
1221
|
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Sort an array of objects that have a Range
|
|
1224
|
+
*/
|
|
1225
|
+
sortByRange(locatables) {
|
|
1226
|
+
//sort the tokens by range
|
|
1227
|
+
return locatables.sort((a, b) => {
|
|
1228
|
+
//start line
|
|
1229
|
+
if (a.range.start.line < b.range.start.line) {
|
|
1230
|
+
return -1;
|
|
1231
|
+
}
|
|
1232
|
+
if (a.range.start.line > b.range.start.line) {
|
|
1233
|
+
return 1;
|
|
1234
|
+
}
|
|
1235
|
+
//start char
|
|
1236
|
+
if (a.range.start.character < b.range.start.character) {
|
|
1237
|
+
return -1;
|
|
1238
|
+
}
|
|
1239
|
+
if (a.range.start.character > b.range.start.character) {
|
|
1240
|
+
return 1;
|
|
1241
|
+
}
|
|
1242
|
+
//end line
|
|
1243
|
+
if (a.range.end.line < b.range.end.line) {
|
|
1244
|
+
return -1;
|
|
1245
|
+
}
|
|
1246
|
+
if (a.range.end.line > b.range.end.line) {
|
|
1247
|
+
return 1;
|
|
1248
|
+
}
|
|
1249
|
+
//end char
|
|
1250
|
+
if (a.range.end.character < b.range.end.character) {
|
|
1251
|
+
return -1;
|
|
1252
|
+
}
|
|
1253
|
+
else if (a.range.end.character > b.range.end.character) {
|
|
1254
|
+
return 1;
|
|
1255
|
+
}
|
|
1256
|
+
return 0;
|
|
1257
|
+
});
|
|
1258
|
+
}
|
|
1259
|
+
/**
|
|
1260
|
+
* Split the given text and return ranges for each chunk.
|
|
1261
|
+
* Only works for single-line strings
|
|
1262
|
+
*/
|
|
1263
|
+
splitGetRange(separator, text, range) {
|
|
1264
|
+
const chunks = text.split(separator);
|
|
1265
|
+
const result = [];
|
|
1266
|
+
let offset = 0;
|
|
1267
|
+
for (let i = 0; i < chunks.length; i++) {
|
|
1268
|
+
const chunk = chunks[i];
|
|
1269
|
+
//only keep nonzero chunks
|
|
1270
|
+
if (chunk.length > 0) {
|
|
1271
|
+
result.push({
|
|
1272
|
+
text: chunk,
|
|
1273
|
+
range: this.createRange(range.start.line, range.start.character + offset, range.end.line, range.start.character + offset + chunk.length)
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1276
|
+
offset += chunk.length + separator.length;
|
|
1277
|
+
}
|
|
1278
|
+
return result;
|
|
1279
|
+
}
|
|
1280
|
+
/*
|
|
1281
|
+
* Wrap the given code in a markdown code fence (with the language)
|
|
1282
|
+
*/
|
|
1283
|
+
mdFence(code, language = '') {
|
|
1284
|
+
return '```' + language + '\n' + code + '\n```';
|
|
1285
|
+
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Finds a callable from a container map based on the name AND number of arguments
|
|
1288
|
+
* If the callable was called in a function in a namespace, functions in that namespace are preferred
|
|
1289
|
+
* The first callable that matches the name AND will accept the number of arguments given is returned
|
|
1290
|
+
* @return a callable containers that matches the call
|
|
1291
|
+
*/
|
|
1292
|
+
getCallableContainerByFunctionCall(callablesByLowerName, expCall) {
|
|
1293
|
+
const callablesWithThisName = this.getCallableContainersByName(callablesByLowerName, expCall);
|
|
1294
|
+
if ((callablesWithThisName === null || callablesWithThisName === void 0 ? void 0 : callablesWithThisName.length) > 0) {
|
|
1295
|
+
for (const callableContainer of callablesWithThisName) {
|
|
1296
|
+
const paramCount = exports.util.getMinMaxParamCount(callableContainer.callable.params);
|
|
1297
|
+
if (paramCount.min <= expCall.args.length && paramCount.max >= expCall.args.length) {
|
|
1298
|
+
return callableContainer;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Gets each part of the dotted get.
|
|
1305
|
+
* @param expression
|
|
1306
|
+
* @returns an array of the parts of the dotted get. If not fully a dotted get, then returns undefined
|
|
1307
|
+
*/
|
|
1308
|
+
getAllDottedGetParts(expression) {
|
|
1309
|
+
var _a, _b;
|
|
1310
|
+
const parts = [];
|
|
1311
|
+
let nextPart = expression;
|
|
1312
|
+
while (nextPart) {
|
|
1313
|
+
if ((0, reflection_1.isDottedGetExpression)(nextPart)) {
|
|
1314
|
+
parts.push((_a = nextPart === null || nextPart === void 0 ? void 0 : nextPart.name) === null || _a === void 0 ? void 0 : _a.text);
|
|
1315
|
+
nextPart = nextPart.obj;
|
|
1316
|
+
}
|
|
1317
|
+
else if ((0, reflection_1.isVariableExpression)(nextPart)) {
|
|
1318
|
+
parts.push((_b = nextPart === null || nextPart === void 0 ? void 0 : nextPart.name) === null || _b === void 0 ? void 0 : _b.text);
|
|
1319
|
+
break;
|
|
1320
|
+
}
|
|
1321
|
+
else {
|
|
1322
|
+
//we found a non-DottedGet expression, so return because this whole operation is invalid.
|
|
1323
|
+
return undefined;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
return parts.reverse();
|
|
1327
|
+
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Returns an integer if valid, or undefined. Eliminates checking for NaN
|
|
1330
|
+
*/
|
|
1331
|
+
parseInt(value) {
|
|
1332
|
+
const result = parseInt(value);
|
|
1333
|
+
if (!isNaN(result)) {
|
|
1334
|
+
return result;
|
|
1335
|
+
}
|
|
1336
|
+
else {
|
|
1337
|
+
return undefined;
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1341
|
+
* Converts a range to a string in the format 1:2-3:4
|
|
1342
|
+
*/
|
|
1343
|
+
rangeToString(range) {
|
|
1344
|
+
var _a, _b, _c, _d;
|
|
1345
|
+
return `${(_a = range === null || range === void 0 ? void 0 : range.start) === null || _a === void 0 ? void 0 : _a.line}:${(_b = range === null || range === void 0 ? void 0 : range.start) === null || _b === void 0 ? void 0 : _b.character}-${(_c = range === null || range === void 0 ? void 0 : range.end) === null || _c === void 0 ? void 0 : _c.line}:${(_d = range === null || range === void 0 ? void 0 : range.end) === null || _d === void 0 ? void 0 : _d.character}`;
|
|
1346
|
+
}
|
|
1098
1347
|
}
|
|
1099
1348
|
exports.Util = Util;
|
|
1100
1349
|
/**
|
|
@@ -1106,9 +1355,10 @@ function standardizePath(stringParts, ...expressions) {
|
|
|
1106
1355
|
for (let i = 0; i < stringParts.length; i++) {
|
|
1107
1356
|
result.push(stringParts[i], expressions[i]);
|
|
1108
1357
|
}
|
|
1109
|
-
return exports.util.standardizePath(result.join(''));
|
|
1358
|
+
return exports.util.driveLetterToLower((0, roku_deploy_1.standardizePath)(result.join('')));
|
|
1110
1359
|
}
|
|
1111
1360
|
exports.standardizePath = standardizePath;
|
|
1112
1361
|
exports.util = new Util();
|
|
1113
1362
|
exports.default = exports.util;
|
|
1363
|
+
exports.MAX_PARAM_COUNT = 32;
|
|
1114
1364
|
//# sourceMappingURL=util.js.map
|