Skip to content

Commit

Permalink
Fix Issue wuseal#123 - File Already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthik authored and Karthik committed Apr 21, 2019
1 parent 542f119 commit 353df83
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,20 @@ class KotlinDataClassFileGenerator(private val interceptors: List<IKotlinDataCla
): String {
var newFileName = fileName
val kotlinFileSuffix = ".kt"
val fileNamesWithoutSuffix =
val fileNamesInLowerCaseWithoutSuffix =
directory.files.filter { it.name.endsWith(kotlinFileSuffix) }
.map { it.name.dropLast(kotlinFileSuffix.length) }
while (fileNamesWithoutSuffix.contains(newFileName)) {
.map { it.name.dropLast(kotlinFileSuffix.length).toLowerCase() }
while (fileNamesInLowerCaseWithoutSuffix.contains(newFileName.toLowerCase())) {
newFileName += "X"
}
return newFileName
}

private fun changeClassNameIfCurrentListContains(classesNames: List<String>, className: String): String {
var newClassName = className
while (classesNames.contains(newClassName)) {

var fileNamesInLowerCase = classesNames.map { it.toLowerCase() }
while (fileNamesInLowerCase.contains(newClassName.toLowerCase())) {
newClassName += "X"
}
return newClassName
Expand Down

0 comments on commit 353df83

Please sign in to comment.