-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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> |
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> |
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> |
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); | ||
} | ||
} |