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

Commit 4dced22

Browse files
committed
feat: add ignore config
1 parent 0ea85b3 commit 4dced22

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

assets/config.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ regex = [
100100
"^.*VariantBuilder", # for mc
101101
]
102102

103+
[ignore]
104+
105+
regex = []
106+
103107
[sort]
104108
parent = [
105109
# { parent = "Actor", dst = "Actor" },

src/main/kotlin/com/liteldev/headeroutput/HeaderOutput.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ object HeaderOutput {
149149
val notIdentifiedTypes = mutableSetOf<String>()
150150
logger.info { "Loading types..." }
151151
typeDataMap
152-
.filterNot { (k, _) -> GeneratorConfig.isExcludedFromGeneration(k) }
152+
.filterNot { (k, _) -> GeneratorConfig.isExcluded(k) }
153+
.filterNot { (k, _) -> GeneratorConfig.isIgnored(k) }
153154
.forEach { (typeName, type) ->
154155
TypeManager.addType(
155156
typeName,

src/main/kotlin/com/liteldev/headeroutput/TypeManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ object TypeManager {
116116
private fun createDummyClass(name: String, type: TypeKind? = null): BaseType? {
117117
require(!hasType(name)) { "type $name already exists" }
118118

119-
if (GeneratorConfig.isExcludedFromGeneration(name)) {
119+
if (GeneratorConfig.isExcluded(name)) {
120120
return null
121121
}
122122

src/main/kotlin/com/liteldev/headeroutput/config/GeneratorConfig.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ object GeneratorConfig {
2626
lateinit var replacementRegex: List<Pair<Regex, String>>
2727

2828
private lateinit var excludeRegexList: List<Regex>
29+
private lateinit var ignoreRegexList: List<Regex>
2930
private lateinit var generatorConfigData: OutputConfig
3031

3132

@@ -45,13 +46,20 @@ object GeneratorConfig {
4546
enableRelativePath = generatorConfigData.config.enableRelativePath
4647
rootPath = generatorConfigData.config.rootPath
4748
excludeRegexList = generatorConfigData.exclusion.regex.map { it.toRegex() }
49+
ignoreRegexList = generatorConfigData.ignore.regex.map { it.toRegex() }
4850
replacementRegex = generatorConfigData.replacement.regex.map { it.regex.toRegex() to it.to }
4951
}
5052

51-
fun isExcludedFromGeneration(name: String): Boolean {
53+
// Exclude means exclude from the origin data, and do not generate the dummy type
54+
fun isExcluded(name: String): Boolean {
5255
return excludeRegexList.any { name.matches(it) }
5356
}
5457

58+
// Ignore means ignore from the origin data, and generate the dummy type
59+
fun isIgnored(name: String): Boolean {
60+
return ignoreRegexList.any { name.matches(it) }
61+
}
62+
5563
fun getSortRules() = generatorConfigData.sort
5664

5765
}

src/main/kotlin/com/liteldev/headeroutput/config/OutputConfig.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ data class OutputConfig(
77
val config: Config,
88
val exclusion: Exclusion,
99
val sort: Sort,
10+
val ignore: Ignore,
1011
val replacement: Replacement
1112
) {
1213
@Serializable
@@ -36,6 +37,11 @@ data class OutputConfig(
3637
val regex: List<String>
3738
)
3839

40+
@Serializable
41+
data class Ignore(
42+
val regex: List<String>
43+
)
44+
3945
@Serializable
4046
data class Replacement(
4147
val regex: List<Regex>

0 commit comments

Comments
 (0)