Visual Studio可扩展性 - 自定义语言文本编辑器设置

Ale*_*rou 5 c# dsl vs-extensibility visual-studio-2013

我正在尝试在Visual Studio中开发语言服务,到目前为止,我已经能够实现高亮和跨度的基本Tagger:

在此输入图像描述

但是,我想更进一步,在"文本编辑器"下添加我自己的部分,以便我可以维护Tab设置等语言(如下所示): 在此输入图像描述

我发现很难在线找到Visual Studio可扩展性的资源,因为你可以做很多事情,但知道从哪里开始通常很困难.我也对自定义项目/项目服务感兴趣,但在查找样本方面也存在类似问题.

有可能我很接近(由于自定义标记),我只是不知道用什么来装饰导出的类型,或者我有很多基础工作要做.方向赞赏.

cod*_*res 4

我发现这篇博客文章有很多 Visual Studio Extension 项目示例。其中有一个项目名为Options Page \xe2\x80\x93 VS 2013我想这就是你正在寻找的:

\n\n

选项页

\n\n

对于您的具体情况,您应该调整类中的以下属性(取自示例)OptionsPagePackage.cs。具体来说这些属性:

\n\n\n\n

将“类别”作为第二个传递参数(对应于“工具”菜单中的主类别)。

\n\n
[ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor","General", 100, 101, true, new string[] { "Change sample general options (C#)" })] \n    [ProvideProfileAttribute(typeof(OptionsPageGeneral), "Text Editor", "General Options", 100, 101, true, DescriptionResourceID = 100)] \n    [ProvideOptionPageAttribute(typeof(OptionsPageCustom), "Text Editor", "Custom", 100, 102, true, new string[] { "Change sample custom options (C#)" })] \n    [InstalledProductRegistration("Text Editor", "My Options Page (C#) Sample", "1.0")] \n    [Guid(GuidStrings.GuidPackage)] \n    public class OptionsPagePackageCS : Package \n    { \n    .....\n    }\n
Run Code Online (Sandbox Code Playgroud)\n\n

DescriptionResourceID(100,101,102 等)在 xml 文件中定义VsPackage.resx,vsix 安装程序将使用它在工具菜单中插入标签:

\n\n
<data name="100" xml:space="preserve">\n    <value>My Managed Options (C#)</value>\n    <comment>Options category</comment>\n  </data>\n  <data name="101" xml:space="preserve">\n    <value>My Options</value>\n    <comment>General page</comment>\n  </data>\n  <data name="102" xml:space="preserve">\n    <value>Custom</value>\n    <comment>Custom page</comment>\n  </data>\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是我的尝试:

\n\n

在此输入图像描述

\n\n

请务必小心,因为使用现有类别会覆盖现有类别。正如您在图片中看到的,所有其他语言都没有选项。

\n\n

编辑:

\n\n

正如亚历山大所指出的为了避免覆盖现有配置(如果想将其类别添加到“工具”菜单中的现有配置)必须将反斜杠添加到上述属性中的类别参数中。例如:

\n\n
[ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor","General", 100, 101, true, new string[] { "Change sample general options (C#)" })]\n
Run Code Online (Sandbox Code Playgroud)\n\n

变成:

\n\n
 [ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor\\\\MyOptionPage","General", 100, 101, true, new string[] { "Change sample general options (C#)" })]\n
Run Code Online (Sandbox Code Playgroud)\n\n

在这种情况下,MyOptionPage 将是文本编辑器的子项,并且不会覆盖现有配置。

\n\n

希望能帮助到你。

\n