Ctrlflow Blog


Recent Posts

Code Snippets à la carte: Catalogs


Code snippets are one of the best tools when learning a new API. In particular when the API’s documentation is lacking (which it all too often is), access to example code is key to getting up to speed.

This is where Ctrlflow Code Search Professional’s catalogs come in: They give you instant access to valuable code snippets for many popular APIs: JavaFX, Spring, Vaadin, and more.

Downloading a Code Snippet Catalog

Suppose you want to write some test code with the help of a modern mocking framework: Mockito. Since you are not (yet) familiar with Mockito’s API, you are in need of some code examples. Luckily, the Ctrlflow > Code Search > Catalogs preference page tells you that there is a suitable catalog ready for download:

Catalogs preference page

As soon as you have downloaded the Mockito Mocking Framework catalog, Ctrlflow Code Search Professional’s Linked Mode will offer you hundreds of code snippets suitable to your current situation ‒ even if you have very little Mockito code in your workspace yet:

Expression search starting from return value of Mockito.mock(Object)

The extensive catalogs offer examples even for unusual situations. When using the @Mock annotation’s answer element, for example, you can simply browse real-world code examples rather than consulting its rather terse Javadoc:

Expression search for element @Mock.answer

How It Works

When you download a catalog, its snippets are added to your local index. From then on, you are able to search for them, just as you would search for your own code. When you view a particular search result, Ctrlflow Code Search Professional will even download the source code of the real-world project the result came from. Thus, you always get a full preview of the code snippet in its original context.

Code snippet catalogs hence truly extend search beyond your workspace. Be it predefined catalogs for popular Open Source APIs (Ctrlflow Code Search Professional) or custom catalogs for your company’s in-house repository (Ctrlflow Code Search Enterprise), catalogs will change the way you search for snippets with the Eclipse IDE.

But if you are not interested in examples from your catalogs right now, they are of course easy to filter out, too:

Expression search for element @Mock.answer (catalogs filtered)

Ctrlflow Code Search Professional

Learn more about all features