Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 50 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,43 +62,62 @@ which is more flexible and convenient.
| Field | use number key as map | 是 | 使用数字类型key替换为Map结构,待完善 |
| Convert library | jackson/fastjson | 是 | jackson/fastjson等转换注解 |

#### 5.版本信息
### 中文版

future features
#### 5. 版本信息

- 提取静态内部类到根类
- 支持数字key映射Map字段
**版本 1.6.2 by xweiba**
- 支持 FastJSON2
- IDEA 插件升级到 1.5.2 版本
- Gradle 插件升级到 7.1 版本
- 更新 README

版本1.5.2 by wangzejun
**版本 1.6.1 by xweiba**
- 修复注释 NPE

- 支持字段注释
- 支持json5格式

版本1.5.1 by sun-men

- 设置默认为jackson注解
- 支持选用lombok注解
- 代码在新版本idea重构
**版本 1.6.0 by wangzhejun**
- 支持自动格式化
- 修复注释位置
- 修复驼峰转换

版本1.5.0 - 3 years ago
**版本 1.5.8 by wangzhejun**
- 修复 JSON 驼峰 Bug
- 修复布尔属性默认 `is` 函数
- 修复注释冲突

- fix several bug
- fix unlock setting window size
**版本 1.5.7 by wangzhejun**
- 修复部分 JSON5 格式 Bug

版本1.4.0
**版本 1.5.6 by mars-men**
- 移除 JSON 对话框的 `VK_ENTER` 监听器
- 更新 README

- New: Support for autovalue
- New: Support for lombok
- New: Support for split generate class
**版本 1.5.5 by mars-men**
- 上传到 JetBrains 插件中心

版本1.2.2

- 支持 field 类型的修改.
- 支持快捷键打开 GsonFormat ,默认为 option+s(mac), alt+s(win)
- 支持 field 名称的修改.
- 支持添加 field 前缀.
- 支持多种转换库 (Gson,Jackjson,FastJson,LoganSquare).
- 支持 private 和 public 两种模式.
- 支持过滤父类已有属性.

the end
**版本 1.5.2 by wangzejun**
- 支持字段注释
- 支持 JSON5 格式

**版本 1.5.1 by sun-men**
- 设置默认为 Jackson 注解
- 支持选用 Lombok 注解
- 代码在新版本 IDEA 重构

**版本 1.5.0 - 3 年前**
- 修复多个 Bug
- 修复设置窗口大小锁定的问题

**版本 1.4.0**
- 新增:支持 Autovalue
- 新增:支持 Lombok
- 新增:支持拆分生成类

**版本 1.2.2**
- 支持字段类型的修改
- 支持快捷键打开 GsonFormat,默认为 Option+S (Mac),Alt+S (Windows)
- 支持字段名称的修改
- 支持添加字段前缀
- 支持多种转换库 (Gson, Jackson, FastJSON, LoganSquare)
- 支持 private 和 public 两种模式
- 支持过滤父类已有属性
61 changes: 44 additions & 17 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,33 +60,60 @@ SETTING
| Convert library | jackson/fastjson | true | jackson/fastjson convert library |


#### 5. Version Information

## Version Info
**Version 1.6.2 by xweiba**
- Support FastJSON2
- Upgrade IDEA plugin to version 1.5.2
- Upgrade Gradle plugin to version 7.1
- Update README

1.5.5 by mars-men
**Version 1.6.1 by xweiba**
- Fix comment NPE

- upload to jetbrain plugin center
**Version 1.6.0 by wangzhejun**
- Support auto format
- Fix comment position
- Fix camel convert

1.5.2 by wangzejun
**Version 1.5.8 by wangzhejun**
- Fix JSON camel bug
- Fix boolean property default `is` function
- Fix comment conflict

- support field comment
- support json5 format
**Version 1.5.7 by wangzhejun**
- Fix some JSON5 format bugs

1.5.1 by mars-men
**Version 1.5.6 by mars-men**
- Remove JSON dialog `VK_ENTER` listener
- Update README

