SnipMatch, Top Eclipse Luna Feature #4

SnipMatch, Top Eclipse Luna Feature #4

Code Recommenders is one of the most exciting and innovative plug-ins available for Eclipse. With standard content-assist, Eclipse will show you all the method calls, variables uses, template options, etc… for the current context. Most of these options are irrelevant, and if you’re learning a new API, all these options can be confusing. Furthermore, listing the code completion options in alphabetical order provides very little value. Code recommenders aims to fix this by displaying the available completion options according to their relevance.

cr

As we enter the final weekend before Eclipse Luna ships, the webmaster is busy moving all the bits into their final location. I’m going to spend some time off the grid, but before I go, I’m going to continue my countdown of The Top 10 Eclipse Luna Features I’m most excited about. Number 4 is SnipMatch, from the code recommenders project.

SnipMatch lets developers search for, and quickly insert, code snippets. API usage is often more than method calls, requiring proper setup, usage and possibly teardown code. With SnipMatch, entire blocks of templated code can be inserted with a single click. To use SnipMatch, install code recommenders and press CTRL+ALT+Space.

Screen Shot 2014-06-20 at 11.55.25 AM There is also a snippets view that shows all the available templates.

Screen Shot 2014-06-20 at 11.58.43 AM

By default, the snippets are fetched from a GitRepository (configured in Preferences -> Code Recommenders -> SnipMatch). Of course, you could fork this repository and modify it as you see fit.

Finally, SnipMatch allows you to edit or even add your own snippets using the JFace template language.

Screen Shot 2014-06-20 at 1.28.12 PM

Screen Shot 2014-06-20 at 1.29.11 PMOf course, while many of us are getting ready to enjoy the start of summer in the northern hemisphere, the code recommenders team is pushing ahead with more goodness for Luna SR1 (available in September) which includes better tools for creating snippets from existing code blocks.

Screen Shot 2014-06-20 at 1.38.17 PM

If you’ve developed an API, consider publishing snippets using SnipMatch to help developers get started. For more Eclipse Tips and Tricks, follow me on Twitter.

4 Comments
  • Arun Kumar
    Posted at 09:25, 2014-07-01

    This is awesome!!

  • mjordan
    Posted at 01:50, 2014-07-13

    For me, code recommenders simply don’t work.
    I’ve tried removing them and reinstalling, cleaning workspace and .eclipse folder.
    None of these actions help.
    When I hit CTRL+Space I obtain the default contest assist, but no code recommenders. There is no way to activate them (Eclipse 4.4 Luna + JDK 8 Update 5). Even moving up the “priority” for code recommenders in Window–>Preferences–>Java–>Editor–>Contest Assist–>Advanced don’t help.
    I will deinstall them.

  • Matteo
    Posted at 10:17, 2014-08-08

    Very interesting feature! An evolvement could be an analyzer for code that calculates how I use my own classes, so I could use it also with my classes. In that case is useful to learn which methods use in a large project, and also to speed up development.

  • Acres
    Posted at 17:13, 2014-08-25

    @mjordan, try ctl-alt-space instead!