Skip to content

Commit 1b26f0c

Browse files
author
tomzu
committed
feat: status bar message for LSP downlaod
1 parent 25006e3 commit 1b26f0c

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

packages/core/src/amazonq/lsp/lspController.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import { fs, globals, ToolkitError } from '../../shared'
2222
import { isWeb } from '../../shared/extensionGlobals'
2323
import { getUserAgent } from '../../shared/telemetry/util'
2424
import { isAmazonInternalOs } from '../../shared/vscode/env'
25+
//import * as nls from 'vscode-nls'
26+
//const localize = nls.loadMessageBundle()
2527

2628
export interface Chunk {
2729
readonly filePath: string
@@ -219,13 +221,15 @@ export class LspController {
219221
return true
220222
}
221223

222-
async tryInstallLsp(context: vscode.ExtensionContext): Promise<boolean> {
224+
async tryInstallLsp(context: vscode.ExtensionContext, forceReset = false): Promise<boolean> {
225+
let status = undefined
223226
let tempFolder = undefined
224227
try {
225-
if (await this.isLspInstalled(context)) {
228+
if ((await this.isLspInstalled(context)) && !forceReset) {
226229
getLogger().info(`LspController: LSP already installed`)
227230
return true
228231
}
232+
status = vscode.window.setStatusBarMessage('LspController: Installing LSP ...')
229233
// clean up previous downloaded LSP
230234
const qserverPath = context.asAbsolutePath(path.join('resources', 'qserver'))
231235
if (await fs.exists(qserverPath)) {
@@ -265,6 +269,7 @@ export class LspController {
265269
}
266270
await fs.chmod(nodeRuntimeTempPath, 0o755)
267271
await fs.rename(nodeRuntimeTempPath, nodeRuntimePath)
272+
getLogger().info(`LspController: LSP successfully installed`)
268273
return true
269274
} catch (e) {
270275
getLogger().error(`LspController: Failed to setup LSP server ${e}`)
@@ -274,6 +279,9 @@ export class LspController {
274279
if (tempFolder) {
275280
await tryRemoveFolder(tempFolder)
276281
}
282+
if (status) {
283+
status.dispose()
284+
}
277285
}
278286
}
279287

packages/core/src/dev/activation.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { NotificationsController } from '../notifications/controller'
2525
import { DevNotificationsState } from '../notifications/types'
2626
import { QuickPickItem } from 'vscode'
2727
import { ChildProcess } from '../shared/utilities/processUtils'
28+
import { LspController } from '../amazonq'
2829

2930
interface MenuOption {
3031
readonly label: string
@@ -464,6 +465,12 @@ const resettableFeatures: readonly ResettableFeature[] = [
464465
detail: 'Resets memory/global state for the notifications panel (includes dismissed, onReceive).',
465466
executor: resetNotificationsState,
466467
},
468+
{
469+
name: 'lsp',
470+
label: 'Lsp',
471+
detail: 'Resets (uninstall & reinstall) LSP',
472+
executor: resetLspDownload,
473+
},
467474
] as const
468475

469476
// TODO this is *somewhat* similar to `openStorageFromInput`. If we need another
@@ -552,6 +559,10 @@ async function resetNotificationsState() {
552559
await targetNotificationsController.reset()
553560
}
554561

562+
async function resetLspDownload() {
563+
await LspController.instance.tryInstallLsp(targetContext, true)
564+
}
565+
555566
async function editNotifications() {
556567
const storageKey = 'aws.notifications.dev'
557568
const current = globalState.get(storageKey) ?? {}

0 commit comments

Comments
 (0)