Skip to content

Commit 88bdbb5

Browse files
修复var和list名字bug
1 parent 72c239a commit 88bdbb5

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
kotlin_version=1.3.61
2-
pluginVersion=3.2.6
2+
pluginVersion=3.2.7
33
#每次修改这里去打包
44
ideaVersionPrefix=193
55
ideaVersion=

src/main/java/com/ruiyu/jsontodart/ClassGeneratorInfo.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class HelperClassGeneratorInfo {
5656
//是否是基础数据类型
5757
val isPrimitive = PRIMITIVE_TYPES[type] ?: false
5858
//是否是list
59-
val isListType = type.contains("List")
59+
val isListType = isListType(type)
6060
return when {
6161
isPrimitive -> {
6262
when {
@@ -121,7 +121,7 @@ class HelperClassGeneratorInfo {
121121
//是否是基础数据类型
122122
val isPrimitive = PRIMITIVE_TYPES[type] ?: false
123123
//是否是list
124-
val isListType = type.contains("List")
124+
val isListType = isListType(type)
125125
val thisKey = "entity.$name"
126126
if (isPrimitive) {
127127
return "data['$getJsonName'] = $thisKey;"

src/main/java/com/ruiyu/jsontodart/utils/Helper.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ val PRIMITIVE_TYPES = mapOf(
1919
"List<bool>" to true,
2020
"List" to true,
2121
"Null" to true,
22+
"var" to true,
2223
"dynamic" to true
2324
)
2425

@@ -35,6 +36,17 @@ fun getListSubType(typeName: String): String {
3536
)[typeName] ?: typeName.substringAfter("<").substringBefore(">")
3637
}
3738

39+
fun isListType(typeName: String): Boolean {
40+
return when {
41+
typeName.contains("List<") -> {
42+
true
43+
}
44+
else -> {
45+
typeName == "List"
46+
}
47+
}
48+
}
49+
3850
val dartKeyword = mutableListOf("abstract", "dynamic", "implements", "show",
3951
"as", "else", "import ", "static",
4052
"assert", "enum", "in", "super",

0 commit comments

Comments
 (0)