brighterscript 0.68.4 → 0.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/BusyStatusTracker.d.ts +37 -7
- package/dist/BusyStatusTracker.js +73 -8
- package/dist/BusyStatusTracker.js.map +1 -1
- package/dist/DiagnosticCollection.d.ts +19 -5
- package/dist/DiagnosticCollection.js +67 -16
- package/dist/DiagnosticCollection.js.map +1 -1
- package/dist/LanguageServer.d.ts +82 -132
- package/dist/LanguageServer.js +403 -940
- 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 +1 -1
- package/dist/PluginInterface.js.map +1 -1
- package/dist/Program.d.ts +20 -2
- package/dist/Program.js +124 -49
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +21 -7
- package/dist/ProgramBuilder.js +45 -22
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.js +6 -3
- package/dist/Scope.js.map +1 -1
- package/dist/SemanticTokenUtils.js +1 -1
- package/dist/SemanticTokenUtils.js.map +1 -1
- package/dist/bscPlugin/CallExpressionInfo.js +2 -1
- package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.js +14 -4
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.js +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.js +9 -9
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/common/Sequencer.d.ts +27 -0
- package/dist/common/Sequencer.js +113 -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/files/BrsFile.d.ts +1 -1
- package/dist/files/BrsFile.js +10 -15
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +8 -0
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/interfaces.d.ts +22 -2
- 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 +178 -0
- package/dist/lsp/Project.js +438 -0
- package/dist/lsp/Project.js.map +1 -0
- package/dist/lsp/Project.spec.d.ts +1 -0
- package/dist/lsp/Project.spec.js +236 -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 +756 -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 +181 -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/util.d.ts +31 -5
- package/dist/util.js +117 -19
- package/dist/util.js.map +1 -1
- package/package.json +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
## [0.69.0](https://github.com/rokucommunity/brighterscript/compare/v0.68.5...v0.69.0) - 2025-02-10
|
|
10
|
+
### Changed
|
|
11
|
+
- Language Server Rewrite ([#993](https://github.com/rokucommunity/brighterscript/pull/993))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [0.68.5](https://github.com/rokucommunity/brighterscript/compare/v0.68.4...v0.68.5) - 2025-02-06
|
|
16
|
+
### Added
|
|
17
|
+
- Add experimental `validate` flag to ProgramBuilder.run() ([#1409](https://github.com/rokucommunity/brighterscript/pull/1409))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
9
21
|
## [0.68.4](https://github.com/rokucommunity/brighterscript/compare/v0.68.3...v0.68.4) - 2025-01-22
|
|
10
22
|
### Changed
|
|
11
23
|
- upgrade to [roku-deploy@3.12.4](https://github.com/rokucommunity/roku-deploy/blob/master/CHANGELOG.md#3124---2025-01-22). Notable changes since 3.12.3:
|
|
@@ -1,21 +1,50 @@
|
|
|
1
|
+
import { Deferred } from './deferred';
|
|
2
|
+
interface RunInfo<T> {
|
|
3
|
+
label: string;
|
|
4
|
+
startTime: Date;
|
|
5
|
+
scope?: T;
|
|
6
|
+
deferred?: Deferred;
|
|
7
|
+
}
|
|
1
8
|
/**
|
|
2
9
|
* Tracks the busy/idle status of various sync or async tasks
|
|
3
10
|
* Reports the overall status to the client
|
|
4
11
|
*/
|
|
5
|
-
export declare class BusyStatusTracker {
|
|
12
|
+
export declare class BusyStatusTracker<T = any> {
|
|
6
13
|
/**
|
|
7
14
|
* @readonly
|
|
8
15
|
*/
|
|
9
|
-
activeRuns:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
activeRuns: Array<RunInfo<T>>;
|
|
17
|
+
/**
|
|
18
|
+
* Begin a busy task. It's expected you will call `endScopeRun` when the task is complete.
|
|
19
|
+
* @param scope an object used for reference as to what is doing the work. Can be used to bulk-cancel all runs for a given scope.
|
|
20
|
+
* @param label label for the run. This is required for the `endScopedRun` method to know what to end.
|
|
21
|
+
*/
|
|
22
|
+
beginScopedRun(scope: T, label: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* End the earliest run for the given scope and label
|
|
25
|
+
* @param scope an object used for reference as to what is doing the work. Can be used to bulk-cancel all runs for a given scope.
|
|
26
|
+
* @param label label for the run
|
|
27
|
+
*/
|
|
28
|
+
endScopedRun(scope: T, label: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* End all runs for a given scope. This is typically used when the scope is destroyed, and we want to make sure all runs are cleaned up.
|
|
31
|
+
* @param scope an object used for reference as to what is doing the work.
|
|
32
|
+
*/
|
|
33
|
+
endAllRunsForScope(scope: T): void;
|
|
13
34
|
/**
|
|
14
35
|
* Start a new piece of work
|
|
15
36
|
*/
|
|
16
|
-
run<
|
|
37
|
+
run<A, R = A | Promise<A>>(callback: (finalize?: FinalizeBuildStatusRun) => R, label?: string): R;
|
|
38
|
+
private _run;
|
|
17
39
|
private emitter;
|
|
18
|
-
|
|
40
|
+
once(eventName: 'active-runs-change'): Promise<{
|
|
41
|
+
activeRuns: Array<RunInfo<T>>;
|
|
42
|
+
}>;
|
|
43
|
+
once(eventName: 'change'): Promise<BusyStatus>;
|
|
44
|
+
on(eventName: 'active-runs-change', handler: (event: {
|
|
45
|
+
activeRuns: Array<RunInfo<T>>;
|
|
46
|
+
}) => void): any;
|
|
47
|
+
on(eventName: 'change', handler: (status: BusyStatus) => void): any;
|
|
19
48
|
private emit;
|
|
20
49
|
destroy(): void;
|
|
21
50
|
/**
|
|
@@ -29,3 +58,4 @@ export declare enum BusyStatus {
|
|
|
29
58
|
busy = "busy",
|
|
30
59
|
idle = "idle"
|
|
31
60
|
}
|
|
61
|
+
export {};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BusyStatus = exports.BusyStatusTracker = void 0;
|
|
4
4
|
const eventemitter3_1 = require("eventemitter3");
|
|
5
|
+
const deferred_1 = require("./deferred");
|
|
5
6
|
/**
|
|
6
7
|
* Tracks the busy/idle status of various sync or async tasks
|
|
7
8
|
* Reports the overall status to the client
|
|
@@ -11,9 +12,57 @@ class BusyStatusTracker {
|
|
|
11
12
|
/**
|
|
12
13
|
* @readonly
|
|
13
14
|
*/
|
|
14
|
-
this.activeRuns =
|
|
15
|
+
this.activeRuns = [];
|
|
15
16
|
this.emitter = new eventemitter3_1.EventEmitter();
|
|
16
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Begin a busy task. It's expected you will call `endScopeRun` when the task is complete.
|
|
20
|
+
* @param scope an object used for reference as to what is doing the work. Can be used to bulk-cancel all runs for a given scope.
|
|
21
|
+
* @param label label for the run. This is required for the `endScopedRun` method to know what to end.
|
|
22
|
+
*/
|
|
23
|
+
beginScopedRun(scope, label) {
|
|
24
|
+
const deferred = new deferred_1.Deferred();
|
|
25
|
+
const runInfo = {
|
|
26
|
+
label: label,
|
|
27
|
+
startTime: new Date(),
|
|
28
|
+
deferred: deferred,
|
|
29
|
+
scope: scope
|
|
30
|
+
};
|
|
31
|
+
void this._run(runInfo, () => {
|
|
32
|
+
//don't mark the busy run as completed until the deferred is resolved
|
|
33
|
+
return deferred.promise;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* End the earliest run for the given scope and label
|
|
38
|
+
* @param scope an object used for reference as to what is doing the work. Can be used to bulk-cancel all runs for a given scope.
|
|
39
|
+
* @param label label for the run
|
|
40
|
+
*/
|
|
41
|
+
endScopedRun(scope, label) {
|
|
42
|
+
const earliestRunIndex = this.activeRuns.findIndex(x => x.scope === scope && x.label === label);
|
|
43
|
+
if (earliestRunIndex === -1) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const earliestRun = this.activeRuns[earliestRunIndex];
|
|
47
|
+
this.activeRuns.splice(earliestRunIndex, 1);
|
|
48
|
+
earliestRun.deferred.resolve();
|
|
49
|
+
return earliestRun.deferred.promise;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* End all runs for a given scope. This is typically used when the scope is destroyed, and we want to make sure all runs are cleaned up.
|
|
53
|
+
* @param scope an object used for reference as to what is doing the work.
|
|
54
|
+
*/
|
|
55
|
+
endAllRunsForScope(scope) {
|
|
56
|
+
for (let i = this.activeRuns.length - 1; i >= 0; i--) {
|
|
57
|
+
const activeRun = this.activeRuns[i];
|
|
58
|
+
if (activeRun.scope === scope) {
|
|
59
|
+
//delete the active run
|
|
60
|
+
this.activeRuns.splice(i, 1);
|
|
61
|
+
//mark the run as resolved
|
|
62
|
+
activeRun.deferred.resolve();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
17
66
|
/**
|
|
18
67
|
* Start a new piece of work
|
|
19
68
|
*/
|
|
@@ -22,16 +71,24 @@ class BusyStatusTracker {
|
|
|
22
71
|
label: label,
|
|
23
72
|
startTime: new Date()
|
|
24
73
|
};
|
|
25
|
-
this.
|
|
26
|
-
|
|
74
|
+
return this._run(run, callback);
|
|
75
|
+
}
|
|
76
|
+
_run(runInfo, callback, label) {
|
|
77
|
+
this.activeRuns.push(runInfo);
|
|
78
|
+
if (this.activeRuns.length === 1) {
|
|
27
79
|
this.emit('change', BusyStatus.busy);
|
|
28
80
|
}
|
|
81
|
+
this.emit('active-runs-change', { activeRuns: [...this.activeRuns] });
|
|
29
82
|
let isFinalized = false;
|
|
30
83
|
const finalizeRun = () => {
|
|
31
84
|
if (isFinalized === false) {
|
|
32
85
|
isFinalized = true;
|
|
33
|
-
this.activeRuns.
|
|
34
|
-
if (
|
|
86
|
+
let idx = this.activeRuns.indexOf(runInfo);
|
|
87
|
+
if (idx > -1) {
|
|
88
|
+
this.activeRuns.splice(idx, 1);
|
|
89
|
+
}
|
|
90
|
+
this.emit('active-runs-change', { activeRuns: [...this.activeRuns] });
|
|
91
|
+
if (this.activeRuns.length <= 0) {
|
|
35
92
|
this.emit('change', BusyStatus.idle);
|
|
36
93
|
}
|
|
37
94
|
}
|
|
@@ -54,14 +111,22 @@ class BusyStatusTracker {
|
|
|
54
111
|
throw e;
|
|
55
112
|
}
|
|
56
113
|
}
|
|
114
|
+
once(eventName) {
|
|
115
|
+
return new Promise((resolve) => {
|
|
116
|
+
const off = this.on(eventName, (data) => {
|
|
117
|
+
off();
|
|
118
|
+
resolve(data);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
}
|
|
57
122
|
on(eventName, handler) {
|
|
58
123
|
this.emitter.on(eventName, handler);
|
|
59
124
|
return () => {
|
|
60
125
|
this.emitter.off(eventName, handler);
|
|
61
126
|
};
|
|
62
127
|
}
|
|
63
|
-
emit(eventName,
|
|
64
|
-
this.emitter.emit(eventName,
|
|
128
|
+
emit(eventName, event) {
|
|
129
|
+
this.emitter.emit(eventName, event);
|
|
65
130
|
}
|
|
66
131
|
destroy() {
|
|
67
132
|
this.emitter.removeAllListeners();
|
|
@@ -71,7 +136,7 @@ class BusyStatusTracker {
|
|
|
71
136
|
* @readonly
|
|
72
137
|
*/
|
|
73
138
|
get status() {
|
|
74
|
-
return this.activeRuns.
|
|
139
|
+
return this.activeRuns.length === 0 ? BusyStatus.idle : BusyStatus.busy;
|
|
75
140
|
}
|
|
76
141
|
}
|
|
77
142
|
exports.BusyStatusTracker = BusyStatusTracker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BusyStatusTracker.js","sourceRoot":"","sources":["../src/BusyStatusTracker.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;
|
|
1
|
+
{"version":3,"file":"BusyStatusTracker.js","sourceRoot":"","sources":["../src/BusyStatusTracker.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAC7C,yCAAsC;AAStC;;;GAGG;AACH,MAAa,iBAAiB;IAA9B;QACI;;WAEG;QACI,eAAU,GAAsB,EAAE,CAAC;QA6GlC,YAAO,GAAG,IAAI,4BAAY,EAAsB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U;QACtC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAEM,OAAO;QACV,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC;IAC5E,CAAC;CACJ;AAxJD,8CAwJC;AAID,IAAY,UAGX;AAHD,WAAY,UAAU;IAClB,2BAAa,CAAA;IACb,2BAAa,CAAA;AACjB,CAAC,EAHW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAGrB"}
|
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Project } from './LanguageServer';
|
|
1
|
+
import type { LspDiagnostic } from './lsp/LspProject';
|
|
3
2
|
export declare class DiagnosticCollection {
|
|
4
3
|
private previousDiagnosticsByFile;
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Get a patch of any changed diagnostics since last time. This takes a single project and diagnostics, but evaluates
|
|
6
|
+
* the patch based on all previously seen projects. It's supposed to be a rolling patch.
|
|
7
|
+
* This will include _ALL_ diagnostics for a file if any diagnostics have changed for that file, due to how the language server expects diagnostics to be sent.
|
|
8
|
+
*/
|
|
9
|
+
getPatch(projectId: number, diagnostics: LspDiagnostic[]): {
|
|
6
10
|
[x: string]: KeyedDiagnostic[];
|
|
7
11
|
};
|
|
8
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Get all the previous diagnostics, remove any that were exclusive to the current project, then mix in the project's new diagnostics.
|
|
14
|
+
* @param projectId the id of the project that should have its diagnostics refreshed
|
|
15
|
+
* @param thisProjectDiagnostics diagnostics for the project
|
|
16
|
+
*/
|
|
17
|
+
private getDiagnosticsByFile;
|
|
18
|
+
/**
|
|
19
|
+
* Clone the previousDiagnosticsByFile, retaining the array of project references on each diagnostic
|
|
20
|
+
*/
|
|
21
|
+
private clonePreviousDiagnosticsByFile;
|
|
9
22
|
/**
|
|
10
23
|
* Get a patch for all the files that have been removed since last time
|
|
11
24
|
*/
|
|
@@ -23,7 +36,8 @@ export declare class DiagnosticCollection {
|
|
|
23
36
|
*/
|
|
24
37
|
private getAddedPatch;
|
|
25
38
|
}
|
|
26
|
-
interface KeyedDiagnostic extends
|
|
39
|
+
interface KeyedDiagnostic extends LspDiagnostic {
|
|
27
40
|
key: string;
|
|
41
|
+
projectIds: Set<number>;
|
|
28
42
|
}
|
|
29
43
|
export {};
|
|
@@ -1,34 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DiagnosticCollection = void 0;
|
|
4
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
4
5
|
const util_1 = require("./util");
|
|
6
|
+
const thenby_1 = require("thenby");
|
|
5
7
|
class DiagnosticCollection {
|
|
6
8
|
constructor() {
|
|
7
9
|
this.previousDiagnosticsByFile = {};
|
|
8
10
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Get a patch of any changed diagnostics since last time. This takes a single project and diagnostics, but evaluates
|
|
13
|
+
* the patch based on all previously seen projects. It's supposed to be a rolling patch.
|
|
14
|
+
* This will include _ALL_ diagnostics for a file if any diagnostics have changed for that file, due to how the language server expects diagnostics to be sent.
|
|
15
|
+
*/
|
|
16
|
+
getPatch(projectId, diagnostics) {
|
|
17
|
+
const diagnosticsByFile = this.getDiagnosticsByFile(projectId, diagnostics);
|
|
11
18
|
const patch = Object.assign(Object.assign(Object.assign({}, this.getRemovedPatch(diagnosticsByFile)), this.getModifiedPatch(diagnosticsByFile)), this.getAddedPatch(diagnosticsByFile));
|
|
12
19
|
//save the new list of diagnostics
|
|
13
20
|
this.previousDiagnosticsByFile = diagnosticsByFile;
|
|
14
21
|
return patch;
|
|
15
22
|
}
|
|
16
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Get all the previous diagnostics, remove any that were exclusive to the current project, then mix in the project's new diagnostics.
|
|
25
|
+
* @param projectId the id of the project that should have its diagnostics refreshed
|
|
26
|
+
* @param thisProjectDiagnostics diagnostics for the project
|
|
27
|
+
*/
|
|
28
|
+
getDiagnosticsByFile(projectId, thisProjectDiagnostics) {
|
|
17
29
|
var _a, _b;
|
|
18
|
-
const result =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
30
|
+
const result = this.clonePreviousDiagnosticsByFile();
|
|
31
|
+
const diagnosticsByKey = new Map();
|
|
32
|
+
//delete all diagnostics linked to this project
|
|
33
|
+
for (const srcPath in result) {
|
|
34
|
+
const diagnostics = result[srcPath];
|
|
35
|
+
for (let i = diagnostics.length - 1; i >= 0; i--) {
|
|
36
|
+
const diagnostic = diagnostics[i];
|
|
37
|
+
//remember this diagnostic key for use when deduplicating down below
|
|
38
|
+
diagnosticsByKey.set(diagnostic.key, diagnostic);
|
|
39
|
+
//unlink the diagnostic from this project
|
|
40
|
+
diagnostic.projectIds.delete(projectId);
|
|
41
|
+
//delete this diagnostic if it's no longer linked to any projects
|
|
42
|
+
if (diagnostic.projectIds.size === 0) {
|
|
43
|
+
diagnostics.splice(i, 1);
|
|
44
|
+
diagnosticsByKey.delete(diagnostic.key);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
22
48
|
//build the full current set of diagnostics by file
|
|
23
|
-
for (let diagnostic of
|
|
24
|
-
const srcPath = (
|
|
49
|
+
for (let diagnostic of thisProjectDiagnostics) {
|
|
50
|
+
const srcPath = vscode_uri_1.URI.parse(diagnostic.uri).fsPath;
|
|
25
51
|
//ensure the file entry exists
|
|
26
52
|
if (!result[srcPath]) {
|
|
27
53
|
result[srcPath] = [];
|
|
28
54
|
}
|
|
29
|
-
const diagnosticMap = result[srcPath];
|
|
30
55
|
//fall back to a default range if missing
|
|
31
|
-
const range = (
|
|
56
|
+
const range = (_a = diagnostic.range) !== null && _a !== void 0 ? _a : util_1.util.createRange(0, 0, 0, 0);
|
|
32
57
|
diagnostic.key =
|
|
33
58
|
srcPath.toLowerCase() + '-' +
|
|
34
59
|
diagnostic.code + '-' +
|
|
@@ -37,21 +62,46 @@ class DiagnosticCollection {
|
|
|
37
62
|
range.end.line + '-' +
|
|
38
63
|
range.end.character +
|
|
39
64
|
diagnostic.message;
|
|
65
|
+
(_b = diagnostic.projectIds) !== null && _b !== void 0 ? _b : (diagnostic.projectIds = new Set([projectId]));
|
|
40
66
|
//don't include duplicates
|
|
41
|
-
if (!
|
|
42
|
-
|
|
43
|
-
|
|
67
|
+
if (!diagnosticsByKey.has(diagnostic.key)) {
|
|
68
|
+
diagnosticsByKey.set(diagnostic.key, diagnostic);
|
|
69
|
+
const diagnosticsForFile = result[srcPath];
|
|
70
|
+
diagnosticsForFile.push(diagnostic);
|
|
44
71
|
}
|
|
72
|
+
//link this project to the diagnostic
|
|
73
|
+
diagnosticsByKey.get(diagnostic.key).projectIds.add(projectId);
|
|
74
|
+
}
|
|
75
|
+
//sort the list so it's easier to compare later
|
|
76
|
+
for (let key in result) {
|
|
77
|
+
result[key].sort((0, thenby_1.firstBy)(x => x.key));
|
|
45
78
|
}
|
|
46
79
|
return result;
|
|
47
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Clone the previousDiagnosticsByFile, retaining the array of project references on each diagnostic
|
|
83
|
+
*/
|
|
84
|
+
clonePreviousDiagnosticsByFile() {
|
|
85
|
+
let clone = {};
|
|
86
|
+
for (let key in this.previousDiagnosticsByFile) {
|
|
87
|
+
clone[key] = [];
|
|
88
|
+
for (const diagnostic of this.previousDiagnosticsByFile[key]) {
|
|
89
|
+
clone[key].push(Object.assign(Object.assign({}, diagnostic), {
|
|
90
|
+
//make a copy of the projects array (but keep the project references intact)
|
|
91
|
+
projectIds: new Set([...diagnostic.projectIds]) }));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return clone;
|
|
95
|
+
}
|
|
48
96
|
/**
|
|
49
97
|
* Get a patch for all the files that have been removed since last time
|
|
50
98
|
*/
|
|
51
99
|
getRemovedPatch(currentDiagnosticsByFile) {
|
|
100
|
+
var _a, _b;
|
|
52
101
|
const result = {};
|
|
53
102
|
for (const filePath in this.previousDiagnosticsByFile) {
|
|
54
|
-
if
|
|
103
|
+
//if there are no current diagnostics for this file, add an empty array to the result for that file path
|
|
104
|
+
if (((_b = (_a = currentDiagnosticsByFile[filePath]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0) {
|
|
55
105
|
result[filePath] = [];
|
|
56
106
|
}
|
|
57
107
|
}
|
|
@@ -90,9 +140,10 @@ class DiagnosticCollection {
|
|
|
90
140
|
* Get diagnostics for all new files not seen since last time
|
|
91
141
|
*/
|
|
92
142
|
getAddedPatch(currentDiagnosticsByFile) {
|
|
143
|
+
var _a, _b;
|
|
93
144
|
const result = {};
|
|
94
145
|
for (const filePath in currentDiagnosticsByFile) {
|
|
95
|
-
if (
|
|
146
|
+
if (((_b = (_a = this.previousDiagnosticsByFile[filePath]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0) {
|
|
96
147
|
result[filePath] = currentDiagnosticsByFile[filePath];
|
|
97
148
|
}
|
|
98
149
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiagnosticCollection.js","sourceRoot":"","sources":["../src/DiagnosticCollection.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"DiagnosticCollection.js","sourceRoot":"","sources":["../src/DiagnosticCollection.ts"],"names":[],"mappings":";;;AAAA,2CAAiC;AAEjC,iCAA8B;AAC9B,mCAAiC;AAEjC,MAAa,oBAAoB;IAAjC;QACY,8BAAyB,GAAsC,EAAE,CAAC;IAuK9E,CAAC;IArKG;;;;OAIG;IACI,QAAQ,CAAC,SAAiB,EAAE,WAA4B;QAC3D,MAAM,iBAA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