Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Commit ca2c648

Browse files
committed
fix: fix incomplete namespace
1 parent 75e309d commit ca2c648

File tree

1 file changed

+3
-18
lines changed
  • src/main/kotlin/com/liteldev/headeroutput/entity

1 file changed

+3
-18
lines changed

src/main/kotlin/com/liteldev/headeroutput/entity/BaseType.kt

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ abstract class BaseType(
2626
val forwardDeclareList: MutableSet<String> = mutableSetOf()
2727

2828
val simpleName = name.substringAfterLast("::")
29-
val namespace = name.substringBeforeLast("::", "::")
29+
val namespace = name.substringBeforeLast("::", "") + "::"
3030
val fullEscapeName = name.replace("::", "_")
3131
val fullUpperEscapeName = fullEscapeName.uppercase(Locale.getDefault())
3232

@@ -60,35 +60,20 @@ abstract class BaseType(
6060
}
6161
if (this is NamespaceType) {
6262
val namespaceRules = GeneratorConfig.getSortRules().namespace
63-
namespaceRules.find { this.name.startsWith(it.namespace) }
63+
namespaceRules.find { this.name == it.namespace || this.name.startsWith(it.namespace + "::") }
6464
?.let {
6565
return@run "$root/${it.dst}/${this.simpleName}.$HEADER_SUFFIX"
6666
}
6767
} else {
6868
val namespaceRules = GeneratorConfig.getSortRules().namespace
69-
namespaceRules.find { this.namespace.startsWith(it.namespace) }
69+
namespaceRules.find { this.namespace.startsWith(it.namespace + "::") }
7070
?.let {
7171
return@run "$root/${it.dst}/${this.simpleName}.$HEADER_SUFFIX"
7272
}
7373
}
7474
regexRules.filter { !it.override }.find { this.name.matches(it.regex.toRegex()) }?.let {
7575
return@run "$root/${it.dst}/${this.simpleName}.$HEADER_SUFFIX"
7676
}
77-
if (this.isEnum()) {
78-
if (!this.name.contains("::"))
79-
return@run "$root/enums/${this.simpleName}.$HEADER_SUFFIX"
80-
return@run "$root/enums/${
81-
this.name.replace("::", "/").substringBeforeLast("/").toSnakeCase()
82-
}/$simpleName.$HEADER_SUFFIX"
83-
}
84-
if (this.isUnion()) {
85-
if (!this.name.contains("::"))
86-
return@run "$root/unions/${this.simpleName}.$HEADER_SUFFIX"
87-
return@run "$root/unions/${
88-
this.name.replace("::", "/").substringBeforeLast("/").toSnakeCase()
89-
}/$simpleName.$HEADER_SUFFIX"
90-
}
91-
9277
notSortedTypes.add(this.name)
9378
return@run "$root/${name.replace("::", "__")}.$HEADER_SUFFIX"
9479
}

0 commit comments

Comments
 (0)