Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Language Service with C# intellisense

Last year I wrote a Language Service for Visual Studio which added syntax highlighting for NHaml files: http://github.com/snappycode/hamleditor.

To clarify, NHaml is a html template language that can mix in code elements like an aspx file can. This plugin adds support to the IDE for editing NHaml files, but basically only adds syntax highlighting.

I was wondering if anyone knows how to add inline c# intellisense to the service like you get now in an aspx file. I'm hoping that would be possible without doing the whole c# grammar myself specific for the plugin.

Has anyone written a language service that mixes languages?

UPDATE: It looks like the spark view engine guys have made some inroads here, I am investigating their implementation

like image 773
whatupdave Avatar asked Apr 11 '09 03:04

whatupdave


2 Answers

I checked the Spark View Engine, and they seem to have made a generic ATL stuff (called SparkLanguagePackageLib), that in fact seems to be not containiag anything Spark specific. It seems to be just a generic C# intellisense library that needs the following:

  • The original code
  • The C# source that gets generated from the original code
  • The position mappings between the two (for example the code on line 2 pos 5 gets mapped in the output to line 4 pos 10, etc.)
  • Some other things, like Paintings(?)

And after that you can call:

events.OnGenerated(
    primaryText, // original source code
    entry.SourceCode, // generated sourcecode
    cMappings, // mappings between the two
    ref mappings[0], // ?
    cPaints, // ?
    ref paints[0]); // ?

I've tried to find Spark-specific stuff in that C++ library, but I couldn't find anything: everythig spark-related is split to a separate C# code file. I think this is good, because:

  • You don't need to edit the C++ files
  • If the spark view engine's intellisense support is installed it can be used by other view engines too
  • You only need to create a class, that maps between the original nhaml file and it's generated C# counterpart.

Btw. Are you still working on this NHaml Intellisense library? If not I'll try to patch their implementation in hope it can be converted to NHaml easily.

like image 92
SztupY Avatar answered Oct 13 '22 01:10

SztupY


this looks like it might help

http://www.codeproject.com/KB/recipes/VSLanguageService.aspx

like image 33
Simon Avatar answered Oct 12 '22 23:10

Simon