-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(amazonq): Create a common langauge server downloader (#6148)
## Problem - we need a way to download the manifest and install the correct mynah ui/language server code ## Solution - create a common lsp downloader that flare/workspace lsps can use
- Loading branch information
1 parent
4d969a6
commit e193d44
Showing
9 changed files
with
375 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/*! | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { | ||
LspDownloader, | ||
getLogger, | ||
makeTemporaryToolkitFolder, | ||
tryRemoveFolder, | ||
fs, | ||
Manifest, | ||
} from 'aws-core-vscode/shared' | ||
|
||
const manifestURL = 'https://aws-toolkit-language-servers.amazonaws.com/codewhisperer/0/manifest.json' | ||
|
||
export class AmazonQLSPDownloader extends LspDownloader { | ||
constructor( | ||
private readonly serverPath: string, | ||
private readonly clientPath: string | ||
) { | ||
super(manifestURL) | ||
} | ||
|
||
async isLspInstalled(): Promise<boolean> { | ||
return (await fs.exists(this.serverPath)) && (await fs.exists(this.clientPath)) | ||
} | ||
|
||
async cleanup(): Promise<boolean> { | ||
if (await fs.exists(this.serverPath)) { | ||
await tryRemoveFolder(this.serverPath) | ||
} | ||
|
||
if (await fs.exists(this.clientPath)) { | ||
await tryRemoveFolder(this.clientPath) | ||
} | ||
|
||
return true | ||
} | ||
|
||
async install(manifest: Manifest) { | ||
const server = this.getDependency(manifest, 'servers') | ||
const clients = this.getDependency(manifest, 'clients') | ||
if (!server || !clients) { | ||
getLogger('lsp').info(`Did not find LSP URL for ${process.platform} ${process.arch}`) | ||
return false | ||
} | ||
|
||
let tempFolder = undefined | ||
|
||
try { | ||
tempFolder = await makeTemporaryToolkitFolder() | ||
|
||
// download and extract the business logic | ||
await this.downloadAndExtractServer({ | ||
content: server, | ||
installLocation: this.serverPath, | ||
name: 'qdeveloperserver', | ||
tempFolder, | ||
}) | ||
|
||
// download and extract mynah ui | ||
await this.downloadAndExtractServer({ | ||
content: clients, | ||
installLocation: this.clientPath, | ||
name: 'qdeveloperclient', | ||
tempFolder, | ||
}) | ||
} finally { | ||
if (tempFolder) { | ||
await tryRemoveFolder(tempFolder) | ||
} | ||
} | ||
|
||
return true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.