Inside F#

Brian's thoughts on F# and .NET

Source code for F# Depth Colorizer extension

Posted by Brian on November 21, 2010

I’ve published the source code for the F# Depth Colorizer.  You can get the code from github.  The code is available under the Apache 2.0 License.

Here’s a quick overview of what’s there.  There is a Visual Studio 2010 solution with two projects. 

  • The “MyFSParser” project is a library that parses F# source code and yields “range” information about where source code constructs begin and end.  It is basically a free-standing version of the front half of the F# compiler, followed by about 350 lines of my own code for munging and publishing range information from the abstract syntax tree (AST) produced by the F# compiler front end.
  • The “VSIXColorizer” project is a Visual Studio extension that plug into the editor, listens for changes in the test buffer, re-parses the source, gets the range information, tags editor ‘spans’ with the semantic depth information, and then draws adornments on the screen for the portions of the file in view.  It’s also about 350 lines of code.

Of course all the code is written in F#.  This is a nice sample that demonstrates both the simple Visual Studio extensibility model that makes it easy to craft editor extensions, as well as the kinds of things you can do when you leverage the F# compiler source to do the “heavy lifting” to parse F# code for you.

In order to provide a little more guidance, I made a couple screencasts, about 10 minutes each, where I give a (rambling) walkthrough of each of the projects.  You won’t learn all the fine details about how the compiler code or my code works, but you will get an overview of the structure and see some of the important methods/functions and how the pieces fit together.  Here is the video about the parser and here is the video about the colorizer.

I’ve already started working on another editor extension that reuses the parser library code, and so in another week or two hopefully I’ll share that too.  I hope this is good “seed code” to help you leverage the F# compiler source and Visual Studio extensibility to do your own cool stuff!

About these ads

6 Responses to “Source code for F# Depth Colorizer extension”

  1. [...] (RSS) « F# source code structural colorizer available Source code for F# Depth Colorizer extension [...]

  2. [...] Source code for F# Depth Colorizer extension “I’ve published the source code for the F# Depth Colorizer. You can get the code from github. The code is available under the Apache 2.0 License.” [...]

  3. [...]  Inside F#: A quick standalone app to edit colors for the F# colorize, Source code for F# Depth Colorizer extension. [...]

  4. [...] Source code for F# Depth Colorizer extension (Brian McNamara) [...]

  5. [...] Comments (RSS) « Source code for F# Depth Colorizer extension [...]

  6. [...] Source code for F# Depth Colorizer extension « Inside F# http://lorgonblog.wordpress.com/2010/11/21/source-code-for-f-depth-colorizer-extension/ [...]

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: