11import * as vscode from "vscode" ;
22import {
33 type Disposable ,
4+ type DocumentSelector ,
45 type Executable ,
56 LanguageClient ,
67 type LanguageClientOptions ,
@@ -69,8 +70,7 @@ function startClient(
6970 debug : serverOpts ,
7071 } ;
7172
72- // biome-ignore lint/suspicious/noImplicitAnyLet: <explanation>
73- let displayName ;
73+ let displayName : string ;
7474 if ( clientOptions . workspaceFolder ) {
7575 console . log (
7676 `ElixirLS: starting LSP client for ${ clientOptions . workspaceFolder . uri . fsPath } with server options` ,
@@ -320,15 +320,15 @@ export class LanguageClientManager {
320320 folder = vscode . workspace . workspaceFolders [ 0 ] ;
321321 } else {
322322 // no folders - use default client
323- // biome-ignore lint/style/noNonNullAssertion: <explanation>
323+ // biome-ignore lint/style/noNonNullAssertion: a default client is always started when no workspace folders exist
324324 return this . defaultClientPromise ! ;
325325 }
326326 }
327327
328328 // If we have nested workspace folders we only start a server on the outer most workspace folder.
329329 folder = this . _workspaceTracker . getOuterMostWorkspaceFolder ( folder ) ;
330330
331- // biome-ignore lint/style/noNonNullAssertion: <explanation>
331+ // biome-ignore lint/style/noNonNullAssertion: the client promise is set when the workspace folder's client is started
332332 return this . clientsPromises . get ( folder . uri . toString ( ) ) ! ;
333333 }
334334
@@ -399,8 +399,8 @@ export class LanguageClientManager {
399399 folder = this . _workspaceTracker . getOuterMostWorkspaceFolder ( folder ) ;
400400
401401 if ( ! this . clients . has ( folder . uri . toString ( ) ) ) {
402- // biome-ignore lint/suspicious/noImplicitAnyLet: <explanation>
403- let documentSelector ;
402+ // The document selector will be assigned based on workspace mode
403+ let documentSelector : DocumentSelector = defaultDocumentSelector ;
404404 if ( this . _workspaceTracker . mode === WorkspaceMode . MULTI_ROOT ) {
405405 // multi-root workspace
406406 // create document selector with glob pattern that will match files
@@ -450,9 +450,9 @@ export class LanguageClientManager {
450450 const clientsToDispose : LanguageClient [ ] = [ ] ;
451451 let changed = false ;
452452 if ( this . defaultClient ) {
453- // biome-ignore lint/complexity/noForEach: <explanation>
453+ // biome-ignore lint/complexity/noForEach: disposing all registered disposables is easier with forEach
454454 this . defaultClientDisposables ?. forEach ( ( d ) => d . dispose ( ) ) ;
455- // biome-ignore lint/style/noNonNullAssertion: <explanation>
455+ // biome-ignore lint/style/noNonNullAssertion: defaultClientPromise is defined whenever defaultClient is
456456 clientStartPromises . push ( this . defaultClientPromise ! ) ;
457457 clientsToDispose . push ( this . defaultClient ) ;
458458 this . defaultClient = null ;
@@ -462,9 +462,9 @@ export class LanguageClientManager {
462462 }
463463
464464 for ( const [ uri , client ] of this . clients . entries ( ) ) {
465- // biome-ignore lint/complexity/noForEach: <explanation>
465+ // biome-ignore lint/complexity/noForEach: disposing all registered disposables is easier with forEach
466466 this . clientsDisposables . get ( uri ) ?. forEach ( ( d ) => d . dispose ( ) ) ;
467- // biome-ignore lint/style/noNonNullAssertion: <explanation>
467+ // biome-ignore lint/style/noNonNullAssertion: a promise exists for every started client
468468 clientStartPromises . push ( this . clientsPromises . get ( uri ) ! ) ;
469469 clientsToDispose . push ( client ) ;
470470 changed = true ;
@@ -498,9 +498,9 @@ export class LanguageClientManager {
498498 const client = this . clients . get ( uri ) ;
499499 if ( client ) {
500500 console . log ( "ElixirLS: Stopping LSP client for" , folder . uri . fsPath ) ;
501- // biome-ignore lint/complexity/noForEach: <explanation>
501+ // biome-ignore lint/complexity/noForEach: disposing all registered disposables is easier with forEach
502502 this . clientsDisposables . get ( uri ) ?. forEach ( ( d ) => d . dispose ( ) ) ;
503- // biome-ignore lint/style/noNonNullAssertion: <explanation>
503+ // biome-ignore lint/style/noNonNullAssertion: a promise exists for every started client
504504 const clientPromise = this . clientsPromises . get ( uri ) ! ;
505505
506506 this . clients . delete ( uri ) ;
@@ -520,7 +520,7 @@ export class LanguageClientManager {
520520 ) ;
521521 reporter . sendTelemetryErrorEvent ( "language_client_stop_error" , {
522522 "elixir_ls.language_client_stop_error" : String ( e ) ,
523- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
523+ // biome-ignore lint/suspicious/noExplicitAny: error may not be typed, cast to access stack trace
524524 "elixir_ls.language_client_start_error_stack" : ( < any > e ) ?. stack ?? "" ,
525525 } ) ;
526526 }
@@ -531,7 +531,7 @@ export class LanguageClientManager {
531531 console . warn ( "ElixirLS: error during LSP client dispose" , e ) ;
532532 reporter . sendTelemetryErrorEvent ( "language_client_stop_error" , {
533533 "elixir_ls.language_client_stop_error" : String ( e ) ,
534- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
534+ // biome-ignore lint/suspicious/noExplicitAny: error may not be typed, cast to access stack trace
535535 "elixir_ls.language_client_start_error_stack" : ( < any > e ) ?. stack ?? "" ,
536536 } ) ;
537537 }
0 commit comments