我该如何:Visual Studio 语法突出显示扩展

发布于 2024-09-10 03:43:19 字数 173 浏览 4 评论 0原文

我想为 VS2010 开发一个扩展,它允许我为语法突出显示添加一些附加功能。

我安装了SDK,如何开始?

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

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

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

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.

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.?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

唱一曲作罢 2024-09-17 03:43:19

有很多关于编写分类器的信息。我写了一篇关于不久前。

至于示例/代码,有:

  • SDK 附带的项目模板(在 C#->Extensibility 下查看)
  • (Brian 的回答提到) Ook 语言服务
  • A 用于编写分类器的模板(该链接是模板的源代码,因此您必须取消 $foo$ 部分的模板化)
  • A < a href="http://code.msdn.microsoft.com/diffclassifier" rel="nofollow noreferrer">diff 分类器(相当旧)
  • 各个项目中的几个其他分类器在我的 github 页面上

关于 SDK 是否告诉您每个单词是什么的问题的另一部分的答案是“否”,但有一些“有点”的警告。一般来说,底层语言模型不会公开,尽管您可以执行诸如使用来自其他分类器的分类信息之类的操作,希望它们能够为您提供足够的信息;有些(例如 C#)往往会提供大量信息,这些信息在默认字体和颜色设置中可能不会显示在 IDE 中(检查“工具”->“选项”->“环境”->“字体和颜色”设置以查看是否你想要改变的可能已经存在了),而其他的,比如 VB,往往不会。您还可以使用 DTE 的 CodeModel,但我从未听说过有人对此有过很好的体验。

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

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

As for samples/code, there's:

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.

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

凹づ凸ル 2024-09-17 03:43:19

您可以查看

http://code.msdn.microsoft.com/ookLanguage

,其中有C# 示例中“OokTokenTag.cs​​”中的语法突出显示。当然,您确实必须解析整个文本块,但这并不太难。

(发现该链接来自 http ://social.msdn.microsoft.com/Forums/en-US/vsx/thread/657212c1-1685-4ed6-be2f-cbf34fcc5b20

You might check out

http://code.msdn.microsoft.com/ookLanguage

which has a syntax highlighter in "OokTokenTag.cs" in the C# sample. You do have to parse a whole block of text, of course, but this is not too hard.

(Found that link from http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/657212c1-1685-4ed6-be2f-cbf34fcc5b20 )

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文