Skip to content

Commit 7868bb7

Browse files
committed
tst
1 parent c3d79f4 commit 7868bb7

File tree

3 files changed

+61
-28
lines changed

3 files changed

+61
-28
lines changed

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLspService.kt

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -373,34 +373,34 @@ private class AmazonQServerInstance(private val project: Project, private val cs
373373

374374
val node = if (SystemInfo.isWindows) "node.exe" else "node"
375375
val cmd = NodeExePatcher.patch(artifact.resolve(node))
376-
.withParameters(
377-
LspSettings.getInstance().getArtifactPath() ?: artifact.resolve("aws-lsp-codewhisperer.js").toString(),
378-
"--stdio",
379-
"--set-credentials-encryption-key",
380-
).withEnvironment(
381-
buildMap {
382-
put("NODE_EXTRA_CA_CERTS", extraCaCerts.toAbsolutePath().toString())
383-
384-
val proxy = JdkProxyProvider.getInstance().proxySelector.select(qUri)
385-
// log if only socks proxy available
386-
.firstOrNull { it.type() == Proxy.Type.HTTP }
387-
388-
if (proxy != null) {
389-
val address = proxy.address()
390-
if (address is java.net.InetSocketAddress) {
391-
put(
392-
"HTTPS_PROXY",
393-
URIBuilder("http://${address.hostName}:${address.port}").apply {
394-
val login = HttpConfigurable.getInstance().proxyLogin
395-
if (login != null) {
396-
setUserInfo(login, HttpConfigurable.getInstance().plainProxyPassword)
397-
}
398-
}.build().toASCIIString()
399-
)
376+
.withParameters(
377+
LspSettings.getInstance().getArtifactPath() ?: artifact.resolve("aws-lsp-codewhisperer.js").toString(),
378+
"--stdio",
379+
"--set-credentials-encryption-key",
380+
).withEnvironment(
381+
buildMap {
382+
put("NODE_EXTRA_CA_CERTS", extraCaCerts.toAbsolutePath().toString())
383+
384+
val proxy = JdkProxyProvider.getInstance().proxySelector.select(qUri)
385+
// log if only socks proxy available
386+
.firstOrNull { it.type() == Proxy.Type.HTTP }
387+
388+
if (proxy != null) {
389+
val address = proxy.address()
390+
if (address is java.net.InetSocketAddress) {
391+
put(
392+
"HTTPS_PROXY",
393+
URIBuilder("http://${address.hostName}:${address.port}").apply {
394+
val login = HttpConfigurable.getInstance().proxyLogin
395+
if (login != null) {
396+
setUserInfo(login, HttpConfigurable.getInstance().plainProxyPassword)
397+
}
398+
}.build().toASCIIString()
399+
)
400+
}
400401
}
401402
}
402-
}
403-
)
403+
)
404404
.withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.CONSOLE)
405405

406406
launcherHandler = KillableColoredProcessHandler.Silent(cmd)

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/NodeExePatcher.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import java.nio.file.Path
1414
* @see https://github.com/aws/aws-toolkit-vscode/commit/6081f890bdbb91fcd8b60c4cc0abb65b15d4a38d
1515
*/
1616
object NodeExePatcher {
17-
private const val GLIBC_LINKER_VAR = "VSCODE_SERVER_CUSTOM_GLIBC_LINKER"
18-
private const val GLIBC_PATH_VAR = "VSCODE_SERVER_CUSTOM_GLIBC_PATH"
17+
const val GLIBC_LINKER_VAR = "VSCODE_SERVER_CUSTOM_GLIBC_LINKER"
18+
const val GLIBC_PATH_VAR = "VSCODE_SERVER_CUSTOM_GLIBC_PATH"
1919

2020
fun patch(node: Path): GeneralCommandLine {
2121
val linker = System.getenv(GLIBC_LINKER_VAR)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package software.aws.toolkits.jetbrains.services.amazonq.lsp
5+
6+
import com.intellij.execution.configurations.GeneralCommandLine
7+
import org.assertj.core.api.Assertions.assertThat
8+
import org.junit.Rule
9+
import org.junit.Test
10+
import software.aws.toolkits.core.rules.EnvironmentVariableHelper
11+
import kotlin.io.path.Path
12+
13+
class NodeExePatcherTest {
14+
@get:Rule
15+
val envVarHelper = EnvironmentVariableHelper()
16+
17+
@Test
18+
fun `patches if path available`() {
19+
envVarHelper[NodeExePatcher.GLIBC_LINKER_VAR] = "/opt/vsc-sysroot/lib/ld-linux-x86-64.so.2"
20+
envVarHelper[NodeExePatcher.GLIBC_PATH_VAR] = "/opt/vsc-sysroot/lib/"
21+
22+
assertThat(NodeExePatcher.patch(Path("/path/to/node")))
23+
.usingComparator(Comparator.comparing { it.commandLineString })
24+
.isEqualTo(GeneralCommandLine("/opt/vsc-sysroot/lib/ld-linux-x86-64.so.2", "--library-path", "/opt/vsc-sysroot/lib/", "/path/to/node"))
25+
}
26+
27+
@Test
28+
fun `noop if no patch available`() {
29+
assertThat(NodeExePatcher.patch(Path("/path/to/node")))
30+
.usingComparator(Comparator.comparing { it.commandLineString })
31+
.isEqualTo(GeneralCommandLine("/path/to/node"))
32+
}
33+
}

0 commit comments

Comments
 (0)