1
Vote

Support for Type and Member dropdowns

description

It would be good get this working.

i have spent a couple of hours on this and have almost give up. IronPython does not support this, but the SDK documentation had an article, so I followed that but hit a few problems.

First you are supposed to override CreateDropDown helper on the languageService class:
for example like this:
    public override TypeAndMemberDropdownBars CreateDropDownHelper(IVsTextView forView)
    {
        var source = GetSource(forView);
        var request = CreateParseRequest(source, 1, 1, new TokenInfo(), source.GetText(), source.GetFilePath(), ParseReason.Check, forView);
        var project = GetProject(request);
        var compiledProject = project.GetCompiledProject();
        return new BooTypeAndMemberDropDownBars(this, compiledProject);
    }
And then you are supposed to return a class that inherits from TypeAndMemberDropDownBars. In this class you are supposed to override the function OnSynchronizeDropdowns. However if you override CreateDropDownHelper and have just a return S_OK in OnSynchronizeDropdowns, you get a managed stackoverflow exception. After hours I managed to track this down (or I think I have), to the equality operator on the DropDownMember class causing a stackoverflow, and the SDK framework is doing a if (member != null) check you get a stackoverflow.

I managed to work around this by overriding some more methods on TypeAndMemberDropDownBars (it was in these methods that the if (member != null) code was), so I by doing that I managed to get the dropdowns showing something. But then I got another problem, the OnSynchronizeDropdowns was not being called, so after a little googling you have to setup a Idle timer that calls the languageService OnIdle method, this timer is setup in the BooPackage class using some OleComponent trickery.

But then again when you change the the selected value in a dropdown the stackoverflow occurs again, that is probably because the method OnItemChosen in the base class TypeAndMemberDropDownBars is doing if (member != null) again (I checked this in reflector..) .

It seems such a hassle, and I am not sure if it is completely possible to work around this bug. I have submitted the bug on microsoft connect, hopefully they have already fixed it in SDK 1.1 (for VS 2008 SP1), because this bug has been mentioned by others on the visual studio extensibility forums.

comments

leppie wrote Oct 8, 2008 at 6:13 PM

I just did something with this for IronScheme. No serious issues. I am using SP1 and SDK 1.1. The example is pretty clear.

I do see however you are making another parse request, and this could be the cause if the infinite loop. var source should contain/be your AST root as it will be already parsed.

Send me a message if you are stuck.

jagregory wrote Oct 9, 2008 at 7:49 AM

Thanks leppie, we may very well do that when we come to tackle this again. Thanks for the comments.