简体   繁体   English

VS 2015插件:当前文本点的对象名称和类型

[英]VS 2015 Addin: Name and type of object at the current text point

I am trying to determine the name and the type (wheter the object is a method, property, etc.) of the element in which the caret is currently placed for a Visual Studio Plugin. 我正在尝试确定当前用于Visual Studio插件的插入符号的元素的名称和类型(对象是方法,属性等)。 I already tried to use CodeElements, but I'm just able to receive the elements declared in the current document and found no way to get the desired information. 我已经尝试使用CodeElements,但是我只能够接收当前文档中声明的元素,却找不到获取所需信息的方法。

Example: 例:

Console.Wr|iteLine(); // Caret is placed after the 'r'

In above's short example, I want to receive "WriteLine" as the current object's name and I'd like to know that it is a method. 在上面的简短示例中,我想接收“ WriteLine”作为当前对象的名称,并且我想知道它是一个方法。 Is there a simple way to do this? 有没有简单的方法可以做到这一点? Any help is welcome. 欢迎任何帮助。

Thanks in advance 提前致谢

I recommend to use Roslyn code analysis. 我建议使用Roslyn代码分析。 See for example Create a typed variable from the current method invocation . 例如,请参见从当前方法调用创建类型化变量 It finds Microsoft.CodeAnalysis.IMethodSymbol from the current text point. 它从当前文本点找到Microsoft.CodeAnalysis.IMethodSymbol。

暂无
暂无

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

相关问题 VS2015 ASP.NET MVC名称'model'在当前上下文中不存在 - VS2015 ASP.NET MVC the name 'model' does not exist in the current context 在Visual Studio 2015中安装qt-vs-addin-msvc2015-2.0.0-beta - Install qt-vs-addin-msvc2015-2.0.0-beta in Visual Studio 2015 使用 VS2015 更改应用程序的入口点 - Changing Entry Point of Application with VS2015 VS2015 Web Addin项目 - 更改Web服务器物理路径? - VS2015 Web Addin Project - Change web server physical path? VS2015中具有类型特征的奇怪错误 - Strange error with type traits in VS2015 对于简单的C#SMTP代码,VS2015编译器错误消息“名称client.UseDefaultCredentials在当前上下文中不存在” - VS2015 compiler error message “the name client.UseDefaultCredentials does not exist in the current context” for simple C# SMTP Code 在 VS2015/C# 中的当前文件/类中查找方法 - Find method in current file/class in VS2015/C# VS2015 C# 交互:错误 CS7069:对类型“对象”的引用声称它在“System.Runtime”中定义,但找不到 - VS2015 C# interactive: error CS7069: Reference to type 'Object' claims it is defined in 'System.Runtime', but it could not be found VS2015与VS2013的不同优化会导致浮点异常 - Different optimization in VS2015 vs VS2013 causes floating point exception 将MS VS2013升级到MS VS2015错误CS0234类型或名称空间名称'Reporting'在名称空间'Microsoft'中不存在 - Upgrade MS VS2013 to MS VS2015 Error CS0234 The type or namespace name 'Reporting' does not exist in the namespace 'Microsoft'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM