brighterscript 0.41.2 → 1.0.0-alpha.12
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 +112 -0
- package/README.md +2 -2
- package/dist/DiagnosticCollection.js +2 -2
- package/dist/DiagnosticCollection.js.map +1 -1
- package/dist/DiagnosticFilterer.js +2 -2
- package/dist/DiagnosticFilterer.js.map +1 -1
- package/dist/DiagnosticMessages.d.ts +6 -1
- package/dist/DiagnosticMessages.js +5 -0
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/LanguageServer.d.ts +8 -2
- package/dist/LanguageServer.js +50 -44
- package/dist/LanguageServer.js.map +1 -1
- package/dist/Program.d.ts +61 -45
- package/dist/Program.js +305 -188
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +7 -7
- package/dist/ProgramBuilder.js +60 -51
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +42 -19
- package/dist/Scope.js +261 -129
- package/dist/Scope.js.map +1 -1
- package/dist/SymbolTable.d.ts +73 -0
- package/dist/SymbolTable.js +157 -0
- package/dist/SymbolTable.js.map +1 -0
- package/dist/XmlScope.d.ts +5 -0
- package/dist/XmlScope.js +66 -28
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/creators.d.ts +15 -1
- package/dist/astUtils/creators.js +39 -9
- package/dist/astUtils/creators.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +28 -16
- package/dist/astUtils/reflection.js +52 -30
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +3 -3
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +12 -13
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/astUtils/xml.d.ts +3 -3
- package/dist/astUtils/xml.js +2 -2
- package/dist/astUtils/xml.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +5 -6
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +24 -22
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.js +2 -2
- package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.js.map +1 -1
- package/dist/examples/plugins/removePrint.js +1 -1
- package/dist/examples/plugins/removePrint.js.map +1 -1
- package/dist/files/BrsFile.Class.spec.js +356 -41
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +55 -37
- package/dist/files/BrsFile.js +430 -399
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +199 -158
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.d.ts +20 -9
- package/dist/files/XmlFile.js +36 -31
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/files/XmlFile.spec.js +113 -113
- package/dist/files/XmlFile.spec.js.map +1 -1
- package/dist/files/tests/imports.spec.js +32 -32
- package/dist/files/tests/imports.spec.js.map +1 -1
- package/dist/globalCallables.js +17 -6
- package/dist/globalCallables.js.map +1 -1
- package/dist/interfaces.d.ts +155 -39
- package/dist/parser/BrsTranspileState.d.ts +7 -0
- package/dist/parser/BrsTranspileState.js +10 -1
- package/dist/parser/BrsTranspileState.js.map +1 -1
- package/dist/parser/Expression.d.ts +23 -12
- package/dist/parser/Expression.js +45 -30
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +100 -1
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.d.ts +118 -5
- package/dist/parser/Parser.js +398 -37
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.js +404 -7
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/SGParser.d.ts +41 -4
- package/dist/parser/SGParser.js +185 -174
- package/dist/parser/SGParser.js.map +1 -1
- package/dist/parser/SGParser.spec.js +17 -4
- package/dist/parser/SGParser.spec.js.map +1 -1
- package/dist/parser/SGTypes.d.ts +203 -38
- package/dist/parser/SGTypes.js +464 -160
- 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 +37 -26
- package/dist/parser/Statement.js +81 -20
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/Statement.spec.js +5 -5
- 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/controlFlow/ForEach.spec.js +5 -4
- package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +1 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +1 -1
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js +1 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.js +1 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
- package/dist/types/ArrayType.d.ts +1 -0
- package/dist/types/ArrayType.js +23 -19
- package/dist/types/ArrayType.js.map +1 -1
- package/dist/types/BooleanType.d.ts +3 -2
- package/dist/types/BooleanType.js +6 -3
- package/dist/types/BooleanType.js.map +1 -1
- package/dist/types/BscType.d.ts +19 -4
- package/dist/types/BscType.js +9 -0
- package/dist/types/BscType.js.map +1 -1
- package/dist/types/CustomType.d.ts +8 -5
- package/dist/types/CustomType.js +12 -12
- package/dist/types/CustomType.js.map +1 -1
- package/dist/types/DoubleType.d.ts +1 -0
- package/dist/types/DoubleType.js +11 -11
- package/dist/types/DoubleType.js.map +1 -1
- package/dist/types/DynamicType.d.ts +1 -0
- package/dist/types/DynamicType.js +4 -0
- package/dist/types/DynamicType.js.map +1 -1
- package/dist/types/FloatType.d.ts +2 -1
- package/dist/types/FloatType.js +11 -11
- package/dist/types/FloatType.js.map +1 -1
- package/dist/types/FunctionType.d.ts +13 -10
- package/dist/types/FunctionType.js +34 -18
- package/dist/types/FunctionType.js.map +1 -1
- package/dist/types/FunctionType.spec.js +8 -2
- package/dist/types/FunctionType.spec.js.map +1 -1
- package/dist/types/IntegerType.d.ts +2 -1
- package/dist/types/IntegerType.js +11 -11
- package/dist/types/IntegerType.js.map +1 -1
- package/dist/types/InvalidType.d.ts +3 -2
- package/dist/types/InvalidType.js +7 -4
- package/dist/types/InvalidType.js.map +1 -1
- package/dist/types/LazyType.d.ts +17 -0
- package/dist/types/LazyType.js +44 -0
- package/dist/types/LazyType.js.map +1 -0
- package/dist/types/LongIntegerType.d.ts +2 -1
- package/dist/types/LongIntegerType.js +11 -11
- package/dist/types/LongIntegerType.js.map +1 -1
- package/dist/types/ObjectType.d.ts +6 -2
- package/dist/types/ObjectType.js +9 -3
- package/dist/types/ObjectType.js.map +1 -1
- package/dist/types/StringType.d.ts +3 -2
- package/dist/types/StringType.js +6 -3
- package/dist/types/StringType.js.map +1 -1
- package/dist/types/UninitializedType.d.ts +4 -2
- package/dist/types/UninitializedType.js +8 -3
- package/dist/types/UninitializedType.js.map +1 -1
- package/dist/types/VoidType.d.ts +3 -2
- package/dist/types/VoidType.js +6 -3
- package/dist/types/VoidType.js.map +1 -1
- package/dist/types/helpers.d.ts +42 -0
- package/dist/types/helpers.js +113 -0
- package/dist/types/helpers.js.map +1 -0
- package/dist/util.d.ts +68 -15
- package/dist/util.js +193 -45
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.d.ts +5 -1
- package/dist/validators/ClassValidator.js +31 -17
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +1 -1
- package/dist/FunctionScope.d.ts +0 -27
- package/dist/FunctionScope.js +0 -49
- package/dist/FunctionScope.js.map +0 -1
package/dist/types/VoidType.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VoidType = void 0;
|
|
4
|
-
const
|
|
4
|
+
const reflection_1 = require("../astUtils/reflection");
|
|
5
5
|
class VoidType {
|
|
6
6
|
isAssignableTo(targetType) {
|
|
7
|
-
return (targetType
|
|
8
|
-
|
|
7
|
+
return ((0, reflection_1.isVoidType)(targetType) ||
|
|
8
|
+
(0, reflection_1.isDynamicType)(targetType));
|
|
9
9
|
}
|
|
10
10
|
isConvertibleTo(targetType) {
|
|
11
11
|
return this.isAssignableTo(targetType);
|
|
@@ -16,6 +16,9 @@ class VoidType {
|
|
|
16
16
|
toTypeString() {
|
|
17
17
|
return this.toString();
|
|
18
18
|
}
|
|
19
|
+
equals(targetType) {
|
|
20
|
+
return (0, reflection_1.isVoidType)(targetType);
|
|
21
|
+
}
|
|
19
22
|
}
|
|
20
23
|
exports.VoidType = VoidType;
|
|
21
24
|
//# sourceMappingURL=VoidType.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoidType.js","sourceRoot":"","sources":["../../src/types/VoidType.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"VoidType.js","sourceRoot":"","sources":["../../src/types/VoidType.ts"],"names":[],"mappings":";;;AAAA,uDAAmE;AAGnE,MAAa,QAAQ;IACV,cAAc,CAAC,UAAmB;QACrC,OAAO,CACH,IAAA,uBAAU,EAAC,UAAU,CAAC;YACtB,IAAA,0BAAa,EAAC,UAAU,CAAC,CAC5B,CAAC;IACN,CAAC;IAEM,eAAe,CAAC,UAAmB;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAEM,QAAQ;QACX,OAAO,MAAM,CAAC;IAClB,CAAC;IAGM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,UAAmB;QAC7B,OAAO,IAAA,uBAAU,EAAC,UAAU,CAAC,CAAC;IAClC,CAAC;CACJ;AAxBD,4BAwBC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { CallExpression, DottedGetExpression, FunctionExpression, NewExpression, VariableExpression } from '../parser/Expression';
|
|
2
|
+
import type { BscType } from './BscType';
|
|
3
|
+
/**
|
|
4
|
+
* Gets the return type of a function, taking into account that the function may not have been declared yet
|
|
5
|
+
* If the callee already exists in symbol table, use that return type
|
|
6
|
+
* otherwise, make a lazy type which will not compute its type until the file is done parsing
|
|
7
|
+
*
|
|
8
|
+
* @param call the Expression to process
|
|
9
|
+
* @param functionExpression the wrapping function expression
|
|
10
|
+
* @return the best guess type of that expression
|
|
11
|
+
*/
|
|
12
|
+
export declare function getTypeFromCallExpression(call: CallExpression, functionExpression: FunctionExpression): BscType;
|
|
13
|
+
/**
|
|
14
|
+
* Gets the type of a variable
|
|
15
|
+
* if it already exists in symbol table, use that type
|
|
16
|
+
* 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)
|
|
17
|
+
*
|
|
18
|
+
* @param variable the Expression to process
|
|
19
|
+
* @param functionExpression the wrapping function expression
|
|
20
|
+
* @return the best guess type of that expression
|
|
21
|
+
*/
|
|
22
|
+
export declare function getTypeFromVariableExpression(variable: VariableExpression, functionExpression: FunctionExpression): BscType;
|
|
23
|
+
/**
|
|
24
|
+
* Gets the type of a variable
|
|
25
|
+
* if it already exists in symbol table, use that type
|
|
26
|
+
* 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)
|
|
27
|
+
*
|
|
28
|
+
* @param newExp the Expression to process
|
|
29
|
+
* @param functionExpression the wrapping function expression
|
|
30
|
+
* @return the best guess type of that expression
|
|
31
|
+
*/
|
|
32
|
+
export declare function getTypeFromNewExpression(newExp: NewExpression, functionExpression: FunctionExpression): BscType;
|
|
33
|
+
/**
|
|
34
|
+
* Gets the type of a variable
|
|
35
|
+
* if it already exists in symbol table, use that type
|
|
36
|
+
* 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)
|
|
37
|
+
*
|
|
38
|
+
* @param variable the Expression to process
|
|
39
|
+
* @param functionExpression the wrapping function expression
|
|
40
|
+
* @return the best guess type of that expression
|
|
41
|
+
*/
|
|
42
|
+
export declare function getTypeFromDottedGetExpression(expr: DottedGetExpression, functionExpression: FunctionExpression): BscType;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTypeFromDottedGetExpression = exports.getTypeFromNewExpression = exports.getTypeFromVariableExpression = exports.getTypeFromCallExpression = void 0;
|
|
4
|
+
const reflection_1 = require("../astUtils/reflection");
|
|
5
|
+
const LazyType_1 = require("./LazyType");
|
|
6
|
+
const UninitializedType_1 = require("./UninitializedType");
|
|
7
|
+
const Parser_1 = require("../parser/Parser");
|
|
8
|
+
const CustomType_1 = require("./CustomType");
|
|
9
|
+
/**
|
|
10
|
+
* Gets the return type of a function, taking into account that the function may not have been declared yet
|
|
11
|
+
* If the callee already exists in symbol table, use that return type
|
|
12
|
+
* otherwise, make a lazy type which will not compute its type until the file is done parsing
|
|
13
|
+
*
|
|
14
|
+
* @param call the Expression to process
|
|
15
|
+
* @param functionExpression the wrapping function expression
|
|
16
|
+
* @return the best guess type of that expression
|
|
17
|
+
*/
|
|
18
|
+
function getTypeFromCallExpression(call, functionExpression) {
|
|
19
|
+
let calleeName = call.callee.name;
|
|
20
|
+
if (calleeName) {
|
|
21
|
+
const currentKnownType = functionExpression.symbolTable.getSymbolType(calleeName.text.toLowerCase());
|
|
22
|
+
if ((0, reflection_1.isFunctionType)(currentKnownType)) {
|
|
23
|
+
return currentKnownType.returnType;
|
|
24
|
+
}
|
|
25
|
+
if (currentKnownType) {
|
|
26
|
+
// this will probably only happen if a functionName has been assigned to something else previously?
|
|
27
|
+
return currentKnownType;
|
|
28
|
+
}
|
|
29
|
+
return new LazyType_1.LazyType((context) => {
|
|
30
|
+
var _a;
|
|
31
|
+
let futureType;
|
|
32
|
+
if ((0, reflection_1.isBrsFile)(context === null || context === void 0 ? void 0 : context.file)) {
|
|
33
|
+
const file = context.file;
|
|
34
|
+
futureType = (_a = file.getSymbolTypeFromToken(calleeName, functionExpression, context.scope)) === null || _a === void 0 ? void 0 : _a.type;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
// Give best guess if there is no file context
|
|
38
|
+
futureType = functionExpression.symbolTable.getSymbolType(calleeName.text);
|
|
39
|
+
}
|
|
40
|
+
if ((0, reflection_1.isFunctionType)(futureType)) {
|
|
41
|
+
return futureType.returnType;
|
|
42
|
+
}
|
|
43
|
+
return futureType;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.getTypeFromCallExpression = getTypeFromCallExpression;
|
|
48
|
+
/**
|
|
49
|
+
* Gets the type of a variable
|
|
50
|
+
* if it already exists in symbol table, use that type
|
|
51
|
+
* 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)
|
|
52
|
+
*
|
|
53
|
+
* @param variable the Expression to process
|
|
54
|
+
* @param functionExpression the wrapping function expression
|
|
55
|
+
* @return the best guess type of that expression
|
|
56
|
+
*/
|
|
57
|
+
function getTypeFromVariableExpression(variable, functionExpression) {
|
|
58
|
+
let variableName = variable.name.text.toLowerCase();
|
|
59
|
+
const currentKnownType = functionExpression.symbolTable.getSymbolType(variableName);
|
|
60
|
+
if ((0, reflection_1.isPrimitiveType)(currentKnownType)) {
|
|
61
|
+
// for "contextless" types, eg. myVar = 3.14
|
|
62
|
+
return currentKnownType;
|
|
63
|
+
}
|
|
64
|
+
return resolveLazyType(variable.name, functionExpression);
|
|
65
|
+
}
|
|
66
|
+
exports.getTypeFromVariableExpression = getTypeFromVariableExpression;
|
|
67
|
+
/**
|
|
68
|
+
* Gets the type of a variable
|
|
69
|
+
* if it already exists in symbol table, use that type
|
|
70
|
+
* 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)
|
|
71
|
+
*
|
|
72
|
+
* @param newExp the Expression to process
|
|
73
|
+
* @param functionExpression the wrapping function expression
|
|
74
|
+
* @return the best guess type of that expression
|
|
75
|
+
*/
|
|
76
|
+
function getTypeFromNewExpression(newExp, functionExpression) {
|
|
77
|
+
let className = newExp.className.getName(Parser_1.ParseMode.BrighterScript);
|
|
78
|
+
return new LazyType_1.LazyType((context) => {
|
|
79
|
+
var _a, _b, _c;
|
|
80
|
+
return new CustomType_1.CustomType(className, (_c = (_a = context === null || context === void 0 ? void 0 : context.scope) === null || _a === void 0 ? void 0 : _a.getClass(className, (_b = functionExpression.namespaceName) === null || _b === void 0 ? void 0 : _b.getName())) === null || _c === void 0 ? void 0 : _c.memberTable);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
exports.getTypeFromNewExpression = getTypeFromNewExpression;
|
|
84
|
+
function resolveLazyType(currentToken, functionExpression) {
|
|
85
|
+
return new LazyType_1.LazyType((context) => {
|
|
86
|
+
var _a, _b;
|
|
87
|
+
let futureType;
|
|
88
|
+
if ((0, reflection_1.isBrsFile)(context === null || context === void 0 ? void 0 : context.file)) {
|
|
89
|
+
const file = context.file;
|
|
90
|
+
futureType = (_a = file.getSymbolTypeFromToken(currentToken, functionExpression, context.scope)) === null || _a === void 0 ? void 0 : _a.type;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
// Give best guess if there is no file context
|
|
94
|
+
futureType = (_b = functionExpression.symbolTable.getSymbolType(currentToken.text)) !== null && _b !== void 0 ? _b : new UninitializedType_1.UninitializedType();
|
|
95
|
+
}
|
|
96
|
+
return futureType;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Gets the type of a variable
|
|
101
|
+
* if it already exists in symbol table, use that type
|
|
102
|
+
* 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)
|
|
103
|
+
*
|
|
104
|
+
* @param variable the Expression to process
|
|
105
|
+
* @param functionExpression the wrapping function expression
|
|
106
|
+
* @return the best guess type of that expression
|
|
107
|
+
*/
|
|
108
|
+
function getTypeFromDottedGetExpression(expr, functionExpression) {
|
|
109
|
+
const currentToken = (0, reflection_1.isCallExpression)(expr) ? (expr.callee).name : expr.name;
|
|
110
|
+
return resolveLazyType(currentToken, functionExpression);
|
|
111
|
+
}
|
|
112
|
+
exports.getTypeFromDottedGetExpression = getTypeFromDottedGetExpression;
|
|
113
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/types/helpers.ts"],"names":[],"mappings":";;;AAAA,uDAAsG;AAGtG,yCAAsC;AAEtC,2DAAwD;AACxD,6CAA6C;AAC7C,6CAA0C;AAE1C;;;;;;;;GAQG;AACH,SAAgB,yBAAyB,CAAC,IAAoB,EAAE,kBAAsC;IAClG,IAAI,UAAU,GAAK,IAAI,CAAC,MAAc,CAAC,IAAc,CAAC;IACtD,IAAI,UAAU,EAAE;QACZ,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,WAAW,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACrG,IAAI,IAAA,2BAAc,EAAC,gBAAgB,CAAC,EAAE;YAClC,OAAO,gBAAgB,CAAC,UAAU,CAAC;SACtC;QACD,IAAI,gBAAgB,EAAE;YAClB,mGAAmG;YACnG,OAAO,gBAAgB,CAAC;SAC3B;QACD,OAAO,IAAI,mBAAQ,CAAC,CAAC,OAAqB,EAAE,EAAE;;YAC1C,IAAI,UAAmB,CAAC;YACxB,IAAI,IAAA,sBAAS,EAAC,OAAO,aAAP,O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
|
import type { BsConfig } from './BsConfig';
|
|
4
|
-
import type { CallableContainer, BsDiagnostic, FileReference, CallableContainerMap, CompilerPlugin, ExpressionInfo } from './interfaces';
|
|
4
|
+
import type { CallableContainer, BsDiagnostic, FileReference, CallableContainerMap, CompilerPlugin, ExpressionInfo, FunctionCall, CallableParam, TranspileResult } from './interfaces';
|
|
5
5
|
import { BooleanType } from './types/BooleanType';
|
|
6
6
|
import { DoubleType } from './types/DoubleType';
|
|
7
7
|
import { DynamicType } from './types/DynamicType';
|
|
@@ -13,11 +13,11 @@ import { LongIntegerType } from './types/LongIntegerType';
|
|
|
13
13
|
import { ObjectType } from './types/ObjectType';
|
|
14
14
|
import { StringType } from './types/StringType';
|
|
15
15
|
import { VoidType } from './types/VoidType';
|
|
16
|
-
import type { DottedGetExpression, Expression, VariableExpression } from './parser/Expression';
|
|
16
|
+
import type { DottedGetExpression, Expression, NamespacedVariableNameExpression, VariableExpression } from './parser/Expression';
|
|
17
17
|
import type { Locatable, Token } from './lexer';
|
|
18
|
-
import { CustomType } from './types/CustomType';
|
|
19
18
|
import { SourceNode } from 'source-map';
|
|
20
|
-
import
|
|
19
|
+
import { SGAttribute } from './parser/SGTypes';
|
|
20
|
+
import { LazyType } from './types/LazyType';
|
|
21
21
|
export declare class Util {
|
|
22
22
|
clearConsole(): void;
|
|
23
23
|
/**
|
|
@@ -37,7 +37,11 @@ export declare class Util {
|
|
|
37
37
|
/**
|
|
38
38
|
* Given a pkg path of any kind, transform it to a roku-specific pkg path (i.e. "pkg:/some/path.brs")
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
sanitizePkgPath(pkgPath: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Determine if the given path starts with a protocol
|
|
43
|
+
*/
|
|
44
|
+
startsWithProtocol(path: string): boolean;
|
|
41
45
|
/**
|
|
42
46
|
* Given a path to a file/directory, replace all path separators with the current system's version.
|
|
43
47
|
* @param filePath
|
|
@@ -105,12 +109,11 @@ export declare class Util {
|
|
|
105
109
|
*/
|
|
106
110
|
getLines(text: string): string[];
|
|
107
111
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* @param
|
|
111
|
-
* @param targetPath
|
|
112
|
+
* Compute the pkg path for the target relative to the source file's location
|
|
113
|
+
* @param sourcePkgPath The pkgPath of the file that contains the target path
|
|
114
|
+
* @param targetPath a full pkgPath, or a path relative to the containing file
|
|
112
115
|
*/
|
|
113
|
-
getPkgPathFromTarget(
|
|
116
|
+
getPkgPathFromTarget(sourcePkgPath: string, targetPath: string): string;
|
|
114
117
|
/**
|
|
115
118
|
* Compute the relative path from the source file to the target file
|
|
116
119
|
* @param pkgSourcePathAbsolute - the absolute path to the source relative to the package location
|
|
@@ -157,8 +160,9 @@ export declare class Util {
|
|
|
157
160
|
areArraysEqual(arr1: any[], arr2: any[]): boolean;
|
|
158
161
|
/**
|
|
159
162
|
* Given a file path, convert it to a URI string
|
|
163
|
+
* @param srcPath The absolute path to the source file on disk
|
|
160
164
|
*/
|
|
161
|
-
pathToUri(
|
|
165
|
+
pathToUri(srcPath: string): string;
|
|
162
166
|
/**
|
|
163
167
|
* Get the outDir from options, taking into account cwd and absolute outFile paths
|
|
164
168
|
* @param options
|
|
@@ -170,7 +174,8 @@ export declare class Util {
|
|
|
170
174
|
getFilePaths(options: BsConfig): Promise<rokuDeploy.StandardizedFileEntry[]>;
|
|
171
175
|
/**
|
|
172
176
|
* Given a path to a brs file, compute the path to a theoretical d.bs file.
|
|
173
|
-
* Only `.brs` files can have typedef
|
|
177
|
+
* Only `.brs` files can have a typedef, so return undefined for everything else
|
|
178
|
+
* @param brsSrcPath The absolute path to the .brs source file on disk
|
|
174
179
|
*/
|
|
175
180
|
getTypedefPath(brsSrcPath: string): string;
|
|
176
181
|
/**
|
|
@@ -253,6 +258,13 @@ export declare class Util {
|
|
|
253
258
|
* Create a `Range` from two `Position`s
|
|
254
259
|
*/
|
|
255
260
|
createRangeFromPositions(startPosition: Position, endPosition: Position): Range;
|
|
261
|
+
/**
|
|
262
|
+
* Given a list of ranges, create a range that starts with the first non-null lefthand range, and ends with the first non-null
|
|
263
|
+
* righthand range. Returns undefined if none of the items have a range.
|
|
264
|
+
*/
|
|
265
|
+
createBoundingRange(...locatables: Array<{
|
|
266
|
+
range?: Range;
|
|
267
|
+
}>): Range;
|
|
256
268
|
/**
|
|
257
269
|
* Create a `Position` object. Prefer this over `Position.create` for performance reasons
|
|
258
270
|
*/
|
|
@@ -267,7 +279,7 @@ export declare class Util {
|
|
|
267
279
|
/**
|
|
268
280
|
* Convert a token into a BscType
|
|
269
281
|
*/
|
|
270
|
-
tokenToBscType(token: Token, allowCustomType?: boolean): DynamicType |
|
|
282
|
+
tokenToBscType(token: Token, allowCustomType?: boolean, currentNamespaceName?: NamespacedVariableNameExpression): DynamicType | FloatType | FunctionType | IntegerType | LongIntegerType | StringType | BooleanType | LazyType | ObjectType | DoubleType | InvalidType | VoidType;
|
|
271
283
|
/**
|
|
272
284
|
* Get the extension for the given file path. Basically the part after the final dot, except for
|
|
273
285
|
* `d.bs` which is treated as single extension
|
|
@@ -289,12 +301,20 @@ export declare class Util {
|
|
|
289
301
|
*/
|
|
290
302
|
simpleMap(source: string, src: string): SourceNode;
|
|
291
303
|
/**
|
|
292
|
-
* Creates a new SGAttribute object, but keeps the existing Range references (since those
|
|
304
|
+
* Creates a new SGAttribute object, but keeps the existing Range references (since those should be immutable)
|
|
293
305
|
*/
|
|
294
306
|
cloneSGAttribute(attr: SGAttribute, value: string): SGAttribute;
|
|
295
307
|
/**
|
|
296
|
-
*
|
|
308
|
+
* Shorthand for creating a new source node
|
|
297
309
|
*/
|
|
310
|
+
sourceNode(source: string, locatable: {
|
|
311
|
+
range: Range;
|
|
312
|
+
}, code: string | SourceNode | TranspileResult): SourceNode | undefined;
|
|
313
|
+
/**
|
|
314
|
+
* Remove leading simple protocols from a path (if present)
|
|
315
|
+
*/
|
|
316
|
+
removeProtocol(pkgPath: string): string;
|
|
317
|
+
standardizePath(thePath: string): string;
|
|
298
318
|
copyBslibToStaging(stagingDir: string): Promise<void>;
|
|
299
319
|
/**
|
|
300
320
|
* Given a Diagnostic or BsDiagnostic, return a copy of the diagnostic
|
|
@@ -310,6 +330,27 @@ export declare class Util {
|
|
|
310
330
|
code: string | number;
|
|
311
331
|
source: string;
|
|
312
332
|
};
|
|
333
|
+
/**
|
|
334
|
+
* Gets the minimum and maximum number of allowed params
|
|
335
|
+
* @param params The list of callable parameters to check
|
|
336
|
+
* @returns the minimum and maximum number of allowed params
|
|
337
|
+
*/
|
|
338
|
+
getMinMaxParamCount(params: CallableParam[]): MinMax;
|
|
339
|
+
/**
|
|
340
|
+
* Gets the minimum and maximum number of allowed params for ALL functions with the name of the function call
|
|
341
|
+
* @param callablesByLowerName The map of callable containers
|
|
342
|
+
* @param expCall function call expression to use for the name
|
|
343
|
+
* @returns the minimum and maximum number of allowed params
|
|
344
|
+
*/
|
|
345
|
+
getMinMaxParamCountByFunctionCall(callablesByLowerName: CallableContainerMap, expCall: FunctionCall): MinMax;
|
|
346
|
+
/**
|
|
347
|
+
* Finds the array of callables from a container map, based on the name of the function call
|
|
348
|
+
* If the callable was called in a function in a namespace, functions in that namespace are preferred
|
|
349
|
+
* @param callablesByLowerName The map of callable containers
|
|
350
|
+
* @param expCall function call expression to use for the name
|
|
351
|
+
* @return an array with callable containers - could be empty if nothing was found
|
|
352
|
+
*/
|
|
353
|
+
getCallableContainersByName(callablesByLowerName: CallableContainerMap, expCall: FunctionCall): CallableContainer[];
|
|
313
354
|
/**
|
|
314
355
|
* Sort an array of objects that have a Range
|
|
315
356
|
*/
|
|
@@ -322,6 +363,13 @@ export declare class Util {
|
|
|
322
363
|
text: string;
|
|
323
364
|
range: Range;
|
|
324
365
|
}[];
|
|
366
|
+
/**
|
|
367
|
+
* Finds a callable from a container map based on the name AND number of arguments
|
|
368
|
+
* If the callable was called in a function in a namespace, functions in that namespace are preferred
|
|
369
|
+
* The first callable that matches the name AND will accept the number of arguments given is returned
|
|
370
|
+
* @return a callable containers that matches the call
|
|
371
|
+
*/
|
|
372
|
+
getCallableContainerByFunctionCall(callablesByLowerName: CallableContainerMap, expCall: FunctionCall): CallableContainer;
|
|
325
373
|
}
|
|
326
374
|
/**
|
|
327
375
|
* A tagged template literal function for standardizing the path. This has to be defined as standalone function since it's a tagged template literal function,
|
|
@@ -330,3 +378,8 @@ export declare class Util {
|
|
|
330
378
|
export declare function standardizePath(stringParts: any, ...expressions: any[]): string;
|
|
331
379
|
export declare let util: Util;
|
|
332
380
|
export default util;
|
|
381
|
+
export interface MinMax {
|
|
382
|
+
min: number;
|
|
383
|
+
max: number;
|
|
384
|
+
}
|
|
385
|
+
export declare const MAX_PARAM_COUNT = 32;
|