@@ -5,7 +5,6 @@ import { stat } from 'fs/promises';
5
5
import * as https from 'https' ;
6
6
import * as path from 'path' ;
7
7
import { match } from 'ts-pattern' ;
8
- import * as url from 'url' ;
9
8
import { promisify } from 'util' ;
10
9
import { ConfigurationTarget , ExtensionContext , ProgressLocation , window , workspace , WorkspaceFolder } from 'vscode' ;
11
10
import { Logger } from 'vscode-languageclient' ;
@@ -68,7 +67,7 @@ async function callAsync(
68
67
envAdd ?: IEnvVars ,
69
68
callback ?: ProcessCallback
70
69
) : Promise < string > {
71
- let newEnv : IEnvVars = await resolveServerEnvironmentPATH (
70
+ let newEnv : IEnvVars = resolveServerEnvironmentPATH (
72
71
workspace . getConfiguration ( 'haskell' ) . get ( 'serverEnvironment' ) || { }
73
72
) ;
74
73
newEnv = { ...( process . env as IEnvVars ) , ...newEnv , ...( envAdd || { } ) } ;
@@ -135,15 +134,14 @@ async function callAsync(
135
134
/** Gets serverExecutablePath and fails if it's not set.
136
135
*/
137
136
async function findServerExecutable (
138
- context : ExtensionContext ,
139
137
logger : Logger ,
140
138
folder ?: WorkspaceFolder
141
139
) : Promise < string > {
142
140
let exePath = workspace . getConfiguration ( 'haskell' ) . get ( 'serverExecutablePath' ) as string ;
143
141
logger . info ( `Trying to find the server executable in: ${ exePath } ` ) ;
144
142
exePath = resolvePathPlaceHolders ( exePath , folder ) ;
145
143
logger . log ( `Location after path variables substitution: ${ exePath } ` ) ;
146
- if ( await executableExists ( exePath ) ) {
144
+ if ( executableExists ( exePath ) ) {
147
145
return exePath ;
148
146
} else {
149
147
const msg = `Could not find a HLS binary at ${ exePath } ! Consider installing HLS via ghcup or change "haskell.manageHLS" in your settings.` ;
@@ -153,13 +151,13 @@ async function findServerExecutable(
153
151
154
152
/** Searches the PATH. Fails if nothing is found.
155
153
*/
156
- async function findHLSinPATH ( context : ExtensionContext , logger : Logger , folder ?: WorkspaceFolder ) : Promise < string > {
154
+ async function findHLSinPATH ( _context : ExtensionContext , logger : Logger ) : Promise < string > {
157
155
// try PATH
158
156
const exes : string [ ] = [ 'haskell-language-server-wrapper' , 'haskell-language-server' ] ;
159
157
logger . info ( `Searching for server executables ${ exes . join ( ',' ) } in $PATH` ) ;
160
158
logger . info ( `$PATH environment variable: ${ process . env . PATH } ` ) ;
161
159
for ( const exe of exes ) {
162
- if ( await executableExists ( exe ) ) {
160
+ if ( executableExists ( exe ) ) {
163
161
logger . info ( `Found server executable in $PATH: ${ exe } ` ) ;
164
162
return exe ;
165
163
}
@@ -189,7 +187,7 @@ export async function findHaskellLanguageServer(
189
187
logger . info ( 'Finding haskell-language-server' ) ;
190
188
191
189
if ( workspace . getConfiguration ( 'haskell' ) . get ( 'serverExecutablePath' ) as string ) {
192
- const exe = await findServerExecutable ( context , logger , folder ) ;
190
+ const exe = await findServerExecutable ( logger , folder ) ;
193
191
return [ exe , undefined ] ;
194
192
}
195
193
@@ -226,7 +224,7 @@ export async function findHaskellLanguageServer(
226
224
}
227
225
228
226
if ( manageHLS === 'PATH' ) {
229
- const exe = await findHLSinPATH ( context , logger , folder ) ;
227
+ const exe = await findHLSinPATH ( context , logger ) ;
230
228
return [ exe , undefined ] ;
231
229
} else {
232
230
// we manage HLS, make sure ghcup is installed/available
@@ -267,7 +265,7 @@ export async function findHaskellLanguageServer(
267
265
latestStack = await getLatestToolFromGHCup ( context , logger , 'stack' ) ;
268
266
}
269
267
if ( recGHC === undefined ) {
270
- recGHC = ! ( await executableExists ( 'ghc' ) )
268
+ recGHC = ! ( executableExists ( 'ghc' ) )
271
269
? await getLatestAvailableToolFromGHCup ( context , logger , 'ghc' , 'recommended' )
272
270
: null ;
273
271
}
@@ -407,7 +405,7 @@ export async function findHaskellLanguageServer(
407
405
if ( projectHls ) {
408
406
return [ path . join ( hlsBinDir , `haskell-language-server-wrapper${ exeExt } ` ) , hlsBinDir ] ;
409
407
} else {
410
- const exe = await findHLSinPATH ( context , logger , folder ) ;
408
+ const exe = await findHLSinPATH ( context , logger ) ;
411
409
return [ exe , hlsBinDir ] ;
412
410
}
413
411
}
@@ -470,8 +468,8 @@ async function getLatestProjectHLS(
470
468
const merged = new Map < string , string [ ] > ( [ ...metadataMap , ...ghcupMap ] ) ; // right-biased
471
469
// now sort and get the latest suitable version
472
470
const latest = [ ...merged ]
473
- . filter ( ( [ k , v ] ) => v . some ( ( x ) => x === projectGhc ) )
474
- . sort ( ( [ k1 , v1 ] , [ k2 , v2 ] ) => comparePVP ( k1 , k2 ) )
471
+ . filter ( ( [ _k , v ] ) => v . some ( ( x ) => x === projectGhc ) )
472
+ . sort ( ( [ k1 , _v1 ] , [ k2 , _v2 ] ) => comparePVP ( k1 , k2 ) )
475
473
. pop ( ) ;
476
474
477
475
if ( ! latest ) {
@@ -484,7 +482,7 @@ async function getLatestProjectHLS(
484
482
/**
485
483
* Obtain the project ghc version from the HLS - Wrapper (which must be in PATH now).
486
484
* Also, serves as a sanity check.
487
- * @param wrapper Path to the Haskell-Language-Server wrapper
485
+ * @param toolchainBindir Path to the toolchainn bin directory (added to PATH)
488
486
* @param workingDir Directory to run the process, usually the root of the workspace.
489
487
* @param logger Logger for feedback.
490
488
* @returns The GHC version, or fail with an `Error`.
@@ -499,7 +497,7 @@ export async function getProjectGHCVersion(
499
497
500
498
const args = [ '--project-ghc-version' ] ;
501
499
502
- const newPath = await addPathToProcessPath ( toolchainBindir , logger ) ;
500
+ const newPath = await addPathToProcessPath ( toolchainBindir ) ;
503
501
const environmentNew : IEnvVars = {
504
502
PATH : newPath ,
505
503
} ;
@@ -550,14 +548,14 @@ export async function upgradeGHCup(context: ExtensionContext, logger: Logger): P
550
548
}
551
549
}
552
550
553
- export async function findGHCup ( context : ExtensionContext , logger : Logger , folder ?: WorkspaceFolder ) : Promise < string > {
551
+ export async function findGHCup ( _context : ExtensionContext , logger : Logger , folder ?: WorkspaceFolder ) : Promise < string > {
554
552
logger . info ( 'Checking for ghcup installation' ) ;
555
553
let exePath = workspace . getConfiguration ( 'haskell' ) . get ( 'ghcupExecutablePath' ) as string ;
556
554
if ( exePath ) {
557
555
logger . info ( `Trying to find the ghcup executable in: ${ exePath } ` ) ;
558
556
exePath = resolvePathPlaceHolders ( exePath , folder ) ;
559
557
logger . log ( `Location after path variables substitution: ${ exePath } ` ) ;
560
- if ( await executableExists ( exePath ) ) {
558
+ if ( executableExists ( exePath ) ) {
561
559
return exePath ;
562
560
} else {
563
561
throw new Error ( `Could not find a ghcup binary at ${ exePath } !` ) ;
@@ -684,8 +682,8 @@ async function toolInstalled(
684
682
version : string
685
683
) : Promise < InstalledTool > {
686
684
const b = await callGHCup ( context , logger , [ 'whereis' , tool , version ] , undefined , false )
687
- . then ( ( x ) => true )
688
- . catch ( ( x ) => false ) ;
685
+ . then ( ( _x ) => true )
686
+ . catch ( ( _x ) => false ) ;
689
687
return new InstalledTool ( tool , version , b ) ;
690
688
}
691
689
@@ -737,7 +735,7 @@ export type ReleaseMetadata = Map<string, Map<string, Map<string, string[]>>>;
737
735
*/
738
736
async function getHLSesfromMetadata ( context : ExtensionContext , logger : Logger ) : Promise < Map < string , string [ ] > | null > {
739
737
const storagePath : string = await getStoragePath ( context ) ;
740
- const metadata = await getReleaseMetadata ( context , storagePath , logger ) . catch ( ( e ) => null ) ;
738
+ const metadata = await getReleaseMetadata ( context , storagePath , logger ) . catch ( ( _e ) => null ) ;
741
739
if ( ! metadata ) {
742
740
window . showErrorMessage ( 'Could not get release metadata' ) ;
743
741
return null ;
@@ -803,23 +801,23 @@ export function findSupportedHlsPerGhc(
803
801
/**
804
802
* Download GHCUP metadata.
805
803
*
806
- * @param context Extension context.
804
+ * @param _context Extension context.
807
805
* @param storagePath Path to put in binary files and caches.
808
806
* @param logger Logger for feedback.
809
807
* @returns Metadata of releases, or null if the cache can not be found.
810
808
*/
811
809
async function getReleaseMetadata (
812
- context : ExtensionContext ,
810
+ _context : ExtensionContext ,
813
811
storagePath : string ,
814
812
logger : Logger
815
813
) : Promise < ReleaseMetadata | null > {
816
814
const releasesUrl = workspace . getConfiguration ( 'haskell' ) . releasesURL
817
- ? url . parse ( workspace . getConfiguration ( 'haskell' ) . releasesURL )
815
+ ? new URL ( workspace . getConfiguration ( 'haskell' ) . releasesURL )
818
816
: undefined ;
819
817
const opts : https . RequestOptions = releasesUrl
820
818
? {
821
819
host : releasesUrl . host ,
822
- path : releasesUrl . path ,
820
+ path : releasesUrl . pathname ,
823
821
}
824
822
: {
825
823
host : 'raw.githubusercontent.com' ,
0 commit comments