title: DIY intellisense on XPath - design approach? (WinForms app)
body: <p>I read the <a href="http://www.codeproject.com/KB/cs/diy-intellisense.aspx" rel="nofollow noreferrer">DIY Intellisense article on code project</a>, which was referenced from the <a href="https://stackoverflow.com/questions/1457961/mimic-intellisense">Mimic Intellisense?</a> question here on SO. </p>
  
  <p>I wanna do something similar, DIY intellisense, but for XPath not C#.  </p>
  
  <p>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.</p>
  
  <p>How would you apply this to XPath autocompletion? </p>
  
  <ol>
  <li><p>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?   </p></li>
  <li><p>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?</p></li>
  <li><p>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 <code>System.Console.</code> 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?</p></li>
  <li><p>what have I not considered?</p></li>
  </ol>