brighterscript 0.68.5 → 0.69.1

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 +13 -6
  20. package/dist/ProgramBuilder.js +25 -15
  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 +183 -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 +32 -5
  112. package/dist/util.js +117 -19
  113. package/dist/util.js.map +1 -1
  114. package/package.json +13 -3
@@ -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,183 @@
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
+ //this needs to align with the same flag in the if statement below
17
+ argv: ['--run-worker-thread-project-runner'],
18
+ //wire up ts-node if we're running in ts-node
19
+ execArgv: /\.ts$/i.test(__filename)
20
+ ? ['--require', 'ts-node/register']
21
+ /* istanbul ignore next */
22
+ : undefined
23
+ });
24
+ });
25
+ //if this script is running in a Worker, start the project runner
26
+ /* istanbul ignore next */
27
+ if (!worker_threads_2.isMainThread && process.argv.includes('--run-worker-thread-project-runner')) {
28
+ const runner = new WorkerThreadProjectRunner_1.WorkerThreadProjectRunner();
29
+ runner.run(worker_threads_2.parentPort);
30
+ }
31
+ class WorkerThreadProject {
32
+ constructor(options) {
33
+ var _a, _b;
34
+ this.isStandaloneProject = false;
35
+ this.activationDeferred = new deferred_1.Deferred();
36
+ this.emitter = new EventEmitter();
37
+ this.disposables = [];
38
+ this.logger = (_a = options === null || options === void 0 ? void 0 : options.logger) !== null && _a !== void 0 ? _a : (0, logging_1.createLogger)();
39
+ this.projectIdentifier = (_b = options === null || options === void 0 ? void 0 : options.projectIdentifier) !== null && _b !== void 0 ? _b : '';
40
+ }
41
+ async activate(options) {
42
+ this.activateOptions = options;
43
+ this.projectPath = options.projectPath ? util_1.default.standardizePath(options.projectPath) : options.projectPath;
44
+ this.workspaceFolder = options.workspaceFolder ? util_1.default.standardizePath(options.workspaceFolder) : options.workspaceFolder;
45
+ this.projectNumber = options.projectNumber;
46
+ this.bsconfigPath = options.bsconfigPath ? util_1.default.standardizePath(options.bsconfigPath) : options.bsconfigPath;
47
+ // start a new worker thread or get an unused existing thread
48
+ this.worker = exports.workerPool.getWorker();
49
+ this.messageHandler = new MessageHandler_1.MessageHandler({
50
+ name: 'MainThread',
51
+ port: this.worker,
52
+ onRequest: this.processRequest.bind(this),
53
+ onUpdate: this.processUpdate.bind(this)
54
+ });
55
+ this.disposables.push(this.messageHandler);
56
+ const activateResponse = await this.messageHandler.sendRequest('activate', { data: [options] });
57
+ this.bsconfigPath = activateResponse.data.bsconfigPath;
58
+ this.rootDir = activateResponse.data.rootDir;
59
+ this.filePatterns = activateResponse.data.filePatterns;
60
+ this.logger.logLevel = activateResponse.data.logLevel;
61
+ //load the bsconfig file contents (used for performance optimizations externally)
62
+ try {
63
+ this.bsconfigFileContents = (await fsExtra.readFile(this.bsconfigPath)).toString();
64
+ }
65
+ catch (_a) { }
66
+ this.activationDeferred.resolve();
67
+ return activateResponse.data;
68
+ }
69
+ /**
70
+ * Promise that resolves when the project finishes activating
71
+ * @returns a promise that resolves when the project finishes activating
72
+ */
73
+ whenActivated() {
74
+ return this.activationDeferred.promise;
75
+ }
76
+ /**
77
+ * Validate the project. This will trigger a full validation on any scopes that were changed since the last validation,
78
+ * and will also eventually emit a new 'diagnostics' event that includes all diagnostics for the project
79
+ */
80
+ async validate() {
81
+ const response = await this.messageHandler.sendRequest('validate');
82
+ return response.data;
83
+ }
84
+ /**
85
+ * Cancel any active validation that's running
86
+ */
87
+ async cancelValidate() {
88
+ const response = await this.messageHandler.sendRequest('cancelValidate');
89
+ return response.data;
90
+ }
91
+ async getDiagnostics() {
92
+ const response = await this.messageHandler.sendRequest('getDiagnostics');
93
+ return response.data;
94
+ }
95
+ /**
96
+ * 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
97
+ * during the program's lifecycle flow
98
+ */
99
+ async applyFileChanges(documentActions) {
100
+ const response = await this.messageHandler.sendRequest('applyFileChanges', {
101
+ data: [documentActions]
102
+ });
103
+ return response.data;
104
+ }
105
+ /**
106
+ * Send a request with the standard structure
107
+ * @param name the name of the request
108
+ * @param data the array of data to send
109
+ * @returns the response from the request
110
+ */
111
+ async sendStandardRequest(name, ...data) {
112
+ const response = await this.messageHandler.sendRequest(name, {
113
+ data: data
114
+ });
115
+ return response.data;
116
+ }
117
+ /**
118
+ * Get the full list of semantic tokens for the given file path
119
+ */
120
+ async getSemanticTokens(options) {
121
+ return this.sendStandardRequest('getSemanticTokens', options);
122
+ }
123
+ async transpileFile(options) {
124
+ return this.sendStandardRequest('transpileFile', options);
125
+ }
126
+ async getHover(options) {
127
+ return this.sendStandardRequest('getHover', options);
128
+ }
129
+ async getDefinition(options) {
130
+ return this.sendStandardRequest('getDefinition', options);
131
+ }
132
+ async getSignatureHelp(options) {
133
+ return this.sendStandardRequest('getSignatureHelp', options);
134
+ }
135
+ async getDocumentSymbol(options) {
136
+ return this.sendStandardRequest('getDocumentSymbol', options);
137
+ }
138
+ async getWorkspaceSymbol() {
139
+ return this.sendStandardRequest('getWorkspaceSymbol');
140
+ }
141
+ async getReferences(options) {
142
+ return this.sendStandardRequest('getReferences', options);
143
+ }
144
+ async getCodeActions(options) {
145
+ return this.sendStandardRequest('getCodeActions', options);
146
+ }
147
+ async getCompletions(options) {
148
+ return this.sendStandardRequest('getCompletions', options);
149
+ }
150
+ processRequest(request) {
151
+ }
152
+ processUpdate(update) {
153
+ //for now, all updates are treated like "events"
154
+ this.emit(update.name, update.data);
155
+ }
156
+ on(eventName, handler) {
157
+ this.emitter.on(eventName, handler);
158
+ return () => {
159
+ this.emitter.removeListener(eventName, handler);
160
+ };
161
+ }
162
+ async emit(eventName, data) {
163
+ //emit these events on next tick, otherwise they will be processed immediately which could cause issues
164
+ await util_1.default.sleep(0);
165
+ this.emitter.emit(eventName, data);
166
+ //emit the 'all' event
167
+ this.emitter.emit('all', eventName, data);
168
+ }
169
+ dispose() {
170
+ var _a, _b, _c;
171
+ for (let disposable of (_a = this.disposables) !== null && _a !== void 0 ? _a : []) {
172
+ (_b = disposable === null || disposable === void 0 ? void 0 : disposable.dispose) === null || _b === void 0 ? void 0 : _b.call(disposable);
173
+ }
174
+ this.disposables = [];
175
+ //move the worker back to the pool so it can be used again
176
+ if (this.worker) {
177
+ exports.workerPool.releaseWorker(this.worker);
178
+ }
179
+ (_c = this.emitter) === null || _c === void 0 ? void 0 : _c.removeAllListeners();
180
+ }
181
+ }
182
+ exports.WorkerThreadProject = WorkerThreadProject;
183
+ //# 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,mDA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AC,OAAO,0CAAE,kBAAkB,EAAE,CAAC;IACvC,CAAC;CACJ;AA3PD,kDA2PC"}
@@ -0,0 +1,2 @@
1
+ export declare function wakeWorkerThread(): Promise<void>;
2
+ export declare function getWakeWorkerThreadPromise(): Promise<any>;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ 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,EA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 -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,8 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
1
3
  import type { Diagnostic, Position, Range, Location } from 'vscode-languageserver';
