Inside F#

Brian's thoughts on F# and .NET

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:

FSParseDepthScreenshot

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.

About these ads

4 Responses to “The F# compiler source release: making it easy to write cool Visual Studio extensions”

  1. 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.

  2. […] Comments (RSS) « The F# compiler source release: making it easy to write cool Visual Studio extensions […]

  3. […] 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.” […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 30 other followers

%d bloggers like this: