-
Notifications
You must be signed in to change notification settings - Fork 686
refactor(amazonq): Improve robustness of lsp installation process #6364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,17 +3,20 @@ | |
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { LspResolver, LspResult } from '../../shared/languageServer/types' | ||
import path from 'path' | ||
import { LspResolution, LspResolver } from '../../shared/languageServer/types' | ||
import { ManifestResolver } from '../../shared/languageServer/manifestResolver' | ||
import { LanguageServerResolver } from '../../shared/languageServer/lspResolver' | ||
import { Range } from 'semver' | ||
import { getNodeExecutableName } from '../../shared/languageServer/utils/platform' | ||
import { fs } from '../../shared/fs/fs' | ||
|
||
const manifestUrl = 'https://aws-toolkit-language-servers.amazonaws.com/q-context/manifest.json' | ||
// this LSP client in Q extension is only going to work with these LSP server versions | ||
const supportedLspServerVersions = '0.1.32' | ||
|
||
export class WorkspaceLSPResolver implements LspResolver { | ||
async resolve(): Promise<LspResult> { | ||
async resolve(): Promise<LspResolution> { | ||
const name = 'AmazonQ-Workspace' | ||
const manifest = await new ManifestResolver(manifestUrl, name).resolve() | ||
const installationResult = await new LanguageServerResolver( | ||
|
@@ -22,7 +25,21 @@ export class WorkspaceLSPResolver implements LspResolver { | |
new Range(supportedLspServerVersions) | ||
).resolve() | ||
|
||
const nodeName = | ||
process.platform === 'win32' ? getNodeExecutableName() : `node-${process.platform}-${process.arch}` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For some reason this idea only exists for the workspace installer. I think the actual standard (which the actual codewhisperer language server uses) is just node.exe/node |
||
const nodePath = path.join(installationResult.assetDirectory, nodeName) | ||
await fs.chmod(nodePath, 0o755) | ||
|
||
// TODO Cleanup old versions of language servers | ||
return installationResult | ||
return { | ||
...installationResult, | ||
executablePaths: { | ||
lsp: path.join( | ||
installationResult.assetDirectory, | ||
`qserver-${process.platform}-${process.arch}/qserver/lspServer.js` | ||
), | ||
node: nodePath, | ||
}, | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/*! | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export function getNodeExecutableName(): string { | ||
return process.platform === 'win32' ? 'node.exe' : 'node' | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we can find a way to use our ChildProcess module, then after #6304 we get instrumentation for free :)