带有 C# 智能感知的 Visual Studio 语言服务
去年,我为 Visual Studio 编写了一个语言服务,为 NHaml 文件添加了语法突出显示: http://github.com/snappycode /hamleditor。
澄清一下,NHaml 是一种 html 模板语言,可以像 aspx 文件一样混合代码元素。 该插件添加了对 IDE 编辑 NHaml 文件的支持,但基本上仅添加语法突出显示。
我想知道是否有人知道如何将内联 c# 智能感知添加到服务中,就像现在在 aspx 文件中一样。 我希望这将是可能的,而无需自己专门针对该插件执行整个 C# 语法。
有人编写过混合语言的语言服务吗?
更新: 看起来 Spark View 引擎的家伙已经在这里取得了一些进展,我正在调查他们的实施
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我检查了 Spark View Engine,他们似乎制作了一个通用的 ATL 东西(称为 SparkLanguagePackageLib),实际上似乎不包含 Spark 特定的任何内容。 它似乎只是一个通用的 C# 智能感知库,需要以下内容:
之后你可以调用:
我试图在那个 C++ 库中找到 Spark 特定的东西,但我找不到任何东西:everythig spark-相关的被拆分为单独的 C# 代码文件。 我认为这很好,因为:
顺便提一句。 您还在研究这个 NHaml Intellisense 库吗? 如果没有,我会尝试修补他们的实现,希望它可以轻松转换为 NHaml。
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:
And after that you can call:
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:
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.
这看起来可能有帮助
http://www.codeproject.com/KB/recipes/ VSLanguageService.aspx
this looks like it might help
http://www.codeproject.com/KB/recipes/VSLanguageService.aspx
我最终设法修改代码以支持 NHaml。 一点也不难。 不幸的是,原始的 NHaml 库并不支持所需的一切,因此我必须为 NHaml 创建一个新的解析器。 它不支持所有结构,但它支持大多数结构(足以使 NHaml 编程更容易)
下载: http://github.com/sztupy/nhamlsense
截屏:http://www .youtube.com/watch?v=8jTZ2zC9eYc
I finally managed to modify the code to support NHaml. It wasn't that hard at all. Unfortunately the original NHaml library doesn't support everything that was needed, so I had to create a new parser for NHaml. It doesn't support all of the constructs, but it supports most of them (enough to make NHaml programming easier)
Download: http://github.com/sztupy/nhamlsense
Screencast: http://www.youtube.com/watch?v=8jTZ2zC9eYc
您可以通过创建或修改来轻松添加关键字 usertype.dat 文件。 请查看此处,了解有关附加到的一些说明特定的文件扩展名。 这可能至少能让您完成部分工作,而无需重做完整的 C# 语法。
(事实上,我不确定在这种情况下“语法突出显示”的确切含义。例如,我确信您可以在编辑器中免费获得大括号匹配突出显示)。
You can easily add keywords by creating or modifying a usertype.dat file. Check here for some directions on attaching to specific file extentions. That might get you at least part of the way, without redoing the complete c# syntax.
(In fact, I'm not sure what you mean exactly by 'syntax highlighting' in this context. I'm sure, for instance, you get brace-match highlighting for free in the editor).