2
4
  import type { BsConfig, FinalizedBsConfig } from './BsConfig';
3
- import type { CallableContainer, BsDiagnostic, FileReference, CallableContainerMap, CompilerPlugin, ExpressionInfo, TranspileResult } from './interfaces';
5
+ import type { CallableContainer, BsDiagnostic, FileReference, CallableContainerMap, CompilerPlugin, ExpressionInfo, TranspileResult, MaybePromise, DisposableLike } from './interfaces';
4
6
  import { BooleanType } from './types/BooleanType';
5
7
  import { DoubleType } from './types/DoubleType';
6
8
  import { DynamicType } from './types/DynamicType';
@@ -38,6 +40,12 @@ export declare class Util {
38
40
  * Determine if this path is a directory
39
41
  */
40
42
  isDirectorySync(dirPath: string | undefined): boolean;
43
+ /**
44
+ * Read a file from disk. If a failure occurrs, simply return undefined
45
+ * @param filePath path to the file
46
+ * @returns the string contents, or undefined if the file doesn't exist
47
+ */
48
+ readFileSync(filePath: string): Buffer | undefined;
41
49
  /**
42
50
  * Given a pkg path of any kind, transform it to a roku-specific pkg path (i.e. "pkg:/some/path.brs")
43
51
  */
@@ -154,10 +162,6 @@ export declare class Util {
154
162
  parseXml(text: string): Promise<any>;
155
163
  propertyCount(object: Record<string, unknown>): number;
156
164
  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
165
  /**
162
166
  * Force the drive letter to lower case
163
167
  */
@@ -171,10 +175,18 @@ export declare class Util {
171
175
  * This considers order and compares by equality.
172
176
  */
173
177
  areArraysEqual(arr1: any[], arr2: any[]): boolean;
178
+ /**
179
+ * Does the string appear to be a uri (i.e. does it start with `file:`)
180
+ */
181
+ isUriLike(filePath: string): boolean;
174
182
  /**
175
183
  * Given a file path, convert it to a URI string
176
184
  */
177
185
  pathToUri(filePath: string): string;
186
+ /**
187
+ * Given a URI, convert that to a regular fs path
188
+ */
189
+ uriToPath(uri: string): string;
178
190
  /**
179
191
  * Get the outDir from options, taking into account cwd and absolute outFile paths
180
192
  */
@@ -380,6 +392,21 @@ export declare class Util {
380
392
  */
381
393
  rangeToString(range: Range): string;
382
394
  validateTooDeepFile(file: (BrsFile | XmlFile)): void;
395
+ /**
396
+ * Execute dispose for a series of disposable items
397
+ * @param disposables a list of functions or disposables
398
+ */
399
+ applyDispose(disposables: DisposableLike[]): void;
400
+ /**
401
+ * Race a series of promises, and return the first one that resolves AND matches the matcher function.
402
+ * If all of the promises reject, then this will emit an AggregatreError with all of the errors.
403
+ * If at least one promise resolves, then this will log all of the errors to the console
404
+ * If at least one promise resolves but none of them match the matcher, then this will return undefined.
405
+ * @param promises all of the promises to race
406
+ * @param matcher a function that should return true if this value should be kept. Returning any value other than true means `false`
407
+ * @returns the first resolved value that matches the matcher, or undefined if none of them match
408
+ */
409
+ promiseRaceMatch<T>(promises: MaybePromise<T>[], matcher: (value: T) => boolean): Promise<T>;
383
410
  /**
384
411
  * Wraps SourceNode's constructor to be compatible with the TranspileResult type
385
412
  */