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!
A quick standalone app to edit colors for the F# colorizer « Inside F# said
[...] (RSS) « F# source code structural colorizer available Source code for F# Depth Colorizer extension [...]
F# Discoveries This Week 11/21/2010 « F# Central said
[...] 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.” [...]
MS Visual Studio 2010 » Blog Archive » Подборка ссылок. 20-21.11.2010 said
[...] Inside F#: A quick standalone app to edit colors for the F# colorize, Source code for F# Depth Colorizer extension. [...]
Dew Drop – November 22, 2010 | Alvin Ashcraft's Morning Dew said
[...] Source code for F# Depth Colorizer extension (Brian McNamara) [...]
Source code for F# XmlDoc extension « Inside F# said
[...] Comments (RSS) « Source code for F# Depth Colorizer extension [...]
F# Depth Colorizerのカスタマイズについて « 焦げlog said
[...] Source code for F# Depth Colorizer extension « Inside F# http://lorgonblog.wordpress.com/2010/11/21/source-code-for-f-depth-colorizer-extension/ [...]