Overview

Whenever you are using a new framework or API, the challenges are always the same: to learn about all the expectations and usage rules implicit in the API. This can be a very time-consuming process. Fortunately, you are not alone in this; often, others have already overcome these challenges for the API in question. But how to tap into their hard-won knowledge?

This is where Eclipse Code Recommenders comes in. Code Recommenders automatically analyzes existing code using that API and extracts common usage rules and patterns from it. In the form of recommendation models, this knowledge is then fed back into your IDE. Powered by these models, Code Recommenders’ intelligent code completion and extended API documentation then propose to you what others have done in a similar situation. This helps you get up to speed with the new framework or API without countless hours of searching the Internet on how to solve a common problem.

Setup

Setting up Code Recommenders is extremely easy, simply install and activate it.

Installation

Access the marketplace via Help > Eclipse Marketplace … and search for “Code Recommenders”. From the search results, select “Eclipse Code Recommenders” and click Install. Next, just confirm this selection and accept the license agreement. Finally, click Finish and restart your Eclipse IDE when prompted. The Eclipse Marketplace Client offering to install Eclipse Code Recommenders

Activation

To activate Code Recommenders, trigger Content Assist on an instance of a well-known type like java.lang.String or java.util.List. The first completion proposal will ask you to activate Code Recommenders. Activate Code Recommenders by pressing Enter

Simply press Enter to do so. That’s it! You are now ready to use Code Recommenders.

There is a lot more to Code Recommenders, though. Read along for information on what features Code Recommenders brings you and how to configure them to your needs.

Intelligent Code Completion

Eclipse Code Recommenders adds several completion engines to Eclipse’s Content Assist (also known as code completion). Each of these engines makes one aspect of code completion more intelligent.

Call Completion

The Call Completion engine, for example, provides you with recommendations of likely methods to call whenever you trigger code completion on an object, be it a variable, field, or constant. The call completion engine bases its recommendations on what other developers in a similar situation have called on an object of the given type. The call completion engine proposing the most likely method calls in the current situation

Override Completion

The Override Completion engine provides you with recommendations which methods you are most likely to override when triggering code completion in the body of class. The override completion engine proposing the most likely method overrides in the current situation

Subwords Completion

The Subwords Completion engine works together with any other completion engine, or completely on its own. It allows you to enter any part of a completion’s text instead of only exact prefixes. The subwords completion engine filters all proposals that do not match the given subword

Chain Completion

The Chain Completion engine suggests entire call-chains of methods that return the currently expected type. It works both as a Quick Fix (Ctrl/Cmd + 1) or as its own Content Assist engine reached by multiple Ctrl + Space presses. The chain completion engine proposing three method calls that return the expected IStatusLineManager

Adaptive Template Completion

The Adaptive Template Completion engine suggests multiple methods that frequently occur together on an object. It works as its own Content Assist engine reached by multiple Ctrl + Space presses. The adaptive template completion proposing three method calls at once on a JFace widget The Adaptive Template Completion engine can be triggered both on object references (pictured above) and type references (pictured below). The adaptive template completion proposing three method calls at once on a SWT Type

Mylyn Completion since 2.0.7

Code Recommenders can work together with Mylyn if the separate Mylyn Integration feature is installed. Any call-completion proposal that is deemed interesting or a landmark by Mylyn is recommended by Code Recommenders. The Mylyn completion proposing a method used by developers in the current task

Extended Documentation

Eclipse Code Recommenders not only assists you through its intelligent code-completion, it also supplies you with extended documentation on many frameworks and APIs. You can find all such documentation in the API Docs view.

Call Recommendations

The Call Recommendations page shows you which methods you likely want to call on a selected object. This page uses the same information as the call completion engine; thus, its recommendations are context-sensitive and take into account how the object was created and what methods have already been called. The Call Recommendations API Docs page showing method call recommendations

Overrides

The Overrides page shows you which methods you likely want to override when subclassing a selected type. This page uses the same information as the overrides completion engine. Additionally, it shows you exactly how often other developers have overridden specific methods. The Overrides API Docs page showing method override recommendations

