开发者

How to get programmatically the information displayed by Quick Info in Visual Studio

开发者 https://www.devze.com 2023-02-07 23:19 出处:网络
I searched without succes a method to get from my C# addin visual studio extension what displayed in the Quick Info when the mouse is moved over some code element.

I searched without succes a method to get from my C# addin visual studio extension what displayed in the Quick Info when the mouse is moved over some code element.

I hope that there's an elegant way to do it.

Tha开发者_如何学Pythonnks.


I do not have a code example, but found the following documentation for the ViewFilter.HandleQuickInfo method which sounds like the steps you need to do.

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.

Source: ViewFilter.HandleQuickInfo

Edit:

You can retrieve the current IVsTextView using 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));

However, I am stuck there, and unable to do anything useful with IVsTextView.UpdateTipWindow, it never calls anything on my passed dummy object, so I presume it requires an already visible IVsTipWindow from a language service.


The Quickview shows the methods and properties that exists and are accessible on the class so one solution would be to use reflection to get this information.

//Gets the methods of the Class MyClass MethodInfo[] methodInfos = typeof(MyClass).GetMethods(BindingFlags.Public | BindingFlags.Static);

0

精彩评论

暂无评论...
验证码 换一张
取 消