Skip to content

Commit

Permalink
可以只处理Swagger注解或Protostuff注解
Browse files Browse the repository at this point in the history
  • Loading branch information
bitkylin committed Jul 28, 2023
1 parent 461a2cd commit 6584f11
Show file tree
Hide file tree
Showing 40 changed files with 576 additions and 138 deletions.
27 changes: 16 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,45 @@

## [Unreleased]

## [0.9.1] - 2023-07-28

### Added

- If you only need to manipulate Swagger annotations and not Protostuff annotations , and vice versa, don't worry, you can switch via the "settings -> tools -> Bitkylin Universal Generate" page.

### 添加

- 如果你只需要操作Swagger注解而不需要操作Protostuff注解,反之亦然,不用担心,你可以通过 "settings -> tools -> Bitkylin Universal Generate" 页面进行切换。

## [0.8.6] - 2023-07-26

### Canary Edition
### Added

- Add multi-language support, now support English and Chinese, you can configure the language by "settings".

### 金丝雀版
### 添加

- 添加多语言支持,现在支持英文和中文,可以通过「settings」配置语言。

## [0.8.5] - 2023-07-25

### Canary Edition
### Added

- Right-click in a different location (class, field, method, or elsewhere) to generate a specific personalized context menu.

### 金丝雀版
### 添加

- 在不同的位置(类、字段、方法或其他地方)点击右键,生成特定的个性化右键菜单。

## [0.8.0] - 2023-07-24

### Canary Edition

- the current version is only for experience oh!
### Added

- Acting on Controller class or POJO class, you can easily generate Protostuff annotation "@Tag" with one click, and can directly convert JavaDoc to Swagger2.0 annotations. In turn, you can easily convert Swagger2.0 annotations to JavaDoc with a single click.

- More convenient features will be added later, so stay tuned!


### 金丝雀版

- 当前版本仅用于体验哦!
### 添加

- 作用于Controller类或POJO类,你可以很方便的一键生成Protostuff注解「@Tag」,并且可以直接将JavaDoc转换为Swagger2.0注解。反过来,你也可以方便的一键将Swagger2.0注解转换为JavaDoc。

Expand Down
59 changes: 51 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,62 @@
- [ ] Click the <kbd>Watch</kbd> button on the top of the [IntelliJ Platform Plugin Template][template] to be notified about releases containing new features and fixes.

<!-- Plugin description -->
### bitkylin-universal-generate
Canary Edition

Acting on Controller class or POJO class, you can easily generate Protostuff annotation "@Tag" with one click, and can directly convert JavaDoc to Swagger2.0 annotations. In turn, you can easily convert Swagger2.0 annotations to JavaDoc with a single click.
### What's this?

More convenient features will be added later, so stay tuned!
- Acting on Controller classes or POJO classes, you can easily generate Protostuff annotations (@Tag) with a single click and directly convert JavaDoc to Swagger annotations (@Api, @ApiOperation, @ApiModel, @ApiModelProperty) with a single click.

### bitkylin-通用生成
金丝雀版
### 有什么用呢?

作用于Controller类或POJO类,你可以很方便的一键生成Protostuff注解@Tag」,并且可以直接将JavaDoc转换为Swagger2.0注解。反过来,你也可以方便的一键将Swagger2.0注解转换为JavaDoc
- 作用于Controller类或POJO类,你可以很方便的一键生成Protostuff注解(@Tag),并且可以一键直接将JavaDoc转换为Swagger注解(@Api, @ApiOperation, @ApiModel, @ApiModelProperty)。反过来,你也可以一键将Swagger注解转换为JavaDoc

后续会添加更多方便的功能,敬请期待吧!
### Features

1. You can generate Swagger annotations (@Api, @ApiOperation, @ApiModel, @ApiModelProperty) with one click, and Protostuff annotations (@Tag) with one click via the right-click menu.
2. you can through the right-click menu , one-click Swagger annotations converted to JavaDoc annotations .
3. Currently supports two languages, English and Chinese, you can switch through the "settings -> tools -> Bitkylin Universal Generate" page.
4. If you only need to manipulate Swagger annotations but not Protostuff annotations , and vice versa, don't worry, you can switch through the "settings -> tools -> Bitkylin Universal Generate" page.

### 特性

1. 你可以通过右键菜单,一键生成Swagger注解(@Api, @ApiOperation, @ApiModel, @ApiModelProperty), 一键生成Protostuff注解(@Tag)。
2. 你可以通过右键菜单,一键将Swagger注解转换为JavaDoc注释。
3. 当前支持两种语言,英文和中文,可以通过 "settings -> tools -> Bitkylin Universal Generate" 页面进行切换。
4. 如果你只需要操作Swagger注解而不需要操作Protostuff注解,反之亦然,不用担心,你可以通过 "settings -> tools -> Bitkylin Universal Generate" 页面进行切换。

### Tip.

#### NO.1

If you want to generate @Tag annotations for the entire document according to a customized starting number, just set the starting number in the first field in the class, then execute "Generate Entry Annotation" ,for example:

如果你想按照自定义的起始序号,生成整个文档的@Tag注解,只需要在类中的第一个字段设置起始序号即可,然后执行"生成入口注解" ,例如:

```java
@Data
public class TestRequest {

@Tag(105)
private String name;

/**
* bitkylin age
*/
private Integer age;

private Address address;

public static class Address {

@Tag(208)
private String province;

private String city;

private String detailedAddress;
}
}
```

<!-- Plugin description end -->

Expand Down
8 changes: 6 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ intellij {
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
groups = listOf(
"Canary Edition",
"金丝雀版"
"Added",
"Fixed",
"Changed",
"添加",
"修复",
"变更"
)

repositoryUrl = properties("pluginRepositoryUrl")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = com.github.bitkylin.bitkyuniversalgenerate
pluginName = bitkylin-universal-generate
pluginRepositoryUrl = https://github.com/bitkylin/bitkylin-universal-generate
# SemVer format -> https://semver.org
pluginVersion = 0.8.6
pluginVersion = 0.9.1

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 222
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public void actionPerformed(AnActionEvent anActionEvent) {

WriteCommandAction.runWriteCommandAction(writeContext.fetchProject(), () -> {
CommandCommandTypeProcessorFactory.decide(writeContext, WriteCommand.Command.POPULATE_SWAGGER_TO_JAVA_DOC).writeElement();
CommandCommandTypeProcessorFactory.decide(writeContext, WriteCommand.Command.DELETE_TAG).writeElement();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public void actionPerformed(AnActionEvent anActionEvent) {

WriteCommandAction.runWriteCommandAction(writeContext.fetchProject(), () -> {
CommandCommandTypeProcessorFactory.decide(writeContext, WriteCommand.Command.POPULATE_SWAGGER_TO_JAVA_DOC).writeFile();
CommandCommandTypeProcessorFactory.decide(writeContext, WriteCommand.Command.DELETE_TAG).writeFile();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public void actionPerformed(AnActionEvent anActionEvent) {

WriteCommandAction.runWriteCommandAction(writeContext.fetchProject(), () -> {
CommandCommandTypeProcessorFactory.decide(writeContext, WriteCommand.Command.RE_GENERATE_SWAGGER_TO_JAVA_DOC).writeElement();
CommandCommandTypeProcessorFactory.decide(writeContext, WriteCommand.Command.DELETE_TAG).writeElement();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public void actionPerformed(AnActionEvent anActionEvent) {

WriteCommandAction.runWriteCommandAction(writeContext.fetchProject(), () -> {
CommandCommandTypeProcessorFactory.decide(writeContext, WriteCommand.Command.RE_GENERATE_SWAGGER_TO_JAVA_DOC).writeFile();
CommandCommandTypeProcessorFactory.decide(writeContext, WriteCommand.Command.DELETE_TAG).writeFile();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cc.bitky.jetbrains.plugin.universalgenerate.action.actiongroup.base.AbstractBitkylinUniversalGenerateActionGroup;
import cc.bitky.jetbrains.plugin.universalgenerate.config.ActionConfig;
import cc.bitky.jetbrains.plugin.universalgenerate.config.setting.state.GlobalSettingsStateHelper;
import cc.bitky.jetbrains.plugin.universalgenerate.constants.ActionEnum;
import cc.bitky.jetbrains.plugin.universalgenerate.constants.ActionGroupEnum;
import cc.bitky.jetbrains.plugin.universalgenerate.factory.ActionFactory;
Expand All @@ -24,6 +25,9 @@ public class GenerateAnnotationActionGroup extends AbstractBitkylinUniversalGene
public AnAction @NotNull [] getChildren(@Nullable AnActionEvent anActionEvent) {
ActionConfig actionConfig = new ActionConfig();
if (DumbService.isDumb(anActionEvent.getProject())) {
if (!GlobalSettingsStateHelper.getInstance().isContextMenuShowed()) {
anActionEvent.getPresentation().setVisible(false);
}
anActionEvent.getPresentation().setEnabled(false);
updateGroupText(anActionEvent, actionConfig, ActionGroupEnum.GENERATE_ANNOTATION, actionConfig.fetchTextForDumbMode());
return new AnAction[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cc.bitky.jetbrains.plugin.universalgenerate.action.actiongroup.base.AbstractBitkylinUniversalGenerateActionGroup;
import cc.bitky.jetbrains.plugin.universalgenerate.config.ActionConfig;
import cc.bitky.jetbrains.plugin.universalgenerate.config.setting.state.GlobalSettingsStateHelper;
import cc.bitky.jetbrains.plugin.universalgenerate.constants.ActionEnum;
import cc.bitky.jetbrains.plugin.universalgenerate.constants.ActionGroupEnum;
import cc.bitky.jetbrains.plugin.universalgenerate.factory.ActionFactory;
Expand All @@ -24,6 +25,9 @@ public class SwaggerToJavaDocActionGroup extends AbstractBitkylinUniversalGenera
public AnAction @NotNull [] getChildren(@Nullable AnActionEvent anActionEvent) {
ActionConfig actionConfig = new ActionConfig();
if (DumbService.isDumb(anActionEvent.getProject())) {
if (!GlobalSettingsStateHelper.getInstance().isContextMenuShowed()) {
anActionEvent.getPresentation().setVisible(false);
}
anActionEvent.getPresentation().setEnabled(false);
updateGroupText(anActionEvent, actionConfig, ActionGroupEnum.SWAGGER_TO_JAVA_DOC, actionConfig.fetchTextForDumbMode());
return new AnAction[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ protected void updateGroupText(AnActionEvent anActionEvent,
ActionConfig actionConfig,
ActionGroupEnum actionGroupEnum,
String scope) {
anActionEvent.getPresentation().setText(actionConfig.fetchActionGroupTitleByActionGroupEnum(actionGroupEnum) + "-" + scope);
anActionEvent.getPresentation().setText(actionConfig.fetchActionGroupTitle(actionGroupEnum) + " - " + scope);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public class ActionConfig {
ACTION_GROUP_MAP.put(ActionGroupEnum.GENERATE_ANNOTATION, GENERATE_ENTRY_ANNOTATION);
}

public String fetchActionTitleByActionEnum(ActionEnum actionEnum) {
public String fetchActionTitle(ActionEnum actionEnum) {
LocalizationEnum localizationEnum = ACTION_MAP.get(actionEnum);
if (localizationEnum == null) {
return localizedText(LocalizationEnum.EMPTY);
}
return localizedText(localizationEnum);
}

public String fetchActionGroupTitleByActionGroupEnum(ActionGroupEnum actionGroupEnum) {
public String fetchActionGroupTitle(ActionGroupEnum actionGroupEnum) {
LocalizationEnum localizationEnum = ACTION_GROUP_MAP.get(actionGroupEnum);
if (localizationEnum == null) {
return localizedText(LocalizationEnum.EMPTY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ public String radioButtonLanguageChinese() {
return localizedText(LocalizationEnum.RADIO_BUTTON_LANGUAGE_CHINESE);
}

public String labelScopeOfEffect() {
return localizedText(LocalizationEnum.LABEL_SCOPE_OF_EFFECT);
}

public String checkBoxSwaggerEffected() {
return localizedText(LocalizationEnum.CHECK_BOX_SWAGGER_EFFECTED);
}

public String checkBoxProtostuffEffected() {
return localizedText(LocalizationEnum.CHECK_BOX_PROTOSTUFF_EFFECTED);
}

public String labelContextMenu() {
return localizedText(LocalizationEnum.LABEL_CONTEXT_MENU);
}

public String checkBoxShowed() {
return localizedText(LocalizationEnum.CHECK_BOX_SHOWED);
}


private String localizedText(LocalizationEnum localizationEnum) {
return LocalizationConfigFactory.name(localizationEnum);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cc.bitky.jetbrains.plugin.universalgenerate.config.localization;

import cc.bitky.jetbrains.plugin.universalgenerate.config.setting.state.GlobalSettingsState;
import cc.bitky.jetbrains.plugin.universalgenerate.config.setting.state.GlobalSettingsStateHelper;
import cc.bitky.jetbrains.plugin.universalgenerate.constants.LocalizationEnum;

/**
Expand All @@ -11,8 +11,8 @@ public final class LocalizationConfigFactory {
private LocalizationConfigFactory() {
}

private static GlobalSettingsState globalSettingsState() {
return GlobalSettingsState.getInstance();
private static GlobalSettingsStateHelper globalSettingsState() {
return GlobalSettingsStateHelper.getInstance();
}

public static GlobalSettingLocalizationConfig config() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@
<text value="English"/>
</properties>
</component>
<component id="b37a8" class="javax.swing.JLabel" binding="labelEffectsTo">
<component id="b37a8" class="javax.swing.JLabel" binding="labelScopeOfEffect">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Label"/>
<text value="scope of effect"/>
</properties>
</component>
<component id="362e8" class="javax.swing.JCheckBox" binding="checkBoxSwaggerEffected">
<component id="362e8" class="javax.swing.JCheckBox" binding="checkBoxSwaggerAffected">
<constraints>
<grid row="1" column="1" 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="CheckBox"/>
<text value="Swagger"/>
</properties>
</component>
<component id="8b331" class="javax.swing.JRadioButton" binding="radioButtonLanguageChinese">
Expand All @@ -61,28 +61,28 @@
<text value="中文"/>
</properties>
</component>
<component id="30bd7" class="javax.swing.JCheckBox" binding="checkBoxProtostuffEffected">
<component id="30bd7" class="javax.swing.JCheckBox" binding="checkBoxProtostuffAffected">
<constraints>
<grid row="1" 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>
<text value="CheckBox"/>
<text value="Protostuff"/>
</properties>
</component>
<component id="39070" class="javax.swing.JLabel" binding="labelEnabled">
<component id="39070" class="javax.swing.JLabel" binding="labelContextMenu">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Label"/>
<text value="context menu"/>
</properties>
</component>
<component id="56324" class="javax.swing.JCheckBox" binding="checkBoxEnabled">
<component id="56324" class="javax.swing.JCheckBox" binding="checkBoxShowed">
<constraints>
<grid row="2" column="1" 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="CheckBox"/>
<text value="showed"/>
</properties>
</component>
</children>
Expand Down
Loading

0 comments on commit 6584f11

Please sign in to comment.