Self-calls

When overriding methods, the Self-calls page can show you which super calls to make based on other subclasses of the same type. The Self-calls API Docs page showing super call recommendations

Static Hooks

The Static Hooks page allows you to quickly locate all public static (hook) methods available in the selected package. The Static Hooks API Docs page showing all public static methods available for a selected package

Snipmatch since 2.1.0

Snipmatch provides a quick and easy way to search for and insert code snippets. To trigger Snipmatch snippet completion, press Ctrl + Alt + Space. This opens a search box view that allows you to search for code snippets. Snipmatch will find Snippets with matching name, description, keywords, or tags, so you do not need to remember the exact names of your favorite snippets. The Snipmatch snippet completion in Action

You can navigate through the list of found snippets using the Up or Down keys. Whenever you select a snippet this way, a preview will show you how the snippet will look like when inserted into your code, as Snipmatch automatically fills in local variables or fields of appropriate types. To insert the selected snippet into the code, simply press Enter.

When you enter more than one search term, Snipmatch will find only snippets that match all of them; there is an implicit AND operator between terms. If you want to find snippets that match any of the given search terms instead, add the OR operator between them.

You can furthermore restrict search terms to specific fields of a snippet, by prepending the term with the name of that field and a colon, e.g., tag:swt. The following fields are recognized by Snipmatch:

  • name
  • description
  • extra
  • tag

Note that tag terms require exact matches. Thus, sw will not match the tag swt.

By default, Snipmatch Snippet Completion uses the key binding of Ctrl + Alt + Space. If this conflicts with a key binding of another installed plugin or if you simply want to change the binding to one that suits you better, you can do so on the General > Keys preference page. Search for the Snipmatch Snippet Completion command and change its binding accordingly.

Snippet Editor

The form-based Snippet Editor lets you create new snippets or edit existing ones. On its two tabs, you can view and edit both the snippet’s code as well as important metadata, like the snippet’s name or description.

Metadata

The Metadata tab gives access to information that helps you find the snippet. The Snippet editor’s Metadata page The following fields are available:

  • Name - the snippet’s name, displayed in the Snipmatch snippet completion
  • Description - a plain text describing the snippet’s purpose
  • Location - restricts the snippet to be applicable only at appropriate positions of the source code
  • Extra search terms - a list of search terms, used to define alternative search terms besides the name and description
  • Tags - a list of tags, used to group snippets into logical groups, displayed in the Snipmatch snippet completion
  • Dependencies - restricts the snippets to be applicable only if the dependencies are on the current project’s classpath
  • UUID - a unique identifier for a snippet (generated automatically, cannot be edited)

Besides UUID, all fields are automatically searched when entering a query in the Snipmatch snippet completion.

since 2.1.9 The Location of a snippet can make the snippet available at certain locations only:

  • File - Anywhere in Java files
  • Java - Java code, not Javadoc
  • Java statements - Java statement blocks (e. g. within a method body)
  • Java type members - Java field declarations
  • Javadoc - Javadoc blocks

since 2.1.10 The Dependencies of a snippet can be declared using a coordinate system similar to Maven. Clicking the Add… button allows you to select which APIs the snippet makes use of. This will open a dialog that lists all of the coordinates identified by Code Recommenders.

Raw Source

The Raw Source tab lets you edit the snippet code that is inserted when applying a snippet. All snippets are defined using the JFace template language. The Snippet editor’s Snippet Source page

When editing the snippet source of existing snippets and saving the changes, you will be asked whether you simply want to save the changes or if you want to store them as a new snippet. In the latter case, the new snippet gets a newly generated UUID.

Install Extensions

You can install extensions that will add further functionality to Snipmatch or provide additional snippet repositories. To see the available extensions and install them, click on the Install Extensions icon in the top-right of the editor.

Create Snippet From Selection since 2.1.1

To quickly create a new snippet from scratch, simply select the Java code you wish to convert into a snippet, right-click and select Create Snippet… This will open the Snippet Editor with the selected code already converted into the template language. Note that the snippet source may need to be edited further, as the conversion does not yet support all of the template language’s features. Create snippet from selection

Reference

In the following, you will find a detailed description of all preferences, views, and completion tips offered by Eclipse Code Recommenders.

Preferences

Eclipse Code Recommenders offers several areas of customization, all of which are accessible through the Eclipse preferences.

Code Recommenders > Completions

You can selectively enable and disable Eclipse Code Recommenders’ session processors on the Code Recommenders > Completions preference page. Some of these processors also allow for further customization. You can configure them by either selecting the engine on the Code Recommenders > Completions preference page and then clicking Configure or by directly navigating to the processor’s preference page. (All session processors that ship with Eclipse Code Recommenders add their preference pages under the Code Recommenders Completions category, but third-party processors may use a different category.) The Code Recommenders Completions preference page

At the moment, the following session processors are available:

Base Relevance Processor
The Base Relevance Completion processor contributes the JDT relevance as base relevance for each proposal. It thus ensures that the proposals are consistent with what is presented by JDT. We therefore suggest that you keep this engine enabled.
Call-Completion Processor
The Call-Completion Processor proposes methods you are likely to call in the current context.
Completion-Tips Processor
The Completion-Tips Processor provides tips on how to enhance your code completion experience. It is described in detail in its own manual section.
Mylyn Completion Processor
The Mylyn Completion Processor ranks proposals according to the relevance computed by Mylyn.
Overrides-Completion Processor
The Overrides-Completion Processor proposes methods you are likely to override in the current context.
Subwords-Completion Processor
The Subwords-Completion Processor adds subwords matching and subwords relevance ranking to Content Assist.

Code Recommenders > Advisors

Code Recommenders uses so-called advisors to assign project coordinates to your projects’ dependencies. These coordinates are used to identify the correct Code Recommenders models for each dependency. Several advisors, each with their own identification strategy, are available at the Code Recommenders > Advisors preference page. Hover above an advisor to get a detailed description of how it identifies a dependency’s coordinate.

When trying to assign a coordinate to a dependency, Code Recommenders will use advisors in the order they appear in this list. You can selectively enable or disable each advisor and change their priority by using the Up and Down buttons. The Code Recommenders Completions preference page

At the moment, the following advisors are available:

Manual mappings
The manual mappings advisor assigns project coordinates based on a mapping performed manually in the Project Coordinates view. This advisor is applicable to all kinds of dependencies.
Shared manual mappings (experimental)
The experimental shared manual mappings advisor assigns project coordinates based on a manual-mappings file shared through the model repository. This advisor is applicable to all kinds of dependencies.
Apache Maven pom.properties
The Apache Maven pom.properties advisor assigns project coordinates based on a pom.properties file. This file is part of many JARs build with Apache Maven or similar tools. This advisor is applicable to JAR files only.
Apache Maven pom.xml
The Apache Maven pom.properties advisor assigns project coordinates based on a pom.xml file. This file is part of all projects build with Apache Maven. This advisor is applicable to workspace projects only.
JRE Execution Environment
The JRE Execution Environment advisor assigns project coordinates based on the Execution Environment that Eclipse associates with the JRE. This advisor is applicable to the JRE only.
JRE release file
The JRE release file advisor assigns project coordinates based on the release file shipped with most Java Runtime Environments. This advisor is applicable to the JRE only.
JRE directory name
The JRE directory name advisor assigns project coordinates based on name of the Java Runtime Environment’s home directory. This advisor is applicable to the JRE only.
Android platform directory name
The Android platform directory name advisor assigns project coordinates based on the platform directory used by the Android SDK. This advisor is applicable to JAR files only.
OSGi Bundle-SymbolicName (Model repository)
The OSGi Bundle-SymbolicName (Model repository) advisor assigns project coordinates based on an OSGi dependency’s Bundle-SymbolicName header. The Bundle-SymbolicName is searched for in all registered model repositories. This advisor is applicable to workspace projects and JAR files only.
SHA-1 Fingerprint (Model repository)
The SHA-1 Fingerprint (Model repository) advisor assigns project coordinates based on a dependency’s SHA-1 fingerprint. The fingerprint is searched for in all registered model repositories. This advisor is applicable to JAR files only.
OSGi MANIFEST.MF
The OSGi MANIFEST.MF advisor assigns project coordinates based on an OSGi MANIFEST.MF. The coordinate is derived from the Bundle-SymbolicName and Bundle-Version headers found therein. This advisor is applicable to workspace projects and JAR files only.
SHA-1 Fingerrint (Maven Central)
The SHA-1 Fingerrint (Maven Central) advisor assigns sproject coordinates based on a dependency’s SHA-1 fingerprint. The fingerprint is searched for in the Maven Central repository. This advisor performs a HTTP request. It is applicable to JAR files only.

Code Recommenders > Completions > Calls

You can customize the Call Completion’s settings on the Code Recommenders > Completions > Calls preference page. Here you can adjust how many method calls Code Recommenders’ intelligent call completion proposes and how exactly these proposals are displayed. The Call Completion preference page

Code Recommenders > Completions > Chains

You can customize the Chain Completion’s settings on the Code Recommenders > Completions > Chains preference page. Here you can adjust the minimum and maximum depth of call chains, as well as the maximum number of chains to find. Increasing these values will slow down Chain Completion with the user adjustable timeout serving as an upper bound for the search time. You can specify ignored Object types. No call chains through ignored types will be found. The Chain Completion preference page

Chain Completion always works as a Quick Fix (Ctrl/Cmd + 1). If you want to use it through Content Assist (Ctrl + Space) as well, you have to enable Chain Proposals (Recommenders) in the Java > Editor > Content Assist > Advanced preference page. Add it to the Content Assist cycling checkbox list. Chain Proposals enabled in the advanced Content Assist preference page

Note that that Chain Proposals cannot be active on the default Content Assist page as its slight delay would slow down your workflow. Activating it on the default Content Assist page will have no effect.

Code Recommenders > Completions > Overrides

You can customize the Override Completion’s settings on the Code Recommenders > Completions > Overrides preference page. Here you can customize how many methods Code Recommenders’ intelligent overrides completion proposes and how exactly these proposals are displayed. The Overrides Completion preference page

Code Recommenders > Completions > Subwords

Code Recommenders’ subwords completion requires little customization. As it performs more comprehensive matching than JDT for many constructor or type proposals. you may experience timeouts during Content Assist. If that is the case, you can switch to less comprehensive matching for such proposals on the Code Recommenders > Completions > Subwords preference page. The Subwords Completion preference page

Code Recommenders > Models

Eclipse Code Recommenders relies on so-called model repositories to provide recommendation models for intelligent code completion and enhanced API documentation. You can add, edit, and remove model repositories on the Code Recommenders > Models preference page. The default model repository provides Code Recommenders models for the Java Runtime Environment (JRE) and org.eclipse classes.

If you wish to add Code Recommenders support for more APIs, add new model repositories by pressing the New... button. If more than one repository provides models for the same class, the respective models are downloaded from the first repository in the list. You can change this priority by using the Up and Down buttons. The Code Recommenders Models preference page

Code Recommenders > Snipmatch since 2.1.0

By default, Snipmatch obtains its snippets from a pre-configured Git repository hosted by the Eclipse Foundation. You may disable or remove any repository to prevent the Snipmatch completion from finding snippets from that repository. Note that the default repository, as well as repositories provided by plugins, cannot be removed, but may be disabled. You can add new snippet repositories on the Code Recommenders > Snipmatch preference page by using the New… button. The Code Recommenders Snipmatch preference page Select the type of repository you want to add (e. g. a Git-Based Snippet Repository), give it a name and enter the URIs of your Git repository to the respective Fetch URI and Push URI fields. You may configure different URIs for fetching and pushing. In order to support code review systems like Gerrit, you can adjust the branch prefix. If you are not using a code review system, the branch prefix is most likely refs/heads. For Gerrit, the branch prefix is refs/for. The Code Recommenders Snipmatch preference page

