Get Symbol for ReferenceLocation

守給你的承諾、 提交于 2019-12-04 12:47:01

So, there isn't strictly a "symbol" at any of these locations, at least no innate concept of that. What you can do is take that Location, and find the enclosing symbol. You can take the location's SyntaxTree and get a Document. From there, call GetSemanticModelAsync, and then call ISemanticModel.GetEnclosingSymbol.

As an example, here's some (internal) code that does this for FAR itself: http://source.roslyn.codeplex.com/#Microsoft.CodeAnalysis.Workspaces/FindSymbols/ReferenceLocationExtensions.cs#45dad82331ae06ef

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!