The F# compiler source release: making it easy to write cool Visual Studio extensions
Posted by Brian on November 12, 2010
In case you’ve been hiding under a rock and haven’t heard, the F# compiler was recently released under the Apache 2.0 license; see Don’s blog for the details. This source code release gives you the freedom to use the F# compiler code how you like, and so of course as a developer who likes using Visual Studio, I decided to take a crack at a Visual Studio extension that I’ve always wanted to write.
The basic idea is an editor extension that uses background colorization to show the “control flow depth” of F# code. A screenshot is a little suggestive:
but in order to really describe it, I made a video (about 6 minutes long), linked below.
The idea is simple; the F# compiler code already knows how to do all the heavy lifting of parsing source code and creating a parse tree (an abstract syntax tree, or “AST”), and the AST knows all the info about code structure and e.g. that this expression starts in this line/column and ends in this other line/column. So I just take the tree and turn it into some useful “depth and span” information, which I then use from a Visual Studio editor extension to add color adornments in the editor.
This is still under development, but I plan to publish the extension on the Visual Studio Gallery, and publish the source code when I’m done.
Anyway, check out the video here. I’m interested to hear what people think, and hope this inspires others to try their hand at leveraging the F# compiler code to write cool tools and extensions.
Joel Mueller said
This sounds like an excellent idea. Far better than the “vertical lines at tab stops” I’ve been wishing for. I’ll definitely try this out when it’s ready.
Brian said
The “vertical lines at tab stops” feature already exists. It’s in the Pro power tools:
http://visualstudiogallery.msdn.microsoft.com/en-us/d0d33361-18e2-46c0-8ff2-4adea1e34fef
and you can see it in conjunction with F# in this video:
http://msdn.microsoft.com/en-us/fsharp/ff742849.aspx
at about 2 minutes and 20 seconds in.
F# source code structural colorizer available « Inside F# said
[...] Comments (RSS) « The F# compiler source release: making it easy to write cool Visual Studio extensions [...]
F# Discoveries This Week 11/21/2010 « F# Central said
[...] Brian McNamara’s The F# compiler source release: making it easy to write cool Visual Studio ex… “This source code release gives you the freedom to use the F# compiler code how you like, and so of course as a developer who likes using Visual Studio, I decided to take a crack at a Visual Studio extension that I’ve always wanted to write.” [...]