Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@ class CodeWhispererConfigurable(private val project: Project) :
.resizableColumn()
.align(Align.FILL)
}
row(message("amazonqFeatureDev.placeholder.node_runtime_path")) {
val fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFileDescriptor()
fileChooserDescriptor.isForcedToUseIdeaFileChooser = true

textFieldWithBrowseButton(fileChooserDescriptor = fileChooserDescriptor)
.bindText(
{ LspSettings.getInstance().getNodeRuntimePath().orEmpty() },
{ LspSettings.getInstance().setNodeRuntimePath(it) }
)
.applyToComponent {
emptyText.text = message("executableCommon.auto_managed")
}
.resizableColumn()
.align(Align.FILL)
}
}

group(message("aws.settings.codewhisperer.group.general")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
import com.intellij.execution.process.ProcessEvent
import com.intellij.execution.process.ProcessListener
import com.intellij.execution.process.ProcessOutputType
import com.intellij.notification.NotificationAction
import com.intellij.openapi.Disposable
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.components.serviceIfCreated
import com.intellij.openapi.options.ShowSettingsUtil
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.Key
Expand Down Expand Up @@ -76,6 +78,8 @@
import software.aws.toolkits.jetbrains.services.amazonq.profile.QDefaultServiceConfig
import software.aws.toolkits.jetbrains.services.telemetry.ClientMetadata
import software.aws.toolkits.jetbrains.settings.LspSettings
import software.aws.toolkits.jetbrains.utils.notifyInfo
import software.aws.toolkits.resources.message
import java.io.IOException
import java.io.OutputStreamWriter
import java.io.PipedInputStream
Expand All @@ -84,6 +88,7 @@
import java.io.StringWriter
import java.net.Proxy
import java.net.URI
import java.nio.file.Path
import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.util.concurrent.Future
Expand Down Expand Up @@ -372,7 +377,36 @@
}

val node = if (SystemInfo.isWindows) "node.exe" else "node"
val cmd = NodeExePatcher.patch(artifact.resolve(node))
var nodePath = artifact.resolve(node)
// download node runtime is not found
if (!Files.exists(nodePath) || !Files.isExecutable(nodePath)) {
LOG.warn() { "Node Runtime download failed. Fallback to user specified node runtime " }

Check notice on line 383 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLspService.kt

View workflow job for this annotation

GitHub Actions / qodana

Unnecessary parentheses in function call with lambda

Unnecessary parentheses in function call with lambda
// attempt to use user provided node runtime path
val nodeRuntime = LspSettings.getInstance().getNodeRuntimePath()
if (!nodeRuntime.isNullOrEmpty()) {
nodePath = Path.of(nodeRuntime)
} else {
notifyInfo(
"Amazon Q",
message("amazonqFeatureDev.placeholder.node_runtime_message"),
project = project,
listOf(
NotificationAction.create(
message("codewhisperer.actions.open_settings.title")

Check warning on line 395 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLspService.kt

View workflow job for this annotation

GitHub Actions / qodana

Incorrect string capitalization

String 'Open Settings' is not properly capitalized. It should have sentence capitalization
) { _, notification ->
ShowSettingsUtil.getInstance().showSettingsDialog(project, CodeWhispererConfigurable::class.java)
},
NotificationAction.create(
message("codewhisperer.notification.custom.simple.button.got_it")
) { _, notification -> notification.expire() }
)
)

}

}

val cmd = NodeExePatcher.patch(nodePath)
.withParameters(
LspSettings.getInstance().getArtifactPath() ?: artifact.resolve("aws-lsp-codewhisperer.js").toString(),
"--stdio",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,22 @@ class LspSettings : PersistentStateComponent<LspConfiguration> {

fun getArtifactPath() = state.artifactPath

fun getNodeRuntimePath() = state.nodeRuntimePath

fun setArtifactPath(artifactPath: String?) {
state.artifactPath = artifactPath.nullize(nullizeSpaces = true)
}

fun setNodeRuntimePath(nodeRuntimePath: String?) {
state.nodeRuntimePath = nodeRuntimePath.nullize(nullizeSpaces = true)
}

companion object {
fun getInstance(): LspSettings = service()
}
}

class LspConfiguration : BaseState() {
var artifactPath by string()
var nodeRuntimePath by string()
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ amazonqFeatureDev.placeholder.lsp=LSP
amazonqFeatureDev.placeholder.new_plan=Describe your task or issue in as much detail as possible
amazonqFeatureDev.placeholder.provide_code_feedback=Provide feedback or comments
amazonqFeatureDev.placeholder.select_lsp_artifact=Select LSP Artifact
amazonqFeatureDev.placeholder.node_runtime_path=Node Runtime Path
amazonqFeatureDev.placeholder.node_runtime_message=Absolute path of your node js v18+ runtime executable.
amazonqFeatureDev.placeholder.write_new_prompt=Write a new prompt
apprunner.action.configure=Configure Service
apprunner.action.create.service=Create Service...
Expand Down
Loading