Skip to content

Commit abb43b7

Browse files
author
David Hasani
committed
fix circular imports
1 parent daeb93e commit abb43b7

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

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

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
downloadHilResultArchive,
2828
findDownloadArtifactStep,
2929
getArtifactsFromProgressUpdate,
30-
getTransformationPlan,
3130
getTransformationSteps,
3231
pollTransformationJob,
3332
resumeTransformationJob,
@@ -558,31 +557,6 @@ export async function pollTransformationStatusUntilPlanReady(jobId: string, prof
558557
throwIfCancelled()
559558
}
560559

561-
export async function openTransformationPlan(jobId: string, profile?: RegionProfile) {
562-
let plan = undefined
563-
try {
564-
plan = await getTransformationPlan(jobId, profile)
565-
} catch (error) {
566-
// means API call failed
567-
getLogger().error(`CodeTransformation: ${CodeWhispererConstants.failedToCompleteJobNotification}`, error)
568-
transformByQState.setJobFailureErrorNotification(
569-
`${CodeWhispererConstants.failedToGetPlanNotification} ${(error as Error).message}`
570-
)
571-
transformByQState.setJobFailureErrorChatMessage(
572-
`${CodeWhispererConstants.failedToGetPlanChatMessage} ${(error as Error).message}`
573-
)
574-
throw new Error('Get plan failed')
575-
}
576-
577-
if (plan !== undefined) {
578-
const planFilePath = path.join(transformByQState.getProjectPath(), 'transformation-plan.md')
579-
fs.writeFileSync(planFilePath, plan)
580-
await vscode.commands.executeCommand('markdown.showPreview', vscode.Uri.file(planFilePath))
581-
transformByQState.setPlanFilePath(planFilePath)
582-
await setContext('gumby.isPlanAvailable', true)
583-
}
584-
}
585-
586560
export async function pollTransformationStatusUntilComplete(jobId: string, profile: RegionProfile | undefined) {
587561
let status = ''
588562
try {

packages/core/src/codewhisperer/service/transformByQ/transformApiHandler.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ import { encodeHTML } from '../../../shared/utilities/textUtilities'
5151
import { convertToTimeString } from '../../../shared/datetime'
5252
import { getAuthType } from '../../../auth/utils'
5353
import { UserWrittenCodeTracker } from '../../tracker/userWrittenCodeTracker'
54+
import { setContext } from '../../../shared/vscode/setContext'
5455
import { AuthUtil } from '../../util/authUtil'
5556
import { DiffModel } from './transformationResultsViewProvider'
5657
import { spawnSync } from 'child_process' // eslint-disable-line no-restricted-imports
5758
import { isClientSideBuildEnabled } from '../../../dev/config'
58-
import { openTransformationPlan } from '../../commands/startTransformByQ'
5959

6060
export function getSha256(buffer: Buffer) {
6161
const hasher = crypto.createHash('sha256')
@@ -758,6 +758,31 @@ export async function pollTransformationJob(jobId: string, validStates: string[]
758758
return status
759759
}
760760

761+
async function openTransformationPlan(jobId: string, profile?: RegionProfile) {
762+
let plan = undefined
763+
try {
764+
plan = await getTransformationPlan(jobId, profile)
765+
} catch (error) {
766+
// means API call failed
767+
getLogger().error(`CodeTransformation: ${CodeWhispererConstants.failedToCompleteJobNotification}`, error)
768+
transformByQState.setJobFailureErrorNotification(
769+
`${CodeWhispererConstants.failedToGetPlanNotification} ${(error as Error).message}`
770+
)
771+
transformByQState.setJobFailureErrorChatMessage(
772+
`${CodeWhispererConstants.failedToGetPlanChatMessage} ${(error as Error).message}`
773+
)
774+
throw new Error('Get plan failed')
775+
}
776+
777+
if (plan) {
778+
const planFilePath = path.join(transformByQState.getProjectPath(), 'transformation-plan.md')
779+
nodefs.writeFileSync(planFilePath, plan)
780+
await vscode.commands.executeCommand('markdown.showPreview', vscode.Uri.file(planFilePath))
781+
transformByQState.setPlanFilePath(planFilePath)
782+
await setContext('gumby.isPlanAvailable', true)
783+
}
784+
}
785+
761786
async function attemptLocalBuild() {
762787
const jobId = transformByQState.getJobId()
763788
let artifactId

0 commit comments

Comments
 (0)