简体   繁体   中英

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 :

  1. Right click on project
  2. Select PMD from the context menu
  3. Select "Check Code With PMD"

It's okay doing this once in 10 minutes, but not really once in 30 seconds.

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. That has the disadvantage of giving you a PMD report outside the IDE. 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.

You can try 3rd party scripting tool 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 . For example you could use a combination like Ctrl + Alt + ? for this.

Go to Window > Preferences > General > Keys > Type " Check Code wit... " into the search box. 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.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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