自定义 Visual Studio 语言服务中导航栏中第一个条目的重复
我正在为公司内部使用的自定义脚本语言实现 Visual Studio 语言服务,并且我遇到了作为 TypeAndMemberDropdownBars。该子类是由我的 LanguageService 子类 LanguageService 创建的。 CreateDropDownHelper 方法。
在 OnSynchronizeDropdowns 方法中,我迭代文件中定义的类型并添加 DropDownMembers 到传入的数组中以填写导航栏。我看到的问题是数组中的第一项被复制并通过我无权访问的代码放置在列表的末尾。这个额外的项目在选择时行为不正确(没有任何反应),但似乎不会导致任何其他问题;列表中的其余项目工作正常。此外,这似乎只发生在类型下拉框中 - 成员下拉框不显示此行为。
我希望其他人已经看到并解决了这个问题并可以提供一些帮助。谢谢!
I'm implementing a Visual Studio Language Service for a custom scripting language used internally at my company, and I've run into an issue with the navigation bar implemented as a subclass of TypeAndMemberDropdownBars. The subclass is created by my LanguageService subclass' LanguageService.CreateDropDownHelper method.
In the OnSynchronizeDropdowns method I'm iterating through the types defined in the file and adding DropDownMembers to the passed-in array to fill out the navigation bar. The issue I'm seeing is that the first item in the array is being duplicated and placed at the end of the listing by code that I don't have access to. This extra item does not behave correctly when selected (nothing happens), but doesn't seem to cause any other issues; the rest of the items in the list work fine. Additionally, this only seems to happen for the type dropdown box - the members dropdown box does not display this behavior.
I'm hoping someone else has seen and resolved this issue and could provide some assistance. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实证明,这是由我调用 LanguageService.SynchronizeDropdowns 来自我的 LanguageService.ParseSource 方法,正在调用在后台线程上。我通过在 ParseSource 执行检查解析时设置一个标志来解决该问题,然后在我的 LanguageService.OnIdle 函数将调用 SynchronizeDropdowns。现在它正在按预期工作!
Turns out this was caused by me calling LanguageService.SynchronizeDropdowns from my LanguageService.ParseSource method, which was being called on a background thread. I've fixed the problem by setting a flag when ParseSource does a Check parse, and then implementing a check for that flag in my LanguageService.OnIdle function that will call SynchronizeDropdowns. It's now working as expected!
更好的解决方案是实施 LanguageService.OnParseComplete回调,并调用同步下拉列表从那里。 OnParseComplete 始终从主线程调用,因此这可以防止出现任何同步问题,并且还使您不必跟踪是否需要调用 SynchronizeDropdowns()。
A better solution is to implement the LanguageService.OnParseComplete callback, and call SynchronizeDropdowns from there. OnParseComplete is always called from the main thread, so this prevents any synchronization issues from coming up, and also keeps you from having to keep track of whether or not you need to call SynchronizeDropdowns().