I'm using an XmlSyntaxLanguage with an XSD to provide automatic intellisense support - this is working very well.
For some attributes on some elements I'd like to define the Member List myself - it will be a dynamic list which isn't available until runtime (and can't be defined in the xsd file). The specific attribute value I'm trying to auto-complete is a very simple script which takes the name of a class and a function seperated by a dot, like this:
Geo.A()
Geo.B()
Geo.C()
Raiden.A()
Raiden.SomeOtherFunction()
These do have parameters, which would be nice to show some help on like:
Raiden.A(String name, Int32 age)
I'm not really sure if I'm on the right track, what I've done so far is pretty rudimentary.
I've made a new class which derives from XmlSyntaxLanguage, and overrides OnSyntaxEditorIntelliPromptMemberListPreFilter - I've then added some IntelliPromptMemberListItems like so:
protected override void OnSyntaxEditorIntelliPromptMemberListPreFilter(SyntaxEditor syntaxEditor, IntelliPromptMemberListPreFilterEventArgs e)
{
//TODO: Some filtering based on the TargetElement and TargetAttribute
IntelliPromptMemberListItem item = new IntelliPromptMemberListItem("Geo.A()", 0, "Geo runtime - The fantastic A method!");
e.Items.Add("Geo.A()",item);
item = new IntelliPromptMemberListItem("Geo.B()", 0, "Geo runtime - The awesome B method!");
e.Items.Add("Geo.B()", item);
item = new IntelliPromptMemberListItem("Geo.C()", 0, "Geo runtime - The amazing C method!");
e.Items.Add("Geo.C()", item);
item = new IntelliPromptMemberListItem("Raiden.A()", 0, "Raiden runtime - incredible A Method");
e.Items.Add("Raiden.A()", item);
item = new IntelliPromptMemberListItem("Raiden.B()", 0, "Raiden runtime - irresistable B Method");
e.Items.Add("Raiden.B()", item);
base.OnSyntaxEditorIntelliPromptMemberListPreFilter(syntaxEditor, e);
}
This code does show a list of members, and if I start typing then it highlights the item in the IntelliPrompt drop down, selecting the item populates the attribute value.
I'd like to do a few more things:
I'd like to just show the "class" names. Ie Geo, Raiden. Then when you press '.' the method names should be scoped to the class name I've put in.
I was thinking that I could filter the MemberList to just "Geo", and "Raiden" first, and then when '.' is pressed I'd somehow raise the IntelliPrompt again, but filter it with the method names, eg A(), B(), C(). But, I've found the following problems trying this approach -
- I've noticed that if the caret is not at the start of the attribute when the IntelliPrompt is invoked then the TargetAttribute of the IntelliPromptMemberListPreFilterEventArgs Context property is null.
- Also I don't know how to get the current contents of the current attribute value.
- Pressing '.' currently selects the current thing in the IntelliPrompt.
So perhaps I'm using the wrong approach.
Please can you advise me on the best way to do this? Or at least improve what I have now.
Thanks,
Daniel