Skip to content

Commit 3685f9e

Browse files
committed
WIP: rename and get rid of unused await's
1 parent 8adb6d5 commit 3685f9e

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/hlsBinaries.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,22 @@ export async function callAsync(
139139

140140
/** Gets serverExecutablePath and fails if it's not set.
141141
*/
142-
async function findServerExecutable(logger: Logger, folder?: WorkspaceFolder): Promise<string> {
143-
let exePath = workspace.getConfiguration('haskell').get('serverExecutablePath') as string;
144-
logger.info(`Trying to find the server executable in: ${exePath}`);
145-
exePath = resolvePathPlaceHolders(exePath, folder);
146-
logger.log(`Location after path variables substitution: ${exePath}`);
147-
if (executableExists(exePath)) {
148-
return exePath;
142+
function findServerExecutable(logger: Logger, folder?: WorkspaceFolder): string {
143+
const rawExePath = workspace.getConfiguration('haskell').get('serverExecutablePath') as string;
144+
logger.info(`Trying to find the server executable in: ${rawExePath}`);
145+
const resolvedExePath = resolvePathPlaceHolders(rawExePath, folder);
146+
logger.log(`Location after path variables substitution: ${resolvedExePath}`);
147+
if (executableExists(resolvedExePath)) {
148+
return resolvedExePath;
149149
} else {
150-
const msg = `Could not find a HLS binary at ${exePath}! Consider installing HLS via ghcup or change "haskell.manageHLS" in your settings.`;
151-
throw new Error(msg);
150+
const msg = `Could not find a HLS binary at ${resolvedExePath}! Consider installing HLS via ghcup or change "haskell.manageHLS" in your settings.`;
151+
throw new HlsError(msg);
152152
}
153153
}
154154

155155
/** Searches the PATH. Fails if nothing is found.
156156
*/
157-
async function findHLSinPATH(_context: ExtensionContext, logger: Logger): Promise<string> {
157+
function findHlsInPath(_context: ExtensionContext, logger: Logger): string {
158158
// try PATH
159159
const exes: string[] = ['haskell-language-server-wrapper', 'haskell-language-server'];
160160
logger.info(`Searching for server executables ${exes.join(',')} in $PATH`);
@@ -210,16 +210,16 @@ export async function findHaskellLanguageServer(
210210
): Promise<HlsExecutable> {
211211
logger.info('Finding haskell-language-server');
212212

213-
if (workspace.getConfiguration('haskell').get('serverExecutablePath') as string) {
214-
const exe = await findServerExecutable(logger, folder);
213+
const hasConfigForExecutable = workspace.getConfiguration('haskell').get('serverExecutablePath') as string;
214+
if (hasConfigForExecutable) {
215+
const exe = findServerExecutable(logger, folder);
215216
return {
216217
location: exe,
217218
tag: 'config',
218219
};
219220
}
220221

221-
const storagePath: string = await getStoragePath(context);
222-
222+
const storagePath: string = getStoragePath(context);
223223
if (!fs.existsSync(storagePath)) {
224224
fs.mkdirSync(storagePath);
225225
}
@@ -228,7 +228,7 @@ export async function findHaskellLanguageServer(
228228
manageHLS = await promptUserForManagingHls(context, manageHLS);
229229

230230
if (manageHLS === 'PATH') {
231-
const exe = await findHLSinPATH(context, logger);
231+
const exe = findHlsInPath(context, logger);
232232
return {
233233
location: exe,
234234
tag: 'path',
@@ -512,7 +512,7 @@ async function getLatestProjectHLS(
512512
: await callAsync(`ghc${exeExt}`, ['--numeric-version'], logger, undefined, undefined, false);
513513

514514
// first we get supported GHC versions from available HLS bindists (whether installed or not)
515-
const metadataMap = (await getHLSesfromMetadata(context, logger)) || new Map<string, string[]>();
515+
const metadataMap = (await getHlsMetadata(context, logger)) || new Map<string, string[]>();
516516
// then we get supported GHC versions from currently installed HLS versions
517517
const ghcupMap = (await getHLSesFromGHCup(context, logger)) || new Map<string, string[]>();
518518
// since installed HLS versions may support a different set of GHC versions than the bindists
@@ -657,8 +657,8 @@ export async function findGHCup(_context: ExtensionContext, logger: Logger, fold
657657
}
658658
}
659659

660-
export async function getStoragePath(context: ExtensionContext): Promise<string> {
661-
let storagePath: string | undefined = await workspace.getConfiguration('haskell').get('releasesDownloadStoragePath');
660+
export function getStoragePath(context: ExtensionContext): string {
661+
let storagePath: string | undefined = workspace.getConfiguration('haskell').get('releasesDownloadStoragePath');
662662

663663
if (!storagePath) {
664664
storagePath = context.globalStorageUri.fsPath;
@@ -838,8 +838,8 @@ export type ReleaseMetadata = Map<string, Map<string, Map<string, string[]>>>;
838838
* @param logger Logger for feedback
839839
* @returns Map of supported HLS versions or null if metadata could not be fetched.
840840
*/
841-
async function getHLSesfromMetadata(context: ExtensionContext, logger: Logger): Promise<Map<string, string[]> | null> {
842-
const storagePath: string = await getStoragePath(context);
841+
async function getHlsMetadata(context: ExtensionContext, logger: Logger): Promise<Map<string, string[]> | null> {
842+
const storagePath: string = getStoragePath(context);
843843
const metadata = await getReleaseMetadata(context, storagePath, logger).catch(() => null);
844844
if (!metadata) {
845845
window.showErrorMessage('Could not get release metadata');

0 commit comments

Comments
 (0)