As highlighted in an earlier post, Ctrlflow Code Search Professional allows you to search for code snippets. Hence, it can immediately answer complex questions like “How to use a
At a single glance, the above search results give you a lot of information: There are two methods
swtDefaults(), which serve as starting points in a fluent interface. Also, there is one common combination of methods that are frequently used together:
span(). That’s certainly good to know.
Other information, however, may not be of immediate interest when you are exploring the
GridDataFactory API for the first time. Whether the second parameters of
grab() has value
false, for example, may seem like a detail you’d rather leave for later.
Fortunately, with Ctrlflow Code Search Professional’s flexible result aggregation, you can do just that.
Aggregating Search Results
Once you enable result aggregation, the search results in the Code Search view are reduced to their essence:
Here, all arguments have been replaced by an ellipsis (“…”) so you can focus on the call chain. With this condensed view of the code snippets, it is very easy to make out the chain’s structure, from the initial
GridDataFactory.fillDefaults() all the way to the final
But if that’s too much aggregation, don’t worry; Ctrlflow Code Search Professional has plenty of aggregation options you can tweak. Want the full method signatures instead of that ellipsis? No problem:
Note that the original, unabridged code snippets are still available one level down. It’s thus easy to find out what those
int arguments were:
How It Works
As explained in an earlier blog post, Ctrlflow Code Search Professional indexes expressions. But as every Java developer knows, there’s more than one way to write even simple things like
Collections has been imported statically. Maybe the local variable is named
elem instead. By enabling aggregation, such syntactic variations are eliminated by turning the code snippet into a canonical form. The resulting canonical form,
Collections.singleton(object), is then used to group the code snippets in the result tree.
In additional to qualifying static accesses and replacing arguments with their types, Ctrlflow Code Search Professional’s index efficiently supports lots of different ways to canonicalize your code snippets:
With all these options available, it’s easy to get the gist of even thousands of search results. Have a look at the user manual to learn more about the different aggregation options.