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
|
@@ -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,mDAA0D;AAC1D,2EAAwE;AACxE,6CAA0C;AAG1C,6CAA0C;AAI1C,2CAA6C;AAC7C,oCAAoC;AAEvB,QAAA,UAAU,GAAG,IAAI,uBAAU,CAAC,GAAG,EAAE;IAC1C,OAAO,IAAI,uBAAM,CACb,UAAU,EACV;QACI,kEAAkE;QAClE,IAAI,EAAE,CAAC,oCAAoC,CAAC;QAC5C,6CAA6C;QAC7C,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC;YAC/B,CAAC,CAAC,CAAC,WAAW,EAAE,kBAAkB,CAAC;YACnC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,CAAC,SAAiB,EAAE,OAA+C;QACxE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,OAAc,CAAC,CAAC;QAC3C,OAAO,GAAG,EAAE;YACR,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,OAAc,CAAC,CAAC;QAC3D,CAAC,CAAC;IACN,CAAC;IAIO,KAAK,CAAC,IAAI,CAAC,SAAiB,EAAE,IAAK;QACvC,uGAAuG;QACvG,MAAM,cAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QACnC,sBAAsB;QACtB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;IAKM,OAAO;;QACV,KAAK,IAAI,UAAU,IAAI,MAAA,IAAI,CAAC,WAAW,mCAAI,EAAE,EAAE;YAC3C,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,OAAO,0DAAI,CAAC;SAC3B;QACD,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QAEtB,0DAA0D;QAC1D,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,kBAAU,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACzC;QACD,MAAA,IAAI,CAAC,OAAO,0CAAE,kBAAkB,EAAE,CAAC;IACvC,CAAC;CACJ;AA3PD,kDA2PC"}
|
|
@@ -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,gEA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C,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;IAoD5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,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"}
|
|
@@ -1345,7 +1345,8 @@ class TemplateStringExpression extends AstNode_1.Expression {
|
|
|
1345
1345
|
return StringType_1.StringType.instance;
|
|
1346
1346
|
}
|
|
1347
1347
|
transpile(state) {
|
|
1348
|
-
if
|
|
1348
|
+
//if this is essentially just a normal brightscript string but with backticks, transpile it as a normal string without parens
|
|
1349
|
+
if (this.expressions.length === 0 && this.quasis.length === 1 && this.quasis[0].expressions.length === 1) {
|
|
1349
1350
|
return this.quasis[0].transpile(state);
|
|
1350
1351
|
}
|
|
1351
1352
|
let result = ['('];
|
|
@@ -1739,7 +1740,11 @@ class TypeExpression extends AstNode_1.Expression {
|
|
|
1739
1740
|
this.location = util_1.default.cloneLocation((_a = this.expression) === null || _a === void 0 ? void 0 : _a.location);
|
|
1740
1741
|
}
|
|
1741
1742
|
transpile(state) {
|
|
1742
|
-
|
|
1743
|
+
const exprType = this.getType({ flags: 2 /* SymbolTypeFlag.typetime */ });
|
|
1744
|
+
if ((0, reflection_1.isNativeType)(exprType)) {
|
|
1745
|
+
return this.expression.transpile(state);
|
|
1746
|
+
}
|
|
1747
|
+
return [exprType.toTypeString()];
|
|
1743
1748
|
}
|
|
1744
1749
|
walk(visitor, options) {
|
|
1745
1750
|
if (options.walkMode & visitors_2.InternalWalkMode.walkExpressions) {
|