views:

116

answers:

1

I read the DIY Intellisense article on code project, which was referenced from the Mimic Intellisense? question here on SO.

I wanna do something similar, DIY intellisense, but for XPath not C#.

The design approach used there makes sense to me: maintain a tree of terms, and when the "completion character" is pressed, in the case of C#, a dot, pop up the list of possible completions in a textfield. Then allow the user to select a term from the textfield either through typing, arrow keys, or double-click.

How would you apply this to XPath autocompletion?

  1. should there be an autocomplete key? In XPath there is no obvious separator key like "dot" in C#. should the popup be triggered explicitly in some other way, let's say ctrl-. ? or should the parser try to autocomplete continuously?

  2. If I do the autocomplete continuously, how to scale it properly? There are 93 xpath functions, not counting overloads. I certainly don't want to popup a list of 93 choices. How do I decide when I've narrowed it enough to offer a useful lsit of possible completions?

  3. How to populate the tree of possible completions? For C#, it's easy: walk the type space via reflection. At a first level, the "syntax tree" for C# seems like a single tree, and the list of completions at any point depends on the graph of nodes you've traversed to that point. Typing System.Console. traverses to a certain node in that tree, and the list of completions is the set of child nodes available at that node in the tree. On the other hand, the xpath syntax seems like it is a "flatter" tree - function names, axis names, literals. Does this make sense?

  4. what have I not considered?

+1  A: 

Check out the RegexEditor http://editorsamples.codeplex.com/ this is a sample editor for regular expressions. it is a part of the VisualStudio 2010 Beta. I think that from the standpoint of the Intellisense approach it should be very similar to XPath. Also if you plan to implement it as VS Plug-in (Packagae, add-in, whatever) I would suggest considering doing it for VS2010 - it is order of magnitude easier to do it as MEF based editor extension

mfeingold