brighterscript 1.0.0-alpha.44 → 1.0.0-alpha.45
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 +63 -0
- package/bsconfig.schema.json +6 -1
- package/dist/AstValidationSegmenter.js +6 -1
- package/dist/AstValidationSegmenter.js.map +1 -1
- package/dist/BsConfig.d.ts +4 -0
- package/dist/BusyStatusTracker.d.ts +37 -7
- package/dist/BusyStatusTracker.js +73 -8
- package/dist/BusyStatusTracker.js.map +1 -1
- package/dist/Cache.d.ts +0 -4
- package/dist/Cache.js +0 -6
- package/dist/Cache.js.map +1 -1
- package/dist/CrossScopeValidator.d.ts +1 -1
- package/dist/CrossScopeValidator.js +4 -4
- package/dist/CrossScopeValidator.js.map +1 -1
- package/dist/DiagnosticCollection.d.ts +19 -5
- package/dist/DiagnosticCollection.js +71 -23
- package/dist/DiagnosticCollection.js.map +1 -1
- package/dist/DiagnosticFilterer.d.ts +14 -1
- package/dist/DiagnosticFilterer.js +130 -12
- package/dist/DiagnosticFilterer.js.map +1 -1
- package/dist/DiagnosticManager.d.ts +11 -1
- package/dist/DiagnosticManager.js +192 -35
- package/dist/DiagnosticManager.js.map +1 -1
- package/dist/LanguageServer.d.ts +82 -139
- package/dist/LanguageServer.js +402 -980
- package/dist/LanguageServer.js.map +1 -1
- package/dist/Logger.d.ts +9 -4
- package/dist/Logger.js +30 -6
- package/dist/Logger.js.map +1 -1
- package/dist/PluginInterface.d.ts +8 -8
- package/dist/PluginInterface.js.map +1 -1
- package/dist/Program.d.ts +23 -4
- package/dist/Program.js +294 -194
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +22 -7
- package/dist/ProgramBuilder.js +44 -21
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +11 -6
- package/dist/Scope.js +60 -36
- package/dist/Scope.js.map +1 -1
- package/dist/SemanticTokenUtils.js +1 -1
- package/dist/SemanticTokenUtils.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +4 -4
- package/dist/astUtils/reflection.js +12 -10
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +3 -3
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/CallExpressionInfo.js +4 -2
- package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.js +15 -15
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +82 -5
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.js +3 -0
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +4 -1
- package/dist/bscPlugin/validation/ScopeValidator.js +161 -61
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/common/Sequencer.d.ts +53 -0
- package/dist/common/Sequencer.js +232 -0
- package/dist/common/Sequencer.js.map +1 -0
- package/dist/common/Sequencer.spec.d.ts +1 -0
- package/dist/common/Sequencer.spec.js +75 -0
- package/dist/common/Sequencer.spec.js.map +1 -0
- package/dist/deferred.d.ts +2 -0
- package/dist/deferred.js +10 -0
- package/dist/deferred.js.map +1 -1
- package/dist/examples/plugins/removePrint.d.ts +2 -2
- package/dist/examples/plugins/removePrint.js.map +1 -1
- package/dist/files/BrsFile.d.ts +1 -1
- package/dist/files/BrsFile.js +11 -40
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +51 -2
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/BscFile.d.ts +1 -0
- package/dist/files/LazyFileData.d.ts +1 -0
- package/dist/files/XmlFile.spec.js +1 -1
- package/dist/files/XmlFile.spec.js.map +1 -1
- package/dist/globalCallables.js +186 -186
- package/dist/globalCallables.js.map +1 -1
- package/dist/interfaces.d.ts +56 -13
- package/dist/interfaces.js.map +1 -1
- package/dist/lexer/Lexer.js +1 -1
- package/dist/lexer/Lexer.js.map +1 -1
- package/dist/logging.d.ts +6 -1
- package/dist/logging.js +14 -1
- package/dist/logging.js.map +1 -1
- package/dist/lsp/ActionQueue.d.ts +35 -0
- package/dist/lsp/ActionQueue.js +115 -0
- package/dist/lsp/ActionQueue.js.map +1 -0
- package/dist/lsp/ActionQueue.spec.d.ts +1 -0
- package/dist/lsp/ActionQueue.spec.js +80 -0
- package/dist/lsp/ActionQueue.spec.js.map +1 -0
- package/dist/lsp/DocumentManager.d.ts +63 -0
- package/dist/lsp/DocumentManager.js +122 -0
- package/dist/lsp/DocumentManager.js.map +1 -0
- package/dist/lsp/DocumentManager.spec.d.ts +1 -0
- package/dist/lsp/DocumentManager.spec.js +103 -0
- package/dist/lsp/DocumentManager.spec.js.map +1 -0
- package/dist/lsp/LspProject.d.ts +231 -0
- package/dist/lsp/LspProject.js +3 -0
- package/dist/lsp/LspProject.js.map +1 -0
- package/dist/lsp/PathFilterer.d.ts +75 -0
- package/dist/lsp/PathFilterer.js +196 -0
- package/dist/lsp/PathFilterer.js.map +1 -0
- package/dist/lsp/PathFilterer.spec.d.ts +1 -0
- package/dist/lsp/PathFilterer.spec.js +182 -0
- package/dist/lsp/PathFilterer.spec.js.map +1 -0
- package/dist/lsp/Project.d.ts +167 -0
- package/dist/lsp/Project.js +432 -0
- package/dist/lsp/Project.js.map +1 -0
- package/dist/lsp/Project.spec.d.ts +1 -0
- package/dist/lsp/Project.spec.js +220 -0
- package/dist/lsp/Project.spec.js.map +1 -0
- package/dist/lsp/ProjectManager.d.ts +221 -0
- package/dist/lsp/ProjectManager.js +735 -0
- package/dist/lsp/ProjectManager.js.map +1 -0
- package/dist/lsp/ProjectManager.spec.d.ts +1 -0
- package/dist/lsp/ProjectManager.spec.js +757 -0
- package/dist/lsp/ProjectManager.spec.js.map +1 -0
- package/dist/lsp/ReaderWriterManager.d.ts +21 -0
- package/dist/lsp/ReaderWriterManager.js +60 -0
- package/dist/lsp/ReaderWriterManager.js.map +1 -0
- package/dist/lsp/worker/MessageHandler.d.ts +99 -0
- package/dist/lsp/worker/MessageHandler.js +138 -0
- package/dist/lsp/worker/MessageHandler.js.map +1 -0
- package/dist/lsp/worker/MessageHandler.spec.d.ts +1 -0
- package/dist/lsp/worker/MessageHandler.spec.js +64 -0
- package/dist/lsp/worker/MessageHandler.spec.js.map +1 -0
- package/dist/lsp/worker/WorkerPool.d.ts +38 -0
- package/dist/lsp/worker/WorkerPool.js +78 -0
- package/dist/lsp/worker/WorkerPool.js.map +1 -0
- package/dist/lsp/worker/WorkerPool.spec.d.ts +1 -0
- package/dist/lsp/worker/WorkerPool.spec.js +59 -0
- package/dist/lsp/worker/WorkerPool.spec.js.map +1 -0
- package/dist/lsp/worker/WorkerThreadProject.d.ts +144 -0
- package/dist/lsp/worker/WorkerThreadProject.js +183 -0
- package/dist/lsp/worker/WorkerThreadProject.js.map +1 -0
- package/dist/lsp/worker/WorkerThreadProject.spec.d.ts +2 -0
- package/dist/lsp/worker/WorkerThreadProject.spec.js +68 -0
- package/dist/lsp/worker/WorkerThreadProject.spec.js.map +1 -0
- package/dist/lsp/worker/WorkerThreadProjectRunner.d.ts +15 -0
- package/dist/lsp/worker/WorkerThreadProjectRunner.js +58 -0
- package/dist/lsp/worker/WorkerThreadProjectRunner.js.map +1 -0
- package/dist/parser/Expression.js +7 -2
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.spec.js +12 -0
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/Statement.js +2 -2
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js +51 -5
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
- package/dist/roku-types/data.json +745 -751
- package/dist/types/BooleanType.d.ts +0 -2
- package/dist/types/BooleanType.js +4 -6
- package/dist/types/BooleanType.js.map +1 -1
- package/dist/types/BscType.js +5 -0
- package/dist/types/BscType.js.map +1 -1
- package/dist/types/BuiltInInterfaceAdder.d.ts +1 -0
- package/dist/types/BuiltInInterfaceAdder.js +24 -17
- package/dist/types/BuiltInInterfaceAdder.js.map +1 -1
- package/dist/types/DoubleType.d.ts +0 -2
- package/dist/types/DoubleType.js +4 -6
- package/dist/types/DoubleType.js.map +1 -1
- package/dist/types/DynamicType.d.ts +0 -2
- package/dist/types/DynamicType.js +3 -5
- package/dist/types/DynamicType.js.map +1 -1
- package/dist/types/FloatType.d.ts +0 -2
- package/dist/types/FloatType.js +4 -6
- package/dist/types/FloatType.js.map +1 -1
- package/dist/types/FunctionType.d.ts +0 -2
- package/dist/types/FunctionType.js +5 -7
- package/dist/types/FunctionType.js.map +1 -1
- package/dist/types/IntegerType.d.ts +0 -2
- package/dist/types/IntegerType.js +4 -6
- package/dist/types/IntegerType.js.map +1 -1
- package/dist/types/LongIntegerType.d.ts +0 -2
- package/dist/types/LongIntegerType.js +4 -6
- package/dist/types/LongIntegerType.js.map +1 -1
- package/dist/types/ObjectType.d.ts +3 -3
- package/dist/types/ObjectType.js +6 -8
- package/dist/types/ObjectType.js.map +1 -1
- package/dist/types/StringType.d.ts +0 -2
- package/dist/types/StringType.js +4 -6
- package/dist/types/StringType.js.map +1 -1
- package/dist/types/VoidType.d.ts +0 -2
- package/dist/types/VoidType.js +4 -6
- package/dist/types/VoidType.js.map +1 -1
- package/dist/types/helpers.d.ts +4 -0
- package/dist/types/helpers.js +5 -1
- package/dist/types/helpers.js.map +1 -1
- package/dist/util.d.ts +44 -16
- package/dist/util.js +196 -70
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.js +2 -2
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +15 -5
package/dist/types/VoidType.js
CHANGED
|
@@ -8,9 +8,8 @@ const helpers_1 = require("./helpers");
|
|
|
8
8
|
const BuiltInInterfaceAdder_1 = require("./BuiltInInterfaceAdder");
|
|
9
9
|
const DynamicType_1 = require("./DynamicType");
|
|
10
10
|
class VoidType extends BscType_1.BscType {
|
|
11
|
-
constructor(
|
|
12
|
-
super();
|
|
13
|
-
this.typeText = typeText;
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
14
13
|
this.kind = BscTypeKind_1.BscTypeKind.VoidType;
|
|
15
14
|
this.isBuiltIn = true;
|
|
16
15
|
}
|
|
@@ -21,8 +20,7 @@ class VoidType extends BscType_1.BscType {
|
|
|
21
20
|
(0, helpers_1.isUnionTypeCompatible)(this, targetType, data));
|
|
22
21
|
}
|
|
23
22
|
toString() {
|
|
24
|
-
|
|
25
|
-
return (_a = this.typeText) !== null && _a !== void 0 ? _a : 'void';
|
|
23
|
+
return 'void';
|
|
26
24
|
}
|
|
27
25
|
toTypeString() {
|
|
28
26
|
return this.toString();
|
|
@@ -35,6 +33,6 @@ class VoidType extends BscType_1.BscType {
|
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
exports.VoidType = VoidType;
|
|
38
|
-
VoidType.instance = new VoidType(
|
|
36
|
+
VoidType.instance = new VoidType();
|
|
39
37
|
BuiltInInterfaceAdder_1.BuiltInInterfaceAdder.primitiveTypeInstanceCache.set('void', VoidType.instance);
|
|
40
38
|
//# sourceMappingURL=VoidType.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoidType.js","sourceRoot":"","sources":["../../src/types/VoidType.ts"],"names":[],"mappings":";;;AAAA,uDAAiF;AACjF,uCAAoC;AACpC,+CAA4C;AAC5C,uCAAkD;AAClD,mEAAgE;AAEhE,+CAA4C;AAE5C,MAAa,QAAS,SAAQ,iBAAO;
|
|
1
|
+
{"version":3,"file":"VoidType.js","sourceRoot":"","sources":["../../src/types/VoidType.ts"],"names":[],"mappings":";;;AAAA,uDAAiF;AACjF,uCAAoC;AACpC,+CAA4C;AAC5C,uCAAkD;AAClD,mEAAgE;AAEhE,+CAA4C;AAE5C,MAAa,QAAS,SAAQ,iBAAO;IAArC;;QAEoB,SAAI,GAAG,yBAAW,CAAC,QAAQ,CAAC;QAIrC,cAAS,GAAG,IAAI,CAAC;IA0B5B,CAAC;IAxBU,gBAAgB,CAAC,UAAmB,EAAE,IAA4B;QACrE,OAAO,CACH,IAAA,uBAAU,EAAC,UAAU,CAAC;YACtB,IAAA,0BAAa,EAAC,UAAU,CAAC;YACzB,IAAA,yBAAY,EAAC,UAAU,CAAC;YACxB,IAAA,+BAAqB,EAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,CAChD,CAAC;IACN,CAAC;IAEM,QAAQ;QACX,OAAO,MAAM,CAAC;IAClB,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAEM,OAAO,CAAC,UAAmB;QAC9B,OAAO,IAAA,uBAAU,EAAC,UAAU,CAAC,CAAC;IAClC,CAAC;IAED,aAAa,CAAC,UAAkB,EAAE,OAAuB;QACrD,OAAO,yBAAW,CAAC,QAAQ,CAAC;IAChC,CAAC;;AA/BL,4BAgCC;AA5BiB,iBAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;AA8B5C,6CAAqB,CAAC,0BAA0B,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC"}
|
package/dist/types/helpers.d.ts
CHANGED
|
@@ -24,3 +24,7 @@ export declare function isEnumTypeCompatible(thisType: BscType, maybeEnumType: B
|
|
|
24
24
|
export declare function isNativeInterfaceCompatible(thisType: BscType, otherType: BscType, allowedType: string, data?: TypeCompatibilityData): boolean;
|
|
25
25
|
export declare function isNativeInterfaceCompatibleNumber(thisType: BscType, otherType: BscType, data?: TypeCompatibilityData): boolean;
|
|
26
26
|
export declare function getAllTypesFromUnionType(union: UnionType): BscType[];
|
|
27
|
+
/**
|
|
28
|
+
* A map of all types created in the program during its lifetime. This applies across all programs, validate runs, etc. Mostly useful for a single run to track types created.
|
|
29
|
+
*/
|
|
30
|
+
export declare const TypesCreated: Record<string, number>;
|
package/dist/types/helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAllTypesFromUnionType = exports.isNativeInterfaceCompatibleNumber = exports.isNativeInterfaceCompatible = exports.isEnumTypeCompatible = exports.isUnionTypeCompatible = exports.getUniqueType = exports.reduceTypesToMostGeneric = exports.getUniqueTypesFromArray = exports.findTypeUnion = exports.findTypeIntersection = void 0;
|
|
3
|
+
exports.TypesCreated = exports.getAllTypesFromUnionType = exports.isNativeInterfaceCompatibleNumber = exports.isNativeInterfaceCompatible = exports.isEnumTypeCompatible = exports.isUnionTypeCompatible = exports.getUniqueType = exports.reduceTypesToMostGeneric = exports.getUniqueTypesFromArray = exports.findTypeUnion = exports.findTypeIntersection = void 0;
|
|
4
4
|
const reflection_1 = require("../astUtils/reflection");
|
|
5
5
|
function findTypeIntersection(typesArr1, typesArr2) {
|
|
6
6
|
if (!typesArr1 || !typesArr2) {
|
|
@@ -195,4 +195,8 @@ function getAllTypesFromUnionType(union) {
|
|
|
195
195
|
return results;
|
|
196
196
|
}
|
|
197
197
|
exports.getAllTypesFromUnionType = getAllTypesFromUnionType;
|
|
198
|
+
/**
|
|
199
|
+
* A map of all types created in the program during its lifetime. This applies across all programs, validate runs, etc. Mostly useful for a single run to track types created.
|
|
200
|
+
*/
|
|
201
|
+
exports.TypesCreated = {};
|
|
198
202
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/types/helpers.ts"],"names":[],"mappings":";;;AACA,uDAAuL;AAIvL,SAAgB,oBAAoB,CAAC,SAAoB,EAAE,SAAoB;IAC3E,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,EAAE;QAC1B,OAAO,SAAS,CAAC;KACpB;IACD,OAAO,SAAS,aA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AAE,CAAC;QACpD,OAAO,cAAc,KAAK,OAAO;YAC7B,cAAc,KAAK,SAAS;YAC5B,cAAc,KAAK,UAAU;YAC7B,cAAc,KAAK,eAAe,CAAC;KAC1C;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAVD,8EAUC;AAED,SAAgB,wBAAwB,CAAC,KAAgB;IACrD,MAAM,OAAO,GAAG,EAAE,CAAC;IAEnB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE;QAC5B,IAAI,IAAA,wBAAW,EAAC,IAAI,CAAC,EAAE;YACnB,OAAO,CAAC,IAAI,CAAC,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC;SACnD;aAAM;YACH,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACtB;KACJ;IACD,OAAO,OAAO,CAAC;AACnB,CAAC;AAXD,4DAWC;AACD;;GAEG;AACU,QAAA,YAAY,GAA2B,EAAE,CAAC"}
|
package/dist/util.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
1
3
|
import type { Diagnostic, Position } from 'vscode-languageserver';
|
|
2
|
-
import { Location } from 'vscode-languageserver';
|
|
3
|
-
import { Range } from 'vscode-languageserver';
|
|
4
|
+
import { Range, Location } from 'vscode-languageserver';
|
|
4
5
|
import type { BsConfig, FinalizedBsConfig } from './BsConfig';
|
|
5
|
-
import type { CallableContainer, BsDiagnostic, FileReference, CallableContainerMap,
|
|
6
|
+
import type { CallableContainer, BsDiagnostic, FileReference, CallableContainerMap, Plugin, ExpressionInfo, TranspileResult, MaybePromise, DisposableLike, GetTypeOptions, TypeChainProcessResult } from './interfaces';
|
|
6
7
|
import { TypeChainEntry } from './interfaces';
|
|
7
8
|
import { BooleanType } from './types/BooleanType';
|
|
8
9
|
import { DoubleType } from './types/DoubleType';
|
|
@@ -30,6 +31,10 @@ import type { BscFile } from './files/BscFile';
|
|
|
30
31
|
import { InvalidType } from './types/InvalidType';
|
|
31
32
|
export declare class Util {
|
|
32
33
|
clearConsole(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Get the version of brighterscript
|
|
36
|
+
*/
|
|
37
|
+
getBrighterScriptVersion(): any;
|
|
33
38
|
/**
|
|
34
39
|
* Returns the number of parent directories in the filPath
|
|
35
40
|
*/
|
|
@@ -46,6 +51,12 @@ export declare class Util {
|
|
|
46
51
|
* Determine if this path is a directory
|
|
47
52
|
*/
|
|
48
53
|
isDirectorySync(dirPath: string | undefined): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Read a file from disk. If a failure occurrs, simply return undefined
|
|
56
|
+
* @param filePath path to the file
|
|
57
|
+
* @returns the string contents, or undefined if the file doesn't exist
|
|
58
|
+
*/
|
|
59
|
+
readFileSync(filePath: string): Buffer | undefined;
|
|
49
60
|
/**
|
|
50
61
|
* Given a pkg path of any kind, transform it to a roku-specific pkg path (i.e. "pkg:/some/path.brs")
|
|
51
62
|
*/
|
|
@@ -183,18 +194,6 @@ export declare class Util {
|
|
|
183
194
|
parseXml(text: string): Promise<any>;
|
|
184
195
|
propertyCount(object: Record<string, unknown>): number;
|
|
185
196
|
padLeft(subject: string, totalLength: number, char: string): string;
|
|
186
|
-
/**
|
|
187
|
-
* Does the string appear to be a uri (i.e. does it start with `file:`)
|
|
188
|
-
*/
|
|
189
|
-
isUriLike(filePath: string): boolean;
|
|
190
|
-
/**
|
|
191
|
-
* Given a file path, convert it to a URI string
|
|
192
|
-
*/
|
|
193
|
-
pathToUri(filePath: string): string;
|
|
194
|
-
/**
|
|
195
|
-
* Given a URI, convert that to a regular fs path
|
|
196
|
-
*/
|
|
197
|
-
uriToPath(uri: string): string;
|
|
198
197
|
/**
|
|
199
198
|
* Force the drive letter to lower case
|
|
200
199
|
*/
|
|
@@ -208,6 +207,18 @@ export declare class Util {
|
|
|
208
207
|
* This considers order and compares by equality.
|
|
209
208
|
*/
|
|
210
209
|
areArraysEqual(arr1: any[], arr2: any[]): boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Does the string appear to be a uri (i.e. does it start with `file:`)
|
|
212
|
+
*/
|
|
213
|
+
isUriLike(filePath: string): boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Given a file path, convert it to a URI string
|
|
216
|
+
*/
|
|
217
|
+
pathToUri(filePath: string): string;
|
|
218
|
+
/**
|
|
219
|
+
* Given a URI, convert that to a regular fs path
|
|
220
|
+
*/
|
|
221
|
+
uriToPath(uri: string): string;
|
|
211
222
|
/**
|
|
212
223
|
* Get the outDir from options, taking into account cwd and absolute outFile paths
|
|
213
224
|
*/
|
|
@@ -377,7 +388,7 @@ export declare class Util {
|
|
|
377
388
|
/**
|
|
378
389
|
* Load and return the list of plugins
|
|
379
390
|
*/
|
|
380
|
-
loadPlugins(cwd: string, pathOrModules: string[], onError?: (pathOrModule: string, err: Error) => void):
|
|
391
|
+
loadPlugins(cwd: string, pathOrModules: string[], onError?: (pathOrModule: string, err: Error) => void): Plugin[];
|
|
381
392
|
/**
|
|
382
393
|
* Gathers expressions, variables, and unique names from an expression.
|
|
383
394
|
* This is mostly used for the ternary expression
|
|
@@ -389,6 +400,8 @@ export declare class Util {
|
|
|
389
400
|
* that haven't changed at all, but we still need the map
|
|
390
401
|
*/
|
|
391
402
|
simpleMap(source: string, src: string): SourceNode;
|
|
403
|
+
private isWindows;
|
|
404
|
+
private standardizePathCache;
|
|
392
405
|
/**
|
|
393
406
|
* Converts a path into a standardized format (drive letter to lower, remove extra slashes, use single slash type, resolve relative parts, etc...)
|
|
394
407
|
*/
|
|
@@ -452,6 +465,21 @@ export declare class Util {
|
|
|
452
465
|
*/
|
|
453
466
|
rangeToString(range: Range): string;
|
|
454
467
|
validateTooDeepFile(file: (BrsFile | XmlFile)): void;
|
|
468
|
+
/**
|
|
469
|
+
* Execute dispose for a series of disposable items
|
|
470
|
+
* @param disposables a list of functions or disposables
|
|
471
|
+
*/
|
|
472
|
+
applyDispose(disposables: DisposableLike[]): void;
|
|
473
|
+
/**
|
|
474
|
+
* Race a series of promises, and return the first one that resolves AND matches the matcher function.
|
|
475
|
+
* If all of the promises reject, then this will emit an AggregatreError with all of the errors.
|
|
476
|
+
* If at least one promise resolves, then this will log all of the errors to the console
|
|
477
|
+
* If at least one promise resolves but none of them match the matcher, then this will return undefined.
|
|
478
|
+
* @param promises all of the promises to race
|
|
479
|
+
* @param matcher a function that should return true if this value should be kept. Returning any value other than true means `false`
|
|
480
|
+
* @returns the first resolved value that matches the matcher, or undefined if none of them match
|
|
481
|
+
*/
|
|
482
|
+
promiseRaceMatch<T>(promises: MaybePromise<T>[], matcher: (value: T) => boolean): Promise<T>;
|
|
455
483
|
/**
|
|
456
484
|
* Wraps SourceNode's constructor to be compatible with the TranspileResult type
|
|
457
485
|
*/
|
package/dist/util.js
CHANGED
|
@@ -7,7 +7,6 @@ const jsonc_parser_1 = require("jsonc-parser");
|
|
|
7
7
|
const path = require("path");
|
|
8
8
|
const roku_deploy_1 = require("roku-deploy");
|
|
9
9
|
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
10
|
-
const vscode_languageserver_2 = require("vscode-languageserver");
|
|
11
10
|
const vscode_uri_1 = require("vscode-uri");
|
|
12
11
|
const xml2js = require("xml2js");
|
|
13
12
|
const DiagnosticMessages_1 = require("./DiagnosticMessages");
|
|
@@ -41,9 +40,24 @@ const FunctionType_1 = require("./types/FunctionType");
|
|
|
41
40
|
const helpers_1 = require("./types/helpers");
|
|
42
41
|
const InvalidType_1 = require("./types/InvalidType");
|
|
43
42
|
class Util {
|
|
43
|
+
constructor() {
|
|
44
|
+
this.isWindows = process.platform === 'win32';
|
|
45
|
+
this.standardizePathCache = new Map();
|
|
46
|
+
}
|
|
44
47
|
clearConsole() {
|
|
45
48
|
// process.stdout.write('\x1Bc');
|
|
46
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Get the version of brighterscript
|
|
52
|
+
*/
|
|
53
|
+
getBrighterScriptVersion() {
|
|
54
|
+
try {
|
|
55
|
+
return fsExtra.readJsonSync(`${__dirname}/../package.json`).version;
|
|
56
|
+
}
|
|
57
|
+
catch (_a) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
47
61
|
/**
|
|
48
62
|
* Returns the number of parent directories in the filPath
|
|
49
63
|
*/
|
|
@@ -81,7 +95,25 @@ class Util {
|
|
|
81
95
|
* Determine if this path is a directory
|
|
82
96
|
*/
|
|
83
97
|
isDirectorySync(dirPath) {
|
|
84
|
-
|
|
98
|
+
try {
|
|
99
|
+
return dirPath !== undefined && fs.existsSync(dirPath) && fs.lstatSync(dirPath).isDirectory();
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Read a file from disk. If a failure occurrs, simply return undefined
|
|
107
|
+
* @param filePath path to the file
|
|
108
|
+
* @returns the string contents, or undefined if the file doesn't exist
|
|
109
|
+
*/
|
|
110
|
+
readFileSync(filePath) {
|
|
111
|
+
try {
|
|
112
|
+
return fsExtra.readFileSync(filePath);
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
85
117
|
}
|
|
86
118
|
/**
|
|
87
119
|
* Given a pkg path of any kind, transform it to a roku-specific pkg path (i.e. "pkg:/some/path.brs")
|
|
@@ -341,6 +373,7 @@ class Util {
|
|
|
341
373
|
ignoreErrorCodes: (_h = config.ignoreErrorCodes) !== null && _h !== void 0 ? _h : [],
|
|
342
374
|
diagnosticSeverityOverrides: (_j = config.diagnosticSeverityOverrides) !== null && _j !== void 0 ? _j : {},
|
|
343
375
|
diagnosticFilters: (_k = config.diagnosticFilters) !== null && _k !== void 0 ? _k : [],
|
|
376
|
+
diagnosticFiltersV0Compatibility: config.diagnosticFiltersV0Compatibility === true ? true : false,
|
|
344
377
|
plugins: (_l = config.plugins) !== null && _l !== void 0 ? _l : [],
|
|
345
378
|
pruneEmptyCodeFiles: config.pruneEmptyCodeFiles === true ? true : false,
|
|
346
379
|
autoImportComponentScript: config.autoImportComponentScript === true ? true : false,
|
|
@@ -703,44 +736,6 @@ class Util {
|
|
|
703
736
|
}
|
|
704
737
|
return subject;
|
|
705
738
|
}
|
|
706
|
-
/**
|
|
707
|
-
* Does the string appear to be a uri (i.e. does it start with `file:`)
|
|
708
|
-
*/
|
|
709
|
-
isUriLike(filePath) {
|
|
710
|
-
return (filePath === null || filePath === void 0 ? void 0 : filePath.indexOf('file:')) === 0; // eslint-disable-line @typescript-eslint/prefer-string-starts-ends-with
|
|
711
|
-
}
|
|
712
|
-
/**
|
|
713
|
-
* Given a file path, convert it to a URI string
|
|
714
|
-
*/
|
|
715
|
-
pathToUri(filePath) {
|
|
716
|
-
if (!filePath) {
|
|
717
|
-
return filePath;
|
|
718
|
-
}
|
|
719
|
-
else if (this.isUriLike(filePath)) {
|
|
720
|
-
return filePath;
|
|
721
|
-
}
|
|
722
|
-
else {
|
|
723
|
-
return vscode_uri_1.URI.file(filePath).toString();
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
/**
|
|
727
|
-
* Given a URI, convert that to a regular fs path
|
|
728
|
-
*/
|
|
729
|
-
uriToPath(uri) {
|
|
730
|
-
//if this doesn't look like a URI, then assume it's already a path
|
|
731
|
-
if (this.isUriLike(uri) === false) {
|
|
732
|
-
return uri;
|
|
733
|
-
}
|
|
734
|
-
let parsedPath = vscode_uri_1.URI.parse(uri).fsPath;
|
|
735
|
-
//Uri annoyingly converts all drive letters to lower case...so this will bring back whatever case it came in as
|
|
736
|
-
let match = /\/\/\/([a-z]:)/i.exec(uri);
|
|
737
|
-
if (match) {
|
|
738
|
-
let originalDriveCasing = match[1];
|
|
739
|
-
parsedPath = originalDriveCasing + parsedPath.substring(2);
|
|
740
|
-
}
|
|
741
|
-
const normalizedPath = path.normalize(parsedPath);
|
|
742
|
-
return normalizedPath;
|
|
743
|
-
}
|
|
744
739
|
/**
|
|
745
740
|
* Force the drive letter to lower case
|
|
746
741
|
*/
|
|
@@ -785,6 +780,44 @@ class Util {
|
|
|
785
780
|
}
|
|
786
781
|
return true;
|
|
787
782
|
}
|
|
783
|
+
/**
|
|
784
|
+
* Does the string appear to be a uri (i.e. does it start with `file:`)
|
|
785
|
+
*/
|
|
786
|
+
isUriLike(filePath) {
|
|
787
|
+
return (filePath === null || filePath === void 0 ? void 0 : filePath.indexOf('file:')) === 0; // eslint-disable-line @typescript-eslint/prefer-string-starts-ends-with
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Given a file path, convert it to a URI string
|
|
791
|
+
*/
|
|
792
|
+
pathToUri(filePath) {
|
|
793
|
+
if (!filePath) {
|
|
794
|
+
return filePath;
|
|
795
|
+
}
|
|
796
|
+
else if (this.isUriLike(filePath)) {
|
|
797
|
+
return filePath;
|
|
798
|
+
}
|
|
799
|
+
else {
|
|
800
|
+
return vscode_uri_1.URI.file(filePath).toString();
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Given a URI, convert that to a regular fs path
|
|
805
|
+
*/
|
|
806
|
+
uriToPath(uri) {
|
|
807
|
+
//if this doesn't look like a URI, then assume it's already a path
|
|
808
|
+
if (this.isUriLike(uri) === false) {
|
|
809
|
+
return uri;
|
|
810
|
+
}
|
|
811
|
+
let parsedPath = vscode_uri_1.URI.parse(uri).fsPath;
|
|
812
|
+
//Uri annoyingly converts all drive letters to lower case...so this will bring back whatever case it came in as
|
|
813
|
+
let match = /\/\/\/([a-z]:)/i.exec(uri);
|
|
814
|
+
if (match) {
|
|
815
|
+
let originalDriveCasing = match[1];
|
|
816
|
+
parsedPath = originalDriveCasing + parsedPath.substring(2);
|
|
817
|
+
}
|
|
818
|
+
const normalizedPath = path.normalize(parsedPath);
|
|
819
|
+
return normalizedPath;
|
|
820
|
+
}
|
|
788
821
|
/**
|
|
789
822
|
* Get the outDir from options, taking into account cwd and absolute outFile paths
|
|
790
823
|
*/
|
|
@@ -906,7 +939,7 @@ class Util {
|
|
|
906
939
|
else if ('range' in rangeIsh) {
|
|
907
940
|
return rangeIsh.range;
|
|
908
941
|
}
|
|
909
|
-
else if (
|
|
942
|
+
else if (vscode_languageserver_1.Range.is(rangeIsh)) {
|
|
910
943
|
return rangeIsh;
|
|
911
944
|
}
|
|
912
945
|
else {
|
|
@@ -1252,67 +1285,67 @@ class Util {
|
|
|
1252
1285
|
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
1253
1286
|
switch (token.kind) {
|
|
1254
1287
|
case TokenKind_1.TokenKind.Boolean:
|
|
1255
|
-
return
|
|
1288
|
+
return BooleanType_1.BooleanType.instance;
|
|
1256
1289
|
case TokenKind_1.TokenKind.True:
|
|
1257
1290
|
case TokenKind_1.TokenKind.False:
|
|
1258
1291
|
return BooleanType_1.BooleanType.instance;
|
|
1259
1292
|
case TokenKind_1.TokenKind.Double:
|
|
1260
|
-
return
|
|
1293
|
+
return DoubleType_1.DoubleType.instance;
|
|
1261
1294
|
case TokenKind_1.TokenKind.DoubleLiteral:
|
|
1262
1295
|
return DoubleType_1.DoubleType.instance;
|
|
1263
1296
|
case TokenKind_1.TokenKind.Dynamic:
|
|
1264
|
-
return
|
|
1297
|
+
return DynamicType_1.DynamicType.instance;
|
|
1265
1298
|
case TokenKind_1.TokenKind.Float:
|
|
1266
|
-
return
|
|
1299
|
+
return FloatType_1.FloatType.instance;
|
|
1267
1300
|
case TokenKind_1.TokenKind.FloatLiteral:
|
|
1268
1301
|
return FloatType_1.FloatType.instance;
|
|
1269
1302
|
case TokenKind_1.TokenKind.Function:
|
|
1270
|
-
return
|
|
1303
|
+
return FunctionType_1.FunctionType.instance;
|
|
1271
1304
|
case TokenKind_1.TokenKind.Integer:
|
|
1272
|
-
return
|
|
1305
|
+
return IntegerType_1.IntegerType.instance;
|
|
1273
1306
|
case TokenKind_1.TokenKind.IntegerLiteral:
|
|
1274
1307
|
return IntegerType_1.IntegerType.instance;
|
|
1275
1308
|
case TokenKind_1.TokenKind.Invalid:
|
|
1276
|
-
return
|
|
1309
|
+
return InvalidType_1.InvalidType.instance;
|
|
1277
1310
|
case TokenKind_1.TokenKind.LongInteger:
|
|
1278
|
-
return
|
|
1311
|
+
return LongIntegerType_1.LongIntegerType.instance;
|
|
1279
1312
|
case TokenKind_1.TokenKind.LongIntegerLiteral:
|
|
1280
1313
|
return LongIntegerType_1.LongIntegerType.instance;
|
|
1281
1314
|
case TokenKind_1.TokenKind.Object:
|
|
1282
|
-
return
|
|
1315
|
+
return ObjectType_1.ObjectType.instance;
|
|
1283
1316
|
case TokenKind_1.TokenKind.String:
|
|
1284
|
-
return
|
|
1317
|
+
return StringType_1.StringType.instance;
|
|
1285
1318
|
case TokenKind_1.TokenKind.StringLiteral:
|
|
1286
1319
|
case TokenKind_1.TokenKind.TemplateStringExpressionBegin:
|
|
1287
1320
|
case TokenKind_1.TokenKind.TemplateStringExpressionEnd:
|
|
1288
1321
|
case TokenKind_1.TokenKind.TemplateStringQuasi:
|
|
1289
1322
|
return StringType_1.StringType.instance;
|
|
1290
1323
|
case TokenKind_1.TokenKind.Void:
|
|
1291
|
-
return
|
|
1324
|
+
return VoidType_1.VoidType.instance;
|
|
1292
1325
|
case TokenKind_1.TokenKind.Identifier:
|
|
1293
1326
|
switch (token.text.toLowerCase()) {
|
|
1294
1327
|
case 'boolean':
|
|
1295
|
-
return
|
|
1328
|
+
return BooleanType_1.BooleanType.instance;
|
|
1296
1329
|
case 'double':
|
|
1297
|
-
return
|
|
1330
|
+
return DoubleType_1.DoubleType.instance;
|
|
1298
1331
|
case 'dynamic':
|
|
1299
|
-
return
|
|
1332
|
+
return DynamicType_1.DynamicType.instance;
|
|
1300
1333
|
case 'float':
|
|
1301
|
-
return
|
|
1334
|
+
return FloatType_1.FloatType.instance;
|
|
1302
1335
|
case 'function':
|
|
1303
|
-
return
|
|
1336
|
+
return FunctionType_1.FunctionType.instance;
|
|
1304
1337
|
case 'integer':
|
|
1305
|
-
return
|
|
1338
|
+
return IntegerType_1.IntegerType.instance;
|
|
1306
1339
|
case 'invalid':
|
|
1307
|
-
return
|
|
1340
|
+
return InvalidType_1.InvalidType.instance;
|
|
1308
1341
|
case 'longinteger':
|
|
1309
|
-
return
|
|
1342
|
+
return LongIntegerType_1.LongIntegerType.instance;
|
|
1310
1343
|
case 'object':
|
|
1311
|
-
return
|
|
1344
|
+
return ObjectType_1.ObjectType.instance;
|
|
1312
1345
|
case 'string':
|
|
1313
|
-
return
|
|
1346
|
+
return StringType_1.StringType.instance;
|
|
1314
1347
|
case 'void':
|
|
1315
|
-
return
|
|
1348
|
+
return VoidType_1.VoidType.instance;
|
|
1316
1349
|
}
|
|
1317
1350
|
}
|
|
1318
1351
|
}
|
|
@@ -1810,7 +1843,9 @@ class Util {
|
|
|
1810
1843
|
// the official plugin format is a factory function that returns a new instance of a plugin.
|
|
1811
1844
|
}
|
|
1812
1845
|
else if (typeof theExport === 'function') {
|
|
1813
|
-
plugin = theExport(
|
|
1846
|
+
plugin = theExport({
|
|
1847
|
+
version: this.getBrighterScriptVersion()
|
|
1848
|
+
});
|
|
1814
1849
|
}
|
|
1815
1850
|
else {
|
|
1816
1851
|
//this should never happen; somehow an invalid plugin has made it into here
|
|
@@ -1891,7 +1926,36 @@ class Util {
|
|
|
1891
1926
|
* Converts a path into a standardized format (drive letter to lower, remove extra slashes, use single slash type, resolve relative parts, etc...)
|
|
1892
1927
|
*/
|
|
1893
1928
|
standardizePath(thePath) {
|
|
1894
|
-
|
|
1929
|
+
//if we have the value in cache already, return it
|
|
1930
|
+
if (this.standardizePathCache.has(thePath)) {
|
|
1931
|
+
return this.standardizePathCache.get(thePath);
|
|
1932
|
+
}
|
|
1933
|
+
const originalPath = thePath;
|
|
1934
|
+
if (typeof thePath !== 'string') {
|
|
1935
|
+
return thePath;
|
|
1936
|
+
}
|
|
1937
|
+
//windows path.normalize will convert all slashes to backslashes and remove duplicates
|
|
1938
|
+
if (this.isWindows) {
|
|
1939
|
+
thePath = path.win32.normalize(thePath);
|
|
1940
|
+
}
|
|
1941
|
+
else {
|
|
1942
|
+
//replace all windows or consecutive slashes with path.sep
|
|
1943
|
+
thePath = thePath.replace(/[\/\\]+/g, '/');
|
|
1944
|
+
// only use path.normalize if dots are present since it's expensive
|
|
1945
|
+
if (thePath.includes('./')) {
|
|
1946
|
+
thePath = path.posix.normalize(thePath);
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
// Lowercase drive letter on Windows-like paths (e.g., "C:/...")
|
|
1950
|
+
if (thePath.charCodeAt(1) === 58 /* : */) {
|
|
1951
|
+
// eslint-disable-next-line no-var
|
|
1952
|
+
var firstChar = thePath.charCodeAt(0);
|
|
1953
|
+
if (firstChar >= 65 && firstChar <= 90) {
|
|
1954
|
+
thePath = String.fromCharCode(firstChar + 32) + thePath.slice(1);
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
this.standardizePathCache.set(originalPath, thePath);
|
|
1958
|
+
return thePath;
|
|
1895
1959
|
}
|
|
1896
1960
|
/**
|
|
1897
1961
|
* Given a Diagnostic or BsDiagnostic, return a deep clone of the diagnostic.
|
|
@@ -1899,7 +1963,7 @@ class Util {
|
|
|
1899
1963
|
* @param relatedInformationFallbackLocation a default location to use for all `relatedInformation` entries that are missing a location
|
|
1900
1964
|
*/
|
|
1901
1965
|
toDiagnostic(diagnostic, relatedInformationFallbackLocation) {
|
|
1902
|
-
var _a, _b, _c, _d;
|
|
1966
|
+
var _a, _b, _c, _d, _e;
|
|
1903
1967
|
let relatedInformation = (_a = diagnostic.relatedInformation) !== null && _a !== void 0 ? _a : [];
|
|
1904
1968
|
if (relatedInformation.length > diagnosticUtils_1.MAX_RELATED_INFOS_COUNT) {
|
|
1905
1969
|
const relatedInfoLength = relatedInformation.length;
|
|
@@ -1931,9 +1995,9 @@ class Util {
|
|
|
1931
1995
|
//filter out null relatedInformation items
|
|
1932
1996
|
}).filter((x) => Boolean(x)),
|
|
1933
1997
|
code: diagnostic.code ? diagnostic.code : diagnostic.legacyCode,
|
|
1934
|
-
source: 'brs'
|
|
1998
|
+
source: (_d = diagnostic.source) !== null && _d !== void 0 ? _d : 'brs'
|
|
1935
1999
|
};
|
|
1936
|
-
if (((
|
|
2000
|
+
if (((_e = diagnostic === null || diagnostic === void 0 ? void 0 : diagnostic.tags) === null || _e === void 0 ? void 0 : _e.length) > 0) {
|
|
1937
2001
|
result.tags = diagnostic.tags;
|
|
1938
2002
|
}
|
|
1939
2003
|
return result;
|
|
@@ -1956,7 +2020,7 @@ class Util {
|
|
|
1956
2020
|
*/
|
|
1957
2021
|
sortByRange(locatables) {
|
|
1958
2022
|
//sort the tokens by range
|
|
1959
|
-
return locatables.sort((a, b) => {
|
|
2023
|
+
return locatables === null || locatables === void 0 ? void 0 : locatables.sort((a, b) => {
|
|
1960
2024
|
//handle undefined tokens to prevent crashes
|
|
1961
2025
|
if (!(a === null || a === void 0 ? void 0 : a.range)) {
|
|
1962
2026
|
return 1;
|
|
@@ -2188,6 +2252,68 @@ class Util {
|
|
|
2188
2252
|
(_b = file.program) === null || _b === void 0 ? void 0 : _b.diagnostics.register(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.detectedTooDeepFileSource(fileDepth)), { location: exports.util.createLocationFromFileRange(file, this.createRange(0, 0, 0, Number.MAX_VALUE)) }));
|
|
2189
2253
|
}
|
|
2190
2254
|
}
|
|
2255
|
+
/**
|
|
2256
|
+
* Execute dispose for a series of disposable items
|
|
2257
|
+
* @param disposables a list of functions or disposables
|
|
2258
|
+
*/
|
|
2259
|
+
applyDispose(disposables) {
|
|
2260
|
+
var _a;
|
|
2261
|
+
for (const disposable of disposables !== null && disposables !== void 0 ? disposables : []) {
|
|
2262
|
+
if (typeof disposable === 'function') {
|
|
2263
|
+
disposable();
|
|
2264
|
+
}
|
|
2265
|
+
else {
|
|
2266
|
+
(_a = disposable === null || disposable === void 0 ? void 0 : disposable.dispose) === null || _a === void 0 ? void 0 : _a.call(disposable);
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
/**
|
|
2271
|
+
* Race a series of promises, and return the first one that resolves AND matches the matcher function.
|
|
2272
|
+
* If all of the promises reject, then this will emit an AggregatreError with all of the errors.
|
|
2273
|
+
* If at least one promise resolves, then this will log all of the errors to the console
|
|
2274
|
+
* If at least one promise resolves but none of them match the matcher, then this will return undefined.
|
|
2275
|
+
* @param promises all of the promises to race
|
|
2276
|
+
* @param matcher a function that should return true if this value should be kept. Returning any value other than true means `false`
|
|
2277
|
+
* @returns the first resolved value that matches the matcher, or undefined if none of them match
|
|
2278
|
+
*/
|
|
2279
|
+
async promiseRaceMatch(promises, matcher) {
|
|
2280
|
+
const workingPromises = [
|
|
2281
|
+
...promises
|
|
2282
|
+
];
|
|
2283
|
+
const results = [];
|
|
2284
|
+
let returnValue;
|
|
2285
|
+
while (workingPromises.length > 0) {
|
|
2286
|
+
//race the promises. If any of them resolve, evaluate it against the matcher. If that passes, return the value. otherwise, eliminate this promise and try again
|
|
2287
|
+
const result = await Promise.race(workingPromises.map((promise, i) => {
|
|
2288
|
+
return Promise.resolve(promise)
|
|
2289
|
+
.then(value => ({ value: value, index: i }))
|
|
2290
|
+
.catch(error => ({ error: error, index: i }));
|
|
2291
|
+
}));
|
|
2292
|
+
results.push(result);
|
|
2293
|
+
//if we got a value and it matches the matcher, return it
|
|
2294
|
+
if ('value' in result && (matcher === null || matcher === void 0 ? void 0 : matcher(result.value)) === true) {
|
|
2295
|
+
returnValue = result.value;
|
|
2296
|
+
break;
|
|
2297
|
+
}
|
|
2298
|
+
//remove this non-matched (or errored) promise from the list and try again
|
|
2299
|
+
workingPromises.splice(result.index, 1);
|
|
2300
|
+
}
|
|
2301
|
+
const errors = results
|
|
2302
|
+
.filter(x => 'error' in x)
|
|
2303
|
+
.map(x => x.error);
|
|
2304
|
+
//if all of them crashed, then reject
|
|
2305
|
+
if (promises.length > 0 && errors.length === promises.length) {
|
|
2306
|
+
throw new AggregateError(errors, 'All requests failed. First error message: ' + errors[0].message);
|
|
2307
|
+
}
|
|
2308
|
+
else {
|
|
2309
|
+
//log all of the errors
|
|
2310
|
+
for (const error of errors) {
|
|
2311
|
+
console.error(error);
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
//return the matched value, or undefined if there wasn't one
|
|
2315
|
+
return returnValue;
|
|
2316
|
+
}
|
|
2191
2317
|
/**
|
|
2192
2318
|
* Wraps SourceNode's constructor to be compatible with the TranspileResult type
|
|
2193
2319
|
*/
|
|
@@ -2665,7 +2791,7 @@ function standardizePath(stringParts, ...expressions) {
|
|
|
2665
2791
|
for (let i = 0; i < stringParts.length; i++) {
|
|
2666
2792
|
result.push(stringParts[i], expressions[i]);
|
|
2667
2793
|
}
|
|
2668
|
-
return exports.util.
|
|
2794
|
+
return exports.util.standardizePath(result.join(''));
|
|
2669
2795
|
}
|
|
2670
2796
|
exports.standardizePath = standardizePath;
|
|
2671
2797
|
exports.util = new Util();
|