我如何:Visual Studio语法突出显示扩展名 [英] How do I: Visual Studio Syntax Highlighting Extension

查看:108
本文介绍了我如何:Visual Studio语法突出显示扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为VS2010开发一个扩展,使我可以为语法高亮显示一些附加功能.

I want to develop an extension for VS2010 that will allow me make some additional features to syntax-highlighting.

我安装了SDK,如何开始?

I installed the SDK, how do I start from?

请提供一个小片段(或代码链接),在这里我可以看到如何开始.

Please give a little snippet (or a link to code) where I can see how to start.

注意:我是否必须检查整个代码块,还是SDK会在每个单词上告诉我它是什么,如何声明等?

Note: do I have to check the whole block of code, or the SDK tells me on each word what it is, how it's declared etc.?

推荐答案

这里有大量的信息可用于编写分类器.我写了一个关于它的博客文章.

There's a decent bit of information out there for writing classifiers. I wrote a blog article about it awhile back.

关于样本/代码,有:

  • A project template that ships with the SDK (look under C#->Extensibility)
  • (Brian's answer mentions) The Ook language service
  • A template for writing classifiers (the link is for the source of the template, so you'll have to un-templatize the $foo$ parts)
  • A diff classifier (pretty old)
  • A couple of other classifiers in the various projects on my github page.

关于问题的另一部分的答案,即SDK是否告诉您每个单词是什么,答案为否",并附带一些注意"警告.通常,不公开基础语言模型,尽管您可以执行一些操作,例如消耗其他 other 分类器的分类信息,以希望它们能为您提供足够的信息.有些代码(例如C#)会提供大量信息,而这些信息可能不会在IDE中以默认字体和颜色设置显示(检查工具"->选项"->环境"->字体和颜色"设置,以查看是否要更改可能已经存在),而其他变量(例如VB)往往没有.您还可以使用DTE的 CodeModel 之类的东西,但是我已经从来没有听说有人对此有很好的经验.

The answer to the other part of your question about if the SDK tells you what each word is, the answer is "no", with a few "kinda" caveats. In general, the underlying language models are not exposed, though you can do things like consume the classification information from other classifiers in the hope that they give you enough information; some, like C#, tend to give a good deal of information that may not show up in the IDE in the default fonts and colors settings (check the Tools->Options->Environment->Fonts and Colors settings to see if you want to change may already be there), and others, like VB, tend not to. You can also use things like DTE's CodeModel, but I've never heard of someone having really good experiences with it.

如果您想要使用分类信息的示例,则可以查看 CommentTextTagger.cs (拼写检查扩展程序的一部分)可以做到这一点.

If you want an example of consuming classification information, you can see how this CommentTextTagger.cs (part of a spellchecker extension) does it.

这篇关于我如何:Visual Studio语法突出显示扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