Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 9 additions & 1 deletion packages/core/src/amazonqGumby/chat/controller/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,14 +432,20 @@ export class GumbyController {

private promptJavaHome(type: 'source' | 'target', tabID: any) {
let jdkVersion = undefined
let currJavaHome = undefined
if (type === 'source') {
this.sessionStorage.getSession().conversationState = ConversationState.PROMPT_SOURCE_JAVA_HOME
jdkVersion = transformByQState.getSourceJDKVersion()
currJavaHome = transformByQState.getPathFromJdkVersion(transformByQState.getSourceJDKVersion())
} else if (type === 'target') {
this.sessionStorage.getSession().conversationState = ConversationState.PROMPT_TARGET_JAVA_HOME
jdkVersion = transformByQState.getTargetJDKVersion()
currJavaHome = transformByQState.getPathFromJdkVersion(transformByQState.getTargetJDKVersion())
}
let message = MessengerUtils.createJavaHomePrompt(jdkVersion)
if (currJavaHome) {
message += `\n\ncurrent:\n\n\`${currJavaHome}\``
}
const message = MessengerUtils.createJavaHomePrompt(jdkVersion)
this.messenger.sendMessage(message, tabID, 'ai-prompt')
this.messenger.sendChatInputEnabled(tabID, true)
this.messenger.sendUpdatePlaceholder(tabID, CodeWhispererConstants.enterJavaHomePlaceholder)
Expand Down Expand Up @@ -640,6 +646,7 @@ export class GumbyController {
const pathToJavaHome = extractPath(data.message)
if (pathToJavaHome) {
transformByQState.setSourceJavaHome(pathToJavaHome)
transformByQState.setJdkVersionToPath(transformByQState.getSourceJDKVersion(), pathToJavaHome)
// if source and target JDK versions are the same, just re-use the source JAVA_HOME and start the build
if (transformByQState.getTargetJDKVersion() === transformByQState.getSourceJDKVersion()) {
transformByQState.setTargetJavaHome(pathToJavaHome)
Expand All @@ -657,6 +664,7 @@ export class GumbyController {
const pathToJavaHome = extractPath(data.message)
if (pathToJavaHome) {
transformByQState.setTargetJavaHome(pathToJavaHome)
transformByQState.setJdkVersionToPath(transformByQState.getTargetJDKVersion(), pathToJavaHome)
await this.prepareLanguageUpgradeProject(data.tabID) // build right after we get target JDK path
} else {
this.messenger.sendUnrecoverableErrorResponse('invalid-java-home', data.tabID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export enum GumbyCommands {

export default class MessengerUtils {
static createJavaHomePrompt = (jdkVersion: JDKVersion | undefined): string => {
let javaHomePrompt = `${CodeWhispererConstants.enterJavaHomeChatMessage} ${jdkVersion}. \n`
let javaHomePrompt = `${CodeWhispererConstants.enterJavaHomeChatMessage} ${jdkVersion}.\n\n`
if (os.platform() === 'win32') {
javaHomePrompt += CodeWhispererConstants.windowsJavaHomeHelpChatMessage
} else if (os.platform() === 'darwin') {
Expand Down
16 changes: 16 additions & 0 deletions packages/core/src/codewhisperer/models/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,8 @@ export class TransformByQState {

private targetJDKVersion: JDKVersion | undefined = undefined

private jdkVersionToPath: Map<JDKVersion, string> = new Map()

private customBuildCommand: string = ''

private sourceDB: DB | undefined = undefined
Expand Down Expand Up @@ -874,6 +876,14 @@ export class TransformByQState {
return this.targetJDKVersion
}

public getPathFromJdkVersion(version: JDKVersion | undefined) {
if (version) {
return this.jdkVersionToPath.get(version)
} else {
return undefined
}
}

public getSourceDB() {
return this.sourceDB
}
Expand Down Expand Up @@ -954,6 +964,12 @@ export class TransformByQState {
return this.targetJavaHome
}

public setJdkVersionToPath(jdkVersion: JDKVersion | undefined, path: string) {
if (jdkVersion) {
this.jdkVersionToPath.set(jdkVersion, path)
}
}

public getChatControllers() {
return this.chatControllers
}
Expand Down
Loading