Skip to content

Commit c6afcb6

Browse files
refactor(amazonq): Change Q LSP downloading message text (#7185)
## PROBLEM: When installing the LSP for Q we get a message that says `"Installing 'Amazon Q' language server"`, but they want it to be slightly different (`"Updating Amazon Q plugin"`). The issue is the base class for the lsp installer class has a generic message that is not easy to customize. ## SOLUTION: Allow an override downloading message to be defined in each specific LspInstaller implementation. This message is then routed in to the LspResolver (the thing that downloads the Lsp), and the message is displayed here. This override message will show when the download is happening. Everyone is happy. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license. Signed-off-by: nkomonen-amazon <[email protected]>
1 parent 2f103ff commit c6afcb6

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

packages/amazonq/src/lsp/lspInstaller.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ export class AmazonQLspInstaller extends BaseLspInstaller.BaseLspInstaller<
4040
ui: path.join(assetDirectory, 'clients/amazonq-ui.js'),
4141
}
4242
}
43+
44+
protected override downloadMessageOverride: string | undefined = 'Updating Amazon Q plugin'
4345
}

packages/core/src/shared/lsp/baseLspInstaller.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ export abstract class BaseLspInstaller<T extends ResourcePaths = ResourcePaths,
4444
id,
4545
new Range(supportedVersions, {
4646
includePrerelease: true,
47-
})
47+
}),
48+
this.downloadMessageOverride
4849
).resolve()
4950

5051
const assetDirectory = installationResult.assetDirectory
@@ -75,6 +76,12 @@ export abstract class BaseLspInstaller<T extends ResourcePaths = ResourcePaths,
7576
return r
7677
}
7778

79+
/**
80+
* Allows implementations of this class to set a custom message to show users
81+
* when the artifacts are being downloaded. If not set, a default message will be shown.
82+
*/
83+
protected downloadMessageOverride: string | undefined = undefined
84+
7885
protected abstract postInstall(assetDirectory: string): Promise<void>
7986
protected abstract resourcePaths(assetDirectory?: string): T
8087
}

packages/core/src/shared/lsp/lspResolver.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,20 @@ import vscode from 'vscode'
2323
const remoteDownloadTimeout = oneMinute * 30
2424

2525
export class LanguageServerResolver {
26+
private readonly downloadMessage: string
27+
2628
constructor(
2729
private readonly manifest: Manifest,
2830
private readonly lsName: string,
2931
private readonly versionRange: semver.Range,
32+
/**
33+
* Custom message to show user when downloading, if undefined it will use the default.
34+
*/
35+
downloadMessage?: string,
3036
private readonly _defaultDownloadFolder?: string
31-
) {}
37+
) {
38+
this.downloadMessage = downloadMessage ?? `Updating '${this.lsName}' language server`
39+
}
3240

3341
/**
3442
* Downloads and sets up the Language Server, attempting different locations in order:
@@ -109,7 +117,7 @@ export class LanguageServerResolver {
109117
const timeout = new Timeout(remoteDownloadTimeout)
110118
void showProgressWithTimeout(
111119
{
112-
title: `Downloading '${this.lsName}' language server`,
120+
title: this.downloadMessage,
113121
location: vscode.ProgressLocation.Notification,
114122
cancellable: false,
115123
},

0 commit comments

Comments
 (0)