brighterscript 0.51.2 → 0.52.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 +22 -0
- package/bsconfig.schema.json +10 -2
- package/dist/DiagnosticCollection.d.ts +3 -3
- package/dist/DiagnosticCollection.js +6 -6
- package/dist/DiagnosticCollection.js.map +1 -1
- package/dist/LanguageServer.d.ts +47 -22
- package/dist/LanguageServer.js +273 -202
- package/dist/LanguageServer.js.map +1 -1
- package/dist/ProgramBuilder.js +3 -3
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.js +4 -1
- package/dist/Scope.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +70 -65
- package/dist/astUtils/visitors.js +24 -9
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +70 -0
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/files/BrsFile.spec.js +64 -0
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/parser/Expression.js +6 -23
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Statement.js +8 -24
- package/dist/parser/Statement.js.map +1 -1
- package/dist/util.js +5 -1
- package/dist/util.js.map +1 -1
- package/package.json +10 -11
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
## [0.52.0](https://github.com/rokucommunity/brighterscript/compare/v0.51.4...v0.52.0) - 2022-06-08
|
|
10
|
+
### Added
|
|
11
|
+
- LanguageServer: Load projects based on bsconfig.json presence ([#613](https://github.com/rokucommunity/brighterscript/pull/613))
|
|
12
|
+
### Changed
|
|
13
|
+
- upgrade to [roku-deploy@3.7.1](https://github.com/rokucommunity/roku-deploy/blob/master/CHANGELOG.md#371---2022-06-08)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [0.51.4](https://github.com/rokucommunity/brighterscript/compare/v0.51.3...v0.51.4) - 2022-05-31
|
|
18
|
+
### Fixed
|
|
19
|
+
- Add allowBrighterScriptInBrightScript to bsconfig.schema.json ([#610](https://github.com/rokucommunity/brighterscript/pull/610))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## [0.51.3](https://github.com/rokucommunity/brighterscript/compare/v0.51.2...v0.51.3) - 2022-05-31
|
|
24
|
+
### Fixed
|
|
25
|
+
- hover for namespace functions ([#606](https://github.com/rokucommunity/brighterscript/pull/606))
|
|
26
|
+
### Changed
|
|
27
|
+
- add `owner` and `key` to the visitor callbacks ([#600](https://github.com/rokucommunity/brighterscript/pull/600))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
9
31
|
## [0.51.2](https://github.com/rokucommunity/brighterscript/compare/v0.51.1...v0.51.2) - 2022-05-26
|
|
10
32
|
### Fixed
|
|
11
33
|
- allow enums and interfaces as class field types ([#602](https://github.com/rokucommunity/brighterscript/pull/602))
|
package/bsconfig.schema.json
CHANGED
|
@@ -165,7 +165,10 @@
|
|
|
165
165
|
"items": {
|
|
166
166
|
"anyOf": [
|
|
167
167
|
{
|
|
168
|
-
"type": [
|
|
168
|
+
"type": [
|
|
169
|
+
"number",
|
|
170
|
+
"string"
|
|
171
|
+
],
|
|
169
172
|
"description": "A code of diagnostics that should be filtered out from the files matched in 'src'"
|
|
170
173
|
}
|
|
171
174
|
]
|
|
@@ -232,6 +235,11 @@
|
|
|
232
235
|
"warn",
|
|
233
236
|
"error"
|
|
234
237
|
]
|
|
238
|
+
},
|
|
239
|
+
"allowBrighterScriptInBrightScript": {
|
|
240
|
+
"description": "Allow brighterscript features (classes, interfaces, etc...) to be included in BrightScript (`.brs`) files, and force those files to be transpiled.",
|
|
241
|
+
"type": "boolean",
|
|
242
|
+
"default": false
|
|
235
243
|
}
|
|
236
244
|
}
|
|
237
|
-
}
|
|
245
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { BsDiagnostic } from './interfaces';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Project } from './LanguageServer';
|
|
3
3
|
export declare class DiagnosticCollection {
|
|
4
4
|
private previousDiagnosticsByFile;
|
|
5
|
-
getPatch(
|
|
6
|
-
private
|
|
5
|
+
getPatch(projects: Project[]): Promise<Record<string, KeyedDiagnostic[]>>;
|
|
6
|
+
private getDiagnosticsByFileFromProjects;
|
|
7
7
|
/**
|
|
8
8
|
* Get a patch for all the files that have been removed since last time
|
|
9
9
|
*/
|
|
@@ -5,20 +5,20 @@ class DiagnosticCollection {
|
|
|
5
5
|
constructor() {
|
|
6
6
|
this.previousDiagnosticsByFile = {};
|
|
7
7
|
}
|
|
8
|
-
async getPatch(
|
|
9
|
-
const diagnosticsByFile = await this.
|
|
8
|
+
async getPatch(projects) {
|
|
9
|
+
const diagnosticsByFile = await this.getDiagnosticsByFileFromProjects(projects);
|
|
10
10
|
const patch = Object.assign(Object.assign(Object.assign({}, this.getRemovedPatch(diagnosticsByFile)), this.getModifiedPatch(diagnosticsByFile)), this.getAddedPatch(diagnosticsByFile));
|
|
11
11
|
//save the new list of diagnostics
|
|
12
12
|
this.previousDiagnosticsByFile = diagnosticsByFile;
|
|
13
13
|
return patch;
|
|
14
14
|
}
|
|
15
|
-
async
|
|
15
|
+
async getDiagnosticsByFileFromProjects(projects) {
|
|
16
16
|
var _a;
|
|
17
17
|
const result = {};
|
|
18
18
|
//wait for all programs to finish running. This ensures the `Program` exists.
|
|
19
|
-
await Promise.all(
|
|
20
|
-
//get all diagnostics for all
|
|
21
|
-
let diagnostics = Array.prototype.concat.apply([],
|
|
19
|
+
await Promise.all(projects.map(x => x.firstRunPromise));
|
|
20
|
+
//get all diagnostics for all projects
|
|
21
|
+
let diagnostics = Array.prototype.concat.apply([], projects.map((x) => x.builder.getDiagnostics()));
|
|
22
22
|
const keys = {};
|
|
23
23
|
//build the full current set of diagnostics by file
|
|
24
24
|
for (let diagnostic of diagnostics) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiagnosticCollection.js","sourceRoot":"","sources":["../src/DiagnosticCollection.ts"],"names":[],"mappings":";;;AAGA,MAAa,oBAAoB;IAAjC;QACY,8BAAyB,GAAG,EAAuC,CAAC;IAkHhF,CAAC;IAhHU,KAAK,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"DiagnosticCollection.js","sourceRoot":"","sources":["../src/DiagnosticCollection.ts"],"names":[],"mappings":";;;AAGA,MAAa,oBAAoB;IAAjC;QACY,8BAAyB,GAAG,EAAuC,CAAC;IAkHhF,CAAC;IAhHU,KAAK,CAAC,QAAQ,CAAC,QAAmB;QACrC,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,gCAAgC,CAAC,QAAQ,CAAC,CAAC;QAEhF,MAAM,KAAK,iDACJ,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAC,GACvC,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,GACxC,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAC3C,CAAC;QAEF,kCAAkC;QAClC,IAAI,CAAC,yBAAyB,GAAG,iBAAiB,CAAC;QACnD,OAAO,KAAK,CAAC;IACjB,CAAC;IAEO,KAAK,CAAC,gCAAgC,CAAC,QAAmB;;QAC9D,MAAM,MAAM,GAAG,EAAuC,CAAC;QAEvD,6EAA6E;QAC7E,MAAM,OAAO,CAAC,GAAG,CACb,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CACvC,CAAC;QAEF,sCAAsC;QACtC,IAAI,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAuB,EAClE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,CAC7B,CAAC;QAEvB,MAAM,IAAI,GAAG,EAAE,C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@@ -5,18 +5,18 @@ import { ProgramBuilder } from './ProgramBuilder';
|
|
|
5
5
|
import { Throttler } from './Throttler';
|
|
6
6
|
export declare class LanguageServer {
|
|
7
7
|
private connection;
|
|
8
|
-
|
|
8
|
+
projects: Project[];
|
|
9
9
|
/**
|
|
10
10
|
* The number of milliseconds that should be used for language server typing debouncing
|
|
11
11
|
*/
|
|
12
12
|
private debounceTimeout;
|
|
13
13
|
/**
|
|
14
|
-
* These
|
|
15
|
-
* in any of the workspace projects.
|
|
16
|
-
* Basically these are single-file
|
|
14
|
+
* These projects are created on the fly whenever a file is opened that is not included
|
|
15
|
+
* in any of the workspace-based projects.
|
|
16
|
+
* Basically these are single-file projects to at least get parsing for standalone files.
|
|
17
17
|
* Also, they should only be created when the file is opened, and destroyed when the file is closed.
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
standaloneFileProjects: Record<string, Project>;
|
|
20
20
|
private hasConfigurationCapability;
|
|
21
21
|
/**
|
|
22
22
|
* Indicates whether the client supports workspace folders
|
|
@@ -41,7 +41,27 @@ export declare class LanguageServer {
|
|
|
41
41
|
onInitialize(params: InitializeParams): {
|
|
42
42
|
capabilities: ServerCapabilities<any>;
|
|
43
43
|
};
|
|
44
|
-
private
|
|
44
|
+
private initialProjectsCreated;
|
|
45
|
+
/**
|
|
46
|
+
* Ask the client for the list of `files.exclude` patterns. Useful when determining if we should process a file
|
|
47
|
+
*/
|
|
48
|
+
private getWorkspaceExcludeGlobs;
|
|
49
|
+
/**
|
|
50
|
+
* Scan the workspace for all `bsconfig.json` files. If at least one is found, then only folders who have bsconfig.json are returned.
|
|
51
|
+
* If none are found, then the workspaceFolder itself is treated as a project
|
|
52
|
+
*/
|
|
53
|
+
private getProjectPaths;
|
|
54
|
+
/**
|
|
55
|
+
* Find all folders with bsconfig.json files in them, and treat each as a project.
|
|
56
|
+
* Treat workspaces that don't have a bsconfig.json as a project.
|
|
57
|
+
* Handle situations where bsconfig.json files were added or removed (to elevate/lower workspaceFolder projects accordingly)
|
|
58
|
+
* Leave existing projects alone if they are not affected by these changes
|
|
59
|
+
*/
|
|
60
|
+
private syncProjects;
|
|
61
|
+
/**
|
|
62
|
+
* Get all workspace paths from the client
|
|
63
|
+
*/
|
|
64
|
+
private getWorkspacePaths;
|
|
45
65
|
/**
|
|
46
66
|
* Called when the client has finished initializing
|
|
47
67
|
* @param params
|
|
@@ -54,22 +74,16 @@ export declare class LanguageServer {
|
|
|
54
74
|
/**
|
|
55
75
|
* Wait for all programs' first run to complete
|
|
56
76
|
*/
|
|
57
|
-
private
|
|
58
|
-
/**
|
|
59
|
-
* Create project for each new workspace. If the workspace is already known,
|
|
60
|
-
* it is skipped.
|
|
61
|
-
* @param workspaceFolders
|
|
62
|
-
*/
|
|
63
|
-
private createWorkspaces;
|
|
77
|
+
private waitAllProjectFirstRuns;
|
|
64
78
|
/**
|
|
65
79
|
* Event handler for when the program wants to load file contents.
|
|
66
80
|
* anytime the program wants to load a file, check with our in-memory document cache first
|
|
67
81
|
*/
|
|
68
82
|
private documentFileResolver;
|
|
69
83
|
private getConfigFilePath;
|
|
70
|
-
private
|
|
71
|
-
private
|
|
72
|
-
private
|
|
84
|
+
private createProject;
|
|
85
|
+
private createStandaloneFileProject;
|
|
86
|
+
private getProjects;
|
|
73
87
|
/**
|
|
74
88
|
* Provide a list of completion items based on the current cursor position
|
|
75
89
|
* @param textDocumentPosition
|
|
@@ -82,9 +96,13 @@ export declare class LanguageServer {
|
|
|
82
96
|
private onCompletionResolve;
|
|
83
97
|
private onCodeAction;
|
|
84
98
|
/**
|
|
85
|
-
*
|
|
99
|
+
* Remove a project from the language server
|
|
100
|
+
*/
|
|
101
|
+
private removeProject;
|
|
102
|
+
/**
|
|
103
|
+
* Reload each of the specified workspaces
|
|
86
104
|
*/
|
|
87
|
-
private
|
|
105
|
+
private reloadProjects;
|
|
88
106
|
private getRootDir;
|
|
89
107
|
/**
|
|
90
108
|
* Sometimes users will alter their bsconfig files array, and will include standalone files.
|
|
@@ -93,7 +111,7 @@ export declare class LanguageServer {
|
|
|
93
111
|
*
|
|
94
112
|
* Sometimes files that used to be included are now excluded, so those open files need to be re-processed as standalone
|
|
95
113
|
*/
|
|
96
|
-
private
|
|
114
|
+
private synchronizeStandaloneProjects;
|
|
97
115
|
private onDidChangeConfiguration;
|
|
98
116
|
/**
|
|
99
117
|
* Called when watched files changed (add/change/delete).
|
|
@@ -108,7 +126,7 @@ export declare class LanguageServer {
|
|
|
108
126
|
* any file changes you receive with no unexpected side-effects
|
|
109
127
|
* @param changes
|
|
110
128
|
*/
|
|
111
|
-
handleFileChanges(
|
|
129
|
+
handleFileChanges(project: Project, changes: {
|
|
112
130
|
type: FileChangeType;
|
|
113
131
|
srcPath: string;
|
|
114
132
|
}[]): Promise<void>;
|
|
@@ -134,14 +152,21 @@ export declare class LanguageServer {
|
|
|
134
152
|
private transpileFile;
|
|
135
153
|
dispose(): void;
|
|
136
154
|
}
|
|
137
|
-
export interface
|
|
155
|
+
export interface Project {
|
|
138
156
|
firstRunPromise: Promise<any>;
|
|
139
157
|
builder: ProgramBuilder;
|
|
158
|
+
/**
|
|
159
|
+
* The path to where the project resides
|
|
160
|
+
*/
|
|
161
|
+
projectPath: string;
|
|
162
|
+
/**
|
|
163
|
+
* The path to the workspace where this project resides. A workspace can have multiple projects (by adding a bsconfig.json to each folder).
|
|
164
|
+
*/
|
|
140
165
|
workspacePath: string;
|
|
141
166
|
isFirstRunComplete: boolean;
|
|
142
167
|
isFirstRunSuccessful: boolean;
|
|
143
168
|
configFilePath?: string;
|
|
144
|
-
|
|
169
|
+
isStandaloneFileProject: boolean;
|
|
145
170
|
}
|
|
146
171
|
export declare enum CustomCommands {
|
|
147
172
|
TranspileFile = "TranspileFile"
|