feat: remove auto conversion if it's an interpolation

This commit is contained in:
2023-11-04 01:40:50 +08:00
parent d9c8c5dc84
commit 6c5835bc72
2 changed files with 9 additions and 1 deletions

View File

@@ -29,6 +29,12 @@ internal typealias PropertyMap = MutableMap<String, Any>
/** 属性键值规则类型定义 */
internal typealias PropertyValueRule = (value: String) -> String
/**
* 移除键值内容自动转换类型的引号
* @return [String]
*/
internal fun String.removeAutoConversion() = removeSurrounding("\"").removeSurrounding("'")
/**
* 解析到键值内容类型
* @param isAutoConversion 是否自动转换类型

View File

@@ -36,6 +36,7 @@ import com.highcapable.sweetproperty.plugin.config.type.GenerateLocationType
import com.highcapable.sweetproperty.plugin.generator.PropertiesAccessorsGenerator
import com.highcapable.sweetproperty.plugin.generator.PropertiesSourcesGenerator
import com.highcapable.sweetproperty.plugin.generator.factory.PropertyMap
import com.highcapable.sweetproperty.plugin.generator.factory.removeAutoConversion
import com.highcapable.sweetproperty.utils.camelcase
import com.highcapable.sweetproperty.utils.code.entity.MavenPomData
import com.highcapable.sweetproperty.utils.code.factory.compile
@@ -293,7 +294,8 @@ internal object PropertiesDeployHelper {
fun String.resolveValue(): String = replaceInterpolation { matchKey ->
if (resolveKeys.size > 5) SError.make("Key \"$key\" has been called recursively multiple times of those $resolveKeys")
resolveKeys.add(matchKey)
val resolveValue = if (configs.isEnableValueInterpolation) resolveKeyValues[matchKey] ?: "" else matchKey
var resolveValue = if (configs.isEnableValueInterpolation) resolveKeyValues[matchKey] ?: "" else matchKey
resolveValue = resolveValue.removeAutoConversion()
if (resolveValue.hasInterpolation()) resolveValue.resolveValue()
else resolveValue
}