直接从dao生成xml放法插件_自己开发 idea 插件 gotoMapper

开发中 我们经常需要再dao.java 和mapper.xml 中来回切换。每次找mapper的时候有点麻烦。就想找一个能直接冲dao方法中跳到mapper文件中的插件。找到后是收费的,就想自己搞个插件。

创建插件项目 new-project

c898ad8e38fe299f6811df7ee50f152c.png

选择 IntelliJ Platform Plugin

ce31cedd7f2bce839f03971488ef5178.png

next

fa61c92135f13b88f324e806b5ede910.png

填写项目名称和路径 finish

src 文件夹 右键

62443e4432f679bb138c1b824aabd462.png

选择action 出现如下窗口

填写信息

选择JavaGenerateGroup1

first 设置快捷键

ok

fd202e7039bf3b18d3792ee55df13e8d.png

ctrl+shift+alt+x 快捷键有可能会被占用 建议先查询下快捷键是否被占用,在使用

确定后 plugin 文件 actions 会增加一个action

e79b8df096689c96d2dc5fef21eacd2e.png

src 中增加 文件

3a1a8da1d84bf9570f6e7b790c575d0e.png

action文件 代码

import com.intellij.openapi.actionSystem.AnAction;import com.intellij.openapi.actionSystem.AnActionEvent;import com.intellij.openapi.actionSystem.PlatformDataKeys;import com.intellij.openapi.editor.CaretModel;import com.intellij.openapi.editor.Editor;import com.intellij.openapi.editor.LogicalPosition;import com.intellij.openapi.editor.SelectionModel;import com.intellij.openapi.fileEditor.FileEditorManager;import com.intellij.openapi.fileEditor.OpenFileDescriptor;import com.intellij.openapi.project.Project;import com.intellij.openapi.util.text.StringUtil;import com.intellij.openapi.vfs.VirtualFile;import com.intellij.psi.PsiElement;import com.intellij.psi.PsiFile;import com.intellij.psi.search.PsiShortNamesCache;import com.intellij.psi.xml.XmlFile;public class GoToMapperAction extends AnAction { @Override public void actionPerformed(AnActionEvent e) { //获取鼠标所在元素 PsiElement psiElement = e.getData(PlatformDataKeys.PSI_ELEMENT); if (psiElement == null){ return; } //获取到方法名 String methodName = psiElement.toString().replace("PsiMethod:
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值