📜 ⬆️ ⬇️

10 opportunities to be more productive with Eclipse for Java developers



Many of you know how effectively using hotkeys , code patterns and a very cool search string (Quick Access) improves performance, but I would like to talk about ten possibilities that not everyone knows.

1. Code Recommenders


Code Recommenders - a delightful smart plugin, prompting code when writing. Previously, when we pressed Ctrl + Space, we saw all the methods, variables, and patterns, many of which could be completely useless; Code Recommenders plug-in chooses useful methods that are applicable in this case and organizes them by relevance - the likelihood with which we use the method in this context. And SnipMatch from Code Recommenders allows you to insert whole blocks of generic code. For details and installation here .



')

2. Type Filters


Type Filters remove the recommendations of selected types from anywhere. Just from everywhere. Eclipse PDE developers, for example, constantly interfere with Label, Button and other AWT classes, because they write to SWT, and even more so there is no point in meeting the List from AWT if you are writing a library. So we go to the Preferences ... no, not that way. Press Ctrl + 3 and start typing “Type Filters”, go to the appropriate settings page and add java.awt * and javax.swing * if necessary.



3. Favorites


There is also another case - when you always want to see some kind of static methods in your heart. For example, I often use the preconditions from the Guava library - Preconditions.checkArgument (boolean) and Preconditions.checkNotNull (T), which are so basic a necessity that when I configure Eclipse, I immediately go to Favorites and add there com.google.common.base. Preconditions.



4. Organize imports on save


It is possible that someone has already developed a reflex to press Ctrl + Shift + O to clean up unnecessary imports at the sight of yellow stripes at the top of the vertical scroll bar of the editor, and perhaps someone presses this key combination unconditionally before saving. But do not worry so, you can not do this - go to “Save Actions”, select “Perform the selected actions on save” and make sure that “Organize imports” is selected - now unnecessary imports will be deleted while saving. By the way, there are many more useful actions, such as placing missing Override annotations, deleting unnecessary type conversions, deleting dead code or formatting only edited lines, and even there are such “fun” features like converting normal for in foreach or nameless classes into lambdas .



5. Display


Display is a view that gives you the power to use the debugger like a real ninja. The code from the Display view runs in the context of current debugging. We write a line of code, select it, press Ctrl + U, and the code starts, and we press Ctrl + Shift + V - the code not only starts, but the result of its call is printed next to our code in Display. In addition, the selected text can be sent to Watch Expressions. All these actions are also available on the view toolbar.



Remarks



6. Show Logical Structure


One of the most unpleasant things when debugging is to tinker with the contents of a TreeMap or LinkedList, because in the Variables view they are presented in an inconvenient way, which corresponds to their actual structure, but does not correspond to the logical structure. The “Show Logical Structure” button on the toolbar of the Variables view makes it so that we see the contents of such collections (and not only) in a form convenient for us. At the same time, this button changes the appearance of the display of objects when you hover the mouse. This button looks like a tree image, next to which there is a yellow arrow on the left.



7. Bookmarks


Bookmarks - the bookmark view itself. It can be useful when you need to parse a whole ton of some code, because it allows you to go to the “selected places” of the code and take notes on them - bookmarks are added by clicking on the area to the left of the editor, “Add Bookmark ...”, but better, of course, assign a hotkey (for example, Ctrl + B - it is still useless, because it is assigned to “Build All” by default).



8. Split Editors


After 12 years, 200 votes, and 181 comments , the separation of editors was implemented in Eclipse. The horizontal split is Ctrl + _ (Ctrl + Shift + -), and the vertical split is Ctrl + {(Ctrl + Shift + [). Hooray! We can edit two parts of a file at the same time! By the way, these two parts are perceived as different editors when switching between editors (by pressing Ctrl + F6 or Ctrl + Shift + E, but not by pressing Ctrl + E).



9. FindBugs, Checkstyle, PMD Eclipse


Various code analyzers help to find copy-paste, deviations from programming standards and other potential problems in the code even before these problems leaked into the bugtracker (and, as a result, worsened the customer's opinion about your company), moreover, such analyzers inevitably help better understand the java library and more effectively use the language itself. Naturally, for many such useful tools, there is integration with Eclipse.



I’ll note that FindBugs, Checkstyle and PMD Eclipse are all in the Eclipse Marketplace, so installing them is extremely simple via the Help → Eclipse Marketplace ... without googling or visiting any sites.

10. Plugins


The power of Eclipse is generally the ability to use any plugins that you may need, this applies not only to code review plugins. Need a Java Disassembler? There is a jd-eclipse. Need integration with Maven or Apache Ivy? There are m2e and apache ivyde. Can't understand 5000 lines of build code for your Ant project? There is an ant visualizer. Worried about dead code? There is an Unnecessary Code Detector. Want to “draw” SWT windows with a WYSIWYG editor? There is a WindowBuilder.



11. Secret opportunity


To be interested in productivity - to be interested in how to properly use the tools that you use, and what innovations are introduced in them.

And what features increase your productivity in Eclipse?

Materials on the topic


  1. Eclipse for Java Developers. Navigation and editing - article on Habré about hotkeys in Eclipse IDE for Java Develipers. By the way, Ctrl + Shift + L is the hot key of all hot keys.
  2. My Eclipse IDE - Jordi Böhme López
    suggests 10 useful features of Eclipse.
  3. Tips and Tricks (JDT) from the Eclipse documentation are a lot of simple tips covering quite a lot of JDT functionality.
  4. Eclipse Luna - New And Noteworthy - some new features of Eclipse Luna, in particular, opportunities for Java developers .

Source: https://habr.com/ru/post/244713/


All Articles