I cannot say for sure which algorithms are used by any particular implementation, but I can make some reasonable assumptions. A trie is a very useful data structure for this problem: the IDE can support a large amount of memory for all characters in your project, with some additional metadata in each node.
When you enter a character, it jumps along the path to trie. All descendants of a particular trie node are possible completions. After that, the IDE just needs to filter out those that make sense in the current context, but just need to calculate as many as can be displayed in the tab completion popup window.
More advanced tab filling requires more sophisticated controls. For example, Visual Assist X has a function in which you only need to enter the capital letters of the CamelCase characters - for example, if you type SFN, this shows you the SomeFunctionName character in the tab completion window.
Computing trie (or other data structures) requires parsing all of your code to get a list of all the characters in your project. Visual Studio stores this in its IntelliSense database, the .ncb file that is stored next to your project, so it does not need to repeat everything every time you close and reopen your project. The first time you open a large project (say, one of which you only synchronized the control of the source code of the form), VS will take time to parse everything and generate a database.
I do not know how it handles incremental changes. As you said, when you write code, this syntax is invalid 90% of the time, and whenever you are idle, you get a huge tax on your processor for very little benefit, especially if you change the header file included in a large number of source files .
I suspect that it either (a) only reparations whenever you really build your project (or perhaps when you close / open it), or (b) it does some kind of local parsing where it only analyzes code where you are "We just edited in a limited way, just to get the names of the corresponding characters. Since C ++ has such an extremely complex grammar, it can behave strangely in dark corners if you use heavy template metaprogramming, etc. .
Adam Rosenfield Aug 02 '09 at 23:12 2009-08-02 23:12
source share