Importing/Exporting Preferences since 2.0.6

You can export preferences related to the model repositories consulted by Code Recommenders. This includes repository URIs and the list of advisors used to assign project coordinates to dependencies. This can be useful to distribute common settings within your team.

To export the preferences go to File > Export > General > Preferences and select Code Recommenders Model Repositories. Choose a location where the preferences are to be saved and click Finish. The Eclipse Export Preferences dialog

To import settings from an existing preferences file, go to File > Import > General > Preferences and browse for the preferences file. Select Code Recommenders Model Repositories and click Finish.

Views

Code Recommenders has a number of views that offer you extended documentation as well as information about your projects, their dependencies, and Code Recommenders models for them.

API Docs

Available under Window > Show View > Other... > Code Recommenders > API Docs, the API Docs view is the one-stop solution for all your documentation needs. It features several pages that offer enhanced documentation about your current selection. Simply select a type or object in your code editor to get more information on how to use it. The Javadoc API Docs page showing documentation on the selected type

The available pages are:

Javadoc
The Javadoc page gives you quick access to classic Javadoc documentation with all the features of Eclipse’s built-in Javadoc view. Thus, the API Docs view can act as a complete replacement for it; there’s no need to waste precious screen space with two views.
Call Recommendations
The Call Recommendations page shows you which methods you likely want to call on a selected object. This page uses the same information as the call completion engine; thus, its recommendations are context-sensitive and take into account how the object was created and what methods have already been called.
Overrides
The Overrides page shows you which methods you likely want to override when subclassing a selected type. This page uses the same information as the overrides completion engine. Additionally, it shows you exactly how often other developers have overridden specific methods.
Self-calls
The Self-calls page shows show you which super calls to make based on other subclasses of the same type.
Static Hooks
The Static Hooks page allows you to quickly locate all public static (hook) methods available in the selected package.
Templates
The experimental Templates page gives you access to example code snippets for selected types.

Dependency Overview

The Dependency Overview view (available under Window > Show View > Other... > Code Recommenders > Dependency Overview) shows you for which of your projects’ dependencies there are recommendation models available and in what version. The Dependency Overview view showing the dependencies of a project

Model Repositories

Eclipse Code Recommenders downloads the recommendation models for the APIs you use from so-called model repositories. The Model Repositories view (available under Window > Show View > Other... > Code Recommenders > Model Repositories) gives you an overview of the contents of all your configured repositories. Using this view, you can also add or remove new model repositories. The Model Repositories view showing the contents of the default model repository

The view lists the APIs the respective model repository contains recommendation models for in terms of their so-called coordinate. For each known coordinate, the model repository may contain one ore more models of different types (CALL, OVRD, OVRP, OVRM, SELFC, and SELFM) used by the different completion engines. For each type, a blue dot indicates that this type of model is available whereas a red cross indicates that the type of model is unavailable for the coordinate in question. Once a model has been downloaded, the blue dot changes to a green check mark.

Downloaded models are available even when working offline. This way, you can continue working with Code Recommenders even without an Internet connection. You can manually trigger a model download, e.g., to prepare for being offline, by right clicking on a coordinate and selecting Download models from the context menu.

CALL and SELFC models are used by the intelligent call completion engine and the Call Recommendations API Docs view. OVRD, OVRM and OVRP models are used for intelligent override completion engine and the Overrides API Docs view.

Project Coordinates

To make recommendations for the APIs you use, Eclipse Code Recommenders needs to identify them. It does so by assigning a so-called project coordinate to each of your projects’ dependencies. The Project Coordinates view (available under Window > Show View > Other... > Code Recommenders > Project Coordinates) shows the mapping from each dependency in your workspace to a project coordinate. The Project Coordinates view classpath JARs and Projects with mapped Code Recommenders model coordinates

