To get started with Ctrlflow Code Search Professional, you will need to create a search index. Once you start code search, Code Search will keep the index up-to-date, which allows it to find code snippets almost instantly.
Like the Eclipse Java Development Tools, Code Search can search for occurrences of types, fields, and methods (only faster!), but its ability to find code snippets is what makes it most useful. The following three examples show you why:
1. How to Best Create Instances of API Classes?
If you are new to an API, one of the first questions is how to create instances of its key classes or interfaces. Even for a comparatively simple API like
java.io this is not a trivial question. How to best create an
InputStream, for example?
While Eclipse’s built-in search quickly turns up
InputStream’s constructors (along with hundreds of irrelevant results), Ctrlflow Code Search Professional presents you with the whole picture: The constructors of
BufferedInputStream are a far more common way of creating an
InputStream instance. Also, both
URL.openStream() are frequently used alternative routes, so those methods may be worth checking out as well.
2. What Arguments to Pass to API Methods?
One question that sooner or later surfaces when working with any larger API is what “magic” constants to pass as method arguments. Whether it is Java NIO’s
OpenOption or SWT’s widget style bits, you are always wondering: “Which value(s) should I pass?”
Ctrlflow Code Search Professional helps to answer this question with its search for values already passed as arguments elsewhere in the code. This way, you can quickly judge which constants are used most often and thus warrant a closer look.
3. What Calls to Make in a Fluent API?
With the advent of Java 8, fluent interfaces and method chaining have finally made their way into the mainstream. Experienced users of the Eclipse IDE explore such APIs using content assist – one method at a time. But this piecemeal approach makes it hard to spot larger patterns. This is where Ctrlflow Code Search Professional and its flexible aggregation options come in: They condense large numbers of method chains into easily-digestable patterns.
Ctrlflow Code Search Professional offers more than twenty different queries specialized for learning and exploring APIs. Consult the user manual for the full list.