本文介绍了问题无心,听者有意语言服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经找到无心,听者有意在互联网上的语言服务两种方式。

I have found two ways of proffering a language service on the internet.

的涉及到使用方式 IOleComponentManager 和注册定时器在空闲时间打电话给我服务。

The first way involves using a IOleComponentManager and registering a timer to call my service during idle times.

的涉及套管我的服务为 IServiceContainer 并添加 ServiceCreatorCallback 来毫无顾忌点播服务。

The second way involves casing my service as an IServiceContainer and adding a ServiceCreatorCallback to "proffer the service on demand".

据说第二方法是现在做事情的首选方式。不幸的是,当我用这个方法, OnSynchronizeDropdowns 永远不会叫上我的 TypeAndMembersDropdownBars 实施

Supposedly the second way is now the "preferred way" of doing things. Unfortunately, when I use this method, OnSynchronizeDropdowns never gets called on my TypeAndMembersDropdownBars implementation.

此外,当我的 LanguageService 查找该文件中的错误,它使用 ParseRequest.Sink.AddError()错误添加到错误列表。当无心,听者有意按需,这些错误并不在GUI中显示出来,即使我看到他们时,我通过代码调试添加。

In addition, when my LanguageService finds errors in the file, it uses ParseRequest.Sink.AddError() to add errors to the error list. When proffering "On Demand", these errors don't show up in the GUI, even though I see them being added when I debug through the code.

我知道,我的语言服务被注册,因为语法高亮显示,去确定指标和查找所有引用仍然有效。

I know that my language service is being registered, because syntax highlighting, "Go to Defintion", and "Find All References" still work.

下面是我使用的代码我毫无顾忌按需服务:

Here is the code I'm using to "proffer my service on demand":

IServiceContainer serviceContainer = this as IServiceContainer;
ServiceCreatorCallback callback = new ServiceCreatorCallback(CreateLanguageService);
serviceContainer.AddService(typeof(MyLanguageService), callback, true);



谁能告诉我,为什么一些功能我 LanguageService 需求无心,听者有意,当它不工作?我缺少的东西,或者是那样只是不意味着一个功能齐全的语言服务?

Can anyone tell me why some functionality of my LanguageService does not work when proffering it on demand? Am I missing something, or is that way just not meant for a fully functional language service?

推荐答案

看起来比如至少缺失的功能,需要使用注册一个定时器中的的空闲时间

It looks like at least the missing functionality requires using the IOleComponentManager method that registers a timer to call the language service during idle periods.

使用,我发现 OnSynchronizeDropdowns ()会从 OnCaretMoved()要求同步,当您单击编辑器围绕选定的项目。 OnCaretMoved()本身似乎只能从 LanguageService.OnIdle()方法,我相信所谓需要使用的空闲计时器。

Using dotPeek, I found that OnSynchronizeDropdowns() gets called from OnCaretMoved() for synchronizing the selected item when you click around in the editor. OnCaretMoved() itself appears to only be called from the LanguageService.OnIdle() method, which I believe requires the use of the idle timer.

挖些后,我还发现错误列表要求 ParseRequest.Reason 设置为 ParseReason.Check ,否则将忽略该呼叫。通过代码挖掘更多一些,我发现解析原因正在使用的是 Source.OnIdle()

After digging some more, I also found that the error list requires that the ParseRequest.Reason be set to ParseReason.Check, otherwise it ignores the call. Digging through the code some more, the only place I found that parse reason being used was in Source.OnIdle().

更新:我相信我已经证实,注册一个空闲计时器需要这两个功能件。从MSDN上:

Update: I believe I have confirmed that registering an idle timer is required for these two pieces of functionality. From MSDN on LanguageService.OnIdle:

注意
,此方法是所谓的,除非你建立自己的计时器和呼叫
从计时器处理此方法。

基本方法调用的如果从去年
时间插入符号已经移动的OnIdle 被调用。则基本方法调用上的当前视图对象。如果当前
对象不能获得基本方法什么事情都不做,
在内的不调用的。

The base method calls OnCaretMoved if the caret has moved since last time OnIdle was called. The base method then calls the OnIdle method on the Source object for the current view. If the current Source object cannot be obtained, the base method does nothing at all, including not calling OnCaretMoved.

这篇关于问题无心,听者有意语言服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 08:02