简体   繁体   English

Visual Studio 2012中嵌入式语言的语法突出显示

[英]Syntax Highlighting of an Embedded Language in Visual Studio 2012

I'm using C# and Visual Studio 2012 to implement syntax highlighting of a language embedded in html (much like ASP code inside <% %>). 我正在使用C#和Visual Studio 2012来实现html中嵌入的语言的语法高亮显示(很像<%%>中的ASP代码)。 So far, I've found out that I need to use IProjectionBuffer to achieve this, but there are no examples of how to do this using MEF, apart from a somewhat vague description here: http://msdn.microsoft.com/en-us/library/dd885240.aspx#projection . 到目前为止,我发现我需要使用IProjectionBuffer来实现此目的,但是除了此处有些含糊的描述之外,没有任何使用MEF进行此操作的示例: http : //msdn.microsoft.com/en -us / library / dd885240.aspx#projection I tried to assign spans of text from the ITextBuffer that is "imported" through MEF to an IProjectionBuffer , but it had no effect. 我试图将通过MEF“导入”的ITextBuffer中的文本范围分配给IProjectionBuffer ,但是它没有任何效果。

Does anybody have any ideas as to how to proceed? 有人对如何进行有任何想法吗?

There is a built in feature for this purpose I think. 我认为有一个内置功能可实现此目的。 I used to deal with text highlighting in C# code with MEF with tags. 我曾经使用带有标签的MEF处理C#代码中的文本突出显示。 I think you shold start with Text.Classification . 我认为您应该从Text.Classification开始。

There is a lack of documentation sadly, but I think you should build a lexer or somthing similar for the lingual part MSDN:DLR (features) may can help you, 令人遗憾的是缺少文档,但是我认为您应该为MSDN:DLR(功能)的语言部分构建一个词法分析器或类似的东西,

The DLR allows language implementers to avoid creating lexical analyzers, parsers, semantic analyzers, code generators, and other tools that they traditionally had to create themselves. DLR允许语言实现者避免创建词汇分析器,解析器,语义分析器,代码生成器以及他们传统上必须自行创建的其他工具。

detect the delimiters, and color it through classification. 检测定界符,并通过分类为其着色。

Here is an example project to customize C# code displaying. 这是自定义C#代码显示的示例项目

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM