Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
Forgus committed Jul 28, 2019
0 parents commit b0a95a4
Show file tree
Hide file tree
Showing 31 changed files with 1,338 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions api-generator.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PLUGIN_MODULE" version="4">
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/resources/META-INF/plugin.xml" />
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Binary file added api-generator.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
41 changes: 41 additions & 0 deletions out/production/api-generator/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<idea-plugin>
<id>site.forgus.plugins.api-generator</id>
<name>API Generator</name>
<version>1.0</version>
<vendor email="wenbin1876@gmail.com" url="http://www.forgus.site">Forgus</vendor>

<description><![CDATA[
API Generator.<br>
<em>Support generate markdown for dubbo api</em>
]]></description>

<change-notes><![CDATA[
<em>2.0</em>
Support upload to Yapi for REST api<br>
<em>1.0</em>
Support generate markdown for DUBBO api<br>
]]>
</change-notes>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version since-build="173.0"/>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
on how to target different products -->
<!-- uncomment to enable plugin in all products
<depends>com.intellij.modules.lang</depends>
-->

<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
</extensions>

<actions>
<!-- Add your actions here -->
<action id="api-generator.ID" class="ApiGenerateAction" text="API Generate"
description="upload to YAPI for REST api or generate markdown for Dubbo api">
<add-to-group group-id="EditorLangPopupMenu" anchor="first"/>
</action>
</actions>

</idea-plugin>
Binary file added out/production/api-generator/YapiDubboDTO.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
41 changes: 41 additions & 0 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<idea-plugin>
<id>site.forgus.plugins.api-generator</id>
<name>API Generator</name>
<version>1.0</version>
<vendor email="wenbin1876@gmail.com" url="http://www.forgus.site">Forgus</vendor>

<description><![CDATA[
API Generator.<br>
<em>Support generate markdown for dubbo api</em>
]]></description>

<change-notes><![CDATA[
<em>2.0</em>
Support upload to Yapi for REST api<br>
<em>1.0</em>
Support generate markdown for DUBBO api<br>
]]>
</change-notes>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version since-build="173.0"/>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
on how to target different products -->
<!-- uncomment to enable plugin in all products
<depends>com.intellij.modules.lang</depends>
-->

<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
</extensions>

<actions>
<!-- Add your actions here -->
<action id="api-generator.ID" class="ApiGenerateAction" text="API Generate"
description="upload to YAPI for REST api or generate markdown for Dubbo api">
<add-to-group group-id="EditorLangPopupMenu" anchor="first"/>
</action>
</actions>

</idea-plugin>
46 changes: 46 additions & 0 deletions src/ApiGenerateAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import com.google.gson.Gson;
import com.intellij.notification.*;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import site.forgus.plugins.apigenerator.normal.BuildMdForDubbo;
import site.forgus.plugins.apigenerator.normal.FieldDocVO;

import java.util.List;

public class ApiGenerateAction extends AnAction {

private static NotificationGroup notificationGroup;

static {
notificationGroup = new NotificationGroup("Java2Json.NotificationGroup", NotificationDisplayType.BALLOON, true);
}

@Override
public void actionPerformed(AnActionEvent e) {
Editor editor = e.getDataContext().getData(CommonDataKeys.EDITOR);
if (editor == null) {
return;
}
Project project = editor.getProject();
// Notification notification = notificationGroup.createNotification("Hey,you should config first before generate api docs!", NotificationType.ERROR);
// Notifications.Bus.notify(notification, project);
dubboApiUpload(e,project);
}
@Override
public void update(AnActionEvent anActionEvent) {
// Set the availability based on whether a project is open
Project project = anActionEvent.getProject();
anActionEvent.getPresentation().setEnabledAndVisible(project != null);
}


private void dubboApiUpload(AnActionEvent anActionEvent, Project project) {
// 获得dubbo需上传的接口列表 参数对象
List<FieldDocVO> fieldDocVOS = new BuildMdForDubbo().generateResponseFieldDocVOs(anActionEvent);
String jsonDoc = new Gson().toJson(fieldDocVOS);
System.out.println(jsonDoc);
}
}
Loading

0 comments on commit b0a95a4

Please sign in to comment.