views:

255

answers:

2

Hi,

I'm trying to find documentation on how one would go about creating a custom editor plug-in for VS2008 or VS2010.

The file syntax I want to edit is from a tool called TemplateMaschine by Stefan Sarstedt.

An example of the template syntax:

<%@ Assembly Name="System.Xml" %>
<%@ Import NameSpace="System.Xml" %>
<%@ Import NameSpace="System.Collections" %>
<%@ Argument Name="className" Type="string" %>
<%@ Argument Name="attributes" Type="ArrayList" %>

public class <%=className%>
{
<% foreach(string attr in attributes) { %>
public string <%=attr%>;
<% } %>
}

The most important editor features for me would be real-time syntax checking and code completion. If we could get those features, it would save us THOUSANDS of man-hours.

Failing to incorporate a custom editor into Studio, maybe there is some open source text editor project out there that might be easy to extend for my purposes? I've looked a little at Eclipse, but I would think code completion won't be an option (also, my Java stinks). Another possibility might be extending the SharpDevelop text editor component.

Ideas and suggestions welcome!

+1  A: 

If you wanted to create your own DSL, take a look at the Visual Studio Visualization and Modeling SDK.

If using TemplateMaschine isn't a complete necessity, take a look at t4 templates. They're built into Visual Studio, and tooling (such as Clarius Visual T4) is already available.

kodefuguru
@kodefuguru:Thanks for the link. Aren't T4 templates a design-time methodology? My templates are executed at run-time. There seems to be some discussion of using T4 at run-time in .NET 4.0, but it seems highly preliminary. Unless I'm mistaken?
David Montgomery
+3  A: 

There are a couple of options that work in VS2008 and VS2010.

There's Managed Babel, which is way to get these features automatically given a grammar (I believe the default uses flex/bison). You can read about it on MSDN.

There's the managed package framework (MPF), which has a managed language service (MLS). If you don't have a grammar already, this is probably the simplest route.

These both use the generalized solution of providing a language service, which is described here.

If you don't care about targeting VS2008, you can go straight to the new editor extensibility APIs in VS2010. You can check out the Ook! language sample, and read my answer to a question about general editor extensibility in VS2010.

Noah Richards
@Noah: Thanks for the info. I've got a lot of reading to do! ... and Ook? as a language -- there's a Terry Pratchett fan somewhere nearby ...
David Montgomery