brighterscript 1.0.0-alpha.43 → 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 +69 -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 -133
- package/dist/LanguageServer.js +403 -942
- 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/SymbolTable.js +4 -3
- package/dist/SymbolTable.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,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
const testHelpers_spec_1 = require("../testHelpers.spec");
|
|
5
|
+
const fsExtra = require("fs-extra");
|
|
6
|
+
const util_1 = require("../util");
|
|
7
|
+
const deferred_1 = require("../deferred");
|
|
8
|
+
const DiagnosticMessages_1 = require("../DiagnosticMessages");
|
|
9
|
+
const Project_1 = require("./Project");
|
|
10
|
+
const sinon_1 = require("sinon");
|
|
11
|
+
const Scope_1 = require("../Scope");
|
|
12
|
+
const sinon = (0, sinon_1.createSandbox)();
|
|
13
|
+
describe('Project', () => {
|
|
14
|
+
let project;
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
sinon.restore();
|
|
17
|
+
project = new Project_1.Project();
|
|
18
|
+
fsExtra.emptyDirSync(testHelpers_spec_1.tempDir);
|
|
19
|
+
});
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
sinon.restore();
|
|
22
|
+
fsExtra.emptyDirSync(testHelpers_spec_1.tempDir);
|
|
23
|
+
project.dispose();
|
|
24
|
+
});
|
|
25
|
+
describe('on', () => {
|
|
26
|
+
it('emits events', async () => {
|
|
27
|
+
const stub = sinon.stub();
|
|
28
|
+
const off = project.on('diagnostics', stub);
|
|
29
|
+
await project['emit']('diagnostics', { diagnostics: [] });
|
|
30
|
+
(0, chai_1.expect)(stub.callCount).to.eql(1);
|
|
31
|
+
await project['emit']('diagnostics', { diagnostics: [] });
|
|
32
|
+
(0, chai_1.expect)(stub.callCount).to.eql(2);
|
|
33
|
+
off();
|
|
34
|
+
await project['emit']('diagnostics', { diagnostics: [] });
|
|
35
|
+
(0, chai_1.expect)(stub.callCount).to.eql(2);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
describe('validate', () => {
|
|
39
|
+
it('prevents multiple valiations from running at the same time', async () => {
|
|
40
|
+
//create 10 scopes, which should each take at least 1ms to validate
|
|
41
|
+
for (let i = 0; i < 20; i++) {
|
|
42
|
+
fsExtra.outputFileSync(`${testHelpers_spec_1.rootDir}/components/component${i}.xml`, `<component name="component${i}"></component>`);
|
|
43
|
+
}
|
|
44
|
+
await project.activate({
|
|
45
|
+
projectPath: testHelpers_spec_1.rootDir,
|
|
46
|
+
workspaceFolder: testHelpers_spec_1.rootDir,
|
|
47
|
+
enableThreading: false
|
|
48
|
+
});
|
|
49
|
+
//wait for the first validate to finish
|
|
50
|
+
await new Promise((resolve) => {
|
|
51
|
+
const off = project.on('validate-end', () => {
|
|
52
|
+
off();
|
|
53
|
+
resolve();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
let validationCount = 0;
|
|
57
|
+
let maxValidationCount = 0;
|
|
58
|
+
//force validation cycles to yield very frequently
|
|
59
|
+
project['builder'].program['validationMinSyncDuration'] = 0.001;
|
|
60
|
+
project['builder'].program.plugins.add({
|
|
61
|
+
name: 'Test',
|
|
62
|
+
beforeProgramValidate: () => {
|
|
63
|
+
validationCount++;
|
|
64
|
+
maxValidationCount = Math.max(maxValidationCount, validationCount);
|
|
65
|
+
},
|
|
66
|
+
afterProgramValidate: () => {
|
|
67
|
+
validationCount--;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
//very small threshold so every validation step will yield
|
|
71
|
+
project['builder'].program['validationMinSyncDuration'] = 0.001;
|
|
72
|
+
sinon.stub(Scope_1.Scope.prototype, 'validate').callsFake(() => {
|
|
73
|
+
//each of these needs to take about 1ms to complete
|
|
74
|
+
const startTime = Date.now();
|
|
75
|
+
while (Date.now() - startTime < 2) { }
|
|
76
|
+
return true;
|
|
77
|
+
});
|
|
78
|
+
//validate 3 times in quick succession
|
|
79
|
+
await Promise.all([
|
|
80
|
+
project.validate(),
|
|
81
|
+
project.validate(),
|
|
82
|
+
project.validate()
|
|
83
|
+
]);
|
|
84
|
+
(0, chai_1.expect)(validationCount).to.eql(0);
|
|
85
|
+
(0, chai_1.expect)(maxValidationCount).to.eql(1);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
describe('activate', () => {
|
|
89
|
+
it('uses `files` from bsconfig.json', async () => {
|
|
90
|
+
fsExtra.outputJsonSync(`${testHelpers_spec_1.rootDir}/bsconfig.json`, {
|
|
91
|
+
rootDir: testHelpers_spec_1.rootDir,
|
|
92
|
+
files: [{
|
|
93
|
+
src: (0, util_1.standardizePath) `${testHelpers_spec_1.tempDir}/lib1.brs`,
|
|
94
|
+
dest: 'source/lib1.brs'
|
|
95
|
+
}]
|
|
96
|
+
});
|
|
97
|
+
fsExtra.outputFileSync(`${testHelpers_spec_1.tempDir}/lib1.brs`, `
|
|
98
|
+
sub main()
|
|
99
|
+
print alpha 'this var doesn't exist
|
|
100
|
+
end sub
|
|
101
|
+
`);
|
|
102
|
+
await project.activate({
|
|
103
|
+
projectPath: testHelpers_spec_1.rootDir
|
|
104
|
+
});
|
|
105
|
+
await (0, testHelpers_spec_1.once)(project, 'diagnostics');
|
|
106
|
+
(0, testHelpers_spec_1.expectDiagnostics)(project, [
|
|
107
|
+
DiagnosticMessages_1.DiagnosticMessages.cannotFindName('alpha').message
|
|
108
|
+
]);
|
|
109
|
+
});
|
|
110
|
+
it('prevents creating package on first run', async () => {
|
|
111
|
+
await project.activate({
|
|
112
|
+
projectPath: testHelpers_spec_1.rootDir
|
|
113
|
+
});
|
|
114
|
+
(0, chai_1.expect)(project['builder'].program.options.copyToStaging).to.be.false;
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
describe('applyFileChanges', () => {
|
|
118
|
+
it('skips setting the file if the contents have not changed', async () => {
|
|
119
|
+
await project.activate({ projectPath: testHelpers_spec_1.rootDir });
|
|
120
|
+
//initial set should be true
|
|
121
|
+
(0, chai_1.expect)((await project.applyFileChanges([{
|
|
122
|
+
fileContents: 'sub main:end sub',
|
|
123
|
+
srcPath: (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/source/main.brs`,
|
|
124
|
+
type: 'set'
|
|
125
|
+
}]))[0].status).to.eql('accepted');
|
|
126
|
+
//contents haven't changed, this should be false
|
|
127
|
+
(0, chai_1.expect)((await project.applyFileChanges([{
|
|
128
|
+
fileContents: 'sub main:end sub',
|
|
129
|
+
srcPath: (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/source/main.brs`,
|
|
130
|
+
type: 'set'
|
|
131
|
+
}]))[0].status).to.eql('accepted');
|
|
132
|
+
//contents changed again, should be true
|
|
133
|
+
(0, chai_1.expect)((await project.applyFileChanges([{
|
|
134
|
+
fileContents: 'sub main2:end sub',
|
|
135
|
+
srcPath: (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/source/main.brs`,
|
|
136
|
+
type: 'set'
|
|
137
|
+
}]))[0].status).to.eql('accepted');
|
|
138
|
+
});
|
|
139
|
+
it('always includes a status', async () => {
|
|
140
|
+
await project.activate({
|
|
141
|
+
projectPath: testHelpers_spec_1.rootDir
|
|
142
|
+
});
|
|
143
|
+
project['builder'].options.files = [
|
|
144
|
+
'source/**/*',
|
|
145
|
+
'!source/**/*.spec.bs'
|
|
146
|
+
];
|
|
147
|
+
//set file that maches files array
|
|
148
|
+
(0, chai_1.expect)((await project['applyFileChanges']([{
|
|
149
|
+
fileContents: '',
|
|
150
|
+
srcPath: (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/source/main.bs`,
|
|
151
|
+
type: 'set'
|
|
152
|
+
}]))[0].status).to.eql('accepted');
|
|
153
|
+
//delete this file that matches a file in the program
|
|
154
|
+
(0, chai_1.expect)((await project['applyFileChanges']([{
|
|
155
|
+
srcPath: (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/source/main.bs`,
|
|
156
|
+
type: 'delete'
|
|
157
|
+
}]))[0].status).to.eql('accepted');
|
|
158
|
+
//set file that does not match files array files array
|
|
159
|
+
(0, chai_1.expect)((await project['applyFileChanges']([{
|
|
160
|
+
fileContents: '',
|
|
161
|
+
srcPath: (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/source/main.spec.bs`,
|
|
162
|
+
type: 'set'
|
|
163
|
+
}]))[0].status).to.eql('rejected');
|
|
164
|
+
//delete directory is "reject" because those should be unraveled into individual files on the outside
|
|
165
|
+
(0, chai_1.expect)((await project['applyFileChanges']([{
|
|
166
|
+
srcPath: (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/source`,
|
|
167
|
+
type: 'delete'
|
|
168
|
+
}]))[0].status).to.eql('rejected');
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
describe('activate', () => {
|
|
172
|
+
it('finds bsconfig.json at root', async () => {
|
|
173
|
+
fsExtra.outputFileSync(`${testHelpers_spec_1.rootDir}/bsconfig.json`, '');
|
|
174
|
+
await project.activate({
|
|
175
|
+
projectPath: testHelpers_spec_1.rootDir
|
|
176
|
+
});
|
|
177
|
+
(0, chai_1.expect)(project.bsconfigPath).to.eql((0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/bsconfig.json`);
|
|
178
|
+
});
|
|
179
|
+
it('produces diagnostics after running', async () => {
|
|
180
|
+
fsExtra.outputFileSync(`${testHelpers_spec_1.rootDir}/source/main.brs`, `
|
|
181
|
+
sub main()
|
|
182
|
+
print varNotThere
|
|
183
|
+
end sub
|
|
184
|
+
`);
|
|
185
|
+
await project.activate({
|
|
186
|
+
projectPath: testHelpers_spec_1.rootDir
|
|
187
|
+
});
|
|
188
|
+
await (0, testHelpers_spec_1.once)(project, 'diagnostics');
|
|
189
|
+
await (0, testHelpers_spec_1.expectDiagnosticsAsync)(project, [
|
|
190
|
+
DiagnosticMessages_1.DiagnosticMessages.cannotFindName('varNotThere').message
|
|
191
|
+
]);
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
describe('createProject', () => {
|
|
195
|
+
it('uses given projectNumber', async () => {
|
|
196
|
+
await project.activate({
|
|
197
|
+
projectPath: testHelpers_spec_1.rootDir,
|
|
198
|
+
projectNumber: 123
|
|
199
|
+
});
|
|
200
|
+
(0, chai_1.expect)(project.projectNumber).to.eql(123);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
describe('getConfigPath', () => {
|
|
204
|
+
it('emits critical failure for missing file', async () => {
|
|
205
|
+
const deferred = new deferred_1.Deferred();
|
|
206
|
+
project.on('critical-failure', (event) => {
|
|
207
|
+
deferred.resolve(event.message);
|
|
208
|
+
});
|
|
209
|
+
await project['getConfigFilePath']({
|
|
210
|
+
projectPath: testHelpers_spec_1.rootDir,
|
|
211
|
+
configFilePath: (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/bsconfig.json`
|
|
212
|
+
});
|
|
213
|
+
(0, chai_1.expect)((await deferred.promise).startsWith('Cannot find config file')).to.be.true;
|
|
214
|
+
});
|
|
215
|
+
it('does not crash on undefined', async () => {
|
|
216
|
+
await project['getConfigFilePath'](undefined);
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
//# sourceMappingURL=Project.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Project.spec.js","sourceRoot":"","sources":["../../src/lsp/Project.spec.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAC9B,0DAAwG;AACxG,oCAAoC;AACpC,kCAA+C;AAC/C,0CAAuC;AACvC,8DAA2D;AAC3D,uCAAoC;AACpC,iCAAsC;AACtC,oCAAiC;AACjC,MAAM,KAAK,GAAG,IAAA,qBAAa,GAAE,CAAC;AAE9B,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACrB,IAAI,OAAgB,CAAC;IAErB,UAAU,CAAC,GAAG,EAAE;QACZ,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,OAAO,GAAG,IAAI,iBAAO,EAAE,CAAC;QACxB,OAAO,CAAC,YAAY,CAAC,0BAAO,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACX,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,OAAO,CAAC,YAAY,CAAC,0BAAO,CAAC,CAAC;QAC9B,OAAO,CAAC,OAAO,EAAE,CAAC;IAC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AO,CAAC,QAAQ,CAAC;gBACnB,WAAW,EAAE,0BAAO;gBACpB,aAAa,EAAE,GAAG;aACd,CAAC,CAAC;YACV,IAAA,aAAM,EAAC,OAAO,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC3B,EAAE,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;YACrD,MAAM,QAAQ,GAAG,IAAI,mBAAQ,EAAU,CAAC;YACxC,OAAO,CAAC,EAAE,CAAC,kBAAkB,EAAE,CAAC,KAAK,EAAE,EAAE;gBACrC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACpC,CAAC,CAAC,CAAC;YACH,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC;gBAC/B,WAAW,EAAE,0BAAO;gBACpB,cAAc,EAAE,IAAA,sBAAC,EAAA,GAAG,0BAAO,gBAAgB;aAC9C,CAAC,CAAC;YACH,IAAA,aAAM,EACF,CAAC,MAAM,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,yBAAyB,CAAC,CACjE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACjB,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;YACzC,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import type { LspDiagnostic, LspProject } from './LspProject';
|
|
2
|
+
import type { Hover, Position, Range, Location, SignatureHelp, DocumentSymbol, WorkspaceSymbol, CompletionList, CancellationToken } from 'vscode-languageserver-protocol';
|
|
3
|
+
import type { FileChange, MaybePromise } from '../interfaces';
|
|
4
|
+
import { BusyStatusTracker } from '../BusyStatusTracker';
|
|
5
|
+
import { PathFilterer } from './PathFilterer';
|
|
6
|
+
import type { Logger } from '../logging';
|
|
7
|
+
/**
|
|
8
|
+
* Manages all brighterscript projects for the language server
|
|
9
|
+
*/
|
|
10
|
+
export declare class ProjectManager {
|
|
11
|
+
constructor(options?: {
|
|
12
|
+
pathFilterer: PathFilterer;
|
|
13
|
+
logger?: Logger;
|
|
14
|
+
});
|
|
15
|
+
private pathFilterer;
|
|
16
|
+
private logger;
|
|
17
|
+
/**
|
|
18
|
+
* Collection of all projects
|
|
19
|
+
*/
|
|
20
|
+
projects: LspProject[];
|
|
21
|
+
/**
|
|
22
|
+
* Collection of standalone projects. These are projects that are not part of a workspace, but are instead single files.
|
|
23
|
+
* All of these are also present in the `projects` collection.
|
|
24
|
+
*/
|
|
25
|
+
private standaloneProjects;
|
|
26
|
+
private documentManager;
|
|
27
|
+
static documentManagerDelay: number;
|
|
28
|
+
busyStatusTracker: BusyStatusTracker<LspProject>;
|
|
29
|
+
/**
|
|
30
|
+
* Apply all of the queued document changes. This should only be called as a result of the documentManager flushing changes, and never called manually
|
|
31
|
+
* @param event the document changes that have occurred since the last time we applied
|
|
32
|
+
*/
|
|
33
|
+
private flushDocumentChanges;
|
|
34
|
+
/**
|
|
35
|
+
* Get a standalone project for a given file path
|
|
36
|
+
*/
|
|
37
|
+
private getStandaloneProject;
|
|
38
|
+
/**
|
|
39
|
+
* Create a project that validates a single file. This is useful for getting language support for files that don't belong to a project
|
|
40
|
+
*/
|
|
41
|
+
private createStandaloneProject;
|
|
42
|
+
private removeStandaloneProject;
|
|
43
|
+
/**
|
|
44
|
+
* A promise that's set when a sync starts, and resolved when the sync is complete
|
|
45
|
+
*/
|
|
46
|
+
private syncPromise;
|
|
47
|
+
private firstSync;
|
|
48
|
+
/**
|
|
49
|
+
* Get a promise that resolves when this manager is finished initializing
|
|
50
|
+
*/
|
|
51
|
+
onInitialized(): Promise<[PromiseSettledResult<void>, PromiseSettledResult<void>, ...PromiseSettledResult<void>[]]>;
|
|
52
|
+
/**
|
|
53
|
+
* Get a promise that resolves when the project manager is idle (no pending work)
|
|
54
|
+
*/
|
|
55
|
+
onIdle(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Given a list of all desired projects, create any missing projects and destroy and projects that are no longer available
|
|
58
|
+
* Treat workspaces that don't have a bsconfig.json as a project.
|
|
59
|
+
* Handle situations where bsconfig.json files were added or removed (to elevate/lower workspaceFolder projects accordingly)
|
|
60
|
+
* Leave existing projects alone if they are not affected by these changes
|
|
61
|
+
* @param workspaceConfigs an array of workspaces
|
|
62
|
+
*/
|
|
63
|
+
syncProjects(workspaceConfigs: WorkspaceConfig[], forceReload?: boolean): Promise<void>;
|
|
64
|
+
private fileChangesQueue;
|
|
65
|
+
handleFileChanges(changes: FileChange[]): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Handle when files or directories are added, changed, or deleted in the workspace.
|
|
68
|
+
* This is safe to call any time. Changes will be queued and flushed at the correct times
|
|
69
|
+
*/
|
|
70
|
+
private _handleFileChanges;
|
|
71
|
+
/**
|
|
72
|
+
* Handle a single file change. If the file is a directory, this will recursively read all files in the directory and call `handleFileChanges` again
|
|
73
|
+
*/
|
|
74
|
+
private handleFileChange;
|
|
75
|
+
/**
|
|
76
|
+
* Handle when a file is closed in the editor (this mostly just handles removing standalone projects)
|
|
77
|
+
*/
|
|
78
|
+
handleFileClose(event: {
|
|
79
|
+
srcPath: string;
|
|
80
|
+
}): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Given a project, forcibly reload it by removing it and re-adding it
|
|
83
|
+
*/
|
|
84
|
+
private reloadProject;
|
|
85
|
+
/**
|
|
86
|
+
* Get all the semantic tokens for the given file
|
|
87
|
+
* @returns an array of semantic tokens
|
|
88
|
+
*/
|
|
89
|
+
getSemanticTokens(options: {
|
|
90
|
+
srcPath: string;
|
|
91
|
+
}): Promise<import("../interfaces").SemanticToken[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Get a string containing the transpiled contents of the file at the given path
|
|
94
|
+
* @returns the transpiled contents of the file as a string
|
|
95
|
+
*/
|
|
96
|
+
transpileFile(options: {
|
|
97
|
+
srcPath: string;
|
|
98
|
+
}): Promise<import("..").FileTranspileResult>;
|
|
99
|
+
/**
|
|
100
|
+
* Get the completions for the given position in the file
|
|
101
|
+
*/
|
|
102
|
+
getCompletions(options: {
|
|
103
|
+
srcPath: string;
|
|
104
|
+
position: Position;
|
|
105
|
+
cancellationToken?: CancellationToken;
|
|
106
|
+
}): Promise<CompletionList>;
|
|
107
|
+
/**
|
|
108
|
+
* Get the hover information for the given position in the file. If multiple projects have hover information, the projects will be raced and
|
|
109
|
+
* the fastest result will be returned
|
|
110
|
+
* @returns the hover information or undefined if no hover information was found
|
|
111
|
+
*/
|
|
112
|
+
getHover(options: {
|
|
113
|
+
srcPath: string;
|
|
114
|
+
position: Position;
|
|
115
|
+
}): Promise<Hover>;
|
|
116
|
+
/**
|
|
117
|
+
* Get the definition for the symbol at the given position in the file
|
|
118
|
+
* @returns a list of locations where the symbol under the position is defined in the project
|
|
119
|
+
*/
|
|
120
|
+
getDefinition(options: {
|
|
121
|
+
srcPath: string;
|
|
122
|
+
position: Position;
|
|
123
|
+
}): Promise<Location[]>;
|
|
124
|
+
getSignatureHelp(options: {
|
|
125
|
+
srcPath: string;
|
|
126
|
+
position: Position;
|
|
127
|
+
}): Promise<SignatureHelp>;
|
|
128
|
+
getDocumentSymbol(options: {
|
|
129
|
+
srcPath: string;
|
|
130
|
+
}): Promise<DocumentSymbol[]>;
|
|
131
|
+
getWorkspaceSymbol(): Promise<WorkspaceSymbol[]>;
|
|
132
|
+
getReferences(options: {
|
|
133
|
+
srcPath: string;
|
|
134
|
+
position: Position;
|
|
135
|
+
}): Promise<Location[]>;
|
|
136
|
+
getCodeActions(options: {
|
|
137
|
+
srcPath: string;
|
|
138
|
+
range: Range;
|
|
139
|
+
}): Promise<import("vscode-languageserver-types").CodeAction[]>;
|
|
140
|
+
/**
|
|
141
|
+
* Scan a given workspace for all `bsconfig.json` files. If at least one is found, then only folders who have bsconfig.json are returned.
|
|
142
|
+
* If none are found, then the workspaceFolder itself is treated as a project
|
|
143
|
+
*/
|
|
144
|
+
private getProjectPaths;
|
|
145
|
+
/**
|
|
146
|
+
* Returns true if we have this project, or false if we don't
|
|
147
|
+
* @param projectPath path to the project
|
|
148
|
+
* @returns true if the project exists, or false if it doesn't
|
|
149
|
+
*/
|
|
150
|
+
private hasProject;
|
|
151
|
+
/**
|
|
152
|
+
* Get a project with the specified path
|
|
153
|
+
* @param param path to the project or an obj that has `projectPath` prop
|
|
154
|
+
* @returns a project, or undefined if no project was found
|
|
155
|
+
*/
|
|
156
|
+
private getProject;
|
|
157
|
+
/**
|
|
158
|
+
* Remove a project from the language server
|
|
159
|
+
*/
|
|
160
|
+
private removeProject;
|
|
161
|
+
/**
|
|
162
|
+
* A unique project counter to help distinguish log entries in lsp mode
|
|
163
|
+
*/
|
|
164
|
+
private static projectNumberSequence;
|
|
165
|
+
private static projectNumberCache;
|
|
166
|
+
/**
|
|
167
|
+
* Get a projectNumber for a given config. Try to reuse project numbers when we've seen this project before
|
|
168
|
+
* - If the config already has one, use that.
|
|
169
|
+
* - If we've already seen this config before, use the same project number as before
|
|
170
|
+
*/
|
|
171
|
+
private getProjectNumber;
|
|
172
|
+
/**
|
|
173
|
+
* Constructs a project for the given config. Just makes the project, doesn't activate it
|
|
174
|
+
* @returns a new project, or the existing project if one already exists with this config info
|
|
175
|
+
*/
|
|
176
|
+
private constructProject;
|
|
177
|
+
/**
|
|
178
|
+
* Constructs a project for the given config
|
|
179
|
+
* @returns a new project, or the existing project if one already exists with this config info
|
|
180
|
+
*/
|
|
181
|
+
private createAndActivateProject;
|
|
182
|
+
private activateProject;
|
|
183
|
+
on(eventName: 'validate-begin', handler: (data: {
|
|
184
|
+
project: LspProject;
|
|
185
|
+
}) => MaybePromise<void>): any;
|
|
186
|
+
on(eventName: 'validate-end', handler: (data: {
|
|
187
|
+
project: LspProject;
|
|
188
|
+
}) => MaybePromise<void>): any;
|
|
189
|
+
on(eventName: 'critical-failure', handler: (data: {
|
|
190
|
+
project: LspProject;
|
|
191
|
+
message: string;
|
|
192
|
+
}) => MaybePromise<void>): any;
|
|
193
|
+
on(eventName: 'project-activate', handler: (data: {
|
|
194
|
+
project: LspProject;
|
|
195
|
+
}) => MaybePromise<void>): any;
|
|
196
|
+
on(eventName: 'diagnostics', handler: (data: {
|
|
197
|
+
project: LspProject;
|
|
198
|
+
diagnostics: LspDiagnostic[];
|
|
199
|
+
}) => MaybePromise<void>): any;
|
|
200
|
+
private emit;
|
|
201
|
+
private emitter;
|
|
202
|
+
dispose(): void;
|
|
203
|
+
}
|
|
204
|
+
export interface WorkspaceConfig {
|
|
205
|
+
/**
|
|
206
|
+
* Absolute path to the folder where the workspace resides
|
|
207
|
+
*/
|
|
208
|
+
workspaceFolder: string;
|
|
209
|
+
/**
|
|
210
|
+
* A list of glob patterns used to _exclude_ files from various bsconfig searches
|
|
211
|
+
*/
|
|
212
|
+
excludePatterns?: string[];
|
|
213
|
+
/**
|
|
214
|
+
* Path to a bsconfig that should be used instead of the auto-discovery algorithm. If this is present, no bsconfig discovery should be used. and an error should be emitted if this file is missing
|
|
215
|
+
*/
|
|
216
|
+
bsconfigPath?: string;
|
|
217
|
+
/**
|
|
218
|
+
* Should the projects in this workspace be run in their own dedicated worker threads, or all run on the main thread
|
|
219
|
+
*/
|
|
220
|
+
enableThreading?: boolean;
|
|
221
|
+
}
|