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.
Files changed (114) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/BusyStatusTracker.d.ts +37 -7
  3. package/dist/BusyStatusTracker.js +73 -8
  4. package/dist/BusyStatusTracker.js.map +1 -1
  5. package/dist/DiagnosticCollection.d.ts +19 -5
  6. package/dist/DiagnosticCollection.js +67 -16
  7. package/dist/DiagnosticCollection.js.map +1 -1
  8. package/dist/LanguageServer.d.ts +82 -132
  9. package/dist/LanguageServer.js +403 -940
  10. package/dist/LanguageServer.js.map +1 -1
  11. package/dist/Logger.d.ts +9 -4
  12. package/dist/Logger.js +30 -6
  13. package/dist/Logger.js.map +1 -1
  14. package/dist/PluginInterface.d.ts +1 -1
  15. package/dist/PluginInterface.js.map +1 -1
  16. package/dist/Program.d.ts +20 -2
  17. package/dist/Program.js +124 -49
  18. package/dist/Program.js.map +1 -1
  19. package/dist/ProgramBuilder.d.ts +21 -7
  20. package/dist/ProgramBuilder.js +45 -22
  21. package/dist/ProgramBuilder.js.map +1 -1
  22. package/dist/Scope.js +6 -3
  23. package/dist/Scope.js.map +1 -1
  24. package/dist/SemanticTokenUtils.js +1 -1
  25. package/dist/SemanticTokenUtils.js.map +1 -1
  26. package/dist/bscPlugin/CallExpressionInfo.js +2 -1
  27. package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
  28. package/dist/bscPlugin/completions/CompletionsProcessor.js +14 -4
  29. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
  30. package/dist/bscPlugin/hover/HoverProcessor.js +1 -1
  31. package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
  32. package/dist/bscPlugin/validation/ScopeValidator.js +9 -9
  33. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
  34. package/dist/common/Sequencer.d.ts +27 -0
  35. package/dist/common/Sequencer.js +113 -0
  36. package/dist/common/Sequencer.js.map +1 -0
  37. package/dist/common/Sequencer.spec.d.ts +1 -0
  38. package/dist/common/Sequencer.spec.js +75 -0
  39. package/dist/common/Sequencer.spec.js.map +1 -0
  40. package/dist/deferred.d.ts +2 -0
  41. package/dist/deferred.js +10 -0
  42. package/dist/deferred.js.map +1 -1
  43. package/dist/files/BrsFile.d.ts +1 -1
  44. package/dist/files/BrsFile.js +10 -15
  45. package/dist/files/BrsFile.js.map +1 -1
  46. package/dist/files/BrsFile.spec.js +8 -0
  47. package/dist/files/BrsFile.spec.js.map +1 -1
  48. package/dist/interfaces.d.ts +22 -2
  49. package/dist/lexer/Lexer.js +1 -1
  50. package/dist/lexer/Lexer.js.map +1 -1
  51. package/dist/logging.d.ts +6 -1
  52. package/dist/logging.js +14 -1
  53. package/dist/logging.js.map +1 -1
  54. package/dist/lsp/ActionQueue.d.ts +35 -0
  55. package/dist/lsp/ActionQueue.js +115 -0
  56. package/dist/lsp/ActionQueue.js.map +1 -0
  57. package/dist/lsp/ActionQueue.spec.d.ts +1 -0
  58. package/dist/lsp/ActionQueue.spec.js +80 -0
  59. package/dist/lsp/ActionQueue.spec.js.map +1 -0
  60. package/dist/lsp/DocumentManager.d.ts +63 -0
  61. package/dist/lsp/DocumentManager.js +122 -0
  62. package/dist/lsp/DocumentManager.js.map +1 -0
  63. package/dist/lsp/DocumentManager.spec.d.ts +1 -0
  64. package/dist/lsp/DocumentManager.spec.js +103 -0
  65. package/dist/lsp/DocumentManager.spec.js.map +1 -0
  66. package/dist/lsp/LspProject.d.ts +231 -0
  67. package/dist/lsp/LspProject.js +3 -0
  68. package/dist/lsp/LspProject.js.map +1 -0
  69. package/dist/lsp/PathFilterer.d.ts +75 -0
  70. package/dist/lsp/PathFilterer.js +196 -0
  71. package/dist/lsp/PathFilterer.js.map +1 -0
  72. package/dist/lsp/PathFilterer.spec.d.ts +1 -0
  73. package/dist/lsp/PathFilterer.spec.js +182 -0
  74. package/dist/lsp/PathFilterer.spec.js.map +1 -0
  75. package/dist/lsp/Project.d.ts +178 -0
  76. package/dist/lsp/Project.js +438 -0
  77. package/dist/lsp/Project.js.map +1 -0
  78. package/dist/lsp/Project.spec.d.ts +1 -0
  79. package/dist/lsp/Project.spec.js +236 -0
  80. package/dist/lsp/Project.spec.js.map +1 -0
  81. package/dist/lsp/ProjectManager.d.ts +221 -0
  82. package/dist/lsp/ProjectManager.js +735 -0
  83. package/dist/lsp/ProjectManager.js.map +1 -0
  84. package/dist/lsp/ProjectManager.spec.d.ts +1 -0
  85. package/dist/lsp/ProjectManager.spec.js +756 -0
  86. package/dist/lsp/ProjectManager.spec.js.map +1 -0
  87. package/dist/lsp/ReaderWriterManager.d.ts +21 -0
  88. package/dist/lsp/ReaderWriterManager.js +60 -0
  89. package/dist/lsp/ReaderWriterManager.js.map +1 -0
  90. package/dist/lsp/worker/MessageHandler.d.ts +99 -0
  91. package/dist/lsp/worker/MessageHandler.js +138 -0
  92. package/dist/lsp/worker/MessageHandler.js.map +1 -0
  93. package/dist/lsp/worker/MessageHandler.spec.d.ts +1 -0
  94. package/dist/lsp/worker/MessageHandler.spec.js +64 -0
  95. package/dist/lsp/worker/MessageHandler.spec.js.map +1 -0
  96. package/dist/lsp/worker/WorkerPool.d.ts +38 -0
  97. package/dist/lsp/worker/WorkerPool.js +78 -0
  98. package/dist/lsp/worker/WorkerPool.js.map +1 -0
  99. package/dist/lsp/worker/WorkerPool.spec.d.ts +1 -0
  100. package/dist/lsp/worker/WorkerPool.spec.js +59 -0
  101. package/dist/lsp/worker/WorkerPool.spec.js.map +1 -0
  102. package/dist/lsp/worker/WorkerThreadProject.d.ts +144 -0
  103. package/dist/lsp/worker/WorkerThreadProject.js +181 -0
  104. package/dist/lsp/worker/WorkerThreadProject.js.map +1 -0
  105. package/dist/lsp/worker/WorkerThreadProject.spec.d.ts +2 -0
  106. package/dist/lsp/worker/WorkerThreadProject.spec.js +68 -0
  107. package/dist/lsp/worker/WorkerThreadProject.spec.js.map +1 -0
  108. package/dist/lsp/worker/WorkerThreadProjectRunner.d.ts +15 -0
  109. package/dist/lsp/worker/WorkerThreadProjectRunner.js +58 -0
  110. package/dist/lsp/worker/WorkerThreadProjectRunner.js.map +1 -0
  111. package/dist/util.d.ts +31 -5
  112. package/dist/util.js +117 -19
  113. package/dist/util.js.map +1 -1
  114. package/package.json +11 -1
