gpt4 book ai didi

c# - 如何以编程方式获取 Visual Studio 中 Quick Info 显示的信息

转载 作者:太空狗 更新时间:2023-10-29 23:53:35 25 4
gpt4 key购买 nike

我搜索了一种方法来从我的 C# 插件 visual studio 扩展中获取在 Quick Info 中显示的内容,但没有成功当鼠标移到某个代码元素上时。

我希望有一种优雅的方式来做到这一点。

谢谢。

最佳答案

我没有代码示例,但找到了 ViewFilter.HandleQuickInfo 的以下文档方法听起来像是您需要执行的步骤。

The base method calls the GetCaretPos method on the IVsTextView object passed to the ViewFilter constructor to obtain the current caret position. This position is then passed to the OnSyncQuickInfo(IVsTextView, Int32, Int32) method on the Source object (obtained from the CodeWindowManager object in the ViewFilter constructor). If OnSyncQuickInfo(IVsTextView, Int32, Int32) returns any text, this method next calls the GetFullDataTipText method to get any additional information from the debugger if debugging is active. Finally, a new (or current) TextTipData object is used to display the tool tip.

来源:ViewFilter.HandleQuickInfo

编辑:

您可以检索当前的 IVsTextView使用 IVsTextManager .

var textManager = Resolve.Service<IVsTextManager, SVsTextManager>();

IVsTextView textView;
ErrorHandler.ThrowOnFailure(textManager.GetActiveView(fMustHaveFocus: 1, pBuffer: null, ppView: out textView));

Int32 caretRow, caretCol;
ErrorHandler.ThrowOnFailure(textView.GetCaretPos(out caretRow, out caretCol));

但是,我被困在那里,无法对 IVsTextView.UpdateTipWindow 做任何有用的事情。 ,它从不在我传递的虚拟对象上调用任何东西,所以我认为它需要来自语言服务的已经可见的 IVsTipWindow。

关于c# - 如何以编程方式获取 Visual Studio 中 Quick Info 显示的信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4855824/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com