简体   繁体   English

Eclipse:PMD shorcut(内置,自定义……)

[英]Eclipse: PMD shorcut (built, custom …)

This is probably a matter of utter laziness, but I am experiencing following problem: 这可能是完全懒惰的问题,但是我遇到了以下问题:

When I want to PMD check my code, I need to perform following steps : 当我想PMD检查我的代码时,我需要执行以下步骤:

  1. Right click on project 右键点击项目
  2. Select PMD from the context menu 从上下文菜单中选择PMD
  3. Select "Check Code With PMD" 选择“使用PMD检查代码”

It's okay doing this once in 10 minutes, but not really once in 30 seconds. 可以每10分钟执行一次,但实际上不是每30秒执行一次。

Is there some way to make this process faster? 有什么方法可以使此过程更快? Like using some shortcut (haven't found one though) or creating own? 像使用一些快捷方式(虽然找不到)还是创建自己的快捷方式?

Thanks 谢谢

You could write an Ant script that calls PMD and have it run whenever you save/build the project. 您可以编写一个调用PMD的Ant脚本,并在保存/构建项目时使其运行。 That has the disadvantage of giving you a PMD report outside the IDE. 这样做的缺点是无法在IDE外部提供PMD报告。 Which would negate any time savings from the original procedure. 这将抵消原始程序节省的任何时间。 It could be useful if you just want to know whether there are any errors or not. 如果您只是想知道是否有任何错误,这可能会很有用。

Or you could extend the Eclipse plugin to add a shortcut. 或者,您可以扩展Eclipse插件以添加快捷方式。

You can try 3rd party scripting tool autohotkey. 您可以尝试使用第三方脚本工具autohotkey。

;PMD on eclipse
^+m::                                ;Ctrl + Shift + m
    MouseClick, right, 686, 420      ;clicks somewhere in the middle
    Send {UP 4}                      ;select PMD in context menu
    Send {RIGHT}                     ;sub menu
    Send {UP}                        ;choose the 'Check code with PMD'
    Send {ENTER}                     
return 

It is not laziness but desire for efficiency. 这不是懒惰,而是对效率的渴望。

Yes, it's possible to add a key binding to Check Code with PMD . 是的,可以Check Code with PMD将密钥绑定添加到Check Code with PMD For example you could use a combination like Ctrl + Alt + ? 例如,您可以使用Ctrl + Alt + 吗? for this. 为了这。

Go to Window > Preferences > General > Keys > Type " Check Code wit... " into the search box. 转到Window > Preferences > General > Keys >在搜索框中键入“使用... 检查代码 ”。 You should find the Command and be able to add a binding to it. 您应该找到该命令,并能够为其添加绑定。

I have not tested this for PMD, but it's possible with nearly all Eclipse Plugins (à la Subclipse etc.) 我尚未针对PMD对此进行测试,但是几乎所有Eclipse插件(例如Subclipse等)都可以实现此功能

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM