Visual Studio扩展性/边距 [英] Visual Studio Extensibility / Margins

查看:114
本文介绍了Visual Studio扩展性/边距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过Marion构建一个Margin作为VS插件.我需要获取包含方法定义的行.我发现有人在做这种事情,但似乎大多数人都在解析测试.这似乎是一个非常糟糕的主意,因为它显然仅适用于您知道如何解析的语言.

I am trying to build a Margin (through MEF) as a VS addin. I need to get the lines that contain the definition of a method. I have found people doing such things but it seems most are parsing test. This seems like a really bad idea as it would obviously only work with languages you knew how to parse.

在插件中,我可以使用更高级别的模型以编程方式访问文档:

In an addin I can access the document in a programmatic fashion using a higher level model:

var fcm = _application.ActiveDocument.ProjectItem.FileCodeModel;
var elem = fcm.CodeElementFromPoint(point, vsCMElement.vsCMElementFunction);

作为一个例子.

在尝试绘制边距时,是否仍可以从MEF内容中执行此操作?

Is there anyway to do this from within the MEF stuff when trying to draw the margin?

推荐答案

好的,可以完成.

通常的过程是: 1)ITextBuffer-> ITextDocument(具有文件名) 2)使用文件名查找项目项(例如:递归项目项) 3)从项目项中获取FCM并使用它

The general process for this is: 1) ITextBuffer -> ITextDocument (which has a file name) 2) Use the file name find the project item (eg: recurse project items) 3) Get FCM from the project item and use it

这篇关于Visual Studio扩展性/边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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