diff --git a/assets/config.toml b/assets/config.toml index a4eb1e6..f050543 100644 --- a/assets/config.toml +++ b/assets/config.toml @@ -100,6 +100,10 @@ regex = [ "^.*VariantBuilder", # for mc ] +[ignore] + +regex = [] + [sort] parent = [ # { parent = "Actor", dst = "Actor" }, diff --git a/src/main/kotlin/com/liteldev/headeroutput/HeaderOutput.kt b/src/main/kotlin/com/liteldev/headeroutput/HeaderOutput.kt index 6b0c6b4..8e698b4 100644 --- a/src/main/kotlin/com/liteldev/headeroutput/HeaderOutput.kt +++ b/src/main/kotlin/com/liteldev/headeroutput/HeaderOutput.kt @@ -149,7 +149,8 @@ object HeaderOutput { val notIdentifiedTypes = mutableSetOf() logger.info { "Loading types..." } typeDataMap - .filterNot { (k, _) -> GeneratorConfig.isExcludedFromGeneration(k) } + .filterNot { (k, _) -> GeneratorConfig.isExcluded(k) } + .filterNot { (k, _) -> GeneratorConfig.isIgnored(k) } .forEach { (typeName, type) -> TypeManager.addType( typeName, diff --git a/src/main/kotlin/com/liteldev/headeroutput/TypeManager.kt b/src/main/kotlin/com/liteldev/headeroutput/TypeManager.kt index eb941fe..66fcceb 100644 --- a/src/main/kotlin/com/liteldev/headeroutput/TypeManager.kt +++ b/src/main/kotlin/com/liteldev/headeroutput/TypeManager.kt @@ -116,7 +116,7 @@ object TypeManager { private fun createDummyClass(name: String, type: TypeKind? = null): BaseType? { require(!hasType(name)) { "type $name already exists" } - if (GeneratorConfig.isExcludedFromGeneration(name)) { + if (GeneratorConfig.isExcluded(name)) { return null } diff --git a/src/main/kotlin/com/liteldev/headeroutput/config/GeneratorConfig.kt b/src/main/kotlin/com/liteldev/headeroutput/config/GeneratorConfig.kt index edf033b..5f04d60 100644 --- a/src/main/kotlin/com/liteldev/headeroutput/config/GeneratorConfig.kt +++ b/src/main/kotlin/com/liteldev/headeroutput/config/GeneratorConfig.kt @@ -26,6 +26,7 @@ object GeneratorConfig { lateinit var replacementRegex: List> private lateinit var excludeRegexList: List + private lateinit var ignoreRegexList: List private lateinit var generatorConfigData: OutputConfig @@ -45,13 +46,20 @@ object GeneratorConfig { enableRelativePath = generatorConfigData.config.enableRelativePath rootPath = generatorConfigData.config.rootPath excludeRegexList = generatorConfigData.exclusion.regex.map { it.toRegex() } + ignoreRegexList = generatorConfigData.ignore.regex.map { it.toRegex() } replacementRegex = generatorConfigData.replacement.regex.map { it.regex.toRegex() to it.to } } - fun isExcludedFromGeneration(name: String): Boolean { + // Exclude means exclude from the origin data, and do not generate the dummy type + fun isExcluded(name: String): Boolean { return excludeRegexList.any { name.matches(it) } } + // Ignore means ignore from the origin data, and generate the dummy type + fun isIgnored(name: String): Boolean { + return ignoreRegexList.any { name.matches(it) } + } + fun getSortRules() = generatorConfigData.sort } diff --git a/src/main/kotlin/com/liteldev/headeroutput/config/OutputConfig.kt b/src/main/kotlin/com/liteldev/headeroutput/config/OutputConfig.kt index 7bbb919..2100238 100644 --- a/src/main/kotlin/com/liteldev/headeroutput/config/OutputConfig.kt +++ b/src/main/kotlin/com/liteldev/headeroutput/config/OutputConfig.kt @@ -7,6 +7,7 @@ data class OutputConfig( val config: Config, val exclusion: Exclusion, val sort: Sort, + val ignore: Ignore, val replacement: Replacement ) { @Serializable @@ -36,6 +37,11 @@ data class OutputConfig( val regex: List ) + @Serializable + data class Ignore( + val regex: List + ) + @Serializable data class Replacement( val regex: List