Thursday, February 12, 2015

Closure IDE Beta Update

Closure IDE Beta Update

Closure IDE Beta Update

The beta update is here. Besides a heavy bunch of bug fixes, the update significantly improves features that allows you to find declarations and references of JavaScript members in source code.

What can these features actually give us?
At large, the features help us answer the questions, such as "Who uses this field?" or "Who implements this method?".
Find Declarations/References of JavaScript members
I decided to use the Closure Library itself to quickly review the features. The library brings pretty impressive codebase that grouped into 121 packages of JavaScript source files. The list of packages is so long it cannot fit into my screen. So, a part of it looks in the Package Explorer like the following:
Closure Library project in the Package Explorer of Closure IDE
Let's open the main class of all UI controls in the Closure Library - goog.ui.Component. When a project is really huge, I prefer to navigate through it using types not JS files. So, I use the Icon of the Open Type dialog - Closure IDE Open Type dialog to quickly find and open the class. So, I do not need to search the class in an endless number of packages/folders and remember the file in which it is located.
goog.ui.Component in the Open Type dialog - Closure IDE
Inside this type, the most interesting part for our task is thedecorateInternal method. This method is a classic usage example of the Template Method design pattern. Therefore, we can expect that the method has a lot of different implementations provided by the subclasses. A lot of implementations means a lot of declarations.

Move your cursor to the method's name or select it in the Outline view. Right-click on it to open the context menu. Select Declarations » Project to find the method's declarations available in the project.
Find JavaScript declarations of a method - Closure IDE
The Search view appears. When the search job is completed, all found matches are shown in the view. As simple as that.
Search view with found declaration matches of a method - Closure IDE
Expand the tree in the view and double-click a match. The file opens in the editor at the position of the match.
Is it smart?
Yes, it is as smart as possible. For example, to decide which matches are accurate for a search of method declarations, the IDE uses the method's scope and binding information, available JSDoc, declaring class and its type hierarchy, parameters, return type and control access information (public, private etc.).

Moreover, the IDE searches references inside JSDoc tags such as @see, @link, @param, @return etc.

In special cases when a match is found but cannot be treated as accurate, the IDE marks it as "possible match" to allow you to decide its correctness.
Even more about Search
The described above is a very small bit of the search-related features available in this beta release of the IDE. For further learning, explore the documentation inside the IDE. The help contains new tutorials and references about the search features introduced by the update.

So, update your Closure IDE 2 Beta (or request it here), check out what we have already done and stay tuned.

No comments: