mirror of
https://github.com/HighCapable/SweetProperty.git
synced 2025-09-04 01:35:37 +08:00
feat: remove auto conversion if it's an interpolation
This commit is contained in:
@@ -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 是否自动转换类型
|
||||
|
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user