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