Calling the Google Closure Javascript Compiler - Code
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.