Skip to content

Commit 7677c2f

Browse files
author
David Hasani
committed
address feedback
1 parent 51cdbc7 commit 7677c2f

File tree

4 files changed

+23
-26
lines changed

4 files changed

+23
-26
lines changed

packages/core/src/amazonqGumby/chat/controller/controller.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,13 @@ export class GumbyController {
639639

640640
case ConversationState.WAITING_FOR_TRANSFORMATION_OBJECTIVE: {
641641
const objective = data.message.trim().toLowerCase()
642+
// since we're prompting the user, their project(s) must be eligible for both types of transformations, so track how often this happens here
643+
if (objective === 'language upgrade' || objective === 'sql conversion') {
644+
telemetry.codeTransform_submitSelection.emit({
645+
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
646+
userChoice: objective,
647+
})
648+
}
642649
if (objective === 'language upgrade') {
643650
await this.handleLanguageUpgrade(data)
644651
} else if (objective === 'sql conversion') {

packages/core/src/amazonqGumby/models/constants.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,10 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { TransformationType, transformByQState } from '../../codewhisperer/models/model'
7-
86
// For uniquely identifiying which chat messages should be routed to Gumby
97
export const gumbyChat = 'gumbyChat'
108

119
// This sets the tab name
12-
export const featureName = 'Q - Code Transform'
10+
export const featureName = 'Q - Code Transformation'
1311

1412
export const dependencyNoAvailableVersions = 'no available versions'
15-
16-
export function getTransformationActionString() {
17-
return transformByQState.getTransformationType() === TransformationType.LANGUAGE_UPGRADE ? 'upgraded' : 'converted'
18-
}

packages/core/src/codewhisperer/commands/startTransformByQ.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ import { setContext } from '../../shared/vscode/setContext'
8181
import { makeTemporaryToolkitFolder } from '../../shared'
8282
import globals from '../../shared/extensionGlobals'
8383
import { convertDateToTimestamp } from '../../shared/datetime'
84-
import { spawnSync } from 'child_process'
84+
import { isWin } from '../../shared/vscode/env'
85+
import { ChildProcess } from '../../shared/utilities/processUtils'
8586

8687
function getFeedbackCommentData() {
8788
const jobId = transformByQState.getJobId()
@@ -152,7 +153,7 @@ export async function validateSQLMetadataFile(fileContents: string, message: any
152153
}
153154

154155
export async function setMaven() {
155-
let mavenWrapperExecutableName = os.platform() === 'win32' ? 'mvnw.cmd' : 'mvnw'
156+
let mavenWrapperExecutableName = isWin() ? 'mvnw.cmd' : 'mvnw'
156157
const mavenWrapperExecutablePath = path.join(transformByQState.getProjectPath(), mavenWrapperExecutableName)
157158
if (fs.existsSync(mavenWrapperExecutablePath)) {
158159
if (mavenWrapperExecutableName === 'mvnw') {
@@ -745,34 +746,31 @@ export async function getValidSQLConversionCandidateProjects() {
745746
const openProjects = await getOpenProjects()
746747
const javaProjects = await getJavaProjects(openProjects)
747748
let errorLog = ''
749+
const isWindows = isWin()
750+
const command = isWindows ? 'findstr' : 'grep'
748751
for (const project of javaProjects) {
749752
// as long as at least one of these strings is found, project contains embedded SQL statements
750753
const searchStrings = ['oracle.jdbc.OracleDriver', 'jdbc:oracle:thin:@//', 'jdbc:oracle:oci:@//']
751754
for (const str of searchStrings) {
752-
const command = process.platform === 'win32' ? 'findstr' : 'grep'
753755
// case-insensitive, recursive search
754-
const args = command === 'findstr' ? ['/i', '/s', str] : ['-i', '-r', str]
755-
const spawnResult = spawnSync(command, args, {
756-
cwd: project.path,
757-
shell: false,
758-
encoding: 'utf-8',
756+
const args = isWindows ? ['/i', '/s', str] : ['-i', '-r', str]
757+
const spawnResult = await new ChildProcess(command, args).run({
758+
spawnOptions: { cwd: project.path, shell: false },
759759
})
760760
// just for telemetry purposes
761761
if (spawnResult.error || spawnResult.stderr) {
762762
errorLog += `${JSON.stringify(spawnResult)}---`
763763
} else {
764-
errorLog += `${command} succeeded: ${spawnResult.status}`
764+
errorLog += `${command} succeeded: ${spawnResult.exitCode}`
765765
}
766766
/*
767767
note:
768768
error is set when command fails to spawn; stderr is set when command itself fails.
769769
status of 0 means search string was detected (will be printed to stdout).
770770
status will be non-zero and stdout / stderr / error will be empty when search string is not detected.
771771
*/
772-
getLogger().info(
773-
`CodeTransformation: searching for ${str} in ${project.path}, status = ${spawnResult.status} and output = ${spawnResult.output}`
774-
)
775-
if (spawnResult.status === 0) {
772+
getLogger().info(`CodeTransformation: searching for ${str} in ${project.path}, result = ${errorLog}`)
773+
if (spawnResult.exitCode === 0) {
776774
embeddedSQLProjects.push(project)
777775
break
778776
}

packages/core/src/codewhisperer/models/constants.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { getTransformationActionString } from '../../amazonqGumby/models/constants'
7-
86
/**
97
* Automated and manual trigger
108
*/
@@ -585,13 +583,13 @@ export const jobCancelledChatMessage =
585583

586584
export const jobCancelledNotification = 'You cancelled the transformation.'
587585

588-
export const jobCompletedChatMessage = `I ${getTransformationActionString()} your code. You can review the diff to see my proposed changes and accept or reject them. The transformation summary has details about the files I updated.`
586+
export const jobCompletedChatMessage = `I transformed your code. You can review the diff to see my proposed changes and accept or reject them. The transformation summary has details about the files I updated.`
589587

590-
export const jobCompletedNotification = `Amazon Q ${getTransformationActionString()} your code. You can review the diff to see my proposed changes and accept or reject them. The transformation summary has details about the files I updated.`
588+
export const jobCompletedNotification = `Amazon Q transformed your code. You can review the diff to see my proposed changes and accept or reject them. The transformation summary has details about the files I updated.`
591589

592-
export const jobPartiallyCompletedChatMessage = `I ${getTransformationActionString()} part of your code. You can review the diff to see my proposed changes and accept or reject them. The transformation summary has details about the files I updated and the errors that prevented a complete transformation.`
590+
export const jobPartiallyCompletedChatMessage = `I transformed part of your code. You can review the diff to see my proposed changes and accept or reject them. The transformation summary has details about the files I updated and the errors that prevented a complete transformation.`
593591

594-
export const jobPartiallyCompletedNotification = `Amazon Q ${getTransformationActionString()} part of your code. You can review the diff to see my proposed changes and accept or reject them. The transformation summary has details about the files I updated and the errors that prevented a complete transformation.`
592+
export const jobPartiallyCompletedNotification = `Amazon Q transformed part of your code. You can review the diff to see my proposed changes and accept or reject them. The transformation summary has details about the files I updated and the errors that prevented a complete transformation.`
595593

596594
export const noPomXmlFoundChatMessage = `I couldn\'t find a project that I can upgrade. I couldn\'t find a pom.xml file in any of your open projects, nor could I find any embedded SQL statements. Currently, I can upgrade Java 8 or Java 11 projects built on Maven, or Oracle SQL to PostgreSQL statements in Java projects. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
597595

0 commit comments

Comments
 (0)