This project is read-only.
3
Vote

Expose public Microsoft.VisualStudio.LanguageServices IOLECommandTarget for command routing

description

I've been working on adding various C# language services to a projection buffer. I'd like to add the proper language services to the command chain.

Microsoft.VisualStudio.LanguageServices defines an internal AbstractOleCommandTarget which may be attached to IWpfTextViews.

If I were able to inherit from AbstractOleCommandTarget, I could properly set up the proper language services myself. I've already tested out a proof of concept in which I manually edited Microsoft.VisualStudio.LanguageServices.dll's "InternalsVisibleTo" property within the DLL. This allowed me to inherit from AbstractOleCommandTarget and properly set up Intellisense within the Visual Studio command chain.

Usage would be as follows:
class CustomOleCommandTarget : AbstractOleCommandTarget
{
    public CodeConnectOleCommandTarget(IWpfTextView textView
        ,ICommandHandlerServiceFactory commandFactory
        ,IVsEditorAdaptersFactoryService adapterFactory
        ,IServiceProvider provider) :base(textView, commandFactory, adapterFactory, provider)
    {
    }
}

public void AttachToIWpfTextView(IWpfTextView textView)
{
    var commandTarget = new CodeConnectOleCommandTarget(
                textView
                , this._commandFactory
                , this._editorFactoryService
                , this._serviceProvider);

    commandTarget.AttachToVsTextView();
}

comments

SSL wrote Nov 7, 2014 at 3:24 PM

This would also let me get rid of this utter horror (and key strokes for non-VS hosting.

Pilchie wrote Feb 17, 2015 at 1:24 AM

Want to re-file this over on GitHub, and consider a PR for it?

JoshVarty wrote Feb 17, 2015 at 5:37 AM