Eclipse Tips and tricks

In a few days, Eclipse Juno will be released. This changes the version number from 3.7 (Indigo) to 4.2 (Juno) and introduces several interesting changes. I scanned through the Trips and tricks section of the Java development user guide and found several interesting points to increase productivity. Not every change is only available in Eclipse Juno, however, these are the ones that I did not know before and will use in future:

  • Entering NPE is automatically replaced with NullPointerException when using CTRL + SPACE.  This works for any class in Code Completion! Next, I will only write IAE, ISE, LL, and many more.
  • Pressing CTRL during Code Completion does not introduce an additional pair of brackes () that has to be removed when changing a method. Normally, when you have list.add("ASDF"); and change the add method via Code Completion to remove, you get list.remove(o)("ASDF");. This is quite annoying. If you accept the remove method instead of ENTER with CTRL + ENTER, you will get list.remove("ASDF"); directly.
  • Compare With works on Files and on Directories. So you can compare complete directories including subdirectories and their files with this method.
  • Package View: You can provide package abreviations for long package names
  • You can configure forbidden and discouraged files for a specific library. This allows for better code quality in huge teams as this prevents the usage of, e.g., internal classes circumventing the appropriate interfaces
  • JUnit: You can run a single test by right clicking on the method Run As -> run as JUnit Test
  • Cursor is at a bracket: Quick Fix for deleting the sourrounding statement
  • ALT + SHIFT + Z: Sourround with can be used to create Runnables, while, if, for, try-catch, etc. blocks around (a) selected line(s).
  • ALT + SHIFT + UP/DOWN: Structured Selection following the bracket structures
  • You can activate the checking of redundant null checks, potential null pointer access and for null pointer access at Java > Compiler > Errors/Warnings / Null Analysis
  • You can activate the validation of the JavaDoc and its corresponding method as warnings in Java > Compiler > Javadoc settings.

Do you have any Eclipse tips or tricks that you use extensively?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s