November 2009 - Posts
EDIT: As of version 9.3.2 of CodeRush functionality similiar to that provided by this plugin is provided in the core product and support and builds for this plugin is discontinued... If you need assistance for earlier version of CR, just leave a comment and I'll get back to you.
Instead of posting a new a post every time a new build of CodeRush (and the plugin) becomes available, I’ll start to post the binaries here by updating this post. If you are interested in the source code, you can get it here. If you want a walk-through of how the plugin was built, you can find the first post in a series here.
Plugin binaries built against CodeRush version:
9.2.4
9.2.8
9.2.9
To install the plugin copy the binaries to: C:\Users\{your user name}\Documents\DevExpress\IDE Tools\Community\PlugIns
Here’s a follow-up to the last post that contained a few screenshots showing the integration of the Google Closure Javascript compiler in Visual Studio.
Since I said in the last post that I would make the source available if there was interest, I’m doing that now.
The project structure is as following
All of the code for accessing the compilation service is in the GoogleClosure project. Initially I didn’t have a Winform project. I split the projects for this post, realizing that some people interested in the code might not have CodeRush.
The GoogleClosure project also contains the UI in a user control. As such, there was no code to be written in neither the VS plugin or in the Winform application. Placing the user control from the GoogleClosure project is enough.
About the code: The code was written in brain-storming mode. As such, I won’t stand to trial for any best-practice not followed or any shortcut taken. ;-)
Seriously though, there’s not a lot of code here. In essence, the Compilation namespace in the GoogleClosure project, contains classes that maps to the compiler service results and options. The ClosureCompilerService class is doing all the communcation with the service. The compiler service can return its results in XML, JSON and text. I implemented only parsing of the XML results which is simple in .Net using Linq2Xml.
P.S (The “CR_” naming convention is common for CodeRush plugins.)
You can download the source code here.
Friday, Google released some of their Javascript tools. Among them the Closure Javascript compiler. Being excited that Google has released Closure (the compiler), I decided to give it a go. So late Saturday night after the party was over and the kids were sleeping, I played a little with the online UI when I saw that the compiler services are exposed through a REST web service. At that point it would be a crime to go to sleep.
2 hours later…
In this screenshot you can see some compiler statistics. (Yes, you can use the compiler service as a pretty-printer or minifier)

Dubious code is flagged with warnings. (I like the “Is there a bug?” message)
If you get the script plain wrong, you’ll be greeted with an error.
I love the fact that it is possible to whip up something like this in just a couple of hours.
The Visual Studio Integration was built as a CodeRush plugin (which takes a full 5 minutes). The rest of the time was spent reading the Closure web service spec and parsing the results from the web service.
It’s not all good however. In the current implementation you need to copy the source from the editor to the code pane in the tool window which isn’t a great user experience. Also, there’s no easy way to “jump” to the error location when there is a warning or an error. There is also no UI for setting the compiler options.
Future Plans: (Maybe)
- Compile the enclosing scope under the caret by pressing a key combination.
- Integrate with Visual Studio Error tool window. (I have no idea how to do that)
- Expose the compiler options through an option page. (Currently I use some decent defaults)
- Any other ideas?
If there’s interest, I’m considering writing up a small series of how the plugin was built including source and binaries. (It’s small enough that it won’t take all my spare time)
Update: Code can be found here - http://blogs.microsoft.co.il/blogs/kim/archive/2009/11/10/calling-the-google-closure-javascript-compiler-code.aspx