Hovering over the coordinate of an entry will give you further information on how exactly Code Recommenders made the assignment it did, i.e., which advisors suggested which project coordinate. In cases where a correct mapping cannot be found automatically, a double click on a coordinate lets you enter a coordinate manually. You may also consider enabling additional advisors or re-ordering existings ones on the Code Recommenders > Advisors preference page.

Snippets View

Available under Window > Show View > Other... > Code Recommenders > Snippets, the Snippets view lets you view all available snippets at once. It allows you to add new snippets or snippet repositories, remove existing ones, or edit snippets using the Snippet Editor. Right-click on snippets or repositories to get further options. The Snippets view

Completion Tips since 2.0.5

The Completion Tips engine provides tips on how to enhance your code completion experience. It may propose, e.g., to install extensions to Code Recommenders that add further features. To do so, it displays additional proposals at the bottom of the list. The completion tips engine proposing to install extensions These proposals are only shown until selected by keyboard; once you have seen the associated tooltip, they won’t show up again.

At the moment, the following completion tips are available:

Enable subwords completion?
Selecting this tip enables Code Recommenders’ subword completion.
Not what you’re looking for? Discover new extensions to Code Recommenders
Selecting this tip opens the Eclipse Marketplace Client which offers several extensions to Eclipse Code Recommenders.

Guides

Editing and Sharing Snippets

Snipmatch snippets are created and maintained by the community. Anyone can contribute new snippets or update existing ones. A review cycle ensures that all snippets are of high quality and useful to a larger community. In this guide, we will create a snippet from scratch. This includes adding metadata, so that the snippet can be easily found, writing the code to be inserted and sharing the snippet with the community.

Creating New Snippets

As an example, we will create a snippet that uses a Lock to synchronize access to a block of code. Such a snippet already exists in the community supplied repository; we recreate it purely as an example. First, open the Snippets view.

The Snippets View

Right-click on the Code Recommenders Snippet Repository entry and select Add Snippet…. This takes you to Snipmatch’s snippet editor. Here you can edit both the snippet’s source and its metadata. Let’s start on the Metadata tab:

The Snippet Editor Metadata Pagte

Of course, every proper snippet needs a name. But if you want your snippet to be found by others, better make sure to give it a useful description as well. Most snippets only make sense at a certain location. Here, we chose Java statements, so that the snippet can only be found within a statement block, such as a method body. Consider assigning extra search terms (i.e., terms which didn’t fit into the description, but which users might also search for) and tags. Here, we picked the extra term unlock; while unlocking is mentioned in neither name nor description, it’s conceivable that users will search for it. As a tag we picked concurrency. That way Snipmatch users will be able to quickly browse through all concurrency-related snippets with a query of tag:concurrency. You can add the Dependency jre:jre to establish that this snippet requires Java Code.

Once you are satisfied with your human-readable description of what the snippet does, you need a machine-readable description as well. Switch to the Snippet Source tab.

The Snippet Editor Source Page

On this tab, you’ll need to describe your snippet in the JFace template language. This little-known but powerful template language is also used elsewhere in Eclipse, e.g., in the Template Proposals Content Assist. JFace template language allows you to intersperse the Java code of your template with special template variables. For example, the current selection (if any) will automatically be inserted in place of the ${line_selection} variable. Moreover, we use the ${var} variable so that the template engine will automatically pick up and use any variables or fields of type java.util.concurrent.locks.Lock (if defined in the current scope). Finally, we explicitly position the cursor using ${cursor}.

Sharing Snippets

To share snippets with the community, you can submit them to our snippet repository for review. Let us now share our newly created snippet with the community. To do so, simply right-click the snippet in the snippets view and select Share Snippet(s).

Share Snippet(s) in snippets view

You may want to change the commit message to better describe your snippet(s). If you push snippets to the public Eclipse Code Recommenders Snippet Repository, make sure to check the sign-off button. Once your are satisfied with the commit message, just click Commit or Commit and Push.

