Skip to content

Commit

Permalink
3.1.5 release
Browse files Browse the repository at this point in the history
  • Loading branch information
kkkkkkkkkkkkkkeee committed Dec 29, 2019
1 parent ed68674 commit fbb3788
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ What I do is generate dart beans based on json, as well as generics parameters a
* Search 'FlutterJsonBeanFactory' in Intellij Idea Plugin Repositroy Or AndroidStudio Plugin Repository And Install it.</br>
File --> Settings --> Plugins --> Browse Repositories -->Search FlutterJsonBean
* Restart your Develop tools
* Press shortcut key `command` + `"` for mac , right click on package -> `New`->`Dart bean clas file from JSON` And Then you will know how to use
* Press shortcut key `alt ` + `j` for mac , right click on package -> `New`->`Dart bean clas file from JSON` And Then you will know how to use
* If you change the fields in the class, just press the shortcut command + "to regenerate the tojson and fromjson methods. The generated method regenerates all helper classes and JsonConvert classes (the same as the shortcut command +") each time an entity file is created in the generated/json directory.
* If you need generic conversions in your network requests, use the jsonconvert.fromjsonast method directly.
* [中文移步](https://www.jianshu.com/p/14cbcbaa74b7)
Expand Down
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.1.4
pluginVersion=3.1.5
#每次修改这里去打包
ideaVersionPrefix=193
ideaVersion=
10 changes: 5 additions & 5 deletions src/main/java/com/ruiyu/beanfactory/FlutterBeanFactoryAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class FlutterBeanFactoryAction : AnAction() {

fun generateAllFile(project: Project) {
val pubSpecConfig = FileHelpers.getPubSpecConfig(project)
//是flutter项目
if (FileHelpers.shouldActivateFor(project)) {
//判断是否是flutter项目
// if (FileHelpers.shouldActivateFor(project)) {
FileHelpers.getGeneratedFileRun(project) {
//上次生成的老旧老文件
val oldHelperChildren = it.children.filterIsInstance<VirtualFileImpl>().toMutableList()
Expand Down Expand Up @@ -118,9 +118,9 @@ class FlutterBeanFactoryAction : AnAction() {
project.showNotify("convert factory is generated")
}

} else {
project.showNotify("This project is not flutter")
}
// } else {
// project.showNotify("This project is not flutter")
// }


}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/ruiyu/jsontodart/ModelGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import com.google.gson.reflect.TypeToken
import com.intellij.openapi.project.Project
import com.ruiyu.file.FileHelpers
import com.ruiyu.json.GsonUtil.MapTypeAdapter
import com.ruiyu.jsontodart.utils.camelCase
import com.ruiyu.jsontodart.utils.fixFieldName
import com.ruiyu.utils.Inflector
import com.ruiyu.utils.JsonUtils
import com.ruiyu.utils.toUpperCaseFirstOne
Expand Down Expand Up @@ -42,10 +44,10 @@ class ModelGenerator(
keys.forEach { key ->
val typeDef = TypeDefinition.fromDynamic(jsonRawData[key])
if (typeDef.name == "Class") {
typeDef.name = preName + (key as String).toUpperCaseFirstOne()
typeDef.name = preName + camelCase(key as String)
}
if (typeDef.subtype != null && typeDef.subtype == "Class") {
typeDef.subtype = preName + (key as String).toUpperCaseFirstOne()
typeDef.subtype = preName + camelCase(key as String)
}
classDefinition.addField(key as String, typeDef)
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/ruiyu/jsontodart/utils/Helper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ fun isPrimitiveType(typeName: String): Boolean {


fun camelCase(init: String): String {
if (init.contains("_").not()) {
return init.toUpperCaseFirstOne()
}
val ret = StringBuilder(init.length)

for (word in init.split("_".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()) {
if (!word.isEmpty()) {
if (word.isNotEmpty()) {
ret.append(word.substring(0, 1).toUpperCase())
ret.append(word.substring(1).toLowerCase())
}
Expand Down
10 changes: 4 additions & 6 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
<description><![CDATA[
<br>Json to dart beans are provided, and dart files ending in entity are provided to generate dart bean factory for use.</br>
<br>right click on package -> `New`->`Dart bean clas file from JSON` And Then you will know how to use</br>
<br>If you change the fields in the class, just press the shortcut command + "to regenerate the tojson and fromjson methods. The generated method regenerates all helper classes and JsonConvert classes (the same as the shortcut command +") each time an entity file is created in the generated/json directory.</br>
<br>If you change the fields in the class, just press the shortcut alt + j to regenerate the tojson and fromjson methods. The generated method regenerates all helper classes and JsonConvert classes (the same as the shortcut alt + j) each time an entity file is created in the generated/json directory.</br>
<br>If you need generic conversions in your network requests, use the jsonconvert.fromjsonast method directly.</br>
]]></description>
<change-notes><![CDATA[
<br>shortcut key is changed to Alt + j</br>
<br>if the first jsonobject in the jsonarray is not perfect, the data will not be complete</br>
<br>rebuild will delete redundant files</br>
<br>version 3.1 has been released,Provide JsonConvert.dart,EntityFactory is deprecated</br>
Expand All @@ -21,10 +22,7 @@
<br>fixed field forEach method when not converted to list</br>
<br>fixed the bug of plural to singular</br>
<br>fixed import bug under Windows</br>
<br>fixed the dart keyword problem, fixed the second-level class name problem, and the int automatic double problem</br>
<br>incomplete support for the first data of the list results in missing fields in the generated dart file</br>
<br>supports custom scan file names, and factory class customizations</br>
<br>support for custom model suffix names</br>
<br>fixed the dart keyword prob <br>support for custom model suffix names</br>
<br>support android studio</br>
<br>Json to dart beans are provided</br>
]]>
Expand All @@ -45,7 +43,7 @@
text="FlutterBeanFactory"
description="Dart files ending in entity generate dart bean factory for use">
<add-to-group group-id="BuildMenu" anchor="first"/>
<keyboard-shortcut keymap="$default" first-keystroke="ctrl QUOTE"/>
<keyboard-shortcut keymap="$default" first-keystroke="alt j"/>
</action>

<action id="FlutterBeanFactory.GenerateDartBeanFileAction"
Expand Down

0 comments on commit fbb3788

Please sign in to comment.