Skip to content

Commit

Permalink
修复var和list名字bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kkkkkkkkkkkkkkeee committed Jan 7, 2020
1 parent 72c239a commit 88bdbb5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
kotlin_version=1.3.61
pluginVersion=3.2.6
pluginVersion=3.2.7
#每次修改这里去打包
ideaVersionPrefix=193
ideaVersion=
4 changes: 2 additions & 2 deletions src/main/java/com/ruiyu/jsontodart/ClassGeneratorInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class HelperClassGeneratorInfo {
//是否是基础数据类型
val isPrimitive = PRIMITIVE_TYPES[type] ?: false
//是否是list
val isListType = type.contains("List")
val isListType = isListType(type)
return when {
isPrimitive -> {
when {
Expand Down Expand Up @@ -121,7 +121,7 @@ class HelperClassGeneratorInfo {
//是否是基础数据类型
val isPrimitive = PRIMITIVE_TYPES[type] ?: false
//是否是list
val isListType = type.contains("List")
val isListType = isListType(type)
val thisKey = "entity.$name"
if (isPrimitive) {
return "data['$getJsonName'] = $thisKey;"
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/ruiyu/jsontodart/utils/Helper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ val PRIMITIVE_TYPES = mapOf(
"List<bool>" to true,
"List" to true,
"Null" to true,
"var" to true,
"dynamic" to true
)

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

fun isListType(typeName: String): Boolean {
return when {
typeName.contains("List<") -> {
true
}
else -> {
typeName == "List"
}
}
}

val dartKeyword = mutableListOf("abstract", "dynamic", "implements", "show",
"as", "else", "import ", "static",
"assert", "enum", "in", "super",
Expand Down

0 comments on commit 88bdbb5

Please sign in to comment.