@@ -139,29 +139,27 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
139
139
// Create the language client
140
140
return new LanguageClient ( id , name , serverOptions , clientOptions ) ;
141
141
}
142
+
142
143
// Create the GPR language client and start it.
143
144
const gprClient = createClient ( 'gpr' , 'GPR Language Server' , [ '--language-gpr' ] , '**/.{gpr}' ) ;
144
145
context . subscriptions . push ( gprClient . start ( ) ) ;
146
+
145
147
// Create the Ada language client and start it.
146
- const client = createClient ( 'ada' , 'Ada Language Server' , [ ] , '**/.{adb,ads,adc,ada}' ) ;
148
+ const alsClient = createClient ( 'ada' , 'Ada Language Server' , [ ] , '**/.{adb,ads,adc,ada}' ) ;
147
149
const alsMiddleware : Middleware = {
148
- executeCommand : alsCommandExecutor ( client ) ,
150
+ executeCommand : alsCommandExecutor ( alsClient ) ,
149
151
} ;
150
- client . clientOptions . middleware = alsMiddleware ;
151
- client . registerFeature ( new ALSClientFeatures ( ) ) ;
152
-
153
- const disposable = client . start ( ) ;
154
- // Push the disposable to the context's subscriptions so that the
155
- // client can be deactivated on extension deactivation
156
- context . subscriptions . push ( disposable ) ;
152
+ alsClient . clientOptions . middleware = alsMiddleware ;
153
+ alsClient . registerFeature ( new ALSClientFeatures ( ) ) ;
154
+ context . subscriptions . push ( gprClient . start ( ) ) ;
157
155
158
156
// Take active editor URI and call execute 'als-other-file' command in LSP
159
157
function otherFileHandler ( ) {
160
158
const activeEditor = vscode . window . activeTextEditor ;
161
159
if ( ! activeEditor ) {
162
160
return ;
163
161
}
164
- void client . sendRequest ( ExecuteCommandRequest . type , {
162
+ void alsClient . sendRequest ( ExecuteCommandRequest . type , {
165
163
command : 'als-other-file' ,
166
164
arguments : [
167
165
{
@@ -205,69 +203,66 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
205
203
// projects' source directories are not placed under the root project's directory).
206
204
// Do nothing is the user did not setup any workspace file.
207
205
if ( vscode . workspace . workspaceFile !== undefined ) {
208
- await client . onReady ( ) . then ( async ( ) => {
209
- await client
210
- . sendRequest < [ ALSSourceDirDescription ] > ( 'workspace/alsSourceDirs' )
211
- . then ( async ( source_dirs ) => {
212
- const workspace_folders = vscode . workspace . workspaceFolders ?? [ ] ;
213
- const workspace_dirs_to_add : { uri : vscode . Uri ; name ?: string | undefined } [ ] =
214
- [ ] ;
206
+ await alsClient
207
+ . sendRequest < [ ALSSourceDirDescription ] > ( 'workspace/alsSourceDirs' )
208
+ . then ( async ( source_dirs ) => {
209
+ const workspace_folders = vscode . workspace . workspaceFolders ?? [ ] ;
210
+ const workspace_dirs_to_add : { uri : vscode . Uri ; name ?: string | undefined } [ ] = [ ] ;
215
211
216
- for ( const source_dir of source_dirs ) {
217
- const source_dir_uri = vscode . Uri . parse ( source_dir . uri ) ;
218
- const source_dir_path = source_dir_uri . path ;
212
+ for ( const source_dir of source_dirs ) {
213
+ const source_dir_uri = vscode . Uri . parse ( source_dir . uri ) ;
214
+ const source_dir_path = source_dir_uri . path ;
219
215
220
- const is_subdirectory = ( dir : string , parent : string ) => {
221
- // Use lower-case on Windows since drives can be specified in VS Code
222
- // either with lower or upper case characters.
223
- if ( process . platform == 'win32' ) {
224
- dir = dir . toLowerCase ( ) ;
225
- parent = parent . toLowerCase ( ) ;
226
- }
216
+ const is_subdirectory = ( dir : string , parent : string ) => {
217
+ // Use lower-case on Windows since drives can be specified in VS Code
218
+ // either with lower or upper case characters.
219
+ if ( process . platform == 'win32' ) {
220
+ dir = dir . toLowerCase ( ) ;
221
+ parent = parent . toLowerCase ( ) ;
222
+ }
227
223
228
- return dir . startsWith ( parent + '/' ) ;
229
- } ;
224
+ return dir . startsWith ( parent + '/' ) ;
225
+ } ;
230
226
231
- // If the source directory is not under one of the workspace folders, push
232
- // this source directory to the workspace folders to add later.
233
- if (
234
- ! workspace_folders . some ( ( workspace_folder ) =>
235
- is_subdirectory ( source_dir_path , workspace_folder . uri . path )
236
- )
237
- ) {
238
- workspace_dirs_to_add . push ( {
239
- name : source_dir . name ,
240
- uri : source_dir_uri ,
241
- } ) ;
242
- }
227
+ // If the source directory is not under one of the workspace folders, push
228
+ // this source directory to the workspace folders to add later.
229
+ if (
230
+ ! workspace_folders . some ( ( workspace_folder ) =>
231
+ is_subdirectory ( source_dir_path , workspace_folder . uri . path )
232
+ )
233
+ ) {
234
+ workspace_dirs_to_add . push ( {
235
+ name : source_dir . name ,
236
+ uri : source_dir_uri ,
237
+ } ) ;
243
238
}
239
+ }
244
240
245
- // If there are some source directories missing in the workspace, ask the user
246
- // to add them in his workspace.
247
- if ( workspace_dirs_to_add . length > 0 ) {
248
- await vscode . window
249
- . showInformationMessage (
250
- 'Some project source directories are not ' +
251
- 'listed in your workspace: do you want to add them?' ,
252
- 'Yes' ,
253
- 'No'
254
- )
255
- . then ( ( answer ) => {
256
- if ( answer === 'Yes' ) {
257
- for ( const workspace_dir of workspace_dirs_to_add ) {
258
- vscode . workspace . updateWorkspaceFolders (
259
- vscode . workspace . workspaceFolders
260
- ? vscode . workspace . workspaceFolders . length
261
- : 0 ,
262
- null ,
263
- workspace_dir
264
- ) ;
265
- }
241
+ // If there are some source directories missing in the workspace, ask the user
242
+ // to add them in his workspace.
243
+ if ( workspace_dirs_to_add . length > 0 ) {
244
+ await vscode . window
245
+ . showInformationMessage (
246
+ 'Some project source directories are not ' +
247
+ 'listed in your workspace: do you want to add them?' ,
248
+ 'Yes' ,
249
+ 'No'
250
+ )
251
+ . then ( ( answer ) => {
252
+ if ( answer === 'Yes' ) {
253
+ for ( const workspace_dir of workspace_dirs_to_add ) {
254
+ vscode . workspace . updateWorkspaceFolders (
255
+ vscode . workspace . workspaceFolders
256
+ ? vscode . workspace . workspaceFolders . length
257
+ : 0 ,
258
+ null ,
259
+ workspace_dir
260
+ ) ;
266
261
}
267
- } ) ;
268
- }
269
- } ) ;
270
- } ) ;
262
+ }
263
+ } ) ;
264
+ }
265
+ } ) ;
271
266
}
272
267
}
273
268
0 commit comments