@@ -1,23 +1,20 @@
1
1
  import 'array-flat-polyfill';
2
- import type { InitializeParams, ServerCapabilities, ExecuteCommandParams, WorkspaceSymbolParams, SymbolInformation, DocumentSymbolParams } from 'vscode-languageserver/node';
3
- import { FileChangeType } from 'vscode-languageserver/node';
4
- import { ProgramBuilder } from './ProgramBuilder';
5
- import { Throttler } from './Throttler';
6
- import { BusyStatusTracker } from './BusyStatusTracker';
2
+ import type { CompletionItem, DidChangeWatchedFilesParams, InitializeParams, TextDocumentPositionParams, ExecuteCommandParams, WorkspaceSymbolParams, DocumentSymbolParams, ReferenceParams, SignatureHelpParams, CodeActionParams, HandlerResult, InitializeError, InitializeResult, CompletionParams, ResultProgressReporter, WorkDoneProgressReporter, CompletionList, CancellationToken, DidChangeConfigurationParams } from 'vscode-languageserver/node';
3
+ import { LogLevel } from './logging';
4
+ import type { WorkspaceConfig } from './lsp/ProjectManager';
7
5
  export declare class LanguageServer {
8
- private connection;
9
- projects: Project[];
10
6
  /**
11
- * The number of milliseconds that should be used for language server typing debouncing
7
+ * The default threading setting for the language server. Can be overridden by per-workspace settings
8
+ */
9
+ static enableThreadingDefault: boolean;
10
+ /**
11
+ * The language server protocol connection, used to send and receive all requests and responses
12
12
  */
13
- private debounceTimeout;
13
+ private connection;
14
14
  /**
15
- * These projects are created on the fly whenever a file is opened that is not included
16
- * in any of the workspace-based projects.
17
- * Basically these are single-file projects to at least get parsing for standalone files.
18
- * Also, they should only be created when the file is opened, and destroyed when the file is closed.
15
+ * Manages all projects for this language server
19
16
  */
20
- standaloneFileProjects: Record<string, Project>;
17
+ private projectManager;
21
18
  private hasConfigurationCapability;
22
19
  /**
23
20
  * Indicates whether the client supports workspace folders
@@ -28,157 +25,96 @@ export declare class LanguageServer {
28
25
  * The text document manager supports full document sync only
29
26
  */
30
27
  private documents;
31
- private createConnection;
32
28
  private loggerSubscription;
33
- private keyedThrottler;
34
- validateThrottler: Throttler;
35
- private sendDiagnosticsThrottler;
36
- private boundValidateAll;
37
- private validateAllThrottled;
38
- busyStatusTracker: BusyStatusTracker;
39
- run(): void;
40
- private busyStatusIndex;
41
- private sendBusyStatus;
42
- /**
43
- * Called when the client starts initialization
44
- */
45
- onInitialize(params: InitializeParams): {
46
- capabilities: ServerCapabilities<any>;
47
- };
48
- private initialProjectsCreated;
49
- /**
50
- * Ask the client for the list of `files.exclude` patterns. Useful when determining if we should process a file
51
- */
52
- private getWorkspaceExcludeGlobs;
53
29
  /**
54
- * Scan the workspace for all `bsconfig.json` files. If at least one is found, then only folders who have bsconfig.json are returned.
55
- * If none are found, then the workspaceFolder itself is treated as a project
30
+ * Used to filter paths based on include/exclude lists (like .gitignore or vscode's `files.exclude`).
31
+ * This is used to prevent the language server from being overwhelmed by files we don't actually want to handle
56
32
  */
57
- private getProjectPaths;
58
- /**
59
- * Find all folders with bsconfig.json files in them, and treat each as a project.
60
- * Treat workspaces that don't have a bsconfig.json as a project.
61
- * Handle situations where bsconfig.json files were added or removed (to elevate/lower workspaceFolder projects accordingly)
62
- * Leave existing projects alone if they are not affected by these changes
63
- */
64
- private syncProjects;
33
+ private pathFilterer;
34
+ logger: import("@rokucommunity/logger/dist/Logger").Logger;
35
+ constructor();
36
+ run(): void;
65
37
  /**
66
- * Get all workspace paths from the client
38
+ * Called when the client starts initialization
67
39
  */
68
- private getWorkspacePaths;
40
+ onInitialize(params: InitializeParams): HandlerResult<InitializeResult, InitializeError>;
69
41
  /**
70
42
  * Called when the client has finished initializing
71
43
  */
72
- private onInitialized;
44
+ onInitialized(): Promise<void>;
73
45
  /**
74
- * Send a critical failure notification to the client, which should show a notification of some kind
46
+ * Set our logLevel to the most verbose log level found across all projects and workspaces
75
47
  */
76
- private sendCriticalFailure;
48
+ private syncLogLevel;
49
+ private onTextDocumentDidChangeContent;
77
50
  /**
78
- * Wait for all programs' first run to complete
79
- */
80
- private waitAllProjectFirstRuns;
81
- /**
82
- * Event handler for when the program wants to load file contents.
83
- * anytime the program wants to load a file, check with our in-memory document cache first
84
- */
85
- private documentFileResolver;
86
- private getConfigFilePath;
87
- /**
88
- * A unique project counter to help distinguish log entries in lsp mode
89
- */
90
- private projectCounter;
91
- /**
92
- * @param projectPath path to the project
93
- * @param workspacePath path to the workspace in which all project should reside or are referenced by
94
- * @param projectNumber an optional project number to assign to the project. Used when reloading projects that should keep the same number
51
+ * Called when watched files changed (add/change/delete).
52
+ * The CLIENT is in charge of what files to watch, so all client
53
+ * implementations should ensure that all valid project
54
+ * file types are watched (.brs,.bs,.xml,manifest, and any json/text/image files)
95
55
  */
96
- private createProject;
97
- private createStandaloneFileProject;
98
- private getProjects;
56
+ onDidChangeWatchedFiles(params: DidChangeWatchedFilesParams): Promise<void>;
57
+ private onDocumentClose;
99
58
  /**
100
59
  * Provide a list of completion items based on the current cursor position
101
60
  */
102
- private onCompletion;
103
- /**
104
- * Provide a full completion item from the selection
105
- */
106
- private onCompletionResolve;
107
- private onCodeAction;
61
+ onCompletion(params: CompletionParams, cancellationToken: CancellationToken, workDoneProgress: WorkDoneProgressReporter, resultProgress: ResultProgressReporter<CompletionItem[]>): Promise<CompletionList>;
108
62
  /**
109
- * Remove a project from the language server
63
+ * Get a list of workspaces, and their configurations.
64
+ * Get only the settings for the workspace that are relevant to the language server. We do this so we can cache this object for use in change detection in the future.
110
65
  */
111
- private removeProject;
66
+ private getWorkspaceConfigs;
67
+ private workspaceConfigsCache;
68
+ onDidChangeConfiguration(args: DidChangeConfigurationParams): Promise<void>;
69
+ onHover(params: TextDocumentPositionParams): Promise<import("vscode-languageserver-types").Hover>;
70
+ onWorkspaceSymbol(params: WorkspaceSymbolParams): Promise<import("vscode-languageserver-types").WorkspaceSymbol[]>;
71
+ onDocumentSymbol(params: DocumentSymbolParams): Promise<import("vscode-languageserver-types").DocumentSymbol[]>;
72
+ onDefinition(params: TextDocumentPositionParams): Promise<import("vscode-languageserver-types").Location[]>;
73
+ onSignatureHelp(params: SignatureHelpParams): Promise<import("vscode-languageserver-types").SignatureHelp>;
74
+ onReferences(params: ReferenceParams): Promise<import("vscode-languageserver-types").Location[]>;
75
+ private onFullSemanticTokens;
76
+ onCodeAction(params: CodeActionParams): Promise<import("vscode-languageserver-types").CodeAction[]>;
77
+ onExecuteCommand(params: ExecuteCommandParams): Promise<import("./Program").FileTranspileResult>;
112
78
  /**
113
- * Reload each of the specified workspaces
79
+ * Establish a connection to the client if not already connected
114
80
  */
115
- private reloadProjects;
116
- private getRootDir;
81
+ private establishConnection;
117
82
  /**
118
- * Sometimes users will alter their bsconfig files array, and will include standalone files.
119
- * If this is the case, those standalone workspaces should be removed because the file was
120
- * included in an actual program now.
121
- *
122
- * Sometimes files that used to be included are now excluded, so those open files need to be re-processed as standalone
83
+ * Send a new busy status notification to the client based on the current busy status
123
84
  */
124
- private synchronizeStandaloneProjects;
125
- private onDidChangeConfiguration;
85
+ private sendBusyStatus;
86
+ private busyStatusIndex;
87
+ private pathFiltererDisposables;
126
88
  /**
127
- * Called when watched files changed (add/change/delete).
128
- * The CLIENT is in charge of what files to watch, so all client
129
- * implementations should ensure that all valid project
130
- * file types are watched (.brs,.bs,.xml,manifest, and any json/text/image files)
89
+ * Populate the path filterer with the client's include/exclude lists and the projects include lists
90
+ * @returns the instance of the path filterer
131
91
  */
132
- private onDidChangeWatchedFiles;
92
+ private rebuildPathFilterer;
133
93
  /**
134
- * This only operates on files that match the specified files globs, so it is safe to throw
135
- * any file changes you receive with no unexpected side-effects
94
+ * Ask the client for the list of `files.exclude` patterns. Useful when determining if we should process a file
136
95
  */
137
- handleFileChanges(project: Project, changes: {
138
- type: FileChangeType;
139
- srcPath: string;
140
- }[]): Promise<void>;
96
+ private getWorkspaceExcludeGlobs;
141
97
  /**
142
- * This only operates on files that match the specified files globs, so it is safe to throw
143
- * any file changes you receive with no unexpected side-effects
98
+ * Ask the project manager to sync all projects found within the list of workspaces
99
+ * @param forceReload if true, all projects are discarded and recreated from scratch
144
100
  */
145
- private handleFileChange;
146
- private onHover;
147
- private onDocumentClose;
148
- private validateTextDocument;
149
- private validateAll;
150
- onWorkspaceSymbol(params: WorkspaceSymbolParams): Promise<SymbolInformation[]>;
151
- onDocumentSymbol(params: DocumentSymbolParams): Promise<import("vscode-languageserver-types").DocumentSymbol[]>;
152
- private onDefinition;
153
- private onSignatureHelp;
154
- private onReferences;
155
- private onValidateSettled;
156
- private onFullSemanticTokens;
157
- private diagnosticCollection;
158
- private sendDiagnostics;
159
- onExecuteCommand(params: ExecuteCommandParams): Promise<import("./Program").FileTranspileResult>;
160
- private transpileFile;
161
- dispose(): void;
162
- }
163
- export interface Project {
101
+ private syncProjects;
164
102
  /**
165
- * A unique number for this project, generated during this current language server session. Mostly used so we can identify which project is doing logging
103
+ * Given a workspaceFolder path, get the specified configuration from the client (if applicable).
104
+ * Be sure to use optional chaining to traverse the result in case that configuration doesn't exist or the client doesn't support `getConfiguration`
105
+ * @param workspaceFolder the folder for the workspace in the client
166
106
  */
167
- projectNumber: number;
168
- firstRunPromise: Promise<any>;
169
- builder: ProgramBuilder;
107
+ private getClientConfiguration;
170
108
  /**
171
- * The path to where the project resides
109
+ * Send a critical failure notification to the client, which should show a notification of some kind
172
110
  */
173
- projectPath: string;
111
+ private sendCriticalFailure;
174
112
  /**
175
- * The path to the workspace where this project resides. A workspace can have multiple projects (by adding a bsconfig.json to each folder).
113
+ * Send diagnostics to the client
176
114
  */
177
- workspacePath: string;
178
- isFirstRunComplete: boolean;
179
- isFirstRunSuccessful: boolean;
180
- configFilePath?: string;
181
- isStandaloneFileProject: boolean;
115
+ private sendDiagnostics;
116
+ private diagnosticCollection;
117
+ protected dispose(): void;
182
118
  }
183
119
  export declare enum CustomCommands {
184
120
  TranspileFile = "TranspileFile"
@@ -186,3 +122,17 @@ export declare enum CustomCommands {
186
122
  export declare enum NotificationName {
187
123
  busyStatus = "busyStatus"
188
124
  }
125
+ declare type Handler<T> = {
126
+ [K in keyof T as K extends `on${string}` ? K : never]: T[K] extends (arg: infer U) => void ? (arg: U) => void : never;
127
+ };
128
+ export declare type OnHandler<T> = {
129
+ [K in keyof Handler<T>]: Handler<T>[K] extends (arg: infer U) => void ? U : never;
130
+ };
131
+ export declare type WorkspaceConfigWithExtras = WorkspaceConfig & {
132
+ bsconfigPath: string;
133
+ languageServer: {
134
+ enableThreading: boolean;
135
+ logLevel: LogLevel | string | undefined;
136
+ };
137
+ };
138
+ export {};