Implementing multiple QuickInfoProvider

SyntaxEditor for WPF Forum

Posted 14 years ago by Daniel Navarro
Version: 9.2.0514
Avatar
I had some trouble to get the new CollapsedRegionQuickInfoProvider working alongside my existing QuickInfoProvider.

My quick info service (similar to CustomQuickInfoProvider on your sample) was displaying errors, info on Identifiers, etc.

Then, when I registered the service to the new collapsed region quick info provider:

// In MySyntaxLanguage method

this.RegisterService(new MyQuickInfoProvider());
this.RegisterService(new CollapsedRegionQuickInfoProvider());

MyQuickInfoProvider stopped being called. If I switched the previous lines, only the last one would be called. Then I realised I had to merge both providers.

I got it to work with the following construct (only the relevant lines are included):

class MyQuickInfoProvider : QuickInfoProviderBase
{
  CollapsedRegionQuickInfoProvider foldingProvider =
    new CollapsedRegionQuickInfoProvider();

  public override object GetContext(IHitTestResult hitTestResult)
  {
    if (hitTestResult.Type == HitTestResultType.ViewTextAreaOverCharacter)
      ... // Gets context for my word related quick infos
    else if (hitTestResult.Type == HitTestResultType.ViewTextAreaOverIntraTextSpacer)
      return foldingProvider.GetContext(hitTestResult); // Calls the folding provider
    else return null;
  }

  ...
}

However, this would only work if I keep both calls to RegisterService(), and only when they are in the opposite order:

this.RegisterService(new CollapsedRegionQuickInfoProvider());
this.RegisterService(new MyQuickInfoProvider());

So, to get to the point, this seems a convoluted way to get it working. And because I can't see the source for your CollapsedRegionQuickInfoProvider class, it is hard to figure out what's going on inside.

Am I missing something obvious?

Comments (2)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Daniel,

Sorry it was intended to work such that you could have multiple quick info providers registered and they would each handle the scenarios that they care about. However our code in QuickInfoProviderBase is currently closing any open sessions if they aren't created by the provider, which is preventing things from working that way.

We're adding a new abstract QuickInfoProviderBase.ContextTypes property to the next build in which you'll indicate the Types of context objects that your provider creates. This way QuickInfoProviderBase will examine the context object of the currently-open session and will know which provider is responsible for closing it, thereby fixing the issue.


Actipro Software Support

Posted 14 years ago by Daniel Navarro
Avatar
I'll wait until next version then.

Thanks for the quick reply :)
The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.