brighterscript 1.0.0-alpha.2 → 1.0.0-alpha.20
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 +542 -253
- package/README.md +30 -9
- package/bsconfig.schema.json +13 -1
- package/dist/BsConfig.d.ts +4 -0
- package/dist/Cache.d.ts +3 -8
- package/dist/Cache.js +9 -14
- 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.js +5 -4
- package/dist/DependencyGraph.js.map +1 -1
- package/dist/DiagnosticFilterer.js +1 -1
- 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 +4 -14
- package/dist/LanguageServer.js +40 -26
- 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 +180 -82
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +4 -0
- package/dist/ProgramBuilder.js +30 -14
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +100 -28
- package/dist/Scope.js +382 -154
- 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 +40 -13
- package/dist/SymbolTable.js.map +1 -1
- package/dist/XmlScope.d.ts +8 -3
- package/dist/XmlScope.js +65 -27
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/AstEditor.d.ts +33 -0
- package/dist/astUtils/AstEditor.js +107 -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 +170 -0
- package/dist/astUtils/AstEditor.spec.js.map +1 -0
- package/dist/astUtils/creators.d.ts +24 -6
- package/dist/astUtils/creators.js +130 -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 +27 -8
- package/dist/astUtils/reflection.js +66 -1
- 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 +17 -2
- package/dist/astUtils/visitors.js +2 -2
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +31 -29
- 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 +97 -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 +73 -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 +9 -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 +634 -145
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +62 -30
- package/dist/files/BrsFile.js +683 -335
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +1055 -449
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.d.ts +11 -10
- package/dist/files/XmlFile.js +33 -26
- 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 +23 -4
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +129 -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 +7 -0
- package/dist/parser/BrsTranspileState.js +9 -0
- package/dist/parser/BrsTranspileState.js.map +1 -1
- package/dist/parser/Expression.d.ts +150 -34
- package/dist/parser/Expression.js +337 -150
- 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 +152 -29
- package/dist/parser/Parser.js +1095 -501
- 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 +194 -40
- package/dist/parser/Statement.js +597 -160
- 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/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 +87 -16
- package/dist/util.js +339 -94
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.d.ts +19 -2
- package/dist/validators/ClassValidator.js +163 -102
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +26 -15
- 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/parser/Parser.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { Token, Identifier } from '../lexer';
|
|
1
|
+
import type { Token, Identifier } from '../lexer/Token';
|
|
2
|
+
import { TokenKind } from '../lexer/TokenKind';
|
|
2
3
|
import type { Statement } from './Statement';
|
|
3
|
-
import { AssignmentStatement, Body, ClassStatement, FunctionStatement, ImportStatement, LibraryStatement, NamespaceStatement } from './Statement';
|
|
4
|
+
import { InterfaceStatement, AssignmentStatement, Body, ClassStatement, DottedSetStatement, EnumStatement, FunctionStatement, ImportStatement, LibraryStatement, NamespaceStatement } from './Statement';
|
|
4
5
|
import type { Expression } from './Expression';
|
|
5
|
-
import {
|
|
6
|
-
import type { Diagnostic } from 'vscode-languageserver';
|
|
6
|
+
import { AALiteralExpression, FunctionExpression, NewExpression, AnnotationExpression } from './Expression';
|
|
7
|
+
import type { Diagnostic, Position } from 'vscode-languageserver';
|
|
7
8
|
import { Logger } from '../Logger';
|
|
8
|
-
import type { BscType } from '../types/BscType';
|
|
9
9
|
import { SymbolTable } from '../SymbolTable';
|
|
10
|
+
import type { BscType } from '../types/BscType';
|
|
10
11
|
export declare class Parser {
|
|
11
12
|
/**
|
|
12
13
|
* The array of tokens passed to `parse()`
|
|
@@ -77,8 +78,7 @@ export declare class Parser {
|
|
|
77
78
|
/**
|
|
78
79
|
* Static wrapper around creating a new parser and parsing a list of tokens
|
|
79
80
|
*/
|
|
80
|
-
static parse(
|
|
81
|
-
static parse(tokens: Token[], options?: ParseOptions): Parser;
|
|
81
|
+
static parse(toParse: Token[] | string, options?: ParseOptions): Parser;
|
|
82
82
|
/**
|
|
83
83
|
* Parses an array of `Token`s into an abstract syntax tree
|
|
84
84
|
* @param toParse the array of tokens to parse. May not contain any whitespace tokens
|
|
@@ -101,6 +101,18 @@ export declare class Parser {
|
|
|
101
101
|
*/
|
|
102
102
|
private lastDiagnosticAsError;
|
|
103
103
|
private declaration;
|
|
104
|
+
/**
|
|
105
|
+
* Try to get an identifier. If not found, add diagnostic and return undefined
|
|
106
|
+
*/
|
|
107
|
+
private tryIdentifier;
|
|
108
|
+
private identifier;
|
|
109
|
+
private enumMemberStatement;
|
|
110
|
+
/**
|
|
111
|
+
* Create a new InterfaceFieldStatement. This should only be called from within `interfaceDeclaration`
|
|
112
|
+
*/
|
|
113
|
+
private interfaceFieldStatement;
|
|
114
|
+
private interfaceDeclaration;
|
|
115
|
+
private enumDeclaration;
|
|
104
116
|
/**
|
|
105
117
|
* A BrighterScript class declaration
|
|
106
118
|
*/
|
|
@@ -110,8 +122,8 @@ export declare class Parser {
|
|
|
110
122
|
* An array of CallExpression for the current function body
|
|
111
123
|
*/
|
|
112
124
|
private callExpressions;
|
|
125
|
+
private functionStatement;
|
|
113
126
|
private functionDeclaration;
|
|
114
|
-
private identifier;
|
|
115
127
|
private functionParameter;
|
|
116
128
|
private assignment;
|
|
117
129
|
private checkLibrary;
|
|
@@ -142,6 +154,7 @@ export declare class Parser {
|
|
|
142
154
|
private annotationExpression;
|
|
143
155
|
private ternaryExpression;
|
|
144
156
|
private nullCoalescingExpression;
|
|
157
|
+
private regexLiteralExpression;
|
|
145
158
|
private templateString;
|
|
146
159
|
private tryCatchStatement;
|
|
147
160
|
private throwStatement;
|
|
@@ -212,10 +225,12 @@ export declare class Parser {
|
|
|
212
225
|
/**
|
|
213
226
|
* Tries to get the next token as a type
|
|
214
227
|
* Allows for built-in types (double, string, etc.) or namespaced custom types in Brighterscript mode
|
|
215
|
-
* Will
|
|
228
|
+
* Will return a token of whatever is next to be parsed (unless `advanceIfUnknown` is false, in which case undefined will be returned instead
|
|
216
229
|
*/
|
|
217
|
-
private
|
|
230
|
+
private typeExpression;
|
|
218
231
|
private primary;
|
|
232
|
+
private arrayLiteral;
|
|
233
|
+
private aaLiteral;
|
|
219
234
|
/**
|
|
220
235
|
* Pop token if we encounter specified token
|
|
221
236
|
*/
|
|
@@ -225,14 +240,21 @@ export declare class Parser {
|
|
|
225
240
|
* @param tokenKinds
|
|
226
241
|
*/
|
|
227
242
|
private matchAny;
|
|
243
|
+
/**
|
|
244
|
+
* If the next series of tokens matches the given set of tokens, pop them all
|
|
245
|
+
* @param tokenKinds
|
|
246
|
+
*/
|
|
247
|
+
private matchSequence;
|
|
228
248
|
/**
|
|
229
249
|
* Get next token matching a specified list, or fail with an error
|
|
230
250
|
*/
|
|
231
251
|
private consume;
|
|
252
|
+
private consumeToken;
|
|
232
253
|
/**
|
|
233
254
|
* Consume, or add a message if not found. But then continue and return undefined
|
|
234
255
|
*/
|
|
235
256
|
private tryConsume;
|
|
257
|
+
private tryConsumeToken;
|
|
236
258
|
private consumeStatementSeparators;
|
|
237
259
|
private advance;
|
|
238
260
|
private checkEndOfStatement;
|
|
@@ -245,13 +267,62 @@ export declare class Parser {
|
|
|
245
267
|
private peekNext;
|
|
246
268
|
private peek;
|
|
247
269
|
private previous;
|
|
270
|
+
/**
|
|
271
|
+
* Get the token that is {offset} indexes away from {this.current}
|
|
272
|
+
* @param offset the number of index steps away from current index to fetch
|
|
273
|
+
* @param tokenKinds the desired token must match one of these
|
|
274
|
+
* @example
|
|
275
|
+
* getToken(-1); //returns the previous token.
|
|
276
|
+
* getToken(0); //returns current token.
|
|
277
|
+
* getToken(1); //returns next token
|
|
278
|
+
*/
|
|
279
|
+
private getMatchingTokenAtOffset;
|
|
248
280
|
private synchronize;
|
|
281
|
+
/**
|
|
282
|
+
* Get the token at the specified position
|
|
283
|
+
* @param position
|
|
284
|
+
*/
|
|
285
|
+
getTokenAt(position: Position): Token;
|
|
286
|
+
/**
|
|
287
|
+
* Get the token closest to the position. if no token is found, the previous token is returned
|
|
288
|
+
* @param position
|
|
289
|
+
* @param tokens
|
|
290
|
+
*/
|
|
291
|
+
getClosestToken(position: Position): Token;
|
|
292
|
+
isPositionNextToTokenKind(position: Position, tokenKind: TokenKind): boolean;
|
|
293
|
+
getTokenBefore(currentToken: Token, tokenKind: TokenKind): Token;
|
|
294
|
+
tokenFollows(currentToken: Token, tokenKind: TokenKind): boolean;
|
|
295
|
+
getTokensUntil(currentToken: Token, tokenKind: TokenKind, direction?: -1 | 1): any[];
|
|
296
|
+
getPreviousToken(token: Token): Token;
|
|
297
|
+
getPreviousTokenFromIndex(idx: number): TokenWithIndex;
|
|
298
|
+
getPreviousTokenIgnoreNests(currentTokenIndex: number, leftBracketType: TokenKind, rightBracketType: TokenKind): TokenWithIndex;
|
|
299
|
+
/**
|
|
300
|
+
* Finds the previous token in a chain (e.g. 'm.obj.func(someFunc()).value'), skipping over any arguments of function calls
|
|
301
|
+
* If this function was called with the token at 'value' above, the previous identifier in the chain is 'func'
|
|
302
|
+
* @param currentTokenIndex token index to start from
|
|
303
|
+
* @param allowCurrent can the current token be the token that's the identifier?
|
|
304
|
+
* @returns the previous identifer
|
|
305
|
+
*/
|
|
306
|
+
getPreviousTokenInChain(currentTokenIndex: number, allowCurrent?: boolean): TokenChainMember;
|
|
307
|
+
private isAcceptableChainToken;
|
|
308
|
+
/**
|
|
309
|
+
* Builds up a chain of tokens, starting with the first in the chain, and ending with currentToken
|
|
310
|
+
* e.g. m.prop.method().field (with 'field' as currentToken) -> ["m", "prop", "method", "field"], with each element as a token
|
|
311
|
+
* @param currentToken the token that is the end of the chain
|
|
312
|
+
* @returns array of tokens
|
|
313
|
+
*/
|
|
314
|
+
getTokenChain(currentToken: Token): TokenChain;
|
|
249
315
|
/**
|
|
250
316
|
* References are found during the initial parse.
|
|
251
317
|
* However, sometimes plugins can modify the AST, requiring a full walk to re-compute all references.
|
|
252
318
|
* This does that walk.
|
|
253
319
|
*/
|
|
254
320
|
private findReferences;
|
|
321
|
+
getContainingClass(currentToken: Token): ClassStatement;
|
|
322
|
+
getContainingAA(currentToken: Token): AALiteralExpression;
|
|
323
|
+
getContainingNamespace(currentToken: Token): NamespaceStatement;
|
|
324
|
+
getContainingFunctionExpression(currentToken: Token): FunctionExpression;
|
|
325
|
+
getContainingFunctionExpressionByPosition(position: Position): FunctionExpression;
|
|
255
326
|
dispose(): void;
|
|
256
327
|
}
|
|
257
328
|
export declare enum ParseMode {
|
|
@@ -269,8 +340,11 @@ export interface ParseOptions {
|
|
|
269
340
|
logger?: Logger;
|
|
270
341
|
}
|
|
271
342
|
export declare class References {
|
|
343
|
+
private cache;
|
|
272
344
|
assignmentStatements: AssignmentStatement[];
|
|
273
345
|
classStatements: ClassStatement[];
|
|
346
|
+
dottedSetStatements: DottedSetStatement[];
|
|
347
|
+
aaLiterals: AALiteralExpression[];
|
|
274
348
|
get classStatementLookup(): Map<string, ClassStatement>;
|
|
275
349
|
private _classStatementLookup;
|
|
276
350
|
functionExpressions: FunctionExpression[];
|
|
@@ -280,6 +354,22 @@ export declare class References {
|
|
|
280
354
|
*/
|
|
281
355
|
get functionStatementLookup(): Map<string, FunctionStatement>;
|
|
282
356
|
private _functionStatementLookup;
|
|
357
|
+
interfaceStatements: InterfaceStatement[];
|
|
358
|
+
get interfaceStatementLookup(): Map<string, InterfaceStatement>;
|
|
359
|
+
private _interfaceStatementLookup;
|
|
360
|
+
enumStatements: EnumStatement[];
|
|
361
|
+
get enumStatementLookup(): any;
|
|
362
|
+
/**
|
|
363
|
+
* A collection of full expressions. This excludes intermediary expressions.
|
|
364
|
+
*
|
|
365
|
+
* Example 1:
|
|
366
|
+
* `a.b.c` is composed of `a` (variableExpression) `.b` (DottedGetExpression) `.c` (DottedGetExpression)
|
|
367
|
+
* This will only contain the final `.c` DottedGetExpression because `.b` and `a` can both be derived by walking back from the `.c` DottedGetExpression.
|
|
368
|
+
*
|
|
369
|
+
* Example 2:
|
|
370
|
+
* `name.space.doSomething(a.b.c)` will result in 2 entries in this list. the `CallExpression` for `doSomething`, and the `.c` DottedGetExpression.
|
|
371
|
+
*/
|
|
372
|
+
expressions: Set<Expression>;
|
|
283
373
|
importStatements: ImportStatement[];
|
|
284
374
|
libraryStatements: LibraryStatement[];
|
|
285
375
|
namespaceStatements: NamespaceStatement[];
|
|
@@ -291,31 +381,64 @@ export interface LocalVarEntry {
|
|
|
291
381
|
nameToken: Identifier;
|
|
292
382
|
type: BscType;
|
|
293
383
|
}
|
|
384
|
+
export declare enum TokenUsage {
|
|
385
|
+
Direct = 1,
|
|
386
|
+
Call = 2,
|
|
387
|
+
ArrayReference = 3
|
|
388
|
+
}
|
|
294
389
|
/**
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
* @param expression the Expression to process
|
|
298
|
-
* @param functionExpression the wrapping function expression
|
|
299
|
-
* @return the best guess type of that expression
|
|
390
|
+
* A member of a token chain - a wrapper around a token, which also gives some context for how it is used, and if the type is knowable
|
|
300
391
|
*/
|
|
301
|
-
export
|
|
392
|
+
export interface TokenChainMember {
|
|
393
|
+
/**
|
|
394
|
+
* The token
|
|
395
|
+
*/
|
|
396
|
+
token: Token;
|
|
397
|
+
/**
|
|
398
|
+
* Is it impossible to know the the type of this token (for now)
|
|
399
|
+
*/
|
|
400
|
+
tokenTypeIsNotKnowable?: boolean;
|
|
401
|
+
/**
|
|
402
|
+
* How was this token used?
|
|
403
|
+
*/
|
|
404
|
+
usage: TokenUsage;
|
|
405
|
+
/**
|
|
406
|
+
* Index of the token in the parser's token list
|
|
407
|
+
*/
|
|
408
|
+
index: number;
|
|
409
|
+
}
|
|
302
410
|
/**
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
* @param call the Expression to process
|
|
308
|
-
* @param functionExpression the wrapping function expression
|
|
309
|
-
* @return the best guess type of that expression
|
|
411
|
+
* A token paired with the index it is at in the file
|
|
412
|
+
* Used for when we need to get a token, but may also need the previous or next token
|
|
413
|
+
* This way, we can access the adjacent tokens via their index instead of search
|
|
310
414
|
*/
|
|
311
|
-
export
|
|
415
|
+
export interface TokenWithIndex {
|
|
416
|
+
/**
|
|
417
|
+
* The token
|
|
418
|
+
*/
|
|
419
|
+
token: Token;
|
|
420
|
+
/**
|
|
421
|
+
* Index of the token in the parser's token list
|
|
422
|
+
*/
|
|
423
|
+
index: number;
|
|
424
|
+
/**
|
|
425
|
+
* Is it impossible to know the the type of this token (for now)
|
|
426
|
+
*/
|
|
427
|
+
tokenTypeIsNotKnowable?: boolean;
|
|
428
|
+
/**
|
|
429
|
+
* does this token have brackets (either parens or square brackets) after it
|
|
430
|
+
*/
|
|
431
|
+
hasBrackets?: boolean;
|
|
432
|
+
}
|
|
433
|
+
export interface TokenChain {
|
|
434
|
+
chain: TokenChainMember[];
|
|
435
|
+
includesUnknowableTokenType?: boolean;
|
|
436
|
+
}
|
|
312
437
|
/**
|
|
313
|
-
* Gets the type of
|
|
314
|
-
* if it already exists in symbol table, use that type
|
|
315
|
-
* otherwise defer the type until first read, which will allow us to derive types from variables defined after this one (like from a loop perhaps)
|
|
438
|
+
* Gets the type of an expression. If it can not be processed, will return DynamicType
|
|
316
439
|
*
|
|
317
|
-
* @param
|
|
440
|
+
* @param expression the Expression to process
|
|
318
441
|
* @param functionExpression the wrapping function expression
|
|
319
442
|
* @return the best guess type of that expression
|
|
320
443
|
*/
|
|
321
|
-
export declare function
|
|
444
|
+
export declare function getBscTypeFromExpression(expression: Expression, functionExpression: FunctionExpression): BscType;
|