从文件路径获取 IVsTextLines
我已经为我工作室的专有脚本语言编写了 Visual Studio 2008 的基本 LanguageService 扩展。它工作得很好,我已经实现了一个基本的符号表来跟踪脚本定义和调用,允许转到定义功能。
我遇到的问题是我只知道如何解析当前活动视图,并且我想扫描整个解决方案的内容,以便用户可以转到他们尚未访问的文件中定义的脚本的定义打开并解析。我已经弄清楚如何生成解决方案中所有文件的列表,但现在我需要创建一个新的 Microsoft.VisualStudio.Package.Source ,它需要 Microsoft.VisualStudio.TextManager.Interop。 IVsTextLines,我不知道如何根据我拥有的文件创建一个新的。
也许我以错误的方式解决这个问题,有人可以向我指出一种更好的方法来使 LanguageService 解析文件。
问候, 科林
I've written a basic LanguageService extension for Visual Studio 2008 for my studio's proprietary scripting language. It works perfectly fine, and I've implemented a basic symbol table to keep track of script definitions and calls allowing for goto definition functionality.
The problem I've run into is that I only know how to parse the current active view, and I'd like to scan the entire solution's contents so that the user can goto the definition of a script defined in a file they have yet to open and have parsed. I've figured out how to generate a list of all files in the solution, but now I need to create a new Microsoft.VisualStudio.Package.Source which requires a Microsoft.VisualStudio.TextManager.Interop.IVsTextLines and I have no idea how to create a new one based off of the file I have.
Maybe I'm going about the problem the wrong way and someone can point me towards a better way to cause a file to be parsed by the LanguageService.
Regards,
Colin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一番研究,我发现 Visual Studio 需要新源的原因是它保留了它们的内部列表,它们就像编辑器所保存的文本文件的视图。
我得出的结论是,关闭的文件不需要 IVsTextLines 或输入到 VS 内部源文件列表中,因为我没有直接对它们进行任何操作,在这种情况下我关心的是构建一个表符号及其相应的 TextSpan。因此,我为我的解析器创建了一个新的 API,它只接受一个字符串并构建我的 AST,而不是从 ParseRequest 中获取文本,并且只担心我需要记录的特定类型的符号。然后我将其推入BackgroundWorker。
所以我想我以错误的方式解决了这个问题。虽然看起来确实很奇怪,但我不能只触发文件在源列表中打开。
有趣的是,我在微软的支持论坛上向微软提出了这个问题,他们建议我必须购买一些服务和支持计划,以便他们回答我的问题。
Poking around I found that the reason Visual Studio needs a new Source is that it's keeping an internal list of them, and they're like the view into the text file held by the editor.
I came to the conclusion that files that are closed do not need IVsTextLines or to be entered into the VS internal list of Source files because I'm not doing any operations directly on them, all I care about in this case is to build a table of symbols and their corresponding TextSpan. So instead I created a new API for my parser that just took in a string and built my AST instead of grabbing the text from a ParseRequest, and only worried about specific types of symbols I needed to record. I then pushed this into a BackgroundWorker.
So I guess I was going about the problem in the wrong way. Although it does seem weird I can't just trigger a file to be opened into the Source list.
Interestingly I asked this question to Microsoft on their support forums and they advised me I had to purchase some service and support plan for them to answer my question.