brighterscript 0.68.4 → 0.69.0

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.
Files changed (114) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/BusyStatusTracker.d.ts +37 -7
  3. package/dist/BusyStatusTracker.js +73 -8
  4. package/dist/BusyStatusTracker.js.map +1 -1
  5. package/dist/DiagnosticCollection.d.ts +19 -5
  6. package/dist/DiagnosticCollection.js +67 -16
  7. package/dist/DiagnosticCollection.js.map +1 -1
  8. package/dist/LanguageServer.d.ts +82 -132
  9. package/dist/LanguageServer.js +403 -940
  10. package/dist/LanguageServer.js.map +1 -1
  11. package/dist/Logger.d.ts +9 -4
  12. package/dist/Logger.js +30 -6
  13. package/dist/Logger.js.map +1 -1
  14. package/dist/PluginInterface.d.ts +1 -1
  15. package/dist/PluginInterface.js.map +1 -1
  16. package/dist/Program.d.ts +20 -2
  17. package/dist/Program.js +124 -49
  18. package/dist/Program.js.map +1 -1
  19. package/dist/ProgramBuilder.d.ts +21 -7
  20. package/dist/ProgramBuilder.js +45 -22
  21. package/dist/ProgramBuilder.js.map +1 -1
  22. package/dist/Scope.js +6 -3
  23. package/dist/Scope.js.map +1 -1
  24. package/dist/SemanticTokenUtils.js +1 -1
  25. package/dist/SemanticTokenUtils.js.map +1 -1
  26. package/dist/bscPlugin/CallExpressionInfo.js +2 -1
  27. package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
  28. package/dist/bscPlugin/completions/CompletionsProcessor.js +14 -4
  29. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
  30. package/dist/bscPlugin/hover/HoverProcessor.js +1 -1
  31. package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
  32. package/dist/bscPlugin/validation/ScopeValidator.js +9 -9
  33. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
  34. package/dist/common/Sequencer.d.ts +27 -0
  35. package/dist/common/Sequencer.js +113 -0
  36. package/dist/common/Sequencer.js.map +1 -0
  37. package/dist/common/Sequencer.spec.d.ts +1 -0
  38. package/dist/common/Sequencer.spec.js +75 -0
  39. package/dist/common/Sequencer.spec.js.map +1 -0
  40. package/dist/deferred.d.ts +2 -0
  41. package/dist/deferred.js +10 -0
  42. package/dist/deferred.js.map +1 -1
  43. package/dist/files/BrsFile.d.ts +1 -1
  44. package/dist/files/BrsFile.js +10 -15
  45. package/dist/files/BrsFile.js.map +1 -1
  46. package/dist/files/BrsFile.spec.js +8 -0
  47. package/dist/files/BrsFile.spec.js.map +1 -1
  48. package/dist/interfaces.d.ts +22 -2
  49. package/dist/lexer/Lexer.js +1 -1
  50. package/dist/lexer/Lexer.js.map +1 -1
  51. package/dist/logging.d.ts +6 -1
  52. package/dist/logging.js +14 -1
  53. package/dist/logging.js.map +1 -1
  54. package/dist/lsp/ActionQueue.d.ts +35 -0
  55. package/dist/lsp/ActionQueue.js +115 -0
  56. package/dist/lsp/ActionQueue.js.map +1 -0
  57. package/dist/lsp/ActionQueue.spec.d.ts +1 -0
  58. package/dist/lsp/ActionQueue.spec.js +80 -0
  59. package/dist/lsp/ActionQueue.spec.js.map +1 -0
  60. package/dist/lsp/DocumentManager.d.ts +63 -0
  61. package/dist/lsp/DocumentManager.js +122 -0
  62. package/dist/lsp/DocumentManager.js.map +1 -0
  63. package/dist/lsp/DocumentManager.spec.d.ts +1 -0
  64. package/dist/lsp/DocumentManager.spec.js +103 -0
  65. package/dist/lsp/DocumentManager.spec.js.map +1 -0
  66. package/dist/lsp/LspProject.d.ts +231 -0
  67. package/dist/lsp/LspProject.js +3 -0
  68. package/dist/lsp/LspProject.js.map +1 -0
  69. package/dist/lsp/PathFilterer.d.ts +75 -0
  70. package/dist/lsp/PathFilterer.js +196 -0
  71. package/dist/lsp/PathFilterer.js.map +1 -0
  72. package/dist/lsp/PathFilterer.spec.d.ts +1 -0
  73. package/dist/lsp/PathFilterer.spec.js +182 -0
  74. package/dist/lsp/PathFilterer.spec.js.map +1 -0
  75. package/dist/lsp/Project.d.ts +178 -0
  76. package/dist/lsp/Project.js +438 -0
  77. package/dist/lsp/Project.js.map +1 -0
  78. package/dist/lsp/Project.spec.d.ts +1 -0
  79. package/dist/lsp/Project.spec.js +236 -0
  80. package/dist/lsp/Project.spec.js.map +1 -0
  81. package/dist/lsp/ProjectManager.d.ts +221 -0
  82. package/dist/lsp/ProjectManager.js +735 -0
  83. package/dist/lsp/ProjectManager.js.map +1 -0
  84. package/dist/lsp/ProjectManager.spec.d.ts +1 -0
  85. package/dist/lsp/ProjectManager.spec.js +756 -0
  86. package/dist/lsp/ProjectManager.spec.js.map +1 -0
  87. package/dist/lsp/ReaderWriterManager.d.ts +21 -0
  88. package/dist/lsp/ReaderWriterManager.js +60 -0
  89. package/dist/lsp/ReaderWriterManager.js.map +1 -0
  90. package/dist/lsp/worker/MessageHandler.d.ts +99 -0
  91. package/dist/lsp/worker/MessageHandler.js +138 -0
  92. package/dist/lsp/worker/MessageHandler.js.map +1 -0
  93. package/dist/lsp/worker/MessageHandler.spec.d.ts +1 -0
  94. package/dist/lsp/worker/MessageHandler.spec.js +64 -0
  95. package/dist/lsp/worker/MessageHandler.spec.js.map +1 -0
  96. package/dist/lsp/worker/WorkerPool.d.ts +38 -0
  97. package/dist/lsp/worker/WorkerPool.js +78 -0
  98. package/dist/lsp/worker/WorkerPool.js.map +1 -0
  99. package/dist/lsp/worker/WorkerPool.spec.d.ts +1 -0
  100. package/dist/lsp/worker/WorkerPool.spec.js +59 -0
  101. package/dist/lsp/worker/WorkerPool.spec.js.map +1 -0
  102. package/dist/lsp/worker/WorkerThreadProject.d.ts +144 -0
  103. package/dist/lsp/worker/WorkerThreadProject.js +181 -0
  104. package/dist/lsp/worker/WorkerThreadProject.js.map +1 -0
  105. package/dist/lsp/worker/WorkerThreadProject.spec.d.ts +2 -0
  106. package/dist/lsp/worker/WorkerThreadProject.spec.js +68 -0
  107. package/dist/lsp/worker/WorkerThreadProject.spec.js.map +1 -0
  108. package/dist/lsp/worker/WorkerThreadProjectRunner.d.ts +15 -0
  109. package/dist/lsp/worker/WorkerThreadProjectRunner.js +58 -0
  110. package/dist/lsp/worker/WorkerThreadProjectRunner.js.map +1 -0
  111. package/dist/util.d.ts +31 -5
  112. package/dist/util.js +117 -19
  113. package/dist/util.js.map +1 -1
  114. package/package.json +11 -1
@@ -0,0 +1,144 @@
1
+ import type { LspDiagnostic, ActivateResponse, ProjectConfig } from '../LspProject';
2
+ import { type LspProject } from '../LspProject';
3
+ import { WorkerPool } from './WorkerPool';
4
+ import type { Hover, MaybePromise, SemanticToken } from '../../interfaces';
5
+ import type { DocumentAction, DocumentActionWithStatus } from '../DocumentManager';
6
+ import type { FileTranspileResult, SignatureInfoObj } from '../../Program';
7
+ import type { Position, Range, Location, DocumentSymbol, WorkspaceSymbol, CodeAction, CompletionList } from 'vscode-languageserver-protocol';
8
+ import type { Logger } from '../../logging';
9
+ export declare const workerPool: WorkerPool;
10
+ export declare class WorkerThreadProject implements LspProject {
11
+ constructor(options?: {
12
+ logger?: Logger;
13
+ projectIdentifier?: string;
14
+ });
15
+ activate(options: ProjectConfig): Promise<ActivateResponse>;
16
+ logger: Logger;
17
+ isStandaloneProject: boolean;
18
+ private activationDeferred;
19
+ /**
20
+ * Options used to activate this project
21
+ */
22
+ activateOptions: ProjectConfig;
23
+ /**
24
+ * The root directory of the project
25
+ */
26
+ rootDir: string;
27
+ /**
28
+ * The file patterns from bsconfig.json that were used to find all files for this project
29
+ */
30
+ filePatterns: string[];
31
+ /**
32
+ * Path to a bsconfig.json file that will be used for this project
33
+ */
34
+ bsconfigPath?: string;
35
+ /**
36
+ * The contents of the bsconfig.json file. This is used to detect when the bsconfig file has not actually been changed (even if the fs says it did).
37
+ *
38
+ * Only available after `.activate()` has completed.
39
+ * @deprecated do not depend on this property. This will certainly be removed in a future release
40
+ */
41
+ bsconfigFileContents?: string;
42
+ /**
43
+ * The worker thread where the actual project will execute
44
+ */
45
+ private worker;
46
+ /**
47
+ * The path to where the project resides
48
+ */
49
+ projectPath: string;
50
+ /**
51
+ * A unique number for this project, generated during this current language server session. Mostly used so we can identify which project is doing logging
52
+ */
53
+ projectNumber: number;
54
+ /**
55
+ * A unique name for this project used in logs to help keep track of everything
56
+ */
57
+ projectIdentifier: string;
58
+ /**
59
+ * The path to the workspace where this project resides. A workspace can have multiple projects (by adding a bsconfig.json to each folder).
60
+ * Defaults to `.projectPath` if not set
61
+ */
62
+ workspaceFolder: string;
63
+ /**
64
+ * Promise that resolves when the project finishes activating
65
+ * @returns a promise that resolves when the project finishes activating
66
+ */
67
+ whenActivated(): Promise<void>;
68
+ /**
69
+ * Validate the project. This will trigger a full validation on any scopes that were changed since the last validation,
70
+ * and will also eventually emit a new 'diagnostics' event that includes all diagnostics for the project
71
+ */
72
+ validate(): Promise<void>;
73
+ /**
74
+ * Cancel any active validation that's running
75
+ */
76
+ cancelValidate(): Promise<void>;
77
+ getDiagnostics(): Promise<LspDiagnostic[]>;
78
+ /**
79
+ * Apply a series of file changes to the project. This is safe to call any time. Changes will be queued and flushed at the correct times
80
+ * during the program's lifecycle flow
81
+ */
82
+ applyFileChanges(documentActions: DocumentAction[]): Promise<DocumentActionWithStatus[]>;
83
+ /**
84
+ * Send a request with the standard structure
85
+ * @param name the name of the request
86
+ * @param data the array of data to send
87
+ * @returns the response from the request
88
+ */
89
+ private sendStandardRequest;
90
+ /**
91
+ * Get the full list of semantic tokens for the given file path
92
+ */
93
+ getSemanticTokens(options: {
94
+ srcPath: string;
95
+ }): Promise<SemanticToken[]>;
96
+ transpileFile(options: {
97
+ srcPath: string;
98
+ }): Promise<FileTranspileResult>;
99
+ getHover(options: {
100
+ srcPath: string;
101
+ position: Position;
102
+ }): Promise<Hover[]>;
103
+ getDefinition(options: {
104
+ srcPath: string;
105
+ position: Position;
106
+ }): Promise<Location[]>;
107
+ getSignatureHelp(options: {
108
+ srcPath: string;
109
+ position: Position;
110
+ }): Promise<SignatureInfoObj[]>;
111
+ getDocumentSymbol(options: {
112
+ srcPath: string;
113
+ }): Promise<DocumentSymbol[]>;
114
+ getWorkspaceSymbol(): Promise<WorkspaceSymbol[]>;
115
+ getReferences(options: {
116
+ srcPath: string;
117
+ position: Position;
118
+ }): Promise<Location[]>;
119
+ getCodeActions(options: {
120
+ srcPath: string;
121
+ range: Range;
122
+ }): Promise<CodeAction[]>;
123
+ getCompletions(options: {
124
+ srcPath: string;
125
+ position: Position;
126
+ }): Promise<CompletionList>;
127
+ /**
128
+ * Handles request/response/update messages from the worker thread
129
+ */
130
+ private messageHandler;
131
+ private processRequest;
132
+ private processUpdate;
133
+ on(eventName: 'critical-failure', handler: (data: {
134
+ message: string;
135
+ }) => void): any;
136
+ on(eventName: 'diagnostics', handler: (data: {
137
+ diagnostics: LspDiagnostic[];
138
+ }) => MaybePromise<void>): any;
139
+ on(eventName: 'all', handler: (eventName: string, data: any) => MaybePromise<void>): any;
140
+ private emit;
141
+ private emitter;
142
+ disposables: LspProject['disposables'];
143
+ dispose(): void;
144
+ }
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkerThreadProject = exports.workerPool = void 0;
4
+ const EventEmitter = require("eventemitter3");
5
+ const worker_threads_1 = require("worker_threads");
6
+ const MessageHandler_1 = require("./MessageHandler");
7
+ const util_1 = require("../../util");
8
+ const worker_threads_2 = require("worker_threads");
9
+ const WorkerThreadProjectRunner_1 = require("./WorkerThreadProjectRunner");
10
+ const WorkerPool_1 = require("./WorkerPool");
11
+ const deferred_1 = require("../../deferred");
12
+ const logging_1 = require("../../logging");
13
+ const fsExtra = require("fs-extra");
14
+ exports.workerPool = new WorkerPool_1.WorkerPool(() => {
15
+ return new worker_threads_1.Worker(__filename, {
16
+ //wire up ts-node if we're running in ts-node
17
+ execArgv: /\.ts$/i.test(__filename)
18
+ ? ['--require', 'ts-node/register']
19
+ /* istanbul ignore next */
20
+ : undefined
21
+ });
22
+ });
23
+ //if this script is running in a Worker, start the project runner
24
+ /* istanbul ignore next */
25
+ if (!worker_threads_2.isMainThread) {
26
+ const runner = new WorkerThreadProjectRunner_1.WorkerThreadProjectRunner();
27
+ runner.run(worker_threads_2.parentPort);
28
+ }
29
+ class WorkerThreadProject {
30
+ constructor(options) {
31
+ var _a, _b;
32
+ this.isStandaloneProject = false;
33
+ this.activationDeferred = new deferred_1.Deferred();
34
+ this.emitter = new EventEmitter();
35
+ this.disposables = [];
36
+ this.logger = (_a = options === null || options === void 0 ? void 0 : options.logger) !== null && _a !== void 0 ? _a : (0, logging_1.createLogger)();
37
+ this.projectIdentifier = (_b = options === null || options === void 0 ? void 0 : options.projectIdentifier) !== null && _b !== void 0 ? _b : '';
38
+ }
39
+ async activate(options) {
40
+ this.activateOptions = options;
41
+ this.projectPath = options.projectPath ? util_1.default.standardizePath(options.projectPath) : options.projectPath;
42
+ this.workspaceFolder = options.workspaceFolder ? util_1.default.standardizePath(options.workspaceFolder) : options.workspaceFolder;
43
+ this.projectNumber = options.projectNumber;
44
+ this.bsconfigPath = options.bsconfigPath ? util_1.default.standardizePath(options.bsconfigPath) : options.bsconfigPath;
45
+ // start a new worker thread or get an unused existing thread
46
+ this.worker = exports.workerPool.getWorker();
47
+ this.messageHandler = new MessageHandler_1.MessageHandler({
48
+ name: 'MainThread',
49
+ port: this.worker,
50
+ onRequest: this.processRequest.bind(this),
51
+ onUpdate: this.processUpdate.bind(this)
52
+ });
53
+ this.disposables.push(this.messageHandler);
54
+ const activateResponse = await this.messageHandler.sendRequest('activate', { data: [options] });
55
+ this.bsconfigPath = activateResponse.data.bsconfigPath;
56
+ this.rootDir = activateResponse.data.rootDir;
57
+ this.filePatterns = activateResponse.data.filePatterns;
58
+ this.logger.logLevel = activateResponse.data.logLevel;
59
+ //load the bsconfig file contents (used for performance optimizations externally)
60
+ try {
61
+ this.bsconfigFileContents = (await fsExtra.readFile(this.bsconfigPath)).toString();
62
+ }
63
+ catch (_a) { }
64
+ this.activationDeferred.resolve();
65
+ return activateResponse.data;
66
+ }
67
+ /**
68
+ * Promise that resolves when the project finishes activating
69
+ * @returns a promise that resolves when the project finishes activating
70
+ */
71
+ whenActivated() {
72
+ return this.activationDeferred.promise;
73
+ }
74
+ /**
75
+ * Validate the project. This will trigger a full validation on any scopes that were changed since the last validation,
76
+ * and will also eventually emit a new 'diagnostics' event that includes all diagnostics for the project
77
+ */
78
+ async validate() {
79
+ const response = await this.messageHandler.sendRequest('validate');
80
+ return response.data;
81
+ }
82
+ /**
83
+ * Cancel any active validation that's running
84
+ */
85
+ async cancelValidate() {
86
+ const response = await this.messageHandler.sendRequest('cancelValidate');
87
+ return response.data;
88
+ }
89
+ async getDiagnostics() {
90
+ const response = await this.messageHandler.sendRequest('getDiagnostics');
91
+ return response.data;
92
+ }
93
+ /**
94
+ * Apply a series of file changes to the project. This is safe to call any time. Changes will be queued and flushed at the correct times
95
+ * during the program's lifecycle flow
96
+ */
97
+ async applyFileChanges(documentActions) {
98
+ const response = await this.messageHandler.sendRequest('applyFileChanges', {
99
+ data: [documentActions]
100
+ });
101
+ return response.data;
102
+ }
103
+ /**
104
+ * Send a request with the standard structure
105
+ * @param name the name of the request
106
+ * @param data the array of data to send
107
+ * @returns the response from the request
108
+ */
109
+ async sendStandardRequest(name, ...data) {
110
+ const response = await this.messageHandler.sendRequest(name, {
111
+ data: data
112
+ });
113
+ return response.data;
114
+ }
115
+ /**
116
+ * Get the full list of semantic tokens for the given file path
117
+ */
118
+ async getSemanticTokens(options) {
119
+ return this.sendStandardRequest('getSemanticTokens', options);
120
+ }
121
+ async transpileFile(options) {
122
+ return this.sendStandardRequest('transpileFile', options);
123
+ }
124
+ async getHover(options) {
125
+ return this.sendStandardRequest('getHover', options);
126
+ }
127
+ async getDefinition(options) {
128
+ return this.sendStandardRequest('getDefinition', options);
129
+ }
130
+ async getSignatureHelp(options) {
131
+ return this.sendStandardRequest('getSignatureHelp', options);
132
+ }
133
+ async getDocumentSymbol(options) {
134
+ return this.sendStandardRequest('getDocumentSymbol', options);
135
+ }
136
+ async getWorkspaceSymbol() {
137
+ return this.sendStandardRequest('getWorkspaceSymbol');
138
+ }
139
+ async getReferences(options) {
140
+ return this.sendStandardRequest('getReferences', options);
141
+ }
142
+ async getCodeActions(options) {
143
+ return this.sendStandardRequest('getCodeActions', options);
144
+ }
145
+ async getCompletions(options) {
146
+ return this.sendStandardRequest('getCompletions', options);
147
+ }
148
+ processRequest(request) {
149
+ }
150
+ processUpdate(update) {
151
+ //for now, all updates are treated like "events"
152
+ this.emit(update.name, update.data);
153
+ }
154
+ on(eventName, handler) {
155
+ this.emitter.on(eventName, handler);
156
+ return () => {
157
+ this.emitter.removeListener(eventName, handler);
158
+ };
159
+ }
160
+ async emit(eventName, data) {
161
+ //emit these events on next tick, otherwise they will be processed immediately which could cause issues
162
+ await util_1.default.sleep(0);
163
+ this.emitter.emit(eventName, data);
164
+ //emit the 'all' event
165
+ this.emitter.emit('all', eventName, data);
166
+ }
167
+ dispose() {
168
+ var _a, _b, _c;
169
+ for (let disposable of (_a = this.disposables) !== null && _a !== void 0 ? _a : []) {
170
+ (_b = disposable === null || disposable === void 0 ? void 0 : disposable.dispose) === null || _b === void 0 ? void 0 : _b.call(disposable);
171
+ }
172
+ this.disposables = [];
173
+ //move the worker back to the pool so it can be used again
174
+ if (this.worker) {
175
+ exports.workerPool.releaseWorker(this.worker);
176
+ }
177
+ (_c = this.emitter) === null || _c === void 0 ? void 0 : _c.removeAllListeners();
178
+ }
179
+ }
180
+ exports.WorkerThreadProject = WorkerThreadProject;
181
+ //# sourceMappingURL=WorkerThreadProject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkerThreadProject.js","sourceRoot":"","sources":["../../../src/lsp/worker/WorkerThreadProject.ts"],"names":[],"mappings":";;;AAAA,8CAA8C;AAC9C,mDAAwC;AAExC,qDAAkD;AAClD,qCAA8B;AAG9B,mDAA0D;AAC1D,2EAAwE;AACxE,6CAA0C;AAG1C,6CAA0C;AAI1C,2CAA6C;AAC7C,oCAAoC;AA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 Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWakeWorkerThreadPromise = exports.wakeWorkerThread = void 0;
4
+ const testHelpers_spec_1 = require("../../testHelpers.spec");
5
+ const fsExtra = require("fs-extra");
6
+ const WorkerThreadProject_1 = require("./WorkerThreadProject");
7
+ const DiagnosticMessages_1 = require("../../DiagnosticMessages");
8
+ const chai_1 = require("chai");
9
+ async function wakeWorkerThread() {
10
+ console.log('waking up a worker thread');
11
+ const project = new WorkerThreadProject_1.WorkerThreadProject();
12
+ try {
13
+ await project.activate({
14
+ projectPath: testHelpers_spec_1.rootDir,
15
+ projectNumber: 1
16
+ });
17
+ }
18
+ finally {
19
+ project.dispose();
20
+ }
21
+ }
22
+ exports.wakeWorkerThread = wakeWorkerThread;
23
+ let wakeWorkerThreadPromise1;
24
+ function getWakeWorkerThreadPromise() {
25
+ if (wakeWorkerThreadPromise1 === undefined) {
26
+ wakeWorkerThreadPromise1 = wakeWorkerThread();
27
+ }
28
+ return wakeWorkerThreadPromise1;
29
+ }
30
+ exports.getWakeWorkerThreadPromise = getWakeWorkerThreadPromise;
31
+ after(() => {
32
+ WorkerThreadProject_1.workerPool.dispose();
33
+ });
34
+ describe('WorkerThreadProject', () => {
35
+ let project;
36
+ before(async function workerThreadWarmup() {
37
+ this.timeout(20000);
38
+ await getWakeWorkerThreadPromise();
39
+ });
40
+ beforeEach(() => {
41
+ project === null || project === void 0 ? void 0 : project.dispose();
42
+ project = new WorkerThreadProject_1.WorkerThreadProject();
43
+ fsExtra.emptyDirSync(testHelpers_spec_1.tempDir);
44
+ });
45
+ afterEach(() => {
46
+ fsExtra.emptyDirSync(testHelpers_spec_1.tempDir);
47
+ project === null || project === void 0 ? void 0 : project.dispose();
48
+ });
49
+ describe('activate', () => {
50
+ it('shows diagnostics after running', async () => {
51
+ fsExtra.outputFileSync(`${testHelpers_spec_1.rootDir}/source/main.brs`, `
52
+ sub main()
53
+ print varNotThere
54
+ end sub
55
+ `);
56
+ await project.activate({
57
+ projectPath: testHelpers_spec_1.rootDir,
58
+ projectNumber: 1
59
+ });
60
+ const diagnostics = await project.getDiagnostics();
61
+ (0, chai_1.expect)(diagnostics).lengthOf(1);
62
+ await (0, testHelpers_spec_1.expectDiagnosticsAsync)(diagnostics, [
63
+ DiagnosticMessages_1.DiagnosticMessages.cannotFindName('varNotThere').message
64
+ ]);
65
+ });
66
+ });
67
+ });
68
+ //# sourceMappingURL=WorkerThreadProject.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkerThreadProject.spec.js","sourceRoot":"","sources":["../../../src/lsp/worker/WorkerThreadProject.spec.ts"],"names":[],"mappings":";;;AAAA,6DAAkF;AAClF,oCAAoC;AACpC,+DAAwE;AACxE,iEAA8D;AAC9D,+BAA8B;AAEvB,KAAK,UAAU,gBAAgB;IAClC,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,IAAI,yCAAmB,EAAE,CAAC;IAC1C,IAAI;QACA,MAAM,OAAO,CAAC,QAAQ,CAAC;YACnB,WAAW,EAAE,0BAAO;YACpB,aAAa,EAAE,CAAC;SACZ,CAAC,CAAC;KACb;YAAS;QACN,OAAO,CAAC,OAAO,EAAE,CAAC;KACrB;AACL,CAAC;AAXD,4CAWC;AAED,IAAI,wBAAsC,CAAC;AAC3C,SAAgB,0BAA0B;IACtC,IAAI,wBAAwB,KAAK,SAAS,EAAE;QACxC,wBAAwB,GAAG,gBAAgB,EAAE,CAAC;KACjD;IACD,OAAO,wBAAwB,CAAC;AACpC,CAAC;AALD,gEAKC;AAED,KAAK,CAAC,GAAG,EAAE;IACP,gCAAU,CAAC,OAAO,EAAE,CAAC;AACzB,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACjC,IAAI,OAA4B,CAAC;IACjC,MAAM,CAAC,KAAK,UAAU,kBAAkB;QACpC,IAAI,CAAC,OAAO,CAAC,KAAM,CAAC,CAAC;QACrB,MAAM,0BAA0B,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,UAAU,CAAC,GAAG,EAAE;QACZ,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,EAAE,CAAC;QACnB,OAAO,GAAG,IAAI,yCAAmB,EAAE,CAAC;QACpC,OAAO,CAAC,YAAY,CAAC,0BAAO,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACX,OAAO,CAAC,YAAY,CAAC,0BAAO,CAAC,CAAC;QAC9B,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;QACtB,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;YAC7C,OAAO,CAAC,cAAc,CAAC,GAAG,0BAAO,kBAAkB,EAAE;;;;aAIpD,CAAC,CAAC;YAEH,MAAM,OAAO,CAAC,QAAQ,CAAC;gBACnB,WAAW,EAAE,0BAAO;gBACpB,aAAa,EAAE,CAAC;aACZ,CAAC,CAAC;YACV,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,cAAc,EAAE,CAAC;YACnD,IAAA,aAAM,EAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAChC,MAAM,IAAA,yCAAsB,EAAC,WAAW,EAAE;gBACtC,uCAAkB,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,OAAO;aAC3D,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ /// <reference types="node" />
2
+ import type { MessagePort } from 'worker_threads';
3
+ /**
4
+ * Runner logic for Running a Project in a worker thread.
5
+ */
6
+ export declare class WorkerThreadProjectRunner {
7
+ private requestInterceptors;
8
+ private project;
9
+ private messageHandler;
10
+ run(parentPort: MessagePort): void;
11
+ /**
12
+ * Fired anytime we get an `activate` request from the client. This allows us to clean up the previous project and make a new one
13
+ */
14
+ private onActivate;
15
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkerThreadProjectRunner = void 0;
4
+ const logging_1 = require("../../logging");
5
+ const Project_1 = require("../Project");
6
+ const MessageHandler_1 = require("./MessageHandler");
7
+ /**
8
+ * Runner logic for Running a Project in a worker thread.
9
+ */
10
+ class WorkerThreadProjectRunner {
11
+ constructor() {
12
+ //collection of interceptors that will be called when events are fired
13
+ this.requestInterceptors = {};
14
+ }
15
+ run(parentPort) {
16
+ //ensure the lgoger is configured for LSP mode
17
+ (0, logging_1.setLspLoggerProps)();
18
+ this.messageHandler = new MessageHandler_1.MessageHandler({
19
+ name: 'WorkerThread',
20
+ port: parentPort,
21
+ onRequest: async (request) => {
22
+ var _a, _b, _c;
23
+ try {
24
+ //if we have a request interceptor registered for this event, call it
25
+ (_b = (_a = this.requestInterceptors)[request.name]) === null || _b === void 0 ? void 0 : _b.call(_a, request.data);
26
+ //only the LspProject interface method names will be passed as request names, so just call those functions on the Project class directly
27
+ let responseData = await this.project[request.name](...(_c = request.data) !== null && _c !== void 0 ? _c : []);
28
+ this.messageHandler.sendResponse(request, { data: responseData });
29
+ //we encountered a runtime crash. Pass that error along as the response to this request
30
+ }
31
+ catch (e) {
32
+ const error = e;
33
+ this.messageHandler.sendResponse(request, { error: error });
34
+ }
35
+ },
36
+ onUpdate: (update) => {
37
+ }
38
+ });
39
+ this.requestInterceptors.activate = this.onActivate.bind(this);
40
+ }
41
+ /**
42
+ * Fired anytime we get an `activate` request from the client. This allows us to clean up the previous project and make a new one
43
+ */
44
+ onActivate() {
45
+ var _a;
46
+ //clean up any existing project
47
+ (_a = this.project) === null || _a === void 0 ? void 0 : _a.dispose();
48
+ //make a new instance of the project (which is the same way we run it in the main thread).
49
+ this.project = new Project_1.Project();
50
+ this.project.on('all', (eventName, data) => {
51
+ this.messageHandler.sendUpdate(eventName, {
52
+ data: data
53
+ });
54
+ });
55
+ }
56
+ }
57
+ exports.WorkerThreadProjectRunner = WorkerThreadProjectRunner;
58
+ //# sourceMappingURL=WorkerThreadProjectRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkerThreadProjectRunner.js","sourceRoot":"","sources":["../../../src/lsp/worker/WorkerThreadProjectRunner.ts"],"names":[],"mappings":";;;AAAA,2CAAkD;AAElD,wCAAqC;AAErC,qDAAkD;AAGlD;;GAEG;AACH,MAAa,yBAAyB;IAAtC;QACI,sEAAsE;QAC9D,wBAAmB,GAAG,EAAyD,CAAC;IAoD5F,CAAC;IA9CU,GAAG,CAAC,UAAuB;QAC9B,8CAA8C;QAC9C,IAAA,2BAAiB,GAAE,CAAC;QAEpB,IAAI,CAAC,cAAc,GAAG,IAAI,+BAAc,CAAC;YACrC,IAAI,EAAE,cAAc;YACpB,IAAI,EAAE,UAAU;YAChB,SAAS,EAAE,KAAK,EAAE,OAAsB,EAAE,EAAE;;gBACxC,IAAI;oBACA,qEAAqE;oBACrE,MAAA,MAAA,IAAI,CAAC,mBAAmB,EAAC,OAAO,CAAC,IAAI,CAAC,mDAAG,OAAO,CAAC,IAAI,CAAC,CAAC;oBAEvD,wIAAwI;oBACxI,IAAI,YAAY,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,MAAA,OAAO,CAAC,IAAI,mCAAI,EAAE,CAAC,CAAC;oBAC3E,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;oBAElE,uFAAuF;iBAC1F;gBAAC,OAAO,CAAC,EAAE;oBACR,MAAM,KAAK,GAAU,CAAQ,CAAC;oBAC9B,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;iBAC/D;YACL,CAAC;YACD,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE;YAErB,CAAC;SACJ,CAAC,CAAC;QAEH,IAAI,CAAC,mBAAmB,CAAC,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnE,CAAC;IAED;;OAEG;IACK,UAAU;;QACd,+BAA+B;QAC/B,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,EAAE,CAAC;QAExB,0FAA0F;QAC1F,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAO,EAAE,CAAC;QAE7B,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,SAAiB,EAAE,IAAS,EAAE,EAAE;YACpD,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,SAAS,EAAE;gBACtC,IAAI,EAAE,IAAI;aACb,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAtDD,8DAsDC"}
package/dist/util.d.ts CHANGED
@@ -1,6 +1,7 @@
1
+ /// <reference types="node" />
1
2
  import type { Diagnostic, Position, Range, Location } from 'vscode-languageserver';
2
3
  import type { BsConfig, FinalizedBsConfig } from './BsConfig';
3
- import type { CallableContainer, BsDiagnostic, FileReference, CallableContainerMap, CompilerPlugin, ExpressionInfo, TranspileResult } from './interfaces';
4
+ import type { CallableContainer, BsDiagnostic, FileReference, CallableContainerMap, CompilerPlugin, ExpressionInfo, TranspileResult, MaybePromise, DisposableLike } from './interfaces';
4
5
  import { BooleanType } from './types/BooleanType';
5
6
  import { DoubleType } from './types/DoubleType';
6
7
  import { DynamicType } from './types/DynamicType';
@@ -38,6 +39,12 @@ export declare class Util {
38
39
  * Determine if this path is a directory
39
40
  */
40
41
  isDirectorySync(dirPath: string | undefined): boolean;
42
+ /**
43
+ * Read a file from disk. If a failure occurrs, simply return undefined
44
+ * @param filePath path to the file
45
+ * @returns the string contents, or undefined if the file doesn't exist
46
+ */
47
+ readFileSync(filePath: string): Buffer | undefined;
41
48
  /**
42
49
  * Given a pkg path of any kind, transform it to a roku-specific pkg path (i.e. "pkg:/some/path.brs")
43
50
  */
@@ -154,10 +161,6 @@ export declare class Util {
154
161
  parseXml(text: string): Promise<any>;
155
162
  propertyCount(object: Record<string, unknown>): number;
156
163
  padLeft(subject: string, totalLength: number, char: string): string;
157
- /**
158
- * Given a URI, convert that to a regular fs path
159
- */
160
- uriToPath(uri: string): string;
161
164
  /**
162
165
  * Force the drive letter to lower case
163
166
  */
@@ -171,10 +174,18 @@ export declare class Util {
171
174
  * This considers order and compares by equality.
172
175
  */
173
176
  areArraysEqual(arr1: any[], arr2: any[]): boolean;
177
+ /**
178
+ * Does the string appear to be a uri (i.e. does it start with `file:`)
179
+ */
180
+ isUriLike(filePath: string): boolean;
174
181
  /**
175
182
  * Given a file path, convert it to a URI string
176
183
  */
177
184
  pathToUri(filePath: string): string;
185
+ /**
186
+ * Given a URI, convert that to a regular fs path
187
+ */
188
+ uriToPath(uri: string): string;
178
189
  /**
179
190
  * Get the outDir from options, taking into account cwd and absolute outFile paths
180
191
  */
@@ -380,6 +391,21 @@ export declare class Util {
380
391
  */
381
392
  rangeToString(range: Range): string;
382
393
  validateTooDeepFile(file: (BrsFile | XmlFile)): void;
394
+ /**
395
+ * Execute dispose for a series of disposable items
396
+ * @param disposables a list of functions or disposables
397
+ */
398
+ applyDispose(disposables: DisposableLike[]): void;
399
+ /**
400
+ * Race a series of promises, and return the first one that resolves AND matches the matcher function.
401
+ * If all of the promises reject, then this will emit an AggregatreError with all of the errors.
402
+ * If at least one promise resolves, then this will log all of the errors to the console
403
+ * If at least one promise resolves but none of them match the matcher, then this will return undefined.
404
+ * @param promises all of the promises to race
405
+ * @param matcher a function that should return true if this value should be kept. Returning any value other than true means `false`
406
+ * @returns the first resolved value that matches the matcher, or undefined if none of them match
407
+ */
408
+ promiseRaceMatch<T>(promises: MaybePromise<T>[], matcher: (value: T) => boolean): Promise<T>;
383
409
  /**
384
410
  * Wraps SourceNode's constructor to be compatible with the TranspileResult type
385
411
  */