How does intellisense work in Visual Studio?

后端 未结 7 778
一个人的身影
一个人的身影 2020-12-19 02:35

I hope this is a valid question: how does intellisense work in VS2008? I\'m after what is known about the algorithm it uses to find the suggestions, when exactly it pops up

7条回答
  •  庸人自扰
    2020-12-19 02:40

    It's more fun to reverse-engineer it, though. Let's consider the problem:

    • you need to identify the words of interest
    • you need to find the options possible
    • you need to present them

    Now, the first step means you have to parse the code. You've got the C/C** keywords, you pre-parse the various function and class declarations, and load them into some kind of data structure. Then you parse the code and store the class, variable, etc names and put them in the same data structure.

    The second step means you want a data structure which efficiently can search for a partial word and get all the words that have that prefix. You can do that with regular expressions, but that's not very efficient. An efficient data structure for that kind of search is a trie, which is discussed here on SO .

    Once you have the list of possibilities, you just present it. You probably want to keep a reference to the root of the tree of possibilities so you can search them out in real time as someone types more letters.

提交回复
热议问题