- setting jackson annotation as default
- support lombok as option
- fix some bug
**Version 1.5.5 by mars-men**
- Upload to JetBrains plugin center

1.5.0 - 3 years ago by gsonformat
**Version 1.5.2 by wangzejun**
- Support field comments
- Support JSON5 format

- fix several bug
- fix unlock setting window size
**Version 1.5.1 by sun-men**
- Set default to Jackson annotations
- Support using Lombok annotations
- Code refactored in new version of IDEA

1.4.0
**Version 1.5.0 - 3 years ago**
- Fix several bugs
- Fix unlock setting window size

- New: Support for autovalue
- New: Support for lombok
**Version 1.4.0**
- New: Support for Autovalue
- New: Support for Lombok
- New: Support for split generate class

the end
**Version 1.2.2**
- Support field type modification
- Support opening GsonFormat with a shortcut, default is Option+S (Mac), Alt+S (Windows)
- Support field name modification
- Support adding field prefix
- Support multiple conversion libraries (Gson, Jackson, FastJSON, LoganSquare)
- Support private and public modes
- Support filtering out parent class properties
19 changes: 11 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
buildscript {
repositories {
mavenCentral()
maven { url "https://www.jetbrains.com/intellij-repository/releases" }
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
Expand All @@ -11,7 +12,7 @@ buildscript {
}

plugins {
id 'org.jetbrains.intellij' version "0.4.21"
id 'org.jetbrains.intellij' version "1.5.2"
}

apply plugin: 'org.jetbrains.intellij'
Expand All @@ -20,14 +21,17 @@ apply plugin: 'java'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

intellij {
plugins 'java'
version ideaVersion //debug version
pluginName 'GsonFormatPlus'
updateSinceUntilBuild false
version = project.ideaVersion
type = project.ideaType
plugins = [
"java"
]
pluginName = 'GsonFormatPlus'
updateSinceUntilBuild = false
}

sourceCompatibility = javaVersion
targetCompatibility = javaVersion
sourceCompatibility = project.javaVersion
targetCompatibility = project.javaVersion

repositories {
mavenCentral()
Expand All @@ -40,4 +44,3 @@ repositories {
maven { url "https://www.jetbrains.com/intellij-repository/releases" }
maven { url "https://www.jetbrains.com/intellij-repository/snapshots" }
}

5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
javaVersion=1.8
ideaVersion=IU-2019.3.5
javaVersion=11
ideaVersion=2019.3.5
ideaType=IC
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 1 addition & 0 deletions src/main/java/com/foxsteps/gsonformat/ConvertBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ public String getPackName(PsiClass psiClass) {
* @return
*/
public String removeComment(String str) {
if (str == null) return "";
String temp = str.replaceAll("/\\*" +
"[\\S\\s]*?" +
"\\*/", "");
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/foxsteps/gsonformat/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ public String geFullNameAnnotation() {
if (annotationStr.equals(Constant.fastAnnotation)) {
return Constant.fastFullNameAnnotation;
}
if (annotationStr.equals(Constant.fast2Annotation)) {
return Constant.fast2FullNameAnnotation;
}
if (annotationStr.equals(Constant.loganSquareAnnotation)) {
return Constant.loganSquareFullNameAnnotation;
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/foxsteps/gsonformat/config/Constant.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public class Constant {

public static final String fastAnnotation = "@com.alibaba.fastjson.annotation.JSONField\\s*\\(\\s*name\\s*=\\s*\"{filed}\"\\s*\\)";

public static final String fast2FullNameAnnotation = "@com.alibaba.fastjson2.annotation.JSONField(name=\"{filed}\")";

public static final String fast2Annotation = "@com.alibaba.fastjson2.annotation.JSONField\\s*\\(\\s*name\\s*=\\s*\"{filed}\"\\s*\\)";

public static final String jacksonAnnotation = "@com.fasterxml.jackson.annotation.JsonProperty\\s*\\(\\s*\"{filed}\"\\s*\\)";

public static final String loganSquareAnnotation = "@com.bluelinelabs.logansquare.annotation.JsonField\\s*\\(\\s*name\\s*=\\s*\"{filed}\"\\s*\\)";
Expand Down
21 changes: 15 additions & 6 deletions src/main/java/com/foxsteps/gsonformat/ui/SettingDialog.form
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
<text value="reuse bean"/>
</properties>
</component>
<grid id="6d2ba" layout-manager="GridLayoutManager" row-count="1" column-count="7" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="6d2ba" layout-manager="GridLayoutManager" row-count="1" column-count="8" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="21" column="0" row-span="1" col-span="10" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="true">
Expand All @@ -160,7 +160,7 @@
<children>
<component id="383cb" class="javax.swing.JRadioButton" binding="gsonRB">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<selected value="false"/>
Expand All @@ -169,7 +169,7 @@
</component>
<component id="9cd04" class="javax.swing.JRadioButton" binding="otherRB">
<constraints>
<grid row="0" column="6" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="7" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<selected value="false"/>
Expand All @@ -178,7 +178,7 @@
</component>
<component id="58b2a" class="javax.swing.JRadioButton" binding="loganSquareRB">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<selected value="false"/>
Expand All @@ -187,15 +187,15 @@
</component>
<component id="52216" class="javax.swing.JRadioButton" binding="autoValueRB" default-binding="true">
<constraints>
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="AutoValue"/>
</properties>
</component>
<component id="640f2" class="javax.swing.JRadioButton" binding="lombokRB">
<constraints>
<grid row="0" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="6" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Lombok"/>
Expand All @@ -219,6 +219,14 @@
<text value="Fastjson"/>
</properties>
</component>
<component id="94290" class="javax.swing.JRadioButton" binding="fastJson2RB">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="FastJson2"/>
</properties>
</component>
</children>
</grid>
<component id="8c193" class="javax.swing.JTextField" binding="annotationTF">
Expand Down Expand Up @@ -477,6 +485,7 @@
<member id="58b2a"/>
<member id="52216"/>
<member id="640f2"/>
<member id="94290"/>
</group>
</buttonGroups>
</form>
25 changes: 25 additions & 0 deletions src/main/java/com/foxsteps/gsonformat/ui/SettingDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class SettingDialog extends JFrame {
private JRadioButton gsonRB;
private JRadioButton jacksonRB;
private JRadioButton fastJsonRB;
private JRadioButton fastJson2RB;
private JRadioButton otherRB;
private JRadioButton loganSquareRB;
private JRadioButton autoValueRB;
Expand Down Expand Up @@ -231,6 +232,27 @@ public void actionPerformed(ActionEvent actionEvent) {
array1Button.setEnabled(false);
}
});
fastJson2RB.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
if (fastJson2RB.isSelected()) {
annotationTF.setText(Constant.fast2Annotation);
}
annotationTF.setEnabled(false);
objectFromDataCB.setEnabled(false);
objectFromDataCB.setSelected(false);
objectFromData1CB.setEnabled(false);
objectFromData1CB.setSelected(false);
arrayFromDataCB.setEnabled(false);
arrayFromDataCB.setSelected(false);
arrayFromData1CB.setEnabled(false);
arrayFromData1CB.setSelected(false);
objectButton.setEnabled(false);
object1Button.setEnabled(false);
arrayButton.setEnabled(false);
array1Button.setEnabled(false);
}
});
loganSquareRB.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
Expand Down Expand Up @@ -308,6 +330,9 @@ public void actionPerformed(ActionEvent actionEvent) {
} else if (annotaionStr.equals(Constant.fastAnnotation)) {
fastJsonRB.setSelected(true);
annotationTF.setEnabled(false);
} else if (annotaionStr.equals(Constant.fast2Annotation)) {
fastJson2RB.setSelected(true);
annotationTF.setEnabled(false);
} else if (annotaionStr.equals(Constant.jacksonAnnotation)) {
jacksonRB.setSelected(true);
annotationTF.setEnabled(false);
Expand Down
Loading