Skip to content

Commit e3d8067

Browse files
author
David Hasani
committed
minor cleanups
1 parent e43e60b commit e3d8067

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/CodeModernizerSession.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class CodeModernizerSession(
160160
telemetryErrorMessage = "Disposed when about to create zip"
161161
return CodeModernizerStartJobResult.Disposed
162162
}
163+
// for language upgrades, copyResult should always be Successful here, failure cases already handled
163164
val result = sessionContext.createZipWithModuleFiles(copyResult)
164165

165166
if (result is ZipCreationResult.Missing1P) {

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/model/CodeModernizerSessionContext.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ data class CodeModernizerSessionContext(
189189
val depDirectory = if (copyResult is MavenCopyCommandsResult.Success) {
190190
showTransformationHub()
191191
copyResult.dependencyDirectory
192+
} else if (copyResult != null) { // failure cases already handled by now, but to be safe set depDir to null if copyResult failed
193+
null
192194
} else {
193195
sqlMetadataZip // null copyResult means doing a SQL conversion
194196
}
@@ -212,7 +214,6 @@ data class CodeModernizerSessionContext(
212214
val depSources = File(ZIP_DEPENDENCIES_PATH)
213215
val outputFile = createTemporaryZipFile { zip ->
214216
// 1) Manifest file
215-
// val dependenciesRoot = if (depDirectory != null) "$ZIP_DEPENDENCIES_PATH/${depDirectory.name}" else null
216217
var manifest = ZipManifest(customBuildCommand = customBuildCommand)
217218
if (sqlMetadataZip != null) {
218219
// doing a SQL conversion, not language upgrade
@@ -273,8 +274,8 @@ data class CodeModernizerSessionContext(
273274
zip.putNextEntry(Path(BUILD_LOG_PATH).toString(), it)
274275
}
275276
}.toFile()
276-
// only return Missing1P for language upgrades with a null depDirectory; for SQL conversions always use Succeeded since depDirectory not used
277-
if (depDirectory != null || schema != null) ZipCreationResult.Succeeded(outputFile) else ZipCreationResult.Missing1P(outputFile)
277+
// depDirectory should never be null
278+
if (depDirectory != null) ZipCreationResult.Succeeded(outputFile) else ZipCreationResult.Missing1P(outputFile)
278279
} catch (e: NoSuchFileException) {
279280
throw CodeModernizerException("Source folder not found")
280281
} catch (e: Exception) {

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/utils/CodeTransformFileUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ fun validateSctMetadata(sctFile: File?): SqlMetadataValidationResult {
174174
for (serverNodeLocation in serverNodeLocations) {
175175
val fullNameNodeInfoList = serverNodeLocation["FullNameNodeInfoList"] as Map<*, *>
176176
val nameParts = fullNameNodeInfoList["nameParts"] as Map<*, *>
177-
var fullNameNodeInfo = nameParts["FullNameNodeInfo"] // as List<Map<*, *>>
177+
var fullNameNodeInfo = nameParts["FullNameNodeInfo"]
178178
if (fullNameNodeInfo is Map<*, *>) {
179179
continue
180180
} else {

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/utils/CodeTransformProjectUtils.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ fun Project.getSupportedModules(supportedJavaMappings: Map<JavaSdkVersion, Set<J
8080
}
8181

8282
// return the first file or directory found inside each open Java module, so that user can select a Module for us to ZIP
83-
// does not strictly need to return the first file or directory found, any one would work fine
8483
fun Project.getJavaModules() = this.modules.flatMap { module ->
8584
val rootManager = ModuleRootManager.getInstance(module)
8685
if (rootManager.sdk?.sdkType?.name?.lowercase()?.contains("java") == true) {

0 commit comments

Comments
 (0)