@@ -30,9 +30,7 @@ import software.aws.toolkits.jetbrains.services.amazonq.CODE_TRANSFORM_TROUBLESH
3030import software.aws.toolkits.jetbrains.services.amazonq.CODE_TRANSFORM_TROUBLESHOOT_DOC_DOWNLOAD_EXPIRED
3131import software.aws.toolkits.jetbrains.services.codemodernizer.client.GumbyClient
3232import software.aws.toolkits.jetbrains.services.codemodernizer.commands.CodeTransformMessageListener
33- import software.aws.toolkits.jetbrains.services.codemodernizer.constants.createViewDiffButton
3433import software.aws.toolkits.jetbrains.services.codemodernizer.constants.getDownloadedArtifactTextFromType
35- import software.aws.toolkits.jetbrains.services.codemodernizer.constants.viewSummaryButton
3634import software.aws.toolkits.jetbrains.services.codemodernizer.controller.CodeTransformChatHelper
3735import software.aws.toolkits.jetbrains.services.codemodernizer.messages.CodeTransformChatMessageContent
3836import software.aws.toolkits.jetbrains.services.codemodernizer.messages.CodeTransformChatMessageType
@@ -43,14 +41,12 @@ import software.aws.toolkits.jetbrains.services.codemodernizer.model.DownloadArt
4341import software.aws.toolkits.jetbrains.services.codemodernizer.model.DownloadFailureReason
4442import software.aws.toolkits.jetbrains.services.codemodernizer.model.JobId
4543import software.aws.toolkits.jetbrains.services.codemodernizer.model.ParseZipFailureReason
46- import software.aws.toolkits.jetbrains.services.codemodernizer.model.PatchInfo
4744import software.aws.toolkits.jetbrains.services.codemodernizer.model.UnzipFailureReason
4845import software.aws.toolkits.jetbrains.services.codemodernizer.state.CodeModernizerSessionState
4946import software.aws.toolkits.jetbrains.services.codemodernizer.utils.getPathToHilArtifactDir
5047import software.aws.toolkits.jetbrains.services.codemodernizer.utils.isValidCodeTransformConnection
5148import software.aws.toolkits.jetbrains.services.codemodernizer.utils.openTroubleshootingGuideNotificationAction
5249import software.aws.toolkits.jetbrains.services.codemodernizer.utils.zipToPath
53- import software.aws.toolkits.jetbrains.utils.notifyInfo
5450import software.aws.toolkits.jetbrains.utils.notifyStickyInfo
5551import software.aws.toolkits.jetbrains.utils.notifyStickyWarn
5652import software.aws.toolkits.resources.message
@@ -63,20 +59,6 @@ import java.util.concurrent.atomic.AtomicBoolean
6359const val DOWNLOAD_PROXY_WILDCARD_ERROR : String = " Dangling meta character '*' near index 0"
6460const val DOWNLOAD_SSL_HANDSHAKE_ERROR : String = " Unable to execute HTTP request: javax.net.ssl.SSLHandshakeException"
6561const val INVALID_ARTIFACT_ERROR : String = " Invalid artifact"
66- val patchDescriptions = mapOf (
67- " Prepare minimal upgrade to Java 17" to " This diff patch covers the set of upgrades for Springboot, JUnit, and PowerMockito frameworks in Java 17." ,
68- " Prepare minimal upgrade to Java 21" to " This diff patch covers the set of upgrades for Springboot, JUnit, and PowerMockito frameworks in Java 21." ,
69- " Popular Enterprise Specifications and Application Frameworks upgrade" to " This diff patch covers the set of upgrades for Jakarta EE 10, Hibernate 6.2, " +
70- " and Micronaut 3." ,
71- " HTTP Client Utilities, Apache Commons Utilities, and Web Frameworks" to " This diff patch covers the set of upgrades for Apache HTTP Client 5, Apache " +
72- " Commons utilities (Collections, IO, Lang, Math), and Struts 6.0." ,
73- " Testing Tools and Frameworks upgrade" to " This diff patch covers the set of upgrades for ArchUnit, Mockito, TestContainers, and Cucumber, in addition " +
74- " to the Jenkins plugins and the Maven Wrapper." ,
75- " Miscellaneous Processing Documentation upgrade" to " This diff patch covers a diverse set of upgrades spanning ORMs, XML processing, API documentation, " +
76- " and more." ,
77- " Deprecated API replacement, dependency upgrades, and formatting" to " This diff patch replaces deprecated APIs, makes additional dependency version " +
78- " upgrades, and formats code changes."
79- )
8062
8163class ArtifactHandler (
8264 private val project : Project ,
@@ -88,21 +70,13 @@ class ArtifactHandler(
8870 private val downloadedSummaries = mutableMapOf<JobId , TransformationSummary >()
8971 private val downloadedBuildLogPath = mutableMapOf<JobId , Path >()
9072 private var isCurrentlyDownloading = AtomicBoolean (false )
91- private var totalPatchFiles: Int = 0
92- private var sharedPatchIndex: Int = 0
9373
9474 internal suspend fun displayDiff (job : JobId ) {
9575 if (isCurrentlyDownloading.get()) return
9676 when (val result = downloadArtifact(job, TransformationDownloadArtifactType .CLIENT_INSTRUCTIONS )) {
9777 is DownloadArtifactResult .Success -> {
9878 if (result.artifact !is CodeModernizerArtifact ) return notifyUnableToApplyPatch(" " )
99- totalPatchFiles = result.artifact.patches.size
100- if (result.artifact.description == null ) {
101- displayDiffUsingPatch(result.artifact.patches.first(), totalPatchFiles, null , job)
102- } else {
103- val diffDescription = result.artifact.description[getCurrentPatchIndex()]
104- displayDiffUsingPatch(result.artifact.patches[getCurrentPatchIndex()], totalPatchFiles, diffDescription, job)
105- }
79+ displayDiffUsingPatch(result.artifact.patch, job)
10680 }
10781 is DownloadArtifactResult .ParseZipFailure -> notifyUnableToApplyPatch(result.failureReason.errorMessage)
10882 is DownloadArtifactResult .UnzipFailure -> notifyUnableToApplyPatch(result.failureReason.errorMessage)
@@ -260,8 +234,6 @@ class ArtifactHandler(
260234 */
261235 internal suspend fun displayDiffUsingPatch (
262236 patchFile : VirtualFile ,
263- totalPatchFiles : Int ,
264- diffDescription : PatchInfo ? ,
265237 jobId : JobId ,
266238 ) {
267239 withContext(EDT ) {
@@ -274,11 +246,7 @@ class ArtifactHandler(
274246 null ,
275247 ChangeListManager .getInstance(project)
276248 .addChangeList(
277- if (diffDescription != null ) {
278- " ${diffDescription.name} (${if (diffDescription.isSuccessful) " Success" else " Failure" } )"
279- } else {
280- patchFile.name
281- },
249+ patchFile.name,
282250 " "
283251 ),
284252 null ,
@@ -289,42 +257,12 @@ class ArtifactHandler(
289257 dialog.isModal = true
290258
291259 if (dialog.showAndGet()) {
292- telemetry.submitSelection(" Submit-${diffDescription?.name} " , jobId.toString())
293- if (diffDescription == null ) {
294- val resultContent = CodeTransformChatMessageContent (
295- type = CodeTransformChatMessageType .PendingAnswer ,
296- message = message(" codemodernizer.chat.message.changes_applied" ),
297- )
298- codeTransformChatHelper?.updateLastPendingMessage(resultContent)
299- } else {
300- if (getCurrentPatchIndex() < totalPatchFiles) {
301- val message = " I applied the changes in diff patch ${getCurrentPatchIndex() + 1 } of $totalPatchFiles . " +
302- " ${patchDescriptions[diffDescription.name]} "
303- val notificationMessage = " Amazon Q applied the changes in diff patch ${getCurrentPatchIndex() + 1 } of $totalPatchFiles " +
304- " to your project."
305- val notificationTitle = " Diff patch ${getCurrentPatchIndex() + 1 } of $totalPatchFiles applied"
306- setCurrentPatchIndex(getCurrentPatchIndex() + 1 )
307- notifyInfo(notificationTitle, notificationMessage, project)
308- if (getCurrentPatchIndex() == totalPatchFiles) {
309- codeTransformChatHelper?.updateLastPendingMessage(
310- CodeTransformChatMessageContent (type = CodeTransformChatMessageType .PendingAnswer , message = message)
311- )
312- } else {
313- codeTransformChatHelper?.updateLastPendingMessage(
314- CodeTransformChatMessageContent (
315- type = CodeTransformChatMessageType .PendingAnswer ,
316- message = message,
317- buttons = listOf (
318- createViewDiffButton(" View diff ${getCurrentPatchIndex() + 1 } /$totalPatchFiles " ),
319- viewSummaryButton
320- )
321- )
322- )
323- }
324- } else {
325- // no-op; start a new transformation button already visible at this point
326- }
327- }
260+ telemetry.submitSelection(" Submit" , jobId.toString())
261+ val resultContent = CodeTransformChatMessageContent (
262+ type = CodeTransformChatMessageType .PendingAnswer ,
263+ message = message(" codemodernizer.chat.message.changes_applied" ),
264+ )
265+ codeTransformChatHelper?.updateLastPendingMessage(resultContent)
328266 } else {
329267 telemetry.submitSelection(" Cancel" , jobId.toString())
330268 }
@@ -411,7 +349,7 @@ class ArtifactHandler(
411349 ),
412350 )
413351
414- fun notifyUnableToShowSummary () {
352+ private fun notifyUnableToShowSummary () {
415353 LOG .error { " Unable to display summary" }
416354 notifyStickyWarn(
417355 message(" codemodernizer.notification.warn.view_summary_failed.title" ),
@@ -425,7 +363,7 @@ class ArtifactHandler(
425363 )
426364 }
427365
428- fun notifyUnableToShowBuildLog () {
366+ private fun notifyUnableToShowBuildLog () {
429367 LOG .error { " Unable to display build log" }
430368 notifyStickyWarn(
431369 message(" codemodernizer.notification.warn.view_build_log_failed.title" ),
@@ -447,12 +385,6 @@ class ArtifactHandler(
447385
448386 fun getSummary (job : JobId ) = downloadedSummaries[job]
449387
450- private fun getCurrentPatchIndex () = sharedPatchIndex
451-
452- private fun setCurrentPatchIndex (index : Int ) {
453- sharedPatchIndex = index
454- }
455-
456388 private fun showSummaryFromFile (summaryFile : File ) {
457389 val summaryMarkdownVirtualFile = LocalFileSystem .getInstance().refreshAndFindFileByIoFile(summaryFile)
458390 if (summaryMarkdownVirtualFile != null ) {
0 commit comments