Committing the new snippet

If you submit your first snippet, you will then be asked for your credentials.

Login to Gerrit

Assuming you have an account with eclipse.org already, you can look up your credentials on Gerrit’s settings page. (Please note: The password is not your SSH passphrase, but rather a special password for HTTP access generated by Gerrit.) Once the server is satsfied with your credentials and the legal paperwork is in order (you need to fill out a Committer License Agreement first), you can view your new snippet in Gerrit and discuss it with the community. If the snippet is accepted, it will be merged into the community repository. From that point on, every Snipmatch user will have access to the snippet you contributed.

Updating Snippet Repositories

Snipmatch requires a Git repository to store its snippets in. While the default snippet repository is maintained by the Code Recommenders team, you may need to do some work yourself when working with your own snippet repository.

Format Version Branches

Snippet repositories store different versions of snippets in different branches. These versions are necessary to allow changes in the snippet’s data structure while still remaining backwards compatibility. Each Snipmatch update that introduces changes to the snippet’s data structure works with its own branch, named format-n with n being the format’s version. If you try to use Snipmatch with a snippet repository that features no such format branch, you will get an error message:

Snippet repository has no format branches

As a snippet repository’s administrator, you need to make sure that it has branches that correspond to the Snipmatch versions that access it. This will most likely mean, that you have to create a branch for the most current Snipmatch version. If you want to maintain compatibility with older Snipmatch versions, you can also create older format branches. Here is a list of Snipmatch versions that introduced new format branches:

  • 2.1.10 - format-5
  • 2.1.9 - format-4
  • 2.1.0 - format-3
  • older format-n branches were only used in pre-release versions

If your snippet repository only has an older format version branch, you will get an error message similar to the one above. Snipmatch will then try to work with the newest available branch. However, in case of significant changes to the snippet’s data structure, this can result in missing features or bigger compatibility issues.

Updating Snippets

The steps required to update snippets differ for each new version. Here are instructions on how to update from each version to the next. You can update snippets by using the snippet editor.

If you prefer to edit the JSON files directly (perhaps to batch process them), look for the hidden .recommenders directory in your workspace. The snippets are located in MY_WORKSPACE/.recommenders/snipmatch/repositories/MY_REPOSITORY_URL. The repository URL has all special characters (like slashes, colons, or dashes) replaced by underscores. Each snippet is stored in its own file that has the snippet’s UUID as its name.

format-4 to format-5

format-5 introduces the new dependencies feature. Existing snippets that do not have the dependencies information, yet, will work as before; the project’s classpath does not restrict whether a snippet is applicable. To add a dependency to the snippet, open it in the snippet editor, add dependencies as needed, and save it.

To udpate the JSON files directly, go through each snippet file and add the following new line just before the last line (the last line contains the closing }):

"dependencies": [
]

In between the square brackets you can add any number of dependencies separated by comma. Each dependency looks like this:

{
"groupId": "org.example.company",
"artifactId": "my.artifact",
"version": "0.0.0"
}

To find the correct groupId and artifactId, you can look for them in the snippet editor. The dependency’s version is ignored in format-5; you can use 0.0.0 as a placeholder.

After you’ve updated all your snippets, commit and push them to the format-5 branch in your repository.

format-3 to format-4

format-4 introduces the new location feature. Existing snippets that do not have the location information, yet, will work just as before, by using the File location. To change the location and update a snippet’s underlying JSON file, simply open it in the snippet editor, change the location (or something else) and save it.

To update the JSON files directly, go through each snippet file and add the following new line before the last line (the last line contains the closing }):

"location": "LOCATION_NAME"

Replace LOCATION_NAME with one of the following:

  • FILE
  • JAVA
  • JAVA_STATEMENTS
  • JAVA_TYPE_MEMBERS
  • JAVADOC

After you’ve updated all your snippets, commit and push them to the format-4 branch in your repository.