33
44package software.aws.toolkits.jetbrains.services.codemodernizer.plan
55
6- import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
76import com.fasterxml.jackson.module.kotlin.readValue
87import com.intellij.ide.BrowserUtil
98import com.intellij.openapi.fileEditor.FileEditor
@@ -22,6 +21,7 @@ import software.aws.toolkits.jetbrains.services.codemodernizer.constants.APPENDI
2221import software.aws.toolkits.jetbrains.services.codemodernizer.constants.CodeModernizerUIConstants
2322import software.aws.toolkits.jetbrains.services.codemodernizer.constants.JOB_STATISTICS_TABLE_KEY
2423import software.aws.toolkits.jetbrains.services.codemodernizer.constants.LOC_THRESHOLD
24+ import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeModernizerArtifact.Companion.MAPPER
2525import software.aws.toolkits.jetbrains.services.codemodernizer.model.PlanTable
2626import software.aws.toolkits.jetbrains.services.codemodernizer.plan.CodeModernizerPlanEditorProvider.Companion.MIGRATION_PLAN_KEY
2727import software.aws.toolkits.jetbrains.services.codemodernizer.utils.getAuthType
@@ -62,7 +62,6 @@ import javax.swing.table.DefaultTableModel
6262class CodeModernizerPlanEditor (val project : Project , private val virtualFile : VirtualFile ) : UserDataHolderBase(), FileEditor {
6363 val plan = virtualFile.getUserData(MIGRATION_PLAN_KEY ) ? : throw RuntimeException (" Migration plan not found" )
6464 private val tableMapping = getTableMapping(plan.transformationSteps()[0 ].progressUpdates())
65- private val mapper = jacksonObjectMapper()
6665
6766 // to-do: convert to UI DSL
6867 private val contentPanel =
@@ -77,7 +76,7 @@ class CodeModernizerPlanEditor(val project: Project, private val virtualFile: Vi
7776 // comes from "name" field of each progressUpdate in step zero of plan
7877 if (JOB_STATISTICS_TABLE_KEY in tableMapping) {
7978 val planTable = parseTableMapping(tableMapping)
80- val linesOfCode = getLinesOfCodeSubmitted(planTable)
79+ val linesOfCode = planTable?. let { getLinesOfCodeSubmitted(it) }
8180 if (linesOfCode != null && linesOfCode > LOC_THRESHOLD && getAuthType(project) == CredentialSourceId .IamIdentityCenter ) {
8281 val billingText = getBillingText(linesOfCode)
8382 val billingTextComponent =
@@ -99,15 +98,15 @@ class CodeModernizerPlanEditor(val project: Project, private val virtualFile: Vi
9998 add(billingTextComponent, CodeModernizerUIConstants .transformationPlanPlaneConstraint)
10099 }
101100 add(
102- transformationPlanInfo(planTable) ,
101+ planTable?. let { transformationPlanInfo(it) } ,
103102 CodeModernizerUIConstants .transformationPlanPlaneConstraint,
104103 )
105104 }
106105 add(transformationPlanPanel(plan), CodeModernizerUIConstants .transformationPlanPlaneConstraint)
107106 // key "-1" reserved for appendix table
108107 if (APPENDIX_TABLE_KEY in tableMapping) {
109108 add(
110- transformationPlanAppendix(mapper.readValue( tableMapping[APPENDIX_TABLE_KEY ], PlanTable :: class .java)) ,
109+ tableMapping[APPENDIX_TABLE_KEY ]?. let { MAPPER .readValue< PlanTable >(it) }?. let { transformationPlanAppendix(it) } ,
111110 CodeModernizerUIConstants .transformationPlanPlaneConstraint,
112111 )
113112 }
@@ -397,7 +396,7 @@ class CodeModernizerPlanEditor(val project: Project, private val virtualFile: Vi
397396 val table = tableMapping[step.id()]
398397
399398 val parsedTable = table?.let {
400- mapper .readValue<PlanTable >(it)
399+ MAPPER .readValue<PlanTable >(it)
401400 }
402401
403402 val renderedStepTable = parsedTable?.let {
0 commit comments